Dream settings: list items back to constant height
Expanding/collapsing items removed, settings icon shown on right with divider if applicable. New "Start" action on the action bar to start dreaming. This is no longer in preview/test mode, but a call to .dream(). Bug: 7010260 Change-Id: Ia1d8b9a70218dcc598bf62befbf545f572bbc6b1
This commit is contained in:
@@ -13,19 +13,20 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:divider="?android:attr/dividerHorizontal"
|
||||
android:orientation="vertical"
|
||||
android:showDividers="middle" >
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<!-- Dream selectable row (icon, caption, radio button) -->
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@android:id/summary"
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true" >
|
||||
android:layout_toLeftOf="@+id/divider"
|
||||
android:background="?android:attr/selectableItemBackground" >
|
||||
|
||||
<!-- Dream icon -->
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/icon"
|
||||
@@ -37,18 +38,14 @@
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:contentDescription="@null"
|
||||
android:maxHeight="@android:dimen/app_icon_size"
|
||||
android:maxWidth="@android:dimen/app_icon_size"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@android:id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:duplicateParentState="true" />
|
||||
<!-- Dream caption -->
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/text1"
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
@@ -57,41 +54,43 @@
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<!-- Dream radio button -->
|
||||
|
||||
<RadioButton
|
||||
android:id="@android:id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:duplicateParentState="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" >
|
||||
<!-- Divider -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="?android:attr/dividerVertical"
|
||||
android:dividerPadding="12dp"
|
||||
android:showDividers="middle" >
|
||||
<ImageView
|
||||
android:id="@id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@android:id/button2"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/nav_divider" />
|
||||
|
||||
<Button
|
||||
<!-- Settings icon -->
|
||||
|
||||
<ImageView
|
||||
android:id="@android:id/button2"
|
||||
style="@android:style/Widget.ActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/screensaver_settings_dream_settings"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="12dp" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignBottom="@android:id/widget_frame"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@android:id/widget_frame"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_margin="0dip"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:contentDescription="@null"
|
||||
android:padding="8dip"
|
||||
android:src="@drawable/ic_bt_config" />
|
||||
|
||||
<Button
|
||||
android:id="@android:id/button3"
|
||||
style="@android:style/Widget.ActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/screensaver_settings_dream_preview"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="12dp" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
@@ -1717,10 +1717,8 @@
|
||||
<string name="screensaver_settings_start_dreaming">Start dreaming now</string>
|
||||
<!-- Dream settings screen, action label, when to dream -->
|
||||
<string name="screensaver_settings_when_to_dream">When to dream</string>
|
||||
<!-- Dream settings screen, button label to launch dream settings -->
|
||||
<string name="screensaver_settings_dream_settings">Settings</string>
|
||||
<!-- Dream settings screen, button label to preview dream -->
|
||||
<string name="screensaver_settings_dream_preview">Preview</string>
|
||||
<!-- Dream settings screen, button label to start dreaming -->
|
||||
<string name="screensaver_settings_dream_start">Start</string>
|
||||
<!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions -->
|
||||
<string name="automatic_brightness">Automatic brightness</string>
|
||||
<!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
|
||||
|
@@ -16,9 +16,9 @@
|
||||
|
||||
package com.android.settings;
|
||||
|
||||
import static android.provider.Settings.Secure.SCREENSAVER_ENABLED;
|
||||
import static android.provider.Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK;
|
||||
import static android.provider.Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP;
|
||||
import static android.provider.Settings.Secure.SCREENSAVER_ENABLED;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -183,6 +183,17 @@ public class DreamBackend {
|
||||
}
|
||||
}
|
||||
|
||||
public void startDreaming() {
|
||||
logd("startDreaming()");
|
||||
if (mDreamManager == null)
|
||||
return;
|
||||
try {
|
||||
mDreamManager.dream();
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Failed to dream", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static ComponentName getDreamComponentName(ResolveInfo resolveInfo) {
|
||||
if (resolveInfo == null || resolveInfo.serviceInfo == null)
|
||||
return null;
|
||||
|
@@ -27,7 +27,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -41,7 +40,6 @@ import android.view.View.OnClickListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
@@ -66,7 +64,7 @@ public class DreamSettings extends SettingsPreferenceFragment {
|
||||
private DreamBackend mBackend;
|
||||
private DreamInfoAdapter mAdapter;
|
||||
private Switch mSwitch;
|
||||
private MenuItem mWhenToDream;
|
||||
private MenuItem[] mMenuItemsWhenEnabled;
|
||||
private boolean mRefreshing;
|
||||
|
||||
@Override
|
||||
@@ -133,19 +131,33 @@ public class DreamSettings extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
logd("onCreateOptionsMenu()");
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
boolean isEnabled = mBackend.isEnabled();
|
||||
|
||||
mWhenToDream = createMenuItem(menu,
|
||||
R.string.screensaver_settings_when_to_dream,
|
||||
// create "start" action
|
||||
MenuItem start = createMenuItem(menu, R.string.screensaver_settings_dream_start,
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS,
|
||||
isEnabled, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
mBackend.startDreaming();
|
||||
}});
|
||||
|
||||
// create "when to dream" overflow menu item
|
||||
MenuItem whenToDream = createMenuItem(menu,
|
||||
R.string.screensaver_settings_when_to_dream,
|
||||
MenuItem.SHOW_AS_ACTION_NEVER,
|
||||
isEnabled,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showDialog(DIALOG_WHEN_TO_DREAM);
|
||||
}});
|
||||
|
||||
// create "help" overflow menu item (make sure it appears last)
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
mMenuItemsWhenEnabled = new MenuItem[] { start, whenToDream };
|
||||
}
|
||||
|
||||
private MenuItem createMenuItem(Menu menu,
|
||||
@@ -242,8 +254,9 @@ public class DreamSettings extends SettingsPreferenceFragment {
|
||||
List<DreamInfo> dreamInfos = mBackend.getDreamInfos();
|
||||
mAdapter.addAll(dreamInfos);
|
||||
}
|
||||
if (mWhenToDream != null)
|
||||
mWhenToDream.setEnabled(dreamsEnabled);
|
||||
if (mMenuItemsWhenEnabled != null)
|
||||
for (MenuItem menuItem : mMenuItemsWhenEnabled)
|
||||
menuItem.setEnabled(dreamsEnabled);
|
||||
mRefreshing = false;
|
||||
}
|
||||
|
||||
@@ -252,7 +265,6 @@ public class DreamSettings extends SettingsPreferenceFragment {
|
||||
Log.d(TAG, args == null || args.length == 0 ? msg : String.format(msg, args));
|
||||
}
|
||||
|
||||
|
||||
private class DreamInfoAdapter extends ArrayAdapter<DreamInfo> {
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
@@ -272,7 +284,7 @@ public class DreamSettings extends SettingsPreferenceFragment {
|
||||
((ImageView) row.findViewById(android.R.id.icon)).setImageDrawable(dreamInfo.icon);
|
||||
|
||||
// bind caption
|
||||
((TextView) row.findViewById(android.R.id.text1)).setText(dreamInfo.caption);
|
||||
((TextView) row.findViewById(android.R.id.title)).setText(dreamInfo.caption);
|
||||
|
||||
// bind radio button
|
||||
RadioButton radioButton = (RadioButton) row.findViewById(android.R.id.button1);
|
||||
@@ -284,24 +296,17 @@ public class DreamSettings extends SettingsPreferenceFragment {
|
||||
return false;
|
||||
}});
|
||||
|
||||
// bind button container
|
||||
View widgetFrame = row.findViewById(android.R.id.widget_frame);
|
||||
widgetFrame.setVisibility(dreamInfo.isActive ? View.VISIBLE : View.GONE);
|
||||
// bind settings button + divider
|
||||
boolean showSettings = dreamInfo.settingsComponentName != null;
|
||||
View settingsDivider = row.findViewById(R.id.divider);
|
||||
settingsDivider.setVisibility(showSettings ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
// bind settings button
|
||||
Button settingsButton = (Button) row.findViewById(android.R.id.button2);
|
||||
settingsButton.setVisibility(dreamInfo.settingsComponentName != null ? View.VISIBLE : View.GONE);
|
||||
ImageView settingsButton = (ImageView) row.findViewById(android.R.id.button2);
|
||||
settingsButton.setVisibility(showSettings ? View.VISIBLE : View.INVISIBLE);
|
||||
settingsButton.setOnClickListener(new OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mBackend.launchSettings((DreamInfo)row.getTag());
|
||||
}});
|
||||
|
||||
// bind preview button
|
||||
((Button) row.findViewById(android.R.id.button3)).setOnClickListener(new OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mBackend.preview((DreamInfo)row.getTag());
|
||||
mBackend.launchSettings((DreamInfo) row.getTag());
|
||||
}});
|
||||
|
||||
return row;
|
||||
|
Reference in New Issue
Block a user