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
This commit is contained in:
Luis Mejia 2016-07-14 11:51:58 -07:00
parent 7c1cf5a232
commit b31e14b835
19 changed files with 261 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2016 Cyanogen, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="72dp"
android:height="16dp"
android:viewportWidth="72"
android:viewportHeight="16">
<path
android:name="ic_logo_mod_title"
android:fillColor="#000000"
android:pathData="M19.9097139,5.66053833 C19.9097139,2.54013671 17.3930434,4.53810596e-05
14.2986968,4.53810596e-05 L0,4.53810596e-05 L0,15.9999319 L2.53412329,15.9999319
L2.53412329,2.5567008 L8.68814203,2.5567008 L8.68814203,15.9999319
L11.221803,15.9999319 L11.221803,2.5567008 L14.2986968,2.5567008
C15.9954325,2.5567008 17.3755906,3.94933205 17.3755906,5.66053833
L17.3755906,15.9999319 L19.9097139,15.9999319 L19.9097139,5.66053833 Z
M44.8456489,7.26108291 L44.8456489,6.32158153 L44.8456489,5.66049295
C44.8456489,2.54020478 42.3287472,0 39.2346318,0 L31.9464123,0 C28.853106,0
26.3363199,2.54020478 26.3363199,5.66049295 L26.3363199,6.93388547
L26.3363199,7.26108291 L26.3363199,8.73891709 L26.3363199,9.19476983
L26.3363199,10.3393936 C26.3363199,13.4595683 28.853106,16 31.9464123,16
L39.2346318,16 C42.3287472,16 44.8456489,13.4595683 44.8456489,10.3393936
L44.8456489,9.71290807 L44.8456489,8.73891709 L44.8456489,7.26108291 Z
M42.3111788,10.3393936 C42.3111788,12.0508268 40.9310208,13.4432311
39.2346318,13.4432311 L31.9464123,13.4432311 C30.2502545,13.4432311
28.8700964,12.0508268 28.8700964,10.3393936 L28.8700964,5.66049295
C28.8700964,3.94928667 30.2502545,2.55676887 31.9464123,2.55676887
L39.2346318,2.55676887 C40.9315987,2.55676887 42.3111788,3.94928667
42.3111788,5.66049295 L42.3111788,10.3393936 Z M64.1708327,0 L51.2719428,0
L51.2719428,16 L64.1708327,16 C67.2652948,16 69.7817342,13.4595683
69.7817342,10.3393936 L69.7817342,5.66049295 C69.7817342,2.54020478 67.2652948,0
64.1708327,0 Z M67.2477265,10.3393936 C67.2477265,12.0508268
65.8674528,13.4432311 64.1708327,13.4432311 L53.8064129,13.4432311
L53.8064129,2.55676887 L64.1708327,2.55676887 C65.8674528,2.55676887
67.2477265,3.94928667 67.2477265,5.66049295 L67.2477265,10.3393936 Z" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 KiB

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2013 The CyanogenMod Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/mod_yellow">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="296dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img_oobe_hero"
tools:ignore="ContentDescription"/>
<ImageView
android:layout_width="140dp"
android:layout_height="32dp"
android:src="@drawable/ic_logo_mod_title"
android:tint="@color/white"
android:layout_marginTop="72dp"
android:layout_marginStart="24dp"
tools:ignore="ContentDescription"/>
</FrameLayout>
<TextView android:id="@+id/mod_welcome"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="20sp"
android:textSize="16sp"
android:fontFamily="sans-serif"
android:layout_marginTop="32dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:text="@string/mod_welcome"
android:textColor="@color/mod_title"/>
<TextView android:id="@+id/mod_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:textSize="14sp"
android:lineSpacingExtra="6sp"
android:layout_marginTop="3dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:text="@string/mod_description"
android:textColor="@color/mod_description"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="72dp"
android:minWidth="208dp"
android:layout_marginTop="25dp"
android:layout_marginStart="24dp"
android:background="@drawable/btn_mod_oobe">
<LinearLayout
android:id="@+id/explore_mod_guide"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:minWidth="176dp"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@mipmap/ic_modguide"
android:layout_margin="8dp"
tools:ignore="ContentDescription"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center_vertical"
android:fontFamily="sans-serif"
android:text="@string/mod_explore"
android:textAllCaps="false"
android:textColor="@color/mod_title"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -31,4 +31,9 @@
<color name="header_condensed_bg">@color/primary_dark</color>
<color name="button_bar_background">#e4e7e8</color>
<color name="fingerprint_setup_text_color">#356bc4</color>
<color name="mod_yellow">#f5d328</color>
<color name="mod_title">#dd000000</color>
<color name="mod_description">#89000000</color>
<color name="mod_button_bar_background">#d7b923</color>
</resources>

View File

@ -26,6 +26,7 @@
<string name="next">Next</string>
<string name="skip">Skip</string>
<string name="start">Start</string>
<string name="done">Done</string>
<string name="ok">OK</string>
<string name="loading">Just a sec\u2026</string>
@ -97,6 +98,7 @@
<string name="sim_locale_changed">%1$s SIM detected</string>
<!-- MOD stuff -->
<string name="mod_welcome">Welcome to the Post-App Era</string>
<string name="mod_description">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.</string>
<string name="mod_welcome">Your device is MOD Ready</string>
<string name="mod_description">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.</string>
<string name="mod_explore">Explore MOD Guide</string>
</resources>

View File

@ -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,17 +59,42 @@ 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;
}
}

View File

@ -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);

View File

@ -49,6 +49,11 @@ public abstract class SetupPage implements Page {
return null;
}
@Override
public int getButtonBarBackgroundColorId() {
return R.color.button_bar_background;
}
@Override
public int getPrevButtonTitleResId() {
return -1;

View File

@ -85,6 +85,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
private final ArrayList<Runnable> mFinishRunnables = new ArrayList<Runnable>();
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;
}
}