diff options
-rw-r--r-- | res/values-gl-rES/strings.xml | 2 | ||||
-rw-r--r-- | res/values-uz-rUZ/strings.xml | 2 | ||||
-rw-r--r-- | res/values/dimens.xml | 4 | ||||
-rw-r--r-- | res/values/styles.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 44 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsTransitionController.java | 34 | ||||
-rw-r--r-- | src/com/android/launcher3/dynamicui/ColorExtractionService.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/dynamicui/ExtractedColors.java | 10 |
8 files changed, 74 insertions, 40 deletions
diff --git a/res/values-gl-rES/strings.xml b/res/values-gl-rES/strings.xml index 62765d538..c03ecdc51 100644 --- a/res/values-gl-rES/strings.xml +++ b/res/values-gl-rES/strings.xml @@ -30,7 +30,7 @@ <string name="long_press_widget_to_add" msgid="7699152356777458215">"Mantén premido un widget para seleccionalo."</string> <string name="long_accessible_way_to_add" msgid="4289502106628154155">"Toca dúas veces e mantén premido para seleccionar un widget ou utiliza accións personalizadas."</string> <string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string> - <string name="widget_accessible_dims_format" msgid="3640149169885301790">"%1$d de largo por %2$d alto"</string> + <string name="widget_accessible_dims_format" msgid="3640149169885301790">"%1$d de largo por %2$d de alto"</string> <string name="all_apps_search_bar_hint" msgid="7084713969757597256">"Aplicacións de busca"</string> <string name="all_apps_loading_message" msgid="7557140873644765180">"Cargando aplicacións..."</string> <string name="all_apps_no_search_results" msgid="6332185285860416787">"Non se atoparon aplicacións que coincidan con \"<xliff:g id="QUERY">%1$s</xliff:g>\""</string> diff --git a/res/values-uz-rUZ/strings.xml b/res/values-uz-rUZ/strings.xml index a36db9fa6..0e541d37a 100644 --- a/res/values-uz-rUZ/strings.xml +++ b/res/values-uz-rUZ/strings.xml @@ -30,7 +30,7 @@ <string name="long_press_widget_to_add" msgid="7699152356777458215">"Vidjetni tanlash uchun bosib turing."</string> <string name="long_accessible_way_to_add" msgid="4289502106628154155">"Ikki marta bosib va bosib turgan holatda vidjetni tanlang yoki maxsus amaldan foydalaning."</string> <string name="widget_dims_format" msgid="2370757736025621599">"%1$d × %2$d"</string> - <string name="widget_accessible_dims_format" msgid="3640149169885301790">"eniga %1$d, bo‘yiga %2$d"</string> + <string name="widget_accessible_dims_format" msgid="3640149169885301790">"Eni %1$d, bo‘yi %2$d"</string> <string name="all_apps_search_bar_hint" msgid="7084713969757597256">"Ilovalar ichidan qidirish"</string> <string name="all_apps_loading_message" msgid="7557140873644765180">"Ilovalar yuklanmoqda…"</string> <string name="all_apps_no_search_results" msgid="6332185285860416787">"“<xliff:g id="QUERY">%1$s</xliff:g>” so‘rovi bo‘yicha hech narsa topilmadi"</string> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 367cee48a..c112949ba 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -182,4 +182,8 @@ also happens to equal 19dp--> <dimen name="deep_shortcuts_arrow_horizontal_offset">19dp</dimen> +<!-- Other --> + <!-- Approximates the system status bar height. Not guaranteed to be always be correct. --> + <dimen name="status_bar_height">24dp</dimen> + </resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index 87a56295a..cd06b7560 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -101,8 +101,8 @@ <!-- Drop targets --> <style name="DropTargetButtonBase"> <item name="android:drawablePadding">7.5dp</item> - <item name="android:paddingLeft">25dp</item> - <item name="android:paddingRight">25dp</item> + <item name="android:paddingLeft">16dp</item> + <item name="android:paddingRight">16dp</item> <item name="android:textColor">#FFFFFFFF</item> <item name="android:textSize">@dimen/drop_target_text_size</item> <item name="android:singleLine">true</item> diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 2b64d42d2..c73a7a61d 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -277,9 +277,9 @@ public class Launcher extends Activity private LauncherAccessibilityDelegate mAccessibilityDelegate; private boolean mIsResumeFromActionScreenOff; @Thunk boolean mUserPresent = true; - private boolean mVisible = false; - private boolean mHasFocus = false; - private boolean mAttached = false; + private boolean mVisible; + private boolean mHasFocus; + private boolean mAttached; /** Maps launcher activity components to their list of shortcut ids. */ private MultiHashMap<ComponentKey, String> mDeepShortcutMap = new MultiHashMap<>(); @@ -484,10 +484,33 @@ public class Launcher extends Activity private void loadExtractedColorsAndColorItems() { // TODO: do this in pre-N as well, once the extraction part is complete. - if (mExtractedColors != null && Utilities.isNycOrAbove()) { + if (Utilities.isNycOrAbove()) { mExtractedColors.load(this); mHotseat.updateColor(mExtractedColors, !mPaused); mWorkspace.getPageIndicator().updateColor(mExtractedColors); + // It's possible that All Apps is visible when this is run, + // so always use light status bar in that case. + activateLightStatusBar(isAllAppsVisible()); + } + } + + /** + * Sets the status bar to be light or not. Light status bar means dark icons. + * @param activate if true, make sure the status bar is light, otherwise base on wallpaper. + */ + public void activateLightStatusBar(boolean activate) { + boolean lightStatusBar = activate + || mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX, + ExtractedColors.DEFAULT_DARK) == ExtractedColors.DEFAULT_LIGHT; + int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility(); + int newSystemUiFlags = oldSystemUiFlags; + if (lightStatusBar) { + newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; + } else { + newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + if (newSystemUiFlags != oldSystemUiFlags) { + getWindow().getDecorView().setSystemUiVisibility(newSystemUiFlags); } } @@ -1793,11 +1816,14 @@ public class Launcher extends Activity } super.onNewIntent(intent); - // Close the menu - Folder openFolder = mWorkspace.getOpenFolder(); boolean alreadyOnHome = mHasFocus && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); + + // Check this condition before handling isActionMain, as this will get reset. + boolean shouldMoveToDefaultScreen = alreadyOnHome && + mState == State.WORKSPACE && getTopFloatingView() == null; + boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction()); if (isActionMain) { // also will cancel mWaitingForResult. @@ -1852,10 +1878,10 @@ public class Launcher extends Activity // as slow logic in the callbacks eat into the time the scroller expects for the snapToPage // animation. if (isActionMain) { - boolean moveToDefaultScreen = mLauncherCallbacks != null ? + boolean callbackAllowsMoveToDefaultScreen = mLauncherCallbacks != null ? mLauncherCallbacks.shouldMoveToDefaultScreenOnHomeIntent() : true; - if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && - openFolder == null && moveToDefaultScreen) { + if (shouldMoveToDefaultScreen && !mWorkspace.isTouchActive() + && callbackAllowsMoveToDefaultScreen) { // We use this flag to suppress noisy callbacks above custom content state // from onResume. diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 1719b0594..b129bb09d 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -6,12 +6,15 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ArgbEvaluator; import android.animation.ObjectAnimator; +import android.graphics.Color; import android.support.v4.content.ContextCompat; +import android.support.v4.graphics.ColorUtils; import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.view.animation.AccelerateInterpolator; +import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import com.android.launcher3.DeviceProfile; @@ -41,6 +44,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private static final boolean DBG = false; private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f); + private final Interpolator mDecelInterpolator = new DecelerateInterpolator(3f); private final Interpolator mFastOutSlowInInterpolator = new FastOutSlowInInterpolator(); private final ScrollInterpolator mScrollInterpolator = new ScrollInterpolator(); @@ -86,8 +90,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private AnimatorSet mCurrentAnimation; private boolean mNoIntercept; - private boolean mLightStatusBar; - // Used in discovery bounce animation to provide the transition without workspace changing. private boolean mIsTranslateWithoutWorkspace = false; private AnimatorSet mDiscoBounceAnimation; @@ -273,26 +275,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } private void updateLightStatusBar(float shift) { - boolean enable = shift <= mStatusBarHeight / 2; // Do not modify status bar on landscape as all apps is not full bleed. if (mLauncher.getDeviceProfile().isVerticalBarLayout()) { return; } - // Already set correctly - if (mLightStatusBar == enable) { - return; - } - int systemUiFlags = mLauncher.getWindow().getDecorView().getSystemUiVisibility(); - if (enable) { - mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags - | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - - } else { - mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags - & ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)); - - } - mLightStatusBar = enable; + // Use a light status bar (dark icons) if all apps is behind at least half of the status + // bar. If the status bar is already light due to wallpaper extraction, keep it that way. + boolean forceLight = shift <= mStatusBarHeight / 2; + mLauncher.activateLightStatusBar(forceLight); } /** @@ -305,12 +295,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f); float alpha = 1 - workspaceHotseatAlpha; - float interpolation = mAccelInterpolator.getInterpolation(workspaceHotseatAlpha); - int color = (Integer) mEvaluator.evaluate(alpha, + int color = (Integer) mEvaluator.evaluate(mDecelInterpolator.getInterpolation(alpha), mHotseatBackgroundColor, mAllAppsBackgroundColor); - mAppsView.setRevealDrawableColor(color); + int bgAlpha = Color.alpha((int) mEvaluator.evaluate(alpha, + mHotseatBackgroundColor, mAllAppsBackgroundColor)); + + mAppsView.setRevealDrawableColor(ColorUtils.setAlphaComponent(color, bgAlpha)); mAppsView.getContentView().setAlpha(alpha); mAppsView.setTranslationY(shiftCurrent); diff --git a/src/com/android/launcher3/dynamicui/ColorExtractionService.java b/src/com/android/launcher3/dynamicui/ColorExtractionService.java index 89594f407..c15b71040 100644 --- a/src/com/android/launcher3/dynamicui/ColorExtractionService.java +++ b/src/com/android/launcher3/dynamicui/ColorExtractionService.java @@ -26,6 +26,7 @@ import android.support.v7.graphics.Palette; import com.android.launcher3.LauncherProvider; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.R; /** * Extracts colors from the wallpaper, and saves results to {@link LauncherProvider}. @@ -52,16 +53,21 @@ public class ColorExtractionService extends IntentService { Bitmap wallpaper = ((BitmapDrawable) wallpaperManager.getDrawable()).getBitmap(); Palette palette = Palette.from(wallpaper).generate(); extractedColors.updatePalette(palette); - // We extract colors for the hotseat separately, - // since it only considers the lower part of the wallpaper. - // TODO(twickham): update Palette library to 23.3.1 or higher, - // which fixes a bug with using regions (b/28349435). + // We extract colors for the hotseat and status bar separately, + // since they only consider part of the wallpaper. Palette hotseatPalette = Palette.from(wallpaper) .setRegion(0, (int) (wallpaper.getHeight() * (1f - HOTSEAT_FRACTION)), wallpaper.getWidth(), wallpaper.getHeight()) .clearFilters() .generate(); extractedColors.updateHotseatPalette(hotseatPalette); + + int statusBarHeight = getResources().getDimensionPixelSize(R.dimen.status_bar_height); + Palette statusBarPalette = Palette.from(wallpaper) + .setRegion(0, 0, wallpaper.getWidth(), statusBarHeight) + .clearFilters() + .generate(); + extractedColors.updateStatusBarPalette(statusBarPalette); } // Save the extracted colors and wallpaper id to LauncherProvider. diff --git a/src/com/android/launcher3/dynamicui/ExtractedColors.java b/src/com/android/launcher3/dynamicui/ExtractedColors.java index e545288a0..4db0797c0 100644 --- a/src/com/android/launcher3/dynamicui/ExtractedColors.java +++ b/src/com/android/launcher3/dynamicui/ExtractedColors.java @@ -38,6 +38,7 @@ public class ExtractedColors { // loading extracted colors. New colors should always be added at the end. public static final int VERSION_INDEX = 0; public static final int HOTSEAT_INDEX = 1; + public static final int STATUS_BAR_INDEX = 2; // public static final int VIBRANT_INDEX = 2; // public static final int VIBRANT_DARK_INDEX = 3; // public static final int VIBRANT_LIGHT_INDEX = 4; @@ -45,8 +46,8 @@ public class ExtractedColors { // public static final int MUTED_DARK_INDEX = 6; // public static final int MUTED_LIGHT_INDEX = 7; - public static final int NUM_COLOR_PROFILES = 1; - private static final int VERSION = 1; + public static final int NUM_COLOR_PROFILES = 2; + private static final int VERSION = 2; private static final String COLOR_SEPARATOR = ","; @@ -156,4 +157,9 @@ public class ExtractedColors { } setColorAtIndex(HOTSEAT_INDEX, hotseatColor); } + + public void updateStatusBarPalette(Palette statusBarPalette) { + setColorAtIndex(STATUS_BAR_INDEX, ExtractionUtils.isSuperLight(statusBarPalette) ? + DEFAULT_LIGHT : DEFAULT_DARK); + } } |