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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user