diff options
author | Luis Mejia <lmejia@cyngn.com> | 2016-07-14 11:51:58 -0700 |
---|---|---|
committer | Luis Mejia <lmejia@cyngn.com> | 2016-07-14 19:27:13 -0700 |
commit | b31e14b835fc09d020ea4022ed5fc518cb8410f2 (patch) | |
tree | 8dfeedbc30bd4d6701ef673d0875f66e83456265 /src/com/cyanogenmod/setupwizard/setup | |
parent | 7c1cf5a2324b1622a12afa115bedd7a9c2031b0a (diff) | |
download | packages_apps_SetupWizard-b31e14b835fc09d020ea4022ed5fc518cb8410f2.zip packages_apps_SetupWizard-b31e14b835fc09d020ea4022ed5fc518cb8410f2.tar.gz packages_apps_SetupWizard-b31e14b835fc09d020ea4022ed5fc518cb8410f2.tar.bz2 |
Replaced last panel with ModGuide panel.
- Created and added ModGuide panel.
- Added the ability to chnage navigation color.
- Added the ability to start an app after wizard completion.
Issue-Id: MSC-14
Change-Id: I8e17735d1a9edbd529339982981f8270cde83d96
Diffstat (limited to 'src/com/cyanogenmod/setupwizard/setup')
-rw-r--r-- | src/com/cyanogenmod/setupwizard/setup/FinishPage.java | 83 | ||||
-rw-r--r-- | src/com/cyanogenmod/setupwizard/setup/Page.java | 1 | ||||
-rw-r--r-- | src/com/cyanogenmod/setupwizard/setup/SetupPage.java | 5 |
3 files changed, 81 insertions, 8 deletions
diff --git a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java index 552403e..3cb5a3f 100644 --- a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java @@ -20,22 +20,36 @@ import android.app.Activity; import android.app.Fragment; import android.app.FragmentManager; import android.content.Context; +import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.os.RemoteException; +import android.util.Log; import android.view.View; -import android.widget.ImageView; import com.cyanogenmod.setupwizard.R; import com.cyanogenmod.setupwizard.ui.SetupPageFragment; +import com.cyanogenmod.setupwizard.ui.SetupWizardActivity; import com.cyanogenmod.setupwizard.util.SetupWizardUtils; +import java.lang.ref.WeakReference; + public class FinishPage extends SetupPage { public static final String TAG = "FinishPage"; + private static final int WHAT_EXPLORE_MOD_GUIDE = 1; + private static final String KEY_MESSENGER = "key_messenger"; + private static final String MODGUIDE_PACKAGE_NAME = "com.cyngn.modguide"; + private FinishFragment mFinishFragment; + private final boolean mShowingModGuide; public FinishPage(Context context, SetupDataCallbacks callbacks) { super(context, callbacks); + mShowingModGuide = SetupWizardUtils.canHasModMOD(context); } @Override @@ -45,18 +59,43 @@ public class FinishPage extends SetupPage { Bundle args = new Bundle(); args.putString(Page.KEY_PAGE_ARGUMENT, getKey()); args.putInt(Page.KEY_PAGE_ACTION, action); + args.putParcelable(KEY_MESSENGER, new Messenger(mHandler)); mFinishFragment = new FinishFragment(); mFinishFragment.setArguments(args); } return mFinishFragment; } + private final PageHandler mHandler = new PageHandler(this); + + private static class PageHandler extends Handler { + + private final WeakReference<FinishPage> mPage; + + private PageHandler(final FinishPage page) { + mPage = new WeakReference<>(page); + } + + @Override + public void handleMessage(final Message msg) { + final FinishPage page = mPage.get(); + if ((page != null) && (msg.what == WHAT_EXPLORE_MOD_GUIDE)) { + page.doExploreModGuide(); + } + } + } + @Override public String getKey() { return TAG; } @Override + public int getButtonBarBackgroundColorId() { + return mShowingModGuide ? R.color.mod_button_bar_background : R.color.primary; + } + + @Override public int getTitleResId() { return R.string.setup_complete; } @@ -67,27 +106,55 @@ public class FinishPage extends SetupPage { return true; } + private void doExploreModGuide() { + final SetupWizardActivity activity = + (SetupWizardActivity) mFinishFragment.getActivity(); + final Intent intent = + activity.getPackageManager().getLaunchIntentForPackage(MODGUIDE_PACKAGE_NAME); + activity.setFinishIntent(intent); + getCallbacks().onFinish(); + } + @Override public int getNextButtonTitleResId() { - return R.string.start; + return mShowingModGuide ? R.string.done : R.string.start; } public static class FinishFragment extends SetupPageFragment { + private boolean mShowingModGuide; + @Override protected void initializePage() { final Activity activity = getActivity(); - if (activity != null && SetupWizardUtils.canHasModMOD(activity)) { - ImageView imageView = (ImageView) mRootView.findViewById(R.id.brand_logo); - imageView.setImageResource(R.drawable.mod_ready); - mRootView.findViewById(R.id.mod_welcome).setVisibility(View.VISIBLE); - mRootView.findViewById(R.id.mod_desc).setVisibility(View.VISIBLE); + if (!mShowingModGuide || (activity == null)) { + return; } + mRootView.findViewById(R.id.explore_mod_guide) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + final Messenger messenger = getArguments().getParcelable(KEY_MESSENGER); + if (messenger == null) { + return; + } + final Message message = Message.obtain(); + message.what = WHAT_EXPLORE_MOD_GUIDE; + try { + messenger.send(message); + } catch (final RemoteException e) { + Log.e(TAG, "Couldn't send message to start MOD Guide", e); + } + } + }); } @Override protected int getLayoutResource() { - return R.layout.setup_finished_page; + final Context context = getContext(); + mShowingModGuide = (context != null) && SetupWizardUtils.canHasModMOD(context); + return mShowingModGuide ? + R.layout.setup_modguide_page : R.layout.setup_finished_page; } } diff --git a/src/com/cyanogenmod/setupwizard/setup/Page.java b/src/com/cyanogenmod/setupwizard/setup/Page.java index ee5efd6..9e48a1b 100644 --- a/src/com/cyanogenmod/setupwizard/setup/Page.java +++ b/src/com/cyanogenmod/setupwizard/setup/Page.java @@ -31,6 +31,7 @@ public interface Page { public String getKey(); public int getTitleResId(); + public int getButtonBarBackgroundColorId(); public int getPrevButtonTitleResId(); public int getNextButtonTitleResId(); public Fragment getFragment(FragmentManager fragmentManager, int action); diff --git a/src/com/cyanogenmod/setupwizard/setup/SetupPage.java b/src/com/cyanogenmod/setupwizard/setup/SetupPage.java index 1a19fb0..05bf9c5 100644 --- a/src/com/cyanogenmod/setupwizard/setup/SetupPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/SetupPage.java @@ -50,6 +50,11 @@ public abstract class SetupPage implements Page { } @Override + public int getButtonBarBackgroundColorId() { + return R.color.button_bar_background; + } + + @Override public int getPrevButtonTitleResId() { return -1; } |