Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22e251dc authored by cretin45's avatar cretin45 Committed by Ed Carrigan
Browse files

SetupWizard: Better handling of launching into other activities

Change-Id: I4d8dc4a1b25e45c6ff35042239a0adf4c16458f1
(cherry picked from commit ed5d4670)
parent 22d81f40
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
@@ -83,17 +84,13 @@ public class CyanogenServicesPage extends SetupPage {
            if (!SetupWizardUtils.accountExists(mContext,
                    mContext.getString(R.string.cm_account_type))) {
                super.doLoadAction(fragmentManager, action);
                launchCyanogenAccountSetup();
            } else {
                getCallbacks().onNextPage();
            }
        }
    }

    @Override
    public void onFragmentReady() {
        launchCyanogenAccountSetup();
    }

    @Override
    public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN) {
@@ -127,6 +124,7 @@ public class CyanogenServicesPage extends SetupPage {
                        null, new AccountManagerCallback<Bundle>() {
                            @Override
                            public void run(AccountManagerFuture<Bundle> future) {
                                boolean error = false;
                                try {
                                    Bundle result = future.getResult();
                                    Intent intent = result
@@ -135,7 +133,6 @@ public class CyanogenServicesPage extends SetupPage {
                                            ActivityOptions.makeCustomAnimation(mContext,
                                                    android.R.anim.fade_in,
                                                    android.R.anim.fade_out);
                                    if (!mFragment.isDetached()) {
                                    SetupStats
                                            .addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
                                                    SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
@@ -144,15 +141,18 @@ public class CyanogenServicesPage extends SetupPage {
                                    mFragment.startActivityForResult(intent,
                                            SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN,
                                            options.toBundle());
                                    } else {
                                        if (getCallbacks().
                                                isCurrentPage(CyanogenServicesPage.this)) {
                                            getCallbacks().onNextPage();
                                        }
                                    }
                                } catch (OperationCanceledException e) {
                                    error = true;
                                } catch (IOException e) {
                                    error = true;
                                } catch (AuthenticatorException e) {
                                    Log.e(TAG, "Error launching cm account", e);
                                    error = true;
                                } finally {
                                    if (error && getCallbacks().
                                            isCurrentPage(CyanogenServicesPage.this)) {
                                        getCallbacks().onNextPage();
                                    }
                                }
                            }
                        }, null);
+16 −16
Original line number Diff line number Diff line
@@ -114,13 +114,9 @@ public class GmsAccountPage extends SetupPage {
            getCallbacks().onPreviousPage();
        } else {
            super.doLoadAction(fragmentManager, action);
        }
    }

    @Override
    public void onFragmentReady() {
            launchGmsAccountSetup();
        }
    }

    @Override
    public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
@@ -217,6 +213,7 @@ public class GmsAccountPage extends SetupPage {
                bundle, null, new AccountManagerCallback<Bundle>() {
                    @Override
                    public void run(AccountManagerFuture<Bundle> future) {
                        boolean error = false;
                        try {
                            Bundle result = future.getResult();
                            Intent intent = result
@@ -225,20 +222,23 @@ public class GmsAccountPage extends SetupPage {
                                    ActivityOptions.makeCustomAnimation(mContext,
                                            android.R.anim.fade_in,
                                            android.R.anim.fade_out);
                            if (!mFragment.isDetached()) {
                            SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
                                    SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
                                    SetupStats.Label.PAGE, SetupStats.Label.GMS_ACCOUNT);
                            mFragment.startActivityForResult(intent,
                                    SetupWizardApp.REQUEST_CODE_SETUP_GMS, options.toBundle());
                            } else {
                                if (getCallbacks().isCurrentPage(GmsAccountPage.this)) {
                                    getCallbacks().onNextPage();
                                }
                            }
                        } catch (OperationCanceledException e) {
                            error = true;
                        } catch (IOException e) {
                            error = true;
                        } catch (AuthenticatorException e) {
                            Log.e(TAG, "Error launching gms account", e);
                            error = true;
                        } finally {
                            if (error && getCallbacks().
                                    isCurrentPage(GmsAccountPage.this)) {
                                getCallbacks().onNextPage();
                            }
                        }
                    }
                }, null);
+3 −8
Original line number Diff line number Diff line
@@ -136,18 +136,13 @@ public class OtherSettingsPage extends SetupPage {
            }
        };

        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            mContentResolver = getActivity().getContentResolver();
            mBackupManager = IBackupManager.Stub.asInterface(
                    ServiceManager.getService(Context.BACKUP_SERVICE));
        }

        @Override
        protected void initializePage() {
            final boolean hasGms = SetupWizardUtils.hasGMS(getActivity());
            final boolean hasTelephony = SetupWizardUtils.hasTelephony(getActivity());
            mContentResolver = getActivity().getContentResolver();
            mBackupManager = IBackupManager.Stub.asInterface(
                    ServiceManager.getService(Context.BACKUP_SERVICE));
            TextView summaryView = (TextView) mRootView.findViewById(android.R.id.summary);
            if (hasGms) {
                String privacy_policy = getString(R.string.services_privacy_policy);
+0 −1
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ public interface Page {
    public boolean doPreviousAction();
    public boolean doNextAction();
    public void doLoadAction(FragmentManager fragmentManager, int action);
    public void onFragmentReady();
    public void onFinishSetup();
    public boolean onActivityResult(int requestCode, int resultCode, Intent data);
    public SetupDataCallbacks getCallbacks();
+0 −3
Original line number Diff line number Diff line
@@ -96,9 +96,6 @@ public abstract class SetupPage implements Page {
        }
    }

    @Override
    public void onFragmentReady(){}

    @Override
    public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
        return false;
Loading