summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaj Yengisetty <rajesh@cyngn.com>2014-08-13 01:01:13 (GMT)
committerMatt Garnes <matt@cyngn.com>2014-08-15 17:17:53 (GMT)
commit562b36032fa60424ca974c0985046f5587f2e8e4 (patch)
treef954a80e51b2740931ca7078d5411de40026ce6c
parent277cfe5d91b4594ba3155d0d2917b9d20b7d3684 (diff)
downloadandroid_packages_apps_Trebuchet-562b36032fa60424ca974c0985046f5587f2e8e4.zip
android_packages_apps_Trebuchet-562b36032fa60424ca974c0985046f5587f2e8e4.tar.gz
android_packages_apps_Trebuchet-562b36032fa60424ca974c0985046f5587f2e8e4.tar.bz2
Settings adapter should use the position and partition values
Fixes: https://jira.cyanogenmod.org/browse/BACON-587 Change-Id: Ie935c51ea1e68eaa7da64b23eaf2ae28a630a3bb
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java8
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java300
2 files changed, 168 insertions, 140 deletions
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index 497e7ca..4381b91 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -22,6 +22,7 @@ public class OverviewSettingsPanel {
"com.android.settings.Settings$ThemeSettingsActivity";
public static final int HOME_SETTINGS_POSITION = 0;
public static final int DRAWER_SETTINGS_POSITION = 1;
+ public static final int APP_SETTINGS_POSITION = 2;
private Launcher mLauncher;
private View mOverviewPanel;
@@ -75,9 +76,10 @@ public class OverviewSettingsPanel {
mSettingsAdapter.addPartition(false, true);
mSettingsAdapter.mPinnedHeaderCount = headers.length;
- mSettingsAdapter.changeCursor(0, createCursor(headers[0], mValues));
- mSettingsAdapter.changeCursor(1, createCursor(headers[1], valuesDrawer));
- mSettingsAdapter.changeCursor(2, createCursor(headers[2], valuesApp));
+ mSettingsAdapter.changeCursor(HOME_SETTINGS_POSITION, createCursor(headers[0], mValues));
+ mSettingsAdapter.changeCursor(DRAWER_SETTINGS_POSITION, createCursor(headers[1],
+ valuesDrawer));
+ mSettingsAdapter.changeCursor(APP_SETTINGS_POSITION, createCursor(headers[2], valuesApp));
mListView.setAdapter(mSettingsAdapter);
}
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index a4a68fb..b09d1d7 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -10,7 +10,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
-import android.widget.Toast;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.OverviewSettingsPanel;
@@ -22,9 +21,22 @@ import android.view.View.OnClickListener;
import android.content.SharedPreferences;
public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
+ private static final int PARTITION_TAG = 0;
+ private static final int POSITION_TAG = 1;
+
private Launcher mLauncher;
private Context mContext;
+ class SettingsPosition {
+ int partition = 0;
+ int position = 0;
+
+ SettingsPosition (int partition, int position) {
+ this.partition = partition;
+ this.position = position;
+ }
+ }
+
public SettingsPinnedHeaderAdapter(Context context) {
super(context);
mLauncher = (Launcher) context;
@@ -67,81 +79,88 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
String title = cursor.getString(1);
text.setText(title);
+ v.setTag(new SettingsPosition(partition, position));
+
Resources res = mLauncher.getResources();
- if (title.equals(res
- .getString(R.string.home_screen_search_text))) {
- boolean current = mLauncher.isSearchBarEnabled();
- String 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);
- } else if (title.equals(res
- .getString(R.string.drawer_sorting_text))) {
- updateDrawerSortSettingsItem(v);
- } else if (title.equals(res
- .getString(R.string.scroll_effect_text)) &&
- partition == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION) {
- String state = mLauncher.getAppsCustomizeTransitionEffect();
- state = mapEffectToValue(state);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
- } else if (title.equals(res
- .getString(R.string.scroll_effect_text)) &&
- partition == OverviewSettingsPanel.HOME_SETTINGS_POSITION) {
- String state = mLauncher.getWorkspaceTransitionEffect();
- state = mapEffectToValue(state);
- ((TextView) v.findViewById(R.id.item_state)).setText(state);
- } else if (title.equals(res
- .getString(R.string.larger_icons_text))) {
- boolean current = SettingsProvider
- .getBoolean(
- mContext,
- SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
- R.bool.preferences_interface_general_icons_large_default);
- String 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);
- } else if (title.equals(res
- .getString(R.string.icon_labels)) &&
- partition == OverviewSettingsPanel.HOME_SETTINGS_POSITION) {
- boolean current = mLauncher.shouldHideWorkspaceIconLables();
- String 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);
- } else if (title.equals(res
- .getString(R.string.icon_labels)) &&
- partition == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION) {
- boolean current = SettingsProvider
- .getBoolean(
- mContext,
- SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
- R.bool.preferences_interface_drawer_hide_icon_labels_default);
- String 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);
- } else if (title.equals(res
- .getString(R.string.search_screen_left_text))) {
- updateSearchPanelItem(v);
- } else if (title.equals(res.getString(R.string.scrolling_wallpaper))) {
- boolean current = SettingsProvider
- .getBoolean(
- mContext,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
- R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
- String 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);
- } else if (title.equals(res.getString(R.string.grid_size_text))) {
- updateDynamicGridSizeSettingsItem(v);
- } else {
- ((TextView) v.findViewById(R.id.item_state)).setText("");
+ boolean current = false;
+ String state = "";
+
+ switch (partition) {
+ case OverviewSettingsPanel.HOME_SETTINGS_POSITION:
+ switch (position) {
+ case 0:
+ current = mLauncher.isSearchBarEnabled();
+ 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);
+ break;
+ case 1:
+ updateSearchPanelItem(v);
+ break;
+ case 2:
+ state = mLauncher.getWorkspaceTransitionEffect();
+ state = mapEffectToValue(state);
+ ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ break;
+ case 3:
+ current = mLauncher.shouldHideWorkspaceIconLables();
+ 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);
+ break;
+ case 4:
+ 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);
+ break;
+ case 5:
+ updateDynamicGridSizeSettingsItem(v);
+ break;
+ default:
+ ((TextView) v.findViewById(R.id.item_state)).setText("");
+ }
+ break;
+ case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION:
+ switch (position) {
+ case 0:
+ state = mLauncher.getAppsCustomizeTransitionEffect();
+ state = mapEffectToValue(state);
+ ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ break;
+ case 1:
+ updateDrawerSortSettingsItem(v);
+ break;
+ case 2:
+ current = SettingsProvider.getBoolean(mContext,
+ SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
+ 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);
+ break;
+ default:
+ ((TextView) v.findViewById(R.id.item_state)).setText("");
+ }
+ break;
+ default:
+ 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);
+ break;
+ default:
+ ((TextView) v.findViewById(R.id.item_state)).setText("");
+ }
}
- v.setTag(partition);
v.setOnClickListener(mSettingsItemListener);
}
@@ -246,71 +265,78 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
String value = ((TextView) v.findViewById(R.id.item_name)).getText().toString();
Resources res = mLauncher.getResources();
- // Handle toggles or launch pickers
- if (value.equals(res
- .getString(R.string.home_screen_search_text))) {
- onSettingsBooleanChanged(
- v,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
- R.bool.preferences_interface_homescreen_search_default);
- mLauncher.setUpdateDynamicGrid();
- } else if (value.equals(res
- .getString(R.string.drawer_sorting_text))) {
- onClickTransitionEffectButton();
- } else if (value.equals(res
- .getString(R.string.scroll_effect_text)) &&
- ((Integer)v.getTag() == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION)) {
- mLauncher.onClickTransitionEffectButton(v, true);
- } else if (value.equals(res
- .getString(R.string.scroll_effect_text)) &&
- ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) {
- mLauncher.onClickTransitionEffectButton(v, false);
- } else if (value.equals(res
- .getString(R.string.larger_icons_text))) {
- onSettingsBooleanChanged(
- v,
- SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
- R.bool.preferences_interface_general_icons_large_default);
- mLauncher.setUpdateDynamicGrid();
- } else if (value.equals(res
- .getString(R.string.icon_labels)) &&
- ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) {
- onIconLabelsBooleanChanged(
- v,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS,
- R.bool.preferences_interface_homescreen_hide_icon_labels_default);
- mLauncher.setUpdateDynamicGrid();
- } else if (value.equals(res
- .getString(R.string.icon_labels)) &&
- ((Integer)v.getTag() == OverviewSettingsPanel.DRAWER_SETTINGS_POSITION)) {
- onIconLabelsBooleanChanged(
- v,
- SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
- R.bool.preferences_interface_drawer_hide_icon_labels_default);
- mLauncher.setUpdateDynamicGrid();
- } else if (value.equals(res.getString(R.string.protected_app_settings))) {
- Intent intent = new Intent();
- intent.setClassName(OverviewSettingsPanel.ANDROID_SETTINGS,
- OverviewSettingsPanel.ANDROID_PROTECTED_APPS);
- mLauncher.startActivity(intent);
- } else if (value.equals(res
- .getString(R.string.scrolling_wallpaper))) {
- onSettingsBooleanChanged(
- v,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
- R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
- mLauncher.setUpdateDynamicGrid();
- } else if (value.equals(res
- .getString(R.string.search_screen_left_text)) &&
- ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) {
- onClickSearchPanelButton();
- boolean customContentEnabled =
- mLauncher.getCustomContentMode() != Launcher.CustomContentMode.DISABLED;
- mLauncher.getWorkspace().updatePageScrollForCustomPage(customContentEnabled);
- mLauncher.setUpdateDynamicGrid();
- } else if (value.equals(res
- .getString(R.string.grid_size_text))) {
- mLauncher.onClickDynamicGridSizeButton();
+ int partition = ((SettingsPosition) v.getTag()).partition;
+ int position = ((SettingsPosition) v.getTag()).position;
+
+ switch (partition) {
+ case OverviewSettingsPanel.HOME_SETTINGS_POSITION:
+ switch (position) {
+ case 0:
+ onSettingsBooleanChanged(v,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH,
+ R.bool.preferences_interface_homescreen_search_default);
+ mLauncher.setUpdateDynamicGrid();
+ break;
+ case 1:
+ onClickSearchPanelButton();
+ boolean customContentEnabled = mLauncher.getCustomContentMode()
+ != Launcher.CustomContentMode.DISABLED;
+ mLauncher.getWorkspace().updatePageScrollForCustomPage(
+ customContentEnabled);
+ mLauncher.setUpdateDynamicGrid();
+ break;
+ case 2:
+ mLauncher.onClickTransitionEffectButton(v, false);
+ break;
+ case 3:
+ onIconLabelsBooleanChanged(v,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS,
+ R.bool.preferences_interface_homescreen_hide_icon_labels_default);
+ mLauncher.setUpdateDynamicGrid();
+ break;
+ case 4:
+ onSettingsBooleanChanged(v,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
+ R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
+ mLauncher.setUpdateDynamicGrid();
+ break;
+ case 5:
+ mLauncher.onClickDynamicGridSizeButton();
+ break;
+
+ }
+ break;
+ case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION:
+ switch (position) {
+ case 0:
+ mLauncher.onClickTransitionEffectButton(v, true);
+ break;
+ case 1:
+ onClickTransitionEffectButton();
+ break;
+ case 2:
+ onIconLabelsBooleanChanged(v,
+ SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
+ R.bool.preferences_interface_drawer_hide_icon_labels_default);
+ mLauncher.setUpdateDynamicGrid();
+ break;
+ }
+ break;
+ default:
+ switch (position) {
+ case 0:
+ onSettingsBooleanChanged(v,
+ SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
+ R.bool.preferences_interface_general_icons_large_default);
+ mLauncher.setUpdateDynamicGrid();
+ break;
+ case 1:
+ Intent intent = new Intent();
+ intent.setClassName(OverviewSettingsPanel.ANDROID_SETTINGS,
+ OverviewSettingsPanel.ANDROID_PROTECTED_APPS);
+ mLauncher.startActivity(intent);
+ break;
+ }
}
View defaultHome = mLauncher.findViewById(R.id.default_home_screen_panel);