From 8847eb7a1ddb0b19c0c79de6d867444a68654874 Mon Sep 17 00:00:00 2001 From: Raj Yengisetty Date: Mon, 27 Jul 2015 14:52:21 -0700 Subject: Move CMHome into Trebuchet Change-Id: I781d10319d183cfb6acca5926ebf64920caf570e --- Android.mk | 32 +- AndroidManifest.xml | 1 + api/Android.mk | 27 ++ api/CleanSpec.mk | 14 + api/api.iml | 11 + api/proguard.flags | 8 + api/src/com/android/launcher/home/Home.java | 217 +++++++++ libs/dashclock-api-r2.0.jar | Bin 0 -> 18865 bytes libs/de-hdodenhof-circleimageview.jar | Bin 0 -> 6709 bytes res/drawable-xxhdpi/persona2.png | Bin 0 -> 333849 bytes res/layout/basic_dashclock_card_inner.xml | 13 + res/layout/calendar_card.xml | 41 ++ res/layout/calendar_event_item.xml | 70 +++ res/layout/card_image_layout.xml | 88 ++++ res/layout/card_status_header_inner.xml | 28 ++ res/layout/contact_card.xml | 62 +++ res/layout/dashclock_card_expand_inner_content.xml | 33 ++ res/layout/dashclock_card_inner_content.xml | 34 ++ res/layout/dashclock_icon_thumbnail_layout.xml | 9 + res/layout/home_layout.xml | 57 +++ res/layout/list_card_image_layout.xml | 30 ++ res/layout/news_card.xml | 62 +++ res/layout/news_card_first.xml | 73 +++ res/layout/simple_message_card_inner_content.xml | 27 ++ res/layout/status_card_inner_content.xml | 19 + res/values/colors.xml | 22 + res/values/dimens.xml | 4 + res/values/strings.xml | 78 ++++ res/values/styles.xml | 23 + src/com/android/launcher/home/Home.java | 2 +- src/com/cyanogen/cardbuilder/DataCardFactory.java | 22 + .../DashClockExtensionCardProvider.java | 296 ++++++++++++ .../launcher/cards/DashClockExtensionCard.java | 446 ++++++++++++++++++ .../launcher/cards/SimpleMessageCard.java | 55 +++ src/org/cyanogenmod/launcher/cards/StatusCard.java | 52 +++ .../launcher/cards/StatusCardHeader.java | 53 +++ .../launcher/dashclock/ExtensionHost.java | 479 +++++++++++++++++++ .../launcher/dashclock/ExtensionManager.java | 390 ++++++++++++++++ .../dashclock/ExtensionPackageChangeReceiver.java | 76 +++ .../cyanogenmod/launcher/home/CMHomeAdapter.java | 252 ++++++++++ .../cyanogenmod/launcher/home/CMHomeCalendar.java | 26 ++ src/org/cyanogenmod/launcher/home/CMHomeCard.java | 7 + .../cyanogenmod/launcher/home/CMHomeContact.java | 22 + src/org/cyanogenmod/launcher/home/CMHomeNews.java | 29 ++ .../cyanogenmod/launcher/home/HomeLauncher.java | 61 +++ src/org/cyanogenmod/launcher/home/HomeLayout.java | 41 ++ src/org/cyanogenmod/launcher/home/HomeStub.java | 517 +++++++++++++++++++++ .../cyanogenmod/trebuchet/CustomHomeLauncher.java | 53 ++- .../cyanogenmod/trebuchet/home/HomeWrapper.java | 5 +- 49 files changed, 3948 insertions(+), 19 deletions(-) create mode 100644 api/Android.mk create mode 100644 api/CleanSpec.mk create mode 100644 api/api.iml create mode 100644 api/proguard.flags create mode 100644 api/src/com/android/launcher/home/Home.java create mode 100644 libs/dashclock-api-r2.0.jar create mode 100644 libs/de-hdodenhof-circleimageview.jar create mode 100644 res/drawable-xxhdpi/persona2.png create mode 100644 res/layout/basic_dashclock_card_inner.xml create mode 100644 res/layout/calendar_card.xml create mode 100644 res/layout/calendar_event_item.xml create mode 100644 res/layout/card_image_layout.xml create mode 100644 res/layout/card_status_header_inner.xml create mode 100644 res/layout/contact_card.xml create mode 100644 res/layout/dashclock_card_expand_inner_content.xml create mode 100644 res/layout/dashclock_card_inner_content.xml create mode 100644 res/layout/dashclock_icon_thumbnail_layout.xml create mode 100644 res/layout/home_layout.xml create mode 100644 res/layout/list_card_image_layout.xml create mode 100644 res/layout/news_card.xml create mode 100644 res/layout/news_card_first.xml create mode 100644 res/layout/simple_message_card_inner_content.xml create mode 100644 res/layout/status_card_inner_content.xml create mode 100644 src/com/cyanogen/cardbuilder/DataCardFactory.java create mode 100644 src/org/cyanogenmod/launcher/cardprovider/DashClockExtensionCardProvider.java create mode 100644 src/org/cyanogenmod/launcher/cards/DashClockExtensionCard.java create mode 100644 src/org/cyanogenmod/launcher/cards/SimpleMessageCard.java create mode 100644 src/org/cyanogenmod/launcher/cards/StatusCard.java create mode 100644 src/org/cyanogenmod/launcher/cards/StatusCardHeader.java create mode 100644 src/org/cyanogenmod/launcher/dashclock/ExtensionHost.java create mode 100644 src/org/cyanogenmod/launcher/dashclock/ExtensionManager.java create mode 100644 src/org/cyanogenmod/launcher/dashclock/ExtensionPackageChangeReceiver.java create mode 100644 src/org/cyanogenmod/launcher/home/CMHomeAdapter.java create mode 100644 src/org/cyanogenmod/launcher/home/CMHomeCalendar.java create mode 100644 src/org/cyanogenmod/launcher/home/CMHomeCard.java create mode 100644 src/org/cyanogenmod/launcher/home/CMHomeContact.java create mode 100644 src/org/cyanogenmod/launcher/home/CMHomeNews.java create mode 100644 src/org/cyanogenmod/launcher/home/HomeLauncher.java create mode 100644 src/org/cyanogenmod/launcher/home/HomeLayout.java create mode 100644 src/org/cyanogenmod/launcher/home/HomeStub.java diff --git a/Android.mk b/Android.mk index b4f2e69e1..3fdb07b5d 100644 --- a/Android.mk +++ b/Android.mk @@ -25,15 +25,36 @@ LOCAL_MODULE_TAGS := optional LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13 \ android-support-v7-recyclerview \ - guava + guava \ + org.cyanogenmod.launcher.home \ + CMHomeSDK \ + dashclockapiv2 \ + android-support-v13 \ + cmfm-android-support-v7-appcompat \ + cmfm-android-support-design \ + android-support-v7-recyclerview \ + android-support-v7-cardview \ + de-hdodenhof-circleimageview + +library_src_files += ../../../external/cardslib/library/src/main/java \ + ../../../external/cyanogen/cmhomeapi/src/main/java + LOCAL_SRC_FILES := $(call all-java-files-under, src) \ $(call all-java-files-under, WallpaperPicker/src) \ + $(call all-java-files-under, $(library_src_files)) \ $(call all-renderscript-files-under, src) \ $(call all-proto-files-under, protos) -LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/WallpaperPicker/res $(LOCAL_PATH)/res -LOCAL_AAPT_FLAGS := --auto-add-overlay +LOCAL_RESOURCE_DIR += $(LOCAL_PATH)/res \ + $(LOCAL_PATH)/WallpaperPicker/res \ + frameworks/support/v7/cardview/res \ + $(LOCAL_PATH)/../../../external/cardslib/library/src/main/res \ + $(LOCAL_PATH)/../../../external/cyanogen/cmhomeapi/src/main/res + +LOCAL_AAPT_FLAGS := --auto-add-overlay \ + --extra-packages android.support.v7.cardview \ + --extra-packages it.gmariotti.cardslib.library \ LOCAL_PROTOC_OPTIMIZE_TYPE := nano LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ @@ -51,6 +72,10 @@ LOCAL_OVERRIDES_PACKAGES := Launcher3 LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_PROGUARD_ENABLED := disabled +LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \ + dashclockapiv2:libs/dashclock-api-r2.0.jar \ + de-hdodenhof-circleimageview:libs/de-hdodenhof-circleimageview.jar + include $(BUILD_PACKAGE) include $(call all-makefiles-under,$(LOCAL_PATH)) @@ -72,6 +97,7 @@ LOCAL_IS_HOST_MODULE := true LOCAL_JAR_MANIFEST := util/etc/manifest.txt LOCAL_STATIC_JAVA_LIBRARIES := host-libprotobuf-java-2.3.0-nano + include $(BUILD_HOST_JAVA_LIBRARY) # diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a6a22b9b8..afd273b8c 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -98,6 +98,7 @@ + diff --git a/api/Android.mk b/api/Android.mk new file mode 100644 index 000000000..0e33598d6 --- /dev/null +++ b/api/Android.mk @@ -0,0 +1,27 @@ +# +# Copyright (C) 2014 The CyanogenMod 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. +# + +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(call all-subdir-java-files) +LOCAL_MODULE := org.cyanogenmod.launcher.home + +LOCAL_PROGUARD_FLAG_FILES := proguard.flags + +include $(BUILD_STATIC_JAVA_LIBRARY) + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/api/CleanSpec.mk b/api/CleanSpec.mk new file mode 100644 index 000000000..b27df9a5b --- /dev/null +++ b/api/CleanSpec.mk @@ -0,0 +1,14 @@ +# Copyright (C) 2014 The CyanogenMod 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. +# diff --git a/api/api.iml b/api/api.iml new file mode 100644 index 000000000..c90834f2d --- /dev/null +++ b/api/api.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/api/proguard.flags b/api/proguard.flags new file mode 100644 index 000000000..0552c3f92 --- /dev/null +++ b/api/proguard.flags @@ -0,0 +1,8 @@ +# configuration +-dontobfuscate +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* \ No newline at end of file diff --git a/api/src/com/android/launcher/home/Home.java b/api/src/com/android/launcher/home/Home.java new file mode 100644 index 000000000..ae8298040 --- /dev/null +++ b/api/src/com/android/launcher/home/Home.java @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2014 The CyanogenMod 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.launcher.home; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup.LayoutParams; + +/** + * The generic contract that should supports a Home app to could + * be invoked and registered by an Android launcher.
+ *
+ * This interface contains the version 1 of the Home Host App protocol.
+ *
+ *
+ * A Home app should: + *
    + *
  • + * should have at least a constructor with no arguments + *
  • + *
  • + * declares inside its manifest a com.android.launcher.home metadata with the + * full qualified that contains this interface
    + *
    + *    <meta-data android:name="com.android.launcher.home" value="org.cyanogenmod.launcher.home.HomeStub"/>
    + *    
    + *
  • + *
  • + * define the "com.android.launcher.home.permissions.HOME_APP" permission
    + *
    + *    <uses-permission android:name="com.android.launcher.home.permissions.HOME_APP"/>
    + *    
    + *
  • + *
  • + * implements the contract defined by this protocol. + *
  • + *
+ *
+ * Implementors classes of this protocol should be aware that all the {@link Context} references + * passed to this class owns to the host launcher app. This means that you cannot access + * to settings defined by the Home app inside its shared context. + */ +public interface Home { + + /** + * A SHA-1 hash of all declared method of this interface. Home apps should compute as:
+ *
+ *
+     *   for method in Home.class.getDeclaredMehod
+     *      sha1.update method.toString.bytes
+     * 

+ * DO NOT MODIFY! + */ + public static final String SIGNATURE = "sZFp8JclUBYdIw0QaJZDosZ8SWM="; + + /** + * Defines the name of the metadata used to declared the full qualified Home stub class + * that implements this protocol. + */ + public static final String METADATA_HOME_STUB = "com.android.launcher.home"; + + /** + * Defines the name of the permission that the Home app should explicitly declare. + */ + public static final String PERMISSION_HOME_APP = "com.android.launcher.home.permissions.HOME_APP"; + + // Notification flags + public static final int FLAG_NOTIFY_MASK = 0x0000; + public static final int FLAG_NOTIFY_ON_RESUME = FLAG_NOTIFY_MASK + 0x0002; + public static final int FLAG_NOTIFY_ON_PAUSE = FLAG_NOTIFY_MASK + 0x0004; + public static final int FLAG_NOTIFY_ON_SHOW = FLAG_NOTIFY_MASK + 0x0008; + public static final int FLAG_NOTIFY_ON_SCROLL_PROGRESS_CHANGED = FLAG_NOTIFY_MASK + 0x0010; + public static final int FLAG_NOTIFY_ON_HIDE = FLAG_NOTIFY_MASK + 0x0020; + public static final int FLAG_NOTIFY_ALL = FLAG_NOTIFY_ON_RESUME | FLAG_NOTIFY_ON_PAUSE | + FLAG_NOTIFY_ON_SHOW | FLAG_NOTIFY_ON_SCROLL_PROGRESS_CHANGED | FLAG_NOTIFY_ON_HIDE; + + // Operation support flags + public static final int FLAG_OP_MASK = 0x1000; + public static final int FLAG_OP_CUSTOM_SEARCH = FLAG_OP_MASK + 0x0002; + public static final int FLAG_OP_ALL = FLAG_OP_CUSTOM_SEARCH; + + // Search modes + public static final int MODE_SEARCH_TEXT = 0x0000; + public static final int MODE_SEARCH_VOICE = 0x0001; + + /** + * Invoked when creating the Home object to set + * a reference to the host Activity that will + * contain this instance. + * @param context The Activity Context of the host activity. + */ + void setHostActivityContext(Context context); + + /** + * Invoked the first time the Home app is created.
+ * This method should be used by implementors classes of this protocol to load the needed + * resources. + * @param context the current {@link Context} of the host launcher. + */ + void onStart(Context context); + + /** + * Load and show the content of this home app if true, + * hide and remove providers if false. + * @param showContent Should content be shown + * + */ + void setShowContent(Context context, boolean showContent); + + /** + * Invoked when the Home app should be destroy.
+ * This method should be used by implementors classes of this protocol to unload all unneeded + * resources. + * @param context the current {@link Context} of the host launcher. + */ + void onDestroy(Context context); + + /** + * Invoked when the host launcher enters in resume mode. + * @param context the current {@link Context} of the host launcher. + */ + void onResume(Context context); + + /** + * Invoked when the host launcher enters in pause mode. + * @param context the current {@link Context} of the host launcher. + */ + void onPause(Context context); + + /** + * Invoked when the custom content page is totally displayed. + * @param context the current {@link Context} of the host launcher. + */ + void onShow(Context context); + + /** + * Invoked when the custom content page is scrolled. + * @param context the current {@link Context} of the host launcher. + * @param progress the current scroll progress. + */ + void onScrollProgressChanged(Context context, float progress); + + /** + * Invoked when the custom content page is totally hidden. + * @param context the current {@link Context} of the host launcher. + */ + void onHide(Context context); + + /** + * Invoked by the host launcher to request an invalidation of the ui elements and data used by + * the Home implementation class. + * @param context the current {@link Context} of the host launcher. + */ + void onInvalidate(Context context); + + /** + * Invoked when the host launcher request enter in search mode. + * @param context the current {@link Context} of the host launcher. + * @param mode the requested search mode. Must be one of: + *
    + *
  • {@link #MODE_SEARCH_TEXT}: Textual mode
  • + *
  • {@link #MODE_SEARCH_VOICE}: Voice mode
  • + *
+ */ + void onRequestSearch(Context context, int mode); + + /** + * Returns an instance of a {@link View} that holds the custom content to be displayed + * by this Home app. + * @param context the current {@link Context} of the host launcher. + * @return View The custom content view that will be enclosed inside a + * com.android.launcher3.Launcher.QSBScroller.
+ * Be aware the the height layout of the returned should be defined as + * {link {@link LayoutParams#WRAP_CONTENT}, so the view could be scrolled inside the + * custom content page. + */ + View createCustomView(Context context); + + /** + * Returns the name of the Home app (LIMIT: 30 characters). + * @param context the current {@link Context} of the host launcher. + */ + String getName(Context context); + + /** + * Implementations should return the combination of notification flags that want to listen to. + * @see #FLAG_NOTIFY_ON_RESUME + * @see #FLAG_NOTIFY_ON_PAUSE + * @see #FLAG_NOTIFY_ON_SHOW + * @see #FLAG_NOTIFY_ON_SCROLL_PROGRESS_CHANGED + * @see #FLAG_NOTIFY_ON_HIDE + * @see #FLAG_NOTIFY_ALL + */ + int getNotificationFlags(); + + /** + * Implementations should return the combination of operation flags that want they want + * to support to. + * @see #FLAG_OP_CUSTOM_SEARCH + * @see #FLAG_OP_ALL + */ + int getOperationFlags(); +} diff --git a/libs/dashclock-api-r2.0.jar b/libs/dashclock-api-r2.0.jar new file mode 100644 index 000000000..18f7bf121 Binary files /dev/null and b/libs/dashclock-api-r2.0.jar differ diff --git a/libs/de-hdodenhof-circleimageview.jar b/libs/de-hdodenhof-circleimageview.jar new file mode 100644 index 000000000..541037fdb Binary files /dev/null and b/libs/de-hdodenhof-circleimageview.jar differ diff --git a/res/drawable-xxhdpi/persona2.png b/res/drawable-xxhdpi/persona2.png new file mode 100644 index 000000000..4b182d1f6 Binary files /dev/null and b/res/drawable-xxhdpi/persona2.png differ diff --git a/res/layout/basic_dashclock_card_inner.xml b/res/layout/basic_dashclock_card_inner.xml new file mode 100644 index 000000000..7b989e4d7 --- /dev/null +++ b/res/layout/basic_dashclock_card_inner.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/res/layout/calendar_card.xml b/res/layout/calendar_card.xml new file mode 100644 index 000000000..814cb2c32 --- /dev/null +++ b/res/layout/calendar_card.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + diff --git a/res/layout/calendar_event_item.xml b/res/layout/calendar_event_item.xml new file mode 100644 index 000000000..403b0767c --- /dev/null +++ b/res/layout/calendar_event_item.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/card_image_layout.xml b/res/layout/card_image_layout.xml new file mode 100644 index 000000000..c887fb7c6 --- /dev/null +++ b/res/layout/card_image_layout.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/card_status_header_inner.xml b/res/layout/card_status_header_inner.xml new file mode 100644 index 000000000..bec9b0c24 --- /dev/null +++ b/res/layout/card_status_header_inner.xml @@ -0,0 +1,28 @@ + + + + + + + + + \ No newline at end of file diff --git a/res/layout/contact_card.xml b/res/layout/contact_card.xml new file mode 100644 index 000000000..367e79f84 --- /dev/null +++ b/res/layout/contact_card.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/dashclock_card_expand_inner_content.xml b/res/layout/dashclock_card_expand_inner_content.xml new file mode 100644 index 000000000..bccc03b68 --- /dev/null +++ b/res/layout/dashclock_card_expand_inner_content.xml @@ -0,0 +1,33 @@ + + + +