SUW: use standard navigation method

Use software/hardware back button and add on-screen Next & Skip buttons.

Change-Id: I7bfa052f2217e51ea778df688e7169657aaad2c6
This commit is contained in:
Timi Rautamäki
2021-08-22 18:27:26 +00:00
parent ab4d6d383f
commit 44fb45c421
23 changed files with 226 additions and 214 deletions

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout <FrameLayout
android:id="@+id/page" android:id="@+id/page"
@@ -43,7 +44,6 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="@style/SudContentFrame"
android:visibility="gone"> android:visibility="gone">
<TextView <TextView
@@ -67,11 +67,10 @@
android:visibility="gone" /> android:visibility="gone" />
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -28,7 +28,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
style="@style/SudContentFrame">
<ImageView <ImageView
android:id="@+id/brand_logo" android:id="@+id/brand_logo"
@@ -39,14 +40,12 @@
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:gravity="center" android:gravity="center"
android:padding="@dimen/content_margin_left" android:padding="@dimen/content_margin_left"/>
style="@style/SudContentFrame"/>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout android:id="@+id/page" <FrameLayout android:id="@+id/page"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -39,8 +40,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
style="@style/SudContentFrame">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -48,23 +48,15 @@
android:text="@string/intro_restore_subtitle" android:text="@string/intro_restore_subtitle"
style="@style/SudItemTitle.GlifDescription" /> style="@style/SudItemTitle.GlifDescription" />
<Button
android:id="@+id/intro_restore_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/intro_restore_button"
style="@style/SudGlifButton.Primary" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content"
app:showSkipButton="true" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout <FrameLayout
android:id="@+id/page" android:id="@+id/page"
@@ -41,8 +42,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
style="@style/SudContentFrame">
<LinearLayout <LinearLayout
android:id="@+id/location" android:id="@+id/location"
@@ -75,11 +75,10 @@
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"
@@ -50,8 +51,7 @@
android:id="@+id/page_view" android:id="@+id/page_view"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
style="@style/SudContentFrame">
<TextView <TextView
android:id="@+id/mobile_data_summary" android:id="@+id/mobile_data_summary"
@@ -107,11 +107,10 @@
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 The LineageOS 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/navbar_skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:text="@string/skip"
android:visibility="gone"
style="@style/SudGlifButton.Secondary" />
<Button
android:id="@+id/navbar_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="@string/next"
style="@style/SudGlifButton.Primary" />
</RelativeLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout android:id="@+id/page" <FrameLayout android:id="@+id/page"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -40,8 +41,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
style="@style/SudContentFrame">
<TextView <TextView
android:id="@+id/setup_biometric_summary" android:id="@+id/setup_biometric_summary"
@@ -75,22 +75,15 @@
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold"/> android:textStyle="bold"/>
<Button
android:id="@+id/setup_biometric"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/biometric_setup_screen_lock_setup"
style="@style/SudGlifButton.Primary" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content"
app:showSkipButton="true" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout <FrameLayout
android:id="@+id/page" android:id="@+id/page"
@@ -41,8 +42,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
style="@style/SudContentFrame">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -115,11 +115,10 @@
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout <FrameLayout
android:id="@+id/page" android:id="@+id/page"
@@ -41,8 +42,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
style="@style/SudContentFrame">
<!-- The caption about privacy policy --> <!-- The caption about privacy policy -->
<TextView <TextView
@@ -114,11 +114,10 @@
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,14 +25,14 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
style="@style/SudContentFrame">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:gravity="center" android:gravity="center">
style="@style/SudContentFrame">
<org.lineageos.setupwizard.widget.LocalePicker <org.lineageos.setupwizard.widget.LocalePicker
android:id="@+id/locale_list" android:id="@+id/locale_list"
@@ -46,11 +46,10 @@
</RelativeLayout> </RelativeLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout android:id="@+id/page" <FrameLayout android:id="@+id/page"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -41,8 +42,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/content_margin_left" android:paddingStart="@dimen/content_margin_left"
android:paddingEnd="@dimen/content_margin_left" android:paddingEnd="@dimen/content_margin_left">
style="@style/SudContentFrame">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -50,23 +50,15 @@
android:text="@string/lockscreen_setup_summary" android:text="@string/lockscreen_setup_summary"
style="@style/SudItemTitle.GlifDescription" /> style="@style/SudItemTitle.GlifDescription" />
<Button
android:id="@+id/setup_lockscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/lockscreen_setup_screen_lock_setup"
style="@style/SudGlifButton.Primary" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content"
app:showSkipButton="true" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout <FrameLayout
android:id="@+id/page" android:id="@+id/page"
@@ -36,8 +37,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
style="@style/SudContentFrame">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -57,11 +57,10 @@
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<FrameLayout <FrameLayout
android:id="@+id/page" android:id="@+id/page"
@@ -41,8 +42,7 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
style="@style/SudContentFrame">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -86,11 +86,10 @@
</ScrollView> </ScrollView>
</FrameLayout> </FrameLayout>
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -25,7 +25,8 @@
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
style="@style/SudContentFrame">
<ImageView <ImageView
android:id="@+id/brand_logo" android:id="@+id/brand_logo"
@@ -36,14 +37,12 @@
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:gravity="center" android:gravity="center"
android:padding="@dimen/content_margin_left" android:padding="@dimen/content_margin_left" />
style="@style/SudContentFrame" />
<com.google.android.setupdesign.view.NavigationBar <org.lineageos.setupwizard.NavigationLayout
android:id="@+id/navigation_bar" android:id="@+id/navigation_bar"
style="@style/SudNavBarTheme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/sud_navbar_height" /> android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
</com.google.android.setupdesign.GlifLayout> </com.google.android.setupdesign.GlifLayout>

View File

@@ -32,4 +32,8 @@
<attr name="internalLayout" format="reference" /> <attr name="internalLayout" format="reference" />
<attr name="virtualButtonPressedDrawable" format="reference"/> <attr name="virtualButtonPressedDrawable" format="reference"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="NavigationLayout">
<attr name="showSkipButton" format="boolean" />
</declare-styleable>
</resources> </resources>

View File

@@ -21,31 +21,6 @@
<item name="android:paddingLeft">@dimen/content_margin_left</item> <item name="android:paddingLeft">@dimen/content_margin_left</item>
</style> </style>
<style name="ButtonBar" parent="@android:style/Widget.Material.ActionButton">
<item name="android:layout_height">56dp</item>
<item name="android:textSize">16sp</item>
<item name="android:textAllCaps">true</item>
<item name="android:maxLines">1</item>
<item name="android:minWidth">15dp</item>
<item name="android:minHeight">15dp</item>
<item name="android:textColor">@color/button_bar_text</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:drawablePadding">6dp</item>
<item name="android:ellipsize">end</item>
</style>
<style name="ButtonBar.Left">
<item name="android:paddingStart">34dp</item>
<item name="android:gravity">center_vertical|start</item>
<item name="android:drawableLeft">@drawable/ic_chevron_left_dark</item>
</style>
<style name="ButtonBar.Right">
<item name="android:paddingEnd">34dp</item>
<item name="android:gravity">center_vertical|end</item>
<item name="android:drawableRight">@drawable/ic_chevron_right_dark</item>
</style>
<style name="LocaleWidget"> <style name="LocaleWidget">
<item name="android:textAppearance">?android:attr/textAppearance</item> <item name="android:textAppearance">?android:attr/textAppearance</item>
</style> </style>

View File

@@ -56,12 +56,10 @@ import android.widget.Button;
import com.android.settingslib.Utils; import com.android.settingslib.Utils;
import com.google.android.setupdesign.view.NavigationBar;
import com.google.android.setupdesign.view.NavigationBar.NavigationBarListener;
import com.google.android.setupcompat.util.SystemBarHelper;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.GlifLayout; import com.google.android.setupdesign.GlifLayout;
import org.lineageos.setupwizard.NavigationLayout.NavigationBarListener;
import org.lineageos.setupwizard.util.SetupWizardUtils; import org.lineageos.setupwizard.util.SetupWizardUtils;
import java.util.List; import java.util.List;
@@ -83,11 +81,11 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
protected static final int BIOMETRIC_ACTIVITY_REQUEST = 10101; protected static final int BIOMETRIC_ACTIVITY_REQUEST = 10101;
protected static final int SCREENLOCK_ACTIVITY_REQUEST = 10102; protected static final int SCREENLOCK_ACTIVITY_REQUEST = 10102;
private static final int IMMERSIVE_FLAGS = private static final int IMMERSIVE_FLAGS = View.STATUS_BAR_DISABLE_HOME
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; | View.STATUS_BAR_DISABLE_RECENT;
private int mSystemUiFlags = IMMERSIVE_FLAGS | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; private int mSystemUiFlags = IMMERSIVE_FLAGS;
private NavigationBar mNavigationBar; private NavigationLayout mNavigationBar;
protected boolean mIsActivityVisible = false; protected boolean mIsActivityVisible = false;
protected boolean mIsExiting = false; protected boolean mIsExiting = false;
@@ -96,6 +94,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
private boolean mIsPrimaryUser; private boolean mIsPrimaryUser;
protected int mResultCode = 0; protected int mResultCode = 0;
private Intent mResultData; private Intent mResultData;
private final BroadcastReceiver finishReceiver = new BroadcastReceiver() { private final BroadcastReceiver finishReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@@ -121,11 +120,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
mNavigationBar = getNavigationBar(); mNavigationBar = getNavigationBar();
if (mNavigationBar != null) { if (mNavigationBar != null) {
mNavigationBar.setNavigationBarListener(this); mNavigationBar.setNavigationBarListener(this);
mNavigationBar.addOnLayoutChangeListener((View view,
int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) -> {
view.requestApplyInsets();
});
mNavigationBar.setSystemUiVisibility(mSystemUiFlags); mNavigationBar.setSystemUiVisibility(mSystemUiFlags);
// Set the UI flags before draw because the visibility might change in unexpected / // Set the UI flags before draw because the visibility might change in unexpected /
// undetectable times, like transitioning from a finishing activity that had a keyboard // undetectable times, like transitioning from a finishing activity that had a keyboard
@@ -237,59 +231,9 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
* @return The navigation bar instance in the layout, or null if the layout does not have a * @return The navigation bar instance in the layout, or null if the layout does not have a
* navigation bar. * navigation bar.
*/ */
public NavigationBar getNavigationBar() { public NavigationLayout getNavigationBar() {
final View view = findViewById(R.id.navigation_bar); final View view = findViewById(R.id.navigation_bar);
return view instanceof NavigationBar ? (NavigationBar) view : null; return view instanceof NavigationLayout ? (NavigationLayout) view : null;
}
/**
* Sets whether system navigation bar should be hidden.
* @param useImmersiveMode True to activate immersive mode and hide the system navigation bar
*/
public void setUseImmersiveMode(boolean useImmersiveMode) {
// By default, enable layoutHideNavigation if immersive mode is used
setUseImmersiveMode(useImmersiveMode, useImmersiveMode);
}
public void setUseImmersiveMode(boolean useImmersiveMode, boolean layoutHideNavigation) {
if (useImmersiveMode) {
mSystemUiFlags |= IMMERSIVE_FLAGS;
if (layoutHideNavigation) {
mSystemUiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
}
} else {
mSystemUiFlags &= ~(IMMERSIVE_FLAGS | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}
if (mNavigationBar != null) {
mNavigationBar.setSystemUiVisibility(mSystemUiFlags);
}
}
protected void setBackDrawable(Drawable drawable) {
if (mNavigationBar != null) {
mNavigationBar.getBackButton().setCompoundDrawables(drawable, null, null, null);
}
}
protected void setNextDrawable(Drawable drawable) {
if (mNavigationBar != null) {
mNavigationBar.getBackButton().setCompoundDrawables(null, null, drawable, null);
}
}
public void setBackAllowed(boolean allowed) {
SystemBarHelper.setBackButtonVisible(getWindow(), allowed);
if (mNavigationBar != null) {
Button backButton = mNavigationBar.getBackButton();
backButton.setEnabled(allowed);
}
}
protected boolean isBackAllowed() {
if (mNavigationBar != null) {
mNavigationBar.getBackButton().isEnabled();
}
return false;
} }
public void setNextAllowed(boolean allowed) { public void setNextAllowed(boolean allowed) {
@@ -309,15 +253,19 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
nextAction(NEXT_REQUEST); nextAction(NEXT_REQUEST);
} }
protected void onSkipPressed() {
nextAction(NEXT_REQUEST);
}
protected void setNextText(int resId) { protected void setNextText(int resId) {
if (mNavigationBar != null) { if (mNavigationBar != null) {
mNavigationBar.getNextButton().setText(resId); mNavigationBar.getNextButton().setText(resId);
} }
} }
protected void setBackText(int resId) { protected void setSkipText(int resId) {
if (mNavigationBar != null) { if (mNavigationBar != null) {
mNavigationBar.getBackButton().setText(resId); mNavigationBar.getSkipButton().setText(resId);
} }
} }
@@ -351,6 +299,10 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
onNextPressed(); onNextPressed();
} }
public void onSkip() {
onSkipPressed();
}
protected void startEmergencyDialer() { protected void startEmergencyDialer() {
try { try {
startFirstRunActivityForResult(new Intent(ACTION_EMERGENCY_DIAL), startFirstRunActivityForResult(new Intent(ACTION_EMERGENCY_DIAL),
@@ -528,15 +480,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
} }
} }
protected void hideBackButton() {
if (mNavigationBar != null) {
Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
final Button back = mNavigationBar.getBackButton();
back.startAnimation(fadeOut);
back.setVisibility(INVISIBLE);
}
}
protected int getTransition() { protected int getTransition() {
return TRANSITION_ID_SLIDE; return TRANSITION_ID_SLIDE;
} }

View File

@@ -50,10 +50,14 @@ public class BiometricActivity extends SubBaseActivity {
} }
} }
@Override
protected void onNextPressed() {
launchBiometricSetup();
}
@Override @Override
protected void onStartSubactivity() { protected void onStartSubactivity() {
setNextAllowed(true); setNextAllowed(true);
findViewById(R.id.setup_biometric).setOnClickListener(view -> launchBiometricSetup());
} }
@Override @Override

View File

@@ -111,7 +111,6 @@ public class FinishActivity extends BaseSetupWizardActivity {
sendBroadcastAsUser(i, getCallingUserHandle(), FINISH_SETUP); sendBroadcastAsUser(i, getCallingUserHandle(), FINISH_SETUP);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
hideBackButton();
hideNextButton(); hideNextButton();
finishSetup(); finishSetup();
} }

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) 2021 The LineageOS 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 org.lineageos.setupwizard;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
public class NavigationLayout extends RelativeLayout {
/*
* An interface to listen to events of the navigation bar,
* namely when the user clicks on the back or next button.
*/
public interface NavigationBarListener {
void onNavigateBack();
void onNavigateNext();
void onSkip();
}
private final Button mNextButton;
private final Button mSkipButton;
public NavigationLayout(Context context, AttributeSet attrs) {
super(context, attrs);
View.inflate(context, R.layout.navigation_layout, this);
mNextButton = findViewById(R.id.navbar_next);
mSkipButton = findViewById(R.id.navbar_skip);
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.NavigationLayout, 0, 0);
final boolean showSkipButton;
try {
showSkipButton = a.getBoolean(
R.styleable.NavigationLayout_showSkipButton, false);
} finally {
a.recycle();
}
if (showSkipButton) {
mSkipButton.setVisibility(View.VISIBLE);
}
}
public Button getSkipButton() {
return mSkipButton;
}
public Button getNextButton() {
return mNextButton;
}
public void setNavigationBarListener(NavigationBarListener listener) {
mSkipButton.setOnClickListener(view -> listener.onSkip());
mNextButton.setOnClickListener(view -> listener.onNavigateNext());
}
}

View File

@@ -24,8 +24,8 @@ import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_LOCKSC
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View;
import org.lineageos.setupwizard.util.SetupWizardUtils; import org.lineageos.setupwizard.util.SetupWizardUtils;
@@ -33,6 +33,11 @@ public class ScreenLockActivity extends SubBaseActivity {
public static final String TAG = ScreenLockActivity.class.getSimpleName(); public static final String TAG = ScreenLockActivity.class.getSimpleName();
@Override
protected void onNextPressed() {
launchLockscreenSetup();
}
@Override @Override
protected void onStartSubactivity() { protected void onStartSubactivity() {
if (isKeyguardSecure()) { if (isKeyguardSecure()) {
@@ -43,12 +48,6 @@ public class ScreenLockActivity extends SubBaseActivity {
return; return;
} }
setNextAllowed(true); setNextAllowed(true);
findViewById(R.id.setup_lockscreen).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchLockscreenSetup();
}
});
} }
@Override @Override

View File

@@ -35,8 +35,7 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mRootView = findViewById(R.id.setup_wizard_layout); mRootView = findViewById(R.id.setup_wizard_layout);
setNextText(R.string.next); setNextText(R.string.next);
setBackText(R.string.emergency_call); setSkipText(R.string.emergency_call);
setBackDrawable(null);
mEnableAccessibilityController = mEnableAccessibilityController =
EnableAccessibilityController.getInstance(getApplicationContext()); EnableAccessibilityController.getInstance(getApplicationContext());
mRootView.setOnTouchListener((v, event) -> mRootView.setOnTouchListener((v, event) ->
@@ -47,6 +46,11 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
@Override @Override
public void onBackPressed() {} public void onBackPressed() {}
@Override
public void onSkip() {
startEmergencyDialer();
}
@Override @Override
public void onNavigateBack() { public void onNavigateBack() {
startEmergencyDialer(); startEmergencyDialer();

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2019-2020 The Calyx Institute * Copyright (C) 2019-2020 The Calyx Institute
* Copyright (C) 2020 The LineageOS Project * Copyright (C) 2020-2021 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import android.content.Intent;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
import org.lineageos.setupwizard.NavigationLayout;
import org.lineageos.setupwizard.R; import org.lineageos.setupwizard.R;
import org.lineageos.setupwizard.SubBaseActivity; import org.lineageos.setupwizard.SubBaseActivity;
@@ -33,12 +34,15 @@ public class RestoreIntroActivity extends SubBaseActivity {
@Override @Override
protected void onStartSubactivity() { protected void onStartSubactivity() {
setNextAllowed(true); setNextAllowed(true);
findViewById(R.id.intro_restore_button).setOnClickListener(v -> launchRestore());
} }
@Override @Override
protected void onNextPressed() { protected void onNextPressed() {
launchRestore();
}
@Override
protected void onSkipPressed() {
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK); Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
nextAction(NEXT_REQUEST, intent); nextAction(NEXT_REQUEST, intent);
} }