Google Glass GDK: Progress Indicator? - google-glass

Using the GDK (or in some other way), is there a way to display a progress indicator similar to the one displayed when connecting to a WiFi network on Glass? (the "spinning" lines on the bottom of the display, kind of like at the end of this video: https://www.youtube.com/watch?v=g3ncmeGaKN0)
Thanks!

UPD 04.11.2014: Google released Slider -- UX component suitable for this. You should better use it instead of the extracted project.
I've extracted Google Glass Progress Bar from GlassHome.apk and created a library project based on that: https://github.com/pif/glass-progress-bar
supports indeterminate
supports default progress
Usage is described in README in the repository.
And yes, everyone is still waiting for a full-featured set of Glass Views.
Update: I extracted MessageDialog as well. You can find it in the same library.

This issue is resolved by google with Slider (global UX Components) https://developers.google.com/glass/develop/gdk/slider

This comes pretty close, but the color is off (blue/teal/whatever instead of white).
style="?android:attr/progressBarStyleHorizontal"
Sample (via OkGlassFindACat):
<ProgressBar
android:id="#+id/someProgressBar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
I definitely haven't figured out how to override that color, though.

I know I'm late but here's my version :)
https://github.com/prt2121/glass-gdk-progressbar
adding to your project in the gradle file
compile 'com.github.prt2121:ProgressBar:1.0#aar'
screenshot:
changing color
app:progress_color="#android:color/holo_blue_bright"

The GDK overrides themes for some widgets automatically to provide a proper Glass-like appearance, such as TextView. For widgets that don't yet have that theming, please file an issue here so that we can track it.

I put together the answer above to create a general layout for my card-list loader activities. Here's the layout file card_scroll_with_progress_layout.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/black">
<com.google.android.glass.widget.CardScrollView
android:id="#+id/card_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="#+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
</FrameLayout>
Then in the onCreate I get the progress bar and set it rolling:
View rootLayout = getLayoutInflater()
.inflate(R.layout.card_scroll_with_progress_layout, null);
mProgressBar = (ProgressBar)rootLayout.findViewById(R.id.progress_bar);
mProgressBar.setVisibility(View.VISIBLE);
mCardScrollView = (CardScrollView)rootLayout
.findViewById(R.id.card_scroll_view);
mCardScrollView.setAdapter(mAdapter);
setContentView(rootLayout);
Later on in my loader callback I hide the progress bar and activate the card scroll view:
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (loader.getId() == mLoaderId) {
mAdapter.swapCursor(data);
mProgressBar.setVisibility(View.GONE);
mCardScrollView.activate();
}
}
This seems to be working well as a paradigm for handling various json loading into a list of cards in the GDK.

We have been having a similar issue and found a hybrid approach that works for us. We use the standard progress bar #patridge mentioned in a previous post and applied generated Holo styles provided by Android Holo Colors.
We were able to generate a white progress bar images, animation, layer and style that looks very similar to the built in GDK version. You can increase the height of the bar to match the GDK by editing the size of Holo Color's generated png images.
You will need the generated files included in your project, but here is what our theme looks like afterwards:
<style name="OurGlassTheme" parent="#android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
<item name="android:progressBarStyleHorizontal">#style/ProgressBarGlass</item>
</style>
<style name="ProgressBarGlass" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:progressDrawable">#drawable/glass_progress_horizontal_holo_light</item>
<item name="android:indeterminateDrawable">#drawable/glass_progress_indeterminate_horizontal_holo_light</item>
<item name="android:minHeight">16dip</item>
<item name="android:maxHeight">16dip</item>
</style>
I know it's super tedious, but it gets us there while #giladgo 's accepted submission to the Glass developers to provide a GDK Progress Bar is finished.

Try to use ProgressBar from zoom-in project.

Related

MSHTML editing - changing the text selection color

I use MSHTML (TWebBrowser control) in Design (edit) mode. I use TEmbeddedWB but slowly moving away from that component and implementing my own interface. When a block of text is selected, so when typing into the editor and then selecting a block of text it is in black color for the background color.
Instead I'd like to use blue.
I know that it has something to do with the selection range but not sure how to modify it in designer mode. The code below is of course when it is not in design mode.
IHTMLSelectionObject currentSelection = document.selection;
IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;
if (range != null)
{
range.execCommand("BackColor", false, "0000FF");
}
Any ideas? Do I have to use event sinking? Or maybe QueryCommandValue? I tried some things with HiliteColor without success yet (according to Mozilla documentation this is not supported by Internet Explorer).
I use C++ Builder or Delphi, but code example in any language is welcome, I can (probably) translate it.

How to eliminate TabLayout scroll jumping (skipping) in Android TV when there are more than 64 tabs?

I’m trying to implement tab navigation in my Android TV app using TabLayout. There are many tabs so I have enabled “scrollable” mode.
When I'm trying to navigate through the tabs (from left to right) using remote control the tab indicator does not move to the very next tab but jumps far to the right, and again and again until it reaches some position. After this position is reached, tab indicator start moving normally.
I have experimented a little and found that this abnormal scrolling behavior appears only when number of tabs in TabLayout is more than 64
First I met this problem with TabHost and changed my code to use TabLayout, but problem persists.
I have played with all relevant options with different combinations but nothing worked.
Below is the fragment of my layout file
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="#color/black_opaque"
android:fillViewport="true"
android:measureAllChildren="true"
android:nestedScrollingEnabled="false"
android:padding="2dp"
app:tabGravity="center"
app:tabMode="scrollable"
app:tabTextAppearance="#style/TextAppearance.AppCompat.Medium" />
<GridView
android:id="#+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
I have recorded the video to show how it looks like:
scroll_skipping.mp4
What do I missing? How to configure TabLayout to avoid such behavior?
Finally I couldn’t find any solution, it looks like bug or TabLayout limitation.
So I have changed the layout and did what I need with ListView.
Conclusion - TabLayout is for limited number of tabs, no more than 64, less is better.

Create window without title bar

I am trying to create a simple panel for Openbox in Arch Linux using c++, but I cannot figure out how to remove the title bar from a window.
I am creating the window with XCreateWindow(...), and that gives a window with the correct size, but it contains a title bar, and the window also opens in the top-left corner of the screen, no matter what offset coordinates I specify.
I read here that both of these problems are probably caused by the window manager (Openbox), which overrides the window attributes I specified in XCreateWindow(..., &window_attributes). This could be solved by adding window_attributes.override_redirect = True;, although this does not seem to do anything for me. When I try this I get the exact same window as before. (I did compile the file after this change.)
Also I read into the code of Tint2 (link), which is another panel for Openbox. They create a window using the following code:
XSetWindowAttributes att = { .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att);
I don't see an override_redirect anywhere in their code, so I'm not sure how they are removing the title bar.
As additional information, I thought it would be worth mentioning how I'm executing the script:
/* The c++ file is saved as 'panel.cpp' */
$ gcc panel.cpp -lX11 -o panel
$ ./panel
Also, I am running Arch Linux through VirtualBox with Windows 8 as host. I'm not sure if this changes anything, but it won't hurt to mention.
Since I found the solution, I figured I'd post the solution here if anyone else needs it.
As #JoachimPileborg mentioned, I needed to alter the Openbox settings in ~/.config/openbox/rc.xml. Inside the <applications> tag, I added the following code:
<application class="*">
<decor>no</decor>
<position force="no"></position>
</application>
The class="*" means that all applications will follow these rules, you could fill in the class name of the application instead. The <decor>no</decor> removes the title bar, and <position force="no"></position> ensures that my own script is able to handle the positioning. You could also add another <application> tag after this one to make exceptions to this rule.
Also, the window_attributes.override_redirect = True; is not needed anymore.
A more correct way is to use the Extended Window Manager Hints.
The idea is that you don't tell the window manager how to decorate or not your window, you just indicate the window type with _NET_WM_WINDOW_TYPE :
Atom window_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
long value = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DOCK", False);
XChangeProperty(display, your_window, window_type,
XA_ATOM, 32, PropModeReplace, (unsigned char *) &value,1 );
"Dock" is the type for panels and taskbar. Usually they are undecorated and appear on all desktops. As written on the documentation, previously the _MOTIF_WM_HINTS property was used to define the appearance and decorations of the window. Window managers still support it, but _NET_WM_WINDOW_TYPE is prefered as it describe the function and let the window manager (and user) decide on the appearance and behavior of that type of window.
Another interesting property for a panel is _NET_WM_STRUT_PARTIAL, to "reserve" space.

Unit testing android listview scrolling using Roboelectric

I have a method that attempts to programatically scroll to a position in a ListView. The method has some conditionals so that its implementation differs slightly based on the Android SDK version the app is running on.
The functionality works fine on 3 android devices that I have tested on. However, I have written a unit test using junit and Roboelectric that checks if the scrolling has made the the item at the target position visible. The test fails. When I debug, I notice that android.os.Build.VERSION.SDK_INT is 0 when running with Roboelectric (i.e., on the desktop vs. device or emulator).
I've tried ignoring the version and just using ListView.smoothScrollToPosition(), but the getFirstVisilePoition() and getLastVisiblePosition() methods continue to return 0, even immediately after I call smoothScrollToPosition(150).
Does anyone know if/how scrolling a listview can be tested using Roboelectric?
Any help would be appreciated - I can't seem to find any information on the topic.
Thanks,
Ana
If you're using robolectric 1.1 or 1.2, here is the source for the AbsListView:
https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowAbsListView.java
It looks like all the scrolling functionality is it ShadowAdapterView:
https://github.com/pivotal/robolectric/blob/master/src/main/java/com/xtremelabs/robolectric/shadows/ShadowAdapterView.java
It doesn't look like getFirstVisiblePoition() or getLastVisiblePosition() are implemented.
I was able to get the smooth scroll position.
#RunWith(RobolectricTestRunner.class)
public class SmoothScroll {
#Test
public void testSmoothScroll() {
Activity context = new Activity();
ListView view = new ListView(context);
view.smoothScrollToPosition(100);
Assert.assertEquals(100, Robolectric.shadowOf(view).getSmoothScrolledPosition());
}
}
You can get the smooth scrolled position. Based on the height of the elements, you may be able to work out which ones are visible.

wxPython - how to colour the text of a statusbar

I searched for the answer in the forum, but I didn't find anything, if I am wrong, I am sorry.
Anyway, question is simple, I have this Frame, with a Status Bar I use to print messages or notifies.
I would like to use it for mistakes or not permitted operations. But I would like these messages to be coloured. I am looking for a solution on wxPython demo -because i read somewhere on the web to get some inspirations by it-, but i still did not find anything.
Do you have any ideas or solutions?
thank you in advance.
I would try the SetForegroundColour or SetBackgroundColour methods of the status bar widget. These methods don't always work on every platform though as each OS has its own rules and wxPython follows those rules. If they do not work, then you'll have to roll your own statusbar, probably by using a couple of panels in a sizer or a splitter window.
There is also the 3rd party EnhancedStatusbar widget which might work for you. It can be found at http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html
Simple solution: pin wx.StaticText on the status bar and write text in it. Text coloring in wx.StaticText works well.
For example:
self.sb = self.ws.CreateStatusBar()
self.sbtext = wx.StaticText(self.sb, -1, '', pos=(8, 4))
...
self.sbtext.SetForegroundColour(wx.Colour(color))
self.sbtext.SetLabel(text)