summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYvonne Wong <ywong@cyngn.com>2015-12-08 16:54:40 -0800
committerYvonne Wong <ywong@cyngn.com>2015-12-10 01:43:18 -0800
commit7600c7f3125a845ce6d4add4ceff90b884e1c033 (patch)
tree08bbde6eb2cf2da2a1b1d1a62d5dcbdf4d02f715
parent045e7db9f0add18e1d95b806417e40fd213de35e (diff)
downloadandroid_packages_apps_Trebuchet-7600c7f3125a845ce6d4add4ceff90b884e1c033.zip
android_packages_apps_Trebuchet-7600c7f3125a845ce6d4add4ceff90b884e1c033.tar.gz
android_packages_apps_Trebuchet-7600c7f3125a845ce6d4add4ceff90b884e1c033.tar.bz2
Reimplement CM Settings Overview Panel Part 5
- Enable default screen button - Make UI changes to settings panel - Add a broadcast receiver for hide/unhide search bar setting Change-Id: I849dd412231795b894e7af7ee575e60feb618c70
-rw-r--r--res/layout/settings_pane_list_header.xml6
-rw-r--r--res/layout/settings_pane_list_item.xml18
-rw-r--r--res/values/dimens.xml4
-rw-r--r--src/com/android/launcher3/Launcher.java46
-rw-r--r--src/com/android/launcher3/Workspace.java19
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java75
6 files changed, 124 insertions, 44 deletions
diff --git a/res/layout/settings_pane_list_header.xml b/res/layout/settings_pane_list_header.xml
index a7d04e3..8c35fb8 100644
--- a/res/layout/settings_pane_list_header.xml
+++ b/res/layout/settings_pane_list_header.xml
@@ -15,7 +15,7 @@
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="@dimen/overview_panel_list_header_height"
android:layout_gravity="center_horizontal|bottom"
android:background="@color/settings_bg_color"
android:paddingLeft="@dimen/overview_panel_list_padding"
@@ -27,8 +27,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="4dp"
- android:fontFamily="sans-serif-condensed"
+ android:fontFamily="sans-serif-medium"
android:gravity="left"
- android:textSize="16sp"
+ android:textSize="14sp"
android:textColor="@color/settings_header_text"/>
</RelativeLayout> \ No newline at end of file
diff --git a/res/layout/settings_pane_list_item.xml b/res/layout/settings_pane_list_item.xml
index 58b2de8..6c8c3c7 100644
--- a/res/layout/settings_pane_list_item.xml
+++ b/res/layout/settings_pane_list_item.xml
@@ -1,6 +1,6 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="@dimen/overview_panel_list_item_height"
android:layout_gravity="center_horizontal|bottom"
android:background="@drawable/listitem_bg"
android:paddingStart="@dimen/overview_panel_list_padding"
@@ -9,13 +9,21 @@
android:paddingTop="@dimen/overview_panel_list_padding"
android:orientation="horizontal" >
+ <Switch
+ android:id="@+id/setting_switch"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_alignParentEnd="true"
+ android:visibility="invisible"/>
+
<TextView
android:id="@+id/item_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="4dp"
- android:fontFamily="sans-serif-condensed"
- android:textSize="20sp"
+ android:fontFamily="sans-serif"
+ android:textSize="16sp"
android:textAllCaps="true"
android:textColor="@drawable/listitem_text"
android:layout_alignParentEnd="true"
@@ -28,8 +36,8 @@
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:drawablePadding="4dp"
- android:fontFamily="sans-serif-condensed"
- android:textSize="20sp"
+ android:fontFamily="sans-serif"
+ android:textSize="16sp"
android:textColor="@drawable/listitem_text"
android:layout_toStartOf="@id/item_state"
android:layout_alignParentStart="true"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d73bd33..44edfcb 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -172,11 +172,13 @@
<!-- Overview panel -->
<dimen name="sliding_panel_padding">175dp</dimen>
+ <dimen name="overview_panel_list_header_height">48dp</dimen>
+ <dimen name="overview_panel_list_item_height">56dp</dimen>
<dimen name="overview_panel_top_padding">20dp</dimen>
<dimen name="overview_panel_bottom_padding">50dp</dimen>
<dimen name="overview_panel_button_spacing">30dp</dimen>
<dimen name="overview_panel_list_padding">16dp</dimen>
<dimen name="overview_mode_page_offset">60dp</dimen>
<dimen name="overview_scaling_padding">50dp</dimen>
-
+
</resources>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3198c0f..729b994 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -108,6 +108,7 @@ import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.list.SettingsPinnedHeaderAdapter;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.settings.SettingsProvider;
import com.android.launcher3.util.ComponentKey;
@@ -369,6 +370,8 @@ public class Launcher extends Activity
// the press state and keep this reference to reset the press state when we return to launcher.
private BubbleTextView mWaitingForResume;
+ private long mDefaultScreenId;
+
public Animator.AnimatorListener mAnimatorListener = new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator arg0) {}
@@ -382,7 +385,7 @@ public class Launcher extends Activity
public void onAnimationCancel(Animator arg0) {}
};
- Runnable mUpdateDynamicGridRunnable = new Runnable() {
+ Runnable mReloadLauncherRunnable = new Runnable() {
@Override
public void run() {
reloadLauncher(mWorkspace.getRestorePage(), true, false);
@@ -393,7 +396,19 @@ public class Launcher extends Activity
@Override
public void onReceive(Context context, Intent intent) {
// Update the workspace
- if (waitUntilResume(mUpdateDynamicGridRunnable, true)) {
+ if (waitUntilResume(mReloadLauncherRunnable, true)) {
+ return;
+ }
+
+ reloadLauncher(mWorkspace.getRestorePage(), true, false);
+ }
+ };
+
+ private BroadcastReceiver searchBarVisibilityChangedReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // Update the workspace
+ if (waitUntilResume(mReloadLauncherRunnable, true)) {
return;
}
@@ -572,6 +587,10 @@ public class Launcher extends Activity
cyanogenmod.content.Intent.ACTION_PROTECTED_CHANGED);
registerReceiver(protectedAppsChangedReceiver, protectedAppsFilter,
cyanogenmod.platform.Manifest.permission.PROTECTED_APP, null);
+
+ IntentFilter searchBarVisibilityFilter = new IntentFilter(
+ SettingsPinnedHeaderAdapter.ACTION_SEARCH_BAR_VISIBILITY_CHANGED);
+ registerReceiver(searchBarVisibilityChangedReceiver, searchBarVisibilityFilter);
}
@Override
@@ -1788,6 +1807,8 @@ public class Launcher extends Activity
mHideIconLabels = SettingsProvider.getBoolean(this,
SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS,
R.bool.preferences_interface_homescreen_hide_icon_labels_default);
+ mDefaultScreenId = SettingsProvider.getLongCustomDefault(this,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID, 1);
mModel = app.setLauncher(this);
mIconCache = app.getIconCache();
@@ -1829,7 +1850,6 @@ public class Launcher extends Activity
mWorkspace.updateCustomContentVisibility();
mSearchDropTargetBar.setupQsb(this);
- mSearchDropTargetBar.setVisibility(View.INVISIBLE);
if (reloadAppDrawer) {
reloadAppDrawer();
@@ -2313,6 +2333,7 @@ public class Launcher extends Activity
}
unregisterReceiver(protectedAppsChangedReceiver);
+ unregisterReceiver(searchBarVisibilityChangedReceiver);
}
public DragController getDragController() {
@@ -3097,7 +3118,24 @@ public class Launcher extends Activity
protected void onClickDefaultScreenButton(View v) {
if (LOGD) Log.d(TAG, "onClickDefaultScreenButton");
- // TODO
+
+ if (!mWorkspace.isInOverviewMode()) return;
+
+ mDefaultScreenId = mWorkspace.getScreenIdForPageIndex(mWorkspace.getPageNearestToCenterOfScreen());
+ updateDefaultScreenButton();
+ SettingsProvider.get(this).edit()
+ .putLong(SettingsProvider.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID,
+ mDefaultScreenId)
+ .commit();
+ }
+
+ protected void updateDefaultScreenButton() {
+ if (mOverviewPanel != null) {
+ View defaultPageButton = mOverviewPanel.findViewById(R.id.default_screen_button);
+ defaultPageButton.setActivated(
+ mWorkspace.getScreenIdForPageIndex(mWorkspace.getPageNearestToCenterOfScreen())
+ == mDefaultScreenId);
+ }
}
public View.OnTouchListener getHapticFeedbackTouchListener() {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 59c870a..09a0a98 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -574,6 +574,11 @@ public class Workspace extends PagedView
mScreenOrder.add(insertIndex, screenId);
addView(newScreen, insertIndex);
+ if (getDefaultScreenId() == screenId) {
+ int defaultPage = getPageIndexForScreenId(screenId);
+ moveToScreen(defaultPage, false);
+ }
+
LauncherAccessibilityDelegate delegate =
LauncherAppState.getInstance().getAccessibilityDelegate();
if (delegate != null && delegate.isInAccessibleDrag()) {
@@ -1546,6 +1551,10 @@ public class Workspace extends PagedView
super.computeScroll();
if (mScrollWallpaper) mWallpaperOffset.syncWithScroll();
+
+ if (isInOverviewMode() && !isReordering(true)) {
+ mLauncher.updateDefaultScreenButton();
+ }
}
@Override
@@ -1985,6 +1994,9 @@ public class Workspace extends PagedView
// Re-enable auto layout transitions for page deletion.
enableLayoutTransitions();
+
+ // Show the default screen button
+ mLauncher.updateDefaultScreenButton();
}
public boolean isInOverviewMode() {
@@ -4436,7 +4448,7 @@ public class Workspace extends PagedView
}
void moveToDefaultScreen(boolean animate) {
- moveToScreen(mDefaultPage, animate);
+ moveToScreen(getPageIndexForScreenId(getDefaultScreenId()), animate);
}
void moveToCustomContentScreen(boolean animate) {
@@ -4521,6 +4533,11 @@ public class Workspace extends PagedView
}
}
+ private long getDefaultScreenId() {
+ return SettingsProvider.getLongCustomDefault(mLauncher,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID, 1);
+ }
+
/**
* Used as a workaround to ensure that the AppWidgetService receives the
* PACKAGE_ADDED broadcast before updating widgets.
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index 034fd49..505b6b4 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -12,6 +12,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.android.launcher3.InvariantDeviceProfile;
@@ -22,6 +23,9 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.settings.SettingsProvider;
public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
+ public static final String ACTION_SEARCH_BAR_VISIBILITY_CHANGED =
+ "cyanogenmod.intent.action.SEARCH_BAR_VISIBILITY_CHANGED";
+
private Launcher mLauncher;
private Context mContext;
@@ -59,9 +63,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
protected void bindHeaderView(View view, int partition, Cursor cursor) {
TextView textView = (TextView) view.findViewById(R.id.item_name);
textView.setText(mHeaders[partition]);
- textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
-
- textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
}
@Override
@@ -73,15 +74,19 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
@Override
protected void bindView(View v, int partition, Cursor cursor, int position) {
- TextView text = (TextView)v.findViewById(R.id.item_name);
+ TextView nameView = (TextView)v.findViewById(R.id.item_name);
+ TextView stateView = (TextView)v.findViewById(R.id.item_state);
+ Switch settingSwitch = (Switch)v.findViewById(R.id.setting_switch);
+ settingSwitch.setClickable(false);
+
// RTL
Configuration config = mLauncher.getResources().getConfiguration();
if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
- text.setGravity(Gravity.RIGHT);
+ nameView.setGravity(Gravity.RIGHT);
}
String title = cursor.getString(1);
- text.setText(title);
+ nameView.setText(title);
v.setTag(new SettingsPosition(partition, position));
@@ -97,9 +102,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
current = SettingsProvider.getBoolean(mContext,
SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
R.bool.preferences_interface_homescreen_search_default);
- state = current ? res.getString(R.string.setting_state_on)
- : res.getString(R.string.setting_state_off);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setSettingSwitch(stateView, settingSwitch, current);
break;
case 1:
current = SettingsProvider.getBoolean(mContext,
@@ -107,21 +110,19 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_homescreen_hide_icon_labels_default);
state = current ? res.getString(R.string.icon_labels_hide)
: res.getString(R.string.icon_labels_show);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setStateText(stateView, settingSwitch, state);
break;
case 2:
current = SettingsProvider.getBoolean(mContext,
SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
- state = current ? res.getString(R.string.setting_state_on)
- : res.getString(R.string.setting_state_off);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setSettingSwitch(stateView, settingSwitch, current);
break;
case 3:
updateDynamicGridSizeSettingsItem(v);
break;
default:
- ((TextView) v.findViewById(R.id.item_state)).setText("");
+ hideStates(stateView, settingSwitch);
}
break;
case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION:
@@ -132,7 +133,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_drawer_hide_icon_labels_default);
state = current ? res.getString(R.string.icon_labels_hide)
: res.getString(R.string.icon_labels_show);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setStateText(stateView, settingSwitch, state);
break;
case 1:
current = SettingsProvider.getBoolean(mContext,
@@ -140,7 +141,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_drawer_compact_default);
state = current ? res.getString(R.string.app_drawer_style_compact)
: res.getString(R.string.app_drawer_style_sections);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setStateText(stateView, settingSwitch, state);
break;
case 2:
current = SettingsProvider.getBoolean(mContext,
@@ -148,7 +149,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_drawer_dark_default);
state = current ? res.getString(R.string.app_drawer_color_dark)
: res.getString(R.string.app_drawer_color_light);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setStateText(stateView, settingSwitch, state);
break;
case 3:
current = SettingsProvider.getBoolean(mContext,
@@ -156,24 +157,22 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_use_horizontal_scrubber_default);
state = current ? res.getString(R.string.fast_scroller_type_horizontal)
: res.getString(R.string.fast_scroller_type_vertical);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setStateText(stateView, settingSwitch, state);
break;
default:
- ((TextView) v.findViewById(R.id.item_state)).setText("");
+ hideStates(stateView, settingSwitch);
}
break;
- default:
+ case OverviewSettingsPanel.APP_SETTINGS_POSITION:
switch (position) {
case 0:
current = SettingsProvider.getBoolean(mContext,
SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
R.bool.preferences_interface_general_icons_large_default);
- state = current ? res.getString(R.string.setting_state_on)
- : res.getString(R.string.setting_state_off);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ setSettingSwitch(stateView, settingSwitch, current);
break;
default:
- ((TextView) v.findViewById(R.id.item_state)).setText("");
+ hideStates(stateView, settingSwitch);
}
}
@@ -234,7 +233,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
switch (position) {
case 0:
updateSearchBarVisibility(v);
- mLauncher.reloadLauncher(false, false);
break;
case 1:
onIconLabelsBooleanChanged(v,
@@ -282,7 +280,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
break;
}
break;
- default:
+ case OverviewSettingsPanel.APP_SETTINGS_POSITION:
switch (position) {
case 0:
onSettingsBooleanChanged(v,
@@ -320,6 +318,9 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
onSettingsBooleanChanged(v,
SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
R.bool.preferences_interface_homescreen_search_default);
+
+ Intent intent = new Intent(ACTION_SEARCH_BAR_VISIBILITY_CHANGED);
+ mContext.sendBroadcast(intent);
}
private void onSettingsBooleanChanged(View v, String key, int res) {
@@ -330,10 +331,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
SettingsProvider.putBoolean(mContext, key, !current);
SettingsProvider.putBoolean(mContext, SettingsProvider.SETTINGS_CHANGED, true);
- String state = current ? mLauncher.getResources().getString(
- R.string.setting_state_off) : mLauncher.getResources().getString(
- R.string.setting_state_on);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ ((Switch)v.findViewById(R.id.setting_switch)).setChecked(!current);
}
private void onIconLabelsBooleanChanged(View v, String key, int res) {
@@ -391,4 +389,21 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.string.fast_scroller_type_horizontal);
((TextView) v.findViewById(R.id.item_state)).setText(state);
}
+
+ private void setStateText(TextView stateView, Switch settingSwitch, String state) {
+ stateView.setText(state);
+ stateView.setVisibility(View.VISIBLE);
+ settingSwitch.setVisibility(View.INVISIBLE);
+ }
+
+ private void setSettingSwitch(TextView stateView, Switch settingSwitch, boolean isChecked) {
+ settingSwitch.setChecked(isChecked);
+ settingSwitch.setVisibility(View.VISIBLE);
+ stateView.setVisibility(View.INVISIBLE);
+ }
+
+ private void hideStates(TextView stateView, Switch settingSwitch) {
+ settingSwitch.setVisibility(View.INVISIBLE);
+ stateView.setVisibility(View.INVISIBLE);
+ }
} \ No newline at end of file