Merge Android Pie into master
Bug: 112104996
Change-Id: I49e765d5af9bbac1d72d8570af2f0a7fcdef0beb
diff --git a/Android.mk b/Android.mk
index f40e2c8..aeb6922 100644
--- a/Android.mk
+++ b/Android.mk
@@ -28,21 +28,11 @@
LOCAL_PACKAGE_NAME := CarLensPickerApp
LOCAL_PRIVATE_PLATFORM_APIS := true
+LOCAL_OVERRIDES_PACKAGES += Launcher2 Launcher3 Launcher3QuickStep
LOCAL_MODULE_TAGS := optional
-include packages/apps/Car/libs/car-stream-ui-lib/car-stream-ui-lib.mk
-
-LOCAL_STATIC_ANDROID_LIBRARIES += \
- android-support-v4 \
- android-support-design
-
-LOCAL_STATIC_JAVA_LIBRARIES += car-stream-lib
-
-# Include support-v7-appcompat, if not already included
-ifeq (,$(findstring android-support-v7-appcompat,$(LOCAL_STATIC_ANDROID_LIBRARIES)))
-LOCAL_STATIC_ANDROID_LIBRARIES += android-support-v7-appcompat
-endif
+LOCAL_STATIC_ANDROID_LIBRARIES += androidx.car_car
LOCAL_PROGUARD_ENABLED := disabled
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 70dde76..a8766e4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -51,7 +51,6 @@
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..38f9800
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,7 @@
+[Hook Scripts]
+checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
+ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py -f ${PREUPLOAD_FILES}
+
+[Builtin Hooks]
+commit_msg_changeid_field = true
+commit_msg_test_field = true
diff --git a/res/layout/car_list_item_1_card.xml b/res/layout/car_list_item_1_card.xml
index e76cad6..8211143 100644
--- a/res/layout/car_list_item_1_card.xml
+++ b/res/layout/car_list_item_1_card.xml
@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" >
- <com.android.car.stream.ui.StreamCardView
+ <androidx.car.widget.ColumnCardView
android:id="@+id/stream_card"
android:layout_width="match_parent"
android:layout_height="@dimen/car_list_item_height"
@@ -35,7 +35,7 @@
android:id="@+id/icon"
android:layout_width="@dimen/car_list_item_icon_size"
android:layout_height="@dimen/car_list_item_icon_size"
- android:layout_marginLeft="@dimen/stream_card_keyline_1"
+ android:layout_marginLeft="@dimen/car_keyline_1"
android:scaleType="centerCrop"
android:layout_gravity="center_vertical|left" />
<TextView
@@ -43,16 +43,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
- android:layout_marginLeft="@dimen/stream_card_keyline_2"
- android:layout_marginRight="@dimen/stream_card_keyline_1"
- style="@style/CarBody1"
+ android:layout_marginLeft="@dimen/car_keyline_2"
+ android:layout_marginRight="@dimen/car_keyline_1"
+ style="@style/TextAppearance.Car.Body1"
android:singleLine="true" />
<ImageView
android:id="@+id/right_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
- android:layout_marginRight="@dimen/stream_card_keyline_1"
+ android:layout_marginRight="@dimen/car_keyline_1"
android:scaleType="center" />
- </com.android.car.stream.ui.StreamCardView>
+ </androidx.car.widget.ColumnCardView>
</FrameLayout>
diff --git a/res/layout/lens_list.xml b/res/layout/lens_list.xml
index 311b9ee..f8381c7 100644
--- a/res/layout/lens_list.xml
+++ b/res/layout/lens_list.xml
@@ -22,19 +22,18 @@
android:layout_height="match_parent"
android:background="@color/car_lens_picker_bg_color"
android:clipChildren="false">
- <com.android.car.view.PagedListView
+ <androidx.car.widget.PagedListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/lens_header_height"
- app:offsetRows="true"
- app:showDivider="false" />
+ android:layout_marginTop="@dimen/car_app_bar_height"
+ app:showPagedListViewDivider="false" />
<RelativeLayout
android:id="@+id/no_app_installed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
- android:layout_marginTop="@dimen/lens_header_height" >
+ android:layout_marginTop="@dimen/car_app_bar_height" >
<ImageView
android:id="@+id/error_icon"
android:layout_width="@dimen/lens_no_compatible_app_installed_icon_size"
@@ -53,6 +52,6 @@
android:layout_marginRight="@dimen/lens_no_compatible_app_installed_text_right_margin"
android:gravity="center"
android:textColor="@color/car_grey_100"
- style="@style/CarBody1" />
+ style="@style/TextAppearance.Car.Body1" />
</RelativeLayout>
</FrameLayout>
diff --git a/res/layout/resolver_list.xml b/res/layout/resolver_list.xml
index 9d63f3d..f071451 100644
--- a/res/layout/resolver_list.xml
+++ b/res/layout/resolver_list.xml
@@ -27,7 +27,7 @@
android:id="@+id/title_checkbox_container"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
- android:layout_height="@dimen/lens_header_height" >
+ android:layout_height="@dimen/car_app_bar_height" >
<TextView
android:id="@+id/title"
@@ -35,7 +35,7 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
- style="@style/CarBody1.Light" />
+ style="@style/TextAppearance.Car.Body1.Light" />
<CheckBox
android:id="@+id/always_checkbox"
@@ -48,22 +48,21 @@
android:checked="true"
android:paddingStart="@dimen/resolver_list_checkbox_spacing"
android:text="@string/alwaysUse"
- style="@style/CarBody1.Light" />
+ style="@style/TextAppearance.Car.Body1.Light" />
</RelativeLayout>
- <com.android.car.view.PagedListView
+ <androidx.car.widget.PagedListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginTop="@dimen/lens_header_height"
- app:offsetRows="true"
- app:showDivider="false" />
+ android:layout_marginTop="@dimen/car_app_bar_height"
+ app:showPagedListViewDivider="false" />
<RelativeLayout
android:id="@+id/no_app_installed"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
- android:layout_marginTop="@dimen/lens_header_height" >
+ android:layout_marginTop="@dimen/car_app_bar_height" >
<ImageView
android:id="@+id/error_icon"
android:layout_width="@dimen/lens_no_compatible_app_installed_icon_size"
@@ -82,6 +81,6 @@
android:layout_marginRight="@dimen/lens_no_compatible_app_installed_text_right_margin"
android:gravity="center"
android:textColor="@color/car_grey_100"
- style="@style/CarBody1" />
+ style="@style/TextAppearance.Car.Body1" />
</RelativeLayout>
</FrameLayout>
diff --git a/res/values/color.xml b/res/values/color.xml
index 6a4ef5e..e189e1a 100644
--- a/res/values/color.xml
+++ b/res/values/color.xml
@@ -20,5 +20,5 @@
<color name="car_lens_picker_bg_color">#ff11181d</color>
<!-- The ripple color for cards in the lens picker. -->
- <color name="car_lens_picker_ripple_color">@color/car_card_ripple_light_color_background</color>
+ <color name="car_lens_picker_ripple_color">@color/car_card_ripple_background</color>
</resources>
diff --git a/res/values/dimen.xml b/res/values/dimen.xml
index 114da56..8f85b26 100644
--- a/res/values/dimen.xml
+++ b/res/values/dimen.xml
@@ -16,6 +16,7 @@
-->
<resources>
<dimen name="car_card_bottom_margin">8dp</dimen>
+ <dimen name="car_card_view_corner_radius">8dp</dimen>
<dimen name="car_list_item_height">100dp</dimen>
<dimen name="car_list_item_icon_size">64dp</dimen>
<dimen name="lens_no_compatible_app_installed_icon_size">96dp</dimen>
diff --git a/src/com/android/support/car/lenspicker/LensPickerActivity.java b/src/com/android/support/car/lenspicker/LensPickerActivity.java
index 19194f9..686795a 100644
--- a/src/com/android/support/car/lenspicker/LensPickerActivity.java
+++ b/src/com/android/support/car/lenspicker/LensPickerActivity.java
@@ -25,9 +25,9 @@
import android.service.media.MediaBrowserService;
import android.text.TextUtils;
import android.util.Log;
-import android.view.View;
-import com.android.car.view.PagedListView;
+import androidx.car.widget.DayNightStyle;
+import androidx.car.widget.PagedListView;
import java.util.ArrayList;
import java.util.Collections;
@@ -60,14 +60,9 @@
mPagedListView = (PagedListView) findViewById(R.id.list_view);
// Set this to light mode, since the scroll bar buttons always appear
// on top of a dark scrim.
- mPagedListView.setLightMode();
+ mPagedListView.setDayNightStyle(DayNightStyle.ALWAYS_LIGHT);
- findViewById(R.id.dismiss_area).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
+ findViewById(R.id.dismiss_area).setOnClickListener(v -> finish());
}
@Override
diff --git a/src/com/android/support/car/lenspicker/LensPickerAdapter.java b/src/com/android/support/car/lenspicker/LensPickerAdapter.java
index b982dca..b9c5820 100644
--- a/src/com/android/support/car/lenspicker/LensPickerAdapter.java
+++ b/src/com/android/support/car/lenspicker/LensPickerAdapter.java
@@ -23,13 +23,13 @@
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import com.android.car.view.PagedListView;
+import androidx.car.widget.PagedListView;
+import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/com/android/support/car/lenspicker/LensPickerRow.java b/src/com/android/support/car/lenspicker/LensPickerRow.java
index 0ed06e2..d3b3867 100644
--- a/src/com/android/support/car/lenspicker/LensPickerRow.java
+++ b/src/com/android/support/car/lenspicker/LensPickerRow.java
@@ -16,12 +16,13 @@
package com.android.support.car.lenspicker;
import android.content.Context;
-import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
* A view that renders a single row in the lens picker list
*/
diff --git a/src/com/android/support/car/lenspicker/LensPickerTrampolineActivity.java b/src/com/android/support/car/lenspicker/LensPickerTrampolineActivity.java
index 6a39c45..0dc0b20 100644
--- a/src/com/android/support/car/lenspicker/LensPickerTrampolineActivity.java
+++ b/src/com/android/support/car/lenspicker/LensPickerTrampolineActivity.java
@@ -59,6 +59,12 @@
finish();
return;
}
+ // if the lens picker is treated as a home app this will handle initial starts
+ if (intent.getCategories().contains(Intent.CATEGORY_HOME)) {
+ launchLastRunOrDefaultApplication();
+ finish();
+ return;
+ }
// Hide the shade if switching to a different facet.
hideNotificationsShade();
diff --git a/src/com/android/support/car/lenspicker/LensPickerUtils.java b/src/com/android/support/car/lenspicker/LensPickerUtils.java
index 4024bc1..88dd9d0 100644
--- a/src/com/android/support/car/lenspicker/LensPickerUtils.java
+++ b/src/com/android/support/car/lenspicker/LensPickerUtils.java
@@ -21,9 +21,8 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.service.media.MediaBrowserService;
-import android.support.annotation.Nullable;
-import java.net.URISyntaxException;
+import androidx.annotation.Nullable;
/**
* Utility methods for the lenspicker
diff --git a/src/com/android/support/car/lenspicker/LensResolverActivity.java b/src/com/android/support/car/lenspicker/LensResolverActivity.java
index 6b0892a..bd69a0d 100644
--- a/src/com/android/support/car/lenspicker/LensResolverActivity.java
+++ b/src/com/android/support/car/lenspicker/LensResolverActivity.java
@@ -27,15 +27,17 @@
import android.os.Bundle;
import android.os.PatternMatcher;
import android.provider.MediaStore;
-import android.support.annotation.StringRes;
+import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.TextView;
-import com.android.car.stream.ui.ColumnCalculator;
-import com.android.car.view.PagedListView;
+import androidx.annotation.StringRes;
+import androidx.car.utils.ColumnCalculator;
+import androidx.car.widget.DayNightStyle;
+import androidx.car.widget.PagedListView;
import java.util.Iterator;
import java.util.List;
@@ -107,11 +109,11 @@
Log.d(TAG, "Found " + size + " matching activities.");
}
- // The title container should match the width of the StreamCards in the list. Those cards
+ // The title container should match the width of the ColumnCards in the list. Those cards
// have their width set depending on the column span, which changes between screen sizes.
// As a result, need to set the width of the title container programmatically.
int defaultColumnSpan =
- getResources().getInteger(R.integer.stream_card_default_column_span);
+ getResources().getInteger(R.integer.column_card_default_column_span);
int cardWidth = ColumnCalculator.getInstance(this /* context */).getSizeForColumnSpan(
defaultColumnSpan);
View titleAndCheckboxContainer = findViewById(R.id.title_checkbox_container);
@@ -120,7 +122,7 @@
mAlwaysCheckbox = (CheckBox) findViewById(R.id.always_checkbox);
PagedListView pagedListView = (PagedListView) findViewById(R.id.list_view);
- pagedListView.setLightMode();
+ pagedListView.setDayNightStyle(DayNightStyle.FORCE_DAY);
ResolverAdapter adapter = new ResolverAdapter(this /* context */, infos);
adapter.setSelectionHandler(this);
@@ -168,8 +170,17 @@
ComponentName component = item.getLaunchIntent().getComponent();
if (mAlwaysCheckbox.isChecked()) {
+ PackageManager pm = getPackageManager();
+ if (info.handleAllWebDataURI) {
+ // Set default Browser if needed
+ int userId = getUserId();
+ String packageName = pm.getDefaultBrowserPackageNameAsUser(userId);
+ if (TextUtils.isEmpty(packageName)) {
+ pm.setDefaultBrowserPackageNameAsUser(info.activityInfo.packageName, userId);
+ }
+ }
IntentFilter filter = buildIntentFilterForResolveInfo(info);
- getPackageManager().addPreferredActivity(filter, info.match, mComponentSet, component);
+ pm.addPreferredActivity(filter, info.match, mComponentSet, component);
}
// Now launch the original resolve intent but correctly set the component.
diff --git a/src/com/android/support/car/lenspicker/ResolverAdapter.java b/src/com/android/support/car/lenspicker/ResolverAdapter.java
index b7fb8e2..d9324c8 100644
--- a/src/com/android/support/car/lenspicker/ResolverAdapter.java
+++ b/src/com/android/support/car/lenspicker/ResolverAdapter.java
@@ -15,20 +15,22 @@
*/
package com.android.support.car.lenspicker;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
-import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;
-import com.android.car.view.PagedListView;
+import androidx.car.widget.PagedListView;
+import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
@@ -93,8 +95,6 @@
for (ResolveInfo info : mResolveInfos) {
String packageName = LensPickerUtils.getPackageName(info);
- Intent launchIntent = LensPickerUtils.getLaunchIntent(packageName, info,
- packageManager);
try {
ApplicationInfo aInfo = packageManager.getApplicationInfo(packageName, 0);
@@ -114,6 +114,16 @@
if (displayName.equals("")) {
displayName = getComponentLabel(packageManager, aInfo);
}
+ Intent launchIntent = LensPickerUtils.getLaunchIntent(packageName, info,
+ packageManager);
+ // If launchIntent is null, create an intent from the ResolverInfo
+ if (launchIntent == null) {
+ launchIntent = new Intent();
+ ActivityInfo activity = info.activityInfo;
+ launchIntent.setComponent(
+ new ComponentName(activity.applicationInfo.packageName,
+ activity.name));
+ }
items.add(new LensPickerItem(displayName,
getComponentIcon(packageManager, aInfo), launchIntent,
diff --git a/src/com/android/support/car/lenspicker/ResolverListRow.java b/src/com/android/support/car/lenspicker/ResolverListRow.java
index 1e648e3..3cf3932 100644
--- a/src/com/android/support/car/lenspicker/ResolverListRow.java
+++ b/src/com/android/support/car/lenspicker/ResolverListRow.java
@@ -17,14 +17,15 @@
import android.content.Context;
import android.content.pm.ResolveInfo;
-import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.recyclerview.widget.RecyclerView;
+
/**
- * A {@link android.support.v7.widget.RecyclerView.ViewHolder} representing a row within the
+ * A {@link androidx.recyclerview.widget.RecyclerView.ViewHolder} representing a row within the
* {@link LensResolverActivity}.
*/
public class ResolverListRow extends RecyclerView.ViewHolder {