From 45936b33b0e03b1f3111a0bfaa61344cd10b2cd1 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 2 Apr 2014 20:02:43 +0200 Subject: Add options to hide icon labels from drawer and homescreen Forward port from CM 10.2 PS3: Fix typo PS4: Rebase and global defaults PS8: Rebase to head Issue: There is already an Icon section in general, move both settings there or leave separate in their categories? Change-Id: I90ae4d2357e5f45fa9261c4eaa0fcf287996e327 --- res/values/cm_strings.xml | 4 ++++ res/values/preferences_defaults.xml | 2 ++ res/xml/preferences_drawer.xml | 6 ++++++ res/xml/preferences_homescreen.xml | 4 ++++ .../android/launcher3/AppsCustomizePagedView.java | 4 ++++ src/com/android/launcher3/CellLayout.java | 9 +++----- src/com/android/launcher3/Folder.java | 18 +++++++++++----- src/com/android/launcher3/Launcher.java | 21 ++++++++++-------- src/com/android/launcher3/PagedViewIcon.java | 25 +++++++++++++++++++++- src/com/android/launcher3/Workspace.java | 12 +++++++---- .../launcher3/settings/SettingsProvider.java | 2 ++ 11 files changed, 82 insertions(+), 25 deletions(-) diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 73598a571..7f5de470f 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -52,6 +52,8 @@ Homescreen Search bar Show persistent search bar at top of screen + Hide icon labels + Hide icon labels on homescreen Drawer @@ -63,6 +65,8 @@ Remove the shortcuts of hidden apps from the homescreen Remove widgets Remove the widgets of hidden apps from the homescreen + Hide icon labels + Hide icon labels in drawer Dock diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml index daf28a3de..676b174a2 100644 --- a/res/values/preferences_defaults.xml +++ b/res/values/preferences_defaults.xml @@ -5,10 +5,12 @@ true @bool/config_workspaceDefaultShowOutlines @bool/config_workspaceFadeAdjacentScreens + true stack false true true + true @bool/config_largeIcons sans-serif-condensed 0 diff --git a/res/xml/preferences_drawer.xml b/res/xml/preferences_drawer.xml index c59d6b7fe..b22597516 100644 --- a/res/xml/preferences_drawer.xml +++ b/res/xml/preferences_drawer.xml @@ -33,4 +33,10 @@ android:summary="@string/preferences_interface_drawer_hidden_apps_widgets_summary" android:defaultValue="@bool/preferences_interface_drawer_remove_hidden_apps_widgets_default" /> + + + \ No newline at end of file diff --git a/res/xml/preferences_homescreen.xml b/res/xml/preferences_homescreen.xml index 8b2652b9a..4671a8a4a 100644 --- a/res/xml/preferences_homescreen.xml +++ b/res/xml/preferences_homescreen.xml @@ -22,4 +22,8 @@ android:title="@string/preferences_interface_homescreen_search_title" android:summary="@string/preferences_interface_homescreen_search_summary" android:defaultValue="@bool/preferences_interface_homescreen_search_default" /> + diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index 0cc540436..7e67f7c60 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -1114,11 +1114,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen layout.removeAllViewsOnPage(); ArrayList items = new ArrayList(); ArrayList images = new ArrayList(); + boolean hideIconLabels = SettingsProvider.getBoolean(mLauncher, + SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS, + R.bool.preferences_interface_drawer_hide_icon_labels_default); for (int i = startIndex; i < endIndex; ++i) { AppInfo info = mFilteredApps.get(i); PagedViewIcon icon = (PagedViewIcon) mLayoutInflater.inflate( R.layout.apps_customize_application, layout, false); icon.applyFromApplicationInfo(info, true, this); + icon.setTextVisibility(!hideIconLabels); icon.setOnClickListener(this); icon.setOnLongClickListener(this); icon.setOnTouchListener(this); diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index dafb79ffc..dc2db8773 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -35,7 +35,6 @@ import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.NinePatchDrawable; import android.os.Parcelable; import android.util.AttributeSet; import android.util.Log; @@ -48,7 +47,6 @@ import android.view.animation.Animation; import android.view.animation.DecelerateInterpolator; import android.view.animation.LayoutAnimationController; -import com.android.launcher3.R; import com.android.launcher3.FolderIcon.FolderRingAnimator; import java.util.ArrayList; @@ -198,7 +196,7 @@ public class CellLayout extends ViewGroup { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0); mCellWidth = mCellHeight = -1; - mFixedCellHeight = mFixedCellHeight = -1; + mFixedCellWidth = mFixedCellHeight = -1; mWidthGap = mOriginalWidthGap = 0; mHeightGap = mOriginalHeightGap = 0; mMaxGap = Integer.MAX_VALUE; @@ -606,9 +604,8 @@ public class CellLayout extends ViewGroup { final LayoutParams lp = params; // Hotseat icons - remove text - if (child instanceof BubbleTextView) { - BubbleTextView bubbleChild = (BubbleTextView) child; - bubbleChild.setTextVisibility(!mIsHotseat); + if (mIsHotseat && child instanceof BubbleTextView) { + ((BubbleTextView) child).setTextVisibility(false); } child.setScaleX(getChildrenScale()); diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index 1a25760ae..1fcfa1173 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -31,9 +31,7 @@ import android.text.InputType; import android.text.Selection; import android.text.Spannable; import android.util.AttributeSet; -import android.util.DisplayMetrics; import android.util.Log; -import android.util.TypedValue; import android.view.ActionMode; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -43,8 +41,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.Interpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; @@ -52,6 +48,7 @@ import android.widget.ScrollView; import android.widget.TextView; import com.android.launcher3.FolderInfo.FolderListener; +import com.android.launcher3.settings.SettingsProvider; import java.util.ArrayList; import java.util.Collections; @@ -195,6 +192,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); mAutoScrollHelper = new FolderAutoScrollHelper(mScrollView); + + if (SettingsProvider.getBoolean(mLauncher, + SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, + R.bool.preferences_interface_homescreen_hide_icon_labels)) { + mFolderName.setVisibility(View.GONE); + mFolderNameHeight = getPaddingBottom(); + } } private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() { @@ -270,7 +274,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList // Convert to a string here to ensure that no other state associated with the text field // gets saved. String newTitle = mFolderName.getText().toString(); - mInfo.setTitle(newTitle); + if (!SettingsProvider.getBoolean(mLauncher, + SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, + R.bool.preferences_interface_homescreen_hide_icon_labels)) { + mInfo.setTitle(newTitle); + } LauncherModel.updateItemInDatabase(mLauncher, mInfo); if (commit) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 620071460..29618422d 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -50,9 +50,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; -import android.content.res.TypedArray; import android.database.ContentObserver; -import android.database.DataSetObserver; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Point; @@ -96,15 +94,9 @@ import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.InputMethodManager; - -import android.widget.AbsListView; -import android.widget.AdapterView; import android.widget.Advanceable; -import android.widget.ArrayAdapter; import android.widget.FrameLayout; -import android.widget.GridView; import android.widget.ImageView; -import android.widget.ListAdapter; import android.widget.PopupMenu; import android.widget.TextView; import android.widget.Toast; @@ -123,7 +115,6 @@ import java.io.IOException; import java.io.PrintWriter; import java.text.DateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -345,6 +336,9 @@ public class Launcher extends Activity private HideFromAccessibilityHelper mHideFromAccessibilityHelper = new HideFromAccessibilityHelper(); + // Preferences + private boolean mHideIconLabels; + private Runnable mBuildLayersRunnable = new Runnable() { public void run() { if (mWorkspace != null) { @@ -395,6 +389,10 @@ public class Launcher extends Activity LauncherAppState.setApplicationContext(getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); + mHideIconLabels = SettingsProvider.getBoolean(this, + SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, + R.bool.preferences_interface_homescreen_hide_icon_labels); + // Determine the dynamic grid properties Point smallestSize = new Point(); Point largestSize = new Point(); @@ -1482,6 +1480,7 @@ public class Launcher extends Activity View createShortcut(int layoutResId, ViewGroup parent, ShortcutInfo info) { BubbleTextView favorite = (BubbleTextView) mInflater.inflate(layoutResId, parent, false); favorite.applyFromShortcutInfo(info, mIconCache); + favorite.setTextVisibility(!mHideIconLabels); favorite.setOnClickListener(this); if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_ALLAPPS && info.getIcon(mIconCache) == null) { // All apps icon @@ -2301,6 +2300,9 @@ public class Launcher extends Activity // Create the view FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this, layout, folderInfo, mIconCache); + if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { + newFolder.setTextVisible(!mHideIconLabels); + } mWorkspace.addInScreen(newFolder, container, screenId, cellX, cellY, 1, 1, isWorkspaceLocked()); // Force measure the new folder icon @@ -4021,6 +4023,7 @@ public class Launcher extends Activity FolderIcon newFolder = FolderIcon.fromXml(R.layout.folder_icon, this, (ViewGroup) workspace.getChildAt(workspace.getCurrentPage()), (FolderInfo) item, mIconCache); + newFolder.setTextVisible(!mHideIconLabels); workspace.addInScreenFromBind(newFolder, item.container, item.screenId, item.cellX, item.cellY, 1, 1); break; diff --git a/src/com/android/launcher3/PagedViewIcon.java b/src/com/android/launcher3/PagedViewIcon.java index 8bfe42d24..785725852 100644 --- a/src/com/android/launcher3/PagedViewIcon.java +++ b/src/com/android/launcher3/PagedViewIcon.java @@ -20,7 +20,6 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Region; -import android.graphics.Region.Op; import android.util.AttributeSet; import android.util.TypedValue; import android.widget.TextView; @@ -44,6 +43,9 @@ public class PagedViewIcon extends TextView { private Bitmap mIcon; + private int mTextColor; + private boolean mIsTextVisible; + public PagedViewIcon(Context context) { this(context, null); } @@ -63,6 +65,8 @@ public class PagedViewIcon extends TextView { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); setTextSize(TypedValue.COMPLEX_UNIT_SP, grid.iconTextSize); + mTextColor = getCurrentTextColor(); + mIsTextVisible = mTextColor != getResources().getColor(android.R.color.transparent); } public void applyFromApplicationInfo(AppInfo info, boolean scaleUp, @@ -126,4 +130,23 @@ public class PagedViewIcon extends TextView { super.draw(canvas); canvas.restore(); } + + @Override + public void setTextColor(int color) { + mTextColor = color; + super.setTextColor(color); + } + + public void setTextVisibility(boolean visible) { + if (visible) { + super.setTextColor(mTextColor); + } else { + super.setTextColor(getResources().getColor(android.R.color.transparent)); + } + mIsTextVisible = visible; + } + + public boolean isTextVisible() { + return mIsTextVisible; + } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index c3ce8bf69..83074aeda 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -54,10 +54,7 @@ import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.View.OnClickListener; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; -import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.TextView; @@ -282,6 +279,7 @@ public class Workspace extends SmoothPagedView private boolean mShowSearchBar; private boolean mShowOutlines; + private boolean mHideIconLabels; /** * Used to inflate the Workspace from XML. @@ -315,6 +313,9 @@ public class Workspace extends SmoothPagedView mShowOutlines = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_PAGE_OUTLINES, R.bool.preferences_interface_homescreen_scrolling_page_outlines_default); + mHideIconLabels = SettingsProvider.getBoolean(context, + SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, + R.bool.preferences_interface_homescreen_hide_icon_labels); mWorkspaceFadeInAdjacentScreens = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_FADE_ADJACENT, R.bool.preferences_interface_homescreen_scrolling_fade_adjacent_default); @@ -895,7 +896,9 @@ public class Workspace extends SmoothPagedView } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { - ((FolderIcon) child).setTextVisible(true); + ((FolderIcon) child).setTextVisible(!mHideIconLabels); + } else if (child instanceof BubbleTextView) { + ((BubbleTextView) child).setTextVisibility(!mHideIconLabels); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); @@ -3707,6 +3710,7 @@ public class Workspace extends SmoothPagedView case LauncherSettings.Favorites.ITEM_TYPE_FOLDER: view = FolderIcon.fromXml(R.layout.folder_icon, mLauncher, cellLayout, (FolderInfo) info, mIconCache); + ((FolderIcon) view).setTextVisible(!mHideIconLabels); break; default: throw new IllegalStateException("Unknown item type: " + info.itemType); diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java index 3a211952a..abf4e1b67 100644 --- a/src/com/android/launcher3/settings/SettingsProvider.java +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -26,6 +26,7 @@ public final class SettingsProvider { public static final String SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID = "ui_homescreen_default_screen_id"; public static final String SETTINGS_UI_HOMESCREEN_SEARCH = "ui_homescreen_search"; + public static final String SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS = "ui_homescreen_general_hide_icon_labels"; public static final String SETTINGS_UI_HOMESCREEN_SCROLLING_TRANSITION_EFFECT = "ui_homescreen_scrolling_transition_effect"; public static final String SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL = "ui_homescreen_scrolling_wallpaper_scroll"; public static final String SETTINGS_UI_HOMESCREEN_SCROLLING_PAGE_OUTLINES = "ui_homescreen_scrolling_page_outlines"; @@ -35,6 +36,7 @@ public final class SettingsProvider { public static final String SETTINGS_UI_DRAWER_HIDDEN_APPS = "ui_drawer_hidden_apps"; public static final String SETTINGS_UI_DRAWER_REMOVE_HIDDEN_APPS_SHORTCUTS = "ui_drawer_remove_hidden_apps_shortcuts"; public static final String SETTINGS_UI_DRAWER_REMOVE_HIDDEN_APPS_WIDGETS = "ui_drawer_remove_hidden_apps_widgets"; + public static final String SETTINGS_UI_DRAWER_HIDE_ICON_LABELS = "ui_drawer_hide_icon_labels"; public static final String SETTINGS_UI_GENERAL_ICONS_LARGE = "ui_general_icons_large"; public static final String SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_FAMILY = "ui_general_icons_text_font"; public static final String SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_STYLE = "ui_general_icons_text_font_style"; -- cgit v1.2.3