2015-01-16 00:04:44 +00:00
|
|
|
/*
|
2016-12-29 16:28:02 +00:00
|
|
|
* Copyright (C) 2017 The LineageOS Project
|
2015-01-16 00:04:44 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.cyanogenmod.setupwizard.setup;
|
|
|
|
|
2015-05-07 23:21:10 +00:00
|
|
|
import android.app.Activity;
|
2015-02-06 23:04:10 +00:00
|
|
|
import android.app.ActivityOptions;
|
2015-01-16 00:04:44 +00:00
|
|
|
import android.app.Fragment;
|
2015-01-23 19:37:23 +00:00
|
|
|
import android.app.FragmentManager;
|
2015-02-23 21:52:37 +00:00
|
|
|
import android.content.Context;
|
2015-01-19 22:29:43 +00:00
|
|
|
import android.content.Intent;
|
2015-01-16 00:04:44 +00:00
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
import com.cyanogenmod.setupwizard.R;
|
2015-05-07 23:21:10 +00:00
|
|
|
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
2015-03-04 21:06:26 +00:00
|
|
|
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
|
2015-01-16 00:04:44 +00:00
|
|
|
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
|
|
|
|
|
|
|
|
public class WelcomePage extends SetupPage {
|
|
|
|
|
|
|
|
public static final String TAG = "WelcomePage";
|
|
|
|
|
2015-01-19 22:29:43 +00:00
|
|
|
private static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";
|
|
|
|
|
2015-05-07 23:21:10 +00:00
|
|
|
private WelcomeFragment mWelcomeFragment;
|
|
|
|
|
2015-02-23 21:52:37 +00:00
|
|
|
public WelcomePage(Context context, SetupDataCallbacks callbacks) {
|
2015-01-16 00:04:44 +00:00
|
|
|
super(context, callbacks);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-23 19:37:23 +00:00
|
|
|
public Fragment getFragment(FragmentManager fragmentManager, int action) {
|
2015-05-07 23:21:10 +00:00
|
|
|
mWelcomeFragment = (WelcomeFragment)fragmentManager.findFragmentByTag(getKey());
|
|
|
|
if (mWelcomeFragment == null) {
|
2015-01-23 19:37:23 +00:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
|
|
|
|
args.putInt(Page.KEY_PAGE_ACTION, action);
|
2015-05-07 23:21:10 +00:00
|
|
|
mWelcomeFragment = new WelcomeFragment();
|
|
|
|
mWelcomeFragment.setArguments(args);
|
2015-01-23 19:37:23 +00:00
|
|
|
}
|
2015-05-07 23:21:10 +00:00
|
|
|
return mWelcomeFragment;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getTitleResId() {
|
2016-12-29 16:28:02 +00:00
|
|
|
return R.string.os_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getIconResId() {
|
|
|
|
return -1;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
2015-05-07 23:21:10 +00:00
|
|
|
@Override
|
|
|
|
public boolean doNextAction() {
|
2016-12-29 16:28:02 +00:00
|
|
|
return super.doNextAction();
|
2015-05-07 23:21:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-19 22:29:43 +00:00
|
|
|
@Override
|
|
|
|
public boolean doPreviousAction() {
|
|
|
|
Intent intent = new Intent(ACTION_EMERGENCY_DIAL);
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
|
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
2015-02-06 23:04:10 +00:00
|
|
|
ActivityOptions options =
|
|
|
|
ActivityOptions.makeCustomAnimation(mContext,
|
|
|
|
android.R.anim.fade_in,
|
|
|
|
android.R.anim.fade_out);
|
2015-03-04 21:06:26 +00:00
|
|
|
SetupStats.addEvent(SetupStats.Categories.BUTTON_CLICK, SetupStats.Label.EMERGENCY_CALL);
|
|
|
|
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
|
|
|
|
SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
|
|
|
|
SetupStats.Label.PAGE, SetupStats.Label.EMERGENCY_CALL);
|
2015-02-06 23:04:10 +00:00
|
|
|
mContext.startActivity(intent, options.toBundle());
|
2015-01-19 22:29:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-05-07 23:21:10 +00:00
|
|
|
@Override
|
|
|
|
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (requestCode == SetupWizardApp.REQUEST_CODE_UNLOCK) {
|
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
|
((SetupWizardApp) mContext.getApplicationContext()).setIsAuthorized(true);
|
|
|
|
getCallbacks().onNextPage();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
@Override
|
|
|
|
public String getKey() {
|
|
|
|
return TAG;
|
|
|
|
}
|
|
|
|
|
2015-05-07 23:21:10 +00:00
|
|
|
@Override
|
|
|
|
public int getNextButtonTitleResId() {
|
2016-12-29 16:28:02 +00:00
|
|
|
return R.string.next;
|
2015-05-07 23:21:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
@Override
|
|
|
|
public int getPrevButtonTitleResId() {
|
|
|
|
return R.string.emergency_call;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class WelcomeFragment extends SetupPageFragment {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void initializePage() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected int getLayoutResource() {
|
|
|
|
return R.layout.setup_welcome_page;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|