diff --git a/res/layout/choose_data_sim_page.xml b/res/layout/choose_data_sim_page.xml
index fdac422d..0de7e1d4 100644
--- a/res/layout/choose_data_sim_page.xml
+++ b/res/layout/choose_data_sim_page.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/finish_activity.xml b/res/layout/finish_activity.xml
index a80a5609..70050635 100644
--- a/res/layout/finish_activity.xml
+++ b/res/layout/finish_activity.xml
@@ -28,7 +28,8 @@
+ android:orientation="vertical"
+ style="@style/SudContentFrame">
+ android:padding="@dimen/content_margin_left"/>
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/intro_restore_activity.xml b/res/layout/intro_restore_activity.xml
index 09366057..a3934a08 100644
--- a/res/layout/intro_restore_activity.xml
+++ b/res/layout/intro_restore_activity.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="wrap_content">
-
-
-
+ android:layout_height="wrap_content"
+ app:showSkipButton="true" />
diff --git a/res/layout/location_settings.xml b/res/layout/location_settings.xml
index 094bc8be..3771fc3f 100644
--- a/res/layout/location_settings.xml
+++ b/res/layout/location_settings.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="match_parent">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/mobile_data_settings.xml b/res/layout/mobile_data_settings.xml
index 54bbd607..26888c5e 100644
--- a/res/layout/mobile_data_settings.xml
+++ b/res/layout/mobile_data_settings.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="wrap_content">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/navigation_layout.xml b/res/layout/navigation_layout.xml
new file mode 100644
index 00000000..9b562780
--- /dev/null
+++ b/res/layout/navigation_layout.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/setup_biometric.xml b/res/layout/setup_biometric.xml
index 6c7d86d9..492a9d7f 100644
--- a/res/layout/setup_biometric.xml
+++ b/res/layout/setup_biometric.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="wrap_content">
-
-
-
+ android:layout_height="wrap_content"
+ app:showSkipButton="true" />
diff --git a/res/layout/setup_datetime_page.xml b/res/layout/setup_datetime_page.xml
index 304d9f74..f6584256 100644
--- a/res/layout/setup_datetime_page.xml
+++ b/res/layout/setup_datetime_page.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="wrap_content">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/setup_lineage_settings.xml b/res/layout/setup_lineage_settings.xml
index 3e808ae3..a222d5b1 100644
--- a/res/layout/setup_lineage_settings.xml
+++ b/res/layout/setup_lineage_settings.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="match_parent">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/setup_locale.xml b/res/layout/setup_locale.xml
index 672d4f21..9af6d009 100644
--- a/res/layout/setup_locale.xml
+++ b/res/layout/setup_locale.xml
@@ -25,14 +25,14 @@
+ android:orientation="vertical"
+ style="@style/SudContentFrame">
+ android:gravity="center">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/setup_lockscreen.xml b/res/layout/setup_lockscreen.xml
index 299cc05f..895b06f3 100644
--- a/res/layout/setup_lockscreen.xml
+++ b/res/layout/setup_lockscreen.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:paddingEnd="@dimen/content_margin_left">
-
-
-
+ android:layout_height="wrap_content"
+ app:showSkipButton="true" />
diff --git a/res/layout/sim_missing_page.xml b/res/layout/sim_missing_page.xml
index f53a0808..5c15a6d4 100644
--- a/res/layout/sim_missing_page.xml
+++ b/res/layout/sim_missing_page.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="match_parent">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/update_recovery_page.xml b/res/layout/update_recovery_page.xml
index 0f91393c..de7fec44 100644
--- a/res/layout/update_recovery_page.xml
+++ b/res/layout/update_recovery_page.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:layout_height="match_parent">
-
+ android:layout_height="wrap_content" />
diff --git a/res/layout/welcome_activity.xml b/res/layout/welcome_activity.xml
index 0515c958..1aa834f5 100644
--- a/res/layout/welcome_activity.xml
+++ b/res/layout/welcome_activity.xml
@@ -25,7 +25,8 @@
+ android:layout_height="match_parent"
+ style="@style/SudContentFrame">
+ android:padding="@dimen/content_margin_left" />
-
+ android:layout_height="wrap_content" />
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 4bf723fd..b5fdee8d 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -32,4 +32,8 @@
+
+
+
+
diff --git a/res/values/styles.xml b/res/values/styles.xml
index f2b4f869..fca98ca1 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -21,31 +21,6 @@
- @dimen/content_margin_left
-
-
-
-
-
-
diff --git a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java
index 512e75b8..d27a5f6c 100644
--- a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java
+++ b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java
@@ -56,12 +56,10 @@ import android.widget.Button;
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.setupdesign.GlifLayout;
+import org.lineageos.setupwizard.NavigationLayout.NavigationBarListener;
import org.lineageos.setupwizard.util.SetupWizardUtils;
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 SCREENLOCK_ACTIVITY_REQUEST = 10102;
- private static final int IMMERSIVE_FLAGS =
- View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
- private int mSystemUiFlags = IMMERSIVE_FLAGS | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ private static final int IMMERSIVE_FLAGS = View.STATUS_BAR_DISABLE_HOME
+ | View.STATUS_BAR_DISABLE_RECENT;
+ private int mSystemUiFlags = IMMERSIVE_FLAGS;
- private NavigationBar mNavigationBar;
+ private NavigationLayout mNavigationBar;
protected boolean mIsActivityVisible = false;
protected boolean mIsExiting = false;
@@ -96,6 +94,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
private boolean mIsPrimaryUser;
protected int mResultCode = 0;
private Intent mResultData;
+
private final BroadcastReceiver finishReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -121,11 +120,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
mNavigationBar = getNavigationBar();
if (mNavigationBar != null) {
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);
// 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
@@ -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
* navigation bar.
*/
- public NavigationBar getNavigationBar() {
+ public NavigationLayout getNavigationBar() {
final View view = findViewById(R.id.navigation_bar);
- return view instanceof NavigationBar ? (NavigationBar) 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;
+ return view instanceof NavigationLayout ? (NavigationLayout) view : null;
}
public void setNextAllowed(boolean allowed) {
@@ -309,15 +253,19 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
nextAction(NEXT_REQUEST);
}
+ protected void onSkipPressed() {
+ nextAction(NEXT_REQUEST);
+ }
+
protected void setNextText(int resId) {
if (mNavigationBar != null) {
mNavigationBar.getNextButton().setText(resId);
}
}
- protected void setBackText(int resId) {
+ protected void setSkipText(int resId) {
if (mNavigationBar != null) {
- mNavigationBar.getBackButton().setText(resId);
+ mNavigationBar.getSkipButton().setText(resId);
}
}
@@ -351,6 +299,10 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
onNextPressed();
}
+ public void onSkip() {
+ onSkipPressed();
+ }
+
protected void startEmergencyDialer() {
try {
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() {
return TRANSITION_ID_SLIDE;
}
diff --git a/src/org/lineageos/setupwizard/BiometricActivity.java b/src/org/lineageos/setupwizard/BiometricActivity.java
index 0eaaa262..510bc468 100644
--- a/src/org/lineageos/setupwizard/BiometricActivity.java
+++ b/src/org/lineageos/setupwizard/BiometricActivity.java
@@ -50,10 +50,14 @@ public class BiometricActivity extends SubBaseActivity {
}
}
+ @Override
+ protected void onNextPressed() {
+ launchBiometricSetup();
+ }
+
@Override
protected void onStartSubactivity() {
setNextAllowed(true);
- findViewById(R.id.setup_biometric).setOnClickListener(view -> launchBiometricSetup());
}
@Override
diff --git a/src/org/lineageos/setupwizard/FinishActivity.java b/src/org/lineageos/setupwizard/FinishActivity.java
index 4eeaeb91..69374546 100644
--- a/src/org/lineageos/setupwizard/FinishActivity.java
+++ b/src/org/lineageos/setupwizard/FinishActivity.java
@@ -111,7 +111,6 @@ public class FinishActivity extends BaseSetupWizardActivity {
sendBroadcastAsUser(i, getCallingUserHandle(), FINISH_SETUP);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
- hideBackButton();
hideNextButton();
finishSetup();
}
diff --git a/src/org/lineageos/setupwizard/NavigationLayout.java b/src/org/lineageos/setupwizard/NavigationLayout.java
new file mode 100644
index 00000000..daa837f6
--- /dev/null
+++ b/src/org/lineageos/setupwizard/NavigationLayout.java
@@ -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());
+ }
+}
diff --git a/src/org/lineageos/setupwizard/ScreenLockActivity.java b/src/org/lineageos/setupwizard/ScreenLockActivity.java
index 92fa5283..74b10623 100644
--- a/src/org/lineageos/setupwizard/ScreenLockActivity.java
+++ b/src/org/lineageos/setupwizard/ScreenLockActivity.java
@@ -24,8 +24,8 @@ import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_LOCKSC
import android.app.KeyguardManager;
import android.content.Intent;
+import android.os.Bundle;
import android.util.Log;
-import android.view.View;
import org.lineageos.setupwizard.util.SetupWizardUtils;
@@ -33,6 +33,11 @@ public class ScreenLockActivity extends SubBaseActivity {
public static final String TAG = ScreenLockActivity.class.getSimpleName();
+ @Override
+ protected void onNextPressed() {
+ launchLockscreenSetup();
+ }
+
@Override
protected void onStartSubactivity() {
if (isKeyguardSecure()) {
@@ -43,12 +48,6 @@ public class ScreenLockActivity extends SubBaseActivity {
return;
}
setNextAllowed(true);
- findViewById(R.id.setup_lockscreen).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- launchLockscreenSetup();
- }
- });
}
@Override
diff --git a/src/org/lineageos/setupwizard/WelcomeActivity.java b/src/org/lineageos/setupwizard/WelcomeActivity.java
index 7f6aac2c..3fef20d4 100644
--- a/src/org/lineageos/setupwizard/WelcomeActivity.java
+++ b/src/org/lineageos/setupwizard/WelcomeActivity.java
@@ -35,8 +35,7 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
super.onCreate(savedInstanceState);
mRootView = findViewById(R.id.setup_wizard_layout);
setNextText(R.string.next);
- setBackText(R.string.emergency_call);
- setBackDrawable(null);
+ setSkipText(R.string.emergency_call);
mEnableAccessibilityController =
EnableAccessibilityController.getInstance(getApplicationContext());
mRootView.setOnTouchListener((v, event) ->
@@ -47,6 +46,11 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
@Override
public void onBackPressed() {}
+ @Override
+ public void onSkip() {
+ startEmergencyDialer();
+ }
+
@Override
public void onNavigateBack() {
startEmergencyDialer();
diff --git a/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java b/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java
index b0ee807c..aa10d970 100644
--- a/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java
+++ b/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java
@@ -1,6 +1,6 @@
/*
* 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");
* 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 org.lineageos.setupwizard.NavigationLayout;
import org.lineageos.setupwizard.R;
import org.lineageos.setupwizard.SubBaseActivity;
@@ -33,12 +34,15 @@ public class RestoreIntroActivity extends SubBaseActivity {
@Override
protected void onStartSubactivity() {
setNextAllowed(true);
-
- findViewById(R.id.intro_restore_button).setOnClickListener(v -> launchRestore());
}
@Override
protected void onNextPressed() {
+ launchRestore();
+ }
+
+ @Override
+ protected void onSkipPressed() {
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
nextAction(NEXT_REQUEST, intent);
}