summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-08-27 10:16:47 -0700
committerXin Li <delphij@google.com>2020-08-27 10:16:47 -0700
commit35737e3de77f302766be747d65d03d00b24fdd4c (patch)
tree6836c2184b90203c441649678daa7b94757d4bd9
parentad64abe7c7ada0deca3d861a68d72ca770b333ff (diff)
parentd05859b843c48f5d16dc03f8b9909a853094b1b2 (diff)
downloadSystemUpdater-35737e3de77f302766be747d65d03d00b24fdd4c.tar.gz
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507 Merged-In: Idbdf32ee4972daa81ea3ff3a19dcb8528283b692 Change-Id: I2ce987573e7e4e2084f79046ae4504d4cdc23485
-rw-r--r--Android.bp2
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/color/action_bar_btn.xml4
-rw-r--r--res/drawable/button_ripple_bg.xml2
-rw-r--r--res/drawable/ic_arrow_back.xml6
-rw-r--r--res/drawable/rectangle_ripple_mask.xml2
-rw-r--r--res/layout/action_bar_with_button.xml57
-rw-r--r--res/layout/activity_main.xml12
-rw-r--r--res/layout/folder_list.xml11
-rw-r--r--res/layout/system_update_auto_content.xml18
-rw-r--r--res/values-night/colors.xml5
-rw-r--r--res/values/colors.xml5
-rw-r--r--res/values/dimens.xml5
-rw-r--r--res/values/strings.xml12
-rw-r--r--res/values/styles.xml29
-rw-r--r--src/com/android/car/systemupdater/DeviceListFragment.java75
-rw-r--r--src/com/android/car/systemupdater/SystemUpdaterActivity.java11
-rw-r--r--src/com/android/car/systemupdater/UpdateLayoutFragment.java44
18 files changed, 89 insertions, 212 deletions
diff --git a/Android.bp b/Android.bp
index 33704c2..dfa7eca 100644
--- a/Android.bp
+++ b/Android.bp
@@ -29,7 +29,7 @@ android_app {
dxflags: ["--multi-dex"],
static_libs: [
"androidx.appcompat_appcompat",
- "androidx.car_car",
"androidx.legacy_legacy-support-v4",
+ "car-ui-lib",
],
}
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 26253b3..32b4a45 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -20,6 +20,7 @@
package="com.android.car.systemupdater">
<uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
+ <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REBOOT" />
diff --git a/res/color/action_bar_btn.xml b/res/color/action_bar_btn.xml
index 29d9fa2..d1253b0 100644
--- a/res/color/action_bar_btn.xml
+++ b/res/color/action_bar_btn.xml
@@ -17,8 +17,8 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true"
- android:color="@color/car_accent" />
+ android:color="?android:attr/colorAccent" />
<item android:state_enabled="false"
android:alpha="0.5"
- android:color="@color/car_accent" />
+ android:color="?android:attr/colorAccent" />
</selector>
diff --git a/res/drawable/button_ripple_bg.xml b/res/drawable/button_ripple_bg.xml
index a28e38c..1bcd2a9 100644
--- a/res/drawable/button_ripple_bg.xml
+++ b/res/drawable/button_ripple_bg.xml
@@ -16,7 +16,7 @@
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/car_card_ripple_background"
+ android:color="@color/car_ui_ripple_color"
android:radius="@dimen/toggle_ripple">
<item android:id="@android:id/mask"
android:drawable="@drawable/rectangle_ripple_mask" />
diff --git a/res/drawable/ic_arrow_back.xml b/res/drawable/ic_arrow_back.xml
index 81da87f..6d92790 100644
--- a/res/drawable/ic_arrow_back.xml
+++ b/res/drawable/ic_arrow_back.xml
@@ -18,9 +18,9 @@
~ does not provide a way to customize it. Here to center the icon in action bar, we make up
~ the margin by add the extra space in the icon itself -->
<vector
- android:height="@dimen/car_primary_icon_size"
- android:width="@dimen/car_primary_icon_size"
- android:tint="@color/car_accent"
+ android:height="@dimen/car_ui_primary_icon_size"
+ android:width="@dimen/car_ui_primary_icon_size"
+ android:tint="?android:attr/colorAccent"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
xmlns:android="http://schemas.android.com/apk/res/android">
diff --git a/res/drawable/rectangle_ripple_mask.xml b/res/drawable/rectangle_ripple_mask.xml
index 69eaf8b..2661da8 100644
--- a/res/drawable/rectangle_ripple_mask.xml
+++ b/res/drawable/rectangle_ripple_mask.xml
@@ -17,6 +17,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <corners android:radius="@dimen/car_radius_1" />
+ <corners android:radius="@dimen/ripple_mask_radius" />
<solid android:color="@android:color/white" />
</shape> \ No newline at end of file
diff --git a/res/layout/action_bar_with_button.xml b/res/layout/action_bar_with_button.xml
deleted file mode 100644
index 5dbf850..0000000
--- a/res/layout/action_bar_with_button.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2018 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
- -->
-
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="@dimen/car_app_bar_height">
-
- <TextView
- android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_marginEnd="@dimen/car_keyline_1"
- android:gravity="center_vertical"
- android:textAppearance="@style/TextAppearance.Car.Body1.Medium"
- android:text="@string/title"/>
-
- <FrameLayout
- android:id="@+id/button_container"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_alignParentEnd="true"
- android:layout_marginEnd="@dimen/car_keyline_1"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/action_button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- style="@style/SystemUpdate.ActionBar.Button.Borderless.Colored"
- android:layout_marginEnd="@dimen/action_bar_end_widget_margin_end" />
- </FrameLayout>
-
- <ProgressBar
- android:id="@+id/progress_bar"
- style="@style/Widget.Car.ProgressBar.Horizontal"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:visibility="gone"
- android:indeterminate="true"/>
-</RelativeLayout>
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
index 4d58853..c268b8d 100644
--- a/res/layout/activity_main.xml
+++ b/res/layout/activity_main.xml
@@ -16,21 +16,13 @@
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/toolbar"
- android:layout_width="match_parent"
- android:layout_height="@dimen/car_app_bar_height"
- android:theme="@style/ActionBarStyle.Car"
- app:contentInsetStart="0dp"
- app:contentInsetEnd="0dp"/>
<View
android:layout_width="match_parent"
- android:layout_height="@dimen/car_list_divider_height"
- android:background="@color/car_list_divider"/>
+ android:layout_height="@dimen/car_ui_divider_width"
+ android:background="@drawable/car_ui_divider"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
diff --git a/res/layout/folder_list.xml b/res/layout/folder_list.xml
index c34ee82..2879bdc 100644
--- a/res/layout/folder_list.xml
+++ b/res/layout/folder_list.xml
@@ -25,14 +25,13 @@
android:id="@+id/current_path"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:textAppearance="@style/TextAppearance.Car.Body2"
- android:layout_marginStart="@dimen/car_gutter_width"
- android:layout_marginEnd="@dimen/car_margin"/>
+ android:textAppearance="@style/TextAppearance.CarUi.Body2"
+ android:layout_marginStart="@dimen/car_ui_scrollbar_container_width"
+ android:layout_marginEnd="@dimen/folder_list_start_margin"/>
- <androidx.car.widget.PagedListView
+ <com.android.car.ui.recyclerview.CarUiRecyclerView
android:id="@+id/folder_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:showPagedListViewDivider="true"
- app:gutter="start"/>
+ app:enableDivider="true" />
</LinearLayout>
diff --git a/res/layout/system_update_auto_content.xml b/res/layout/system_update_auto_content.xml
index 6f5ee5c..6938b61 100644
--- a/res/layout/system_update_auto_content.xml
+++ b/res/layout/system_update_auto_content.xml
@@ -19,32 +19,32 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginStart="@dimen/car_margin"
- android:layout_marginEnd="@dimen/car_margin">
+ android:layout_marginStart="@dimen/auto_content_margin"
+ android:layout_marginEnd="@dimen/auto_content_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/car_padding_3"
- android:paddingBottom="@dimen/car_padding_5"
+ android:paddingTop="@dimen/car_ui_padding_3"
+ android:paddingBottom="@dimen/car_ui_padding_5"
android:orientation="vertical">
<TextView
- android:textAppearance="@style/TextAppearance.Car.Body1"
+ android:textAppearance="@style/TextAppearance.CarUi.Body1"
android:id="@+id/system_update_auto_content_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/car_padding_1"/>
+ android:layout_marginBottom="@dimen/car_ui_padding_1"/>
<TextView
- android:textAppearance="@style/TextAppearance.Car.Body2"
+ android:textAppearance="@style/TextAppearance.CarUi.Body2"
android:id="@+id/system_update_auto_content_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/car_padding_5"/>
+ android:layout_marginBottom="@dimen/car_ui_padding_5"/>
<TextView
- android:textAppearance="@style/TextAppearance.Car.Body2"
+ android:textAppearance="@style/TextAppearance.CarUi.Body2"
android:id="@+id/system_update_auto_content_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 9d4fc43..35c4ce1 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -16,8 +16,5 @@
-->
<resources>
<!-- The default color for all activities in the SetupWizard. -->
- <color name="windowBackground">@color/car_dark_blue_grey_700</color>
-
- <!-- The color of the status bar. -->
- <color name="colorPrimaryDark">@color/car_dark_blue_grey_800</color>
+ <color name="windowBackground">#ff172026</color>
</resources> \ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 5ca113b..2211a42 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -16,8 +16,7 @@
-->
<resources>
<!-- The default color for all activities in the Settings. -->
- <color name="windowBackground">@color/car_grey_50</color>
+ <color name="windowBackground">#fff8f9fa</color>
- <!-- The color of the status bar. -->
- <color name="colorPrimaryDark">@color/car_grey_300</color>
+ <color name="icon_tint">#fff8f9fa</color>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 915915f..ed45548 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -17,4 +17,9 @@
<resources>
<dimen name="action_bar_end_widget_margin_end">46dp</dimen>
<dimen name="toggle_ripple">90dp</dimen>
+ <dimen name="button_min_width">56dp</dimen>
+ <dimen name="ripple_mask_radius">4dp</dimen>
+ <dimen name="keyline_1">24dp</dimen>
+ <dimen name="auto_content_margin">20dp</dimen>
+ <dimen name="folder_list_start_margin">20dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d72f65a..f57e7ab 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -19,11 +19,11 @@
<string name="title">Local System Update</string>
<!-- Device List Fragment -->
- <!-- An error that the selected file is not a valid update. [CHAR LIMIT=40] -->
+ <!-- An error that the selected file is not a valid update. [CHAR LIMIT=47] -->
<string name="invalid_file_type">This is not a valid file for updating</string>
<!-- A name of an invalid file. [CHAR LIMIT=40] -->
<string name="unknown_file">Unknown File</string>
- <!-- An error message indicating that the file system could not be found. [CHAR LIMIT=40] -->
+ <!-- An error message indicating that the file system could not be found. [CHAR LIMIT=52] -->
<string name="cannot_access_storage">Cannot access the storage device</string>
<!-- UpdateLayoutFragment -->
@@ -38,15 +38,15 @@
<string name="update_failed">Update Failed</string>
<!-- A status that indicates that the update is being verified before installation. [CHAR LIMIT=40] -->
<string name="verify_in_progress">Verifying update&#8230;</string>
- <!-- An error message indicating that verification failed. [CHAR LIMIT=40] -->
- <string name="verify_failure">Verification Failed. Please select a valid update file.</string>
+ <!-- An error message indicating that verification failed. [CHAR LIMIT=50] -->
+ <string name="verify_failure">Please select a valid update file.</string>
<!-- A status that indicates that the update is ready to be installed. [CHAR LIMIT=40] -->
<string name="install_ready">The update is ready to be installed.</string>
<!-- A status that indicates the installation process is running. [CHAR LIMIT=40] -->
<string name="install_in_progress">Installation in progress&#8230;</string>
- <!-- A status that indicates that installation worked and update is complete. [CHAR LIMIT=40] -->
+ <!-- A status that indicates that installation worked and update is complete. [CHAR LIMIT=56] -->
<string name="install_success">The update is successful.</string>
- <!-- A status that indicates that installation failed. [CHAR LIMIT=40] -->
+ <!-- A status that indicates that installation failed. [CHAR LIMIT=45] -->
<string name="install_failed">System update installation failed.</string>
<!-- A status that indicates the system is about to reboot. [CHAR LIMIT=40] -->
<string name="rebooting">The update is successful. Rebooting now&#8230;</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index ad10701..32ef26d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -16,10 +16,7 @@
-->
<resources>
- <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
-
- <style name="SystemUpdaterTheme" parent="Theme.Car.Light.NoActionBar">
- <item name="android:windowBackground">@color/car_card</item>
+ <style name="SystemUpdaterTheme" parent="Theme.CarUi.WithToolbar">
<item name="android:windowAnimationStyle">@style/SettingAnimationStyle</item>
</style>
@@ -28,28 +25,10 @@
<item name="android:windowExitAnimation">@anim/trans_fade_out</item>
</style>
- <style name="ActionBarStyle.Car" parent="Widget.Car.Toolbar">
- <item name="actionBarSize">@dimen/car_app_bar_height</item>
- </style>
-
- <style name="ListIcon">
- <item name="android:layout_width">@dimen/car_primary_icon_size</item>
- <item name="android:layout_height">@dimen/car_primary_icon_size</item>
- <item name="android:layout_centerVertical">true</item>
- <item name="android:gravity">center_vertical</item>
- <item name="android:scaleType">fitCenter</item>
- <item name="android:tint">@color/car_tint</item>
- </style>
-
- <style name="ListIcon.ActionBar" parent="ListIcon">
- <item name="android:layout_gravity">center</item>
- <item name="android:src">@drawable/ic_arrow_back</item>
- </style>
-
<style name="SystemUpdate.ActionBar.Button.Borderless.Colored"
- parent="Widget.Car.Button.Borderless.Colored">
- <item name="android:minWidth">@dimen/car_button_min_width</item>
+ parent="Widget.CarUi.Button.Borderless.Colored">
+ <item name="android:minWidth">@dimen/button_min_width</item>
<item name="android:fontFamily">roboto-regular</item>
- <item name="android:textColor">@color/car_accent</item>
+ <item name="android:textColor">?android:attr/colorAccent</item>
</style>
</resources>
diff --git a/src/com/android/car/systemupdater/DeviceListFragment.java b/src/com/android/car/systemupdater/DeviceListFragment.java
index 857654b..df0c54b 100644
--- a/src/com/android/car/systemupdater/DeviceListFragment.java
+++ b/src/com/android/car/systemupdater/DeviceListFragment.java
@@ -29,15 +29,13 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
-import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.car.widget.ListItem;
-import androidx.car.widget.ListItemAdapter;
-import androidx.car.widget.ListItemProvider;
-import androidx.car.widget.PagedListView;
-import androidx.car.widget.TextListItem;
import androidx.fragment.app.Fragment;
+import com.android.car.ui.recyclerview.CarUiContentListItem;
+import com.android.car.ui.recyclerview.CarUiListItem;
+import com.android.car.ui.recyclerview.CarUiListItemAdapter;
+import com.android.car.ui.recyclerview.CarUiRecyclerView;
+
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
@@ -60,9 +58,7 @@ public class DeviceListFragment extends Fragment implements UpFragment {
private final Stack<File> mFileStack = new Stack<>();
private StorageManager mStorageManager;
private SystemUpdater mSystemUpdater;
- private List<File> mListItems;
- private ListItemAdapter mAdapter;
- private FileItemProvider mItemProvider;
+ private CarUiRecyclerView mFolderListView;
private TextView mCurrentPathView;
private final StorageEventListener mListener = new StorageEventListener() {
@@ -87,9 +83,7 @@ public class DeviceListFragment extends Fragment implements UpFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
Context context = getContext();
- mItemProvider = new FileItemProvider(context);
mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
if (mStorageManager == null) {
@@ -104,28 +98,18 @@ public class DeviceListFragment extends Fragment implements UpFragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- mAdapter = new ListItemAdapter(getContext(), mItemProvider);
return inflater.inflate(R.layout.folder_list, container, false);
}
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
- PagedListView folderListView = (PagedListView) view.findViewById(R.id.folder_list);
- folderListView.setMaxPages(PagedListView.ItemCap.UNLIMITED);
- folderListView.setAdapter(mAdapter);
-
- mCurrentPathView = (TextView) view.findViewById(R.id.current_path);
+ mFolderListView = view.findViewById(R.id.folder_list);
+ mCurrentPathView = view.findViewById(R.id.current_path);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- AppCompatActivity activity = (AppCompatActivity) getActivity();
- ActionBar actionBar = activity.getSupportActionBar();
- actionBar.setCustomView(R.layout.action_bar_with_button);
- actionBar.setDisplayShowCustomEnabled(true);
- actionBar.setDisplayShowTitleEnabled(false);
-
showMountedVolumes();
}
@@ -168,10 +152,17 @@ public class DeviceListFragment extends Fragment implements UpFragment {
/** Set the list of files shown on the screen. */
private void setFileList(List<File> files) {
- mListItems = files;
- if (mAdapter != null) {
- mAdapter.notifyDataSetChanged();
+ List<CarUiListItem> fileList = new ArrayList<>();
+ for (File file : files) {
+ CarUiContentListItem item = new CarUiContentListItem(CarUiContentListItem.Action.NONE);
+ item.setTitle(file.getName());
+ item.setOnItemClickedListener(i -> onFileSelected(file));
+ fileList.add(item);
}
+
+ CarUiListItemAdapter adapter = new CarUiListItemAdapter(fileList);
+ adapter.setMaxItems(CarUiRecyclerView.ItemCap.UNLIMITED);
+ mFolderListView.setAdapter(adapter);
}
/** Handle user selection of a file. */
@@ -235,36 +226,6 @@ public class DeviceListFragment extends Fragment implements UpFragment {
}.execute(folder);
}
- /** A list item provider to display the list of files on this fragment. */
- private class FileItemProvider extends ListItemProvider {
- private final Context mContext;
-
- FileItemProvider(Context context) {
- mContext = context;
- }
-
- @Override
- public ListItem get(int position) {
- if (position < 0 || position >= mListItems.size()) {
- return null;
- }
- TextListItem item = new TextListItem(mContext);
- File file = mListItems.get(position);
- if (file != null) {
- item.setTitle(file.getName());
- item.setOnClickListener(v -> onFileSelected(file));
- } else {
- item.setTitle(getString(R.string.unknown_file));
- }
- return item;
- }
-
- @Override
- public int size() {
- return mListItems == null ? 0 : mListItems.size();
- }
- }
-
/** Returns true if a file is considered to contain a system update. */
private static boolean isUpdateFile(File file) {
return file.getName().endsWith(UPDATE_FILE_SUFFIX);
diff --git a/src/com/android/car/systemupdater/SystemUpdaterActivity.java b/src/com/android/car/systemupdater/SystemUpdaterActivity.java
index ee1c1c8..25b8cf4 100644
--- a/src/com/android/car/systemupdater/SystemUpdaterActivity.java
+++ b/src/com/android/car/systemupdater/SystemUpdaterActivity.java
@@ -23,10 +23,13 @@ import android.os.Bundle;
import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
+import com.android.car.ui.core.CarUi;
+import com.android.car.ui.toolbar.Toolbar;
+import com.android.car.ui.toolbar.ToolbarController;
+
import java.io.File;
/**
@@ -54,8 +57,10 @@ public class SystemUpdaterActivity extends AppCompatActivity
}
setContentView(R.layout.activity_main);
- Toolbar toolbar = findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
+
+ ToolbarController toolbar = CarUi.requireToolbar(this);
+ toolbar.setTitle(getString(R.string.title));
+ toolbar.setState(Toolbar.State.SUBPAGE);
if (savedInstanceState == null) {
Bundle intentExtras = getIntent().getExtras();
diff --git a/src/com/android/car/systemupdater/UpdateLayoutFragment.java b/src/com/android/car/systemupdater/UpdateLayoutFragment.java
index 4ff1b58..ff56371 100644
--- a/src/com/android/car/systemupdater/UpdateLayoutFragment.java
+++ b/src/com/android/car/systemupdater/UpdateLayoutFragment.java
@@ -33,20 +33,22 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
-import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
+import com.android.car.ui.core.CarUi;
+import com.android.car.ui.toolbar.MenuItem;
+import com.android.car.ui.toolbar.ProgressBarController;
+import com.android.car.ui.toolbar.ToolbarController;
import com.android.internal.util.Preconditions;
import java.io.File;
import java.io.IOException;
+import java.util.Collections;
/** Display update state and progress. */
public class UpdateLayoutFragment extends Fragment implements UpFragment {
@@ -59,12 +61,12 @@ public class UpdateLayoutFragment extends Fragment implements UpFragment {
private static final String NOTIFICATION_CHANNEL_ID = "update";
private static final int NOTIFICATION_ID = 1;
- private ProgressBar mProgressBar;
private TextView mContentTitle;
private TextView mContentInfo;
private TextView mContentDetails;
private File mUpdateFile;
- private Button mSystemUpdateToolbarAction;
+ private ToolbarController mToolbar;
+ private ProgressBarController mProgressBar;
private PowerManager mPowerManager;
private NotificationManager mNotificationManager;
private final UpdateVerifier mPackageVerifier = new UpdateVerifier();
@@ -124,19 +126,11 @@ public class UpdateLayoutFragment extends Fragment implements UpFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
-
AppCompatActivity activity = (AppCompatActivity) getActivity();
-
- ActionBar actionBar = activity.getSupportActionBar();
- actionBar.setCustomView(R.layout.action_bar_with_button);
- actionBar.setDisplayShowCustomEnabled(true);
- actionBar.setDisplayShowTitleEnabled(false);
-
- mProgressBar = (ProgressBar) activity.findViewById(R.id.progress_bar);
-
- mSystemUpdateToolbarAction = activity.findViewById(R.id.action_button1);
+ mToolbar = CarUi.requireToolbar(getActivity());
+ mProgressBar = mToolbar.getProgressBar();
mProgressBar.setIndeterminate(true);
- mProgressBar.setVisibility(View.VISIBLE);
+ mProgressBar.setVisible(true);
showStatus(R.string.verify_in_progress);
if (getArguments().getBoolean(EXTRA_RESUME_UPDATE)) {
@@ -174,9 +168,11 @@ public class UpdateLayoutFragment extends Fragment implements UpFragment {
mContentInfo.append(getString(R.string.update_file_size));
mContentInfo.append(Formatter.formatFileSize(getContext(), mUpdateFile.length()));
mContentDetails.setText(null);
- mSystemUpdateToolbarAction.setOnClickListener(v -> installUpdate(update));
- mSystemUpdateToolbarAction.setText(R.string.install_now);
- mSystemUpdateToolbarAction.setVisibility(View.VISIBLE);
+ MenuItem installButton = MenuItem.builder(getActivity())
+ .setTitle(R.string.install_now)
+ .setOnClickListener(i -> installUpdate(update))
+ .build();
+ mToolbar.setMenuItems(Collections.singletonList(installButton));
}
/** Reboot the system. */
@@ -198,9 +194,9 @@ public class UpdateLayoutFragment extends Fragment implements UpFragment {
private void showInstallationInProgress() {
mInstallationInProgress = true;
mProgressBar.setIndeterminate(false);
- mProgressBar.setVisibility(View.VISIBLE);
+ mProgressBar.setVisible(true);
mProgressBar.setMax(PERCENT_MAX);
- mSystemUpdateToolbarAction.setVisibility(View.GONE);
+ mToolbar.setMenuItems(null); // Remove install button
showStatus(R.string.install_in_progress);
mUpdateEngine.bind(mCarUpdateEngineCallback, new Handler(getContext().getMainLooper()));
@@ -223,7 +219,7 @@ public class UpdateLayoutFragment extends Fragment implements UpFragment {
@Override
protected void onPostExecute(UpdateParser.ParsedUpdate result) {
- mProgressBar.setVisibility(View.GONE);
+ mProgressBar.setVisible(false);
if (result == null) {
showStatus(R.string.verify_failure);
return;
@@ -268,8 +264,8 @@ public class UpdateLayoutFragment extends Fragment implements UpFragment {
showStatus(errorCode == UpdateEngine.ErrorCodeConstants.SUCCESS
? R.string.install_success
: R.string.install_failed);
- mProgressBar.setVisibility(View.GONE);
- mSystemUpdateToolbarAction.setVisibility(View.GONE);
+ mProgressBar.setVisible(false);
+ mToolbar.setMenuItems(null); // Remove install now button
}
}