The big code style cleanup

* Format using AOSP code style in Android Studio,
  excluding `Rearrange entries` option.
* Rename static variables to use proper naming scheme
* Remove empty lines

Change-Id: I0d193e35f071bc288050e587b1693844d68865e1
This commit is contained in:
Michael Bestas
2021-08-25 19:13:30 +03:00
committed by Timi Rautamäki
parent ade1361e3b
commit b7b34b96a9
32 changed files with 376 additions and 378 deletions

View File

@@ -18,6 +18,7 @@
package org.lineageos.setupwizard; package org.lineageos.setupwizard;
import static android.view.View.INVISIBLE; 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_ACTIVITY_NOT_FOUND;
import static com.google.android.setupcompat.util.ResultCodes.RESULT_RETRY; import static com.google.android.setupcompat.util.ResultCodes.RESULT_RETRY;
import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP; import static com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP;
@@ -85,7 +86,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
protected boolean mIsActivityVisible = false; protected boolean mIsActivityVisible = false;
protected boolean mIsExiting = false; protected boolean mIsExiting = false;
private boolean mIsFirstRun = true; private final boolean mIsFirstRun = true;
protected boolean mIsGoingBack = false; protected boolean mIsGoingBack = false;
private boolean mIsPrimaryUser; private boolean mIsPrimaryUser;
protected int mResultCode = 0; protected int mResultCode = 0;
@@ -312,7 +313,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
tryEnablingWifi(); tryEnablingWifi();
} }
protected void exitIfSetupComplete() { protected void exitIfSetupComplete() {
if (WizardManagerHelper.isUserSetupComplete(this)) { if (WizardManagerHelper.isUserSetupComplete(this)) {
Log.i(TAG, "Starting activity with USER_SETUP_COMPLETE=true"); Log.i(TAG, "Starting activity with USER_SETUP_COMPLETE=true");
@@ -511,7 +511,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga
startActivityForResult(intent, requestCode); startActivityForResult(intent, requestCode);
} }
protected boolean isFirstRun() { protected boolean isFirstRun() {
return mIsFirstRun; return mIsFirstRun;
} }

View File

@@ -24,7 +24,6 @@ import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_BIOMET
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -39,7 +38,8 @@ public class BiometricActivity extends SubBaseActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
final TextView setupBiometricSummary = (TextView) findViewById(R.id.setup_biometric_summary); final TextView setupBiometricSummary = (TextView) findViewById(
R.id.setup_biometric_summary);
final TextView setupAddBiometric = (TextView) findViewById(R.id.setup_add_biometric); final TextView setupAddBiometric = (TextView) findViewById(R.id.setup_add_biometric);
if (SetupWizardUtils.hasFace(this)) { if (SetupWizardUtils.hasFace(this)) {
setupBiometricSummary.setText(getString(R.string.face_setup_summary)); setupBiometricSummary.setText(getString(R.string.face_setup_summary));

View File

@@ -37,7 +37,7 @@ public class BluetoothSetupActivity extends WrapperSubBaseActivity {
protected void onStartSubactivity() { protected void onStartSubactivity() {
try { try {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setComponent(SetupWizardUtils.mTvAddAccessorySettingsActivity); intent.setComponent(SetupWizardUtils.sTvAddAccessorySettingsActivity);
intent.setAction(ACTION_CONNECT_INPUT); intent.setAction(ACTION_CONNECT_INPUT);
intent.putExtra(INTENT_EXTRA_NO_INPUT_MODE, true); intent.putExtra(INTENT_EXTRA_NO_INPUT_MODE, true);
startActivityForResult(intent, REQUEST_CODE_SETUP_BLUETOOTH); startActivityForResult(intent, REQUEST_CODE_SETUP_BLUETOOTH);

View File

@@ -68,7 +68,8 @@ public class CaptivePortalSetupActivity extends WrapperSubBaseActivity {
} }
public static void checkForCaptivePortal(URL captivePortalUrl, public static void checkForCaptivePortal(URL captivePortalUrl,
CaptivePortalSetupActivity captivePortalSetupActivity, boolean cancelAndRecreateIfRunning) { CaptivePortalSetupActivity captivePortalSetupActivity,
boolean cancelAndRecreateIfRunning) {
if (sTask == null || sTask.getStatus() == Status.FINISHED) { if (sTask == null || sTask.getStatus() == Status.FINISHED) {
sTask = new CheckForCaptivePortalTask(captivePortalUrl, captivePortalSetupActivity); sTask = new CheckForCaptivePortalTask(captivePortalUrl, captivePortalSetupActivity);
sTask.execute(); sTask.execute();
@@ -123,11 +124,16 @@ public class CaptivePortalSetupActivity extends WrapperSubBaseActivity {
intent.putExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL, intent.putExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL,
new CaptivePortal(new ICaptivePortal.Stub() { new CaptivePortal(new ICaptivePortal.Stub() {
@Override @Override
public void appResponse(int response) {} public void appResponse(int response) {
}
@Override @Override
public void logEvent(int eventId, String packageName) {} public void logEvent(int eventId, String packageName) {
}
@Override @Override
public void appRequest(int request) {} public void appRequest(int request) {
}
})); }));
intent.putExtra("status_bar_color", intent.putExtra("status_bar_color",
context.getResources().getColor(R.color.primary_dark)); context.getResources().getColor(R.color.primary_dark));
@@ -135,7 +141,8 @@ public class CaptivePortalSetupActivity extends WrapperSubBaseActivity {
R.color.primary_dark)); R.color.primary_dark));
intent.putExtra("progress_bar_color", context.getResources().getColor( intent.putExtra("progress_bar_color", context.getResources().getColor(
R.color.accent)); R.color.accent));
captivePortalSetupActivity.startSubactivity(intent, REQUEST_CODE_SETUP_CAPTIVE_PORTAL); captivePortalSetupActivity.startSubactivity(intent,
REQUEST_CODE_SETUP_CAPTIVE_PORTAL);
} else { } else {
captivePortalSetupActivity.finishAction(RESULT_OK); captivePortalSetupActivity.finishAction(RESULT_OK);
captivePortalSetupActivity.finish(); captivePortalSetupActivity.finish();

View File

@@ -25,7 +25,6 @@ import android.telephony.ServiceState;
import android.telephony.SignalStrength; import android.telephony.SignalStrength;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
@@ -75,14 +74,14 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity {
} }
}; };
private View.OnClickListener mSetDataSimClickListener = view -> { private final View.OnClickListener mSetDataSimClickListener = view -> {
SubscriptionInfo subInfoRecord = (SubscriptionInfo) view.getTag(); SubscriptionInfo subInfoRecord = (SubscriptionInfo) view.getTag();
if (subInfoRecord != null) { if (subInfoRecord != null) {
changeDataSub(subInfoRecord); changeDataSub(subInfoRecord);
} }
}; };
private PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener = private final PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener =
new PhoneMonitor.SubscriptionStateListener() { new PhoneMonitor.SubscriptionStateListener() {
@Override @Override
public void onServiceStateChanged(int subId, ServiceState serviceState) { public void onServiceStateChanged(int subId, ServiceState serviceState) {
@@ -204,7 +203,6 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity {
} }
updateSignalStrengths(); updateSignalStrengths();
updateCurrentDataSub(); updateCurrentDataSub();
} }
@Override @Override
@@ -317,11 +315,7 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity {
if (mIsAttached) { if (mIsAttached) {
for (int i = 0; i < mCheckBoxes.size(); i++) { for (int i = 0; i < mCheckBoxes.size(); i++) {
int key = mCheckBoxes.keyAt(i); int key = mCheckBoxes.keyAt(i);
if (subInfoRecord.getSimSlotIndex() == key) { mCheckBoxes.get(key).setChecked(subInfoRecord.getSimSlotIndex() == key);
mCheckBoxes.get(key).setChecked(true);
} else {
mCheckBoxes.get(key).setChecked(false);
}
} }
} }
} }

View File

@@ -29,7 +29,6 @@ import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.DatePicker; import android.widget.DatePicker;
@@ -66,10 +65,9 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements
private TextView mDateTextView; private TextView mDateTextView;
private TextView mTimeTextView; private TextView mTimeTextView;
private final Handler mHandler = new Handler(); private final Handler mHandler = new Handler();
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
updateTimeAndDateDisplay(); updateTimeAndDateDisplay();
@@ -293,7 +291,7 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements
public static class TimePickerFragment extends DialogFragment public static class TimePickerFragment extends DialogFragment
implements TimePickerDialog.OnTimeSetListener { implements TimePickerDialog.OnTimeSetListener {
private static String TAG = TimePickerFragment.class.getSimpleName(); private static final String TAG = TimePickerFragment.class.getSimpleName();
public static TimePickerFragment newInstance() { public static TimePickerFragment newInstance() {
TimePickerFragment frag = new TimePickerFragment(); TimePickerFragment frag = new TimePickerFragment();
@@ -315,13 +313,12 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements
calendar.get(Calendar.MINUTE), calendar.get(Calendar.MINUTE),
DateFormat.is24HourFormat(getActivity())); DateFormat.is24HourFormat(getActivity()));
} }
} }
public static class DatePickerFragment extends DialogFragment public static class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener { implements DatePickerDialog.OnDateSetListener {
private static String TAG = DatePickerFragment.class.getSimpleName(); private static final String TAG = DatePickerFragment.class.getSimpleName();
public static DatePickerFragment newInstance() { public static DatePickerFragment newInstance() {
DatePickerFragment frag = new DatePickerFragment(); DatePickerFragment frag = new DatePickerFragment();

View File

@@ -17,6 +17,9 @@
package org.lineageos.setupwizard; package org.lineageos.setupwizard;
import static android.os.Binder.getCallingUserHandle;
import static org.lineageos.setupwizard.Manifest.permission.FINISH_SETUP;
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE; import static org.lineageos.setupwizard.SetupWizardApp.ACTION_SETUP_COMPLETE;
import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS; import static org.lineageos.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE; import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE;
@@ -35,8 +38,8 @@ import android.graphics.Bitmap;
import android.graphics.Point; import android.graphics.Point;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.UserHandle;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.view.View; import android.view.View;
import android.view.ViewAnimationUtils; import android.view.ViewAnimationUtils;
@@ -48,9 +51,6 @@ import org.lineageos.setupwizard.util.EnableAccessibilityController;
import lineageos.providers.LineageSettings; import lineageos.providers.LineageSettings;
import static android.os.Binder.getCallingUserHandle;
import static org.lineageos.setupwizard.Manifest.permission.FINISH_SETUP;
public class FinishActivity extends BaseSetupWizardActivity { public class FinishActivity extends BaseSetupWizardActivity {
public static final String TAG = FinishActivity.class.getSimpleName(); public static final String TAG = FinishActivity.class.getSimpleName();
@@ -65,7 +65,6 @@ public class FinishActivity extends BaseSetupWizardActivity {
private volatile boolean mIsFinishing = false; private volatile boolean mIsFinishing = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -162,10 +161,12 @@ public class FinishActivity extends BaseSetupWizardActivity {
} }
@Override @Override
public void onAnimationCancel(Animator animation) {} public void onAnimationCancel(Animator animation) {
}
@Override @Override
public void onAnimationRepeat(Animator animation) {} public void onAnimationRepeat(Animator animation) {
}
}); });
anim.start(); anim.start();
} }
@@ -191,7 +192,8 @@ public class FinishActivity extends BaseSetupWizardActivity {
if (privacyData != null if (privacyData != null
&& privacyData.containsKey(KEY_SEND_METRICS)) { && privacyData.containsKey(KEY_SEND_METRICS)) {
LineageSettings.Secure.putInt(setupWizardApp.getContentResolver(), LineageSettings.Secure.putInt(setupWizardApp.getContentResolver(),
LineageSettings.Secure.STATS_COLLECTION, privacyData.getBoolean(KEY_SEND_METRICS) LineageSettings.Secure.STATS_COLLECTION,
privacyData.getBoolean(KEY_SEND_METRICS)
? 1 : 0); ? 1 : 0);
} }
} }

View File

@@ -25,7 +25,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle; import android.os.UserHandle;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
@@ -34,16 +33,12 @@ import android.text.Spanned;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.util.Log; import android.util.Log;
import android.view.IWindowManager;
import android.view.View; import android.view.View;
import android.view.WindowManagerGlobal;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
import org.lineageos.setupwizard.R;
import lineageos.hardware.LineageHardwareManager; import lineageos.hardware.LineageHardwareManager;
import lineageos.providers.LineageSettings; import lineageos.providers.LineageSettings;
@@ -60,13 +55,13 @@ public class LineageSettingsActivity extends BaseSetupWizardActivity {
private boolean mSupportsKeyDisabler = false; private boolean mSupportsKeyDisabler = false;
private View.OnClickListener mMetricsClickListener = view -> { private final View.OnClickListener mMetricsClickListener = view -> {
boolean checked = !mMetrics.isChecked(); boolean checked = !mMetrics.isChecked();
mMetrics.setChecked(checked); mMetrics.setChecked(checked);
mSetupWizardApp.getSettingsBundle().putBoolean(KEY_SEND_METRICS, checked); mSetupWizardApp.getSettingsBundle().putBoolean(KEY_SEND_METRICS, checked);
}; };
private View.OnClickListener mNavKeysClickListener = view -> { private final View.OnClickListener mNavKeysClickListener = view -> {
boolean checked = !mNavKeys.isChecked(); boolean checked = !mNavKeys.isChecked();
mNavKeys.setChecked(checked); mNavKeys.setChecked(checked);
mSetupWizardApp.getSettingsBundle().putBoolean(DISABLE_NAV_KEYS, checked); mSetupWizardApp.getSettingsBundle().putBoolean(DISABLE_NAV_KEYS, checked);

View File

@@ -39,7 +39,6 @@ import com.android.internal.telephony.util.LocaleUtils;
import com.google.android.setupcompat.util.SystemBarHelper; import com.google.android.setupcompat.util.SystemBarHelper;
import org.lineageos.setupwizard.R;
import org.lineageos.setupwizard.widget.LocalePicker; import org.lineageos.setupwizard.widget.LocalePicker;
import java.util.List; import java.util.List;
@@ -76,7 +75,6 @@ public class LocaleActivity extends BaseSetupWizardActivity {
} }
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@@ -22,9 +22,6 @@ import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.TextView;
import org.lineageos.setupwizard.util.SetupWizardUtils;
public class LocationSettingsActivity extends BaseSetupWizardActivity { public class LocationSettingsActivity extends BaseSetupWizardActivity {

View File

@@ -64,7 +64,7 @@ public class MobileDataActivity extends BaseSetupWizardActivity {
private final Runnable mDataConnectionReadyRunnable = this::onDataStateReady; private final Runnable mDataConnectionReadyRunnable = this::onDataStateReady;
private PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener = private final PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener =
new PhoneMonitor.SubscriptionStateListener() { new PhoneMonitor.SubscriptionStateListener() {
@Override @Override
public void onServiceStateChanged(int subId, ServiceState serviceState) { public void onServiceStateChanged(int subId, ServiceState serviceState) {
@@ -95,11 +95,13 @@ public class MobileDataActivity extends BaseSetupWizardActivity {
} }
@Override @Override
public void onDefaultDataSubscriptionChanged(int subId) {} public void onDefaultDataSubscriptionChanged(int subId) {
}
@Override @Override
public void onDefaultDataSubscriptionChangeRequested(int currentSubId, public void onDefaultDataSubscriptionChangeRequested(int currentSubId,
int newSubId) {} int newSubId) {
}
@Override @Override
public void onSignalStrengthsChanged(int subId, SignalStrength signalStrength) { public void onSignalStrengthsChanged(int subId, SignalStrength signalStrength) {
@@ -124,7 +126,7 @@ public class MobileDataActivity extends BaseSetupWizardActivity {
} }
}; };
private View.OnClickListener mEnableDataClickListener = new View.OnClickListener() { private final View.OnClickListener mEnableDataClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
boolean checked = !mEnableMobileData.isChecked(); boolean checked = !mEnableMobileData.isChecked();
@@ -153,10 +155,8 @@ public class MobileDataActivity extends BaseSetupWizardActivity {
mNameView = (TextView) findViewById(R.id.enable_data_title); mNameView = (TextView) findViewById(R.id.enable_data_title);
updateDataConnectionStatus(); updateDataConnectionStatus();
updateSignalStrength(); updateSignalStrength();
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();

View File

@@ -1,5 +1,3 @@
package org.lineageos.setupwizard;
/* /*
* Copyright (C) 2016 The CyanogenMod Project * Copyright (C) 2016 The CyanogenMod Project
* *
@@ -16,6 +14,8 @@ package org.lineageos.setupwizard;
* limitations under the License. * limitations under the License.
*/ */
package org.lineageos.setupwizard;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;

View File

@@ -55,7 +55,8 @@ public class SetupWizardActivity extends BaseSetupWizardActivity {
if (isPrimaryUser()) { if (isPrimaryUser()) {
intent.putExtra(EXTRA_SCRIPT_URI, getString(R.string.lineage_wizard_script_uri)); intent.putExtra(EXTRA_SCRIPT_URI, getString(R.string.lineage_wizard_script_uri));
} else { } else {
intent.putExtra(EXTRA_SCRIPT_URI, getString(R.string.lineage_wizard_script_user_uri)); intent.putExtra(EXTRA_SCRIPT_URI,
getString(R.string.lineage_wizard_script_user_uri));
} }
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | FLAG_GRANT_READ_URI_PERMISSION); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent); startActivity(intent);

View File

@@ -17,7 +17,6 @@
package org.lineageos.setupwizard; package org.lineageos.setupwizard;
import android.app.Application; import android.app.Application;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.os.Bundle; import android.os.Bundle;
@@ -31,19 +30,19 @@ import org.lineageos.setupwizard.util.SetupWizardUtils;
public class SetupWizardApp extends Application { public class SetupWizardApp extends Application {
public static final String TAG = SetupWizardApp.class.getSimpleName(); public static final String TAG = SetupWizardApp.class.getSimpleName();
// Leave this off for release // Verbose logging
public static final boolean DEBUG = false;
/* Verbose Logging */
public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE); public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE);
public static final String ACTION_ACCESSIBILITY_SETTINGS = public static final String ACTION_ACCESSIBILITY_SETTINGS =
"android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW"; "android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW";
public static final String ACTION_SETUP_COMPLETE = "org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE"; 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_FINISHED = "org.lineageos.setupwizard.SETUP_FINISHED";
public static final String ACTION_SETUP_WIFI = "android.net.wifi.PICK_WIFI_NETWORK"; public static final String ACTION_SETUP_WIFI = "android.net.wifi.PICK_WIFI_NETWORK";
public static final String ACTION_SETUP_BIOMETRIC = "android.settings.BIOMETRIC_ENROLL"; public static final String ACTION_SETUP_BIOMETRIC = "android.settings.BIOMETRIC_ENROLL";
public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN"; public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN";
public static final String ACTION_RESTORE_FROM_BACKUP = "com.stevesoltys.seedvault.RESTORE_BACKUP"; public static final String ACTION_RESTORE_FROM_BACKUP =
"com.stevesoltys.seedvault.RESTORE_BACKUP";
public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL"; public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";
public static final String ACTION_NEXT = "com.android.wizard.NEXT"; public static final String ACTION_NEXT = "com.android.wizard.NEXT";
public static final String ACTION_LOAD = "com.android.wizard.LOAD"; public static final String ACTION_LOAD = "com.android.wizard.LOAD";

View File

@@ -16,7 +16,6 @@
package org.lineageos.setupwizard; package org.lineageos.setupwizard;
import static org.lineageos.setupwizard.SetupWizardApp.LOGV; import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
import android.annotation.Nullable; import android.annotation.Nullable;

View File

@@ -16,7 +16,6 @@
package org.lineageos.setupwizard; package org.lineageos.setupwizard;
import static android.content.Intent.FLAG_ACTIVITY_FORWARD_RESULT; import static android.content.Intent.FLAG_ACTIVITY_FORWARD_RESULT;
import static com.google.android.setupcompat.util.ResultCodes.RESULT_ACTIVITY_NOT_FOUND; import static com.google.android.setupcompat.util.ResultCodes.RESULT_ACTIVITY_NOT_FOUND;

View File

@@ -28,8 +28,8 @@ import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupcompat.util.WizardManagerHelper;
import org.lineageos.setupwizard.util.SetupWizardUtils;
import org.lineageos.setupwizard.util.SetupWizardUtils;
public class UpdateRecoveryActivity extends BaseSetupWizardActivity { public class UpdateRecoveryActivity extends BaseSetupWizardActivity {

View File

@@ -52,7 +52,8 @@ public class WelcomeActivity extends BaseSetupWizardActivity {
} }
@Override @Override
public void onBackPressed() {} public void onBackPressed() {
}
@Override @Override
protected int getLayoutResId() { protected int getLayoutResId() {

View File

@@ -30,13 +30,12 @@ public class WifiSetupActivity extends WrapperSubBaseActivity {
public static final String TAG = WifiSetupActivity.class.getSimpleName(); public static final String TAG = WifiSetupActivity.class.getSimpleName();
@Override @Override
protected void onStartSubactivity() { protected void onStartSubactivity() {
tryEnablingWifi(); tryEnablingWifi();
Intent intent = new Intent(ACTION_SETUP_WIFI); Intent intent = new Intent(ACTION_SETUP_WIFI);
if (SetupWizardUtils.hasLeanback(this)) { if (SetupWizardUtils.hasLeanback(this)) {
intent.setComponent(SetupWizardUtils.mTvwifisettingsActivity); intent.setComponent(SetupWizardUtils.sTvWifiSetupSettingsActivity);
} }
intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, true); intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, true);
intent.putExtra(EXTRA_PREFS_SET_BACK_TEXT, (String) null); intent.putExtra(EXTRA_PREFS_SET_BACK_TEXT, (String) null);

View File

@@ -17,6 +17,9 @@
package org.lineageos.setupwizard.backup; 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.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
@@ -26,9 +29,6 @@ import org.lineageos.setupwizard.NavigationLayout;
import org.lineageos.setupwizard.R; import org.lineageos.setupwizard.R;
import org.lineageos.setupwizard.SubBaseActivity; import org.lineageos.setupwizard.SubBaseActivity;
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_RESTORE_FROM_BACKUP;
import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_RESTORE;
public class RestoreIntroActivity extends SubBaseActivity { public class RestoreIntroActivity extends SubBaseActivity {
@Override @Override

View File

@@ -61,17 +61,20 @@ public class EnableAccessibilityController {
// TODO: Fix these or remove these // TODO: Fix these or remove these
//String text = mContext.getString(R.string.continue_to_enable_accessibility); //String text = mContext.getString(R.string.continue_to_enable_accessibility);
//mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null); //mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
} break; }
break;
case MESSAGE_SPEAK_ENABLE_CANCELED: { case MESSAGE_SPEAK_ENABLE_CANCELED: {
//String text = mContext.getString(R.string.enable_accessibility_canceled); //String text = mContext.getString(R.string.enable_accessibility_canceled);
//mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null); //mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
} break; }
break;
case MESSAGE_ENABLE_ACCESSIBILITY: { case MESSAGE_ENABLE_ACCESSIBILITY: {
enableAccessibility(); enableAccessibility();
//mTone.play(); //mTone.play();
//mTts.speak(mContext.getString(R.string.accessibility_enabled), //mTts.speak(mContext.getString(R.string.accessibility_enabled),
// TextToSpeech.QUEUE_FLUSH, null); // TextToSpeech.QUEUE_FLUSH, null);
} break; }
break;
} }
} }
}; };
@@ -82,7 +85,6 @@ public class EnableAccessibilityController {
private final IAccessibilityManager mAccessibilityManager = IAccessibilityManager private final IAccessibilityManager mAccessibilityManager = IAccessibilityManager
.Stub.asInterface(ServiceManager.getService("accessibility")); .Stub.asInterface(ServiceManager.getService("accessibility"));
private final Context mContext; private final Context mContext;
private final UserManager mUserManager; private final UserManager mUserManager;
private final TextToSpeech mTts; private final TextToSpeech mTts;

View File

@@ -106,7 +106,7 @@ public class NetworkMonitor {
ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
if (cm != null) { if (cm != null) {
NetworkInfo ni = cm.getActiveNetworkInfo(); NetworkInfo ni = cm.getActiveNetworkInfo();
boolean isConnected = ni != null ? ni.isConnected() : false; boolean isConnected = ni != null && ni.isConnected();
if (isConnected && !mNetworkConnected) { if (isConnected && !mNetworkConnected) {
onNetworkConnected(ni); onNetworkConnected(ni);
} else if (!isConnected && mNetworkConnected) { } else if (!isConnected && mNetworkConnected) {

View File

@@ -77,15 +77,15 @@ public class PhoneMonitor {
public static final String TAG = PhoneMonitor.class.getSimpleName(); public static final String TAG = PhoneMonitor.class.getSimpleName();
private static PhoneMonitor sInstance; private static PhoneMonitor sInstance;
private Context mContext; private final Context mContext;
private TelephonyManager mTelephony; private final TelephonyManager mTelephony;
private SubscriptionManager mSubscriptionManager; private SubscriptionManager mSubscriptionManager;
private ArrayList<SubscriptionStateListener> mListeners = new ArrayList<>(); private final ArrayList<SubscriptionStateListener> mListeners = new ArrayList<>();
private SparseArray<SubscriptionStateTracker> mTrackers = new SparseArray<>(); private final SparseArray<SubscriptionStateTracker> mTrackers = new SparseArray<>();
private int mChangingToDataSubId = -1; private int mChangingToDataSubId = -1;
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { if (intent.getAction().equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
@@ -489,10 +489,15 @@ public class PhoneMonitor {
public interface SubscriptionStateListener { public interface SubscriptionStateListener {
void onServiceStateChanged(int subId, ServiceState serviceState); void onServiceStateChanged(int subId, ServiceState serviceState);
void onDataConnectionStateChanged(int subId, int state, int networkType); void onDataConnectionStateChanged(int subId, int state, int networkType);
void onDefaultDataSubscriptionChanged(int subId); void onDefaultDataSubscriptionChanged(int subId);
void onDefaultDataSubscriptionChangeRequested(int currentSubId, int newSubId); void onDefaultDataSubscriptionChangeRequested(int currentSubId, int newSubId);
void onSignalStrengthsChanged(int subId, SignalStrength signalStrength); void onSignalStrengthsChanged(int subId, SignalStrength signalStrength);
void onSimStateChanged(int subId, int simState); void onSimStateChanged(int subId, int simState);
} }

View File

@@ -34,36 +34,34 @@ import android.content.ComponentName;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ComponentInfo; import android.content.pm.ComponentInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.hardware.face.FaceManager; import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager; import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
import android.os.Binder; import android.os.Binder;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.UserHandle; import android.os.UserHandle;
import android.net.ConnectivityManager;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
import org.lineageos.internal.util.PackageManagerUtils;
import org.lineageos.setupwizard.BiometricActivity;
import org.lineageos.setupwizard.BluetoothSetupActivity; import org.lineageos.setupwizard.BluetoothSetupActivity;
import org.lineageos.setupwizard.ChooseDataSimActivity; import org.lineageos.setupwizard.ChooseDataSimActivity;
import org.lineageos.setupwizard.BiometricActivity;
import org.lineageos.setupwizard.MobileDataActivity; import org.lineageos.setupwizard.MobileDataActivity;
import org.lineageos.setupwizard.SetupWizardApp; import org.lineageos.setupwizard.SetupWizardApp;
import org.lineageos.setupwizard.SimMissingActivity; import org.lineageos.setupwizard.SimMissingActivity;
import org.lineageos.setupwizard.UpdateRecoveryActivity;
import org.lineageos.setupwizard.WifiSetupActivity; import org.lineageos.setupwizard.WifiSetupActivity;
import org.lineageos.setupwizard.wizardmanager.WizardManager; import org.lineageos.setupwizard.wizardmanager.WizardManager;
import org.lineageos.internal.util.PackageManagerUtils;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -81,7 +79,8 @@ public class SetupWizardUtils {
private static final String CONFIG_HIDE_RECOVERY_UPDATE = "config_hideRecoveryUpdate"; private static final String CONFIG_HIDE_RECOVERY_UPDATE = "config_hideRecoveryUpdate";
private static final String PROP_BUILD_DATE = "ro.build.date.utc"; private static final String PROP_BUILD_DATE = "ro.build.date.utc";
private SetupWizardUtils(){} private SetupWizardUtils() {
}
public static SharedPreferences getPrefs(Context context) { public static SharedPreferences getPrefs(Context context) {
return context.getSharedPreferences("SetupWizardPrefs", MODE_PRIVATE); return context.getSharedPreferences("SetupWizardPrefs", MODE_PRIVATE);
@@ -134,7 +133,8 @@ public class SetupWizardUtils {
int res = updaterResources.getIdentifier( int res = updaterResources.getIdentifier(
CONFIG_HIDE_RECOVERY_UPDATE, "bool", UPDATER_PACKAGE); CONFIG_HIDE_RECOVERY_UPDATE, "bool", UPDATER_PACKAGE);
featureHidden = updaterResources.getBoolean(res); featureHidden = updaterResources.getBoolean(res);
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException ignored) { } } catch (PackageManager.NameNotFoundException | Resources.NotFoundException ignored) {
}
return !featureHidden; return !featureHidden;
} }
@@ -148,7 +148,6 @@ public class SetupWizardUtils {
setupWizardApp.setRadioReady(ready); setupWizardApp.setRadioReady(ready);
return ready; return ready;
} }
} }
public static boolean isOwner() { public static boolean isOwner() {
@@ -307,8 +306,7 @@ public class SetupWizardUtils {
if (!isMultiSimDevice() || singleSimInserted()) { if (!isMultiSimDevice() || singleSimInserted()) {
disableComponent(context, ChooseDataSimActivity.class); disableComponent(context, ChooseDataSimActivity.class);
} }
if (!SetupWizardUtils.hasWifi(context) || if (!hasWifi(context) || isEthernetConnected(context)) {
isEthernetConnected(context)) {
disableComponent(context, WifiSetupActivity.class); disableComponent(context, WifiSetupActivity.class);
} }
} }
@@ -327,7 +325,7 @@ public class SetupWizardUtils {
intent.addCategory("android.intent.category.HOME"); intent.addCategory("android.intent.category.HOME");
intent.setPackage(context.getPackageName()); intent.setPackage(context.getPackageName());
ComponentName comp = intent.resolveActivity(context.getPackageManager()); ComponentName comp = intent.resolveActivity(context.getPackageManager());
if (SetupWizardApp.LOGV) { if (LOGV) {
Log.v(TAG, "resolveActivity for intent=" + intent + " returns " + comp); Log.v(TAG, "resolveActivity for intent=" + intent + " returns " + comp);
} }
return comp; return comp;
@@ -358,7 +356,6 @@ public class SetupWizardUtils {
COMPONENT_ENABLED_STATE_DEFAULT); COMPONENT_ENABLED_STATE_DEFAULT);
} }
public static void setComponentEnabledState(Context context, ComponentName componentName, public static void setComponentEnabledState(Context context, ComponentName componentName,
int enabledState) { int enabledState) {
context.getPackageManager().setComponentEnabledSetting(componentName, context.getPackageManager().setComponentEnabledSetting(componentName,
@@ -403,12 +400,11 @@ public class SetupWizardUtils {
return componentNames; return componentNames;
} }
public static final ComponentName sTvWifiSetupSettingsActivity =
public static final ComponentName mTvwifisettingsActivity =
new ComponentName("com.android.tv.settings", new ComponentName("com.android.tv.settings",
"com.android.tv.settings.connectivity.setup.WifiSetupActivity"); "com.android.tv.settings.connectivity.setup.WifiSetupActivity");
public static final ComponentName mTvAddAccessorySettingsActivity = public static final ComponentName sTvAddAccessorySettingsActivity =
new ComponentName("com.android.tv.settings", new ComponentName("com.android.tv.settings",
"com.android.tv.settings.accessories.AddAccessoryActivity"); "com.android.tv.settings.accessories.AddAccessoryActivity");

View File

@@ -16,8 +16,6 @@
package org.lineageos.setupwizard.widget; package org.lineageos.setupwizard.widget;
import org.lineageos.setupwizard.R;
import android.annotation.Widget; import android.annotation.Widget;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@@ -57,17 +55,18 @@ import android.widget.LinearLayout;
import android.widget.Scroller; import android.widget.Scroller;
import android.widget.TextView; import android.widget.TextView;
import libcore.icu.LocaleData;
import org.lineageos.setupwizard.R;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import libcore.icu.LocaleData;
/** /**
* A widget that enables the user to select a number form a predefined range. * A widget that enables the user to select a number form a predefined range. There are two flavors
* There are two flavors of this widget and which one is presented to the user * of this widget and which one is presented to the user depends on the current theme.
* depends on the current theme.
* <ul> * <ul>
* <li> * <li>
* If the current theme is derived from {@link android.R.style#Theme} the widget * If the current theme is derived from {@link android.R.style#Theme} the widget
@@ -152,10 +151,9 @@ public class LocalePicker extends LinearLayout {
private static final int SIZE_UNSPECIFIED = -1; private static final int SIZE_UNSPECIFIED = -1;
/** /**
* Use a custom NumberPicker formatting callback to use two-digit minutes * Use a custom NumberPicker formatting callback to use two-digit minutes strings like "01".
* strings like "01". Keeping a static formatter etc. is the most efficient * Keeping a static formatter etc. is the most efficient way to do this; it avoids creating
* way to do this; it avoids creating temporary objects on every call to * temporary objects on every call to format().
* format().
*/ */
private static class TwoDigitFormatter implements LocalePicker.Formatter { private static class TwoDigitFormatter implements LocalePicker.Formatter {
final StringBuilder mBuilder = new StringBuilder(); final StringBuilder mBuilder = new StringBuilder();
@@ -315,7 +313,8 @@ public class LocalePicker extends LinearLayout {
private final Paint mSelectorWheelPaint; private final Paint mSelectorWheelPaint;
/** /**
* The {@link android.graphics.drawable.Drawable} for pressed virtual (increment/decrement) buttons. * The {@link android.graphics.drawable.Drawable} for pressed virtual (increment/decrement)
* buttons.
*/ */
private final Drawable mVirtualButtonPressedDrawable; private final Drawable mVirtualButtonPressedDrawable;
@@ -355,8 +354,7 @@ public class LocalePicker extends LinearLayout {
private SetSelectionCommand mSetSelectionCommand; private SetSelectionCommand mSetSelectionCommand;
/** /**
* Handle to the reusable command for changing the current value from long * Handle to the reusable command for changing the current value from long press by one.
* press by one.
*/ */
private ChangeCurrentByOneFromLongPressCommand mChangeCurrentByOneFromLongPressCommand; private ChangeCurrentByOneFromLongPressCommand mChangeCurrentByOneFromLongPressCommand;
@@ -388,17 +386,17 @@ public class LocalePicker extends LinearLayout {
/** /**
* @see android.view.ViewConfiguration#getScaledTouchSlop() * @see android.view.ViewConfiguration#getScaledTouchSlop()
*/ */
private int mTouchSlop; private final int mTouchSlop;
/** /**
* @see android.view.ViewConfiguration#getScaledMinimumFlingVelocity() * @see android.view.ViewConfiguration#getScaledMinimumFlingVelocity()
*/ */
private int mMinimumFlingVelocity; private final int mMinimumFlingVelocity;
/** /**
* @see android.view.ViewConfiguration#getScaledMaximumFlingVelocity() * @see android.view.ViewConfiguration#getScaledMaximumFlingVelocity()
*/ */
private int mMaximumFlingVelocity; private final int mMaximumFlingVelocity;
/** /**
* Flag whether the selector should wrap around. * Flag whether the selector should wrap around.
@@ -431,8 +429,8 @@ public class LocalePicker extends LinearLayout {
private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE; private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE;
/** /**
* Flag whether to ignore move events - we ignore such when we show in IME * Flag whether to ignore move events - we ignore such when we show in IME to prevent the
* to prevent the content from scrolling. * content from scrolling.
*/ */
private boolean mIngonreMoveEvents; private boolean mIngonreMoveEvents;
@@ -504,28 +502,26 @@ public class LocalePicker extends LinearLayout {
/** /**
* The view is not scrolling. * The view is not scrolling.
*/ */
public static int SCROLL_STATE_IDLE = 0; int SCROLL_STATE_IDLE = 0;
/** /**
* The user is scrolling using touch, and his finger is still on the screen. * The user is scrolling using touch, and his finger is still on the screen.
*/ */
public static int SCROLL_STATE_TOUCH_SCROLL = 1; int SCROLL_STATE_TOUCH_SCROLL = 1;
/** /**
* The user had previously been scrolling using touch and performed a fling. * The user had previously been scrolling using touch and performed a fling.
*/ */
public static int SCROLL_STATE_FLING = 2; int SCROLL_STATE_FLING = 2;
/** /**
* Callback invoked while the number picker scroll state has changed. * Callback invoked while the number picker scroll state has changed.
* *
* @param view The view whose scroll state is being reported. * @param view The view whose scroll state is being reported.
* @param scrollState The current scroll state. One of * @param scrollState The current scroll state. One of {@link #SCROLL_STATE_IDLE}, {@link
* {@link #SCROLL_STATE_IDLE}, * #SCROLL_STATE_TOUCH_SCROLL} or {@link #SCROLL_STATE_IDLE}.
* {@link #SCROLL_STATE_TOUCH_SCROLL} or
* {@link #SCROLL_STATE_IDLE}.
*/ */
public void onScrollStateChange(LocalePicker view, int scrollState); void onScrollStateChange(LocalePicker view, int scrollState);
} }
/** /**
@@ -539,7 +535,7 @@ public class LocalePicker extends LinearLayout {
* @param value The currently selected value. * @param value The currently selected value.
* @return A formatted string representation. * @return A formatted string representation.
*/ */
public String format(int value); String format(int value);
} }
/** /**
@@ -571,7 +567,8 @@ public class LocalePicker extends LinearLayout {
public LocalePicker(Context context, AttributeSet attrs, int defStyle) { public LocalePicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
sSelectorWheelItemCount = context.getResources().getInteger(R.integer.local_picker_items); sSelectorWheelItemCount = context.getResources().getInteger(R.integer.local_picker_items);
sSelectorMiddleItemIndex = context.getResources().getInteger(R.integer.local_picker_items)/2; sSelectorMiddleItemIndex = context.getResources().getInteger(R.integer.local_picker_items)
/ 2;
mSelectorIndices = new int[sSelectorWheelItemCount]; mSelectorIndices = new int[sSelectorWheelItemCount];
// process style attributes // process style attributes
TypedArray attributesArray = context.obtainStyledAttributes( TypedArray attributesArray = context.obtainStyledAttributes(
@@ -641,11 +638,7 @@ public class LocalePicker extends LinearLayout {
public void onClick(View v) { public void onClick(View v) {
hideSoftInput(); hideSoftInput();
mInputText.clearFocus(); mInputText.clearFocus();
if (v.getId() == R.id.lp__increment) { changeValueByOne(v.getId() == R.id.lp__increment);
changeValueByOne(true);
} else {
changeValueByOne(false);
}
} }
}; };
@@ -653,11 +646,7 @@ public class LocalePicker extends LinearLayout {
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
hideSoftInput(); hideSoftInput();
mInputText.clearFocus(); mInputText.clearFocus();
if (v.getId() == R.id.lp__increment) { postChangeCurrentByOneFromLongPress(v.getId() == R.id.lp__increment, 0);
postChangeCurrentByOneFromLongPress(true, 0);
} else {
postChangeCurrentByOneFromLongPress(false, 0);
}
return true; return true;
} }
}; };
@@ -778,9 +767,9 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Move to the final position of a scroller. Ensures to force finish the scroller * Move to the final position of a scroller. Ensures to force finish the scroller and if it is
* and if it is not at its final position a scroll of the selector wheel is * not at its final position a scroll of the selector wheel is performed to fast forward to the
* performed to fast forward to the final position. * final position.
* *
* @param scroller The scroller to whose final position to get. * @param scroller The scroller to whose final position to get.
* @return True of the a move was performed, i.e. the scroller was not in final position. * @return True of the a move was performed, i.e. the scroller was not in final position.
@@ -886,7 +875,8 @@ public class LocalePicker extends LinearLayout {
invalidate(); invalidate();
} }
mLastDownOrMoveEventY = currentMoveY; mLastDownOrMoveEventY = currentMoveY;
} break; }
break;
case MotionEvent.ACTION_UP: { case MotionEvent.ACTION_UP: {
removeBeginSoftInputCommand(); removeBeginSoftInputCommand();
removeChangeCurrentByOneFromLongPress(); removeChangeCurrentByOneFromLongPress();
@@ -925,7 +915,8 @@ public class LocalePicker extends LinearLayout {
} }
mVelocityTracker.recycle(); mVelocityTracker.recycle();
mVelocityTracker = null; mVelocityTracker = null;
} break; }
break;
} }
return true; return true;
} }
@@ -1016,7 +1007,8 @@ public class LocalePicker extends LinearLayout {
mLastHoveredChildVirtualViewId = hoveredVirtualViewId; mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
provider.performAction(hoveredVirtualViewId, provider.performAction(hoveredVirtualViewId,
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
} break; }
break;
case MotionEvent.ACTION_HOVER_MOVE: { case MotionEvent.ACTION_HOVER_MOVE: {
if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId
&& mLastHoveredChildVirtualViewId != View.NO_ID) { && mLastHoveredChildVirtualViewId != View.NO_ID) {
@@ -1029,12 +1021,14 @@ public class LocalePicker extends LinearLayout {
provider.performAction(hoveredVirtualViewId, provider.performAction(hoveredVirtualViewId,
AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
} }
} break; }
break;
case MotionEvent.ACTION_HOVER_EXIT: { case MotionEvent.ACTION_HOVER_EXIT: {
provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
mLastHoveredChildVirtualViewId = View.NO_ID; mLastHoveredChildVirtualViewId = View.NO_ID;
} break; }
break;
} }
} }
return false; return false;
@@ -1133,12 +1127,12 @@ public class LocalePicker extends LinearLayout {
/** /**
* Set the formatter to be used for formatting the current value. * Set the formatter to be used for formatting the current value.
* <p> * <p>
* Note: If you have provided alternative values for the values this * Note: If you have provided alternative values for the values this formatter is never
* formatter is never invoked. * invoked.
* </p> * </p>
* *
* @param formatter The formatter object. If formatter is <code>null</code>, * @param formatter The formatter object. If formatter is <code>null</code>, {@link
* {@link String#valueOf(int)} will be used. * String#valueOf(int)} will be used.
* @see #setDisplayedValues(String[]) * @see #setDisplayedValues(String[])
*/ */
public void setFormatter(Formatter formatter) { public void setFormatter(Formatter formatter) {
@@ -1153,24 +1147,24 @@ public class LocalePicker extends LinearLayout {
/** /**
* Set the current value for the number picker. * Set the current value for the number picker.
* <p> * <p>
* If the argument is less than the {@link LocalePicker#getMinValue()} and * If the argument is less than the {@link LocalePicker#getMinValue()} and {@link
* {@link LocalePicker#getWrapSelectorWheel()} is <code>false</code> the * LocalePicker#getWrapSelectorWheel()} is <code>false</code> the current value is set to the
* current value is set to the {@link LocalePicker#getMinValue()} value. * {@link LocalePicker#getMinValue()} value.
* </p> * </p>
* <p> * <p>
* If the argument is less than the {@link LocalePicker#getMinValue()} and * If the argument is less than the {@link LocalePicker#getMinValue()} and {@link
* {@link LocalePicker#getWrapSelectorWheel()} is <code>true</code> the * LocalePicker#getWrapSelectorWheel()} is <code>true</code> the current value is set to the
* current value is set to the {@link LocalePicker#getMaxValue()} value. * {@link LocalePicker#getMaxValue()} value.
* </p> * </p>
* <p> * <p>
* If the argument is less than the {@link LocalePicker#getMaxValue()} and * If the argument is less than the {@link LocalePicker#getMaxValue()} and {@link
* {@link LocalePicker#getWrapSelectorWheel()} is <code>false</code> the * LocalePicker#getWrapSelectorWheel()} is <code>false</code> the current value is set to the
* current value is set to the {@link LocalePicker#getMaxValue()} value. * {@link LocalePicker#getMaxValue()} value.
* </p> * </p>
* <p> * <p>
* If the argument is less than the {@link LocalePicker#getMaxValue()} and * If the argument is less than the {@link LocalePicker#getMaxValue()} and {@link
* {@link LocalePicker#getWrapSelectorWheel()} is <code>true</code> the * LocalePicker#getWrapSelectorWheel()} is <code>true</code> the current value is set to the
* current value is set to the {@link LocalePicker#getMinValue()} value. * {@link LocalePicker#getMinValue()} value.
* </p> * </p>
* *
* @param value The current value. * @param value The current value.
@@ -1256,7 +1250,6 @@ public class LocalePicker extends LinearLayout {
* Gets whether the selector wheel wraps when reaching the min/max value. * Gets whether the selector wheel wraps when reaching the min/max value.
* *
* @return True if the selector wheel wraps. * @return True if the selector wheel wraps.
*
* @see #getMinValue() * @see #getMinValue()
* @see #getMaxValue() * @see #getMaxValue()
*/ */
@@ -1265,18 +1258,17 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Sets whether the selector wheel shown during flinging/scrolling should * Sets whether the selector wheel shown during flinging/scrolling should wrap around the {@link
* wrap around the {@link LocalePicker#getMinValue()} and * LocalePicker#getMinValue()} and {@link LocalePicker#getMaxValue()} values.
* {@link LocalePicker#getMaxValue()} values.
* <p> * <p>
* By default if the range (max - min) is more than the number of items shown * By default if the range (max - min) is more than the number of items shown on the selector
* on the selector wheel the selector wheel wrapping is enabled. * wheel the selector wheel wrapping is enabled.
* </p> * </p>
* <p> * <p>
* <strong>Note:</strong> If the number of items, i.e. the range ( * <strong>Note:</strong> If the number of items, i.e. the range (
* {@link #getMaxValue()} - {@link #getMinValue()}) is less than * {@link #getMaxValue()} - {@link #getMinValue()}) is less than the number of items shown on
* the number of items shown on the selector wheel, the selector wheel will * the selector wheel, the selector wheel will not wrap. Hence, in such a case calling this
* not wrap. Hence, in such a case calling this method is a NOP. * method is a NOP.
* </p> * </p>
* *
* @param wrapSelectorWheel Whether to wrap. * @param wrapSelectorWheel Whether to wrap.
@@ -1289,14 +1281,14 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Sets the speed at which the numbers be incremented and decremented when * Sets the speed at which the numbers be incremented and decremented when the up and down
* the up and down buttons are long pressed respectively. * buttons are long pressed respectively.
* <p> * <p>
* The default value is 300 ms. * The default value is 300 ms.
* </p> * </p>
* *
* @param intervalMillis The speed (in milliseconds) at which the numbers * @param intervalMillis The speed (in milliseconds) at which the numbers will be incremented
* will be incremented and decremented. * and decremented.
*/ */
public void setOnLongPressUpdateInterval(long intervalMillis) { public void setOnLongPressUpdateInterval(long intervalMillis) {
mLongPressUpdateInterval = intervalMillis; mLongPressUpdateInterval = intervalMillis;
@@ -1326,9 +1318,9 @@ public class LocalePicker extends LinearLayout {
* @param minValue The min value inclusive. * @param minValue The min value inclusive.
* *
* <strong>Note:</strong> The length of the displayed values array * <strong>Note:</strong> The length of the displayed values array
* set via {@link #setDisplayedValues(String[])} must be equal to the * set via {@link #setDisplayedValues(String[])} must be equal to the range of
* range of selectable numbers which is equal to * selectable numbers which is equal to {@link #getMaxValue()} - {@link
* {@link #getMaxValue()} - {@link #getMinValue()} + 1. * #getMinValue()} + 1.
*/ */
public void setMinValue(int minValue) { public void setMinValue(int minValue) {
if (mMinValue == minValue) { if (mMinValue == minValue) {
@@ -1364,9 +1356,9 @@ public class LocalePicker extends LinearLayout {
* @param maxValue The max value inclusive. * @param maxValue The max value inclusive.
* *
* <strong>Note:</strong> The length of the displayed values array * <strong>Note:</strong> The length of the displayed values array
* set via {@link #setDisplayedValues(String[])} must be equal to the * set via {@link #setDisplayedValues(String[])} must be equal to the range of
* range of selectable numbers which is equal to * selectable numbers which is equal to {@link #getMaxValue()} - {@link
* {@link #getMaxValue()} - {@link #getMinValue()} + 1. * #getMinValue()} + 1.
*/ */
public void setMaxValue(int maxValue) { public void setMaxValue(int maxValue) {
if (mMaxValue == maxValue) { if (mMaxValue == maxValue) {
@@ -1540,9 +1532,8 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Utility to reconcile a desired size and state, with constraints imposed * Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec.
* by a MeasureSpec. Tries to respect the min size, unless a different size * Tries to respect the min size, unless a different size is imposed by the constraints.
* is imposed by the constraints.
* *
* @param minSize The minimal desired size. * @param minSize The minimal desired size.
* @param measuredSize The currently measured size. * @param measuredSize The currently measured size.
@@ -1560,8 +1551,7 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Resets the selector indices and clear the cached string representation of * Resets the selector indices and clear the cached string representation of these indices.
* these indices.
*/ */
private void initializeSelectorWheelIndices() { private void initializeSelectorWheelIndices() {
mSelectorIndexToStringCache.clear(); mSelectorIndexToStringCache.clear();
@@ -1605,9 +1595,8 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Changes the current value by one which is increment or * Changes the current value by one which is increment or decrement based on the passes
* decrement based on the passes argument. * argument. decrement the current value.
* decrement the current value.
* *
* @param increment True to increment, false to decrement. * @param increment True to increment, false to decrement.
*/ */
@@ -1712,8 +1701,8 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Increments the <code>selectorIndices</code> whose string representations * Increments the <code>selectorIndices</code> whose string representations will be displayed in
* will be displayed in the selector. * the selector.
*/ */
private void incrementSelectorIndices(int[] selectorIndices) { private void incrementSelectorIndices(int[] selectorIndices) {
for (int i = 0; i < selectorIndices.length - 1; i++) { for (int i = 0; i < selectorIndices.length - 1; i++) {
@@ -1728,8 +1717,8 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Decrements the <code>selectorIndices</code> whose string representations * Decrements the <code>selectorIndices</code> whose string representations will be displayed in
* will be displayed in the selector. * the selector.
*/ */
private void decrementSelectorIndices(int[] selectorIndices) { private void decrementSelectorIndices(int[] selectorIndices) {
for (int i = selectorIndices.length - 1; i > 0; i--) { for (int i = selectorIndices.length - 1; i > 0; i--) {
@@ -1744,8 +1733,8 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Ensures we have a cached string representation of the given <code> * Ensures we have a cached string representation of the given <code> selectorIndex</code> to
* selectorIndex</code> to avoid multiple instantiations of the same string. * avoid multiple instantiations of the same string.
*/ */
private void ensureCachedScrollSelectorValue(int selectorIndex) { private void ensureCachedScrollSelectorValue(int selectorIndex) {
SparseArray<String> cache = mSelectorIndexToStringCache; SparseArray<String> cache = mSelectorIndexToStringCache;
@@ -1777,16 +1766,15 @@ public class LocalePicker extends LinearLayout {
updateInputTextView(); updateInputTextView();
} else { } else {
// Check the new value and ensure it's in range // Check the new value and ensure it's in range
int current = getSelectedPos(str.toString()); int current = getSelectedPos(str);
setValueInternal(current, true); setValueInternal(current, true);
} }
} }
/** /**
* Updates the view of this NumberPicker. If displayValues were specified in * Updates the view of this NumberPicker. If displayValues were specified in the string
* the string corresponding to the index specified by the current value will * corresponding to the index specified by the current value will be returned. Otherwise, the
* be returned. Otherwise, the formatter specified in {@link #setFormatter} * formatter specified in {@link #setFormatter} will be used to format the number.
* will be used to format the number.
* *
* @return Whether the text was updated. * @return Whether the text was updated.
*/ */
@@ -1807,8 +1795,7 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Notifies the listener, if registered, of a change of the value of this * Notifies the listener, if registered, of a change of the value of this NumberPicker.
* NumberPicker.
*/ */
private void notifyChange(int previous, int current) { private void notifyChange(int previous, int current) {
if (mOnValueChangeListener != null) { if (mOnValueChangeListener != null) {
@@ -1841,8 +1828,7 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Posts a command for beginning an edit of the current value via IME on * Posts a command for beginning an edit of the current value via IME on long press.
* long press.
*/ */
private void postBeginSoftInputOnLongPressCommand() { private void postBeginSoftInputOnLongPressCommand() {
if (mBeginSoftInputOnLongPressCommand == null) { if (mBeginSoftInputOnLongPressCommand == null) {
@@ -1941,8 +1927,8 @@ public class LocalePicker extends LinearLayout {
}; };
/** /**
* Filter for accepting only valid indices or prefixes of the string * Filter for accepting only valid indices or prefixes of the string representation of valid
* representation of valid indices. * indices.
*/ */
class InputTextFilter extends NumberKeyListener { class InputTextFilter extends NumberKeyListener {
@@ -1993,7 +1979,7 @@ public class LocalePicker extends LinearLayout {
} }
String result = String.valueOf(dest.subSequence(0, dstart)) + filtered String result = String.valueOf(dest.subSequence(0, dstart)) + filtered
+ dest.subSequence(dend, dest.length()); + dest.subSequence(dend, dest.length());
String str = String.valueOf(result).toLowerCase(); String str = result.toLowerCase();
for (String val : mDisplayedValues) { for (String val : mDisplayedValues) {
String valLowerCase = val.toLowerCase(); String valLowerCase = val.toLowerCase();
if (valLowerCase.startsWith(str)) { if (valLowerCase.startsWith(str)) {
@@ -2007,8 +1993,8 @@ public class LocalePicker extends LinearLayout {
} }
/** /**
* Ensures that the scroll wheel is adjusted i.e. there is no offset and the * Ensures that the scroll wheel is adjusted i.e. there is no offset and the middle element is
* middle element is in the middle of the widget. * in the middle of the widget.
* *
* @return Whether an adjustment has been made. * @return Whether an adjustment has been made.
*/ */
@@ -2073,13 +2059,15 @@ public class LocalePicker extends LinearLayout {
case BUTTON_INCREMENT: { case BUTTON_INCREMENT: {
mIncrementVirtualButtonPressed = true; mIncrementVirtualButtonPressed = true;
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
} break; }
break;
case BUTTON_DECREMENT: { case BUTTON_DECREMENT: {
mDecrementVirtualButtonPressed = true; mDecrementVirtualButtonPressed = true;
invalidate(0, 0, mRight, mTopSelectionDividerTop); invalidate(0, 0, mRight, mTopSelectionDividerTop);
} }
} }
} break; }
break;
case MODE_TAPPED: { case MODE_TAPPED: {
switch (mManagedButton) { switch (mManagedButton) {
case BUTTON_INCREMENT: { case BUTTON_INCREMENT: {
@@ -2089,7 +2077,8 @@ public class LocalePicker extends LinearLayout {
} }
mIncrementVirtualButtonPressed ^= true; mIncrementVirtualButtonPressed ^= true;
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
} break; }
break;
case BUTTON_DECREMENT: { case BUTTON_DECREMENT: {
if (!mDecrementVirtualButtonPressed) { if (!mDecrementVirtualButtonPressed) {
LocalePicker.this.postDelayed(this, LocalePicker.this.postDelayed(this,
@@ -2099,7 +2088,8 @@ public class LocalePicker extends LinearLayout {
invalidate(0, 0, mRight, mTopSelectionDividerTop); invalidate(0, 0, mRight, mTopSelectionDividerTop);
} }
} }
} break; }
break;
} }
} }
} }
@@ -2247,7 +2237,8 @@ public class LocalePicker extends LinearLayout {
requestAccessibilityFocus(); requestAccessibilityFocus();
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: {
if (mAccessibilityFocusedView == virtualViewId) { if (mAccessibilityFocusedView == virtualViewId) {
mAccessibilityFocusedView = UNDEFINED; mAccessibilityFocusedView = UNDEFINED;
@@ -2262,23 +2253,27 @@ public class LocalePicker extends LinearLayout {
changeValueByOne(true); changeValueByOne(true);
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: { case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: {
if (LocalePicker.this.isEnabled() if (LocalePicker.this.isEnabled()
&& (getWrapSelectorWheel() || getValue() > getMinValue())) { && (getWrapSelectorWheel() || getValue() > getMinValue())) {
changeValueByOne(false); changeValueByOne(false);
return true; return true;
} }
} return false;
} }
} break; return false;
}
}
break;
case VIRTUAL_VIEW_ID_INPUT: { case VIRTUAL_VIEW_ID_INPUT: {
switch (action) { switch (action) {
case AccessibilityNodeInfo.ACTION_FOCUS: { case AccessibilityNodeInfo.ACTION_FOCUS: {
if (LocalePicker.this.isEnabled() && !mInputText.isFocused()) { if (LocalePicker.this.isEnabled() && !mInputText.isFocused()) {
return mInputText.requestFocus(); return mInputText.requestFocus();
} }
} break; }
break;
case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: { case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: {
if (LocalePicker.this.isEnabled() && mInputText.isFocused()) { if (LocalePicker.this.isEnabled() && mInputText.isFocused()) {
mInputText.clearFocus(); mInputText.clearFocus();
@@ -2301,7 +2296,8 @@ public class LocalePicker extends LinearLayout {
mInputText.invalidate(); mInputText.invalidate();
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: {
if (mAccessibilityFocusedView == virtualViewId) { if (mAccessibilityFocusedView == virtualViewId) {
mAccessibilityFocusedView = UNDEFINED; mAccessibilityFocusedView = UNDEFINED;
@@ -2310,12 +2306,14 @@ public class LocalePicker extends LinearLayout {
mInputText.invalidate(); mInputText.invalidate();
return true; return true;
} }
} return false; }
return false;
default: { default: {
return mInputText.performAccessibilityAction(action, arguments); return mInputText.performAccessibilityAction(action, arguments);
} }
} }
} return false; }
return false;
case VIRTUAL_VIEW_ID_INCREMENT: { case VIRTUAL_VIEW_ID_INCREMENT: {
switch (action) { switch (action) {
case AccessibilityNodeInfo.ACTION_CLICK: { case AccessibilityNodeInfo.ACTION_CLICK: {
@@ -2325,7 +2323,8 @@ public class LocalePicker extends LinearLayout {
AccessibilityEvent.TYPE_VIEW_CLICKED); AccessibilityEvent.TYPE_VIEW_CLICKED);
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: { case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: {
if (mAccessibilityFocusedView != virtualViewId) { if (mAccessibilityFocusedView != virtualViewId) {
mAccessibilityFocusedView = virtualViewId; mAccessibilityFocusedView = virtualViewId;
@@ -2334,7 +2333,8 @@ public class LocalePicker extends LinearLayout {
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: {
if (mAccessibilityFocusedView == virtualViewId) { if (mAccessibilityFocusedView == virtualViewId) {
mAccessibilityFocusedView = UNDEFINED; mAccessibilityFocusedView = UNDEFINED;
@@ -2343,20 +2343,24 @@ public class LocalePicker extends LinearLayout {
invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom);
return true; return true;
} }
} return false;
} }
} return false; return false;
}
}
return false;
case VIRTUAL_VIEW_ID_DECREMENT: { case VIRTUAL_VIEW_ID_DECREMENT: {
switch (action) { switch (action) {
case AccessibilityNodeInfo.ACTION_CLICK: { case AccessibilityNodeInfo.ACTION_CLICK: {
if (LocalePicker.this.isEnabled()) { if (LocalePicker.this.isEnabled()) {
final boolean increment = (virtualViewId == VIRTUAL_VIEW_ID_INCREMENT); final boolean increment =
(virtualViewId == VIRTUAL_VIEW_ID_INCREMENT);
LocalePicker.this.changeValueByOne(increment); LocalePicker.this.changeValueByOne(increment);
sendAccessibilityEventForVirtualView(virtualViewId, sendAccessibilityEventForVirtualView(virtualViewId,
AccessibilityEvent.TYPE_VIEW_CLICKED); AccessibilityEvent.TYPE_VIEW_CLICKED);
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: { case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: {
if (mAccessibilityFocusedView != virtualViewId) { if (mAccessibilityFocusedView != virtualViewId) {
mAccessibilityFocusedView = virtualViewId; mAccessibilityFocusedView = virtualViewId;
@@ -2365,7 +2369,8 @@ public class LocalePicker extends LinearLayout {
invalidate(0, 0, mRight, mTopSelectionDividerTop); invalidate(0, 0, mRight, mTopSelectionDividerTop);
return true; return true;
} }
} return false; }
return false;
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: {
if (mAccessibilityFocusedView == virtualViewId) { if (mAccessibilityFocusedView == virtualViewId) {
mAccessibilityFocusedView = UNDEFINED; mAccessibilityFocusedView = UNDEFINED;
@@ -2374,9 +2379,11 @@ public class LocalePicker extends LinearLayout {
invalidate(0, 0, mRight, mTopSelectionDividerTop); invalidate(0, 0, mRight, mTopSelectionDividerTop);
return true; return true;
} }
} return false;
} }
} return false; return false;
}
}
return false;
} }
return super.performAction(virtualViewId, action, arguments); return super.performAction(virtualViewId, action, arguments);
} }
@@ -2388,16 +2395,19 @@ public class LocalePicker extends LinearLayout {
sendAccessibilityEventForVirtualButton(virtualViewId, eventType, sendAccessibilityEventForVirtualButton(virtualViewId, eventType,
getVirtualDecrementButtonText()); getVirtualDecrementButtonText());
} }
} break; }
break;
case VIRTUAL_VIEW_ID_INPUT: { case VIRTUAL_VIEW_ID_INPUT: {
sendAccessibilityEventForVirtualText(eventType); sendAccessibilityEventForVirtualText(eventType);
} break; }
break;
case VIRTUAL_VIEW_ID_INCREMENT: { case VIRTUAL_VIEW_ID_INCREMENT: {
if (hasVirtualIncrementButton()) { if (hasVirtualIncrementButton()) {
sendAccessibilityEventForVirtualButton(virtualViewId, eventType, sendAccessibilityEventForVirtualButton(virtualViewId, eventType,
getVirtualIncrementButtonText()); getVirtualIncrementButtonText());
} }
} break; }
break;
} }
} }
@@ -2430,10 +2440,11 @@ public class LocalePicker extends LinearLayout {
case VIRTUAL_VIEW_ID_DECREMENT: { case VIRTUAL_VIEW_ID_DECREMENT: {
String text = getVirtualDecrementButtonText(); String text = getVirtualDecrementButtonText();
if (!TextUtils.isEmpty(text) if (!TextUtils.isEmpty(text)
&& text.toString().toLowerCase().contains(searchedLowerCase)) { && text.toLowerCase().contains(searchedLowerCase)) {
outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_DECREMENT)); outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_DECREMENT));
} }
} return; }
return;
case VIRTUAL_VIEW_ID_INPUT: { case VIRTUAL_VIEW_ID_INPUT: {
CharSequence text = mInputText.getText(); CharSequence text = mInputText.getText();
if (!TextUtils.isEmpty(text) && if (!TextUtils.isEmpty(text) &&
@@ -2447,14 +2458,16 @@ public class LocalePicker extends LinearLayout {
outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INPUT)); outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INPUT));
return; return;
} }
} break; }
break;
case VIRTUAL_VIEW_ID_INCREMENT: { case VIRTUAL_VIEW_ID_INCREMENT: {
String text = getVirtualIncrementButtonText(); String text = getVirtualIncrementButtonText();
if (!TextUtils.isEmpty(text) if (!TextUtils.isEmpty(text)
&& text.toString().toLowerCase().contains(searchedLowerCase)) { && text.toLowerCase().contains(searchedLowerCase)) {
outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INCREMENT)); outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INCREMENT));
} }
} return; }
return;
} }
} }

View File

@@ -29,14 +29,15 @@ import androidx.core.view.ViewCompat;
import org.lineageos.setupwizard.R; 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 * A layout that draws something in the insets passed to
* (status and navigation bars, overlay action bars). * {@link #fitSystemWindows(android.graphics.Rect)},
* i.e. the area above UI chrome (status and navigation bars, overlay action bars).
*/ */
public class ScrimInsetsFrameLayout extends FrameLayout { public class ScrimInsetsFrameLayout extends FrameLayout {
private Drawable mInsetForeground; private Drawable mInsetForeground;
private Rect mInsets; private Rect mInsets;
private Rect mTempRect = new Rect(); private final Rect mTempRect = new Rect();
private OnInsetsCallback mOnInsetsCallback; private OnInsetsCallback mOnInsetsCallback;
public ScrimInsetsFrameLayout(Context context) { public ScrimInsetsFrameLayout(Context context) {
@@ -128,16 +129,16 @@ public class ScrimInsetsFrameLayout extends FrameLayout {
} }
/** /**
* Allows the calling container to specify a callback for custom processing when insets change (i.e. when * Allows the calling container to specify a callback for custom processing when insets change
* {@link #fitSystemWindows(android.graphics.Rect)} is called. This is useful for setting padding on UI elements based on * (i.e. when {@link #fitSystemWindows(android.graphics.Rect)} is called. This is useful for
* UI chrome insets (e.g. a Google Map or a ListView). When using with ListView or GridView, remember to set * setting padding on UI elements based on UI chrome insets (e.g. a Google Map or a ListView).
* clipToPadding to false. * When using with ListView or GridView, remember to set clipToPadding to false.
*/ */
public void setOnInsetsCallback(OnInsetsCallback onInsetsCallback) { public void setOnInsetsCallback(OnInsetsCallback onInsetsCallback) {
mOnInsetsCallback = onInsetsCallback; mOnInsetsCallback = onInsetsCallback;
} }
public static interface OnInsetsCallback { public interface OnInsetsCallback {
public void onInsetsChanged(Rect insets); void onInsetsChanged(Rect insets);
} }
} }

View File

@@ -145,7 +145,8 @@ public class WizardAction implements Parcelable {
} }
} }
public static WizardAction parseWizardAction(XmlPullParser parser) throws XmlPullParserException, public static WizardAction parseWizardAction(XmlPullParser parser)
throws XmlPullParserException,
IOException { IOException {
String id = parser.getAttributeValue(null, WizardScript.ATTR_ID); String id = parser.getAttributeValue(null, WizardScript.ATTR_ID);
String uri = parser.getAttributeValue(WizardScript.WIZARD_SCRIPT_NAMESPACE, String uri = parser.getAttributeValue(WizardScript.WIZARD_SCRIPT_NAMESPACE,

View File

@@ -17,7 +17,6 @@
package org.lineageos.setupwizard.wizardmanager; package org.lineageos.setupwizard.wizardmanager;
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_LOAD; import static org.lineageos.setupwizard.SetupWizardApp.ACTION_LOAD;
import static org.lineageos.setupwizard.SetupWizardApp.ACTION_NEXT; import static org.lineageos.setupwizard.SetupWizardApp.ACTION_NEXT;
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_ACTION_ID; import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_ACTION_ID;
@@ -25,12 +24,6 @@ import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_RESULT_CODE;
import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_SCRIPT_URI; import static org.lineageos.setupwizard.SetupWizardApp.EXTRA_SCRIPT_URI;
import static org.lineageos.setupwizard.SetupWizardApp.LOGV; import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
import com.google.android.setupcompat.util.ResultCodes;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;
import org.lineageos.setupwizard.util.SetupWizardUtils;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
@@ -39,15 +32,19 @@ import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import java.util.HashMap; import com.google.android.setupcompat.util.ResultCodes;
import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;
import org.lineageos.setupwizard.util.SetupWizardUtils;
import java.util.HashMap;
public class WizardManager extends Activity { public class WizardManager extends Activity {
private static final String TAG = WizardManager.class.getSimpleName(); private static final String TAG = WizardManager.class.getSimpleName();
private static HashMap<String, WizardScript> sWizardScripts = new HashMap(); private static final HashMap<String, WizardScript> sWizardScripts = new HashMap();
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -188,11 +185,8 @@ public class WizardManager extends Activity {
} }
private static boolean isIntentAvailable(Context context, Intent intent) { private static boolean isIntentAvailable(Context context, Intent intent) {
if (context.getPackageManager().queryIntentActivities(intent, return context.getPackageManager().queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY).size() > 0) { PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
return true;
}
return false;
} }
private static WizardScript getWizardScript(Context context, String scriptUri) { private static WizardScript getWizardScript(Context context, String scriptUri) {

View File

@@ -19,11 +19,6 @@ package org.lineageos.setupwizard.wizardmanager;
import static org.lineageos.setupwizard.SetupWizardApp.LOGV; import static org.lineageos.setupwizard.SetupWizardApp.LOGV;
import com.android.internal.util.XmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity; import android.app.Activity;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@@ -33,6 +28,11 @@ import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import android.util.Xml; import android.util.Xml;
import com.android.internal.util.XmlUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;

View File

@@ -24,8 +24,6 @@ import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import org.lineageos.setupwizard.SetupWizardApp;
public class WizardTransitions extends SparseArray<String> implements Parcelable { public class WizardTransitions extends SparseArray<String> implements Parcelable {
private static final String TAG = "WizardTransitions"; private static final String TAG = "WizardTransitions";
@@ -47,7 +45,8 @@ public class WizardTransitions extends SparseArray<String> implements Parcelable
} }
}; };
public WizardTransitions() {} public WizardTransitions() {
}
public void setDefaultAction(String action) { public void setDefaultAction(String action) {
mDefaultAction = action; mDefaultAction = action;
@@ -77,7 +76,8 @@ public class WizardTransitions extends SparseArray<String> implements Parcelable
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
WizardTransitions that = (WizardTransitions) o; WizardTransitions that = (WizardTransitions) o;
return mDefaultAction != null ? mDefaultAction.equals(that.mDefaultAction) : that.mDefaultAction == null; return mDefaultAction != null ? mDefaultAction.equals(that.mDefaultAction)
: that.mDefaultAction == null;
} }
@@ -105,5 +105,4 @@ public class WizardTransitions extends SparseArray<String> implements Parcelable
mDefaultAction = in.readString(); mDefaultAction = in.readString();
} }
} }