From b7b34b96a9d73bc3856117107a62541504b53d64 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Wed, 25 Aug 2021 19:13:30 +0300 Subject: [PATCH] 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 --- .../setupwizard/BaseSetupWizardActivity.java | 9 +- .../setupwizard/BiometricActivity.java | 4 +- .../setupwizard/BluetoothSetupActivity.java | 2 +- .../CaptivePortalSetupActivity.java | 17 +- .../setupwizard/ChooseDataSimActivity.java | 24 +- .../setupwizard/DateTimeActivity.java | 45 ++- .../lineageos/setupwizard/FinishActivity.java | 22 +- .../setupwizard/LineageSettingsActivity.java | 9 +- .../lineageos/setupwizard/LocaleActivity.java | 18 +- .../setupwizard/LocationSettingsActivity.java | 5 +- .../setupwizard/MobileDataActivity.java | 20 +- .../setupwizard/PartnerReceiver.java | 4 +- .../setupwizard/SetupWizardActivity.java | 3 +- .../lineageos/setupwizard/SetupWizardApp.java | 17 +- .../setupwizard/SetupWizardExitActivity.java | 2 +- .../setupwizard/SetupWizardExitService.java | 1 - .../setupwizard/SimMissingActivity.java | 2 +- .../setupwizard/SubBaseActivity.java | 1 - .../setupwizard/UpdateRecoveryActivity.java | 2 +- .../setupwizard/WelcomeActivity.java | 3 +- .../setupwizard/WifiSetupActivity.java | 3 +- .../backup/RestoreIntroActivity.java | 6 +- .../util/EnableAccessibilityController.java | 10 +- .../setupwizard/util/NetworkMonitor.java | 2 +- .../setupwizard/util/PhoneMonitor.java | 33 +- .../setupwizard/util/SetupWizardUtils.java | 32 +- .../setupwizard/widget/LocalePicker.java | 341 +++++++++--------- .../widget/ScrimInsetsFrameLayout.java | 19 +- .../wizardmanager/WizardAction.java | 5 +- .../wizardmanager/WizardManager.java | 56 ++- .../wizardmanager/WizardScript.java | 26 +- .../wizardmanager/WizardTransitions.java | 11 +- 32 files changed, 376 insertions(+), 378 deletions(-) diff --git a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java index e1ca4d5c..3788669f 100644 --- a/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java +++ b/src/org/lineageos/setupwizard/BaseSetupWizardActivity.java @@ -18,6 +18,7 @@ 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; @@ -85,7 +86,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga protected boolean mIsActivityVisible = false; protected boolean mIsExiting = false; - private boolean mIsFirstRun = true; + private final boolean mIsFirstRun = true; protected boolean mIsGoingBack = false; private boolean mIsPrimaryUser; protected int mResultCode = 0; @@ -212,7 +213,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga /** * @return The navigation bar instance in the layout, or null if the layout does not have a - * navigation bar. + * navigation bar. */ public NavigationLayout getNavigationBar() { final View view = findViewById(R.id.navigation_bar); @@ -312,7 +313,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga tryEnablingWifi(); } - protected void exitIfSetupComplete() { if (WizardManagerHelper.isUserSetupComplete(this)) { Log.i(TAG, "Starting activity with USER_SETUP_COMPLETE=true"); @@ -465,7 +465,7 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga } else if (transitionId == TRANSITION_ID_DEFAULT) { TypedArray typedArray = obtainStyledAttributes(android.R.style.Animation_Activity, new int[]{android.R.attr.activityCloseEnterAnimation, - android.R.attr.activityCloseExitAnimation}); + android.R.attr.activityCloseExitAnimation}); overridePendingTransition(typedArray.getResourceId(0, 0), typedArray.getResourceId(1, 0)); typedArray.recycle(); @@ -511,7 +511,6 @@ public abstract class BaseSetupWizardActivity extends Activity implements Naviga startActivityForResult(intent, requestCode); } - protected boolean isFirstRun() { return mIsFirstRun; } diff --git a/src/org/lineageos/setupwizard/BiometricActivity.java b/src/org/lineageos/setupwizard/BiometricActivity.java index 510bc468..e3dfbe1f 100644 --- a/src/org/lineageos/setupwizard/BiometricActivity.java +++ b/src/org/lineageos/setupwizard/BiometricActivity.java @@ -24,7 +24,6 @@ import static org.lineageos.setupwizard.SetupWizardApp.REQUEST_CODE_SETUP_BIOMET import android.content.Intent; import android.os.Bundle; -import android.view.View; import android.widget.TextView; import com.google.android.setupcompat.util.WizardManagerHelper; @@ -39,7 +38,8 @@ public class BiometricActivity extends SubBaseActivity { @Override protected void onCreate(Bundle 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); if (SetupWizardUtils.hasFace(this)) { setupBiometricSummary.setText(getString(R.string.face_setup_summary)); diff --git a/src/org/lineageos/setupwizard/BluetoothSetupActivity.java b/src/org/lineageos/setupwizard/BluetoothSetupActivity.java index 197f05a7..ad82ae6e 100644 --- a/src/org/lineageos/setupwizard/BluetoothSetupActivity.java +++ b/src/org/lineageos/setupwizard/BluetoothSetupActivity.java @@ -37,7 +37,7 @@ public class BluetoothSetupActivity extends WrapperSubBaseActivity { protected void onStartSubactivity() { try { Intent intent = new Intent(); - intent.setComponent(SetupWizardUtils.mTvAddAccessorySettingsActivity); + intent.setComponent(SetupWizardUtils.sTvAddAccessorySettingsActivity); intent.setAction(ACTION_CONNECT_INPUT); intent.putExtra(INTENT_EXTRA_NO_INPUT_MODE, true); startActivityForResult(intent, REQUEST_CODE_SETUP_BLUETOOTH); diff --git a/src/org/lineageos/setupwizard/CaptivePortalSetupActivity.java b/src/org/lineageos/setupwizard/CaptivePortalSetupActivity.java index 8e162793..cb1b0ea7 100644 --- a/src/org/lineageos/setupwizard/CaptivePortalSetupActivity.java +++ b/src/org/lineageos/setupwizard/CaptivePortalSetupActivity.java @@ -68,7 +68,8 @@ public class CaptivePortalSetupActivity extends WrapperSubBaseActivity { } public static void checkForCaptivePortal(URL captivePortalUrl, - CaptivePortalSetupActivity captivePortalSetupActivity, boolean cancelAndRecreateIfRunning) { + CaptivePortalSetupActivity captivePortalSetupActivity, + boolean cancelAndRecreateIfRunning) { if (sTask == null || sTask.getStatus() == Status.FINISHED) { sTask = new CheckForCaptivePortalTask(captivePortalUrl, captivePortalSetupActivity); sTask.execute(); @@ -123,11 +124,16 @@ public class CaptivePortalSetupActivity extends WrapperSubBaseActivity { intent.putExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL, new CaptivePortal(new ICaptivePortal.Stub() { @Override - public void appResponse(int response) {} + public void appResponse(int response) { + } + @Override - public void logEvent(int eventId, String packageName) {} + public void logEvent(int eventId, String packageName) { + } + @Override - public void appRequest(int request) {} + public void appRequest(int request) { + } })); intent.putExtra("status_bar_color", context.getResources().getColor(R.color.primary_dark)); @@ -135,7 +141,8 @@ public class CaptivePortalSetupActivity extends WrapperSubBaseActivity { R.color.primary_dark)); intent.putExtra("progress_bar_color", context.getResources().getColor( R.color.accent)); - captivePortalSetupActivity.startSubactivity(intent, REQUEST_CODE_SETUP_CAPTIVE_PORTAL); + captivePortalSetupActivity.startSubactivity(intent, + REQUEST_CODE_SETUP_CAPTIVE_PORTAL); } else { captivePortalSetupActivity.finishAction(RESULT_OK); captivePortalSetupActivity.finish(); diff --git a/src/org/lineageos/setupwizard/ChooseDataSimActivity.java b/src/org/lineageos/setupwizard/ChooseDataSimActivity.java index 2d552fa7..5de88ff1 100644 --- a/src/org/lineageos/setupwizard/ChooseDataSimActivity.java +++ b/src/org/lineageos/setupwizard/ChooseDataSimActivity.java @@ -25,7 +25,6 @@ import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; -import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.util.SparseArray; @@ -75,14 +74,14 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { } }; - private View.OnClickListener mSetDataSimClickListener = view -> { - SubscriptionInfo subInfoRecord = (SubscriptionInfo)view.getTag(); + private final View.OnClickListener mSetDataSimClickListener = view -> { + SubscriptionInfo subInfoRecord = (SubscriptionInfo) view.getTag(); if (subInfoRecord != null) { changeDataSub(subInfoRecord); } }; - private PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener = + private final PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener = new PhoneMonitor.SubscriptionStateListener() { @Override public void onServiceStateChanged(int subId, ServiceState serviceState) { @@ -204,7 +203,6 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { } updateSignalStrengths(); updateCurrentDataSub(); - } @Override @@ -317,11 +315,7 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { if (mIsAttached) { for (int i = 0; i < mCheckBoxes.size(); i++) { int key = mCheckBoxes.keyAt(i); - if (subInfoRecord.getSimSlotIndex() == key) { - mCheckBoxes.get(key).setChecked(true); - } else { - mCheckBoxes.get(key).setChecked(false); - } + mCheckBoxes.get(key).setChecked(subInfoRecord.getSimSlotIndex() == key); } } } @@ -353,9 +347,9 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { private void enableRows(boolean enabled) { for (int i = 0; i < mRows.size(); i++) { - final View v = mRows.get(mRows.keyAt(i)); + final View v = mRows.get(mRows.keyAt(i)); v.setEnabled(enabled); - final SubscriptionInfo subInfoRecord = (SubscriptionInfo)v.getTag(); + final SubscriptionInfo subInfoRecord = (SubscriptionInfo) v.getTag(); if (subInfoRecord != null) { updateCarrierText(subInfoRecord); } @@ -401,7 +395,7 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { "signalStrength='" + signalStrength + '\'' + "signalStrengthLevel='" + ((signalStrength != null) ? signalStrength.getLevel() : "null") + '\'' + - ", subInfoRecord.getSimSlotIndex() =" + subInfoRecord.getSimSlotIndex() + + ", subInfoRecord.getSimSlotIndex() =" + subInfoRecord.getSimSlotIndex() + '}'); } if (!hasService(subInfoRecord)) { @@ -437,7 +431,7 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { boolean retVal; ServiceState serviceState = mServiceStates.get(subInfoRecord.getSimSlotIndex()); if (serviceState == null) { - serviceState = mPhoneMonitor + serviceState = mPhoneMonitor .getServiceStateForSubscriber(subInfoRecord.getSubscriptionId()); mServiceStates.put(subInfoRecord.getSimSlotIndex(), serviceState); } @@ -455,7 +449,7 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity { // Some SIM cards are marketed as data-only and do not support voice service, and on // these SIM cards, we want to show signal bars for data service as well as the "no // service" or "emergency calls only" text that indicates that voice is not available. - switch(serviceState.getVoiceRegState()) { + switch (serviceState.getVoiceRegState()) { case ServiceState.STATE_POWER_OFF: retVal = false; break; diff --git a/src/org/lineageos/setupwizard/DateTimeActivity.java b/src/org/lineageos/setupwizard/DateTimeActivity.java index f7e32f32..d5293654 100644 --- a/src/org/lineageos/setupwizard/DateTimeActivity.java +++ b/src/org/lineageos/setupwizard/DateTimeActivity.java @@ -29,7 +29,6 @@ import android.content.IntentFilter; import android.os.Bundle; import android.os.Handler; import android.text.format.DateFormat; -import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.DatePicker; @@ -54,10 +53,10 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements public static final String TAG = DateTimeActivity.class.getSimpleName(); - private static final String KEY_ID = "id"; // value: String - private static final String KEY_DISPLAYNAME = "name"; // value: String - private static final String KEY_GMT = "gmt"; // value: String - private static final String KEY_OFFSET = "offset"; // value: int (Integer) + private static final String KEY_ID = "id"; // value: String + private static final String KEY_DISPLAYNAME = "name"; // value: String + private static final String KEY_GMT = "gmt"; // value: String + private static final String KEY_OFFSET = "offset"; // value: int (Integer) private static final String XMLTAG_TIMEZONE = "timezone"; private static final int HOURS_1 = 60 * 60000; @@ -66,13 +65,12 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements private TextView mDateTextView; private TextView mTimeTextView; - private final Handler mHandler = new Handler(); - private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - updateTimeAndDateDisplay(); + updateTimeAndDateDisplay(); } }; @@ -88,8 +86,8 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements dateView.setOnClickListener((view) -> showDatePicker()); View timeView = findViewById(R.id.time_item); timeView.setOnClickListener((view) -> showTimePicker()); - mDateTextView = (TextView)findViewById(R.id.date_text); - mTimeTextView = (TextView)findViewById(R.id.time_text); + mDateTextView = (TextView) findViewById(R.id.date_text); + mTimeTextView = (TextView) findViewById(R.id.time_text); // Pre-select current/default timezone mHandler.post(() -> { int tzIndex = getTimeZoneIndex(adapter, mCurrentTimeZone); @@ -100,7 +98,7 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int position, - long id) { + long id) { final Map map = (Map) adapterView.getItemAtPosition(position); final String tzId = (String) map.get(KEY_ID); if (mCurrentTimeZone != null && !mCurrentTimeZone.getID().equals(tzId)) { @@ -173,14 +171,14 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements @Override public void onDateSet(DatePicker view, int year, int month, int day) { - setDate(this, year, month, day); - updateTimeAndDateDisplay(); + setDate(this, year, month, day); + updateTimeAndDateDisplay(); } @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { - setTime(this, hourOfDay, minute); - updateTimeAndDateDisplay(); + setTime(this, hourOfDay, minute); + updateTimeAndDateDisplay(); } private void showDatePicker() { @@ -201,8 +199,8 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements } private static SimpleAdapter constructTimezoneAdapter(Context context) { - final String[] from = new String[] {KEY_DISPLAYNAME, KEY_GMT}; - final int[] to = new int[] {android.R.id.text1, android.R.id.text2}; + final String[] from = new String[]{KEY_DISPLAYNAME, KEY_GMT}; + final int[] to = new int[]{android.R.id.text1, android.R.id.text2}; final TimeZoneComparator comparator = new TimeZoneComparator(KEY_OFFSET); final List> sortedList = ZoneGetter.getZonesList(context); @@ -220,8 +218,8 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements final String defaultId = tz.getID(); final int listSize = adapter.getCount(); for (int i = 0; i < listSize; i++) { - final Map map = (Map)adapter.getItem(i); - final String id = (String)map.get(KEY_ID); + final Map map = (Map) adapter.getItem(i); + final String id = (String) map.get(KEY_ID); if (defaultId.equals(id)) { // If current timezone is in this list, move focus to it return i; @@ -293,7 +291,7 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { - private static String TAG = TimePickerFragment.class.getSimpleName(); + private static final String TAG = TimePickerFragment.class.getSimpleName(); public static TimePickerFragment newInstance() { TimePickerFragment frag = new TimePickerFragment(); @@ -302,7 +300,7 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { - ((DateTimeActivity)getActivity()).onTimeSet(view, hourOfDay, minute); + ((DateTimeActivity) getActivity()).onTimeSet(view, hourOfDay, minute); } @Override @@ -315,13 +313,12 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(getActivity())); } - } public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { - private static String TAG = DatePickerFragment.class.getSimpleName(); + private static final String TAG = DatePickerFragment.class.getSimpleName(); public static DatePickerFragment newInstance() { DatePickerFragment frag = new DatePickerFragment(); @@ -330,7 +327,7 @@ public class DateTimeActivity extends BaseSetupWizardActivity implements @Override public void onDateSet(DatePicker view, int year, int month, int day) { - ((DateTimeActivity)getActivity()).onDateSet(view, year, month, day); + ((DateTimeActivity) getActivity()).onDateSet(view, year, month, day); } @Override diff --git a/src/org/lineageos/setupwizard/FinishActivity.java b/src/org/lineageos/setupwizard/FinishActivity.java index 69374546..f3dfb085 100644 --- a/src/org/lineageos/setupwizard/FinishActivity.java +++ b/src/org/lineageos/setupwizard/FinishActivity.java @@ -17,6 +17,9 @@ 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.DISABLE_NAV_KEYS; import static org.lineageos.setupwizard.SetupWizardApp.ENABLE_RECOVERY_UPDATE; @@ -35,8 +38,8 @@ import android.graphics.Bitmap; import android.graphics.Point; import android.os.Bundle; import android.os.Handler; -import android.os.UserHandle; import android.os.SystemProperties; +import android.os.UserHandle; import android.preference.PreferenceManager; import android.view.View; import android.view.ViewAnimationUtils; @@ -48,9 +51,6 @@ import org.lineageos.setupwizard.util.EnableAccessibilityController; 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 static final String TAG = FinishActivity.class.getSimpleName(); @@ -65,7 +65,6 @@ public class FinishActivity extends BaseSetupWizardActivity { private volatile boolean mIsFinishing = false; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -162,10 +161,12 @@ public class FinishActivity extends BaseSetupWizardActivity { } @Override - public void onAnimationCancel(Animator animation) {} + public void onAnimationCancel(Animator animation) { + } @Override - public void onAnimationRepeat(Animator animation) {} + public void onAnimationRepeat(Animator animation) { + } }); anim.start(); } @@ -191,7 +192,8 @@ public class FinishActivity extends BaseSetupWizardActivity { if (privacyData != null && privacyData.containsKey(KEY_SEND_METRICS)) { 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); } } @@ -216,8 +218,8 @@ public class FinishActivity extends BaseSetupWizardActivity { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final boolean virtualKeysEnabled = LineageSettings.System.getIntForUser( - context.getContentResolver(), LineageSettings.System.FORCE_SHOW_NAVBAR, 0, - UserHandle.USER_CURRENT) != 0; + context.getContentResolver(), LineageSettings.System.FORCE_SHOW_NAVBAR, 0, + UserHandle.USER_CURRENT) != 0; if (enabled != virtualKeysEnabled) { LineageSettings.System.putIntForUser(context.getContentResolver(), LineageSettings.System.FORCE_SHOW_NAVBAR, enabled ? 1 : 0, diff --git a/src/org/lineageos/setupwizard/LineageSettingsActivity.java b/src/org/lineageos/setupwizard/LineageSettingsActivity.java index 03f79450..4f5519d1 100644 --- a/src/org/lineageos/setupwizard/LineageSettingsActivity.java +++ b/src/org/lineageos/setupwizard/LineageSettingsActivity.java @@ -25,7 +25,6 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.os.RemoteException; import android.os.UserHandle; import android.text.Spannable; import android.text.SpannableString; @@ -34,16 +33,12 @@ import android.text.Spanned; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.util.Log; -import android.view.IWindowManager; import android.view.View; -import android.view.WindowManagerGlobal; import android.widget.CheckBox; import android.widget.TextView; import com.google.android.setupcompat.util.WizardManagerHelper; -import org.lineageos.setupwizard.R; - import lineageos.hardware.LineageHardwareManager; import lineageos.providers.LineageSettings; @@ -60,13 +55,13 @@ public class LineageSettingsActivity extends BaseSetupWizardActivity { private boolean mSupportsKeyDisabler = false; - private View.OnClickListener mMetricsClickListener = view -> { + private final View.OnClickListener mMetricsClickListener = view -> { boolean checked = !mMetrics.isChecked(); mMetrics.setChecked(checked); mSetupWizardApp.getSettingsBundle().putBoolean(KEY_SEND_METRICS, checked); }; - private View.OnClickListener mNavKeysClickListener = view -> { + private final View.OnClickListener mNavKeysClickListener = view -> { boolean checked = !mNavKeys.isChecked(); mNavKeys.setChecked(checked); mSetupWizardApp.getSettingsBundle().putBoolean(DISABLE_NAV_KEYS, checked); diff --git a/src/org/lineageos/setupwizard/LocaleActivity.java b/src/org/lineageos/setupwizard/LocaleActivity.java index 8f3ec2a4..08b0b173 100644 --- a/src/org/lineageos/setupwizard/LocaleActivity.java +++ b/src/org/lineageos/setupwizard/LocaleActivity.java @@ -39,7 +39,6 @@ import com.android.internal.telephony.util.LocaleUtils; import com.google.android.setupcompat.util.SystemBarHelper; -import org.lineageos.setupwizard.R; import org.lineageos.setupwizard.widget.LocalePicker; import java.util.List; @@ -76,7 +75,6 @@ public class LocaleActivity extends BaseSetupWizardActivity { } }; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -130,8 +128,8 @@ public class LocaleActivity extends BaseSetupWizardActivity { fetchAndUpdateSimLocale(); mAdapterIndices = new int[mLocaleAdapter.getCount()]; int currentLocaleIndex = 0; - String [] labels = new String[mLocaleAdapter.getCount()]; - for (int i=0; i { if (scrollState == NumberPicker.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { - ((SetupWizardApp)getApplication()).setIgnoreSimLocale(true); + ((SetupWizardApp) getApplication()).setIgnoreSimLocale(true); } }); } private void setLocaleFromPicker() { - ((SetupWizardApp)getApplication()).setIgnoreSimLocale(true); + ((SetupWizardApp) getApplication()).setIgnoreSimLocale(true); int i = mAdapterIndices[mLanguagePicker.getValue()]; final com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i); @@ -176,7 +174,7 @@ public class LocaleActivity extends BaseSetupWizardActivity { } private void fetchAndUpdateSimLocale() { - if (((SetupWizardApp)getApplication()).ignoreSimLocale() || isDestroyed()) { + if (((SetupWizardApp) getApplication()).ignoreSimLocale() || isDestroyed()) { return; } if (mPaused) { @@ -200,7 +198,7 @@ public class LocaleActivity extends BaseSetupWizardActivity { TelephonyManager telephonyManager = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE); int state = telephonyManager.getSimState(); - if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED || + if (state == TelephonyManager.SIM_STATE_PIN_REQUIRED || state == TelephonyManager.SIM_STATE_PUK_REQUIRED) { return null; } @@ -233,12 +231,12 @@ public class LocaleActivity extends BaseSetupWizardActivity { @Override protected void onPostExecute(Locale simLocale) { if (simLocale != null && !simLocale.equals(mCurrentLocale)) { - if (!((SetupWizardApp)getApplication()).ignoreSimLocale() && !isDestroyed()) { + 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); + ((SetupWizardApp) getApplication()).setIgnoreSimLocale(true); } } } diff --git a/src/org/lineageos/setupwizard/LocationSettingsActivity.java b/src/org/lineageos/setupwizard/LocationSettingsActivity.java index ad32023e..846020bb 100644 --- a/src/org/lineageos/setupwizard/LocationSettingsActivity.java +++ b/src/org/lineageos/setupwizard/LocationSettingsActivity.java @@ -22,9 +22,6 @@ import android.os.Bundle; import android.os.UserHandle; import android.view.View; import android.widget.CheckBox; -import android.widget.TextView; - -import org.lineageos.setupwizard.util.SetupWizardUtils; public class LocationSettingsActivity extends BaseSetupWizardActivity { @@ -45,7 +42,7 @@ public class LocationSettingsActivity extends BaseSetupWizardActivity { View locationAccessView = findViewById(R.id.location); locationAccessView.setOnClickListener(v -> { mLocationManager.setLocationEnabledForUser(!mLocationAccess.isChecked(), - new UserHandle(UserHandle.USER_CURRENT)); + new UserHandle(UserHandle.USER_CURRENT)); mLocationAccess.setChecked(!mLocationAccess.isChecked()); }); } diff --git a/src/org/lineageos/setupwizard/MobileDataActivity.java b/src/org/lineageos/setupwizard/MobileDataActivity.java index b071273c..3a567b1d 100644 --- a/src/org/lineageos/setupwizard/MobileDataActivity.java +++ b/src/org/lineageos/setupwizard/MobileDataActivity.java @@ -64,7 +64,7 @@ public class MobileDataActivity extends BaseSetupWizardActivity { private final Runnable mDataConnectionReadyRunnable = this::onDataStateReady; - private PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener = + private final PhoneMonitor.SubscriptionStateListener mSubscriptionStateListener = new PhoneMonitor.SubscriptionStateListener() { @Override public void onServiceStateChanged(int subId, ServiceState serviceState) { @@ -95,11 +95,13 @@ public class MobileDataActivity extends BaseSetupWizardActivity { } @Override - public void onDefaultDataSubscriptionChanged(int subId) {} + public void onDefaultDataSubscriptionChanged(int subId) { + } @Override public void onDefaultDataSubscriptionChangeRequested(int currentSubId, - int newSubId) {} + int newSubId) { + } @Override 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 public void onClick(View view) { boolean checked = !mEnableMobileData.isChecked(); @@ -149,14 +151,12 @@ public class MobileDataActivity extends BaseSetupWizardActivity { mEnableDataRow = findViewById(R.id.data); mEnableDataRow.setOnClickListener(mEnableDataClickListener); mEnableMobileData = (Switch) findViewById(R.id.data_switch); - mSignalView = (ImageView) findViewById(R.id.signal); - mNameView = (TextView) findViewById(R.id.enable_data_title); + mSignalView = (ImageView) findViewById(R.id.signal); + mNameView = (TextView) findViewById(R.id.enable_data_title); updateDataConnectionStatus(); updateSignalStrength(); - } - @Override public void onResume() { super.onResume(); @@ -275,7 +275,7 @@ public class MobileDataActivity extends BaseSetupWizardActivity { private boolean hasService() { boolean retVal; if (mServiceState == null) { - mServiceState = TelephonyManager.from(this) + mServiceState = TelephonyManager.from(this) .getServiceStateForSubscriber(getDefaultSubscriptionId()); } if (mServiceState != null) { @@ -283,7 +283,7 @@ public class MobileDataActivity extends BaseSetupWizardActivity { // Some SIM cards are marketed as data-only and do not support voice service, and on // these SIM cards, we want to show signal bars for data service as well as the "no // service" or "emergency calls only" text that indicates that voice is not available. - switch(mServiceState.getVoiceRegState()) { + switch (mServiceState.getVoiceRegState()) { case ServiceState.STATE_POWER_OFF: retVal = false; break; diff --git a/src/org/lineageos/setupwizard/PartnerReceiver.java b/src/org/lineageos/setupwizard/PartnerReceiver.java index f768a72e..6a8eb1e3 100644 --- a/src/org/lineageos/setupwizard/PartnerReceiver.java +++ b/src/org/lineageos/setupwizard/PartnerReceiver.java @@ -1,5 +1,3 @@ -package org.lineageos.setupwizard; - /* * Copyright (C) 2016 The CyanogenMod Project * @@ -16,6 +14,8 @@ package org.lineageos.setupwizard; * limitations under the License. */ +package org.lineageos.setupwizard; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; diff --git a/src/org/lineageos/setupwizard/SetupWizardActivity.java b/src/org/lineageos/setupwizard/SetupWizardActivity.java index 5a716918..7d7ddfe3 100644 --- a/src/org/lineageos/setupwizard/SetupWizardActivity.java +++ b/src/org/lineageos/setupwizard/SetupWizardActivity.java @@ -55,7 +55,8 @@ public class SetupWizardActivity extends BaseSetupWizardActivity { if (isPrimaryUser()) { intent.putExtra(EXTRA_SCRIPT_URI, getString(R.string.lineage_wizard_script_uri)); } 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); startActivity(intent); diff --git a/src/org/lineageos/setupwizard/SetupWizardApp.java b/src/org/lineageos/setupwizard/SetupWizardApp.java index b0e55eb4..5982beff 100644 --- a/src/org/lineageos/setupwizard/SetupWizardApp.java +++ b/src/org/lineageos/setupwizard/SetupWizardApp.java @@ -17,7 +17,6 @@ package org.lineageos.setupwizard; - import android.app.Application; import android.app.StatusBarManager; import android.os.Bundle; @@ -31,19 +30,19 @@ import org.lineageos.setupwizard.util.SetupWizardUtils; public class SetupWizardApp extends Application { public static final String TAG = SetupWizardApp.class.getSimpleName(); - // Leave this off for release - public static final boolean DEBUG = false; - /* Verbose Logging */ + // Verbose logging public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE); public static final String ACTION_ACCESSIBILITY_SETTINGS = "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_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_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_NEXT = "com.android.wizard.NEXT"; public static final String ACTION_LOAD = "com.android.wizard.LOAD"; @@ -64,8 +63,8 @@ public class SetupWizardApp extends Application { public static final String UPDATE_RECOVERY_PROP = "persist.vendor.recovery_update"; public static final int REQUEST_CODE_SETUP_WIFI = 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_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; @@ -80,7 +79,7 @@ public class SetupWizardApp extends Application { private final Bundle mSettingsBundle = new Bundle(); private final Handler mHandler = new Handler(); - private final Runnable mRadioTimeoutRunnable = () -> mIsRadioReady = true; + private final Runnable mRadioTimeoutRunnable = () -> mIsRadioReady = true; @Override public void onCreate() { diff --git a/src/org/lineageos/setupwizard/SetupWizardExitActivity.java b/src/org/lineageos/setupwizard/SetupWizardExitActivity.java index baa822ff..629448b9 100644 --- a/src/org/lineageos/setupwizard/SetupWizardExitActivity.java +++ b/src/org/lineageos/setupwizard/SetupWizardExitActivity.java @@ -53,7 +53,7 @@ public class SetupWizardExitActivity extends BaseSetupWizardActivity { private void launchHome() { startActivity(new Intent("android.intent.action.MAIN") .addCategory("android.intent.category.HOME") - .addFlags(FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_CLEAR_TASK)); + .addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)); } } diff --git a/src/org/lineageos/setupwizard/SetupWizardExitService.java b/src/org/lineageos/setupwizard/SetupWizardExitService.java index 9b9c7338..6505ca44 100644 --- a/src/org/lineageos/setupwizard/SetupWizardExitService.java +++ b/src/org/lineageos/setupwizard/SetupWizardExitService.java @@ -16,7 +16,6 @@ package org.lineageos.setupwizard; - import static org.lineageos.setupwizard.SetupWizardApp.LOGV; import android.annotation.Nullable; diff --git a/src/org/lineageos/setupwizard/SimMissingActivity.java b/src/org/lineageos/setupwizard/SimMissingActivity.java index e7694259..1a52d855 100644 --- a/src/org/lineageos/setupwizard/SimMissingActivity.java +++ b/src/org/lineageos/setupwizard/SimMissingActivity.java @@ -44,7 +44,7 @@ public class SimMissingActivity extends BaseSetupWizardActivity { } final int simLocation = getResources().getInteger( R.integer.sim_image_type); - ImageView simLogo = ((ImageView)findViewById(R.id.sim_slot_image)); + ImageView simLogo = ((ImageView) findViewById(R.id.sim_slot_image)); switch (simLocation) { case SIM_SIDE: simLogo.setImageResource(R.drawable.sim_side); diff --git a/src/org/lineageos/setupwizard/SubBaseActivity.java b/src/org/lineageos/setupwizard/SubBaseActivity.java index 25b883cf..c28fa46a 100644 --- a/src/org/lineageos/setupwizard/SubBaseActivity.java +++ b/src/org/lineageos/setupwizard/SubBaseActivity.java @@ -16,7 +16,6 @@ package org.lineageos.setupwizard; - import static android.content.Intent.FLAG_ACTIVITY_FORWARD_RESULT; import static com.google.android.setupcompat.util.ResultCodes.RESULT_ACTIVITY_NOT_FOUND; diff --git a/src/org/lineageos/setupwizard/UpdateRecoveryActivity.java b/src/org/lineageos/setupwizard/UpdateRecoveryActivity.java index 4e990ede..2290b479 100644 --- a/src/org/lineageos/setupwizard/UpdateRecoveryActivity.java +++ b/src/org/lineageos/setupwizard/UpdateRecoveryActivity.java @@ -28,8 +28,8 @@ import android.view.View; import android.widget.CheckBox; import com.google.android.setupcompat.util.WizardManagerHelper; -import org.lineageos.setupwizard.util.SetupWizardUtils; +import org.lineageos.setupwizard.util.SetupWizardUtils; public class UpdateRecoveryActivity extends BaseSetupWizardActivity { diff --git a/src/org/lineageos/setupwizard/WelcomeActivity.java b/src/org/lineageos/setupwizard/WelcomeActivity.java index 9214803c..d550acaf 100644 --- a/src/org/lineageos/setupwizard/WelcomeActivity.java +++ b/src/org/lineageos/setupwizard/WelcomeActivity.java @@ -52,7 +52,8 @@ public class WelcomeActivity extends BaseSetupWizardActivity { } @Override - public void onBackPressed() {} + public void onBackPressed() { + } @Override protected int getLayoutResId() { diff --git a/src/org/lineageos/setupwizard/WifiSetupActivity.java b/src/org/lineageos/setupwizard/WifiSetupActivity.java index 151a1aa7..41325b27 100644 --- a/src/org/lineageos/setupwizard/WifiSetupActivity.java +++ b/src/org/lineageos/setupwizard/WifiSetupActivity.java @@ -30,13 +30,12 @@ public class WifiSetupActivity extends WrapperSubBaseActivity { public static final String TAG = WifiSetupActivity.class.getSimpleName(); - @Override protected void onStartSubactivity() { tryEnablingWifi(); Intent intent = new Intent(ACTION_SETUP_WIFI); if (SetupWizardUtils.hasLeanback(this)) { - intent.setComponent(SetupWizardUtils.mTvwifisettingsActivity); + intent.setComponent(SetupWizardUtils.sTvWifiSetupSettingsActivity); } intent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, true); intent.putExtra(EXTRA_PREFS_SET_BACK_TEXT, (String) null); diff --git a/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java b/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java index aa10d970..8757934d 100644 --- a/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java +++ b/src/org/lineageos/setupwizard/backup/RestoreIntroActivity.java @@ -17,6 +17,9 @@ 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.content.Intent; @@ -26,9 +29,6 @@ import org.lineageos.setupwizard.NavigationLayout; import org.lineageos.setupwizard.R; 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 { @Override diff --git a/src/org/lineageos/setupwizard/util/EnableAccessibilityController.java b/src/org/lineageos/setupwizard/util/EnableAccessibilityController.java index ccb6196a..f56433df 100644 --- a/src/org/lineageos/setupwizard/util/EnableAccessibilityController.java +++ b/src/org/lineageos/setupwizard/util/EnableAccessibilityController.java @@ -61,17 +61,20 @@ public class EnableAccessibilityController { // TODO: Fix these or remove these //String text = mContext.getString(R.string.continue_to_enable_accessibility); //mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null); - } break; + } + break; case MESSAGE_SPEAK_ENABLE_CANCELED: { //String text = mContext.getString(R.string.enable_accessibility_canceled); //mTts.speak(text, TextToSpeech.QUEUE_FLUSH, null); - } break; + } + break; case MESSAGE_ENABLE_ACCESSIBILITY: { enableAccessibility(); //mTone.play(); //mTts.speak(mContext.getString(R.string.accessibility_enabled), // TextToSpeech.QUEUE_FLUSH, null); - } break; + } + break; } } }; @@ -82,7 +85,6 @@ public class EnableAccessibilityController { private final IAccessibilityManager mAccessibilityManager = IAccessibilityManager .Stub.asInterface(ServiceManager.getService("accessibility")); - private final Context mContext; private final UserManager mUserManager; private final TextToSpeech mTts; diff --git a/src/org/lineageos/setupwizard/util/NetworkMonitor.java b/src/org/lineageos/setupwizard/util/NetworkMonitor.java index 9000a8ea..bbf5d26a 100644 --- a/src/org/lineageos/setupwizard/util/NetworkMonitor.java +++ b/src/org/lineageos/setupwizard/util/NetworkMonitor.java @@ -106,7 +106,7 @@ public class NetworkMonitor { ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); if (cm != null) { NetworkInfo ni = cm.getActiveNetworkInfo(); - boolean isConnected = ni != null ? ni.isConnected() : false; + boolean isConnected = ni != null && ni.isConnected(); if (isConnected && !mNetworkConnected) { onNetworkConnected(ni); } else if (!isConnected && mNetworkConnected) { diff --git a/src/org/lineageos/setupwizard/util/PhoneMonitor.java b/src/org/lineageos/setupwizard/util/PhoneMonitor.java index 9203eb35..c593613b 100644 --- a/src/org/lineageos/setupwizard/util/PhoneMonitor.java +++ b/src/org/lineageos/setupwizard/util/PhoneMonitor.java @@ -77,15 +77,15 @@ public class PhoneMonitor { public static final String TAG = PhoneMonitor.class.getSimpleName(); private static PhoneMonitor sInstance; - private Context mContext; - private TelephonyManager mTelephony; + private final Context mContext; + private final TelephonyManager mTelephony; private SubscriptionManager mSubscriptionManager; - private ArrayList mListeners = new ArrayList<>(); - private SparseArray mTrackers = new SparseArray<>(); + private final ArrayList mListeners = new ArrayList<>(); + private final SparseArray mTrackers = new SparseArray<>(); private int mChangingToDataSubId = -1; - private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { + private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) { @@ -134,14 +134,14 @@ public class PhoneMonitor { private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener = new OnSubscriptionsChangedListener() { - public void onSubscriptionsChanged() { - if (LOGV) { - Log.d(TAG, "Subscriptions changed"); - } - super.onSubscriptionsChanged(); - updatePhoneStateTrackers(); - } - }; + public void onSubscriptionsChanged() { + if (LOGV) { + Log.d(TAG, "Subscriptions changed"); + } + super.onSubscriptionsChanged(); + updatePhoneStateTrackers(); + } + }; public static void initInstance(Context context) { if (sInstance == null) { @@ -319,7 +319,7 @@ public class PhoneMonitor { public int getLteOnCdmaMode(int subId) { if (mTelephony == null || mTelephony.createForSubscriptionId(subId).getLteOnCdmaMode(subId) - == LTE_ON_CDMA_UNKNOWN) { + == LTE_ON_CDMA_UNKNOWN) { return TelephonyProperties.lte_on_cdma_device().orElse(LTE_ON_CDMA_UNKNOWN); } return mTelephony.createForSubscriptionId(subId).getLteOnCdmaMode(subId); @@ -489,10 +489,15 @@ public class PhoneMonitor { public interface SubscriptionStateListener { void onServiceStateChanged(int subId, ServiceState serviceState); + void onDataConnectionStateChanged(int subId, int state, int networkType); + void onDefaultDataSubscriptionChanged(int subId); + void onDefaultDataSubscriptionChangeRequested(int currentSubId, int newSubId); + void onSignalStrengthsChanged(int subId, SignalStrength signalStrength); + void onSimStateChanged(int subId, int simState); } diff --git a/src/org/lineageos/setupwizard/util/SetupWizardUtils.java b/src/org/lineageos/setupwizard/util/SetupWizardUtils.java index aea2135a..d29c9169 100644 --- a/src/org/lineageos/setupwizard/util/SetupWizardUtils.java +++ b/src/org/lineageos/setupwizard/util/SetupWizardUtils.java @@ -34,36 +34,34 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; -import android.content.res.Resources; import android.content.SharedPreferences; import android.content.pm.ComponentInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; +import android.content.res.Resources; import android.hardware.face.FaceManager; import android.hardware.fingerprint.FingerprintManager; +import android.net.ConnectivityManager; import android.os.Binder; import android.os.SystemProperties; import android.os.UserHandle; -import android.net.ConnectivityManager; import android.provider.Settings; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.util.Log; +import org.lineageos.internal.util.PackageManagerUtils; +import org.lineageos.setupwizard.BiometricActivity; import org.lineageos.setupwizard.BluetoothSetupActivity; import org.lineageos.setupwizard.ChooseDataSimActivity; -import org.lineageos.setupwizard.BiometricActivity; import org.lineageos.setupwizard.MobileDataActivity; import org.lineageos.setupwizard.SetupWizardApp; import org.lineageos.setupwizard.SimMissingActivity; -import org.lineageos.setupwizard.UpdateRecoveryActivity; import org.lineageos.setupwizard.WifiSetupActivity; import org.lineageos.setupwizard.wizardmanager.WizardManager; -import org.lineageos.internal.util.PackageManagerUtils; - import java.io.File; import java.util.ArrayList; 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 PROP_BUILD_DATE = "ro.build.date.utc"; - private SetupWizardUtils(){} + private SetupWizardUtils() { + } public static SharedPreferences getPrefs(Context context) { return context.getSharedPreferences("SetupWizardPrefs", MODE_PRIVATE); @@ -134,12 +133,13 @@ public class SetupWizardUtils { int res = updaterResources.getIdentifier( CONFIG_HIDE_RECOVERY_UPDATE, "bool", UPDATER_PACKAGE); featureHidden = updaterResources.getBoolean(res); - } catch (PackageManager.NameNotFoundException | Resources.NotFoundException ignored) { } + } catch (PackageManager.NameNotFoundException | Resources.NotFoundException ignored) { + } return !featureHidden; } public static boolean isRadioReady(Context context, ServiceState state) { - final SetupWizardApp setupWizardApp = (SetupWizardApp)context.getApplicationContext(); + final SetupWizardApp setupWizardApp = (SetupWizardApp) context.getApplicationContext(); if (setupWizardApp.isRadioReady()) { return true; } else { @@ -148,7 +148,6 @@ public class SetupWizardUtils { setupWizardApp.setRadioReady(ready); return ready; } - } public static boolean isOwner() { @@ -241,7 +240,7 @@ public class SetupWizardUtils { public static boolean isEthernetConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context. - getSystemService(Context.CONNECTIVITY_SERVICE); + getSystemService(Context.CONNECTIVITY_SERVICE); return (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_ETHERNET); @@ -307,8 +306,7 @@ public class SetupWizardUtils { if (!isMultiSimDevice() || singleSimInserted()) { disableComponent(context, ChooseDataSimActivity.class); } - if (!SetupWizardUtils.hasWifi(context) || - isEthernetConnected(context)) { + if (!hasWifi(context) || isEthernetConnected(context)) { disableComponent(context, WifiSetupActivity.class); } } @@ -327,7 +325,7 @@ public class SetupWizardUtils { intent.addCategory("android.intent.category.HOME"); intent.setPackage(context.getPackageName()); ComponentName comp = intent.resolveActivity(context.getPackageManager()); - if (SetupWizardApp.LOGV) { + if (LOGV) { Log.v(TAG, "resolveActivity for intent=" + intent + " returns " + comp); } return comp; @@ -358,7 +356,6 @@ public class SetupWizardUtils { COMPONENT_ENABLED_STATE_DEFAULT); } - public static void setComponentEnabledState(Context context, ComponentName componentName, int enabledState) { context.getPackageManager().setComponentEnabledSetting(componentName, @@ -403,12 +400,11 @@ public class SetupWizardUtils { return componentNames; } - - public static final ComponentName mTvwifisettingsActivity = + public static final ComponentName sTvWifiSetupSettingsActivity = new ComponentName("com.android.tv.settings", "com.android.tv.settings.connectivity.setup.WifiSetupActivity"); - public static final ComponentName mTvAddAccessorySettingsActivity = + public static final ComponentName sTvAddAccessorySettingsActivity = new ComponentName("com.android.tv.settings", "com.android.tv.settings.accessories.AddAccessoryActivity"); diff --git a/src/org/lineageos/setupwizard/widget/LocalePicker.java b/src/org/lineageos/setupwizard/widget/LocalePicker.java index 42356db5..c0c05c17 100644 --- a/src/org/lineageos/setupwizard/widget/LocalePicker.java +++ b/src/org/lineageos/setupwizard/widget/LocalePicker.java @@ -16,8 +16,6 @@ package org.lineageos.setupwizard.widget; -import org.lineageos.setupwizard.R; - import android.annotation.Widget; import android.content.Context; import android.content.res.ColorStateList; @@ -57,17 +55,18 @@ import android.widget.LinearLayout; import android.widget.Scroller; import android.widget.TextView; +import libcore.icu.LocaleData; + +import org.lineageos.setupwizard.R; + import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; -import libcore.icu.LocaleData; - /** - * A widget that enables the user to select a number form a predefined range. - * There are two flavors of this widget and which one is presented to the user - * depends on the current theme. + * A widget that enables the user to select a number form a predefined range. There are two flavors + * of this widget and which one is presented to the user depends on the current theme. *
    *
  • * 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; /** - * Use a custom NumberPicker formatting callback to use two-digit minutes - * strings like "01". Keeping a static formatter etc. is the most efficient - * way to do this; it avoids creating temporary objects on every call to - * format(). + * Use a custom NumberPicker formatting callback to use two-digit minutes strings like "01". + * Keeping a static formatter etc. is the most efficient way to do this; it avoids creating + * temporary objects on every call to format(). */ private static class TwoDigitFormatter implements LocalePicker.Formatter { final StringBuilder mBuilder = new StringBuilder(); @@ -315,7 +313,8 @@ public class LocalePicker extends LinearLayout { 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; @@ -355,8 +354,7 @@ public class LocalePicker extends LinearLayout { private SetSelectionCommand mSetSelectionCommand; /** - * Handle to the reusable command for changing the current value from long - * press by one. + * Handle to the reusable command for changing the current value from long press by one. */ private ChangeCurrentByOneFromLongPressCommand mChangeCurrentByOneFromLongPressCommand; @@ -388,17 +386,17 @@ public class LocalePicker extends LinearLayout { /** * @see android.view.ViewConfiguration#getScaledTouchSlop() */ - private int mTouchSlop; + private final int mTouchSlop; /** * @see android.view.ViewConfiguration#getScaledMinimumFlingVelocity() */ - private int mMinimumFlingVelocity; + private final int mMinimumFlingVelocity; /** * @see android.view.ViewConfiguration#getScaledMaximumFlingVelocity() */ - private int mMaximumFlingVelocity; + private final int mMaximumFlingVelocity; /** * Flag whether the selector should wrap around. @@ -431,8 +429,8 @@ public class LocalePicker extends LinearLayout { private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE; /** - * Flag whether to ignore move events - we ignore such when we show in IME - * to prevent the content from scrolling. + * Flag whether to ignore move events - we ignore such when we show in IME to prevent the + * content from scrolling. */ private boolean mIngonreMoveEvents; @@ -504,28 +502,26 @@ public class LocalePicker extends LinearLayout { /** * 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. */ - 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. */ - public static int SCROLL_STATE_FLING = 2; + int SCROLL_STATE_FLING = 2; /** * Callback invoked while the number picker scroll state has changed. * - * @param view The view whose scroll state is being reported. - * @param scrollState The current scroll state. One of - * {@link #SCROLL_STATE_IDLE}, - * {@link #SCROLL_STATE_TOUCH_SCROLL} or - * {@link #SCROLL_STATE_IDLE}. + * @param view The view whose scroll state is being reported. + * @param scrollState The current scroll state. One of {@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. * @return A formatted string representation. */ - public String format(int value); + String format(int value); } /** @@ -555,7 +551,7 @@ public class LocalePicker extends LinearLayout { * Create a new number picker. * * @param context The application environment. - * @param attrs A collection of attributes. + * @param attrs A collection of attributes. */ public LocalePicker(Context context, AttributeSet attrs) { this(context, attrs, R.attr.localePickerStyle); @@ -564,15 +560,16 @@ public class LocalePicker extends LinearLayout { /** * Create a new number picker * - * @param context the application environment. - * @param attrs a collection of attributes. + * @param context the application environment. + * @param attrs a collection of attributes. * @param defStyle The default style to apply to this view. */ public LocalePicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); sSelectorWheelItemCount = context.getResources().getInteger(R.integer.local_picker_items); - sSelectorMiddleItemIndex = context.getResources().getInteger(R.integer.local_picker_items)/2; - mSelectorIndices= new int[sSelectorWheelItemCount]; + sSelectorMiddleItemIndex = context.getResources().getInteger(R.integer.local_picker_items) + / 2; + mSelectorIndices = new int[sSelectorWheelItemCount]; // process style attributes TypedArray attributesArray = context.obtainStyledAttributes( attrs, R.styleable.LocalePicker, defStyle, 0); @@ -641,11 +638,7 @@ public class LocalePicker extends LinearLayout { public void onClick(View v) { hideSoftInput(); mInputText.clearFocus(); - if (v.getId() == R.id.lp__increment) { - changeValueByOne(true); - } else { - changeValueByOne(false); - } + changeValueByOne(v.getId() == R.id.lp__increment); } }; @@ -653,11 +646,7 @@ public class LocalePicker extends LinearLayout { public boolean onLongClick(View v) { hideSoftInput(); mInputText.clearFocus(); - if (v.getId() == R.id.lp__increment) { - postChangeCurrentByOneFromLongPress(true, 0); - } else { - postChangeCurrentByOneFromLongPress(false, 0); - } + postChangeCurrentByOneFromLongPress(v.getId() == R.id.lp__increment, 0); return true; } }; @@ -692,8 +681,8 @@ public class LocalePicker extends LinearLayout { } } }); - mInputText.setFilters(new InputFilter[] { - new InputTextFilter() + mInputText.setFilters(new InputFilter[]{ + new InputTextFilter() }); mInputText.setRawInputType(InputType.TYPE_CLASS_NUMBER); @@ -778,9 +767,9 @@ public class LocalePicker extends LinearLayout { } /** - * Move to the final position of a scroller. Ensures to force finish the scroller - * and if it is not at its final position a scroll of the selector wheel is - * performed to fast forward to the final position. + * Move to the final position of a scroller. Ensures to force finish the scroller and if it is + * not at its final position a scroll of the selector wheel is performed to fast forward to the + * final position. * * @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. @@ -886,7 +875,8 @@ public class LocalePicker extends LinearLayout { invalidate(); } mLastDownOrMoveEventY = currentMoveY; - } break; + } + break; case MotionEvent.ACTION_UP: { removeBeginSoftInputCommand(); removeChangeCurrentByOneFromLongPress(); @@ -925,7 +915,8 @@ public class LocalePicker extends LinearLayout { } mVelocityTracker.recycle(); mVelocityTracker = null; - } break; + } + break; } return true; } @@ -1008,7 +999,7 @@ public class LocalePicker extends LinearLayout { } final int action = event.getActionMasked(); AccessibilityNodeProviderImpl provider = - (AccessibilityNodeProviderImpl) getAccessibilityNodeProvider(); + (AccessibilityNodeProviderImpl) getAccessibilityNodeProvider(); switch (action) { case MotionEvent.ACTION_HOVER_ENTER: { provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, @@ -1016,7 +1007,8 @@ public class LocalePicker extends LinearLayout { mLastHoveredChildVirtualViewId = hoveredVirtualViewId; provider.performAction(hoveredVirtualViewId, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); - } break; + } + break; case MotionEvent.ACTION_HOVER_MOVE: { if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId && mLastHoveredChildVirtualViewId != View.NO_ID) { @@ -1029,12 +1021,14 @@ public class LocalePicker extends LinearLayout { provider.performAction(hoveredVirtualViewId, AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); } - } break; + } + break; case MotionEvent.ACTION_HOVER_EXIT: { provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId, AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); mLastHoveredChildVirtualViewId = View.NO_ID; - } break; + } + break; } } return false; @@ -1133,13 +1127,13 @@ public class LocalePicker extends LinearLayout { /** * Set the formatter to be used for formatting the current value. *

    - * Note: If you have provided alternative values for the values this - * formatter is never invoked. + * Note: If you have provided alternative values for the values this formatter is never + * invoked. *

    * - * @param formatter The formatter object. If formatter is null, - * {@link String#valueOf(int)} will be used. - *@see #setDisplayedValues(String[]) + * @param formatter The formatter object. If formatter is null, {@link + * String#valueOf(int)} will be used. + * @see #setDisplayedValues(String[]) */ public void setFormatter(Formatter formatter) { if (formatter == mFormatter) { @@ -1153,24 +1147,24 @@ public class LocalePicker extends LinearLayout { /** * Set the current value for the number picker. *

    - * If the argument is less than the {@link LocalePicker#getMinValue()} and - * {@link LocalePicker#getWrapSelectorWheel()} is false the - * current value is set to the {@link LocalePicker#getMinValue()} value. + * If the argument is less than the {@link LocalePicker#getMinValue()} and {@link + * LocalePicker#getWrapSelectorWheel()} is false the current value is set to the + * {@link LocalePicker#getMinValue()} value. *

    *

    - * If the argument is less than the {@link LocalePicker#getMinValue()} and - * {@link LocalePicker#getWrapSelectorWheel()} is true the - * current value is set to the {@link LocalePicker#getMaxValue()} value. + * If the argument is less than the {@link LocalePicker#getMinValue()} and {@link + * LocalePicker#getWrapSelectorWheel()} is true the current value is set to the + * {@link LocalePicker#getMaxValue()} value. *

    *

    - * If the argument is less than the {@link LocalePicker#getMaxValue()} and - * {@link LocalePicker#getWrapSelectorWheel()} is false the - * current value is set to the {@link LocalePicker#getMaxValue()} value. + * If the argument is less than the {@link LocalePicker#getMaxValue()} and {@link + * LocalePicker#getWrapSelectorWheel()} is false the current value is set to the + * {@link LocalePicker#getMaxValue()} value. *

    *

    - * If the argument is less than the {@link LocalePicker#getMaxValue()} and - * {@link LocalePicker#getWrapSelectorWheel()} is true the - * current value is set to the {@link LocalePicker#getMinValue()} value. + * If the argument is less than the {@link LocalePicker#getMaxValue()} and {@link + * LocalePicker#getWrapSelectorWheel()} is true the current value is set to the + * {@link LocalePicker#getMinValue()} 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. * * @return True if the selector wheel wraps. - * * @see #getMinValue() * @see #getMaxValue() */ @@ -1265,18 +1258,17 @@ public class LocalePicker extends LinearLayout { } /** - * Sets whether the selector wheel shown during flinging/scrolling should - * wrap around the {@link LocalePicker#getMinValue()} and - * {@link LocalePicker#getMaxValue()} values. + * Sets whether the selector wheel shown during flinging/scrolling should wrap around the {@link + * LocalePicker#getMinValue()} and {@link LocalePicker#getMaxValue()} values. *

    - * By default if the range (max - min) is more than the number of items shown - * on the selector wheel the selector wheel wrapping is enabled. + * By default if the range (max - min) is more than the number of items shown on the selector + * wheel the selector wheel wrapping is enabled. *

    *

    * Note: If the number of items, i.e. the range ( - * {@link #getMaxValue()} - {@link #getMinValue()}) is less than - * the number of items shown on the selector wheel, the selector wheel will - * not wrap. Hence, in such a case calling this method is a NOP. + * {@link #getMaxValue()} - {@link #getMinValue()}) is less than the number of items shown on + * the selector wheel, the selector wheel will not wrap. Hence, in such a case calling this + * method is a NOP. *

    * * @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 - * the up and down buttons are long pressed respectively. + * Sets the speed at which the numbers be incremented and decremented when the up and down + * buttons are long pressed respectively. *

    * The default value is 300 ms. *

    * - * @param intervalMillis The speed (in milliseconds) at which the numbers - * will be incremented and decremented. + * @param intervalMillis The speed (in milliseconds) at which the numbers will be incremented + * and decremented. */ public void setOnLongPressUpdateInterval(long intervalMillis) { mLongPressUpdateInterval = intervalMillis; @@ -1325,10 +1317,10 @@ public class LocalePicker extends LinearLayout { * * @param minValue The min value inclusive. * - * Note: The length of the displayed values array - * set via {@link #setDisplayedValues(String[])} must be equal to the - * range of selectable numbers which is equal to - * {@link #getMaxValue()} - {@link #getMinValue()} + 1. + * Note: The length of the displayed values array + * set via {@link #setDisplayedValues(String[])} must be equal to the range of + * selectable numbers which is equal to {@link #getMaxValue()} - {@link + * #getMinValue()} + 1. */ public void setMinValue(int minValue) { if (mMinValue == minValue) { @@ -1363,10 +1355,10 @@ public class LocalePicker extends LinearLayout { * * @param maxValue The max value inclusive. * - * Note: The length of the displayed values array - * set via {@link #setDisplayedValues(String[])} must be equal to the - * range of selectable numbers which is equal to - * {@link #getMaxValue()} - {@link #getMinValue()} + 1. + * Note: The length of the displayed values array + * set via {@link #setDisplayedValues(String[])} must be equal to the range of + * selectable numbers which is equal to {@link #getMaxValue()} - {@link + * #getMinValue()} + 1. */ public void setMaxValue(int maxValue) { if (mMaxValue == maxValue) { @@ -1401,9 +1393,9 @@ public class LocalePicker extends LinearLayout { * * @param displayedValues The displayed values. * - * Note: The length of the displayed values array - * must be equal to the range of selectable numbers which is equal to - * {@link #getMaxValue()} - {@link #getMinValue()} + 1. + * Note: The length of the displayed values array + * must be equal to the range of selectable numbers which is equal to + * {@link #getMaxValue()} - {@link #getMinValue()} + 1. */ public void setDisplayedValues(String[] displayedValues) { if (mDisplayedValues == displayedValues) { @@ -1518,7 +1510,7 @@ public class LocalePicker extends LinearLayout { * Makes a measure spec that tries greedily to use the max value. * * @param measureSpec The measure spec. - * @param maxSize The max value for the size. + * @param maxSize The max value for the size. * @return A measure spec greedily imposing the max size. */ private int makeMeasureSpec(int measureSpec, int maxSize) { @@ -1540,13 +1532,12 @@ public class LocalePicker extends LinearLayout { } /** - * Utility to reconcile a desired size and state, with constraints imposed - * by a MeasureSpec. Tries to respect the min size, unless a different size - * is imposed by the constraints. + * Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. + * Tries to respect the min size, unless a different size is imposed by the constraints. * - * @param minSize The minimal desired size. + * @param minSize The minimal desired size. * @param measuredSize The currently measured size. - * @param measureSpec The current measure spec. + * @param measureSpec The current measure spec. * @return The resolved size and state. */ private int resolveSizeAndStateRespectingMinSize( @@ -1560,8 +1551,7 @@ public class LocalePicker extends LinearLayout { } /** - * Resets the selector indices and clear the cached string representation of - * these indices. + * Resets the selector indices and clear the cached string representation of these indices. */ private void initializeSelectorWheelIndices() { mSelectorIndexToStringCache.clear(); @@ -1580,7 +1570,7 @@ public class LocalePicker extends LinearLayout { /** * Sets the current value of this NumberPicker. * - * @param current The new value of the NumberPicker. + * @param current The new value of the NumberPicker. * @param notifyChange Whether to notify if the current value changed. */ private void setValueInternal(int current, boolean notifyChange) { @@ -1605,13 +1595,12 @@ public class LocalePicker extends LinearLayout { } /** - * Changes the current value by one which is increment or - * decrement based on the passes argument. - * decrement the current value. + * Changes the current value by one which is increment or decrement based on the passes + * argument. decrement the current value. * * @param increment True to increment, false to decrement. */ - private void changeValueByOne(boolean increment) { + private void changeValueByOne(boolean increment) { if (mHasSelectorWheel) { mInputText.setVisibility(View.INVISIBLE); if (!moveToFinalScrollerPosition(mFlingScroller)) { @@ -1712,8 +1701,8 @@ public class LocalePicker extends LinearLayout { } /** - * Increments the selectorIndices whose string representations - * will be displayed in the selector. + * Increments the selectorIndices whose string representations will be displayed in + * the selector. */ private void incrementSelectorIndices(int[] selectorIndices) { for (int i = 0; i < selectorIndices.length - 1; i++) { @@ -1728,8 +1717,8 @@ public class LocalePicker extends LinearLayout { } /** - * Decrements the selectorIndices whose string representations - * will be displayed in the selector. + * Decrements the selectorIndices whose string representations will be displayed in + * the selector. */ private void decrementSelectorIndices(int[] selectorIndices) { 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 - * selectorIndex to avoid multiple instantiations of the same string. + * Ensures we have a cached string representation of the given selectorIndex to + * avoid multiple instantiations of the same string. */ private void ensureCachedScrollSelectorValue(int selectorIndex) { SparseArray cache = mSelectorIndexToStringCache; @@ -1777,16 +1766,15 @@ public class LocalePicker extends LinearLayout { updateInputTextView(); } else { // Check the new value and ensure it's in range - int current = getSelectedPos(str.toString()); + int current = getSelectedPos(str); setValueInternal(current, true); } } /** - * Updates the view of this NumberPicker. If displayValues were specified in - * the string corresponding to the index specified by the current value will - * be returned. Otherwise, the formatter specified in {@link #setFormatter} - * will be used to format the number. + * Updates the view of this NumberPicker. If displayValues were specified in the string + * corresponding to the index specified by the current value will be returned. Otherwise, the + * formatter specified in {@link #setFormatter} will be used to format the number. * * @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 - * NumberPicker. + * Notifies the listener, if registered, of a change of the value of this NumberPicker. */ private void notifyChange(int previous, int current) { 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 - * long press. + * Posts a command for beginning an edit of the current value via IME on long press. */ private void postBeginSoftInputOnLongPressCommand() { if (mBeginSoftInputOnLongPressCommand == null) { @@ -1929,7 +1915,7 @@ public class LocalePicker extends LinearLayout { /** * The numbers accepted by the input text's {@link android.view.LayoutInflater.Filter} */ - private static final char[] DIGIT_CHARACTERS = new char[] { + private static final char[] DIGIT_CHARACTERS = new char[]{ // Latin digits are the common case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // Arabic-Indic @@ -1941,8 +1927,8 @@ public class LocalePicker extends LinearLayout { }; /** - * Filter for accepting only valid indices or prefixes of the string - * representation of valid indices. + * Filter for accepting only valid indices or prefixes of the string representation of valid + * indices. */ class InputTextFilter extends NumberKeyListener { @@ -1993,7 +1979,7 @@ public class LocalePicker extends LinearLayout { } String result = String.valueOf(dest.subSequence(0, dstart)) + filtered + dest.subSequence(dend, dest.length()); - String str = String.valueOf(result).toLowerCase(); + String str = result.toLowerCase(); for (String val : mDisplayedValues) { String valLowerCase = val.toLowerCase(); 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 - * middle element is in the middle of the widget. + * Ensures that the scroll wheel is adjusted i.e. there is no offset and the middle element is + * in the middle of the widget. * * @return Whether an adjustment has been made. */ @@ -2073,13 +2059,15 @@ public class LocalePicker extends LinearLayout { case BUTTON_INCREMENT: { mIncrementVirtualButtonPressed = true; invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); - } break; + } + break; case BUTTON_DECREMENT: { mDecrementVirtualButtonPressed = true; invalidate(0, 0, mRight, mTopSelectionDividerTop); } } - } break; + } + break; case MODE_TAPPED: { switch (mManagedButton) { case BUTTON_INCREMENT: { @@ -2089,7 +2077,8 @@ public class LocalePicker extends LinearLayout { } mIncrementVirtualButtonPressed ^= true; invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); - } break; + } + break; case BUTTON_DECREMENT: { if (!mDecrementVirtualButtonPressed) { LocalePicker.this.postDelayed(this, @@ -2099,7 +2088,8 @@ public class LocalePicker extends LinearLayout { invalidate(0, 0, mRight, mTopSelectionDividerTop); } } - } break; + } + break; } } } @@ -2186,7 +2176,7 @@ public class LocalePicker extends LinearLayout { public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId) { switch (virtualViewId) { case View.NO_ID: - return createAccessibilityNodeInfoForNumberPicker( mScrollX, mScrollY, + return createAccessibilityNodeInfoForNumberPicker(mScrollX, mScrollY, mScrollX + (mRight - mLeft), mScrollY + (mBottom - mTop)); case VIRTUAL_VIEW_ID_DECREMENT: return createAccessibilityNodeInfoForVirtualButton(VIRTUAL_VIEW_ID_DECREMENT, @@ -2247,7 +2237,8 @@ public class LocalePicker extends LinearLayout { requestAccessibilityFocus(); return true; } - } return false; + } + return false; case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { if (mAccessibilityFocusedView == virtualViewId) { mAccessibilityFocusedView = UNDEFINED; @@ -2262,23 +2253,27 @@ public class LocalePicker extends LinearLayout { changeValueByOne(true); return true; } - } return false; + } + return false; case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD: { if (LocalePicker.this.isEnabled() && (getWrapSelectorWheel() || getValue() > getMinValue())) { changeValueByOne(false); return true; } - } return false; + } + return false; } - } break; + } + break; case VIRTUAL_VIEW_ID_INPUT: { switch (action) { case AccessibilityNodeInfo.ACTION_FOCUS: { if (LocalePicker.this.isEnabled() && !mInputText.isFocused()) { return mInputText.requestFocus(); } - } break; + } + break; case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: { if (LocalePicker.this.isEnabled() && mInputText.isFocused()) { mInputText.clearFocus(); @@ -2301,8 +2296,9 @@ public class LocalePicker extends LinearLayout { mInputText.invalidate(); return true; } - } return false; - case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { + } + return false; + case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { if (mAccessibilityFocusedView == virtualViewId) { mAccessibilityFocusedView = UNDEFINED; sendAccessibilityEventForVirtualView(virtualViewId, @@ -2310,12 +2306,14 @@ public class LocalePicker extends LinearLayout { mInputText.invalidate(); return true; } - } return false; + } + return false; default: { return mInputText.performAccessibilityAction(action, arguments); } } - } return false; + } + return false; case VIRTUAL_VIEW_ID_INCREMENT: { switch (action) { case AccessibilityNodeInfo.ACTION_CLICK: { @@ -2325,7 +2323,8 @@ public class LocalePicker extends LinearLayout { AccessibilityEvent.TYPE_VIEW_CLICKED); return true; } - } return false; + } + return false; case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: { if (mAccessibilityFocusedView != virtualViewId) { mAccessibilityFocusedView = virtualViewId; @@ -2334,8 +2333,9 @@ public class LocalePicker extends LinearLayout { invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); return true; } - } return false; - case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { + } + return false; + case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { if (mAccessibilityFocusedView == virtualViewId) { mAccessibilityFocusedView = UNDEFINED; sendAccessibilityEventForVirtualView(virtualViewId, @@ -2343,20 +2343,24 @@ public class LocalePicker extends LinearLayout { invalidate(0, mBottomSelectionDividerBottom, mRight, mBottom); return true; } - } return false; + } + return false; } - } return false; + } + return false; case VIRTUAL_VIEW_ID_DECREMENT: { switch (action) { case AccessibilityNodeInfo.ACTION_CLICK: { if (LocalePicker.this.isEnabled()) { - final boolean increment = (virtualViewId == VIRTUAL_VIEW_ID_INCREMENT); + final boolean increment = + (virtualViewId == VIRTUAL_VIEW_ID_INCREMENT); LocalePicker.this.changeValueByOne(increment); sendAccessibilityEventForVirtualView(virtualViewId, AccessibilityEvent.TYPE_VIEW_CLICKED); return true; } - } return false; + } + return false; case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: { if (mAccessibilityFocusedView != virtualViewId) { mAccessibilityFocusedView = virtualViewId; @@ -2365,8 +2369,9 @@ public class LocalePicker extends LinearLayout { invalidate(0, 0, mRight, mTopSelectionDividerTop); return true; } - } return false; - case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { + } + return false; + case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { if (mAccessibilityFocusedView == virtualViewId) { mAccessibilityFocusedView = UNDEFINED; sendAccessibilityEventForVirtualView(virtualViewId, @@ -2374,9 +2379,11 @@ public class LocalePicker extends LinearLayout { invalidate(0, 0, mRight, mTopSelectionDividerTop); return true; } - } return false; + } + return false; } - } return false; + } + return false; } return super.performAction(virtualViewId, action, arguments); } @@ -2388,16 +2395,19 @@ public class LocalePicker extends LinearLayout { sendAccessibilityEventForVirtualButton(virtualViewId, eventType, getVirtualDecrementButtonText()); } - } break; + } + break; case VIRTUAL_VIEW_ID_INPUT: { sendAccessibilityEventForVirtualText(eventType); - } break; + } + break; case VIRTUAL_VIEW_ID_INCREMENT: { if (hasVirtualIncrementButton()) { sendAccessibilityEventForVirtualButton(virtualViewId, eventType, getVirtualIncrementButtonText()); } - } break; + } + break; } } @@ -2430,10 +2440,11 @@ public class LocalePicker extends LinearLayout { case VIRTUAL_VIEW_ID_DECREMENT: { String text = getVirtualDecrementButtonText(); if (!TextUtils.isEmpty(text) - && text.toString().toLowerCase().contains(searchedLowerCase)) { + && text.toLowerCase().contains(searchedLowerCase)) { outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_DECREMENT)); } - } return; + } + return; case VIRTUAL_VIEW_ID_INPUT: { CharSequence text = mInputText.getText(); if (!TextUtils.isEmpty(text) && @@ -2447,14 +2458,16 @@ public class LocalePicker extends LinearLayout { outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INPUT)); return; } - } break; + } + break; case VIRTUAL_VIEW_ID_INCREMENT: { String text = getVirtualIncrementButtonText(); if (!TextUtils.isEmpty(text) - && text.toString().toLowerCase().contains(searchedLowerCase)) { + && text.toLowerCase().contains(searchedLowerCase)) { outResult.add(createAccessibilityNodeInfo(VIRTUAL_VIEW_ID_INCREMENT)); } - } return; + } + return; } } @@ -2534,7 +2547,7 @@ public class LocalePicker extends LinearLayout { info.setScrollable(true); final float applicationScale = - getContext().getResources().getCompatibilityInfo().applicationScale; + getContext().getResources().getCompatibilityInfo().applicationScale; Rect boundsInParent = mTempRect; boundsInParent.set(left, top, right, bottom); diff --git a/src/org/lineageos/setupwizard/widget/ScrimInsetsFrameLayout.java b/src/org/lineageos/setupwizard/widget/ScrimInsetsFrameLayout.java index 9ae659b6..bf715faa 100644 --- a/src/org/lineageos/setupwizard/widget/ScrimInsetsFrameLayout.java +++ b/src/org/lineageos/setupwizard/widget/ScrimInsetsFrameLayout.java @@ -29,14 +29,15 @@ 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). + * 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 Rect mTempRect = new Rect(); + private final Rect mTempRect = new Rect(); private OnInsetsCallback mOnInsetsCallback; 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 - * {@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. + * 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 static interface OnInsetsCallback { - public void onInsetsChanged(Rect insets); + public interface OnInsetsCallback { + void onInsetsChanged(Rect insets); } } diff --git a/src/org/lineageos/setupwizard/wizardmanager/WizardAction.java b/src/org/lineageos/setupwizard/wizardmanager/WizardAction.java index f719e279..73e263ec 100644 --- a/src/org/lineageos/setupwizard/wizardmanager/WizardAction.java +++ b/src/org/lineageos/setupwizard/wizardmanager/WizardAction.java @@ -63,7 +63,7 @@ public class WizardAction implements Parcelable { Intent intent = null; try { intent = Intent.parseUri(mUri, FLAG_GRANT_READ_URI_PERMISSION); - } catch(URISyntaxException e) { + } catch (URISyntaxException e) { Log.e(TAG, "Bad URI: " + mUri); } return intent; @@ -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 { String id = parser.getAttributeValue(null, WizardScript.ATTR_ID); String uri = parser.getAttributeValue(WizardScript.WIZARD_SCRIPT_NAMESPACE, diff --git a/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java b/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java index 33ec2044..317d5207 100644 --- a/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java +++ b/src/org/lineageos/setupwizard/wizardmanager/WizardManager.java @@ -17,7 +17,6 @@ package org.lineageos.setupwizard.wizardmanager; - import static org.lineageos.setupwizard.SetupWizardApp.ACTION_LOAD; import static org.lineageos.setupwizard.SetupWizardApp.ACTION_NEXT; 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.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.app.Activity; import android.content.Context; @@ -39,15 +32,19 @@ import android.content.pm.PackageManager; import android.os.Bundle; 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 { private static final String TAG = WizardManager.class.getSimpleName(); - private static HashMap sWizardScripts = new HashMap(); - + private static final HashMap sWizardScripts = new HashMap(); @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -93,13 +90,13 @@ public class WizardManager extends Activity { private void doAction(String scriptUri, WizardAction action, Intent extras) { Intent intent = action.getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - if(LOGV) { + if (LOGV) { Log.v(TAG, "doAction scriptUri=" + scriptUri + " extras=" + extras + " intent=" + intent + " extras2=" + intent.getExtras() + " action=" + action); } addExtras(intent); - if(extras != null) { + if (extras != null) { intent.putExtras(extras); } @@ -111,15 +108,15 @@ public class WizardManager extends Activity { private void load(String scriptUri, Intent extras) { WizardScript wizardScript = getWizardScript(this, scriptUri); WizardAction wizardAction; - for(wizardAction = wizardScript.getFirstAction(); - wizardAction != null; - wizardAction = wizardScript.getNextAction(wizardAction.getId(), - ResultCodes.RESULT_ACTIVITY_NOT_FOUND)) { + for (wizardAction = wizardScript.getFirstAction(); + wizardAction != null; + wizardAction = wizardScript.getNextAction(wizardAction.getId(), + ResultCodes.RESULT_ACTIVITY_NOT_FOUND)) { if (isActionAvailable(this, wizardAction)) { break; } - if(LOGV) { + if (LOGV) { Log.v(TAG, "load action not available " + wizardAction); } } @@ -134,20 +131,20 @@ public class WizardManager extends Activity { } private void next(String scriptUri, String actionId, int resultCode, Intent extras) { - if(LOGV) { + if (LOGV) { Log.v(TAG, "next actionId=" + actionId + " resultCode=" + resultCode); } WizardAction wizardAction = checkNextAction(this, scriptUri, actionId, resultCode); if (wizardAction != null) { doAction(scriptUri, wizardAction, extras); - } else { + } else { exit(scriptUri); } } private void exit(String scriptUri) { - if(LOGV) { + if (LOGV) { Log.v(TAG, "exit scriptUri=" + scriptUri); } WizardManager.sWizardScripts.remove(scriptUri); @@ -156,22 +153,22 @@ public class WizardManager extends Activity { private static WizardAction checkNextAction(Context context, String scriptUri, String actionId, int resultCode) { - if(LOGV) { + if (LOGV) { Log.v(TAG, "checkNextAction scriptUri=" + scriptUri + " actionId=" + actionId + " resultCode=" + resultCode); } WizardScript wizardScript = getWizardScript(context, scriptUri); WizardAction wizardAction; - for ( wizardAction = wizardScript.getNextAction(actionId, resultCode); - wizardAction != null; - wizardAction = wizardScript.getNextAction(wizardAction.getId(), - ResultCodes.RESULT_ACTIVITY_NOT_FOUND)) { + for (wizardAction = wizardScript.getNextAction(actionId, resultCode); + wizardAction != null; + wizardAction = wizardScript.getNextAction(wizardAction.getId(), + ResultCodes.RESULT_ACTIVITY_NOT_FOUND)) { if (WizardManager.isActionAvailable(context, wizardAction)) { break; } - if(LOGV) { + if (LOGV) { Log.v(TAG, "checkNextAction action not available " + wizardAction); } } @@ -188,11 +185,8 @@ public class WizardManager extends Activity { } private static boolean isIntentAvailable(Context context, Intent intent) { - if (context.getPackageManager().queryIntentActivities(intent, - PackageManager.MATCH_DEFAULT_ONLY).size() > 0) { - return true; - } - return false; + return context.getPackageManager().queryIntentActivities(intent, + PackageManager.MATCH_DEFAULT_ONLY).size() > 0; } private static WizardScript getWizardScript(Context context, String scriptUri) { diff --git a/src/org/lineageos/setupwizard/wizardmanager/WizardScript.java b/src/org/lineageos/setupwizard/wizardmanager/WizardScript.java index ed234069..5521be2f 100644 --- a/src/org/lineageos/setupwizard/wizardmanager/WizardScript.java +++ b/src/org/lineageos/setupwizard/wizardmanager/WizardScript.java @@ -19,11 +19,6 @@ package org.lineageos.setupwizard.wizardmanager; 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.content.ContentResolver; import android.content.Context; @@ -33,6 +28,11 @@ import android.os.Parcelable; import android.util.Log; 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.IOException; import java.io.InputStream; @@ -88,12 +88,12 @@ public class WizardScript implements Parcelable { public String getNextActionId(String currentActionId, int resultCode) { String nextActionId = null; - if(resultCode != Activity.RESULT_CANCELED) { + if (resultCode != Activity.RESULT_CANCELED) { WizardAction wizardAction = mActions.get(currentActionId); if (LOGV) { StringBuilder currentAction = new StringBuilder().append("getNextActionId(").append(currentActionId) - .append(",").append(resultCode).append(")").append(" current uri="); + .append(",").append(resultCode).append(")").append(" current uri="); String uri = wizardAction == null ? "n/a" : wizardAction.getUri(); Log.v(TAG, currentAction.append(uri).toString()); } @@ -139,8 +139,8 @@ public class WizardScript implements Parcelable { try { ContentResolver.OpenResourceIdResult openResourceIdResult = context.getContentResolver().getResourceId(Uri - .parse(uriString)); - if("xml".equals(openResourceIdResult.r.getResourceTypeName(openResourceIdResult.id))) { + .parse(uriString)); + if ("xml".equals(openResourceIdResult.r.getResourceTypeName(openResourceIdResult.id))) { xmlPullParser = openResourceIdResult.r.getXml(openResourceIdResult.id); } else { @@ -164,11 +164,11 @@ public class WizardScript implements Parcelable { Log.e(TAG, "Ill-formatted wizard_script: " + uriString); Log.e(TAG, e.getMessage()); return wizardScript; - } catch(FileNotFoundException fnfe) { + } catch (FileNotFoundException fnfe) { Log.e(TAG, "Cannot find file: " + uriString); Log.e(TAG, fnfe.getMessage()); return wizardScript; - } catch(IOException ioe) { + } catch (IOException ioe) { Log.e(TAG, "Unable to read wizard_script: " + uriString); Log.e(TAG, ioe.getMessage()); return wizardScript; @@ -178,14 +178,14 @@ public class WizardScript implements Parcelable { private static WizardScript parseWizardScript(XmlPullParser parser) throws XmlPullParserException, IOException { String startTag = parser.getName(); - if(!TAG_WIZARD_SCRIPT.equals(startTag)) { + if (!TAG_WIZARD_SCRIPT.equals(startTag)) { throw new XmlPullParserException("XML document must start with " + " tag; found " + startTag + " at " + parser.getPositionDescription()); } String firstAction = parser.getAttributeValue(WIZARD_SCRIPT_NAMESPACE, ATTR_FIRST_ACTION); - if(firstAction == null) { + if (firstAction == null) { throw new XmlPullParserException("WizardScript must define a firstAction"); } diff --git a/src/org/lineageos/setupwizard/wizardmanager/WizardTransitions.java b/src/org/lineageos/setupwizard/wizardmanager/WizardTransitions.java index 7c142494..60d1d5b8 100644 --- a/src/org/lineageos/setupwizard/wizardmanager/WizardTransitions.java +++ b/src/org/lineageos/setupwizard/wizardmanager/WizardTransitions.java @@ -24,8 +24,6 @@ import android.os.Parcelable; import android.util.Log; import android.util.SparseArray; -import org.lineageos.setupwizard.SetupWizardApp; - public class WizardTransitions extends SparseArray implements Parcelable { private static final String TAG = "WizardTransitions"; @@ -47,7 +45,8 @@ public class WizardTransitions extends SparseArray implements Parcelable } }; - public WizardTransitions() {} + public WizardTransitions() { + } public void setDefaultAction(String action) { mDefaultAction = action; @@ -77,12 +76,13 @@ public class WizardTransitions extends SparseArray implements Parcelable if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; WizardTransitions that = (WizardTransitions) o; - return mDefaultAction != null ? mDefaultAction.equals(that.mDefaultAction) : that.mDefaultAction == null; + return mDefaultAction != null ? mDefaultAction.equals(that.mDefaultAction) + : that.mDefaultAction == null; } public int hashCode() { - return super.hashCode() + mDefaultAction.hashCode(); + return super.hashCode() + mDefaultAction.hashCode(); } @Override @@ -105,5 +105,4 @@ public class WizardTransitions extends SparseArray implements Parcelable mDefaultAction = in.readString(); } - }