Update deprecated code
Change-Id: I1b128b0f8b654c5c76464c12145d927ec10da26e
This commit is contained in:
committed by
Michael Bestas
parent
83338c4ae6
commit
f58c0f4b83
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2021-2023 The LineageOS Project
|
||||
// Copyright (C) 2021-2024 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.
|
||||
@@ -31,7 +31,8 @@ android_app {
|
||||
},
|
||||
|
||||
static_libs: [
|
||||
"androidx.core_core",
|
||||
"androidx.activity_activity",
|
||||
"androidx.work_work-runtime-ktx",
|
||||
"SettingsLib",
|
||||
"setupcompat",
|
||||
"setupdesign",
|
||||
|
@@ -52,9 +52,6 @@
|
||||
<protected-broadcast android:name="org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE"
|
||||
android:permission="lineageos.permission.FINISH_SETUP"/>
|
||||
|
||||
<protected-broadcast android:name="org.lineageos.setupwizard.SETUP_FINISHED"
|
||||
android:permission="lineageos.permission.FINISH_SETUP"/>
|
||||
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:theme="@style/Theme.Setup"
|
||||
@@ -175,19 +172,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".CaptivePortalSetupActivity"
|
||||
android:label="@string/activity_label_empty"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
android:immersive="true"
|
||||
android:exported="false"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="org.lineageos.setupwizard.LINEAGE_CAPTIVE_PORTAL_SETUP" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".LocationSettingsActivity"
|
||||
android:label="@string/activity_label_empty"
|
||||
android:excludeFromRecents="true"
|
||||
@@ -347,7 +331,7 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name=".SetupWizardExitService"
|
||||
<service android:name=".SetupWizardExitWorker"
|
||||
android:exported="false"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
@@ -15,7 +15,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<org.lineageos.setupwizard.widget.ScrimInsetsFrameLayout
|
||||
<android.widget.FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
@@ -56,4 +56,4 @@
|
||||
android:background="@drawable/reveal"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
</org.lineageos.setupwizard.widget.ScrimInsetsFrameLayout>
|
||||
</android.widget.FrameLayout>
|
||||
|
@@ -46,7 +46,14 @@
|
||||
<item name="virtualButtonPressedDrawable">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="NoDisplay" parent="@android:style/Theme.NoDisplay" />
|
||||
<style name="NoDisplay" parent="@style/Theme.AppCompat">
|
||||
<item name="android:windowBackground">@null</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowAnimationStyle">@null</item>
|
||||
<item name="android:windowDisablePreview">true</item>
|
||||
<item name="android:windowNoDisplay">true</item>
|
||||
</style>
|
||||
|
||||
<style name="WelcomeTitle">
|
||||
<item name="android:textSize">@dimen/welcome_title_text_size</item>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* 2017-2022 The LineageOS Project
|
||||
* 2017-2024 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.
|
||||
@@ -19,21 +19,14 @@ package org.lineageos.setupwizard;
|
||||
|
||||
import static android.view.View.INVISIBLE;
|
||||
|
||||
import static com.google.android.setupcompat.util.ResultCodes.RESULT_ACTIVITY_NOT_FOUND;
|
||||
import static com.google.android.setupcompat.util.ResultCodes.RESULT_RETRY;
|
||||
import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_ACCESSIBILITY_SETTINGS;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_EMERGENCY_DIAL;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_HAS_MULTIPLE_USERS;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -42,12 +35,17 @@ import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.activity.result.ActivityResult;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.android.settingslib.Utils;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
@@ -58,7 +56,8 @@ import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BaseSetupWizardActivity extends Activity implements NavigationBarListener {
|
||||
public abstract class BaseSetupWizardActivity extends AppCompatActivity implements
|
||||
NavigationBarListener {
|
||||
|
||||
public static final String TAG = BaseSetupWizardActivity.class.getSimpleName();
|
||||
|
||||
@@ -67,23 +66,8 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
protected static final int TRANSITION_ID_SLIDE = 2;
|
||||
protected static final int TRANSITION_ID_FADE = 3;
|
||||
|
||||
protected static final int NEXT_REQUEST = 10000;
|
||||
protected static final int EMERGENCY_DIAL_ACTIVITY_REQUEST = 10038;
|
||||
protected static final int ACCESSIBILITY_SETTINGS_ACTIVITY_REQUEST = 10039;
|
||||
protected static final int WIFI_ACTIVITY_REQUEST = 10004;
|
||||
protected static final int BLUETOOTH_ACTIVITY_REQUEST = 10100;
|
||||
protected static final int BIOMETRIC_ACTIVITY_REQUEST = 10101;
|
||||
protected static final int SCREENLOCK_ACTIVITY_REQUEST = 10102;
|
||||
|
||||
private NavigationLayout mNavigationBar;
|
||||
|
||||
protected boolean mIsActivityVisible = false;
|
||||
protected boolean mIsExiting = false;
|
||||
private final boolean mIsFirstRun = true;
|
||||
protected boolean mIsGoingBack = false;
|
||||
protected int mResultCode = 0;
|
||||
private Intent mResultData;
|
||||
|
||||
private final BroadcastReceiver finishReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -96,6 +80,9 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
}
|
||||
}
|
||||
};
|
||||
private final ActivityResultLauncher<Intent> activityResultLauncher = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
BaseSetupWizardActivity.this::onActivityResult);
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -109,6 +96,15 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.setNavigationBarListener(this);
|
||||
}
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "handleOnBackPressed()");
|
||||
}
|
||||
finishAction(RESULT_CANCELED, new Intent().putExtra("onBackPressed", true));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,13 +132,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
logActivityState("onResume");
|
||||
}
|
||||
super.onResume();
|
||||
if (mIsGoingBack) {
|
||||
if (!mIsExiting) {
|
||||
applyBackwardTransition(getTransition());
|
||||
}
|
||||
} else if (!mIsExiting) {
|
||||
applyForwardTransition(getTransition());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,7 +164,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
if (LOGV) {
|
||||
logActivityState("onAttachedToWindow");
|
||||
}
|
||||
mIsActivityVisible = true;
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
|
||||
@@ -213,7 +201,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
return view instanceof NavigationLayout ? (NavigationLayout) view : null;
|
||||
}
|
||||
|
||||
public void setNextAllowed(boolean allowed) {
|
||||
public final void setNextAllowed(boolean allowed) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getNextButton().setEnabled(allowed);
|
||||
}
|
||||
@@ -234,7 +222,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
nextAction(RESULT_SKIP);
|
||||
}
|
||||
|
||||
protected void setNextText(int resId) {
|
||||
protected final void setNextText(int resId) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getNextButton().setText(resId);
|
||||
}
|
||||
@@ -244,34 +232,21 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
return mNavigationBar.getNextButton();
|
||||
}
|
||||
|
||||
protected void setSkipText(int resId) {
|
||||
protected final void setSkipText(int resId) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getSkipButton().setText(resId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideNextButton() {
|
||||
protected final void hideNextButton() {
|
||||
if (mNavigationBar != null) {
|
||||
final Button next = mNavigationBar.getNextButton();
|
||||
next.setVisibility(INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
protected Intent getResultData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onBackPressed()");
|
||||
}
|
||||
setResultCode(RESULT_CANCELED, getResultData());
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
public void onNavigateBack() {
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
|
||||
public void onNavigateNext() {
|
||||
@@ -282,35 +257,13 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
onSkipPressed();
|
||||
}
|
||||
|
||||
protected void startEmergencyDialer() {
|
||||
try {
|
||||
startFirstRunActivityForResult(new Intent(ACTION_EMERGENCY_DIAL),
|
||||
EMERGENCY_DIAL_ACTIVITY_REQUEST);
|
||||
applyForwardTransition(TRANSITION_ID_DEFAULT);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "Can't find the emergency dialer: com.android.phone.EmergencyDialer.DIAL");
|
||||
}
|
||||
}
|
||||
|
||||
protected void startAccessibilitySettings() {
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_ACCESSIBILITY_SETTINGS);
|
||||
startFirstRunActivityForResult(intent, ACCESSIBILITY_SETTINGS_ACTIVITY_REQUEST);
|
||||
applyForwardTransition(TRANSITION_ID_DEFAULT);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "Can't find the accessibility settings: " +
|
||||
"android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW");
|
||||
}
|
||||
}
|
||||
|
||||
protected void onSetupStart() {
|
||||
protected final void onSetupStart() {
|
||||
if (SetupWizardUtils.isOwner()) {
|
||||
SetupWizardUtils.disableCaptivePortalDetection(getApplicationContext());
|
||||
tryEnablingWifi();
|
||||
}
|
||||
}
|
||||
|
||||
protected void exitIfSetupComplete() {
|
||||
private void exitIfSetupComplete() {
|
||||
if (WizardManagerHelper.isUserSetupComplete(this)) {
|
||||
Log.i(TAG, "Starting activity with USER_SETUP_COMPLETE=true");
|
||||
startSetupWizardExitActivity();
|
||||
@@ -319,7 +272,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
}
|
||||
}
|
||||
|
||||
protected void finishAllAppTasks() {
|
||||
protected final void finishAllAppTasks() {
|
||||
List<ActivityManager.AppTask> appTasks =
|
||||
getSystemService(ActivityManager.class).getAppTasks();
|
||||
|
||||
@@ -332,300 +285,129 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
|
||||
finish();
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onActivityResult(" + getRequestName(requestCode) + ", " +
|
||||
getResultName(requestCode, resultCode) + ")");
|
||||
}
|
||||
mIsGoingBack = true;
|
||||
if (requestCode != NEXT_REQUEST || resultCode != RESULT_CANCELED) {
|
||||
if (requestCode == EMERGENCY_DIAL_ACTIVITY_REQUEST |
|
||||
requestCode == ACCESSIBILITY_SETTINGS_ACTIVITY_REQUEST) {
|
||||
applyBackwardTransition(TRANSITION_ID_DEFAULT);
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
finish();
|
||||
} else {
|
||||
nextAction(resultCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "finish");
|
||||
}
|
||||
super.finish();
|
||||
if (isResumed() && mResultCode == RESULT_CANCELED) {
|
||||
applyBackwardTransition(getTransition());
|
||||
}
|
||||
mIsExiting = true;
|
||||
}
|
||||
|
||||
protected void finishAction() {
|
||||
finishAction(RESULT_CANCELED);
|
||||
}
|
||||
|
||||
protected void finishAction(int resultCode) {
|
||||
protected final void finishAction(int resultCode) {
|
||||
finishAction(resultCode, null);
|
||||
}
|
||||
|
||||
protected void finishAction(int resultCode, Intent data) {
|
||||
if (resultCode != 0) {
|
||||
protected final void finishAction(int resultCode, Intent data) {
|
||||
if (resultCode != RESULT_CANCELED) {
|
||||
nextAction(resultCode, data);
|
||||
} else {
|
||||
setResult(resultCode, data);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
protected void setResultCode(int resultCode) {
|
||||
setResultCode(resultCode, getResultData());
|
||||
}
|
||||
|
||||
protected void setResultCode(int resultCode, Intent data) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "setResultCode result=" + getResultName(0, resultCode) + " data=" + data);
|
||||
}
|
||||
mResultCode = resultCode;
|
||||
mResultData = data;
|
||||
setResult(resultCode, data);
|
||||
}
|
||||
|
||||
protected void nextAction(int resultCode) {
|
||||
protected final void nextAction(int resultCode) {
|
||||
nextAction(resultCode, null);
|
||||
}
|
||||
|
||||
protected void nextAction(int resultCode, Intent data) {
|
||||
protected final void nextAction(int resultCode, Intent data) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "nextAction resultCode=" + resultCode +
|
||||
" data=" + data + " this=" + this);
|
||||
}
|
||||
if (resultCode == 0) {
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
throw new IllegalArgumentException("Cannot call nextAction with RESULT_CANCELED");
|
||||
}
|
||||
setResultCode(resultCode, data);
|
||||
sendActionResults();
|
||||
setResult(resultCode, data);
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), resultCode, data);
|
||||
startActivityForResult(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivity(Intent intent) {
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, isFirstRun());
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
|
||||
super.startActivity(intent);
|
||||
if (isResumed() && mIsActivityVisible) {
|
||||
applyForwardTransition(getTransition());
|
||||
}
|
||||
mIsExiting = true;
|
||||
}
|
||||
|
||||
public void startActivityForResult(Intent intent, int requestCode) {
|
||||
protected final void startActivityForResult(@NonNull Intent intent) {
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, isFirstRun());
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
|
||||
super.startActivityForResult(intent, requestCode);
|
||||
if (isResumed() && mIsActivityVisible) {
|
||||
applyForwardTransition(getTransition());
|
||||
}
|
||||
mIsExiting = true;
|
||||
activityResultLauncher.launch(intent);
|
||||
}
|
||||
|
||||
protected void sendActionResults() {
|
||||
protected void onActivityResult(ActivityResult activityResult) {
|
||||
int resultCode = activityResult.getResultCode();
|
||||
Intent data = activityResult.getData();
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "sendActionResults resultCode=" + mResultCode + " data=" + mResultData);
|
||||
StringBuilder append = new StringBuilder().append("onActivityResult(")
|
||||
.append(resultCode).append(", ");
|
||||
Bundle extras = null;
|
||||
if (data != null) {
|
||||
extras = data.getExtras();
|
||||
}
|
||||
Log.v(TAG, append.append(extras).append(")").toString());
|
||||
}
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), mResultCode, mResultData);
|
||||
startActivityForResult(intent, NEXT_REQUEST);
|
||||
}
|
||||
|
||||
protected void applyForwardTransition(int transitionId) {
|
||||
protected final void applyForwardTransition(int transitionId) {
|
||||
if (transitionId == TRANSITION_ID_SLIDE) {
|
||||
overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, R.anim.sud_slide_next_in,
|
||||
R.anim.sud_slide_next_out);
|
||||
} else if (transitionId == TRANSITION_ID_FADE) {
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, android.R.anim.fade_in,
|
||||
android.R.anim.fade_out);
|
||||
} else if (transitionId == TRANSITION_ID_DEFAULT) {
|
||||
TypedArray typedArray = obtainStyledAttributes(android.R.style.Animation_Activity,
|
||||
new int[]{android.R.attr.activityOpenEnterAnimation,
|
||||
android.R.attr.activityOpenExitAnimation});
|
||||
overridePendingTransition(typedArray.getResourceId(0, 0),
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, typedArray.getResourceId(0, 0),
|
||||
typedArray.getResourceId(1, 0));
|
||||
typedArray.recycle();
|
||||
} else if (transitionId == TRANSITION_ID_NONE) {
|
||||
overridePendingTransition(0, 0);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyBackwardTransition(int transitionId) {
|
||||
protected final void applyBackwardTransition(int transitionId) {
|
||||
if (transitionId == TRANSITION_ID_SLIDE) {
|
||||
overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, R.anim.sud_slide_back_in,
|
||||
R.anim.sud_slide_back_out);
|
||||
} else if (transitionId == TRANSITION_ID_FADE) {
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, android.R.anim.fade_in,
|
||||
android.R.anim.fade_out);
|
||||
} else if (transitionId == TRANSITION_ID_DEFAULT) {
|
||||
TypedArray typedArray = obtainStyledAttributes(android.R.style.Animation_Activity,
|
||||
new int[]{android.R.attr.activityCloseEnterAnimation,
|
||||
android.R.attr.activityCloseExitAnimation});
|
||||
overridePendingTransition(typedArray.getResourceId(0, 0),
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, typedArray.getResourceId(0, 0),
|
||||
typedArray.getResourceId(1, 0));
|
||||
typedArray.recycle();
|
||||
} else if (transitionId == TRANSITION_ID_NONE) {
|
||||
overridePendingTransition(0, 0);
|
||||
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getTransition() {
|
||||
return TRANSITION_ID_SLIDE;
|
||||
}
|
||||
|
||||
protected boolean tryEnablingWifi() {
|
||||
protected final boolean tryEnablingWifi() {
|
||||
WifiManager wifiManager = getSystemService(WifiManager.class);
|
||||
if (wifiManager != null && !wifiManager.isWifiEnabled()) {
|
||||
return wifiManager.setWifiEnabled(true);
|
||||
}
|
||||
return false;
|
||||
return wifiManager.setWifiEnabled(true);
|
||||
}
|
||||
|
||||
private void startSetupWizardExitActivity() {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "startSetupWizardExitActivity()");
|
||||
}
|
||||
startFirstRunActivity(new Intent(this, SetupWizardExitActivity.class));
|
||||
startActivity(new Intent(this, SetupWizardExitActivity.class));
|
||||
}
|
||||
|
||||
protected void startFirstRunActivity(Intent intent) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "starting activity " + intent);
|
||||
}
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, isFirstRun());
|
||||
intent.putExtra(EXTRA_HAS_MULTIPLE_USERS, hasMultipleUsers());
|
||||
startActivity(intent);
|
||||
private boolean isFirstRun() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void startFirstRunActivityForResult(Intent intent, int requestCode) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "startFirstRunActivityForResult requestCode=" + requestCode);
|
||||
}
|
||||
intent.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, isFirstRun());
|
||||
intent.putExtra(EXTRA_HAS_MULTIPLE_USERS, hasMultipleUsers());
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
protected boolean isFirstRun() {
|
||||
return mIsFirstRun;
|
||||
}
|
||||
|
||||
public boolean hasMultipleUsers() {
|
||||
return ((UserManager) getSystemService(USER_SERVICE)).getUsers().size() > 1;
|
||||
}
|
||||
|
||||
protected void logActivityState(String prefix) {
|
||||
protected final void logActivityState(String prefix) {
|
||||
Log.v(TAG, prefix + " isResumed=" + isResumed() + " isFinishing=" +
|
||||
isFinishing() + " isDestroyed=" + isDestroyed());
|
||||
}
|
||||
|
||||
protected static String getRequestName(int requestCode) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
switch (requestCode) {
|
||||
case NEXT_REQUEST:
|
||||
sb.append("NEXT_REQUEST");
|
||||
break;
|
||||
case EMERGENCY_DIAL_ACTIVITY_REQUEST:
|
||||
sb.append("EMERGENCY_DIAL_ACTIVITY_REQUEST");
|
||||
break;
|
||||
case WIFI_ACTIVITY_REQUEST:
|
||||
sb.append("WIFI_ACTIVITY_REQUEST");
|
||||
break;
|
||||
case BLUETOOTH_ACTIVITY_REQUEST:
|
||||
sb.append("BLUETOOTH_ACTIVITY_REQUEST");
|
||||
break;
|
||||
case BIOMETRIC_ACTIVITY_REQUEST:
|
||||
sb.append("BIOMETRIC_ACTIVITY_REQUEST");
|
||||
break;
|
||||
case SCREENLOCK_ACTIVITY_REQUEST:
|
||||
sb.append("SCREENLOCK_ACTIVITY_REQUEST");
|
||||
break;
|
||||
}
|
||||
sb.append("(").append(requestCode).append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected static String getResultName(int requestCode, int resultCode) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
switch (requestCode) {
|
||||
case WIFI_ACTIVITY_REQUEST:
|
||||
switch (resultCode) {
|
||||
case RESULT_OK:
|
||||
sb.append("RESULT_OK");
|
||||
break;
|
||||
case RESULT_CANCELED:
|
||||
sb.append("RESULT_CANCELED");
|
||||
break;
|
||||
case RESULT_SKIP:
|
||||
sb.append("RESULT_WIFI_SKIP");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case BLUETOOTH_ACTIVITY_REQUEST:
|
||||
switch (resultCode) {
|
||||
case RESULT_OK:
|
||||
sb.append("RESULT_OK");
|
||||
break;
|
||||
case RESULT_CANCELED:
|
||||
sb.append("RESULT_CANCELED");
|
||||
break;
|
||||
case RESULT_SKIP:
|
||||
sb.append("RESULT_BLUETOOTH_SKIP");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case BIOMETRIC_ACTIVITY_REQUEST:
|
||||
switch (resultCode) {
|
||||
case RESULT_OK:
|
||||
sb.append("RESULT_OK");
|
||||
break;
|
||||
case RESULT_CANCELED:
|
||||
sb.append("RESULT_CANCELED");
|
||||
break;
|
||||
case RESULT_SKIP:
|
||||
sb.append("RESULT_BIOMETRIC_SKIP");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case SCREENLOCK_ACTIVITY_REQUEST:
|
||||
switch (resultCode) {
|
||||
case RESULT_OK:
|
||||
sb.append("RESULT_OK");
|
||||
break;
|
||||
case RESULT_CANCELED:
|
||||
sb.append("RESULT_CANCELED");
|
||||
break;
|
||||
case RESULT_SKIP:
|
||||
sb.append("RESULT_SCREENLOCK_SKIP");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
switch (resultCode) {
|
||||
case RESULT_OK:
|
||||
sb.append("RESULT_OK");
|
||||
break;
|
||||
case RESULT_CANCELED:
|
||||
sb.append("RESULT_CANCELED");
|
||||
break;
|
||||
case RESULT_SKIP:
|
||||
sb.append("RESULT_SKIP");
|
||||
break;
|
||||
case RESULT_RETRY:
|
||||
sb.append("RESULT_RETRY");
|
||||
break;
|
||||
case RESULT_ACTIVITY_NOT_FOUND:
|
||||
sb.append("RESULT_ACTIVITY_NOT_FOUND");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sb.append("(").append(resultCode).append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void initLayout() {
|
||||
if (getLayoutResId() != -1) {
|
||||
setContentView(getLayoutResId());
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* 2017-2022 The LineageOS Project
|
||||
* 2017-2024 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.
|
||||
@@ -18,17 +18,16 @@
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_BIOMETRIC;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_BIOMETRIC;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
public class BiometricActivity extends WrapperSubBaseActivity {
|
||||
public class BiometricActivity extends SubBaseActivity {
|
||||
|
||||
public static final String TAG = BiometricActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onStartSubactivity() {
|
||||
Intent intent = new Intent(ACTION_SETUP_BIOMETRIC);
|
||||
startSubactivity(intent, REQUEST_CODE_SETUP_BIOMETRIC);
|
||||
startSubactivity(intent);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017-2018,2020 The LineageOS Project
|
||||
* Copyright (C) 2017-2024 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.
|
||||
@@ -17,14 +17,12 @@
|
||||
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_BLUETOOTH;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class BluetoothSetupActivity extends WrapperSubBaseActivity {
|
||||
public class BluetoothSetupActivity extends SubBaseActivity {
|
||||
|
||||
public static final String TAG = BluetoothSetupActivity.class.getSimpleName();
|
||||
|
||||
@@ -40,18 +38,11 @@ public class BluetoothSetupActivity extends WrapperSubBaseActivity {
|
||||
intent.setComponent(SetupWizardUtils.sTvAddAccessorySettingsActivity);
|
||||
intent.setAction(ACTION_CONNECT_INPUT);
|
||||
intent.putExtra(INTENT_EXTRA_NO_INPUT_MODE, true);
|
||||
startActivityForResult(intent, REQUEST_CODE_SETUP_BLUETOOTH);
|
||||
startSubactivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error starting bluetooth setup", e);
|
||||
nextAction(RESULT_OK);
|
||||
finishAction(RESULT_OK);
|
||||
SetupWizardUtils.disableComponent(this, BluetoothSetupActivity.class);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSubactivityNextTransition() {
|
||||
nextAction(RESULT_OK);
|
||||
return TRANSITION_ID_SLIDE;
|
||||
}
|
||||
}
|
||||
|
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017-2020 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 static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_CAPTIVE_PORTAL;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Random;
|
||||
|
||||
public class CaptivePortalSetupActivity extends WrapperSubBaseActivity {
|
||||
|
||||
public static final String TAG = CaptivePortalSetupActivity.class.getSimpleName();
|
||||
|
||||
private static final int CAPTIVE_PORTAL_SOCKET_TIMEOUT_MS = 10000;
|
||||
|
||||
private URL mCaptivePortalUrl;
|
||||
|
||||
@Override
|
||||
protected void onStartSubactivity() {
|
||||
ConnectivityManager connectivity = getSystemService(ConnectivityManager.class);
|
||||
|
||||
try {
|
||||
mCaptivePortalUrl = new URL(connectivity.getCaptivePortalServerUrl());
|
||||
} catch (MalformedURLException e) {
|
||||
Log.e(TAG, "Not a valid url" + e);
|
||||
}
|
||||
CheckForCaptivePortalTask
|
||||
.checkForCaptivePortal(mCaptivePortalUrl, this, true);
|
||||
}
|
||||
|
||||
private static class CheckForCaptivePortalTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final URL captivePortalUrl;
|
||||
private final CaptivePortalSetupActivity captivePortalSetupActivity;
|
||||
private static CheckForCaptivePortalTask sTask = null;
|
||||
private String responseToken;
|
||||
|
||||
public CheckForCaptivePortalTask(URL captivePortalUrl,
|
||||
CaptivePortalSetupActivity captivePortalSetupActivity) {
|
||||
this.captivePortalUrl = captivePortalUrl;
|
||||
this.captivePortalSetupActivity = captivePortalSetupActivity;
|
||||
}
|
||||
|
||||
public static void checkForCaptivePortal(URL captivePortalUrl,
|
||||
CaptivePortalSetupActivity captivePortalSetupActivity,
|
||||
boolean cancelAndRecreateIfRunning) {
|
||||
if (sTask == null || sTask.getStatus() == Status.FINISHED) {
|
||||
sTask = new CheckForCaptivePortalTask(captivePortalUrl, captivePortalSetupActivity);
|
||||
sTask.execute();
|
||||
|
||||
} else if (cancelAndRecreateIfRunning) {
|
||||
sTask.cancel(true);
|
||||
sTask = new CheckForCaptivePortalTask(captivePortalUrl, captivePortalSetupActivity);
|
||||
sTask.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
if (captivePortalUrl == null) return false;
|
||||
HttpURLConnection urlConnection = null;
|
||||
try {
|
||||
urlConnection = (HttpURLConnection) captivePortalUrl.openConnection();
|
||||
urlConnection.setInstanceFollowRedirects(false);
|
||||
urlConnection.setConnectTimeout(CAPTIVE_PORTAL_SOCKET_TIMEOUT_MS);
|
||||
urlConnection.setReadTimeout(CAPTIVE_PORTAL_SOCKET_TIMEOUT_MS);
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.getInputStream();
|
||||
// We got a valid response, but not from the real google
|
||||
final int responseCode = urlConnection.getResponseCode();
|
||||
if (responseCode == 408 || responseCode == 504) {
|
||||
// If we timeout here, we'll try and go through captive portal login
|
||||
return true;
|
||||
}
|
||||
return urlConnection.getResponseCode() != 204;
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Captive portal check - probably not a portal: exception "
|
||||
+ e);
|
||||
return false;
|
||||
} finally {
|
||||
if (urlConnection != null) {
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean isPortal) {
|
||||
if (isPortal) {
|
||||
final Context context = captivePortalSetupActivity.getApplicationContext();
|
||||
responseToken = String.valueOf(new Random().nextLong());
|
||||
final Intent intent = new Intent(
|
||||
ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, responseToken);
|
||||
intent.putExtra("status_bar_color",
|
||||
context.getResources().getColor(R.color.primary_dark));
|
||||
intent.putExtra("action_bar_color", context.getResources().getColor(
|
||||
R.color.primary_dark));
|
||||
intent.putExtra("progress_bar_color", context.getResources().getColor(
|
||||
R.color.accent));
|
||||
captivePortalSetupActivity.startSubactivity(intent,
|
||||
REQUEST_CODE_SETUP_CAPTIVE_PORTAL);
|
||||
} else {
|
||||
captivePortalSetupActivity.finishAction(RESULT_OK);
|
||||
captivePortalSetupActivity.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -20,7 +20,6 @@ package org.lineageos.setupwizard;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -28,6 +27,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
@@ -37,6 +37,8 @@ import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.android.settingslib.datetime.ZoneGetter;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
@@ -65,7 +67,7 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements
|
||||
private TextView mDateTextView;
|
||||
private TextView mTimeTextView;
|
||||
|
||||
private final Handler mHandler = new Handler();
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -184,12 +186,12 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements
|
||||
|
||||
private void showDatePicker() {
|
||||
DatePickerFragment datePickerFragment = DatePickerFragment.newInstance();
|
||||
datePickerFragment.show(getFragmentManager(), DatePickerFragment.TAG);
|
||||
datePickerFragment.show(getSupportFragmentManager(), DatePickerFragment.TAG);
|
||||
}
|
||||
|
||||
private void showTimePicker() {
|
||||
TimePickerFragment timePickerFragment = TimePickerFragment.newInstance();
|
||||
timePickerFragment.show(getFragmentManager(), TimePickerFragment.TAG);
|
||||
timePickerFragment.show(getSupportFragmentManager(), TimePickerFragment.TAG);
|
||||
}
|
||||
|
||||
private void updateTimeAndDateDisplay() {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project
|
||||
* Copyright (C) 2021-2024 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.
|
||||
@@ -18,50 +18,21 @@ package org.lineageos.setupwizard;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class DeviceSpecificActivity extends BaseSetupWizardActivity {
|
||||
public class DeviceSpecificActivity extends SubBaseActivity {
|
||||
|
||||
private static final String ACTION_SETUP_DEVICE = "org.lineageos.settings.device.SUW_SETTINGS";
|
||||
private static final int REQUEST_CODE_SETUP_DEVICE = 90000;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
onStartSubactivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CODE_SETUP_DEVICE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
nextAction(RESULT_OK);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
} else if (resultCode == RESULT_CANCELED) {
|
||||
onStartSubactivity();
|
||||
applyBackwardTransition(TRANSITION_ID_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.setup_device_specific;
|
||||
}
|
||||
|
||||
private void onStartSubactivity() {
|
||||
protected void onStartSubactivity() {
|
||||
Intent intent = new Intent(ACTION_SETUP_DEVICE);
|
||||
ComponentName name = intent.resolveActivity(getPackageManager());
|
||||
if (name != null) {
|
||||
applyForwardTransition(TRANSITION_ID_SLIDE);
|
||||
startActivityForResult(intent, REQUEST_CODE_SETUP_DEVICE);
|
||||
startSubactivity(intent);
|
||||
} else {
|
||||
SetupWizardUtils.disableComponent(this, DeviceSpecificActivity.class);
|
||||
nextAction(RESULT_OK);
|
||||
finish();
|
||||
finishAction(RESULT_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,31 +31,28 @@ import static org.lineageos.setupwizard.SetupWizardApp.UPDATE_RECOVERY_PROP;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.Activity;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
public class FinishActivity extends BaseSetupWizardActivity {
|
||||
|
||||
public static final String TAG = FinishActivity.class.getSimpleName();
|
||||
@@ -64,7 +61,7 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
||||
|
||||
private SetupWizardApp mSetupWizardApp;
|
||||
|
||||
private final Handler mHandler = new Handler();
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private volatile boolean mIsFinishing = false;
|
||||
|
||||
@@ -79,26 +76,11 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
||||
setNextText(R.string.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (!mIsFinishing) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.finish_activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
if (!isResumed() || mResultCode != RESULT_CANCELED) {
|
||||
overridePendingTransition(R.anim.translucent_enter, R.anim.translucent_exit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
applyForwardTransition(TRANSITION_ID_NONE);
|
||||
@@ -123,8 +105,8 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
||||
}
|
||||
|
||||
private void setupRevealImage() {
|
||||
final Point p = new Point();
|
||||
getWindowManager().getDefaultDisplay().getRealSize(p);
|
||||
Rect rect = getWindowManager().getCurrentWindowMetrics().getBounds();
|
||||
final Point p = new Point(rect.width(), rect.height());
|
||||
final WallpaperManager wallpaperManager =
|
||||
WallpaperManager.getInstance(this);
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
@@ -160,12 +142,7 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
completeSetup();
|
||||
}
|
||||
});
|
||||
mHandler.post(() -> completeSetup());
|
||||
}
|
||||
});
|
||||
anim.start();
|
||||
@@ -181,9 +158,7 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
finishAllAppTasks();
|
||||
SetupWizardUtils.enableStatusBar();
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(),
|
||||
Activity.RESULT_OK);
|
||||
startActivityForResult(intent, NEXT_REQUEST);
|
||||
finishAction(RESULT_OK);
|
||||
}
|
||||
|
||||
private static void handleEnableMetrics(SetupWizardApp setupWizardApp) {
|
||||
@@ -227,8 +202,6 @@ public class FinishActivity extends BaseSetupWizardActivity {
|
||||
}
|
||||
|
||||
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
final boolean virtualKeysEnabled = LineageSettings.System.getIntForUser(
|
||||
context.getContentResolver(), LineageSettings.System.FORCE_SHOW_NAVBAR, 0,
|
||||
UserHandle.USER_CURRENT) != 0;
|
||||
|
@@ -17,16 +17,16 @@
|
||||
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static androidx.appcompat.app.AppCompatDelegate.setApplicationLocales;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
@@ -35,6 +35,8 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.os.LocaleListCompat;
|
||||
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.internal.telephony.util.LocaleUtils;
|
||||
|
||||
@@ -44,6 +46,8 @@ import org.lineageos.setupwizard.widget.LocalePicker;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
|
||||
@@ -53,8 +57,8 @@ public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
private Locale mCurrentLocale;
|
||||
private int[] mAdapterIndices;
|
||||
private LocalePicker mLanguagePicker;
|
||||
private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
|
||||
private final Handler mHandler = new Handler();
|
||||
private ExecutorService mFetchUpdateSimLocaleTask;
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
private boolean mPendingLocaleUpdate;
|
||||
private boolean mPaused = true;
|
||||
|
||||
@@ -62,7 +66,7 @@ public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
public void run() {
|
||||
if (mCurrentLocale != null) {
|
||||
mLanguagePicker.setEnabled(false);
|
||||
com.android.internal.app.LocalePicker.updateLocale(mCurrentLocale);
|
||||
setApplicationLocales(LocaleListCompat.create(mCurrentLocale));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -170,12 +174,6 @@ public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
|
||||
private void onLocaleChanged(Locale paramLocale) {
|
||||
mLanguagePicker.setEnabled(true);
|
||||
Resources localResources = getResources();
|
||||
Configuration localConfiguration1 = localResources.getConfiguration();
|
||||
Configuration localConfiguration2 = new Configuration();
|
||||
localConfiguration2.locale = paramLocale;
|
||||
localResources.updateConfiguration(localConfiguration2, null);
|
||||
localResources.updateConfiguration(localConfiguration1, null);
|
||||
mHandler.removeCallbacks(mUpdateLocale);
|
||||
mCurrentLocale = paramLocale;
|
||||
mHandler.postDelayed(mUpdateLocale, 1000);
|
||||
@@ -190,16 +188,11 @@ public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
return;
|
||||
}
|
||||
if (mFetchUpdateSimLocaleTask != null) {
|
||||
mFetchUpdateSimLocaleTask.cancel(true);
|
||||
mFetchUpdateSimLocaleTask.shutdown();
|
||||
}
|
||||
mFetchUpdateSimLocaleTask = new FetchUpdateSimLocaleTask();
|
||||
mFetchUpdateSimLocaleTask.execute();
|
||||
}
|
||||
|
||||
private class FetchUpdateSimLocaleTask extends AsyncTask<Void, Void, Locale> {
|
||||
@Override
|
||||
protected Locale doInBackground(Void... params) {
|
||||
Locale locale = null;
|
||||
mFetchUpdateSimLocaleTask = Executors.newSingleThreadExecutor();
|
||||
mFetchUpdateSimLocaleTask.execute(() -> {
|
||||
Locale locale;
|
||||
Activity activity = LocaleActivity.this;
|
||||
if (!activity.isFinishing() || !activity.isDestroyed()) {
|
||||
// If the sim is currently pin locked, return
|
||||
@@ -208,19 +201,19 @@ public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
int state = telephonyManager.getSimState();
|
||||
if (state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
|
||||
state == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
final SubscriptionManager subscriptionManager =
|
||||
SubscriptionManager.from(activity);
|
||||
activity.getSystemService(SubscriptionManager.class);
|
||||
List<SubscriptionInfo> activeSubs =
|
||||
subscriptionManager.getActiveSubscriptionInfoList();
|
||||
if (activeSubs == null || activeSubs.isEmpty()) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch locale for active sim's MCC
|
||||
int mcc = activeSubs.get(0).getMcc();
|
||||
int mcc = Integer.parseInt(activeSubs.get(0).getMccString());
|
||||
locale = LocaleUtils.getLocaleFromMcc(activity, mcc, null);
|
||||
|
||||
// If that fails, fall back to preferred languages reported
|
||||
@@ -232,22 +225,20 @@ public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
|
||||
}
|
||||
}
|
||||
Locale finalLocale = locale;
|
||||
mHandler.post(() -> {
|
||||
if (finalLocale != null && !finalLocale.equals(mCurrentLocale)) {
|
||||
if (!((SetupWizardApp) getApplication()).ignoreSimLocale()
|
||||
&& !isDestroyed()) {
|
||||
String label = getString(R.string.sim_locale_changed,
|
||||
finalLocale.getDisplayName());
|
||||
Toast.makeText(LocaleActivity.this, label, Toast.LENGTH_SHORT).show();
|
||||
onLocaleChanged(finalLocale);
|
||||
((SetupWizardApp) getApplication()).setIgnoreSimLocale(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Locale simLocale) {
|
||||
if (simLocale != null && !simLocale.equals(mCurrentLocale)) {
|
||||
if (!((SetupWizardApp) getApplication()).ignoreSimLocale() && !isDestroyed()) {
|
||||
String label = getString(R.string.sim_locale_changed,
|
||||
simLocale.getDisplayName());
|
||||
Toast.makeText(LocaleActivity.this, label, Toast.LENGTH_SHORT).show();
|
||||
onLocaleChanged(simLocale);
|
||||
((SetupWizardApp) getApplication()).setIgnoreSimLocale(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ public class LocationSettingsActivity extends BaseSetupWizardActivity {
|
||||
mLocationAccess.setChecked(!mLocationAccess.isChecked());
|
||||
});
|
||||
View locationAgpsAccessView = findViewById(R.id.location_agps);
|
||||
if (mUserManager.isPrimaryUser()) {
|
||||
if (mUserManager.isMainUser()) {
|
||||
locationAgpsAccessView.setOnClickListener(v -> {
|
||||
mLocationAgpsAccess.setChecked(!mLocationAgpsAccess.isChecked());
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 The LineageOS Project
|
||||
* Copyright (C) 2022-2024 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.
|
||||
@@ -28,8 +28,6 @@ import static org.lineageos.setupwizard.SetupWizardApp.NAVIGATION_OPTION_KEY;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
@@ -39,7 +37,6 @@ import android.widget.RadioGroup;
|
||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
||||
|
||||
import com.airbnb.lottie.LottieAnimationView;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import lineageos.providers.LineageSettings;
|
||||
|
||||
@@ -99,8 +96,7 @@ public class NavigationSettingsActivity extends BaseSetupWizardActivity {
|
||||
if (!navBarEnabled && hasHomeKey || available <= 1) {
|
||||
mSetupWizardApp.getSettingsBundle().putString(NAVIGATION_OPTION_KEY,
|
||||
NAV_BAR_MODE_3BUTTON_OVERLAY);
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
|
||||
finishAction(RESULT_OK, intent);
|
||||
finishAction(RESULT_OK);
|
||||
}
|
||||
|
||||
final LottieAnimationView navigationIllustration =
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017-2021 The LineageOS Project
|
||||
* Copyright (C) 2017-2024 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.
|
||||
@@ -23,13 +23,12 @@ import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_PREFS_SET_BACK_TEXT
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_PREFS_SHOW_BUTTON_BAR;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_PREFS_SHOW_SKIP;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_PREFS_SHOW_SKIP_TV;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_NETWORK;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class NetworkSetupActivity extends WrapperSubBaseActivity {
|
||||
public class NetworkSetupActivity extends SubBaseActivity {
|
||||
|
||||
public static final String TAG = NetworkSetupActivity.class.getSimpleName();
|
||||
|
||||
@@ -47,6 +46,6 @@ public class NetworkSetupActivity extends WrapperSubBaseActivity {
|
||||
intent.putExtra(EXTRA_PREFS_SHOW_SKIP_TV, true);
|
||||
intent.putExtra(EXTRA_PREFS_SET_BACK_TEXT, (String) null);
|
||||
intent.putExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, true);
|
||||
startSubactivity(intent, REQUEST_CODE_SETUP_NETWORK);
|
||||
startSubactivity(intent);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* 2017-2022 The LineageOS Project
|
||||
* 2017-2024 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.
|
||||
@@ -18,17 +18,16 @@
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_LOCKSCREEN;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_LOCKSCREEN;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
public class ScreenLockActivity extends WrapperSubBaseActivity {
|
||||
public class ScreenLockActivity extends SubBaseActivity {
|
||||
|
||||
public static final String TAG = ScreenLockActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
protected void onStartSubactivity() {
|
||||
Intent intent = new Intent(ACTION_SETUP_LOCKSCREEN);
|
||||
startSubactivity(intent, REQUEST_CODE_SETUP_LOCKSCREEN);
|
||||
startSubactivity(intent);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017,2019 The LineageOS Project
|
||||
* Copyright (C) 2017-2024 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.
|
||||
@@ -29,12 +29,14 @@ import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
import org.lineageos.setupwizard.wizardmanager.WizardManager;
|
||||
|
||||
public class SetupWizardActivity extends BaseSetupWizardActivity {
|
||||
public class SetupWizardActivity extends AppCompatActivity {
|
||||
private static final String TAG = SetupWizardActivity.class.getSimpleName();
|
||||
|
||||
@Override
|
||||
@@ -55,7 +57,6 @@ public class SetupWizardActivity extends BaseSetupWizardActivity {
|
||||
SetupWizardUtils.finishSetupWizard(this);
|
||||
finish();
|
||||
} else {
|
||||
onSetupStart();
|
||||
SetupWizardUtils.enableComponent(this, WizardManager.class);
|
||||
Intent intent = new Intent(ACTION_LOAD);
|
||||
if (SetupWizardUtils.isOwner()) {
|
||||
|
@@ -21,9 +21,9 @@ import android.app.Application;
|
||||
import android.app.StatusBarManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import org.lineageos.setupwizard.util.NetworkMonitor;
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class SetupWizardApp extends Application {
|
||||
@@ -36,7 +36,6 @@ public class SetupWizardApp extends Application {
|
||||
"android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW";
|
||||
public static final String ACTION_SETUP_COMPLETE =
|
||||
"org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE";
|
||||
public static final String ACTION_FINISHED = "org.lineageos.setupwizard.SETUP_FINISHED";
|
||||
public static final String ACTION_SETUP_NETWORK = "android.settings.NETWORK_PROVIDER_SETUP";
|
||||
public static final String ACTION_SETUP_BIOMETRIC = "android.settings.BIOMETRIC_ENROLL";
|
||||
public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN";
|
||||
@@ -57,7 +56,6 @@ public class SetupWizardApp extends Application {
|
||||
public static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
|
||||
public static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect";
|
||||
|
||||
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
|
||||
public static final String KEY_SEND_METRICS = "send_metrics";
|
||||
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
|
||||
public static final String ENABLE_RECOVERY_UPDATE = "enable_recovery_update";
|
||||
@@ -65,13 +63,6 @@ public class SetupWizardApp extends Application {
|
||||
|
||||
public static final String NAVIGATION_OPTION_KEY = "navigation_option";
|
||||
|
||||
public static final int REQUEST_CODE_SETUP_NETWORK = 0;
|
||||
public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL = 4;
|
||||
public static final int REQUEST_CODE_SETUP_BLUETOOTH = 5;
|
||||
public static final int REQUEST_CODE_SETUP_BIOMETRIC = 7;
|
||||
public static final int REQUEST_CODE_SETUP_LOCKSCREEN = 9;
|
||||
public static final int REQUEST_CODE_RESTORE = 10;
|
||||
|
||||
public static final int RADIO_READY_TIMEOUT = 10 * 1000;
|
||||
|
||||
private static StatusBarManager sStatusBarManager;
|
||||
@@ -80,7 +71,7 @@ public class SetupWizardApp extends Application {
|
||||
private boolean mIgnoreSimLocale = false;
|
||||
|
||||
private final Bundle mSettingsBundle = new Bundle();
|
||||
private final Handler mHandler = new Handler();
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private final Runnable mRadioTimeoutRunnable = () -> mIsRadioReady = true;
|
||||
|
||||
@@ -90,7 +81,6 @@ public class SetupWizardApp extends Application {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onCreate()");
|
||||
}
|
||||
NetworkMonitor.initInstance(this);
|
||||
SetupWizardUtils.disableComponentsForMissingFeatures(this);
|
||||
if (SetupWizardUtils.isOwner()) {
|
||||
SetupWizardUtils.setMobileDataEnabled(this, false);
|
||||
|
@@ -26,6 +26,10 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.OutOfQuotaPolicy;
|
||||
import androidx.work.WorkManager;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class SetupWizardExitActivity extends BaseSetupWizardActivity {
|
||||
@@ -38,17 +42,14 @@ public class SetupWizardExitActivity extends BaseSetupWizardActivity {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onCreate savedInstanceState=" + savedInstanceState);
|
||||
}
|
||||
if (SetupWizardUtils.isOwner()) {
|
||||
SetupWizardUtils.enableCaptivePortalDetection(this);
|
||||
}
|
||||
if (!SetupWizardUtils.isManagedProfile(this)) {
|
||||
launchHome();
|
||||
}
|
||||
finish();
|
||||
applyForwardTransition(TRANSITION_ID_FADE);
|
||||
Intent i = new Intent();
|
||||
i.setClassName(getPackageName(), SetupWizardExitService.class.getName());
|
||||
startService(i);
|
||||
WorkManager.getInstance(this).enqueue(new OneTimeWorkRequest.Builder(
|
||||
SetupWizardExitWorker.class).setExpedited(
|
||||
OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST).build());
|
||||
}
|
||||
|
||||
private void launchHome() {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The LineageOS Project
|
||||
* Copyright (C) 2024 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.
|
||||
@@ -16,28 +16,28 @@
|
||||
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
|
||||
import android.content.Context;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.IntentService;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.work.CoroutineWorker;
|
||||
import androidx.work.WorkerParameters;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class SetupWizardExitService extends IntentService {
|
||||
import kotlin.coroutines.Continuation;
|
||||
|
||||
private static final String TAG = "SUWExitService";
|
||||
public class SetupWizardExitWorker extends CoroutineWorker {
|
||||
|
||||
public SetupWizardExitService() {
|
||||
super(TAG);
|
||||
public SetupWizardExitWorker(@NonNull Context appContext,
|
||||
@NonNull WorkerParameters params) {
|
||||
super(appContext, params);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected void onHandleIntent(@Nullable Intent intent) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onHandleIntent intent=" + intent.toString());
|
||||
}
|
||||
SetupWizardUtils.finishSetupWizard(this);
|
||||
public Object doWork(@NonNull Continuation<? super Result> continuation) {
|
||||
SetupWizardUtils.finishSetupWizard(getApplicationContext());
|
||||
return Result.success();
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2021 The LineageOS Project
|
||||
* Copyright (C) 2017-2024 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.
|
||||
@@ -30,12 +30,13 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.activity.result.ActivityResult;
|
||||
|
||||
public abstract class SubBaseActivity extends BaseSetupWizardActivity {
|
||||
|
||||
public static final String TAG = SubBaseActivity.class.getSimpleName();
|
||||
|
||||
private boolean mIsSubactivityNotFound = false;
|
||||
private int mRequestCode;
|
||||
|
||||
protected abstract void onStartSubactivity();
|
||||
|
||||
@@ -58,23 +59,19 @@ public abstract class SubBaseActivity extends BaseSetupWizardActivity {
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mIsActivityVisible = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
outState.putInt("request_code", mRequestCode);
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
mRequestCode = savedInstanceState.getInt("request_code");
|
||||
}
|
||||
|
||||
protected void startSubactivity(Intent subactivityIntent, int requestCode) {
|
||||
mRequestCode = requestCode;
|
||||
protected void startSubactivity(Intent subactivityIntent) {
|
||||
Intent intent = getIntent();
|
||||
if (intent.hasExtra(EXTRA_SCRIPT_URI)) {
|
||||
subactivityIntent.putExtra(EXTRA_SCRIPT_URI, intent.getStringExtra(EXTRA_SCRIPT_URI));
|
||||
@@ -84,78 +81,36 @@ public abstract class SubBaseActivity extends BaseSetupWizardActivity {
|
||||
(subactivityIntent.getFlags() & FLAG_ACTIVITY_FORWARD_RESULT) != 0;
|
||||
if (activityForwardsResult) {
|
||||
try {
|
||||
startFirstRunActivity(subactivityIntent);
|
||||
setResultCode(RESULT_OK);
|
||||
finish();
|
||||
startActivity(subactivityIntent);
|
||||
finishAction(RESULT_OK);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.w(TAG, "activity not found; start next screen and finish; intent="
|
||||
+ intent);
|
||||
mIsSubactivityNotFound = true;
|
||||
nextAction(RESULT_ACTIVITY_NOT_FOUND);
|
||||
finish();
|
||||
finishAction(RESULT_ACTIVITY_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
}
|
||||
startFirstRunActivityForResult(subactivityIntent, requestCode);
|
||||
startActivityForResult(subactivityIntent);
|
||||
mIsSubactivityNotFound = false;
|
||||
applyForwardTransition(getSubactivityPreviousTransition());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Bundle extras = null;
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onActivityResult(" + getRequestName(requestCode) +
|
||||
", " + getResultName(requestCode, resultCode));
|
||||
}
|
||||
if (requestCode == mRequestCode) {
|
||||
StringBuilder append = new StringBuilder().append("subactivity result {")
|
||||
.append(getRequestName(requestCode)).append(", ")
|
||||
.append(getResultName(mRequestCode, resultCode)).append(", ");
|
||||
if (data != null) {
|
||||
extras = data.getExtras();
|
||||
}
|
||||
Log.i(TAG, append.append(extras).append("}").toString());
|
||||
onSubactivityResult(requestCode, resultCode, data);
|
||||
} else if (resultCode == RESULT_CANCELED) {
|
||||
onStartSubactivity();
|
||||
mIsGoingBack = true;
|
||||
applyBackwardTransition(getSubactivityNextTransition());
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onSubactivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (LOGV) {
|
||||
StringBuilder append = new StringBuilder().append("onSubactivityResult(")
|
||||
.append(getRequestName(requestCode)).append(", ")
|
||||
.append(getResultName(requestCode, resultCode)).append(", ");
|
||||
Bundle extras = null;
|
||||
if (data != null) {
|
||||
extras = data.getExtras();
|
||||
}
|
||||
Log.v(TAG, append.append(extras).append(")").toString());
|
||||
}
|
||||
protected void onActivityResult(ActivityResult activityResult) {
|
||||
super.onActivityResult(activityResult);
|
||||
int resultCode = activityResult.getResultCode();
|
||||
Intent data = activityResult.getData();
|
||||
if (resultCode != RESULT_CANCELED) {
|
||||
applyForwardTransition(getSubactivityNextTransition());
|
||||
nextAction(resultCode, data);
|
||||
} else if (mIsSubactivityNotFound) {
|
||||
nextAction(RESULT_ACTIVITY_NOT_FOUND);
|
||||
finish();
|
||||
finishAction(RESULT_ACTIVITY_NOT_FOUND);
|
||||
} else if (data != null && data.getBooleanExtra("onBackPressed", false)) {
|
||||
onStartSubactivity();
|
||||
} else {
|
||||
onSubactivityCanceled(data);
|
||||
finishAction(RESULT_CANCELED);
|
||||
}
|
||||
}
|
||||
|
||||
protected int getSubactivityPreviousTransition() {
|
||||
return TRANSITION_ID_SLIDE;
|
||||
}
|
||||
|
||||
protected int getSubactivityNextTransition() {
|
||||
return TRANSITION_ID_SLIDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.setup_loading_page;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 The LineageOS Project
|
||||
* Copyright (C) 2020-2024 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.
|
||||
@@ -45,8 +45,7 @@ public class UpdateRecoveryActivity extends BaseSetupWizardActivity {
|
||||
|
||||
if (!SetupWizardUtils.hasRecoveryUpdater(this)) {
|
||||
Log.v(TAG, "No recovery updater, skipping UpdateRecoveryActivity");
|
||||
nextAction(RESULT_SKIP);
|
||||
finish();
|
||||
finishAction(RESULT_SKIP);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017-2023 The LineageOS Project
|
||||
* Copyright (C) 2017-2024 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.
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
package org.lineageos.setupwizard;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_ACCESSIBILITY_SETTINGS;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_EMERGENCY_DIAL;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@@ -27,29 +31,34 @@ import com.google.android.setupcompat.util.SystemBarHelper;
|
||||
|
||||
import org.lineageos.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class WelcomeActivity extends BaseSetupWizardActivity {
|
||||
public class WelcomeActivity extends SubBaseActivity {
|
||||
|
||||
public static final String TAG = WelcomeActivity.class.getSimpleName();
|
||||
|
||||
private View mRootView;
|
||||
@Override
|
||||
protected void onStartSubactivity() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
onSetupStart();
|
||||
SystemBarHelper.setBackButtonVisible(getWindow(), false);
|
||||
mRootView = findViewById(R.id.setup_wizard_layout);
|
||||
View rootView = findViewById(R.id.setup_wizard_layout);
|
||||
setNextText(R.string.start);
|
||||
Button startButton = findViewById(R.id.start);
|
||||
Button emergButton = findViewById(R.id.emerg_dialer);
|
||||
startButton.setOnClickListener(view -> onNextPressed());
|
||||
findViewById(R.id.launch_accessibility)
|
||||
.setOnClickListener(view -> startAccessibilitySettings());
|
||||
.setOnClickListener(
|
||||
view -> startSubactivity(new Intent(ACTION_ACCESSIBILITY_SETTINGS)));
|
||||
|
||||
FooterButtonStyleUtils.applyPrimaryButtonPartnerResource(this, startButton, true);
|
||||
|
||||
if (SetupWizardUtils.hasTelephony(this)) {
|
||||
setSkipText(R.string.emergency_call);
|
||||
emergButton.setOnClickListener(view -> startEmergencyDialer());
|
||||
emergButton.setOnClickListener(
|
||||
view -> startSubactivity(new Intent(ACTION_EMERGENCY_DIAL)));
|
||||
|
||||
FooterButtonStyleUtils.applySecondaryButtonPartnerResource(this, emergButton, true);
|
||||
} else {
|
||||
@@ -61,12 +70,13 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
|
||||
getString(R.string.os_name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.welcome_activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTitleResId() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.Intent;
|
||||
|
||||
public abstract class WrapperSubBaseActivity extends SubBaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onSubactivityCanceled(Intent data) {
|
||||
super.onSubactivityCanceled(data);
|
||||
|
||||
// As the subactivity we're wrapping finishes, we finish too
|
||||
applyBackwardTransition(getSubactivityPreviousTransition());
|
||||
finishAction(RESULT_CANCELED, data);
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 The Calyx Institute
|
||||
* 2020-2022 The LineageOS Project
|
||||
* 2020-2024 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.
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.lineageos.setupwizard.backup;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_RESTORE_FROM_BACKUP;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_RESTORE;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -62,7 +61,7 @@ public class RestoreIntroActivity extends SubBaseActivity {
|
||||
|
||||
private void launchRestore() {
|
||||
Intent intent = new Intent(ACTION_RESTORE_FROM_BACKUP);
|
||||
startSubactivity(intent, REQUEST_CODE_RESTORE);
|
||||
startSubactivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.util;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
public class NetworkMonitor {
|
||||
|
||||
public static final String TAG = NetworkMonitor.class.getSimpleName();
|
||||
|
||||
private static NetworkMonitor sInstance;
|
||||
|
||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, intent.toString());
|
||||
}
|
||||
NetworkMonitor.this.updateNetworkStatus(context);
|
||||
}
|
||||
};
|
||||
private Context mContext = null;
|
||||
private boolean mNetworkConnected = false;
|
||||
private NetworkInfo mNetworkInfo = null;
|
||||
|
||||
public static void initInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new NetworkMonitor(context.getApplicationContext());
|
||||
}
|
||||
}
|
||||
|
||||
public static NetworkMonitor getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public NetworkMonitor(Context context) {
|
||||
mContext = context;
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "Starting NetworkMonitor");
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
|
||||
context.registerReceiver(mBroadcastReceiver, filter);
|
||||
new Handler().post(new Runnable() {
|
||||
public void run() {
|
||||
updateNetworkStatus(mContext);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isNetworkConnected() {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "isNetworkConnected() returns " + mNetworkConnected);
|
||||
}
|
||||
return mNetworkConnected;
|
||||
}
|
||||
|
||||
public boolean isWifiConnected() {
|
||||
boolean wifiConnected = (mNetworkConnected && mNetworkInfo != null &&
|
||||
mNetworkInfo.getType() == 1);
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "isWifiConnected() returns " + wifiConnected);
|
||||
}
|
||||
return wifiConnected;
|
||||
}
|
||||
|
||||
private void onNetworkConnected(NetworkInfo ni) {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onNetworkConnected()");
|
||||
}
|
||||
mNetworkConnected = true;
|
||||
mNetworkInfo = ni;
|
||||
}
|
||||
|
||||
private void onNetworkDisconnected() {
|
||||
if (LOGV) {
|
||||
Log.v(TAG, "onNetworkDisconnected()");
|
||||
}
|
||||
mNetworkConnected = false;
|
||||
mNetworkInfo = null;
|
||||
}
|
||||
|
||||
private boolean updateNetworkStatus(Context context) {
|
||||
ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
|
||||
if (cm != null) {
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
boolean isConnected = ni != null && ni.isConnected();
|
||||
if (isConnected && !mNetworkConnected) {
|
||||
onNetworkConnected(ni);
|
||||
} else if (!isConnected && mNetworkConnected) {
|
||||
onNetworkDisconnected();
|
||||
}
|
||||
}
|
||||
return mNetworkConnected;
|
||||
}
|
||||
}
|
@@ -31,7 +31,6 @@ import static android.telephony.TelephonyManager.SIM_STATE_ABSENT;
|
||||
import static com.android.internal.telephony.PhoneConstants.LTE_ON_CDMA_TRUE;
|
||||
import static com.android.internal.telephony.PhoneConstants.LTE_ON_CDMA_UNKNOWN;
|
||||
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.KEY_DETECT_CAPTIVE_PORTAL;
|
||||
import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
|
||||
|
||||
import android.app.StatusBarManager;
|
||||
@@ -47,7 +46,7 @@ import android.content.pm.ServiceInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.biometrics.BiometricManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Binder;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -96,14 +95,11 @@ public class SetupWizardUtils {
|
||||
TelephonyManager tm = context.getSystemService(TelephonyManager.class);
|
||||
if (tm.isMultiSimEnabled()) {
|
||||
int subId = SubscriptionManager.getDefaultDataSubscriptionId();
|
||||
int phoneId = SubscriptionManager.from(context).getPhoneId(subId);
|
||||
android.provider.Settings.Global.putInt(context.getContentResolver(),
|
||||
android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0);
|
||||
tm.createForSubscriptionId(subId).setDataEnabled(enabled);
|
||||
int phoneId = SubscriptionManager.getPhoneId(subId);
|
||||
tm.createForSubscriptionId(subId).setDataEnabledForReason(
|
||||
TelephonyManager.DATA_ENABLED_REASON_USER, enabled);
|
||||
} else {
|
||||
android.provider.Settings.Global.putInt(context.getContentResolver(),
|
||||
android.provider.Settings.Global.MOBILE_DATA, enabled ? 1 : 0);
|
||||
tm.setDataEnabled(enabled);
|
||||
tm.setDataEnabledForReason(TelephonyManager.DATA_ENABLED_REASON_USER, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,14 +151,6 @@ public class SetupWizardUtils {
|
||||
return context.getSystemService(UserManager.class).isManagedProfile();
|
||||
}
|
||||
|
||||
public static void disableCaptivePortalDetection(Context context) {
|
||||
Settings.Global.putInt(context.getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 0);
|
||||
}
|
||||
|
||||
public static void enableCaptivePortalDetection(Context context) {
|
||||
Settings.Global.putInt(context.getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 1);
|
||||
}
|
||||
|
||||
public static StatusBarManager disableStatusBar(Context context) {
|
||||
StatusBarManager statusBarManager = context.getSystemService(StatusBarManager.class);
|
||||
if (statusBarManager != null) {
|
||||
@@ -232,9 +220,6 @@ public class SetupWizardUtils {
|
||||
|
||||
disableComponent(context, WizardManager.class);
|
||||
disableHome(context);
|
||||
context.sendStickyBroadcastAsUser(
|
||||
new Intent(SetupWizardApp.ACTION_FINISHED),
|
||||
Binder.getCallingUserHandle());
|
||||
disableComponentSets(context, GET_RECEIVERS | GET_SERVICES);
|
||||
}
|
||||
|
||||
@@ -245,9 +230,11 @@ public class SetupWizardUtils {
|
||||
public static boolean isEthernetConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.
|
||||
getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
return (cm.getActiveNetworkInfo() != null &&
|
||||
cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_ETHERNET);
|
||||
NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(cm.getActiveNetwork());
|
||||
if (networkCapabilities != null) {
|
||||
return networkCapabilities.hasCapability(NetworkCapabilities.TRANSPORT_ETHERNET);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasLeanback(Context context) {
|
||||
|
@@ -46,6 +46,7 @@ import android.view.ViewConfiguration;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
import android.view.accessibility.AccessibilityNodeProvider;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
@@ -200,7 +201,7 @@ public class LocalePicker extends LinearLayout {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public static final Formatter getTwoDigitFormatter() {
|
||||
public static Formatter getTwoDigitFormatter() {
|
||||
return sTwoDigitFormatter;
|
||||
}
|
||||
|
||||
@@ -1190,7 +1191,7 @@ public class LocalePicker extends LinearLayout {
|
||||
* Shows the soft input for its input text.
|
||||
*/
|
||||
private void showSoftInput() {
|
||||
InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
|
||||
InputMethodManager inputMethodManager = mContext.getSystemService(InputMethodManager.class);
|
||||
if (inputMethodManager != null) {
|
||||
if (mHasSelectorWheel) {
|
||||
mInputText.setVisibility(View.VISIBLE);
|
||||
@@ -1204,7 +1205,7 @@ public class LocalePicker extends LinearLayout {
|
||||
* Hides the soft input if it is active for the input text.
|
||||
*/
|
||||
private void hideSoftInput() {
|
||||
InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
|
||||
InputMethodManager inputMethodManager = mContext.getSystemService(InputMethodManager.class);
|
||||
if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
|
||||
inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
|
||||
if (mHasSelectorWheel) {
|
||||
@@ -2039,11 +2040,11 @@ public class LocalePicker extends LinearLayout {
|
||||
LocalePicker.this.removeCallbacks(this);
|
||||
if (mIncrementVirtualButtonPressed) {
|
||||
mIncrementVirtualButtonPressed = false;
|
||||
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
|
||||
invalidate();
|
||||
}
|
||||
mDecrementVirtualButtonPressed = false;
|
||||
if (mDecrementVirtualButtonPressed) {
|
||||
invalidate(0, 0, mRight, mTopSelectionDividerTop);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2068,12 +2069,12 @@ public class LocalePicker extends LinearLayout {
|
||||
switch (mManagedButton) {
|
||||
case BUTTON_INCREMENT: {
|
||||
mIncrementVirtualButtonPressed = true;
|
||||
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
|
||||
invalidate();
|
||||
}
|
||||
break;
|
||||
case BUTTON_DECREMENT: {
|
||||
mDecrementVirtualButtonPressed = true;
|
||||
invalidate(0, 0, mRight, mTopSelectionDividerTop);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2086,7 +2087,7 @@ public class LocalePicker extends LinearLayout {
|
||||
ViewConfiguration.getPressedStateDuration());
|
||||
}
|
||||
mIncrementVirtualButtonPressed ^= true;
|
||||
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
|
||||
invalidate();
|
||||
}
|
||||
break;
|
||||
case BUTTON_DECREMENT: {
|
||||
@@ -2095,7 +2096,7 @@ public class LocalePicker extends LinearLayout {
|
||||
ViewConfiguration.getPressedStateDuration());
|
||||
}
|
||||
mDecrementVirtualButtonPressed ^= true;
|
||||
invalidate(0, 0, mRight, mTopSelectionDividerTop);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2340,7 +2341,7 @@ public class LocalePicker extends LinearLayout {
|
||||
mAccessibilityFocusedView = virtualViewId;
|
||||
sendAccessibilityEventForVirtualView(virtualViewId,
|
||||
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
|
||||
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2350,7 +2351,7 @@ public class LocalePicker extends LinearLayout {
|
||||
mAccessibilityFocusedView = UNDEFINED;
|
||||
sendAccessibilityEventForVirtualView(virtualViewId,
|
||||
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
|
||||
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2376,7 +2377,7 @@ public class LocalePicker extends LinearLayout {
|
||||
mAccessibilityFocusedView = virtualViewId;
|
||||
sendAccessibilityEventForVirtualView(virtualViewId,
|
||||
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
|
||||
invalidate(0, 0, mRight, mTopSelectionDividerTop);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2386,7 +2387,7 @@ public class LocalePicker extends LinearLayout {
|
||||
mAccessibilityFocusedView = UNDEFINED;
|
||||
sendAccessibilityEventForVirtualView(virtualViewId,
|
||||
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED);
|
||||
invalidate(0, 0, mRight, mTopSelectionDividerTop);
|
||||
invalidate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2423,7 +2424,7 @@ public class LocalePicker extends LinearLayout {
|
||||
|
||||
private void sendAccessibilityEventForVirtualText(int eventType) {
|
||||
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
|
||||
AccessibilityEvent event = new AccessibilityEvent(eventType);
|
||||
mInputText.onInitializeAccessibilityEvent(event);
|
||||
mInputText.onPopulateAccessibilityEvent(event);
|
||||
event.setSource(LocalePicker.this, VIRTUAL_VIEW_ID_INPUT);
|
||||
@@ -2434,7 +2435,7 @@ public class LocalePicker extends LinearLayout {
|
||||
private void sendAccessibilityEventForVirtualButton(int virtualViewId, int eventType,
|
||||
String text) {
|
||||
if (AccessibilityManager.getInstance(mContext).isEnabled()) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
|
||||
AccessibilityEvent event = new AccessibilityEvent(eventType);
|
||||
event.setClassName(Button.class.getName());
|
||||
event.setPackageName(mContext.getPackageName());
|
||||
event.getText().add(text);
|
||||
@@ -2485,15 +2486,14 @@ public class LocalePicker extends LinearLayout {
|
||||
AccessibilityNodeInfo info = mInputText.createAccessibilityNodeInfo();
|
||||
info.setSource(LocalePicker.this, VIRTUAL_VIEW_ID_INPUT);
|
||||
if (mAccessibilityFocusedView != VIRTUAL_VIEW_ID_INPUT) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
|
||||
info.addAction(AccessibilityAction.ACTION_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
if (mAccessibilityFocusedView == VIRTUAL_VIEW_ID_INPUT) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
info.addAction(AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
Rect boundsInParent = mTempRect;
|
||||
boundsInParent.set(left, top, right, bottom);
|
||||
info.setVisibleToUser(isVisibleToUser(boundsInParent));
|
||||
info.setBoundsInParent(boundsInParent);
|
||||
Rect boundsInScreen = boundsInParent;
|
||||
int[] locationOnScreen = mTempArray;
|
||||
getLocationOnScreen(locationOnScreen);
|
||||
@@ -2504,7 +2504,7 @@ public class LocalePicker extends LinearLayout {
|
||||
|
||||
private AccessibilityNodeInfo createAccessibilityNodeInfoForVirtualButton(int virtualViewId,
|
||||
String text, int left, int top, int right, int bottom) {
|
||||
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
|
||||
AccessibilityNodeInfo info = new AccessibilityNodeInfo();
|
||||
info.setClassName(Button.class.getName());
|
||||
info.setPackageName(mContext.getPackageName());
|
||||
info.setSource(LocalePicker.this, virtualViewId);
|
||||
@@ -2516,7 +2516,6 @@ public class LocalePicker extends LinearLayout {
|
||||
Rect boundsInParent = mTempRect;
|
||||
boundsInParent.set(left, top, right, bottom);
|
||||
info.setVisibleToUser(isVisibleToUser(boundsInParent));
|
||||
info.setBoundsInParent(boundsInParent);
|
||||
Rect boundsInScreen = boundsInParent;
|
||||
int[] locationOnScreen = mTempArray;
|
||||
getLocationOnScreen(locationOnScreen);
|
||||
@@ -2524,13 +2523,13 @@ public class LocalePicker extends LinearLayout {
|
||||
info.setBoundsInScreen(boundsInScreen);
|
||||
|
||||
if (mAccessibilityFocusedView != virtualViewId) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
|
||||
info.addAction(AccessibilityAction.ACTION_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
if (mAccessibilityFocusedView == virtualViewId) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
info.addAction(AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
if (LocalePicker.this.isEnabled()) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
|
||||
info.addAction(AccessibilityAction.ACTION_CLICK);
|
||||
}
|
||||
|
||||
return info;
|
||||
@@ -2538,7 +2537,7 @@ public class LocalePicker extends LinearLayout {
|
||||
|
||||
private AccessibilityNodeInfo createAccessibilityNodeInfoForNumberPicker(int left, int top,
|
||||
int right, int bottom) {
|
||||
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
|
||||
AccessibilityNodeInfo info = new AccessibilityNodeInfo();
|
||||
info.setClassName(LocalePicker.class.getName());
|
||||
info.setPackageName(mContext.getPackageName());
|
||||
info.setSource(LocalePicker.this);
|
||||
@@ -2561,7 +2560,6 @@ public class LocalePicker extends LinearLayout {
|
||||
Rect boundsInParent = mTempRect;
|
||||
boundsInParent.set(left, top, right, bottom);
|
||||
boundsInParent.scale(applicationScale);
|
||||
info.setBoundsInParent(boundsInParent);
|
||||
|
||||
info.setVisibleToUser(isVisibleToUser());
|
||||
|
||||
@@ -2573,17 +2571,17 @@ public class LocalePicker extends LinearLayout {
|
||||
info.setBoundsInScreen(boundsInScreen);
|
||||
|
||||
if (mAccessibilityFocusedView != View.NO_ID) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
|
||||
info.addAction(AccessibilityAction.ACTION_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
if (mAccessibilityFocusedView == View.NO_ID) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
info.addAction(AccessibilityAction.ACTION_CLEAR_ACCESSIBILITY_FOCUS);
|
||||
}
|
||||
if (LocalePicker.this.isEnabled()) {
|
||||
if (getWrapSelectorWheel() || getValue() < getMaxValue()) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
|
||||
info.addAction(AccessibilityAction.ACTION_SCROLL_FORWARD);
|
||||
}
|
||||
if (getWrapSelectorWheel() || getValue() > getMinValue()) {
|
||||
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
|
||||
info.addAction(AccessibilityAction.ACTION_SCROLL_BACKWARD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
* 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.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.core.view.ViewCompat;
|
||||
|
||||
import org.lineageos.setupwizard.R;
|
||||
|
||||
/**
|
||||
* A layout that draws something in the insets passed to
|
||||
* {@link #fitSystemWindows(android.graphics.Rect)},
|
||||
* i.e. the area above UI chrome (status and navigation bars, overlay action bars).
|
||||
*/
|
||||
public class ScrimInsetsFrameLayout extends FrameLayout {
|
||||
private Drawable mInsetForeground;
|
||||
|
||||
private Rect mInsets;
|
||||
private final Rect mTempRect = new Rect();
|
||||
private OnInsetsCallback mOnInsetsCallback;
|
||||
|
||||
public ScrimInsetsFrameLayout(Context context) {
|
||||
super(context);
|
||||
init(context, null, 0);
|
||||
}
|
||||
|
||||
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ScrimInsetsFrameLayout(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyle) {
|
||||
final TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ScrimInsetsView, defStyle, 0);
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground);
|
||||
a.recycle();
|
||||
|
||||
setWillNotDraw(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fitSystemWindows(Rect insets) {
|
||||
mInsets = new Rect(insets);
|
||||
setWillNotDraw(mInsetForeground == null);
|
||||
ViewCompat.postInvalidateOnAnimation(this);
|
||||
if (mOnInsetsCallback != null) {
|
||||
mOnInsetsCallback.onInsetsChanged(insets);
|
||||
}
|
||||
return true; // consume insets
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
if (mInsets != null && mInsetForeground != null) {
|
||||
int sc = canvas.save();
|
||||
canvas.translate(getScrollX(), getScrollY());
|
||||
|
||||
// Top
|
||||
mTempRect.set(0, 0, width, mInsets.top);
|
||||
mInsetForeground.setBounds(mTempRect);
|
||||
mInsetForeground.draw(canvas);
|
||||
|
||||
// Bottom
|
||||
mTempRect.set(0, height - mInsets.bottom, width, height);
|
||||
mInsetForeground.setBounds(mTempRect);
|
||||
mInsetForeground.draw(canvas);
|
||||
|
||||
// Left
|
||||
mTempRect.set(0, mInsets.top, mInsets.left, height - mInsets.bottom);
|
||||
mInsetForeground.setBounds(mTempRect);
|
||||
mInsetForeground.draw(canvas);
|
||||
|
||||
// Right
|
||||
mTempRect.set(width - mInsets.right, mInsets.top, width, height - mInsets.bottom);
|
||||
mInsetForeground.setBounds(mTempRect);
|
||||
mInsetForeground.draw(canvas);
|
||||
|
||||
canvas.restoreToCount(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (mInsetForeground != null) {
|
||||
mInsetForeground.setCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (mInsetForeground != null) {
|
||||
mInsetForeground.setCallback(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the calling container to specify a callback for custom processing when insets change
|
||||
* (i.e. when {@link #fitSystemWindows(android.graphics.Rect)} is called. This is useful for
|
||||
* setting padding on UI elements based on UI chrome insets (e.g. a Google Map or a ListView).
|
||||
* When using with ListView or GridView, remember to set clipToPadding to false.
|
||||
*/
|
||||
public void setOnInsetsCallback(OnInsetsCallback onInsetsCallback) {
|
||||
mOnInsetsCallback = onInsetsCallback;
|
||||
}
|
||||
|
||||
public interface OnInsetsCallback {
|
||||
void onInsetsChanged(Rect insets);
|
||||
}
|
||||
}
|
@@ -114,11 +114,12 @@ public class WizardAction implements Parcelable {
|
||||
dest.writeParcelable(mTransitions, flags);
|
||||
}
|
||||
|
||||
public static final Creator<WizardAction> CREATOR = new Creator<WizardAction>() {
|
||||
public static final Creator<WizardAction> CREATOR = new Creator<>() {
|
||||
public WizardAction createFromParcel(Parcel source) {
|
||||
return new WizardAction(source.readString(),
|
||||
source.readString(),
|
||||
source.readParcelable(WizardTransitions.class.getClassLoader()));
|
||||
source.readParcelable(WizardTransitions.class.getClassLoader(),
|
||||
WizardTransitions.class));
|
||||
}
|
||||
|
||||
public WizardAction[] newArray(int size) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* 2017-2022 The LineageOS Project
|
||||
* 2017-2024 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.
|
||||
@@ -101,6 +101,7 @@ public class WizardManager extends Activity {
|
||||
|
||||
intent.putExtra(EXTRA_SCRIPT_URI, scriptUri);
|
||||
intent.putExtra(EXTRA_ACTION_ID, action.getId());
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
@@ -32,10 +32,10 @@ public class WizardTransitions extends SparseArray<String> implements Parcelable
|
||||
|
||||
private String mDefaultAction;
|
||||
|
||||
public static final Creator<WizardTransitions> CREATOR = new Creator<WizardTransitions>() {
|
||||
public static final Creator<WizardTransitions> CREATOR = new Creator<>() {
|
||||
public WizardTransitions createFromParcel(Parcel source) {
|
||||
WizardTransitions transitions = new WizardTransitions(source);
|
||||
SparseArray<String> actions = source.readSparseArray(null);
|
||||
SparseArray<String> actions = source.readSparseArray(null, String.class);
|
||||
for (int i = 0; i < actions.size(); i++) {
|
||||
transitions.put(actions.keyAt(i), actions.valueAt(i));
|
||||
}
|
||||
|
Reference in New Issue
Block a user