Fix double up arrow in LocalSystemUpdater
bug: 79701781
Test: m -j && emulator
Change-Id: I39bc1eb79410e5163194c330a8ecd19df5ae4b82
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e03b9c7..1a77c05 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -26,11 +26,10 @@
<application
android:label="@string/title"
- android:theme="@style/Theme.Car.Settings.NoActionBar">
+ android:theme="@style/SystemUpdaterTheme">
<activity
android:name="com.android.car.systemupdater.SystemUpdaterActivity"
- android:label="@string/title"
- android:theme="@style/Theme.Car.Settings.NoActionBar" >
+ android:label="@string/title">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
diff --git a/res/anim/trans_fade_in.xml b/res/anim/trans_fade_in.xml
new file mode 100644
index 0000000..4f80a18
--- /dev/null
+++ b/res/anim/trans_fade_in.xml
@@ -0,0 +1,24 @@
+<?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
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <alpha
+ android:fromAlpha="0.2"
+ android:toAlpha="1"
+ android:duration="@android:integer/config_mediumAnimTime" />
+</set>
diff --git a/res/anim/trans_fade_out.xml b/res/anim/trans_fade_out.xml
new file mode 100644
index 0000000..db7808a
--- /dev/null
+++ b/res/anim/trans_fade_out.xml
@@ -0,0 +1,24 @@
+<?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
+ -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <alpha
+ android:fromAlpha="1.0"
+ android:toAlpha="0.2"
+ android:duration="@android:integer/config_mediumAnimTime" />
+</set>
diff --git a/res/drawable/button_ripple_bg.xml b/res/drawable/button_ripple_bg.xml
index 7565c69..a28e38c 100644
--- a/res/drawable/button_ripple_bg.xml
+++ b/res/drawable/button_ripple_bg.xml
@@ -16,5 +16,8 @@
-->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
- android:color="@color/car_card_ripple_background">
+ android:color="@color/car_card_ripple_background"
+ android:radius="@dimen/toggle_ripple">
+ <item android:id="@android:id/mask"
+ android:drawable="@drawable/rectangle_ripple_mask" />
</ripple>
diff --git a/res/drawable/rectangle_ripple_mask.xml b/res/drawable/rectangle_ripple_mask.xml
new file mode 100644
index 0000000..69eaf8b
--- /dev/null
+++ b/res/drawable/rectangle_ripple_mask.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <corners android:radius="@dimen/car_radius_1" />
+ <solid android:color="@android:color/white" />
+</shape>
\ No newline at end of file
diff --git a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml b/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
new file mode 100644
index 0000000..e73b470
--- /dev/null
+++ b/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
@@ -0,0 +1,53 @@
+<?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.
+-->
+
+<!-- Variant of vector_drawable_progress_indeterminate_horizontal in frameworks/base/core/res, which
+ draws the whole height of the progress bar instead having blank space above and below the
+ bar. -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="10dp"
+ android:width="360dp"
+ android:viewportHeight="10"
+ android:viewportWidth="360" >
+ <group
+ android:name="progress_group"
+ android:translateX="180"
+ android:translateY="5" >
+ <path
+ android:name="background_track"
+ android:pathData="M -180.0,-5.0 l 360.0,0 l 0,10.0 l -360.0,0 Z"
+ android:fillColor="?android:attr/colorControlActivated"
+ android:fillAlpha="?android:attr/disabledAlpha"/>
+ <group
+ android:name="rect2_grp"
+ android:translateX="-197.60001"
+ android:scaleX="0.1" >
+ <path
+ android:name="rect2"
+ android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
+ android:fillColor="?android:attr/colorControlActivated" />
+ </group>
+ <group
+ android:name="rect1_grp"
+ android:translateX="-522.59998"
+ android:scaleX="0.1" >
+ <path
+ android:name="rect1"
+ android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
+ android:fillColor="?android:attr/colorControlActivated" />
+ </group>
+ </group>
+</vector>
diff --git a/res/layout/action_bar_with_button.xml b/res/layout/action_bar_with_button.xml
index db41411..5a824ab 100644
--- a/res/layout/action_bar_with_button.xml
+++ b/res/layout/action_bar_with_button.xml
@@ -20,46 +20,38 @@
android:layout_width="match_parent"
android:layout_height="@dimen/car_app_bar_height">
- <FrameLayout
- android:id="@+id/action_bar_icon_container"
- android:layout_width="@dimen/car_margin"
- android:layout_height="match_parent"
- android:layout_alignParentStart="true">
-
- <ImageView
- android:id="@+id/back_button"
- android:layout_width="@dimen/car_primary_icon_size"
- android:layout_height="@dimen/car_primary_icon_size"
- android:layout_gravity="center"
- android:background="@drawable/button_ripple_bg"
- android:src="@drawable/ic_arrow_back"/>
- </FrameLayout>
-
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/car_keyline_1"
- android:layout_toEndOf="@id/action_bar_icon_container"
android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.Car.Title2"
- android:textColor="@color/car_accent"
android:text="@string/title"/>
- <Button
- android:id="@+id/system_update_auto_toolbar_action"
- style="@style/SystemUpdateAutoToolbarAction"
+ <FrameLayout
+ android:id="@+id/button_container"
android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:layout_alignParentRight="true"
- android:visibility="gone"/>
+ 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: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/folder_list.xml b/res/layout/folder_list.xml
index 33982d6..1265653 100644
--- a/res/layout/folder_list.xml
+++ b/res/layout/folder_list.xml
@@ -25,7 +25,7 @@
android:id="@+id/current_path"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:textAppearance="@style/ListPath"
+ android:textAppearance="@style/TextAppearance.Car.Body2"
android:layout_marginStart="@dimen/car_gutter_size"
android:layout_marginEnd="@dimen/car_margin"/>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a77109b..915915f 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -16,5 +16,5 @@
-->
<resources>
<dimen name="action_bar_end_widget_margin_end">46dp</dimen>
- <dimen name="system_update_auto_toolbar_action_size">32sp</dimen>
+ <dimen name="toggle_ripple">90dp</dimen>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 4d01334..ad10701 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -14,54 +14,42 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="Theme.Car.Settings.NoActionBar" parent="Theme.Car.Light.NoActionBar">
- <item name="android:windowBackground">@color/windowBackground</item>
- <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
- <item name="android:windowLightStatusBar">true</item>
- </style>
- <style name="ActionBarStyle.Car" parent="@style/Widget.Car.Toolbar">
- <item name="actionBarSize">@dimen/car_app_bar_height</item>
- </style>
+<resources>
+ <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
- <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="SystemUpdaterTheme" parent="Theme.Car.Light.NoActionBar">
+ <item name="android:windowBackground">@color/car_card</item>
+ <item name="android:windowAnimationStyle">@style/SettingAnimationStyle</item>
+ </style>
- <style name="ListIcon.ActionBar" parent="ListIcon">
- <item name="android:tint">@color/car_accent</item>
- <item name="android:layout_gravity">center</item>
- <item name="android:src">@drawable/ic_arrow_back</item>
- </style>
- <style name="SettingsListHeader" parent="TextAppearance.Car.Title2">
- <item name="android:textColor">@color/car_accent</item>
- </style>
+ <style name="SettingAnimationStyle">
+ <item name="android:windowEnterAnimation">@anim/trans_fade_in</item>
+ <item name="android:windowExitAnimation">@anim/trans_fade_out</item>
+ </style>
- <style name="Widget.Car.Settings.ActionBar.Button.Borderless.Colored"
- parent="Widget.Car.Button.Borderless.Colored">
- <item name="android:minWidth">@dimen/car_button_min_width</item>
- <item name="android:fontFamily">roboto-regular</item>
- <item name="android:textColor">@color/action_bar_btn</item>
- </style>
+ <style name="ActionBarStyle.Car" parent="Widget.Car.Toolbar">
+ <item name="actionBarSize">@dimen/car_app_bar_height</item>
+ </style>
- <style name="SystemUpdateAutoToolbarAction">
- <item name="android:textSize">@dimen/system_update_auto_toolbar_action_size</item>
- <item name="android:textAllCaps">true</item>
- <item name="android:fontFamily">sans-serif-medium</item>
- <item name="android:textColor">@color/car_accent</item>
- <item name="android:paddingLeft">@dimen/car_padding_5</item>
- <item name="android:paddingRight">@dimen/car_padding_5</item>
- <item name="android:background">?android:selectableItemBackground</item>
- <item name="android:gravity">center</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="ListPath" parent="TextAppearance.Car.Body2">
- <item name="android:textColor">@color/car_accent</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>
+ <item name="android:fontFamily">roboto-regular</item>
+ <item name="android:textColor">@color/car_accent</item>
+ </style>
</resources>
diff --git a/src/com/android/car/systemupdater/DeviceListFragment.java b/src/com/android/car/systemupdater/DeviceListFragment.java
index fceae5c..857654b 100644
--- a/src/com/android/car/systemupdater/DeviceListFragment.java
+++ b/src/com/android/car/systemupdater/DeviceListFragment.java
@@ -48,7 +48,7 @@
/**
* Display a list of files and directories.
*/
-public class DeviceListFragment extends Fragment {
+public class DeviceListFragment extends Fragment implements UpFragment {
private static final String TAG = "DeviceListFragment";
private static final String UPDATE_FILE_SUFFIX = ".zip";
@@ -72,6 +72,7 @@
Log.d(TAG, String.format(
"onVolumeMetadataChanged %d %d %s", oldState, newState, vol.toString()));
}
+ mFileStack.clear();
showMountedVolumes();
}
};
@@ -124,8 +125,6 @@
actionBar.setCustomView(R.layout.action_bar_with_button);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
- activity.findViewById(R.id.action_bar_icon_container)
- .setOnClickListener(v -> onBackPressed());
showMountedVolumes();
}
@@ -178,6 +177,7 @@
/** Handle user selection of a file. */
private void onFileSelected(File file) {
if (isUpdateFile(file)) {
+ mFileStack.clear();
mSystemUpdater.applyUpdate(file);
} else if (file.isDirectory()) {
showFolderContent(file);
@@ -187,11 +187,10 @@
}
}
- /** Handle user pressing the back button. */
- private void onBackPressed() {
+ @Override
+ public boolean goUp() {
if (mFileStack.empty()) {
- getActivity().onBackPressed();
- return;
+ return false;
}
mFileStack.pop();
if (!mFileStack.empty()) {
@@ -201,6 +200,7 @@
// When the stack is empty, display the volumes and reset the title.
showMountedVolumes();
}
+ return true;
}
/** Display the content at the provided {@code location}. */
diff --git a/src/com/android/car/systemupdater/SystemUpdaterActivity.java b/src/com/android/car/systemupdater/SystemUpdaterActivity.java
index 13f6fcc..c53ea18 100644
--- a/src/com/android/car/systemupdater/SystemUpdaterActivity.java
+++ b/src/com/android/car/systemupdater/SystemUpdaterActivity.java
@@ -20,6 +20,7 @@
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
+import android.view.MenuItem;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
@@ -34,6 +35,7 @@
public class SystemUpdaterActivity extends AppCompatActivity
implements DeviceListFragment.SystemUpdater {
+ private static final String FRAGMENT_TAG = "FRAGMENT_TAG";
private static final int STORAGE_PERMISSIONS_REQUEST_CODE = 0;
private static final String[] REQUIRED_STORAGE_PERMISSIONS = new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE,
@@ -59,18 +61,31 @@
if (intentExtras != null && intentExtras.getBoolean(EXTRA_RESUME_UPDATE)) {
UpdateLayoutFragment fragment = UpdateLayoutFragment.newResumedInstance();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.device_container, fragment)
+ .replace(R.id.device_container, fragment, FRAGMENT_TAG)
.commitNow();
} else {
DeviceListFragment fragment = new DeviceListFragment();
getSupportFragmentManager().beginTransaction()
- .replace(R.id.device_container, fragment)
+ .replace(R.id.device_container, fragment, FRAGMENT_TAG)
.commitNow();
}
}
}
@Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ UpFragment upFragment =
+ (UpFragment) getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG);
+ if (!upFragment.goUp()) {
+ onBackPressed();
+ }
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
public void onRequestPermissionsResult(int requestCode, String permissions[],
int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
@@ -90,7 +105,7 @@
public void applyUpdate(File file) {
UpdateLayoutFragment fragment = UpdateLayoutFragment.getInstance(file);
getSupportFragmentManager().beginTransaction()
- .replace(R.id.device_container, fragment)
+ .replace(R.id.device_container, fragment, FRAGMENT_TAG)
.addToBackStack(null)
.commit();
}
diff --git a/src/com/android/car/systemupdater/UpFragment.java b/src/com/android/car/systemupdater/UpFragment.java
new file mode 100644
index 0000000..094814b
--- /dev/null
+++ b/src/com/android/car/systemupdater/UpFragment.java
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+package com.android.car.systemupdater;
+
+/** Allow a fragment to handle an up action. */
+interface UpFragment {
+ /** Returns true if the fragment handled the up action. */
+ default boolean goUp() {
+ return false;
+ }
+}
diff --git a/src/com/android/car/systemupdater/UpdateLayoutFragment.java b/src/com/android/car/systemupdater/UpdateLayoutFragment.java
index 933dbe5..4ff1b58 100644
--- a/src/com/android/car/systemupdater/UpdateLayoutFragment.java
+++ b/src/com/android/car/systemupdater/UpdateLayoutFragment.java
@@ -49,7 +49,7 @@
import java.io.IOException;
/** Display update state and progress. */
-public class UpdateLayoutFragment extends Fragment {
+public class UpdateLayoutFragment extends Fragment implements UpFragment {
public static final String EXTRA_RESUME_UPDATE = "resume_update";
private static final String TAG = "UpdateLayoutFragment";
@@ -131,12 +131,10 @@
actionBar.setCustomView(R.layout.action_bar_with_button);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
- activity.findViewById(R.id.action_bar_icon_container)
- .setOnClickListener(v -> activity.onBackPressed());
mProgressBar = (ProgressBar) activity.findViewById(R.id.progress_bar);
- mSystemUpdateToolbarAction = activity.findViewById(R.id.system_update_auto_toolbar_action);
+ mSystemUpdateToolbarAction = activity.findViewById(R.id.action_button1);
mProgressBar.setIndeterminate(true);
mProgressBar.setVisibility(View.VISIBLE);
showStatus(R.string.verify_in_progress);
@@ -163,6 +161,8 @@
mContentTitle.setText(status);
if (mInstallationInProgress) {
mNotificationManager.notify(NOTIFICATION_ID, createNotification(getContext(), status));
+ } else {
+ mNotificationManager.cancel(NOTIFICATION_ID);
}
}
@@ -264,6 +264,7 @@
@Override
public void onPayloadApplicationComplete(int errorCode) {
Log.w(TAG, String.format("onPayloadApplicationComplete %d", errorCode));
+ mInstallationInProgress = false;
showStatus(errorCode == UpdateEngine.ErrorCodeConstants.SUCCESS
? R.string.install_success
: R.string.install_failed);