2015-01-16 00:04:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 The CyanogenMod Project
|
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;
|
|
|
|
|
2016-04-27 19:38:53 +00:00
|
|
|
import android.app.Activity;
|
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;
|
2016-07-14 18:51:58 +00:00
|
|
|
import android.content.Intent;
|
2015-01-16 00:04:44 +00:00
|
|
|
import android.os.Bundle;
|
2016-07-14 18:51:58 +00:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Message;
|
|
|
|
import android.os.Messenger;
|
|
|
|
import android.os.RemoteException;
|
|
|
|
import android.util.Log;
|
2016-04-27 19:38:53 +00:00
|
|
|
import android.view.View;
|
2015-01-27 23:23:16 +00:00
|
|
|
|
|
|
|
import com.cyanogenmod.setupwizard.R;
|
|
|
|
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
|
2016-07-14 18:51:58 +00:00
|
|
|
import com.cyanogenmod.setupwizard.ui.SetupWizardActivity;
|
2016-04-27 19:38:53 +00:00
|
|
|
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
2015-01-16 00:04:44 +00:00
|
|
|
|
2016-07-14 18:51:58 +00:00
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
public class FinishPage extends SetupPage {
|
|
|
|
|
|
|
|
public static final String TAG = "FinishPage";
|
|
|
|
|
2016-07-14 18:51:58 +00:00
|
|
|
private static final String KEY_MESSENGER = "key_messenger";
|
|
|
|
|
2015-01-21 23:55:03 +00:00
|
|
|
private FinishFragment mFinishFragment;
|
|
|
|
|
2015-02-23 21:52:37 +00:00
|
|
|
public FinishPage(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) {
|
|
|
|
mFinishFragment = (FinishFragment)fragmentManager.findFragmentByTag(getKey());
|
|
|
|
if (mFinishFragment == null) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
|
|
|
|
args.putInt(Page.KEY_PAGE_ACTION, action);
|
2016-07-14 18:51:58 +00:00
|
|
|
args.putParcelable(KEY_MESSENGER, new Messenger(mHandler));
|
2015-01-23 19:37:23 +00:00
|
|
|
mFinishFragment = new FinishFragment();
|
|
|
|
mFinishFragment.setArguments(args);
|
|
|
|
}
|
2015-01-21 23:55:03 +00:00
|
|
|
return mFinishFragment;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
2016-07-14 18:51:58 +00:00
|
|
|
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) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
@Override
|
|
|
|
public String getKey() {
|
|
|
|
return TAG;
|
|
|
|
}
|
|
|
|
|
2016-07-14 18:51:58 +00:00
|
|
|
@Override
|
2016-12-29 16:28:02 +00:00
|
|
|
public int getTitleResId() {
|
|
|
|
return R.string.setup_complete;
|
2016-07-14 18:51:58 +00:00
|
|
|
}
|
|
|
|
|
2015-01-16 00:04:44 +00:00
|
|
|
@Override
|
2016-12-29 16:28:02 +00:00
|
|
|
public int getIconResId() {
|
|
|
|
return -1;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doNextAction() {
|
2015-01-27 23:23:16 +00:00
|
|
|
getCallbacks().onFinish();
|
2015-01-16 00:04:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getNextButtonTitleResId() {
|
2016-12-29 16:28:02 +00:00
|
|
|
return R.string.start;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class FinishFragment extends SetupPageFragment {
|
|
|
|
|
|
|
|
@Override
|
2016-04-27 19:38:53 +00:00
|
|
|
protected void initializePage() {
|
|
|
|
final Activity activity = getActivity();
|
2016-12-29 16:28:02 +00:00
|
|
|
if (activity == null) {
|
2016-07-14 18:51:58 +00:00
|
|
|
return;
|
2016-04-27 19:38:53 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-16 00:04:44 +00:00
|
|
|
|
|
|
|
@Override
|
2015-01-21 23:55:03 +00:00
|
|
|
protected int getLayoutResource() {
|
2016-12-29 16:28:02 +00:00
|
|
|
return R.layout.setup_finished_page;
|
2015-01-16 00:04:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|