Merge changes from topic 'am-103e12ab-e4f5-4f1e-a8f6-6b164b13e8de' into ub-launcher3-master
* changes:
Merge commit '18c4aa458ea5c9ee5513fa756da4f5492bb7c5b8' into am-103e12ab-e4f5-4f1e-a8f6-6b164b13e8de
Update accessibility for popup
Update accessibility for popup
diff --git a/proguard.flags b/proguard.flags
index 2ad9cac..51abcca 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -98,3 +98,7 @@
-keep interface com.android.launcher3.userevent.nano.LauncherLogProto.** {
*;
}
+
+-keep interface com.android.launcher3.model.nano.LauncherDumpProto.** {
+ *;
+}
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
index 909a429..93e09ae 100644
--- a/protos/launcher_log.proto
+++ b/protos/launcher_log.proto
@@ -156,4 +156,5 @@
optional int64 elapsed_session_millis = 6;
optional bool is_in_multi_window_mode = 7;
+ optional bool is_in_landscape_mode = 8;
}
diff --git a/res/drawable-v24/ic_info_shadow.xml b/res/drawable-v24/ic_info_shadow.xml
index 9bd7e16..1fe2c46 100644
--- a/res/drawable-v24/ic_info_shadow.xml
+++ b/res/drawable-v24/ic_info_shadow.xml
@@ -15,4 +15,5 @@
-->
<com.android.launcher3.graphics.ShadowDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_info_no_shadow" />
+ android:src="@drawable/ic_info_no_shadow"
+ android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/res/drawable-v24/ic_remove_shadow.xml b/res/drawable-v24/ic_remove_shadow.xml
index 16a630e..48abc10 100644
--- a/res/drawable-v24/ic_remove_shadow.xml
+++ b/res/drawable-v24/ic_remove_shadow.xml
@@ -15,4 +15,5 @@
-->
<com.android.launcher3.graphics.ShadowDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_remove_no_shadow" />
+ android:src="@drawable/ic_remove_no_shadow"
+ android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/res/drawable-v24/ic_uninstall_shadow.xml b/res/drawable-v24/ic_uninstall_shadow.xml
index 2532157..b441b0e 100644
--- a/res/drawable-v24/ic_uninstall_shadow.xml
+++ b/res/drawable-v24/ic_uninstall_shadow.xml
@@ -15,4 +15,5 @@
-->
<com.android.launcher3.graphics.ShadowDrawable
xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_uninstall_no_shadow" />
+ android:src="@drawable/ic_uninstall_no_shadow"
+ android:elevation="@dimen/drop_target_shadow_elevation" />
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index 565728c..1e82f22 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -32,8 +32,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <include layout="@layout/gradient_scrim" />
-
<!-- The workspace contains 5 screens of cells -->
<!-- DO NOT CHANGE THE ID -->
<com.android.launcher3.Workspace
@@ -44,6 +42,8 @@
android:layout_gravity="center"
launcher:pageIndicator="@id/page_indicator" />
+ <include layout="@layout/gradient_scrim" />
+
<!-- DO NOT CHANGE THE ID -->
<include layout="@layout/hotseat"
android:id="@+id/hotseat"
diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml
index eccb824..c15e53d 100644
--- a/res/layout-port/launcher.xml
+++ b/res/layout-port/launcher.xml
@@ -33,8 +33,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <include layout="@layout/gradient_scrim" />
-
<!-- The workspace contains 5 screens of cells -->
<!-- DO NOT CHANGE THE ID -->
<com.android.launcher3.Workspace
@@ -46,6 +44,8 @@
launcher:pageIndicator="@+id/page_indicator">
</com.android.launcher3.Workspace>
+ <include layout="@layout/gradient_scrim" />
+
<!-- DO NOT CHANGE THE ID -->
<include layout="@layout/hotseat"
android:id="@+id/hotseat"
diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml
index 7fad517..c516c46 100644
--- a/res/layout-sw720dp/launcher.xml
+++ b/res/layout-sw720dp/launcher.xml
@@ -32,8 +32,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
- <include layout="@layout/gradient_scrim" />
-
<!-- The workspace contains 5 screens of cells -->
<!-- DO NOT CHANGE THE ID -->
<com.android.launcher3.Workspace
@@ -45,6 +43,8 @@
launcher:pageIndicator="@id/page_indicator">
</com.android.launcher3.Workspace>
+ <include layout="@layout/gradient_scrim" />
+
<!-- DO NOT CHANGE THE ID -->
<include layout="@layout/hotseat"
android:id="@+id/hotseat"
diff --git a/res/layout/all_apps_discovery_item.xml b/res/layout/all_apps_discovery_item.xml
index 1a7eaa7..3350530 100644
--- a/res/layout/all_apps_discovery_item.xml
+++ b/res/layout/all_apps_discovery_item.xml
@@ -51,11 +51,12 @@
android:layout_height="wrap_content"
android:textColor="?android:textColorSecondary"
android:textSize="14sp"
- android:layout_gravity="center_vertical"/>
+ android:layout_gravity="center_vertical"
+ android:includeFontPadding="false"/>
<com.android.launcher3.discovery.RatingView
android:id="@+id/rating_view"
- android:layout_width="80dp"
+ android:layout_width="70dp"
android:layout_height="16dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
diff --git a/res/layout/all_apps_discovery_loading_divider.xml b/res/layout/all_apps_discovery_loading_divider.xml
index c7b5ad2..1ad5521 100644
--- a/res/layout/all_apps_discovery_loading_divider.xml
+++ b/res/layout/all_apps_discovery_loading_divider.xml
@@ -15,7 +15,7 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="20dp"
+ android:layout_height="6dp"
android:paddingLeft="@dimen/container_fastscroll_thumb_max_width"
android:paddingRight="@dimen/container_fastscroll_thumb_max_width">
@@ -34,7 +34,7 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/all_apps_divider"
- android:layout_gravity="center"
+ android:layout_gravity="bottom"
android:visibility="invisible"/>
</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/gradient_scrim.xml b/res/layout/gradient_scrim.xml
index 02c39eb..c40c5fc 100644
--- a/res/layout/gradient_scrim.xml
+++ b/res/layout/gradient_scrim.xml
@@ -15,7 +15,7 @@
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
- <com.android.launcher3.graphics.RadialGradientView
+ <com.android.launcher3.graphics.GradientView
android:id="@+id/gradient_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 18759f8..807d08a 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -114,5 +114,6 @@
<declare-styleable name="ShadowDrawable">
<attr name="android:src" />
<attr name="android:shadowColor" />
+ <attr name="android:elevation" />
</declare-styleable>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 47bc5b5..c24ab3b 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -36,6 +36,8 @@
<color name="notification_icon_default_color">#757575</color> <!-- Gray 600 -->
<color name="notification_color_beneath">#E0E0E0</color> <!-- Gray 300 -->
+ <color name="badge_color">#1DE9B6</color> <!-- Teal A400 -->
+
<color name="icon_background">#E0E0E0</color> <!-- Gray 300 -->
<color name="legacy_icon_background">#FFFFFF</color>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index bb80ec8..8f2590a 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -22,20 +22,18 @@
<string-array name="icon_shape_override_paths_values">
<item></item>
<item translatable="false">M50,0L100,0 100,100 0,100 0,0z</item>
- <item translatable="false">M50,0L80,0 A20,20,0,0 1 100,20 L100,80 A20,20,0,0 1 80,100 L20,100 A20,20,0,0 1 0,80 L 0,20 A20,20,0,0 1 20,0z</item>
<item translatable="false">M50,0 C10,0 0,10 0,50 0,90 10,100 50,100 90,100 100,90 100,50 100,10 90,0 50,0 Z</item>
<item translatable="false">M50 0A50 50,0,1,1,50 100A50 50,0,1,1,50 0</item>
- <item translatable="false">M50,0A50,30 0,0,1 100,30V70A50,30 0,0,1 0,70V30A50,30 0,0,1 50,0z</item>
+ <item translatable="false">M50,0A50,50,0,0 1 100,50 L100,85 A15,15,0,0 1 85,100 L50,100 A50,50,0,0 1 50,0z</item>
</string-array>
<string-array name="icon_shape_override_paths_names">
<!-- Option to not change the icon shape on home screen. [CHAR LIMIT=50] -->
- <item>@string/icon_shape_no_override</item>
+ <item>@string/icon_shape_system_default</item>
<item translatable="false">Square</item>
- <item translatable="false">Rounded corner rect</item>
<item translatable="false">Squircle</item>
<item translatable="false">Circle</item>
- <item translatable="false">Cylinder</item>
+ <item translatable="false">Teardrop</item>
</string-array>
<!-- DragController -->
<item type="id" name="drag_event_parity" />
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 6add64d..958cb6b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -48,11 +48,6 @@
<dimen name="resize_frame_background_padding">24dp</dimen>
<!-- Container -->
- <!-- Note: This needs to match the fixed insets for the search box. -->
- <dimen name="container_bounds_inset">8dp</dimen>
- <!-- Notes: container_bounds_inset - quantum_panel_outer_padding -->
- <dimen name="container_bounds_minus_quantum_panel_padding_inset">4dp</dimen>
-
<dimen name="container_fastscroll_thumb_min_width">5dp</dimen>
<dimen name="container_fastscroll_thumb_max_width">9dp</dimen>
<dimen name="container_fastscroll_popup_margin">18dp</dimen>
@@ -65,9 +60,6 @@
<dimen name="all_apps_button_scale_down">0dp</dimen>
<dimen name="all_apps_search_bar_field_height">48dp</dimen>
<dimen name="all_apps_search_bar_height">60dp</dimen>
- <dimen name="all_apps_search_bar_icon_margin_right">4dp</dimen>
- <dimen name="all_apps_search_bar_icon_margin_top">1dp</dimen>
- <dimen name="all_apps_list_bottom_padding">8dp</dimen>
<dimen name="all_apps_empty_search_message_top_offset">40dp</dimen>
<dimen name="all_apps_empty_search_bg_top_offset">144dp</dimen>
<dimen name="all_apps_background_canvas_width">700dp</dimen>
@@ -112,6 +104,7 @@
<!-- Drag padding to add to the bottom of drop targets -->
<dimen name="drop_target_drag_padding">14dp</dimen>
<dimen name="drop_target_text_size">14sp</dimen>
+ <dimen name="drop_target_shadow_elevation">2dp</dimen>
<!-- the distance an icon must be dragged before button drop targets accept it -->
<dimen name="drag_distanceThreshold">30dp</dimen>
@@ -146,7 +139,6 @@
<dimen name="blur_size_medium_outline">2dp</dimen>
<dimen name="blur_size_click_shadow">4dp</dimen>
<dimen name="click_shadow_high_shift">2dp</dimen>
- <dimen name="drawable_shadow_size">2dp</dimen>
<!-- Pending widget -->
<dimen name="pending_widget_min_padding">8dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f906a78..1fe33ae 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -172,6 +172,12 @@
<string name="allow_rotation_desc">When phone is rotated</string>
<!-- Text explaining that rotation is disabled in Display settings. 'Display' refers to the Display section in system settings [CHAR LIMIT=100] -->
<string name="allow_rotation_blocked_desc">Current Display setting doesn\'t permit rotation</string>
+ <!-- Title for Icon Badging setting. Tapping this will link to the system Notifications Settings screen where the user can turn off badging globally. [CHAR LIMIT=50] -->
+ <string name="icon_badging_title">Icon badging</string>
+ <!-- Text to indicate that the system icon badging setting is on [CHAR LIMIT=100] -->
+ <string name="icon_badging_desc_on">On for all apps</string>
+ <!-- Text to indicate that the system icon badging setting is off [CHAR LIMIT=100] -->
+ <string name="icon_badging_desc_off">Off for all apps</string>
<!-- Label for the setting that allows the automatic placement of launcher shortcuts for applications and games installed on the device [CHAR LIMIT=40] -->
<string name="auto_add_shortcuts_label">Add icon to Home screen</string>
@@ -180,8 +186,8 @@
<!-- Developer setting to change the shape of icons on home screen. [CHAR LIMIT=50] -->
<string name="icon_shape_override_label">Change icon shape</string>
- <!-- Option to not change the icon shape on home screen. [CHAR LIMIT=50] -->
- <string name="icon_shape_no_override">Do not change</string>
+ <!-- Option to not change the icon shape on home screen and use the system default setting instead. [CHAR LIMIT=50] -->
+ <string name="icon_shape_system_default">Use system default</string>
<!-- Message shown in the progress dialog when the icon shape override is being applied [CHAR LIMIT=100]-->
<string name="icon_shape_override_progress">Applying icon shape changes</string>
diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml
index 301bef1..8763883 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -17,13 +17,6 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
- android:key="pref_allowRotation"
- android:title="@string/allow_rotation_title"
- android:defaultValue="@bool/allow_rotation"
- android:persistent="true"
- />
-
- <SwitchPreference
android:key="pref_add_icon_to_home"
android:title="@string/auto_add_shortcuts_label"
android:summary="@string/auto_add_shortcuts_description"
@@ -40,4 +33,23 @@
android:defaultValue=""
android:persistent="false" />
+ <Preference
+ android:key="pref_icon_badging"
+ android:title="@string/icon_badging_title"
+ android:persistent="false">
+ <intent android:action="android.settings.NOTIFICATION_SETTINGS">
+ <!-- This extra highlights the "Allow icon badges" field in Notification settings -->
+ <extra
+ android:name=":settings:fragment_args_key"
+ android:value="notification_badging" />
+ </intent>
+ </Preference>/>
+
+ <SwitchPreference
+ android:key="pref_allowRotation"
+ android:title="@string/allow_rotation_title"
+ android:defaultValue="@bool/allow_rotation"
+ android:persistent="true"
+ />
+
</PreferenceScreen>
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 410d590..08cd955 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -39,7 +39,7 @@
public final UserEventDispatcher getUserEventDispatcher() {
if (mUserEventDispatcher == null) {
mUserEventDispatcher = UserEventDispatcher.newInstance(this,
- isInMultiWindowModeCompat());
+ mDeviceProfile.isLandscape, isInMultiWindowModeCompat());
}
return mUserEventDispatcher;
}
diff --git a/src/com/android/launcher3/BaseRecyclerView.java b/src/com/android/launcher3/BaseRecyclerView.java
index c056336..1e6d894 100644
--- a/src/com/android/launcher3/BaseRecyclerView.java
+++ b/src/com/android/launcher3/BaseRecyclerView.java
@@ -113,6 +113,7 @@
* it is already showing).
*/
private boolean handleTouchEvent(MotionEvent ev) {
+ ev.offsetLocation(0, -getPaddingTop());
int action = ev.getAction();
int x = (int) ev.getX();
int y = (int) ev.getY();
@@ -136,6 +137,7 @@
mScrollbar.handleTouchEvent(ev, mDownX, mDownY, mLastY);
break;
}
+ ev.offsetLocation(0, getPaddingTop());
return mScrollbar.isDraggingThumb();
}
@@ -162,7 +164,7 @@
* Returns the height of the fast scroll bar
*/
protected int getScrollbarTrackHeight() {
- return getHeight();
+ return getHeight() - getPaddingTop() - getPaddingBottom();
}
/**
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
index 5feb42e..3039744 100644
--- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
+++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java
@@ -136,6 +136,7 @@
mTmpRect.set(drawLeft, mThumbOffsetY, drawLeft + mMaxWidth, mThumbOffsetY + mThumbHeight);
mThumbOffsetY = y;
mTmpRect.union(drawLeft, mThumbOffsetY, drawLeft + mMaxWidth, mThumbOffsetY + mThumbHeight);
+ mTmpRect.offset(0, mRv.getPaddingTop());
mRv.invalidate(mTmpRect);
}
@@ -148,8 +149,9 @@
return;
}
int left = getDrawLeft();
+ int top = mRv.getPaddingTop();
// Invalidate the whole scroll bar area.
- mRv.invalidate(left, 0, left + mMaxWidth, mRv.getScrollbarTrackHeight());
+ mRv.invalidate(left, top, left + mMaxWidth, top + mRv.getScrollbarTrackHeight());
mWidth = width;
updateThumbPath();
@@ -265,6 +267,7 @@
if (!mIsRtl) {
canvas.translate(mRv.getWidth(), 0);
}
+ canvas.translate(0, mRv.getPaddingTop());
// Draw the track
int thumbWidth = mIsRtl ? mWidth : -mWidth;
canvas.drawRect(0, 0, thumbWidth, mRv.getScrollbarTrackHeight(), mTrackPaint);
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 2e7c405..e49ead0 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -457,7 +457,7 @@
final int scrollX = getScrollX();
final int scrollY = getScrollY();
canvas.translate(scrollX, scrollY);
- mBadgeRenderer.draw(canvas, mIconPalette, mBadgeInfo, mTempIconBounds, mBadgeScale,
+ mBadgeRenderer.draw(canvas, mBadgeInfo, mTempIconBounds, mBadgeScale,
mTempSpaceForBadgeOffset);
canvas.translate(-scrollX, -scrollY);
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index c32f2d5..508fc34 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -113,9 +113,9 @@
public int hotseatCellHeightPx;
public int hotseatIconSizePx;
public int hotseatBarHeightPx;
- private int hotseatBarTopPaddingPx;
- private int hotseatBarBottomPaddingPx;
- private int hotseatLandGutterPx;
+ public int hotseatBarTopPaddingPx;
+ public int hotseatBarBottomPaddingPx;
+ public int hotseatLandGutterPx;
// All apps
public int allAppsNumCols;
@@ -231,9 +231,6 @@
profile.cellHeightPx = profile.iconSizePx + profile.iconDrawablePaddingPx
+ Utilities.calculateTextHeight(profile.iconTextSizePx);
- // The nav bar is black so we add bottom padding to visually center hotseat icons.
- profile.hotseatBarBottomPaddingPx = profile.hotseatBarTopPaddingPx;
-
// We use these scales to measure and layout the widgets using their full invariant profile
// sizes and then draw them scaled and centered to fit in their multi-window mode cellspans.
float appWidgetScaleX = (float) profile.getCellSize().x / getCellSize().x;
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index ca9f312..e75c217 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1777,17 +1777,15 @@
}
private void loadDeepShortcuts() {
- if (!mModelLoaded) {
- sBgDataModel.deepShortcutMap.clear();
- DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(mContext);
- mHasShortcutHostPermission = shortcutManager.hasHostPermission();
- if (mHasShortcutHostPermission) {
- for (UserHandle user : mUserManager.getUserProfiles()) {
- if (mUserManager.isUserUnlocked(user)) {
- List<ShortcutInfoCompat> shortcuts =
- shortcutManager.queryForAllShortcuts(user);
- sBgDataModel.updateDeepShortcutMap(null, user, shortcuts);
- }
+ sBgDataModel.deepShortcutMap.clear();
+ DeepShortcutManager shortcutManager = DeepShortcutManager.getInstance(mContext);
+ mHasShortcutHostPermission = shortcutManager.hasHostPermission();
+ if (mHasShortcutHostPermission) {
+ for (UserHandle user : mUserManager.getUserProfiles()) {
+ if (mUserManager.isUserUnlocked(user)) {
+ List<ShortcutInfoCompat> shortcuts =
+ shortcutManager.queryForAllShortcuts(user);
+ sBgDataModel.updateDeepShortcutMap(null, user, shortcuts);
}
}
}
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index 7ae6b26..0902b20 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -34,6 +34,11 @@
* Settings activity for Launcher. Currently implements the following setting: Allow rotation
*/
public class SettingsActivity extends Activity {
+
+ private static final String ICON_BADGING_PREFERENCE_KEY = "pref_icon_badging";
+ // TODO: use Settings.Secure.NOTIFICATION_BADGING
+ private static final String NOTIFICATION_BADGING = "notification_badging";
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -50,6 +55,7 @@
public static class LauncherSettingsFragment extends PreferenceFragment {
private SystemDisplayRotationLockObserver mRotationLockObserver;
+ private IconBadgingObserver mIconBadgingObserver;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -57,13 +63,14 @@
getPreferenceManager().setSharedPreferencesName(LauncherFiles.SHARED_PREFERENCES_KEY);
addPreferencesFromResource(R.xml.launcher_preferences);
+ ContentResolver resolver = getActivity().getContentResolver();
+
// Setup allow rotation preference
Preference rotationPref = findPreference(Utilities.ALLOW_ROTATION_PREFERENCE_KEY);
if (getResources().getBoolean(R.bool.allow_rotation)) {
// Launcher supports rotation by default. No need to show this setting.
getPreferenceScreen().removePreference(rotationPref);
} else {
- ContentResolver resolver = getActivity().getContentResolver();
mRotationLockObserver = new SystemDisplayRotationLockObserver(rotationPref, resolver);
// Register a content observer to listen for system setting changes while
@@ -77,9 +84,18 @@
rotationPref.setDefaultValue(Utilities.getAllowRotationDefaultValue(getActivity()));
}
+ Preference iconBadgingPref = findPreference(ICON_BADGING_PREFERENCE_KEY);
if (!BuildCompat.isAtLeastO()) {
getPreferenceScreen().removePreference(
findPreference(SessionCommitReceiver.ADD_ICON_PREFERENCE_KEY));
+ getPreferenceScreen().removePreference(iconBadgingPref);
+ } else {
+ // Listen to system notification badge settings while this UI is active.
+ mIconBadgingObserver = new IconBadgingObserver(iconBadgingPref, resolver);
+ resolver.registerContentObserver(
+ Settings.Secure.getUriFor(NOTIFICATION_BADGING),
+ false, mIconBadgingObserver);
+ mIconBadgingObserver.onChange(true);
}
Preference iconShapeOverride = findPreference(IconShapeOverride.KEY_PREFERENCE);
@@ -98,6 +114,10 @@
getActivity().getContentResolver().unregisterContentObserver(mRotationLockObserver);
mRotationLockObserver = null;
}
+ if (mIconBadgingObserver != null) {
+ getActivity().getContentResolver().unregisterContentObserver(mIconBadgingObserver);
+ mIconBadgingObserver = null;
+ }
super.onDestroy();
}
}
@@ -127,4 +147,29 @@
? R.string.allow_rotation_desc : R.string.allow_rotation_blocked_desc);
}
}
+
+ /**
+ * Content observer which listens for system badging setting changes,
+ * and updates the launcher badging setting subtext accordingly.
+ */
+ private static class IconBadgingObserver extends ContentObserver {
+
+ private final Preference mBadgingPref;
+ private final ContentResolver mResolver;
+
+ public IconBadgingObserver(Preference badgingPref, ContentResolver resolver) {
+ super(new Handler());
+ mBadgingPref = badgingPref;
+ mResolver = resolver;
+ }
+
+ @Override
+ public void onChange(boolean selfChange) {
+ boolean enabled = Settings.Secure.getInt(mResolver, NOTIFICATION_BADGING, 1) == 1;
+ mBadgingPref.setSummary(enabled
+ ? R.string.icon_badging_desc_on
+ : R.string.icon_badging_desc_off);
+ }
+ }
+
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 25e5749..b3dd7ac 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2277,7 +2277,7 @@
mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent();
}
- if (child instanceof BubbleTextView) {
+ if (child instanceof BubbleTextView && !dragOptions.isAccessibleDrag) {
PopupContainerWithArrow popupContainer = PopupContainerWithArrow
.showForIcon((BubbleTextView) child);
if (popupContainer != null) {
@@ -2529,6 +2529,8 @@
}
}
+ boolean droppedOnOriginalCell = false;
+
int snapScreen = -1;
boolean resizeOnDrop = false;
if (d.dragSource != this) {
@@ -2580,9 +2582,9 @@
minSpanY = item.minSpanY;
}
- droppedOnOriginalCellDuringTransition = mIsSwitchingState
- && item.screenId == screenId && item.container == container
+ droppedOnOriginalCell = item.screenId == screenId && item.container == container
&& item.cellX == mTargetCell[0] && item.cellY == mTargetCell[1];
+ droppedOnOriginalCellDuringTransition = droppedOnOriginalCell && mIsSwitchingState;
// When quickly moving an item, a user may accidentally rearrange their
// workspace. So instead we move the icon back safely to its original position.
@@ -2717,7 +2719,7 @@
}
parent.onDropChild(cell);
}
- if (d.stateAnnouncer != null) {
+ if (d.stateAnnouncer != null && !droppedOnOriginalCell) {
d.stateAnnouncer.completeAction(R.string.item_moved);
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 0ea61f4..d9ee2c5 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -245,6 +245,10 @@
}
}
+ public SearchUiManager getSearchUiManager() {
+ return mSearchUiManager;
+ }
+
@Override
public View getTouchDelegateTargetView() {
return mAppsRecyclerView;
@@ -366,6 +370,10 @@
@Override
public void setInsets(Rect insets) {
DeviceProfile grid = mLauncher.getDeviceProfile();
+ mAppsRecyclerView.setPadding(
+ mAppsRecyclerView.getPaddingLeft(), mAppsRecyclerView.getPaddingTop(),
+ mAppsRecyclerView.getPaddingRight(), insets.bottom);
+
if (grid.isVerticalBarLayout()) {
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
mlp.leftMargin = insets.left;
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index e126102..cfd04e2 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -161,11 +161,6 @@
}
return extraRows;
}
-
- @Override
- public int getPaddingBottom() {
- return mLauncher.getDragLayer().getInsets().bottom;
- }
}
/**
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index f3089d2..16b2bd1 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -392,21 +392,14 @@
return getPaddingTop() + y - offset;
}
- @Override
- protected int getScrollbarTrackHeight() {
- return super.getScrollbarTrackHeight()
- - Launcher.getLauncher(getContext()).getDragLayer().getInsets().bottom;
- }
-
/**
* Returns the available scroll height:
* AvailableScrollHeight = Total height of the all items - last page height
*/
@Override
protected int getAvailableScrollHeight() {
- int paddedHeight = getCurrentScrollY(mApps.getAdapterItems().size(), 0);
- int totalHeight = paddedHeight + getPaddingBottom();
- return totalHeight - getScrollbarTrackHeight();
+ return getCurrentScrollY(mApps.getAdapterItems().size(), 0)
+ - getHeight() + getPaddingBottom();
}
/**
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 9c1854a..7c6ff51 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -24,7 +24,7 @@
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dynamicui.ExtractedColors;
-import com.android.launcher3.graphics.RadialGradientView;
+import com.android.launcher3.graphics.GradientView;
import com.android.launcher3.graphics.ScrimView;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -42,12 +42,13 @@
* closer to top or closer to the page indicator.
*/
public class AllAppsTransitionController implements TouchController, VerticalPullDetector.Listener,
- View.OnLayoutChangeListener, ExtractedColors.OnChangeListener {
+ ExtractedColors.OnChangeListener, SearchUiManager.OnScrollRangeChangeListener {
private static final String TAG = "AllAppsTrans";
private static final boolean DBG = false;
- private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
+ private final Interpolator mWorkspaceAccelnterpolator = new AccelerateInterpolator(2f);
+ private final Interpolator mHotseatAccelInterpolator = new AccelerateInterpolator(.5f);
private final Interpolator mDecelInterpolator = new DecelerateInterpolator(3f);
private final Interpolator mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
private final VerticalPullDetector.ScrollInterpolator mScrollInterpolator
@@ -95,7 +96,7 @@
// Used in discovery bounce animation to provide the transition without workspace changing.
private boolean mIsTranslateWithoutWorkspace = false;
private AnimatorSet mDiscoBounceAnimation;
- private RadialGradientView mGradientView;
+ private GradientView mGradientView;
private ScrimView mScrimView;
public AllAppsTransitionController(Launcher l) {
@@ -275,7 +276,7 @@
private void updateAllAppsBg(float progress) {
// gradient
if (mGradientView == null) {
- mGradientView = (RadialGradientView) mLauncher.findViewById(R.id.gradient_bg);
+ mGradientView = (GradientView) mLauncher.findViewById(R.id.gradient_bg);
mGradientView.setVisibility(View.VISIBLE);
onExtractedColorsChanged();
}
@@ -313,7 +314,8 @@
float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f);
float alpha = 1 - workspaceHotseatAlpha;
- float interpolation = mAccelInterpolator.getInterpolation(workspaceHotseatAlpha);
+ float workspaceAlpha = mWorkspaceAccelnterpolator.getInterpolation(workspaceHotseatAlpha);
+ float hotseatAlpha = mHotseatAccelInterpolator.getInterpolation(workspaceHotseatAlpha);
int color = (Integer) mEvaluator.evaluate(mDecelInterpolator.getInterpolation(alpha),
mHotseatBackgroundColor, mAllAppsBackgroundColor);
@@ -331,18 +333,18 @@
if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, -mShiftRange + shiftCurrent,
- interpolation);
+ hotseatAlpha);
} else {
mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y,
PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent),
- interpolation);
+ hotseatAlpha);
}
if (mIsTranslateWithoutWorkspace) {
return;
}
mWorkspace.setWorkspaceYTranslationAndAlpha(
- PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), interpolation);
+ PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), workspaceAlpha);
if (!mDetector.isDraggingState()) {
mContainerVelocity = mDetector.computeVelocity(shiftCurrent - shiftPrevious,
@@ -531,21 +533,15 @@
mAppsView = appsView;
mHotseat = hotseat;
mWorkspace = workspace;
- mHotseat.addOnLayoutChangeListener(this);
mHotseat.bringToFront();
mCaretController = new AllAppsCaretController(
mWorkspace.getPageIndicator().getCaretDrawable(), mLauncher);
+ mAppsView.getSearchUiManager().addOnScrollRangeChangeListener(this);
}
@Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
- mShiftRange = top;
- } else {
- mShiftRange = bottom;
- }
+ public void onScrollRangeChanged(int scrollRange) {
+ mShiftRange = scrollRange;
setProgress(mProgress);
}
-
}
diff --git a/src/com/android/launcher3/allapps/SearchUiManager.java b/src/com/android/launcher3/allapps/SearchUiManager.java
index 15455bc..0d013c7 100644
--- a/src/com/android/launcher3/allapps/SearchUiManager.java
+++ b/src/com/android/launcher3/allapps/SearchUiManager.java
@@ -55,4 +55,14 @@
* TODO: Remove when removing support for opening all-apps in search mode.
*/
void startAppsSearch();
+
+ void addOnScrollRangeChangeListener(OnScrollRangeChangeListener listener);
+
+ /**
+ * Callback for listening to changes in the vertical scroll range when opening all-apps.
+ */
+ interface OnScrollRangeChangeListener {
+
+ void onScrollRangeChanged(int scrollRange);
+ }
}
diff --git a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
index 116ec88..126a02c 100644
--- a/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
+++ b/src/com/android/launcher3/allapps/search/AppsSearchContainerLayout.java
@@ -16,6 +16,7 @@
package com.android.launcher3.allapps.search;
import android.content.Context;
+import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Selection;
@@ -26,8 +27,10 @@
import android.text.method.TextKeyListener;
import android.util.AttributeSet;
import android.view.KeyEvent;
+import android.view.View;
import android.widget.FrameLayout;
+import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
@@ -51,6 +54,7 @@
private final Launcher mLauncher;
private final int mMinHeight;
+ private final int mSearchBoxHeight;
private final AllAppsSearchBarController mSearchBarController;
private final SpannableStringBuilder mSearchQueryBuilder;
private final HeaderElevationController mElevationController;
@@ -73,6 +77,8 @@
mLauncher = Launcher.getLauncher(context);
mMinHeight = getResources().getDimensionPixelSize(R.dimen.all_apps_search_bar_height);
+ mSearchBoxHeight = getResources()
+ .getDimensionPixelSize(R.dimen.all_apps_search_bar_field_height);
mSearchBarController = new AllAppsSearchBarController();
mElevationController = new HeaderElevationController(this);
@@ -192,4 +198,23 @@
mElevationController.reset();
mAppsRecyclerView.onSearchResultsChanged();
}
+
+ @Override
+ public void addOnScrollRangeChangeListener(final OnScrollRangeChangeListener listener) {
+ mLauncher.getHotseat().addOnLayoutChangeListener(new OnLayoutChangeListener() {
+ @Override
+ public void onLayoutChange(View v, int left, int top, int right, int bottom,
+ int oldLeft, int oldTop, int oldRight, int oldBottom) {
+ DeviceProfile dp = mLauncher.getDeviceProfile();
+ if (!dp.isVerticalBarLayout()) {
+ Rect insets = mLauncher.getDragLayer().getInsets();
+ int hotseatBottom = bottom - dp.hotseatBarBottomPaddingPx - insets.bottom;
+ int searchTopMargin = insets.top + (mMinHeight - mSearchBoxHeight);
+ listener.onScrollRangeChanged(hotseatBottom - searchTopMargin);
+ } else {
+ listener.onScrollRangeChanged(bottom);
+ }
+ }
+ });
+ }
}
diff --git a/src/com/android/launcher3/badge/BadgeRenderer.java b/src/com/android/launcher3/badge/BadgeRenderer.java
index ba1977a..adde4a2 100644
--- a/src/com/android/launcher3/badge/BadgeRenderer.java
+++ b/src/com/android/launcher3/badge/BadgeRenderer.java
@@ -63,6 +63,7 @@
private final Paint mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG
| Paint.FILTER_BITMAP_FLAG);
private final SparseArray<Bitmap> mBackgroundsWithShadow;
+ private final IconPalette mIconPalette;
public BadgeRenderer(Context context, int iconSizePx) {
mContext = context;
@@ -82,24 +83,25 @@
mTextHeight = tempTextHeight.height();
mBackgroundsWithShadow = new SparseArray<>(3);
+
+ mIconPalette = IconPalette.fromDominantColor(context.getColor(R.color.badge_color));
}
/**
* Draw a circle in the top right corner of the given bounds, and draw
* {@link BadgeInfo#getNotificationCount()} on top of the circle.
- * @param palette The colors (based on the icon) to use for the badge.
* @param badgeInfo Contains data to draw on the badge. Could be null if we are animating out.
* @param iconBounds The bounds of the icon being badged.
* @param badgeScale The progress of the animation, from 0 to 1.
* @param spaceForOffset How much space is available to offset the badge up and to the right.
*/
- public void draw(Canvas canvas, IconPalette palette, @Nullable BadgeInfo badgeInfo,
+ public void draw(Canvas canvas, @Nullable BadgeInfo badgeInfo,
Rect iconBounds, float badgeScale, Point spaceForOffset) {
- mTextPaint.setColor(palette.textColor);
+ mTextPaint.setColor(mIconPalette.textColor);
IconDrawer iconDrawer = badgeInfo != null && badgeInfo.isIconLarge()
? mLargeIconDrawer : mSmallIconDrawer;
Shader icon = badgeInfo == null ? null : badgeInfo.getNotificationIconForBadge(
- mContext, palette.backgroundColor, mSize, iconDrawer.mPadding);
+ mContext, mIconPalette.backgroundColor, mSize, iconDrawer.mPadding);
String notificationCount = badgeInfo == null ? "0"
: String.valueOf(badgeInfo.getNotificationCount());
int numChars = notificationCount.length();
@@ -125,7 +127,7 @@
canvas.translate(badgeCenterX + offsetX, badgeCenterY - offsetY);
canvas.scale(badgeScale, badgeScale);
// Prepare the background and shadow and possible stacking effect.
- mBackgroundPaint.setColorFilter(palette.backgroundColorMatrixFilter);
+ mBackgroundPaint.setColorFilter(mIconPalette.backgroundColorMatrixFilter);
int backgroundWithShadowSize = backgroundWithShadow.getHeight(); // Same as width.
boolean shouldStack = !isDot && badgeInfo != null
&& badgeInfo.getNotificationKeys().size() > 1;
@@ -147,7 +149,7 @@
-backgroundWithShadowSize / 2, mBackgroundPaint);
iconDrawer.drawIcon(icon, canvas);
} else if (isDot) {
- mBackgroundPaint.setColorFilter(palette.saturatedBackgroundColorMatrixFilter);
+ mBackgroundPaint.setColorFilter(mIconPalette.saturatedBackgroundColorMatrixFilter);
canvas.drawBitmap(backgroundWithShadow, -backgroundWithShadowSize / 2,
-backgroundWithShadowSize / 2, mBackgroundPaint);
}
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index bbf1546..1ffd3da 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -24,6 +24,7 @@
import android.os.Handler;
import android.os.Process;
import android.os.UserHandle;
+import android.text.TextUtils;
import android.util.SparseArray;
import com.android.launcher3.IconCache;
@@ -151,7 +152,9 @@
};
private PackageInstaller.SessionInfo verify(PackageInstaller.SessionInfo sessionInfo) {
- if (sessionInfo == null || sessionInfo.getInstallerPackageName() == null) {
+ if (sessionInfo == null
+ || sessionInfo.getInstallerPackageName() == null
+ || TextUtils.isEmpty(sessionInfo.getAppPackageName())) {
return null;
}
String pkg = sessionInfo.getInstallerPackageName();
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
index 9bb3b10..809d724 100644
--- a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
+++ b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
@@ -82,7 +82,7 @@
mPrice.setText(info.priceFormatted != null ? info.priceFormatted : "");
mReviewCount.setVisibility(SHOW_REVIEW_COUNT ? View.VISIBLE : View.GONE);
if (info.rating >= 0) {
- mRatingText.setText(new DecimalFormat("#.#").format(info.rating));
+ mRatingText.setText(new DecimalFormat("#.0").format(info.rating));
mRatingView.setRating(info.rating);
mRatingView.setVisibility(View.VISIBLE);
String reviewCountFormatted = NumberFormat.getInstance().format(info.reviewCount);
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 6e3db0b..4548792 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -75,7 +75,6 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
-import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.util.Thunk;
import java.util.ArrayList;
@@ -933,7 +932,7 @@
// If we are animating to the accepting state, animate the badge out.
float badgeScale = Math.max(0, mBadgeScale - mBackground.getScaleProgress());
mTempSpaceForBadgeOffset.set(getWidth() - mTempBounds.right, mTempBounds.top);
- mBadgeRenderer.draw(canvas, IconPalette.FOLDER_ICON_PALETTE, mBadgeInfo, mTempBounds,
+ mBadgeRenderer.draw(canvas, mBadgeInfo, mTempBounds,
badgeScale, mTempSpaceForBadgeOffset);
}
}
diff --git a/src/com/android/launcher3/graphics/RadialGradientView.java b/src/com/android/launcher3/graphics/GradientView.java
similarity index 65%
rename from src/com/android/launcher3/graphics/RadialGradientView.java
rename to src/com/android/launcher3/graphics/GradientView.java
index cf6851c..c5b7693 100644
--- a/src/com/android/launcher3/graphics/RadialGradientView.java
+++ b/src/com/android/launcher3/graphics/GradientView.java
@@ -27,7 +27,8 @@
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
-import android.view.animation.DecelerateInterpolator;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.Interpolator;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -36,63 +37,50 @@
* Draws a translucent radial gradient background from an initial state with progress 0.0 to a
* final state with progress 1.0;
*/
-public class RadialGradientView extends View {
+public class GradientView extends View {
- public static final int DEFAULT_COLOR_1 = Color.WHITE;
- public static final int DEFAULT_COLOR_2 = Color.BLACK;
+ private static final int DEFAULT_COLOR = Color.WHITE;
+ private static final float GRADIENT_ALPHA_MASK_LENGTH_DP = 300;
+ private static final float FINAL_GRADIENT_ALPHA = 0.75f;
+ private static final boolean DEBUG = false;
private static Bitmap sFinalGradientMask;
private static Bitmap sAlphaGradientMask;
- // TODO needs to be cleaned up once design finalizes
- static class Config {
- // dimens
- final float gradientCenterX = 0.5f;
- final float gradientCenterY = 1.05f;
- final float gradientHeadStartFactor = 0.35f;
- final float gradientAlphaMaskLengthDp = 700;
- // interpolation
- final boolean useGradientAlphaDecel = false;
- final float decelFactorForGradientAlpha = 2f;
- // colors
- final float finalGradientAlpha = 0.75f;
- int color1 = DEFAULT_COLOR_1;
- int color2 = DEFAULT_COLOR_2;
- }
-
+ private int mColor1 = DEFAULT_COLOR;
+ private int mColor2 = DEFAULT_COLOR;
+ private int mWidth;
+ private int mHeight;
private final RectF mAlphaMaskRect = new RectF();
private final RectF mFinalMaskRect = new RectF();
private final Paint mPaint = new Paint();
- private final Config mConfig = new Config();
- private final DecelerateInterpolator mDecelInterpolator;
private float mProgress;
- private int mWidth;
- private int mHeight;
private final int mMaskHeight;
private final Context mAppContext;
+ private final Paint mDebugPaint = DEBUG ? new Paint() : null;
+ private final Interpolator mAccelerator = new AccelerateInterpolator();
- public RadialGradientView(Context context, AttributeSet attrs) {
+ public GradientView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mAppContext = context.getApplicationContext();
- this.mDecelInterpolator = new DecelerateInterpolator(mConfig.decelFactorForGradientAlpha);
- this.mMaskHeight = Utilities.pxFromDp(mConfig.gradientAlphaMaskLengthDp,
+ this.mMaskHeight = Utilities.pxFromDp(GRADIENT_ALPHA_MASK_LENGTH_DP,
mAppContext.getResources().getDisplayMetrics());
if (sFinalGradientMask == null) {
sFinalGradientMask = Utilities.convertToAlphaMask(
- Utilities.createOnePixBitmap(), mConfig.finalGradientAlpha);
+ Utilities.createOnePixBitmap(), FINAL_GRADIENT_ALPHA);
}
if (sAlphaGradientMask == null) {
Bitmap alphaMaskFromResource = BitmapFactory.decodeResource(context.getResources(),
R.drawable.all_apps_alpha_mask);
sAlphaGradientMask = Utilities.convertToAlphaMask(
- alphaMaskFromResource, mConfig.finalGradientAlpha);
+ alphaMaskFromResource, FINAL_GRADIENT_ALPHA);
}
}
public void onExtractedColorsChanged(int color1, int color2) {
- mConfig.color1 = color1;
- mConfig.color2 = color2;
+ this.mColor1 = color1;
+ this.mColor2 = color2;
if (mWidth + mHeight > 0) {
createRadialShader();
}
@@ -110,14 +98,15 @@
// only being called when colors change
private void createRadialShader() {
- float radius = Math.max(mHeight, mWidth) * mConfig.gradientCenterY;
+ final float gradientCenterY = 1.05f;
+ float radius = Math.max(mHeight, mWidth) * gradientCenterY;
float posScreenBottom = (radius - mHeight) / radius; // center lives below screen
RadialGradient shader = new RadialGradient(
- mWidth * mConfig.gradientCenterX,
- mHeight * mConfig.gradientCenterY,
+ mWidth * 0.5f,
+ mHeight * gradientCenterY,
radius,
- new int[] {mConfig.color1, mConfig.color1, mConfig.color2},
+ new int[] {mColor1, mColor1, mColor2},
new float[] {0f, posScreenBottom, 1f},
Shader.TileMode.CLAMP);
mPaint.setShader(shader);
@@ -130,17 +119,22 @@
@Override
protected void onDraw(Canvas canvas) {
- float head = mConfig.gradientHeadStartFactor;
+ float head = 0.29f;
float linearProgress = head + (mProgress * (1f - head));
- float adjustProgress = mConfig.useGradientAlphaDecel
- ? mDecelInterpolator.getInterpolation(linearProgress)
- : linearProgress;
- float startMaskY = (1f - adjustProgress) * mHeight - mMaskHeight * adjustProgress;
-
+ float startMaskY = (1f - linearProgress) * mHeight - mMaskHeight * linearProgress;
+ float startAlpha = 100;
+ float interpolatedAlpha = (255 - startAlpha) * mAccelerator.getInterpolation(mProgress);
+ mPaint.setAlpha((int) (startAlpha + interpolatedAlpha));
mAlphaMaskRect.set(0, startMaskY, mWidth, startMaskY + mMaskHeight);
mFinalMaskRect.set(0, startMaskY + mMaskHeight, mWidth, mHeight);
canvas.drawBitmap(sAlphaGradientMask, null, mAlphaMaskRect, mPaint);
canvas.drawBitmap(sFinalGradientMask, null, mFinalMaskRect, mPaint);
+
+ if (DEBUG) {
+ mDebugPaint.setColor(0xFF00FF00);
+ canvas.drawLine(0, startMaskY, mWidth, startMaskY, mDebugPaint);
+ canvas.drawLine(0, startMaskY + mMaskHeight, mWidth, startMaskY + mMaskHeight, mDebugPaint);
+ }
}
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/graphics/IconPalette.java b/src/com/android/launcher3/graphics/IconPalette.java
index 0182e53..60ca7b2 100644
--- a/src/com/android/launcher3/graphics/IconPalette.java
+++ b/src/com/android/launcher3/graphics/IconPalette.java
@@ -49,7 +49,7 @@
private IconPalette(int color) {
dominantColor = color;
- backgroundColor = getMutedColor(dominantColor);
+ backgroundColor = dominantColor;
ColorMatrix backgroundColorMatrix = new ColorMatrix();
Themes.setColorScaleOnMatrix(backgroundColor, backgroundColorMatrix);
backgroundColorMatrixFilter = new ColorMatrixColorFilter(backgroundColorMatrix);
@@ -176,10 +176,6 @@
return ColorUtils.LABToColor(low, a, b);
}
- private static int getMutedColor(int color) {
- return getMutedColor(color, 0.87f);
- }
-
private static int getMutedColor(int color, float whiteScrimAlpha) {
int whiteScrim = ColorUtils.setAlphaComponent(Color.WHITE, (int) (255 * whiteScrimAlpha));
return ColorUtils.compositeColors(whiteScrim, color);
diff --git a/src/com/android/launcher3/graphics/ScrimView.java b/src/com/android/launcher3/graphics/ScrimView.java
index 521fbed..feb3f03 100644
--- a/src/com/android/launcher3/graphics/ScrimView.java
+++ b/src/com/android/launcher3/graphics/ScrimView.java
@@ -26,18 +26,22 @@
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.view.View;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.Interpolator;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
public class ScrimView extends View {
- // Config
- private static final int MASK_HEIGHT_DP = 600;
- private static final float MASK_START_LENGTH_FACTOR = 0.4f;
+ private static final boolean DEBUG = false;
+
+ private static final int MASK_HEIGHT_DP = 300;
+ private static final float MASK_START_LENGTH_FACTOR = 1f;
private static final float FINAL_ALPHA = 0.87f;
private static final int SCRIM_COLOR = ColorUtils.setAlphaComponent(
Color.WHITE, (int) (FINAL_ALPHA * 255));
+ private static final boolean APPLY_ALPHA = true;
private static Bitmap sFinalScrimMask;
private static Bitmap sAlphaScrimMask;
@@ -50,6 +54,8 @@
private final RectF mFinalMaskRect = new RectF();
private final Paint mPaint = new Paint();
private float mProgress;
+ private final Interpolator mAccelerator = new AccelerateInterpolator();
+ private final Paint mDebugPaint = DEBUG ? new Paint() : null;
public ScrimView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -73,17 +79,22 @@
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
mVisibleHeight = MeasureSpec.getSize(heightMeasureSpec);
- int fullHeight = mVisibleHeight * 2 + mMaskHeight;
- setMeasuredDimension(width, fullHeight);
+ setMeasuredDimension(width, mVisibleHeight * 2);
setProgress(mProgress);
}
public void setProgress(float progress) {
mProgress = progress;
float initialY = mVisibleHeight - mHeadStart;
- float fullTranslationY = mMaskHeight + initialY + mVisibleHeight;
- float translationY = initialY - progress * fullTranslationY;
- setTranslationY(translationY);
+ float fullTranslationY = mVisibleHeight;
+ float linTranslationY = initialY - progress * fullTranslationY;
+ setTranslationY(linTranslationY);
+
+ if (APPLY_ALPHA) {
+ int alpha = 55 + (int) (200f * mAccelerator.getInterpolation(progress));
+ mPaint.setAlpha(alpha);
+ invalidate();
+ }
}
@Override
@@ -92,6 +103,12 @@
mFinalMaskRect.set(0, mMaskHeight, getWidth(), getHeight());
canvas.drawBitmap(sAlphaScrimMask, null, mAlphaMaskRect, mPaint);
canvas.drawBitmap(sFinalScrimMask, null, mFinalMaskRect, mPaint);
+
+ if (DEBUG) {
+ mDebugPaint.setColor(0xFF0000FF);
+ canvas.drawLine(0, mAlphaMaskRect.top, getWidth(), mAlphaMaskRect.top, mDebugPaint);
+ canvas.drawLine(0, mAlphaMaskRect.bottom, getWidth(), mAlphaMaskRect.bottom, mDebugPaint);
+ }
}
}
diff --git a/src/com/android/launcher3/graphics/ShadowDrawable.java b/src/com/android/launcher3/graphics/ShadowDrawable.java
index 5e76649..5f4fc6c 100644
--- a/src/com/android/launcher3/graphics/ShadowDrawable.java
+++ b/src/com/android/launcher3/graphics/ShadowDrawable.java
@@ -46,6 +46,7 @@
private final ShadowDrawableState mState;
+ @SuppressWarnings("unused")
public ShadowDrawable() {
this(new ShadowDrawableState());
}
@@ -98,17 +99,6 @@
return mState.mIntrinsicWidth;
}
- /**
- * Sets the color for the generated shadow
- */
- public void setShadowColor(int color) {
- if (mState.mShadowColor != color) {
- mState.mShadowColor = color;
- mState.mLastDrawnBitmap = null;
- invalidateSelf();
- }
- }
-
private void regenerateBitmapCache() {
Bitmap bitmap = Bitmap.createBitmap(mState.mIntrinsicWidth, mState.mIntrinsicHeight,
Bitmap.Config.ARGB_8888);
@@ -154,7 +144,8 @@
}
mState.mShadowColor = a.getColor(
R.styleable.ShadowDrawable_android_shadowColor, Color.BLACK);
- mState.mShadowSize = r.getDimensionPixelSize(R.dimen.drawable_shadow_size);
+ mState.mShadowSize = a.getDimensionPixelSize(
+ R.styleable.ShadowDrawable_android_elevation, 0);
mState.mIntrinsicHeight = d.getIntrinsicHeight() + 2 * mState.mShadowSize;
mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 7899846..7585be6 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -62,9 +62,11 @@
private static final boolean IS_VERBOSE =
FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT);
- public static UserEventDispatcher newInstance(Context context, boolean isInMultiWindowMode) {
+ public static UserEventDispatcher newInstance(Context context, boolean isInLandscapeMode,
+ boolean isInMultiWindowMode) {
UserEventDispatcher ued = Utilities.getOverrideObject(UserEventDispatcher.class,
context.getApplicationContext(), R.string.user_event_dispatcher_class);
+ ued.mIsInLandscapeMode = isInLandscapeMode;
ued.mIsInMultiWindowMode = isInMultiWindowMode;
return ued;
}
@@ -112,6 +114,7 @@
private long mElapsedSessionMillis;
private long mActionDurationMillis;
private boolean mIsInMultiWindowMode;
+ private boolean mIsInLandscapeMode;
// Used for filling in predictedRank on {@link Target}s.
private List<ComponentKey> mPredictedApps;
@@ -296,6 +299,7 @@
}
public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
+ ev.isInLandscapeMode = mIsInLandscapeMode;
ev.isInMultiWindowMode = mIsInMultiWindowMode;
ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;
@@ -315,6 +319,7 @@
ev.elapsedContainerMillis,
ev.elapsedSessionMillis,
ev.actionDurationMillis);
+ log += "\n isInLandscapeMode " + ev.isInLandscapeMode;
log += "\n isInMultiWindowMode " + ev.isInMultiWindowMode;
Log.d(TAG, log);
}