Improvements to system UI demos.

- Content browser now lets you long press to go into selection mode.
- Overscan demo has more options for controlling more window state.

Change-Id: I04cfb58f515882cc6dccd65cb68bc073e53dcad5
This commit is contained in:
Dianne Hackborn
2012-05-06 12:44:34 -07:00
parent a8863a9614
commit f5d3a23dee
3 changed files with 136 additions and 14 deletions

View File

@@ -66,26 +66,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFFFF"
android:textSize="16dp"
android:textStyle="bold"
android:text="LOW_PROFILE"
/>
<CheckBox
android:id="@+id/modeFullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:textColor="#FFFFFFFF"
android:textSize="16dp"
android:textStyle="bold"
android:text="FULLSCREEN"
/>
<CheckBox
android:id="@+id/modeHideNavigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:textColor="#FFFFFFFF"
android:textSize="16dp"
android:textStyle="bold"
android:text="HIDE_NAVIGATION"
/>
</LinearLayout>
@@ -93,7 +89,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
android:baselineAligned="true"
>
@@ -118,26 +113,77 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFFFF"
android:textSize="16dp"
android:textStyle="bold"
android:text="STABLE"
/>
<CheckBox
android:id="@+id/layoutFullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:textColor="#FFFFFFFF"
android:textSize="16dp"
android:textStyle="bold"
android:text="FULLSCREEN"
/>
<CheckBox
android:id="@+id/layoutHideNavigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:textColor="#FFFFFFFF"
android:text="HIDE_NAVIGATION"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:baselineAligned="true"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#FFFFFFFF"
android:textSize="16dp"
android:textStyle="bold"
android:gravity="left"
android:text="Window:"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:baselineAlignedChildIndex="0"
>
<CheckBox
android:id="@+id/windowFullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFFFF"
android:text="FULLSCREEN"
/>
<CheckBox
android:id="@+id/windowHideActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:textColor="#FFFFFFFF"
android:text="Hide ActionBar"
/>
<CheckBox
android:id="@+id/windowActionMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-10dp"
android:textColor="#FFFFFFFF"
android:text="Action Mode"
/>
<!-- Crappy hack to make these the same size as the
above groups. You'd never do this in real code. -->
<CheckBox
android:layout_width="wrap_content"
android:layout_height="0dp"
android:textColor="#FFFFFFFF"
android:text="HIDE_NAVIGATION"
/>
</LinearLayout>

View File

@@ -74,8 +74,8 @@ public class ContentBrowserActivity extends Activity
mText = new TextView(context);
mText.setText(context.getString(R.string.alert_dialog_two_buttons2ultra_msg));
mText.setClickable(false);
mText.setLongClickable(false);
mText.setOnClickListener(this);
mText.setTextIsSelectable(true);
addView(mText, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

View File

@@ -26,6 +26,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
@@ -54,6 +55,7 @@ public class OverscanActivity extends Activity
implements OnQueryTextListener, ActionBar.TabListener {
public static class IV extends ImageView implements View.OnSystemUiVisibilityChangeListener {
private OverscanActivity mActivity;
private ActionMode mActionMode;
public IV(Context context) {
super(context);
}
@@ -71,6 +73,44 @@ public class OverscanActivity extends Activity
@Override
public void onSystemUiVisibilityChange(int visibility) {
mActivity.updateCheckControls();
mActivity.refreshSizes();
}
private class MyActionModeCallback implements ActionMode.Callback {
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.setTitle("My Action Mode!");
mode.setSubtitle(null);
mode.setTitleOptionalHint(false);
menu.add("Sort By Size").setIcon(android.R.drawable.ic_menu_sort_by_size);
menu.add("Sort By Alpha").setIcon(android.R.drawable.ic_menu_sort_alphabetically);
return true;
}
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return true;
}
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return true;
}
@Override public void onDestroyActionMode(ActionMode mode) {
mActionMode = null;
mActivity.clearActionMode();
}
}
public void startActionMode() {
if (mActionMode == null) {
ActionMode.Callback cb = new MyActionModeCallback();
mActionMode = startActionMode(cb);
}
}
public void stopActionMode() {
if (mActionMode != null) {
mActionMode.finish();
}
}
}
@@ -137,6 +177,38 @@ public class OverscanActivity extends Activity
for (int i=0; i<mCheckControls.length; i++) {
mCheckControls[i].setOnCheckedChangeListener(checkChangeListener);
}
((CheckBox) findViewById(R.id.windowFullscreen)).setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setFullscreen(isChecked);
}
}
);
((CheckBox) findViewById(R.id.windowHideActionBar)).setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
getActionBar().hide();
} else {
getActionBar().show();
}
}
}
);
((CheckBox) findViewById(R.id.windowActionMode)).setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
mImage.startActionMode();
} else {
mImage.stopActionMode();
}
}
}
);
mMetricsText = (TextView) findViewById(R.id.metricsText);
}
@@ -228,4 +300,8 @@ public class OverscanActivity extends Activity
}
mImage.setSystemUiVisibility(visibility);
}
public void clearActionMode() {
((CheckBox) findViewById(R.id.windowActionMode)).setChecked(false);
}
}