blob: a44a91938ea5d8d0292478fd7686ca9e04d6c372 [file] [log] [blame]
/*
* 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.fairphone.setupwizard.setup;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import com.android.internal.telephony.TelephonyIntents;
import com.fairphone.setupwizard.util.SetupWizardUtils;
import java.util.ArrayList;
public class SetupWizard extends AbstractSetupData {
private static final String TAG = SetupWizard.class.getSimpleName();
private boolean mTimeSet = false;
private boolean mTimeZoneSet = false;
public SetupWizard(Context context) {
super(context);
}
@Override
protected PageList onNewPageList() {
ArrayList<Page> pages = new ArrayList<Page>();
pages.add(new WelcomePage(mContext, this));
pages.add(new WifiSetupPage(mContext, this));
pages.add(new DateTimePage(mContext, this));
pages.add(new FinishPage(mContext, this));
return new PageList(pages.toArray(new SetupPage[pages.size()]));
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED) ||
intent.getAction().equals(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE)) {
mTimeZoneSet = true;
showHideDateTimePage();
} else if (intent.getAction().equals(Intent.ACTION_TIME_CHANGED) ||
intent.getAction().equals(TelephonyIntents.ACTION_NETWORK_SET_TIME)) {
mTimeSet = true;
showHideDateTimePage();
}
}
private void showHideDateTimePage() {
DateTimePage dateTimePage = (DateTimePage) getPage(DateTimePage.TAG);
if (dateTimePage != null) {
dateTimePage.setHidden(mTimeZoneSet & mTimeSet);
}
}
public IntentFilter getIntentFilter() {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(TelephonyIntents.ACTION_NETWORK_SET_TIME);
filter.addAction(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE);
return filter;
}
}