As of now, Google Glass GDK API has no Progress Bar view. So I extracted this from GlassHome.apk (from https://github.com/zhuowei/Xenologer).
Progress & indeterminate slider:
Message dialog with success sound:
- Progress bar, which is used by all native apps.
- Supports default progress.
- Supports indeterminate progress.
- Supports MessageDialog with success sound found in Glass apps.
- Add this library project to your project.
- (optional) override progress bar height in your own
res/values/dimens.xml
--><dimen name="slider_bar_height">12.0px</dimen>
- (optional) override message dialog background dimming in
res/values/dimens.xml
--><item type="dimen" name="background_dim_amount">0.75</item>
- Add progress bar view to your layout:
<com.google.glass.widget.SliderView
android:id="@+id/indeterm_slider"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
- Start it from activity:
mIndeterm.startIndeterminate();
mProgress.startProgress(10 * 1000); // progress which lasts 10 seconds
- Use it in code:
MessageDialog localDialog = new MessageDialog.Builder(ctx)
.setTemporaryIcon(R.drawable.ic_sync_50)
.setTemporaryMessage(R.string.dlg_temp_message)
.setTemporarySecondaryMessage(R.string.dlg_temp_secondary_message)
.setIcon(R.drawable.ic_done_50)
.setMessage(R.string.dlg_message)
.setSecondaryMessage(R.string.dlg_secondary_message)
.setDismissable(true)
.setAutoHide(true)
.setListener(new MessageDialog.SimpleListener() {
public boolean onConfirmed() {
Log.d(TAG, "onConfirm");
Toast.makeText(ctx, "onConfirmed", Toast.LENGTH_LONG).show();
return true;
}
public void onDismissed() {
Log.d(TAG, "onDismissed");
Toast.makeText(ctx, "onDismissed", Toast.LENGTH_LONG).show();
}
public void onDone() {
Log.d(TAG, "onDone");
Toast.makeText(ctx, "onDone", Toast.LENGTH_LONG).show();
}
}).build();
localDialog.show();
Look in testwithlibrary
folder.
Google Glass is in Explorer Stage. That's why I tried to find the answer to this SO question http://stackoverflow.com/questions/20237873/google-glass-gdk-progress-indicator and a workaround for this issue https://code.google.com/p/google-glass-api/issues/detail?id=271
This is just for educational purposes and should not be used in any production apps until Google releases something similar officially.
I hope, Google will publish a set of Google Glass Views in the future releases of GDK. We really need them! Especially that awesome progress bar!