Loading res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,9 @@ <!-- Name of a user event dispatcher class. --> <string name="user_event_dispatcher_class" translatable="false"></string> <!-- Name of a color extraction implementation class. --> <string name="color_extraction_impl_class" translatable="false"></string> <!-- Package name of the default wallpaper picker. --> <string name="wallpaper_picker_package" translatable="false"></string> Loading src/com/android/launcher3/dynamicui/colorextraction/types/Tonal.java→src/com/android/launcher3/dynamicui/ColorExtractionAlgorithm.java +33 −30 Original line number Diff line number Diff line package com.android.launcher3.dynamicui.colorextraction.types; /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.dynamicui; import android.content.Context; import android.graphics.Color; import android.support.annotation.NonNull; import android.support.annotation.Nullable; Loading @@ -8,6 +25,8 @@ import android.util.Log; import android.util.Pair; import android.util.SparseIntArray; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.compat.WallpaperColorsCompat; import java.util.ArrayList; Loading @@ -15,13 +34,16 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; /** * Implementation of tonal color extraction * * TODO remove this class if available by platform */ public class Tonal implements ExtractionType { **/ public class ColorExtractionAlgorithm { public static ColorExtractionAlgorithm newInstance(Context context) { return Utilities.getOverrideObject(ColorExtractionAlgorithm.class, context.getApplicationContext(), R.string.color_extraction_impl_class); } private static final String TAG = "Tonal"; // Used for tonal palette fitting Loading @@ -32,6 +54,9 @@ public class Tonal implements ExtractionType { private static final float MIN_COLOR_OCCURRENCE = 0.1f; private static final float MIN_LUMINOSITY = 0.5f; public ColorExtractionAlgorithm() { } public @Nullable Pair<Integer, Integer> extractInto(WallpaperColorsCompat wallpaperColors) { if (wallpaperColors == null) { return null; Loading Loading @@ -142,34 +167,12 @@ public class Tonal implements ExtractionType { float delta = v - data[index]; for (int i = 0; i < data.length; i++) { fitData[i] = constrain(data[i] + delta, min, max); fitData[i] = Utilities.boundToRange(data[i] + delta, min, max); } return fitData; } // TODO no MathUtils private static float constrain(float x, float min, float max) { x = Math.min(x, max); x = Math.max(x, min); return x; } /*function adjustSatLumForFit(val, points, fitIndex) { var fitValue = lerpBetweenPoints(points, fitIndex); var diff = val - fitValue; var newPoints = []; for (var ii=0; ii<points.length; ii++) { var point = [points[ii][0], points[ii][1]]; point[1] += diff; if (point[1] > 1) point[1] = 1; if (point[1] < 0) point[1] = 0; newPoints[ii] = point; } return newPoints; }*/ /** * Finds the closest color in a palette, given another HSL color * Loading Loading @@ -308,5 +311,5 @@ public class Tonal implements ExtractionType { new float[] { 0.241f, 0.316f, 0.46f, 0.586f, 0.655f, 0.7f, 0.75f, 0.8f, 0.84f, 0.88f } ) }; } } src/com/android/launcher3/dynamicui/WallpaperColorInfo.java +2 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,6 @@ import android.util.Pair; import com.android.launcher3.compat.WallpaperColorsCompat; import com.android.launcher3.compat.WallpaperManagerCompat; import com.android.launcher3.dynamicui.colorextraction.types.ExtractionType; import com.android.launcher3.dynamicui.colorextraction.types.Tonal; import java.util.ArrayList; Loading @@ -31,7 +29,7 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange private final ArrayList<OnChangeListener> mListeners = new ArrayList<>(); private final WallpaperManagerCompat mWallpaperManager; private final ExtractionType mExtractionType; private final ColorExtractionAlgorithm mExtractionType; private int mMainColor; private int mSecondaryColor; private boolean mIsDark; Loading @@ -40,7 +38,7 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange private WallpaperColorInfo(Context context) { mWallpaperManager = WallpaperManagerCompat.getInstance(context); mWallpaperManager.addOnColorsChangedListener(this); mExtractionType = new Tonal(); // TODO create and use DefaultExtractionLogic mExtractionType = ColorExtractionAlgorithm.newInstance(context); update(mWallpaperManager.getWallpaperColors(FLAG_SYSTEM)); } Loading src/com/android/launcher3/dynamicui/colorextraction/types/ExtractionType.javadeleted 100644 → 0 +0 −22 Original line number Diff line number Diff line package com.android.launcher3.dynamicui.colorextraction.types; import android.support.annotation.Nullable; import android.util.Pair; import com.android.launcher3.compat.WallpaperColorsCompat; /** * Interface to allow various color extraction implementations. */ public interface ExtractionType { /** * Executes color extraction by reading WallpaperColors and setting * main and secondary colors. * * @param wallpaperColors where to read from * @return a pair of main and secondary color */ @Nullable Pair<Integer, Integer> extractInto(WallpaperColorsCompat wallpaperColors); } src_flags/com/android/launcher3/config/FeatureFlags.java +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public final class FeatureFlags { // When enabled the promise icon is visible in all apps while installation an app. public static boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = true; // When enabled uses the AllAppsRadialGradientAndScrimDrawable for all apps public static boolean LAUNCHER3_GRADIENT_ALL_APPS = false; public static boolean LAUNCHER3_GRADIENT_ALL_APPS = true; // When enabled allows use of physics based motions in the Launcher. public static boolean LAUNCHER3_PHYSICS = true; Loading Loading
res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,9 @@ <!-- Name of a user event dispatcher class. --> <string name="user_event_dispatcher_class" translatable="false"></string> <!-- Name of a color extraction implementation class. --> <string name="color_extraction_impl_class" translatable="false"></string> <!-- Package name of the default wallpaper picker. --> <string name="wallpaper_picker_package" translatable="false"></string> Loading
src/com/android/launcher3/dynamicui/colorextraction/types/Tonal.java→src/com/android/launcher3/dynamicui/ColorExtractionAlgorithm.java +33 −30 Original line number Diff line number Diff line package com.android.launcher3.dynamicui.colorextraction.types; /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.dynamicui; import android.content.Context; import android.graphics.Color; import android.support.annotation.NonNull; import android.support.annotation.Nullable; Loading @@ -8,6 +25,8 @@ import android.util.Log; import android.util.Pair; import android.util.SparseIntArray; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.compat.WallpaperColorsCompat; import java.util.ArrayList; Loading @@ -15,13 +34,16 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; /** * Implementation of tonal color extraction * * TODO remove this class if available by platform */ public class Tonal implements ExtractionType { **/ public class ColorExtractionAlgorithm { public static ColorExtractionAlgorithm newInstance(Context context) { return Utilities.getOverrideObject(ColorExtractionAlgorithm.class, context.getApplicationContext(), R.string.color_extraction_impl_class); } private static final String TAG = "Tonal"; // Used for tonal palette fitting Loading @@ -32,6 +54,9 @@ public class Tonal implements ExtractionType { private static final float MIN_COLOR_OCCURRENCE = 0.1f; private static final float MIN_LUMINOSITY = 0.5f; public ColorExtractionAlgorithm() { } public @Nullable Pair<Integer, Integer> extractInto(WallpaperColorsCompat wallpaperColors) { if (wallpaperColors == null) { return null; Loading Loading @@ -142,34 +167,12 @@ public class Tonal implements ExtractionType { float delta = v - data[index]; for (int i = 0; i < data.length; i++) { fitData[i] = constrain(data[i] + delta, min, max); fitData[i] = Utilities.boundToRange(data[i] + delta, min, max); } return fitData; } // TODO no MathUtils private static float constrain(float x, float min, float max) { x = Math.min(x, max); x = Math.max(x, min); return x; } /*function adjustSatLumForFit(val, points, fitIndex) { var fitValue = lerpBetweenPoints(points, fitIndex); var diff = val - fitValue; var newPoints = []; for (var ii=0; ii<points.length; ii++) { var point = [points[ii][0], points[ii][1]]; point[1] += diff; if (point[1] > 1) point[1] = 1; if (point[1] < 0) point[1] = 0; newPoints[ii] = point; } return newPoints; }*/ /** * Finds the closest color in a palette, given another HSL color * Loading Loading @@ -308,5 +311,5 @@ public class Tonal implements ExtractionType { new float[] { 0.241f, 0.316f, 0.46f, 0.586f, 0.655f, 0.7f, 0.75f, 0.8f, 0.84f, 0.88f } ) }; } }
src/com/android/launcher3/dynamicui/WallpaperColorInfo.java +2 −4 Original line number Diff line number Diff line Loading @@ -7,8 +7,6 @@ import android.util.Pair; import com.android.launcher3.compat.WallpaperColorsCompat; import com.android.launcher3.compat.WallpaperManagerCompat; import com.android.launcher3.dynamicui.colorextraction.types.ExtractionType; import com.android.launcher3.dynamicui.colorextraction.types.Tonal; import java.util.ArrayList; Loading @@ -31,7 +29,7 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange private final ArrayList<OnChangeListener> mListeners = new ArrayList<>(); private final WallpaperManagerCompat mWallpaperManager; private final ExtractionType mExtractionType; private final ColorExtractionAlgorithm mExtractionType; private int mMainColor; private int mSecondaryColor; private boolean mIsDark; Loading @@ -40,7 +38,7 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange private WallpaperColorInfo(Context context) { mWallpaperManager = WallpaperManagerCompat.getInstance(context); mWallpaperManager.addOnColorsChangedListener(this); mExtractionType = new Tonal(); // TODO create and use DefaultExtractionLogic mExtractionType = ColorExtractionAlgorithm.newInstance(context); update(mWallpaperManager.getWallpaperColors(FLAG_SYSTEM)); } Loading
src/com/android/launcher3/dynamicui/colorextraction/types/ExtractionType.javadeleted 100644 → 0 +0 −22 Original line number Diff line number Diff line package com.android.launcher3.dynamicui.colorextraction.types; import android.support.annotation.Nullable; import android.util.Pair; import com.android.launcher3.compat.WallpaperColorsCompat; /** * Interface to allow various color extraction implementations. */ public interface ExtractionType { /** * Executes color extraction by reading WallpaperColors and setting * main and secondary colors. * * @param wallpaperColors where to read from * @return a pair of main and secondary color */ @Nullable Pair<Integer, Integer> extractInto(WallpaperColorsCompat wallpaperColors); }
src_flags/com/android/launcher3/config/FeatureFlags.java +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public final class FeatureFlags { // When enabled the promise icon is visible in all apps while installation an app. public static boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = true; // When enabled uses the AllAppsRadialGradientAndScrimDrawable for all apps public static boolean LAUNCHER3_GRADIENT_ALL_APPS = false; public static boolean LAUNCHER3_GRADIENT_ALL_APPS = true; // When enabled allows use of physics based motions in the Launcher. public static boolean LAUNCHER3_PHYSICS = true; Loading