Docs: Sync browseable samples for lmp-docs

Synced to developers/samples/android commit
bc036ecdf44cd03163c206096172299f3940b057.

Change-Id: Ib68230d79ca300e7db906aff2ebfc2cb6c6968f7
This commit is contained in:
Trevor Johns
2014-12-09 18:47:59 -08:00
parent 1ccf8350d5
commit abededd8f7
503 changed files with 8907 additions and 2690 deletions

View File

@@ -170,12 +170,12 @@ public class MainActivity extends Activity implements Handler.Callback {
}
private void updateTextEditors(NotificationPreset preset) {
mTitleEditText.setText(getString(preset.titleResId));
mTextEditText.setText(getString(preset.textResId));
if (preset == NotificationPresets.BASIC) {
findViewById(R.id.title_edit_field).setVisibility(View.VISIBLE);
mTitleEditText.setText(getString(preset.titleResId));
mTitleEditText.addTextChangedListener(mTextChangedListener);
findViewById(R.id.text_edit_field).setVisibility(View.VISIBLE);
mTextEditText.setText(getString(preset.textResId));
mTextEditText.addTextChangedListener(mTextChangedListener);
} else {
findViewById(R.id.title_edit_field).setVisibility(View.GONE);

View File

@@ -50,6 +50,7 @@ public class NotificationPresets {
public static final NotificationPreset CONTENT_ICON = new ContentIconNotificationPreset();
public static final NotificationPreset MULTIPLE_PAGE = new MultiplePageNotificationPreset();
public static final NotificationPreset BUNDLE = new NotificationBundlePreset();
public static final NotificationPreset BARCODE = new NotificationBarcodePreset();
public static final NotificationPreset[] PRESETS = new NotificationPreset[] {
BASIC,
@@ -62,7 +63,8 @@ public class NotificationPresets {
CONTENT_ACTION,
CONTENT_ICON,
MULTIPLE_PAGE,
BUNDLE
BUNDLE,
BARCODE
};
private static NotificationCompat.Builder applyBasicOptions(Context context,
@@ -476,4 +478,33 @@ public class NotificationPresets {
childBuilder2.build() };
}
}
private static class NotificationBarcodePreset extends NotificationPreset {
public NotificationBarcodePreset() {
super(R.string.barcode_example, R.string.barcode_content_title,
R.string.barcode_content_text);
}
@Override
public Notification[] buildNotifications(Context context, BuildOptions options) {
NotificationCompat.Builder secondPageBuilder = new NotificationCompat.Builder(context)
.extend(new NotificationCompat.WearableExtender()
.setHintShowBackgroundOnly(true)
.setBackground(BitmapFactory.decodeResource(context.getResources(),
R.drawable.qr_code))
.setHintAvoidBackgroundClipping(true)
.setHintScreenTimeout(
NotificationCompat.WearableExtender.SCREEN_TIMEOUT_LONG));
NotificationCompat.Builder firstPageBuilder = new NotificationCompat.Builder(context);
NotificationCompat.WearableExtender firstPageWearableOptions =
new NotificationCompat.WearableExtender();
applyBasicOptions(context, firstPageBuilder, firstPageWearableOptions, options);
firstPageBuilder.extend(
firstPageWearableOptions.addPage(secondPageBuilder.build()));
return new Notification[]{ firstPageBuilder.build() };
}
}
}