From b31e14b835fc09d020ea4022ed5fc518cb8410f2 Mon Sep 17 00:00:00 2001 From: Luis Mejia Date: Thu, 14 Jul 2016 11:51:58 -0700 Subject: 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 --- res/drawable-hdpi/btn_mod_oobe.9.png | Bin 0 -> 1349 bytes res/drawable-mdpi/btn_mod_oobe.9.png | Bin 0 -> 858 bytes res/drawable-xhdpi/btn_mod_oobe.9.png | Bin 0 -> 2049 bytes res/drawable-xxhdpi/btn_mod_oobe.9.png | Bin 0 -> 3489 bytes res/drawable-xxxhdpi/btn_mod_oobe.9.png | Bin 0 -> 4854 bytes res/drawable/ic_logo_mod_title.xml | 50 ++++++++++ res/drawable/img_oobe_hero.jpg | Bin 0 -> 406243 bytes res/layout/setup_modguide_page.xml | 102 +++++++++++++++++++++ res/mipmap-hdpi/ic_modguide.png | Bin 0 -> 2182 bytes res/mipmap-mdpi/ic_modguide.png | Bin 0 -> 1476 bytes res/mipmap-xhdpi/ic_modguide.png | Bin 0 -> 2830 bytes res/mipmap-xxhdpi/ic_modguide.png | Bin 0 -> 4118 bytes res/mipmap-xxxhdpi/ic_modguide.png | Bin 0 -> 5444 bytes res/values/colors.xml | 5 + res/values/strings.xml | 6 +- .../cyanogenmod/setupwizard/setup/FinishPage.java | 83 +++++++++++++++-- src/com/cyanogenmod/setupwizard/setup/Page.java | 1 + .../cyanogenmod/setupwizard/setup/SetupPage.java | 5 + .../setupwizard/ui/SetupWizardActivity.java | 23 ++++- 19 files changed, 261 insertions(+), 14 deletions(-) create mode 100644 res/drawable-hdpi/btn_mod_oobe.9.png create mode 100644 res/drawable-mdpi/btn_mod_oobe.9.png create mode 100644 res/drawable-xhdpi/btn_mod_oobe.9.png create mode 100644 res/drawable-xxhdpi/btn_mod_oobe.9.png create mode 100644 res/drawable-xxxhdpi/btn_mod_oobe.9.png create mode 100644 res/drawable/ic_logo_mod_title.xml create mode 100644 res/drawable/img_oobe_hero.jpg create mode 100644 res/layout/setup_modguide_page.xml create mode 100644 res/mipmap-hdpi/ic_modguide.png create mode 100644 res/mipmap-mdpi/ic_modguide.png create mode 100644 res/mipmap-xhdpi/ic_modguide.png create mode 100644 res/mipmap-xxhdpi/ic_modguide.png create mode 100644 res/mipmap-xxxhdpi/ic_modguide.png diff --git a/res/drawable-hdpi/btn_mod_oobe.9.png b/res/drawable-hdpi/btn_mod_oobe.9.png new file mode 100644 index 0000000..d97a67a Binary files /dev/null and b/res/drawable-hdpi/btn_mod_oobe.9.png differ diff --git a/res/drawable-mdpi/btn_mod_oobe.9.png b/res/drawable-mdpi/btn_mod_oobe.9.png new file mode 100644 index 0000000..f71d859 Binary files /dev/null and b/res/drawable-mdpi/btn_mod_oobe.9.png differ diff --git a/res/drawable-xhdpi/btn_mod_oobe.9.png b/res/drawable-xhdpi/btn_mod_oobe.9.png new file mode 100644 index 0000000..b944ecc Binary files /dev/null and b/res/drawable-xhdpi/btn_mod_oobe.9.png differ diff --git a/res/drawable-xxhdpi/btn_mod_oobe.9.png b/res/drawable-xxhdpi/btn_mod_oobe.9.png new file mode 100644 index 0000000..eddb5a7 Binary files /dev/null and b/res/drawable-xxhdpi/btn_mod_oobe.9.png differ diff --git a/res/drawable-xxxhdpi/btn_mod_oobe.9.png b/res/drawable-xxxhdpi/btn_mod_oobe.9.png new file mode 100644 index 0000000..2cf8eb2 Binary files /dev/null and b/res/drawable-xxxhdpi/btn_mod_oobe.9.png differ diff --git a/res/drawable/ic_logo_mod_title.xml b/res/drawable/ic_logo_mod_title.xml new file mode 100644 index 0000000..c16fb76 --- /dev/null +++ b/res/drawable/ic_logo_mod_title.xml @@ -0,0 +1,50 @@ + + + + + + \ No newline at end of file diff --git a/res/drawable/img_oobe_hero.jpg b/res/drawable/img_oobe_hero.jpg new file mode 100644 index 0000000..fab7d97 Binary files /dev/null and b/res/drawable/img_oobe_hero.jpg differ diff --git a/res/layout/setup_modguide_page.xml b/res/layout/setup_modguide_page.xml new file mode 100644 index 0000000..beec6eb --- /dev/null +++ b/res/layout/setup_modguide_page.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/mipmap-hdpi/ic_modguide.png b/res/mipmap-hdpi/ic_modguide.png new file mode 100644 index 0000000..a2fb4a4 Binary files /dev/null and b/res/mipmap-hdpi/ic_modguide.png differ diff --git a/res/mipmap-mdpi/ic_modguide.png b/res/mipmap-mdpi/ic_modguide.png new file mode 100644 index 0000000..ad24eb6 Binary files /dev/null and b/res/mipmap-mdpi/ic_modguide.png differ diff --git a/res/mipmap-xhdpi/ic_modguide.png b/res/mipmap-xhdpi/ic_modguide.png new file mode 100644 index 0000000..784589c Binary files /dev/null and b/res/mipmap-xhdpi/ic_modguide.png differ diff --git a/res/mipmap-xxhdpi/ic_modguide.png b/res/mipmap-xxhdpi/ic_modguide.png new file mode 100644 index 0000000..7226819 Binary files /dev/null and b/res/mipmap-xxhdpi/ic_modguide.png differ diff --git a/res/mipmap-xxxhdpi/ic_modguide.png b/res/mipmap-xxxhdpi/ic_modguide.png new file mode 100644 index 0000000..3cc0d7f Binary files /dev/null and b/res/mipmap-xxxhdpi/ic_modguide.png differ diff --git a/res/values/colors.xml b/res/values/colors.xml index 34110b7..ed7e190 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -31,4 +31,9 @@ @color/primary_dark #e4e7e8 #356bc4 + + #f5d328 + #dd000000 + #89000000 + #d7b923 diff --git a/res/values/strings.xml b/res/values/strings.xml index 475ac8b..80b8e2d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,6 +26,7 @@ Next Skip Start + Done OK Just a sec\u2026 @@ -97,6 +98,7 @@ %1$s SIM detected - Welcome to the Post-App Era - Mods are intelligent, aware, and lightweight experiences built directly into the OS. When MOD thinks it can help, it will offer to activate them for you. + Your device is MOD Ready + Mods make your phone faster, smarter, and easier to use. In this guide, you can discover new mods, learn what they do, and enable or disable them. + Explore MOD Guide 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 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; } diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java index 0d82a74..cf56631 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java @@ -85,6 +85,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks, private final ArrayList mFinishRunnables = new ArrayList(); + private Intent mAfterFinishIntent; + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final boolean isOwner = SetupWizardUtils.isOwner(); @@ -268,6 +270,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks, private void updateButtonBar() { Page page = mSetupData.getCurrentPage(); + mButtonBar.setBackgroundColor(getColor(page.getButtonBarBackgroundColorId())); mNextButton.setText(page.getNextButtonTitleResId()); if (page.getPrevButtonTitleResId() != -1) { mPrevButton.setText(page.getPrevButtonTitleResId()); @@ -285,7 +288,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks, } final Resources resources = getResources(); if (mSetupData.isLastPage()) { - mButtonBar.setBackgroundResource(R.color.primary); mNextButton.setCompoundDrawablesWithIntrinsicBounds(null, null, getDrawable(R.drawable.ic_chevron_right_wht), null); mNextButton.setTextColor(resources.getColor(R.color.white)); @@ -493,10 +495,23 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks, @Override protected void onPostExecute(Boolean aBoolean) { - Intent intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_HOME); - mActivity.startActivity(intent); + if (mActivity.mAfterFinishIntent == null) { + final Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_HOME); + mActivity.startActivity(intent); + } else { + mActivity.startActivity(mActivity.mAfterFinishIntent); + } mActivity.finish(); } } + + /** + * Sets an intent to be started when the wizard finishes. + * By default, or null, it will go Home. + * @param intent Intent to start after wizard finishes. + */ + public void setFinishIntent(final Intent intent) { + mAfterFinishIntent = intent; + } } -- cgit v1.1