From be1ef90bcb60be4f9c74e36f20cf4cdbc06a5d81 Mon Sep 17 00:00:00 2001 From: Edward Cross Date: Tue, 31 Jul 2018 15:17:57 +0200 Subject: Launcher3: Google Feed integration If Google Search is installed, the Google Feed can be found at the -1 screen (which is the very left). This feature is enabled by default. Change-Id: I495196818699fd378cd60e6dd61b07a0ab951762 --- Android.mk | 16 ++++- build.gradle | 2 + libs/libGoogleFeed.jar | Bin 0 -> 24271 bytes res/values-ldrtl/lineage_config.xml | 19 +++++ res/values/lineage_config.xml | 19 +++++ res/values/lineage_strings.xml | 26 +++++++ res/xml/launcher_preferences.xml | 6 ++ .../lineage/LineageLauncherCallbacks.java | 54 ++++++++++++-- .../android/launcher3/lineage/LineageUtils.java | 17 +++++ .../launcher3/lineage/OverlayCallbackImpl.java | 80 +++++++++++++++++++++ .../launcher3/settings/SettingsActivity.java | 9 +++ 11 files changed, 240 insertions(+), 8 deletions(-) create mode 100644 libs/libGoogleFeed.jar create mode 100644 res/values-ldrtl/lineage_config.xml create mode 100644 res/values/lineage_config.xml create mode 100644 res/values/lineage_strings.xml create mode 100644 src/com/android/launcher3/lineage/LineageUtils.java create mode 100644 src/com/android/launcher3/lineage/OverlayCallbackImpl.java diff --git a/Android.mk b/Android.mk index a765b1399..811322f7a 100644 --- a/Android.mk +++ b/Android.mk @@ -39,6 +39,18 @@ LOCAL_MODULE := LauncherPluginLib include $(BUILD_STATIC_JAVA_LIBRARY) +# +# Prebuilt Google Feed library +# +include $(CLEAR_VARS) +LOCAL_MODULE := libGoogleFeed +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := JAVA_LIBRARIES +LOCAL_SRC_FILES := libs/libGoogleFeed.jar +LOCAL_UNINSTALLABLE_MODULE := true +LOCAL_SDK_VERSION := 27 +include $(BUILD_PREBUILT) + # # Build rule for Launcher3 dependencies lib. # @@ -53,7 +65,9 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \ androidx.preference_preference \ iconloader_base -LOCAL_STATIC_JAVA_LIBRARIES := LauncherPluginLib +LOCAL_STATIC_JAVA_LIBRARIES := \ + LauncherPluginLib \ + libGoogleFeed LOCAL_SRC_FILES := \ $(call all-proto-files-under, protos) \ diff --git a/build.gradle b/build.gradle index e296455be..e419b0adc 100644 --- a/build.gradle +++ b/build.gradle @@ -147,6 +147,8 @@ repositories { } dependencies { + implementation fileTree(dir: 'libs', include: ['libGoogleFeed.jar']) + implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}" implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}" implementation "androidx.preference:preference:${ANDROID_X_VERSION}" diff --git a/libs/libGoogleFeed.jar b/libs/libGoogleFeed.jar new file mode 100644 index 000000000..5cda956ac Binary files /dev/null and b/libs/libGoogleFeed.jar differ diff --git a/res/values-ldrtl/lineage_config.xml b/res/values-ldrtl/lineage_config.xml new file mode 100644 index 000000000..7067ca880 --- /dev/null +++ b/res/values-ldrtl/lineage_config.xml @@ -0,0 +1,19 @@ + + + + + @string/msg_minus_one_on_left + diff --git a/res/values/lineage_config.xml b/res/values/lineage_config.xml new file mode 100644 index 000000000..7067ca880 --- /dev/null +++ b/res/values/lineage_config.xml @@ -0,0 +1,19 @@ + + + + + @string/msg_minus_one_on_left + diff --git a/res/values/lineage_strings.xml b/res/values/lineage_strings.xml new file mode 100644 index 000000000..e5a10302d --- /dev/null +++ b/res/values/lineage_strings.xml @@ -0,0 +1,26 @@ + + + + + + + + Show Google app + + When you swipe right from main home screen + + When you swipe left from main home screen + diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml index 3455cb866..f4165c3b2 100644 --- a/res/xml/launcher_preferences.xml +++ b/res/xml/launcher_preferences.xml @@ -44,6 +44,12 @@ android:defaultValue="@bool/allow_rotation" android:persistent="true" /> + + Implements {@link LauncherClientCallbacks} and sends all the corresponding callbacks to {@link + * Launcher}. + */ +public class OverlayCallbackImpl implements LauncherOverlay, LauncherClientCallbacks { + private final Launcher mLauncher; + + private LauncherClient mClient; + private LauncherOverlayCallbacks mLauncherOverlayCallbacks; + private boolean mWasOverlayAttached = false; + + public OverlayCallbackImpl(Launcher launcher) { + mLauncher = launcher; + } + + public void setClient(LauncherClient client) { + mClient = client; + } + + @Override + public void onServiceStateChanged(boolean overlayAttached, boolean hotwordActive) { + if (overlayAttached != mWasOverlayAttached) { + mWasOverlayAttached = overlayAttached; + mLauncher.setLauncherOverlay(overlayAttached ? this : null); + } + } + + @Override + public void onOverlayScrollChanged(float progress) { + if (mLauncherOverlayCallbacks != null) { + mLauncherOverlayCallbacks.onScrollChanged(progress); + } + } + + @Override + public void onScrollInteractionBegin() { + mClient.startMove(); + } + + @Override + public void onScrollInteractionEnd() { + mClient.endMove(); + } + + @Override + public void onScrollChange(float progress, boolean rtl) { + mClient.updateMove(progress); + } + + @Override + public void setOverlayCallbacks(Launcher.LauncherOverlayCallbacks callbacks) { + mLauncherOverlayCallbacks = callbacks; + } +} diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 18b6094fb..6209c5ef0 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -37,6 +37,8 @@ import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.graphics.GridOptionsProvider; +import com.android.launcher3.lineage.LineageLauncherCallbacks; +import com.android.launcher3.lineage.LineageUtils; import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; import com.android.launcher3.util.SecureSettingsObserver; @@ -69,6 +71,8 @@ public class SettingsActivity extends Activity public static final String GRID_OPTIONS_PREFERENCE_KEY = "pref_grid_options"; + public static final String KEY_MINUS_ONE = "pref_enable_minus_one"; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -230,6 +234,11 @@ public class SettingsActivity extends Activity // Show if plugins are enabled or flag UI is enabled. return FeatureFlags.showFlagTogglerUi(getContext()) || PluginManagerWrapper.hasPlugins(getContext()); + + case KEY_MINUS_ONE: + return LineageUtils.hasPackageInstalled(getActivity(), + LineageLauncherCallbacks.SEARCH_PACKAGE); + case GRID_OPTIONS_PREFERENCE_KEY: return Utilities.isDevelopersOptionsEnabled(getContext()) && Utilities.IS_DEBUG_DEVICE && -- cgit v1.2.3