Related
I am trying to create a popup message in the Backoffice PCM. In particular, from within the editor area of a product. From the editor a user can click on the assortment view or compare view buttons on the side toolbar to change screens (redirect).
I want to give the user a popup to inform them that any changes will be lost.
Any ideas on how to accomplish this?
I have tried to create my own widget and wiring my custom widget to the ootb pcmbackoffice-toolbar but have not been successful.
It's possible to display a simple popup via the ZK framework (the framework used by Backoffice). From the backoffice code you can open a popup like this:
import org.zkoss.zul.Messagebox;
public void someMethod() {
// do some actions...
Messagebox.show("Some Messagetext", "Info", Messagebox.OK, Messagebox.INFO);
}
I have written an Espresso test that fails (matching view not found).
Example:
onView((allOf(withText("OK"), hasSibling(withText("Text"))))).perform(click());
The error I get is:
androidx.test.espresso.NoMatchingViewException: No views in hierarchy found
matching: (with text: is "OK" and has sibling: with text: is "Text")
If the target view is not part of the view hierarchy, you may need to use
Espresso.onData to load it from one of the following
AdapterViews:androidx.appcompat.widget.AppCompatSpinner{da0caf9 VFED..CL.
........ 273,0-505,48 #7f0901c1 app:id/structure_formation_spinner}
View Hierarchy:
....
Then the view hierarchy is displayed. The problem is that in Android Studio, the hierarchy is truncated to 32K characters.
I know how to fix the returned error, this is not my problem.
My question is: How can I see the full view hierarchy ?
Is it possible in Android Studio?
If not, is it possible from the command line?
Since the test is executed on the Device/Emulator, exception with the full message (view hierarchy is just a message, attached to NoMatchingViewException) can be obtained from Logcat (i.e. Logcat window in the Android Studio). Filter E/TestRunner simplifies the search.
Logcat itself is not unlimited though. Default size is 1024KB. It can be changed via Settings | Editor | General | Console
TL;DR;
Android Studio and Android Device/Emulator communicate via protobuf messages. Data from the device arrives to com.android.ddmlib.testrunner.InstrumentationProtoResultParser#updateState in the form of key-value map (collection of InstrumentationData.ResultsBundleEntry).
Instrumented Test Results view in Android Studio only displays stackTrace. You can convince yourself by adding println("hello") anywhere in the instrumented test. The line will only appear in the Logcat, and not in the Test Result view.
stackTrace is obtained from the map by key StatusKeys.STACK (see ln 239). Unfortunately, data already arrives truncated at this point. There is STREAM key which contains the full text, but it is not used. So the problem is on device side which failed to send complete stacktrace, IMO.
Other runners (e.g., gradle, when running from console) may use different values from that map. This explains why you see full message when running from console.
The only way I have found is to launch the test in a "terminal" window.
Then the full hierarchy is displayed (around 300K chars in my case)
You can also checkout Radiography by Square. It will help you to print the view hierachy in the logs.
I am writing a new better version of my old Android project that will fix a lot of UI bugs but also has a better design, needed for integration of some new features.
As I go through the source I can see all my old and new TODOs in the source, but there are things I remember and forget I want to do in the future and don't fit in any source yet.
Eclipse had a simple list of Tasks in the project on which you could write down and track all bug fixes and new features you wanted for that project. Very handy!
Is there a way add such tasks/issues/notes/todos in Android Studio in the project in general, WITHOUT adding them at a specific place in the sources?
To add a ToDo, just comment anywhere in your code starting with the word ToDo
//Todo: Get count from database instead
To view the list of ToDos, look in the bottom left corner of your Android Studio window:
if you open it, you will get this view with the list of your todos and options to navigate to files where they are located in your project:
go to View -> Tool Windows -> TODO to display the TODO panel
Anything marked
// TODO
should be visible in the list panel
Edit:
You can add plugins for task management in Intellij 14
https://www.jetbrains.com/idea/help/managing-tasks-and-context.html
I've not used them as our workflow is outside the IDE and I can't comment on whether they will work as intended in Android Studio.
Here's how I do this: I create a text file called "TaskList.txt". I put it in the java/res package. (Not necessarily appropriate for this package, but I haven't felt like creating a package just for this purpose.)
Like any code file, you can start a line with
//TODO
and the IDE will recognize it as one of your tasks. You can have dozens or hundreds of TODO's in this file. And, of course, you can still have TODO's embedded in your code files, closely-associated with the code you need to update/correct.
My TaskList.txt TODO's show up in Android Studio's TODO view (bottom-left corner of the IDE or View -> Tool Windows -> TODO) along with all my embedded TODO's.
In order to set check points for yourself inside the android studio project, you may do it as:
In Java File:
// TODO: I am waiting for you to be fixed ;)
OR
//FIXME: fix me before release :)
In XML File:
<!-- TODO! Hey I am here down in XML -->
some one above commented that todo is not working inside xml file so it is for them.
You can view them in your android studio window of TODOs:
and all todos from your project will be listed like:
You can use either of TODO, FIXME, etc. but it's not possible to do that without using them inline in your code. use them as follow:
{
...
some code //FIXME
...
}
or
{
...
some code //TODO
...
}
Here's a cheat sheet for some popular IDEs:
IntelliJ IDEA-based IDEs (e.g. Android Studio): TODO, FIXME
Visual Studio: HACK, TODO, UNDONE and NOTE.
Eclipse: #todo, FIXME, TODO and XXX.
Netbeans: TODO and FIXME
Code::Blocks: At least TODO.
Rider: TODO and BUG
Android Studio: TODO and FIXME
P.S. feel free to edit this answer by adding your fav IDE comment
tokens.
Write (todo) after than press tab key
According to this link, you can define all of your own comment tags (TODO, FIXME, OPTIMIZE, OPTIONAL, etc).
Android Studio -> Settings/Preferences -> Editor -> TODO
Red - Add your own patterns using the \bpattern\b* format
Green - Add custom filters. These filters show up in the filter list at the bottom of Android Studio on the TODO tab.
EDIT better use Alternative to avoid app crash
Alternative: You could write it like this: //TODO: "your todo here", and it'll also appear on TODO tool windows
In Android Studio (I'm using v2020.3.1), you could do (... = your normal codes):
...
TODO("your todo here")
...
TODO comment example
TODO comment example alternative
It will show up on the TODO tool windows (View -> Tool Windows -> TODO)
Todo lists window
Todo lists alternative window
NOTE: It could cause your app to crash if your code read it as a function call (Error code/function not implemented yet)
In Android Studio under the Tools menu there is the option for Tasks&Contexts. You can manually add tasks (i.e the todo's you want to perform for your project). It is quite simple, just add a task title, a VCS branch name and changelist, so might not suit your needs. Follow this link to learn more.
My favorite way is like the following:
<!-- //TODO: Poczytać o rodzaja Layoutow -->
//todo works as well for java in android studio.
No need for capitalization.
This will make your ease
<!-- TODO: Update blank fragment layout -->
I found this plugin
https://plugins.jetbrains.com/plugin/14966-todo4me
You can keep track of local work without add a //todo comment.
Sometimes as you said, you just need to keep track of small tasks and you don't want to use tools like jira.
Per the question here,
What's "tools:context" in Android layout files?
The 'tools' namespace reference (xmlns:tools="http://schemas.android.com/tools") has begun to appear in my layouts recently, and I want to know more. The original post only described the 'tools:context' attribute, but I have also noticed usage of the "tools:listitem" attribute appearing when I have designated a preview layout item for a listview, i.e.
<ListView
android:id="#+id/lvCustomer"
tools:listitem="#layout/customer_list_item" >
</ListView>
Are there more elements?
What brought me to this 'tools' namespace is that I want to be able to have 'preview-only' text (i.e. in a TextView or EditText) when using the layout designer in eclipse.
Currently, I assign the 'text' or 'hint' property for previewing text when arranging my layouts... but then I always have to remember to clear the preview value from within the code.
Ideally, instead of
<string name="preview_customer_name">Billy Bob's Roadhouse Pub</string>
...
<TextView
android:id="#+id/tvCustomerName"
android:text="#string/preview_customer_name"
</TextView>
have a something like:
<TextView
android:id="#+id/tvCustomerName"
tools:previewText="#string/preview_customer_name"
</TextView>
Thanks-
We've just added support for designtime attributes like this in Android Studio 0.2.11. See http://tools.android.com/tips/layout-designtime-attributes for more.
Think of them as design time helpers only.They do not get processed in actual view rendering at run time.
For example you want to set background of some view in your layout design when working on android studio so that you can make clear distinction where that particular view is.So you would normally do that with
android:background="#color/<some-color>"
Now risk is that sometimes we forget to remove that color and it gets shipped in apk.
instead you can do as follows:
tools:background="#color/<some-color>"
These changes will be local to android studio and will never get transferred to apk.
And also check out http://tools.android.com/tech-docs/tools-attributes for more options.
You will find tool attribute when you set object in graphical layout.
Listview (in graphical mode) -> right Click -> Preview List Content -> Choose Layout...
produces:
tools:listitem="#layout/customer_list_item"
See in layout XML below. There are 2 namespace in use "xmlns:android" and "xmlns:tools".
Tools namespace is used when the developer wants to define placeholder content that is only used in preview or in design time. Tools namespace is removed when we compiled the app.
So in the code below, I want to show the placeholder image (image_empty) that will only be visible at design time, and image1 will the actual image that will be shown when the application launch
I am trying to do this:
public class DialogMenuHawaii extends Dialog {
Style s = UiFactory.getBaseStyle();
s.setBgTransparency(0);
s.setBgImage( <my image >);
this.setUnselectedStyle(s);
}
but it doesn't work.
First, I suggest you use a theme. We constantly change small implementation details e.g. customizations like the one you are doing will not be portable between LWUIT 1.4 and 1.5. There is no reason whatsoever not to use a theme for something like this.
If you are interested in the pain and suffering of manually coding view logic into your application you can use several methods such as getDialogComponent() to get the style from them and manipulate that. Dialog is a complex beast due to the fact that its really a form padded away from the edges.
Open your '.res' file in resource Editor and select your preferred theme,
Under 'Unselected' tab open the DialogContentPane style, if you don't have one create it look at the end of this answer on HOW TO DO IT?, and set the background image to the image you need to show as Dialog bg
Under 'Unselected' tab open the DialogBody style, if you don't have one create it look at the end of this answer on HOW TO DO IT?, and set the background transparency as '0' and also make sure the background image type is NONE
NOTE: The above code will reflect for all the Dialogs in your application. If you want a particular dialog with background image than derive new styles from these default styles, and follow the above steps to apply it to your DialogMenuHawaii or any runtime Dialogs.
HOW TO: I would recommend you to go through the Shai's blog posts LWUIT Resource Editor Tutorial Part 1 till part 10. To better understand the Resouce Editor its features and capabilities.
:
:
:
PS: Programmatic-ally i haven't been able to achieve it using TextArea which is the case for default Dialog's. If you replace the dialog body component with Label if works fine, the code sample is given below. I haven't delved much into why is it so ? maybe will do it in my free time. Hence i have proposed a working alternative solution which is scripted above using Resource Editor and below using the code
class MyDialog extends Dialog {
public void show() {
Container octnPane = this.getDialogComponent();
octnPane.getUnselectedStyle().setBgTransparency(0, false);
Container ctnPane = (Container)((BorderLayout)octnPane.getLayout()).getCenter();
ctnPane.getUnselectedStyle().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED, false);
ctnPane.getUnselectedStyle().setBgImage(myImage, false);
Label t = new Label("Dialog");
t.setUIID("DialogBody");
t.getUnselectedStyle().setBgTransparency(0, false);
ctnPane.addComponent(t);
super.show();
}
}
This is for Dialog background.
Dialog dialog = new Dialog();
dialog.getDialogStyle().setBgImage(Image.createImage("/image/image.png"));
If you want to set transparency of Dialog with image.
dialog.getStyle().setBgImage(Image.createImage("/image/image.png");