From 17850fe0bfcfed514c3e7a346a93f09c648abc83 Mon Sep 17 00:00:00 2001 From: Dake Gu Date: Wed, 8 Nov 2017 15:35:34 -0800 Subject: convert LiveTv to aapt2 To avoid hardcode resource directories. Bug: NA Test: make Change-Id: If8778b8c293eb10818baa1dead38d8ac3ee30cb3 Merged-In: If8778b8c293eb10818baa1dead38d8ac3ee30cb3 (cherry picked from commit d0b4dee914668ad32185d82146947cacade657e2) --- Android.mk | 42 ++++++++-------------- common/Android.mk | 16 +++------ .../common/ui/setup/SetupGuidedStepFragment.java | 14 +++++--- .../tv/common/ui/setup/SetupMultiPaneFragment.java | 8 +++-- .../animation/TranslationAnimationCreator.java | 2 +- 5 files changed, 33 insertions(+), 49 deletions(-) diff --git a/Android.mk b/Android.mk index a238b192..76e429b9 100644 --- a/Android.mk +++ b/Android.mk @@ -36,26 +36,23 @@ LOCAL_PRIVILEGED_MODULE := true LOCAL_SDK_VERSION := system_current LOCAL_MIN_SDK_VERSION := 23 # M + +LOCAL_USE_AAPT2 := true + LOCAL_RESOURCE_DIR := \ $(LOCAL_PATH)/res \ - $(LOCAL_PATH)/usbtuner-res \ - $(LOCAL_PATH)/common/res - -ifdef TARGET_BUILD_APPS -LOCAL_RESOURCE_DIR += \ - $(TOP)/prebuilts/sdk/current/support/compat/res \ - $(TOP)/prebuilts/sdk/current/support/v17/leanback/res \ - $(TOP)/prebuilts/sdk/current/support/v7/recyclerview/res -else # !TARGET_BUILD_APPS -LOCAL_RESOURCE_DIR += \ - $(TOP)/frameworks/support/compat/res \ - $(TOP)/frameworks/support/v17/leanback/res \ - $(TOP)/frameworks/support/v7/recyclerview/res -endif + $(LOCAL_PATH)/usbtuner-res + LOCAL_SRC_FILES += \ src/com/android/tv/tuner/exoplayer/ffmpeg/IFfmpegDecoder.aidl LOCAL_STATIC_JAVA_LIBRARIES := \ + icu4j-usbtuner \ + lib-exoplayer \ + lib-exoplayer-v2 \ + lib-exoplayer-v2-ext-ffmpeg + +LOCAL_STATIC_ANDROID_LIBRARIES := \ android-support-annotations \ android-support-compat \ android-support-core-ui \ @@ -63,23 +60,11 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ android-support-v7-palette \ android-support-v7-recyclerview \ android-support-v17-leanback \ - icu4j-usbtuner \ - lib-exoplayer \ - lib-exoplayer-v2 \ - lib-exoplayer-v2-ext-ffmpeg \ - tv-common \ - - - - + tv-common LOCAL_JAVACFLAGS := -Xlint:deprecation -Xlint:unchecked -LOCAL_AAPT_FLAGS += --auto-add-overlay \ - --extra-packages android.support.compat \ - --extra-packages android.support.v7.recyclerview \ - --extra-packages android.support.v17.leanback \ - --extra-packages com.android.tv.common \ +LOCAL_AAPT_FLAGS += \ --version-name "$(version_name_package)" \ --version-code $(version_code_package) \ @@ -127,3 +112,4 @@ include $(BUILD_MULTI_PREBUILT) include $(call all-makefiles-under,$(LOCAL_PATH)) + diff --git a/common/Android.mk b/common/Android.mk index d632597f..ff19392e 100644 --- a/common/Android.mk +++ b/common/Android.mk @@ -9,25 +9,17 @@ LOCAL_MODULE_CLASS := STATIC_JAVA_LIBRARIES LOCAL_MODULE_TAGS := optional LOCAL_SDK_VERSION := system_current -LOCAL_RESOURCE_DIR := \ - $(TOP)/prebuilts/sdk/current/support/compat/res \ - $(TOP)/prebuilts/sdk/current/support/v7/recyclerview/res \ - $(TOP)/prebuilts/sdk/current/support/v17/leanback/res \ - $(LOCAL_PATH)/res \ +LOCAL_USE_AAPT2 := true -LOCAL_STATIC_JAVA_LIBRARIES := \ +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res + +LOCAL_SHARED_ANDROID_LIBRARIES := \ android-support-annotations \ android-support-compat \ android-support-core-ui \ android-support-v7-recyclerview \ android-support-v17-leanback \ -LOCAL_AAPT_FLAGS := --auto-add-overlay \ - --extra-packages android.support.compat \ - --extra-packages android.support.v7.recyclerview \ - --extra-packages android.support.v17.leanback \ - - include $(LOCAL_PATH)/buildconfig.mk include $(BUILD_STATIC_JAVA_LIBRARY) diff --git a/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java b/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java index 88159da9..7bce9c27 100644 --- a/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java +++ b/common/src/com/android/tv/common/ui/setup/SetupGuidedStepFragment.java @@ -45,9 +45,11 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); Bundle arguments = getArguments(); - view.findViewById(R.id.action_fragment_root).setPadding(0, 0, 0, 0); + view.findViewById(android.support.v17.leanback.R.id.action_fragment_root) + .setPadding(0, 0, 0, 0); LinearLayout.LayoutParams guidanceLayoutParams = (LinearLayout.LayoutParams) - view.findViewById(R.id.content_fragment).getLayoutParams(); + view.findViewById(android.support.v17.leanback.R.id.content_fragment) + .getLayoutParams(); guidanceLayoutParams.weight = 0; if (arguments != null && arguments.getBoolean(KEY_THREE_PANE, false)) { // Content fragment. @@ -56,7 +58,7 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { int doneButtonWidth = getResources().getDimensionPixelOffset( R.dimen.setup_done_button_container_width); // Guided actions list - View list = view.findViewById(R.id.guidedactions_list); + View list = view.findViewById(android.support.v17.leanback.R.id.guidedactions_list); MarginLayoutParams marginLayoutParams = (MarginLayoutParams) list.getLayoutParams(); // Use content view to check layout direction while view is being created. if (getResources().getConfiguration().getLayoutDirection() @@ -77,10 +79,12 @@ public abstract class SetupGuidedStepFragment extends GuidedStepFragment { gridView.setWindowAlignmentOffset(offset); gridView.setWindowAlignmentOffsetPercent(0); gridView.setItemAlignmentOffsetPercent(0); - ((ViewGroup) view.findViewById(R.id.guidedactions_list)).setTransitionGroup(false); + ((ViewGroup) view.findViewById(android.support.v17.leanback.R.id.guidedactions_list)) + .setTransitionGroup(false); // Needed for the shared element transition. // content_frame is defined in leanback. - ViewGroup group = (ViewGroup) view.findViewById(R.id.content_frame); + ViewGroup group = (ViewGroup) view.findViewById( + android.support.v17.leanback.R.id.content_frame); group.setClipChildren(false); group.setClipToPadding(false); return view; diff --git a/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java b/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java index b9ad4657..f5c2bf26 100644 --- a/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java +++ b/common/src/com/android/tv/common/ui/setup/SetupMultiPaneFragment.java @@ -102,11 +102,13 @@ public abstract class SetupMultiPaneFragment extends SetupFragment { @Override protected int[] getParentIdsForDelay() { - return new int[] {R.id.content_fragment, R.id.guidedactions_list}; + return new int[] {android.support.v17.leanback.R.id.content_fragment, + android.support.v17.leanback.R.id.guidedactions_list}; } @Override public int[] getSharedElementIds() { - return new int[] {R.id.action_fragment_background, R.id.done_button_container}; + return new int[] {android.support.v17.leanback.R.id.action_fragment_background, + R.id.done_button_container}; } -} \ No newline at end of file +} diff --git a/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java b/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java index 99b8811a..7705f7a7 100644 --- a/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java +++ b/common/src/com/android/tv/common/ui/setup/animation/TranslationAnimationCreator.java @@ -9,7 +9,7 @@ import android.transition.Transition; import android.transition.TransitionValues; import android.view.View; -import com.android.tv.common.R; +import android.support.v17.leanback.R; /** * This class is used by Slide and Explode to create an animator that goes from the start position -- cgit v1.2.3