summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java1
-rw-r--r--src/com/android/launcher3/DynamicGrid.java4
-rw-r--r--src/com/android/launcher3/Folder.java1
-rw-r--r--src/com/android/launcher3/FolderIcon.java1
-rw-r--r--src/com/android/launcher3/Hotseat.java1
-rw-r--r--src/com/android/launcher3/Launcher.java1
-rw-r--r--src/com/android/launcher3/LauncherAppState.java14
-rw-r--r--src/com/android/launcher3/Utilities.java34
-rw-r--r--src/com/android/launcher3/settings/FontStylePreference.java134
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java4
10 files changed, 182 insertions, 13 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 34dd9294d..34625dfd7 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -1088,6 +1088,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
icon.setOnLongClickListener(this);
icon.setOnTouchListener(this);
icon.setOnKeyListener(this);
+ Utilities.applyTypeface(icon);
int index = i - startIndex;
int x = index % mCellCountX;
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index c6f2cb282..53332655e 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -518,8 +518,8 @@ public class DynamicGrid {
ArrayList<DeviceProfile> deviceProfiles =
new ArrayList<DeviceProfile>();
boolean hasAA = !AppsCustomizePagedView.DISABLE_ALL_APPS;
- boolean useLargeIcons = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_GENERAL_LARGE_ICONS,
- R.bool.preferences_interface_general_large_icons_default);
+ boolean useLargeIcons = SettingsProvider.getBoolean(context, SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
+ R.bool.preferences_interface_general_icons_large_default);
// Our phone profiles include the bar sizes in each orientation
deviceProfiles.add(new DeviceProfile("Super Short Stubby",
255, 300, 2, 3, (useLargeIcons ? 54 : 48), 13, (hasAA ? 5 : 4), (useLargeIcons ? 54 : 48)));
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 69d9a3d4b..1a25760ae 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -538,6 +538,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
textView.setTag(item);
textView.setTextColor(getResources().getColor(R.color.folder_items_text_color));
textView.setShadowsEnabled(false);
+ Utilities.applyTypeface(textView);
textView.setOnClickListener(this);
textView.setOnLongClickListener(this);
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index cd1ff2c37..e80b0f4f2 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -139,6 +139,7 @@ public class FolderIcon extends LinearLayout implements FolderListener {
icon.setClipToPadding(false);
icon.mFolderName = (BubbleTextView) icon.findViewById(R.id.folder_icon_name);
icon.mFolderName.setText(folderInfo.title);
+ Utilities.applyTypeface(icon.mFolderName);
icon.mPreviewBackground = (ImageView) icon.findViewById(R.id.preview_background);
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index 094e188c7..c88cd1da5 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -151,6 +151,7 @@ public class Hotseat extends FrameLayout {
inflater.inflate(R.layout.all_apps_button, mContent, false);
Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
Utilities.resizeIconDrawable(d);
+ Utilities.applyTypeface(allAppsButton);
allAppsButton.setCompoundDrawables(null, d, null, null);
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 53fa329fb..6347324ed 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1321,6 +1321,7 @@ public class Launcher extends Activity
BubbleTextView favorite = (BubbleTextView) mInflater.inflate(layoutResId, parent, false);
favorite.applyFromShortcutInfo(info, mIconCache);
favorite.setOnClickListener(this);
+ Utilities.applyTypeface(favorite);
return favorite;
}
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index a255b89a2..cba0d61ac 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -24,7 +24,7 @@ import android.database.ContentObserver;
import android.os.Handler;
import android.provider.Settings;
import android.util.Log;
-import android.view.Display;
+import com.android.launcher3.settings.SettingsProvider;
import java.lang.ref.WeakReference;
@@ -113,6 +113,18 @@ public class LauncherAppState {
ContentResolver resolver = sContext.getContentResolver();
resolver.registerContentObserver(LauncherSettings.Favorites.CONTENT_URI, true,
mFavoritesObserver);
+
+ // Generate default typeface
+ String fontFamily = SettingsProvider.getString(sContext,
+ SettingsProvider.SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_FAMILY,
+ R.string.preferences_interface_general_icons_text_font_family_default);
+
+ // TODO: Implement font styles
+ int fontStyle = SettingsProvider.getInt(sContext,
+ SettingsProvider.SETTINGS_UI_GENERAL_ICONS_TEXT_FONT_STYLE,
+ R.integer.preferences_interface_general_icons_text_font_style_default);
+
+ Utilities.generateTypeface(fontFamily, fontStyle);
}
/**
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 21c546d04..f41a1c2e5 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -21,21 +21,14 @@ import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BlurMaskFilter;
-import android.graphics.Canvas;
-import android.graphics.ColorMatrix;
-import android.graphics.ColorMatrixColorFilter;
-import android.graphics.Matrix;
-import android.graphics.Paint;
-import android.graphics.PaintFlagsDrawFilter;
-import android.graphics.Rect;
+import android.graphics.*;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.PaintDrawable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
+import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
@@ -58,6 +51,8 @@ final class Utilities {
private static final Rect sOldBounds = new Rect();
private static final Canvas sCanvas = new Canvas();
+ private static Typeface sTypeface;
+
static {
sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
Paint.FILTER_BITMAP_FLAG));
@@ -202,6 +197,27 @@ final class Utilities {
}
/**
+ * Generates the default icon typeface for use in icons.
+ *
+ * @param familyName May be null. The name of the font family.
+ * @param style The style (normal, bold, italic) of the typeface. e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC
+ */
+ static void generateTypeface(String familyName, int style) {
+ sTypeface = Typeface.create(familyName, style);
+ }
+
+ /**
+ * Applies the default icon typeface to a textview.
+ *
+ * @param textView View to apply typeface to.
+ */
+ static void applyTypeface(TextView textView) {
+ if (sTypeface != null) {
+ textView.setTypeface(sTypeface);
+ }
+ }
+
+ /**
* Given a coordinate relative to the descendant, find the coordinate in a parent view's
* coordinates.
*
diff --git a/src/com/android/launcher3/settings/FontStylePreference.java b/src/com/android/launcher3/settings/FontStylePreference.java
new file mode 100644
index 000000000..6c1160d40
--- /dev/null
+++ b/src/com/android/launcher3/settings/FontStylePreference.java
@@ -0,0 +1,134 @@
+package com.android.launcher3.settings;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.graphics.Typeface;
+import android.preference.ListPreference;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.*;
+import com.android.launcher3.R;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class FontStylePreference extends ListPreference {
+ private ListView mListView;
+ private String mValue;
+ public int mClickedDialogEntryIndex;
+ private boolean mValueSet;
+
+ public FontStylePreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
+ return;
+ }
+
+ @Override
+ public View onCreateDialogView() {
+ View view = LayoutInflater.from(getContext()).inflate(R.layout.preference_font_style, null);
+ mListView = (ListView) view.findViewById(android.R.id.list);
+ mListView.setAdapter(new FontStyleAdapter(getContext()));
+ mListView.setOnItemClickListener(mOnClickListener);
+ mListView.setItemChecked(getValueIndex(), true);
+ return view;
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+
+ if (positiveResult && mClickedDialogEntryIndex >= 0 && getEntryValues() != null) {
+ String value = getEntryValues()[mClickedDialogEntryIndex].toString();
+ if (callChangeListener(value)) {
+ setValue(value);
+ }
+ }
+ }
+
+ @Override
+ protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
+ setValue(restoreValue ? getPersistedString(mValue) : (String) defaultValue);
+ }
+
+ /**
+ * Sets the value of the key. This should be one of the entries in
+ * {@link #getEntryValues()}.
+ *
+ * @param value The value to set for the key.
+ */
+ @Override
+ public void setValue(String value) {
+ // Always persist/notify the first time.
+ final boolean changed = !TextUtils.equals(mValue, value);
+ if (changed || !mValueSet) {
+ mValue = value;
+ mValueSet = true;
+ persistString(value);
+ if (changed) {
+ notifyChanged();
+ }
+ }
+ }
+
+ /**
+ * Returns the value of the key. This should be one of the entries in
+ * {@link #getEntryValues()}.
+ *
+ * @return The value of the key.
+ */
+ @Override
+ public String getValue() {
+ return mValue;
+ }
+
+ private int getValueIndex() {
+ return findIndexOfValue(mValue);
+ }
+
+ private AdapterView.OnItemClickListener mOnClickListener = new AdapterView.OnItemClickListener() {
+ public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
+ mClickedDialogEntryIndex = position;
+ }
+ };
+
+ private class FontStyleAdapter extends ArrayAdapter<CharSequence> {
+ private LayoutInflater mInflater;
+ private List<CharSequence> mEntries;
+ private List<CharSequence> mValues;
+
+ public FontStyleAdapter(Context context) {
+ super(context, -1, getEntryValues());
+
+ mInflater = LayoutInflater.from(context);
+ mEntries = Arrays.asList(getEntries());
+ mValues = Arrays.asList(getEntryValues());
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ CheckedTextView textView;
+
+ if (convertView == null) {
+ textView = (CheckedTextView) mInflater.inflate(R.layout.list_item_checkable, parent, false);
+ } else {
+ textView = (CheckedTextView) convertView;
+ }
+
+ if (textView != null) {
+ textView.setText(mEntries.get(position));
+ textView.setTag(mValues.get(position));
+ textView.setTypeface(Typeface.create((String) mValues.get(position), Typeface.NORMAL));
+ }
+
+ return textView;
+ }
+ }
+}
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java
index 3d4f5d229..9c0a283ac 100644
--- a/src/com/android/launcher3/settings/SettingsProvider.java
+++ b/src/com/android/launcher3/settings/SettingsProvider.java
@@ -28,7 +28,9 @@ public final class SettingsProvider {
public static final String SETTINGS_UI_HOMESCREEN_SEARCH = "ui_homescreen_search";
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";
- public static final String SETTINGS_UI_GENERAL_LARGE_ICONS = "ui_general_large_icons";
+ 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";
public static SharedPreferences get(Context context) {
return context.getSharedPreferences(SETTINGS_KEY, 0);