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