diff options
author | cretin45 <cretin45@gmail.com> | 2015-02-23 14:33:07 -0800 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2015-02-23 14:33:07 -0800 |
commit | d7e70040b79dafe475de5205836d714a52a2506a (patch) | |
tree | d07f74a9a3e54dff8a848818f156edde28d120cb | |
parent | c4584a78e30444b336dd6788334af6432b1ca466 (diff) | |
download | packages_apps_SetupWizard-d7e70040b79dafe475de5205836d714a52a2506a.zip packages_apps_SetupWizard-d7e70040b79dafe475de5205836d714a52a2506a.tar.gz packages_apps_SetupWizard-d7e70040b79dafe475de5205836d714a52a2506a.tar.bz2 |
SetupWizard: Refactor context type
Context is assumed to be SetupWizardActivity and blindly cast. Just make the Context reference a SetupWizardActivity.
Change-Id: I3d7ffd08980fbff0fbea51b45b28002b49813038
16 files changed, 47 insertions, 41 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/AbstractSetupData.java b/src/com/cyanogenmod/setupwizard/setup/AbstractSetupData.java index 184afba..baab434 100644 --- a/src/com/cyanogenmod/setupwizard/setup/AbstractSetupData.java +++ b/src/com/cyanogenmod/setupwizard/setup/AbstractSetupData.java @@ -17,22 +17,23 @@ package com.cyanogenmod.setupwizard.setup; import android.content.BroadcastReceiver; -import android.content.Context; import android.os.Bundle; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; + import java.util.ArrayList; public abstract class AbstractSetupData extends BroadcastReceiver implements SetupDataCallbacks { private static final String TAG = AbstractSetupData.class.getSimpleName(); - protected Context mContext; + protected SetupWizardActivity mContext; private ArrayList<SetupDataCallbacks> mListeners = new ArrayList<SetupDataCallbacks>(); private PageList mPageList; private int mCurrentPageIndex = 0; - public AbstractSetupData(Context context) { + public AbstractSetupData(SetupWizardActivity context) { mContext = context; mPageList = onNewPageList(); } diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java index 3061c36..92ad15a 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java +++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java @@ -23,6 +23,7 @@ import android.net.ConnectivityManager; import android.telephony.TelephonyManager; import com.android.internal.telephony.TelephonyIntents; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import java.util.ArrayList; @@ -34,7 +35,7 @@ public class CMSetupWizardData extends AbstractSetupData { private boolean mTimeSet = false; private boolean mTimeZoneSet = false; - public CMSetupWizardData(Context context) { + public CMSetupWizardData(SetupWizardActivity context) { super(context); } diff --git a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java index 6e7ab51..c63ca19 100644 --- a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java @@ -27,7 +27,6 @@ import android.telephony.SubInfoRecord; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; -import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; @@ -38,6 +37,7 @@ import android.widget.TextView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import java.util.List; @@ -45,7 +45,7 @@ public class ChooseDataSimPage extends SetupPage { public static final String TAG = "ChooseDataSimPage"; - public ChooseDataSimPage(Context context, SetupDataCallbacks callbacks) { + public ChooseDataSimPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java index 2d90947..13b925a 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java @@ -25,13 +25,13 @@ import android.app.Activity; import android.app.ActivityOptions; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.SetupWizardApp; import com.cyanogenmod.setupwizard.ui.LoadingFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import java.io.IOException; @@ -40,7 +40,7 @@ public class CyanogenServicesPage extends SetupPage { public static final String TAG = "CyanogenServicesPage"; - public CyanogenServicesPage(Context context, SetupDataCallbacks callbacks) { + public CyanogenServicesPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } @@ -73,7 +73,7 @@ public class CyanogenServicesPage extends SetupPage { } @Override - public void doLoadAction(Activity context, int action) { + public void doLoadAction(SetupWizardActivity context, int action) { if (action == Page.ACTION_PREVIOUS) { getCallbacks().onPreviousPage(); } else { diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java index 9dab3c0..c35859c 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java @@ -39,6 +39,7 @@ import android.widget.TextView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.ui.WebViewDialogFragment; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import com.cyanogenmod.setupwizard.util.WhisperPushUtils; @@ -59,7 +60,7 @@ public class CyanogenSettingsPage extends SetupPage { public static final String SETTING_METRICS = "settings.cyanogen.allow_metrics"; public static final String PRIVACY_POLICY_URI = "https://cyngn.com/legal/privacy-policy"; - public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) { + public CyanogenSettingsPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java b/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java index 39d3f85..d953a53 100644 --- a/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java +++ b/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java @@ -16,11 +16,6 @@ package com.cyanogenmod.setupwizard.setup; -import com.cyanogenmod.setupwizard.R; -import com.cyanogenmod.setupwizard.ui.SetupPageFragment; - -import org.xmlpull.v1.XmlPullParserException; - import android.app.Activity; import android.app.AlarmManager; import android.app.DatePickerDialog; @@ -46,6 +41,12 @@ import android.widget.Spinner; import android.widget.TextView; import android.widget.TimePicker; +import com.cyanogenmod.setupwizard.R; +import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; + +import org.xmlpull.v1.XmlPullParserException; + import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -68,7 +69,7 @@ public class DateTimePage extends SetupPage { private static final int HOURS_1 = 60 * 60000; - public DateTimePage(Context context, SetupDataCallbacks callbacks) { + public DateTimePage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java index fa25bd1..a45a648 100644 --- a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java @@ -18,11 +18,11 @@ package com.cyanogenmod.setupwizard.setup; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Context; import android.os.Bundle; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; public class FinishPage extends SetupPage { @@ -30,7 +30,7 @@ public class FinishPage extends SetupPage { private FinishFragment mFinishFragment; - public FinishPage(Context context, SetupDataCallbacks callbacks) { + public FinishPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java index 11f9e7c..9cacb0b 100644 --- a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java @@ -27,7 +27,6 @@ import android.app.Fragment; import android.app.FragmentManager; import android.content.ContentQueryMap; import android.content.ContentResolver; -import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.os.Bundle; @@ -56,7 +55,7 @@ public class GmsAccountPage extends SetupPage { private boolean mBackupEnabled = false; - public GmsAccountPage(final Context context, SetupDataCallbacks callbacks) { + public GmsAccountPage(final SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); final ContentResolver res = context.getContentResolver(); mBackupEnabled = Settings.Secure.getInt(res, @@ -106,7 +105,7 @@ public class GmsAccountPage extends SetupPage { } @Override - public void doLoadAction(Activity context, int action) { + public void doLoadAction(SetupWizardActivity context, int action) { if (action == Page.ACTION_PREVIOUS) { getCallbacks().onPreviousPage(); } else { @@ -119,7 +118,7 @@ public class GmsAccountPage extends SetupPage { public boolean onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS) { if (!mBackupEnabled && SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) { - launchGmsRestorePage((Activity) mContext); + launchGmsRestorePage(mContext); } else { handleResult(resultCode); } @@ -149,7 +148,7 @@ public class GmsAccountPage extends SetupPage { } } - private static void launchGmsRestorePage(final Activity activity) { + private static void launchGmsRestorePage(final SetupWizardActivity activity) { try { // GMS can disable this after logging in sometimes SetupWizardUtils.enableGMSSetupWizard(activity); @@ -172,11 +171,11 @@ public class GmsAccountPage extends SetupPage { e.printStackTrace(); // XXX: In open source, we don't know what gms version a user has. // Bail if the restore activity is not found. - ((SetupWizardActivity) activity).onNextPage(); + activity.onNextPage(); } } - private void launchGmsAccountSetup(final Activity activity) { + private void launchGmsAccountSetup(final SetupWizardActivity activity) { Bundle bundle = new Bundle(); bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true); bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true); diff --git a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java index d8866bf..efa2516 100644 --- a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java @@ -34,13 +34,14 @@ import android.widget.TextView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; public class MobileDataPage extends SetupPage { public static final String TAG = "MobileDataPage"; - public MobileDataPage(Context context, SetupDataCallbacks callbacks) { + public MobileDataPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java index d6293e9..ee6d206 100644 --- a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java @@ -39,6 +39,7 @@ import android.widget.TextView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.SetupWizardApp; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.ui.WebViewDialogFragment; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; @@ -52,7 +53,7 @@ public class OtherSettingsPage extends SetupPage { private static final String PRIVACY_POLICY_URI = "https://www.google.com/intl/en/policies/privacy/?fg=1"; - public OtherSettingsPage(Context context, SetupDataCallbacks callbacks) { + public OtherSettingsPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/Page.java b/src/com/cyanogenmod/setupwizard/setup/Page.java index 18d7e39..4ab2f40 100644 --- a/src/com/cyanogenmod/setupwizard/setup/Page.java +++ b/src/com/cyanogenmod/setupwizard/setup/Page.java @@ -16,12 +16,13 @@ package com.cyanogenmod.setupwizard.setup; -import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.content.Intent; import android.os.Bundle; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; + public interface Page { public static final String KEY_PAGE_ARGUMENT = "key_arg"; @@ -43,7 +44,7 @@ public interface Page { public Page setHidden(boolean hidden); public boolean doPreviousAction(); public boolean doNextAction(); - public void doLoadAction(Activity context, int action); + public void doLoadAction(SetupWizardActivity context, int action); public void onFinishSetup(); public boolean onActivityResult(int requestCode, int resultCode, Intent data); public SetupDataCallbacks getCallbacks(); diff --git a/src/com/cyanogenmod/setupwizard/setup/SetupPage.java b/src/com/cyanogenmod/setupwizard/setup/SetupPage.java index 4479ab4..fe3fca3 100644 --- a/src/com/cyanogenmod/setupwizard/setup/SetupPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/SetupPage.java @@ -17,6 +17,7 @@ package com.cyanogenmod.setupwizard.setup; import com.cyanogenmod.setupwizard.R; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import android.app.Activity; import android.app.Fragment; @@ -37,9 +38,9 @@ public abstract class SetupPage implements Page { private boolean mRequired = false; private boolean mHidden = false; - protected final Context mContext; + protected final SetupWizardActivity mContext; - protected SetupPage(Context context, SetupDataCallbacks callbacks) { + protected SetupPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { mContext = context; mCallbacks = callbacks; } @@ -73,7 +74,7 @@ public abstract class SetupPage implements Page { public void onFinishSetup() {} @Override - public void doLoadAction(Activity context, int action) { + public void doLoadAction(SetupWizardActivity context, int action) { if (context == null || context.isFinishing()) { return; } final FragmentManager fragmentManager = context.getFragmentManager(); Fragment fragment = getFragment(fragmentManager, action); diff --git a/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java b/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java index 83d2833..04d2ce2 100644 --- a/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java @@ -18,12 +18,12 @@ package com.cyanogenmod.setupwizard.setup; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Context; import android.os.Bundle; import android.widget.ImageView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; public class SimCardMissingPage extends SetupPage { @@ -33,7 +33,7 @@ public class SimCardMissingPage extends SetupPage { private static final int SIM_SIDE = 1; private static final int SIM_BACK = 2; - public SimCardMissingPage(Context context, SetupDataCallbacks callbacks) { + public SimCardMissingPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java index e919267..bd88d44 100644 --- a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java +++ b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java @@ -19,7 +19,6 @@ package com.cyanogenmod.setupwizard.setup; import android.app.ActivityOptions; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; @@ -32,6 +31,7 @@ import android.widget.NumberPicker; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.LocalePicker; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import java.util.Locale; @@ -41,7 +41,7 @@ public class WelcomePage extends SetupPage { private static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL"; - public WelcomePage(Context context, SetupDataCallbacks callbacks) { + public WelcomePage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); } diff --git a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java index 04f0d3d..268d8a9 100644 --- a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.ActivityOptions; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.os.Bundle; @@ -31,6 +30,7 @@ import android.util.Log; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.SetupWizardApp; import com.cyanogenmod.setupwizard.ui.LoadingFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import java.io.IOException; @@ -59,7 +59,7 @@ public class WifiSetupPage extends SetupPage { private Runnable mFinishCaptivePortalCheckRunnable = new Runnable() { @Override public void run() { - final Activity activity = (Activity)mContext; + final Activity activity = mContext; if (mIsCaptivePortal) { try { int netId = ConnectivityManager.from(activity) @@ -90,7 +90,7 @@ public class WifiSetupPage extends SetupPage { } }; - public WifiSetupPage(Context context, SetupDataCallbacks callbacks) { + public WifiSetupPage(SetupWizardActivity context, SetupDataCallbacks callbacks) { super(context, callbacks); String server = Settings.Global.getString(context.getContentResolver(), "captive_portal_server"); if (server == null) server = DEFAULT_SERVER; @@ -130,7 +130,7 @@ public class WifiSetupPage extends SetupPage { } @Override - public void doLoadAction(Activity context, int action) { + public void doLoadAction(SetupWizardActivity context, int action) { super.doLoadAction(context, action); SetupWizardUtils.launchWifiSetup(context); } diff --git a/src/com/cyanogenmod/setupwizard/ui/LoadingFragment.java b/src/com/cyanogenmod/setupwizard/ui/LoadingFragment.java index 4cafadf..f7fab63 100644 --- a/src/com/cyanogenmod/setupwizard/ui/LoadingFragment.java +++ b/src/com/cyanogenmod/setupwizard/ui/LoadingFragment.java @@ -17,7 +17,6 @@ package com.cyanogenmod.setupwizard.ui; import com.cyanogenmod.setupwizard.R; -import com.cyanogenmod.setupwizard.ui.SetupPageFragment; public class LoadingFragment extends SetupPageFragment { @Override |