2015-01-16 00:04:44 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.cyanogenmod.setupwizard.setup;
|
|
|
|
|
|
|
|
import android.app.Fragment;
|
|
|
|
import android.app.FragmentManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
2015-01-21 23:55:03 +00:00
|
|
|
import android.transition.Slide;
|
|
|
|
import android.transition.Transition;
|
|
|
|
import android.view.Gravity;
|
2015-01-16 00:04:44 +00:00
|
|
|
|
2015-02-23 21:52:37 +00:00
|
|
|
import com.cyanogenmod.setupwizard.R;
|
2015-03-04 21:06:26 +00:00
|
|
|
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
|
2015-02-23 21:52:37 +00:00
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
|
|
|
|
public abstract class SetupPage implements Page {
|
|
|
|
|
|
|
|
private final SetupDataCallbacks mCallbacks;
|
|
|
|
|
|
|
|
private Bundle mData = new Bundle();
|
|
|
|
private boolean mRequired = false;
|
2015-01-29 05:32:50 +00:00
|
|
|
private boolean mHidden = false;
|
2015-01-16 00:04:44 +00:00
|
|
|
|
2015-02-23 21:52:37 +00:00
|
|
|
protected final Context mContext;
|
2015-01-16 00:04:44 +00:00
|
|
|
|
2015-02-23 21:52:37 +00:00
|
|
|
protected SetupPage(Context context, SetupDataCallbacks callbacks) {
|
2015-01-16 00:04:44 +00:00
|
|
|
mContext = context;
|
|
|
|
mCallbacks = callbacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-23 19:37:23 +00:00
|
|
|
public Fragment getFragment(FragmentManager fragmentManager, int action) {
|
2015-01-16 00:04:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getPrevButtonTitleResId() {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getNextButtonTitleResId() {
|
|
|
|
return R.string.next;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doNextAction() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doPreviousAction() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-30 18:52:47 +00:00
|
|
|
@Override
|
|
|
|
public void onFinishSetup() {}
|
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
@Override
|
2015-02-23 21:52:37 +00:00
|
|
|
public void doLoadAction(FragmentManager fragmentManager, int action) {
|
2015-01-23 19:37:23 +00:00
|
|
|
Fragment fragment = getFragment(fragmentManager, action);
|
2015-01-16 00:04:44 +00:00
|
|
|
if (action == Page.ACTION_NEXT) {
|
2015-03-04 21:06:26 +00:00
|
|
|
SetupStats.addEvent(SetupStats.Categories.BUTTON_CLICK,
|
|
|
|
SetupStats.Action.NEXT_BUTTON, getKey(),
|
|
|
|
String.valueOf(System.currentTimeMillis()));
|
2015-01-21 23:55:03 +00:00
|
|
|
Transition t = new Slide(Gravity.RIGHT);
|
|
|
|
fragment.setEnterTransition(t);
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.content,fragment, getKey())
|
|
|
|
.commit();
|
2015-01-16 00:04:44 +00:00
|
|
|
} else {
|
2015-03-04 21:06:26 +00:00
|
|
|
SetupStats.addEvent(SetupStats.Categories.BUTTON_CLICK,
|
|
|
|
SetupStats.Action.PREVIOUS_BUTTON, getKey(),
|
|
|
|
String.valueOf(System.currentTimeMillis()));
|
2015-01-21 23:55:03 +00:00
|
|
|
Transition t = new Slide(Gravity.LEFT);
|
|
|
|
fragment.setEnterTransition(t);
|
|
|
|
fragmentManager.beginTransaction()
|
|
|
|
.replace(R.id.content, fragment, getKey())
|
|
|
|
.commit();
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isRequired() {
|
|
|
|
return mRequired;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Page setRequired(boolean required) {
|
|
|
|
mRequired = required;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-29 05:32:50 +00:00
|
|
|
public boolean isHidden() {
|
|
|
|
return mHidden;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-30 01:36:30 +00:00
|
|
|
public Page setHidden(boolean hidden) {
|
2015-01-29 05:32:50 +00:00
|
|
|
mHidden = hidden;
|
2015-01-30 01:36:30 +00:00
|
|
|
return this;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Bundle getData() {
|
|
|
|
return mData;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void resetData(Bundle data) {
|
|
|
|
mData = data;
|
|
|
|
mCallbacks.onPageLoaded(this);
|
|
|
|
}
|
|
|
|
|
2015-01-19 22:29:43 +00:00
|
|
|
public SetupDataCallbacks getCallbacks() {
|
2015-01-16 00:04:44 +00:00
|
|
|
return mCallbacks;
|
|
|
|
}
|
|
|
|
}
|