diff --git a/astrid/AndroidManifest.xml b/astrid/AndroidManifest.xml
index 5e1e76d5f..3796bdbc9 100644
--- a/astrid/AndroidManifest.xml
+++ b/astrid/AndroidManifest.xml
@@ -194,9 +194,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/astrid/res/layout/share_activity.xml b/astrid/res/layout/share_activity.xml
deleted file mode 100644
index 23fcb40da..000000000
--- a/astrid/res/layout/share_activity.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/astrid/res/layout/welcome_walkthrough.xml b/astrid/res/layout/welcome_walkthrough.xml
deleted file mode 100644
index 614ee8fed..000000000
--- a/astrid/res/layout/welcome_walkthrough.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/astrid/res/layout/welcome_walkthrough_login_page.xml b/astrid/res/layout/welcome_walkthrough_login_page.xml
deleted file mode 100644
index 194086ad6..000000000
--- a/astrid/res/layout/welcome_walkthrough_login_page.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/astrid/res/layout/welcome_walkthrough_page.xml b/astrid/res/layout/welcome_walkthrough_page.xml
deleted file mode 100644
index 46699c0fe..000000000
--- a/astrid/res/layout/welcome_walkthrough_page.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/astrid/res/layout/welcome_walkthrough_simple_login.xml b/astrid/res/layout/welcome_walkthrough_simple_login.xml
deleted file mode 100644
index de859a595..000000000
--- a/astrid/res/layout/welcome_walkthrough_simple_login.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/astrid/res/xml/preferences.xml b/astrid/res/xml/preferences.xml
index 208c76adb..e775df0b6 100644
--- a/astrid/res/xml/preferences.xml
+++ b/astrid/res/xml/preferences.xml
@@ -8,32 +8,6 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/EPr_title">
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/astrid/src/com/todoroo/astrid/activity/AboutActivity.java b/astrid/src/com/todoroo/astrid/activity/AboutActivity.java
deleted file mode 100644
index 32e719cff..000000000
--- a/astrid/src/com/todoroo/astrid/activity/AboutActivity.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2008 Google 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.
- */
-package com.todoroo.astrid.activity;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.res.Resources;
-import android.text.Html;
-import android.text.Spanned;
-import android.text.method.LinkMovementMethod;
-import android.widget.TextView;
-
-import com.timsu.astrid.R;
-
-/**
- * Displays an About dialog.
- */
-class About {
- /**
- * Displays the About dialog from the settings menu.
- *
- * @param activity For context.
- */
- @SuppressWarnings("nls")
- public static void showAbout(final Activity activity, final String versionName) {
-
- Resources r = activity.getResources();
-
- StringBuilder aboutText = new StringBuilder();
- aboutText.append("").append(r.getString(R.string.app_name)).append("
").
- append(r.getString(R.string.p_about_text, versionName).replace("\n", "
")).append("
").
- append("Source Code
").
- append("Privacy Policy
").
- append("Terms of Use
").
- append("Visit astrid.com " +
- "for more information, to add translations or help make Astrid better!");
-
- final AlertDialog.Builder d = new AlertDialog.Builder(activity);
-
- Spanned body = Html.fromHtml(aboutText.toString());
- TextView textView = new TextView(activity);
- textView.setText(body);
- textView.setMovementMethod(LinkMovementMethod.getInstance());
- textView.setPadding(5, 0, 5, 0);
-
- d.setIcon(android.R.drawable.ic_dialog_info);
- d.setView(textView);
- d.setTitle(r.getString(R.string.p_about));
- d.show();
- }
-
- private About() {
- // don't construct me
- }
-}
diff --git a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java
index b67c7bcc2..d62857506 100644
--- a/astrid/src/com/todoroo/astrid/activity/EditPreferences.java
+++ b/astrid/src/com/todoroo/astrid/activity/EditPreferences.java
@@ -12,7 +12,6 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
-import android.net.Uri;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
@@ -60,7 +59,6 @@ import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceInputAssistant;
import com.todoroo.astrid.voice.VoiceOutputService;
import com.todoroo.astrid.voice.VoiceRecognizer;
-import com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough;
import com.todoroo.astrid.widget.TasksWidget;
import java.util.ArrayList;
@@ -76,8 +74,6 @@ import java.util.Map.Entry;
*/
public class EditPreferences extends TodorooPreferenceActivity {
- private static final String SUPPORT_URL = "http://astrid.helpshift.com/a/astrid/?p=android"; //$NON-NLS-1$
-
private static final int APPEARANCE_PREFERENCE = 4;
private static final int REQUEST_CODE_SYNC = 0;
@@ -164,53 +160,7 @@ public class EditPreferences extends TodorooPreferenceActivity {
final Resources r = getResources();
// first-order preferences
- Preference preference = screen.findPreference(getString(R.string.p_about));
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference p) {
- showAbout();
- return true;
- }
- });
-
- preference = screen.findPreference(getString(R.string.p_tutorial));
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference p) {
- Intent showWelcomeLogin = new Intent(EditPreferences.this, WelcomeWalkthrough.class);
- showWelcomeLogin.putExtra(ActFmLoginActivity.SHOW_TOAST, false);
- showWelcomeLogin.putExtra(WelcomeWalkthrough.TOKEN_MANUAL_SHOW, true);
- startActivity(showWelcomeLogin);
- return true;
- }
- });
-
- preference = screen.findPreference(getString(R.string.p_help));
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference p) {
- showSupport();
- return true;
- }
- });
-
- preference = screen.findPreference(getString(R.string.p_account));
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference p) {
- showAccountPrefs();
- return true;
- }
- });
-
- preference = screen.findPreference(getString(R.string.EPr_share_astrid));
- preference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference p) {
- showShareActivity();
- return true;
- }
- });
+ Preference preference;
Preference beastMode = findPreference(getString(R.string.p_beastMode));
beastMode.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@@ -288,46 +238,12 @@ public class EditPreferences extends TodorooPreferenceActivity {
findPreference(getString(R.string.p_voiceRemindersEnabled)).setEnabled(hasPowerPack);
}
- /**
- * Show about dialog
- */
- private void showAbout() {
- String version = "unknown"; //$NON-NLS-1$
- try {
- version = getPackageManager().getPackageInfo(Constants.PACKAGE, 0).versionName;
- } catch (NameNotFoundException e) {
- // sadness
- }
- About.showAbout(this, version);
- }
-
- private void showSupport() {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(SUPPORT_URL));
- startActivity(intent);
- }
-
private void showBeastMode() {
Intent intent = new Intent(this, BeastModePreferences.class);
intent.setAction(AstridApiConstants.ACTION_SETTINGS);
startActivity(intent);
}
- private void showAccountPrefs() {
- if (actFmPreferenceService.isLoggedIn()) {
- Intent intent = new Intent(this, ActFmPreferences.class);
- intent.setAction(AstridApiConstants.ACTION_SETTINGS);
- startActivityForResult(intent, REQUEST_CODE_SYNC);
- } else {
- Intent intent = new Intent(this, ActFmLoginActivity.class);
- startActivity(intent);
- }
- }
-
- private void showShareActivity() {
- Intent intent = new Intent(this, ShareActivity.class);
- startActivity(intent);
- }
-
private static final HashMap, Integer> PREFERENCE_REQUEST_CODES = new HashMap, Integer>();
static {
diff --git a/astrid/src/com/todoroo/astrid/activity/ShareActivity.java b/astrid/src/com/todoroo/astrid/activity/ShareActivity.java
deleted file mode 100644
index 14cf23f6a..000000000
--- a/astrid/src/com/todoroo/astrid/activity/ShareActivity.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.todoroo.astrid.activity;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.DisplayMetrics;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.ImageView;
-import android.widget.ImageView.ScaleType;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.MenuItem;
-import com.timsu.astrid.R;
-import com.todoroo.astrid.service.ThemeService;
-
-public class ShareActivity extends SherlockFragmentActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- ThemeService.applyTheme(this);
- super.onCreate(savedInstanceState);
-
- ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDisplayShowTitleEnabled(false);
-
- actionBar.setDisplayShowCustomEnabled(true);
- actionBar.setCustomView(R.layout.header_title_view);
- ((TextView) actionBar.getCustomView().findViewById(R.id.title)).setText(R.string.EPr_share_astrid);
-
- setContentView(R.layout.share_activity);
- TextView fb = (TextView) findViewById(R.id.share_facebook);
- setUpTextView(fb, getString(R.string.share_with_facebook), "http://facebook.com/weloveastrid", "facebook"); //$NON-NLS-1$ //$NON-NLS-2$
-
- TextView twitter = (TextView) findViewById(R.id.share_twitter);
- setUpTextView(twitter, getString(R.string.share_with_twitter), "http://twitter.com/astrid", "twitter"); //$NON-NLS-1$ //$NON-NLS-2$
-
- TextView google = (TextView) findViewById(R.id.share_google);
- setUpTextView(google, getString(R.string.share_with_google), "https://plus.google.com/116404018347675245869", "google"); //$NON-NLS-1$ //$NON-NLS-2$
-
- setupText();
- }
-
- private void setUpTextView(TextView tv, String text, final String url, final String buttonId) {
- tv.setText(text);
- ((View) tv.getParent()).setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- startActivity(intent);
- }
- });
- }
-
- private void setupText() {
- View speechBubbleBackground = findViewById(R.id.speech_bubble_container);
- speechBubbleBackground.setBackgroundColor(0);
-
- DisplayMetrics metrics = getResources().getDisplayMetrics();
- ImageView icon = (ImageView) findViewById(R.id.astridIcon);
-
- int dim = (int) (80 * metrics.density);
- icon.setLayoutParams(new LinearLayout.LayoutParams(dim, dim));
- icon.setScaleType(ScaleType.FIT_CENTER);
-
- TextView speechBubble = (TextView) findViewById(R.id.reminder_message);
-
- speechBubble.setText(R.string.share_speech_bubble);
- speechBubble.setTextSize(17);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
-}
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
index 9febd06f6..2ec6aa61a 100644
--- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java
@@ -68,7 +68,6 @@ import com.todoroo.astrid.ui.TaskListFragmentPager;
import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Constants;
import com.todoroo.astrid.utility.Flags;
-import com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough;
import org.json.JSONArray;
import org.json.JSONException;
@@ -542,15 +541,6 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
lists.setText(title);
}
- @Override
- protected void onResume() {
- super.onResume();
-
- if (Preferences.getBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, false)) {
- SyncUpgradePrompt.showSyncUpgradePrompt(this);
- }
- }
-
@Override
protected void onPause() {
super.onPause();
diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java
index 840e95661..dec173654 100644
--- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java
+++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java
@@ -105,7 +105,6 @@ import com.todoroo.astrid.ui.QuickAddBar;
import com.todoroo.astrid.utility.AstridPreferences;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.welcome.HelpInfoPopover;
-import com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough;
import com.todoroo.astrid.widget.TasksWidget;
import java.util.List;
@@ -701,17 +700,6 @@ public class TaskListFragment extends SherlockListFragment implements OnSortSele
setUpBackgroundJobs();
- if (!Preferences.getBoolean(
- WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN, false)) {
- Preferences.setBoolean(WelcomeWalkthrough.KEY_SHOWED_WELCOME_LOGIN,
- true);
- Intent showWelcomeLogin = new Intent(getActivity(),
- WelcomeWalkthrough.class);
- showWelcomeLogin.putExtra(ActFmLoginActivity.SHOW_TOAST, false);
- startActivity(showWelcomeLogin);
- return;
- }
-
if (!Preferences.getBoolean(R.string.p_showed_add_task_help, false)) {
showTaskCreateHelpPopover();
} else if (!Preferences.getBoolean(R.string.p_showed_tap_task_help, false)) {
diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomePagerAdapter.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomePagerAdapter.java
deleted file mode 100644
index e9ec182b1..000000000
--- a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomePagerAdapter.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Copyright (c) 2012 Todoroo Inc
- *
- * See the file "LICENSE" for the full license governing this code.
- */
-package com.todoroo.astrid.welcome.tutorial;
-
-
-import android.accounts.Account;
-import android.content.Context;
-import android.os.Parcelable;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
-import com.timsu.astrid.R;
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.service.DependencyInjectionService;
-import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
-import com.todoroo.astrid.utility.Constants;
-import com.viewpagerindicator.TitleProvider;
-
-public class WelcomePagerAdapter extends PagerAdapter implements TitleProvider {
- private int[] images = new int[]{
- R.drawable.welcome_walkthrough_1,
- R.drawable.welcome_walkthrough_2,
- R.drawable.welcome_walkthrough_3,
- R.drawable.welcome_walkthrough_4,
- R.drawable.welcome_walkthrough_5,
- R.drawable.welcome_walkthrough_6,
- 0
- };
- private int[] title = new int[]{
- R.string.welcome_title_1,
- R.string.welcome_title_2,
- R.string.welcome_title_3,
- R.string.welcome_title_4,
- R.string.welcome_title_5,
- R.string.welcome_title_6,
- R.string.welcome_title_7,
- };
- private int[] body = new int[]{
- R.string.welcome_body_1,
- R.string.welcome_body_2,
- R.string.welcome_body_3,
- R.string.welcome_body_4,
- R.string.welcome_body_5,
- R.string.welcome_body_6,
- R.string.welcome_body_7,
- };
- public int[] layouts = new int[]{
- R.layout.welcome_walkthrough_page,
- R.layout.welcome_walkthrough_page,
- R.layout.welcome_walkthrough_page,
- R.layout.welcome_walkthrough_page,
- R.layout.welcome_walkthrough_page,
- R.layout.welcome_walkthrough_page,
- R.layout.actfm_login_activity,
- };
-
- public int fallbackLoginPage;
-
- private final Context context;
- public Account[] accounts;
- public WelcomeWalkthrough parent;
- @Autowired
- ActFmPreferenceService actFmPreferenceService;
-
- public WelcomePagerAdapter(Context context, boolean manual) {
- this.context = context;
- DependencyInjectionService.getInstance().inject(this);
-
- accounts = null;
- try {
- GoogleAccountManager am = new GoogleAccountManager(context);
- accounts = am.getAccounts();
- } catch (Exception e) {
- //
- }
-
- if (manual) {
- layouts[layouts.length - 1] = R.layout.welcome_walkthrough_page;
- title[title.length - 1] = R.string.welcome_title_7_return;
- images[images.length - 1] = R.drawable.welcome_walkthrough_1;
- body[body.length - 1] = R.string.welcome_body_7_return;
- fallbackLoginPage = R.layout.actfm_login_activity;
- } else {
- if (Constants.ASTRID_LITE) {
- adjustResourcesForLite();
- }
-
- // Setup login page from AB tests
- fallbackLoginPage = layouts[layouts.length - 1];
- if (accounts != null && accounts.length > 0) { // If has google account
- layouts[layouts.length - 1] = R.layout.welcome_walkthrough_simple_login;
- fallbackLoginPage = R.layout.actfm_login_activity;
- } else { // If no google account
- fallbackLoginPage = layouts[layouts.length - 1] = R.layout.actfm_login_activity;
- }
- }
- }
-
- private void adjustResourcesForLite() {
- images = new int[]{0};
- title = new int[]{R.string.welcome_title_7};
- body = new int[]{R.string.welcome_body_7};
- layouts = new int[]{R.layout.actfm_login_activity};
- }
-
- @Override
- public void setPrimaryItem(ViewGroup container, int position, Object object) {
- super.setPrimaryItem(container, position, object);
-
- parent.onPageChanged(container, position);
- }
-
-
- @Override
- public int getCount() {
- return layouts.length;
- }
-
- public void changeLoginPage(int newLayout) {
- layouts[layouts.length - 1] = newLayout;
- notifyDataSetChanged();
- }
-
- @Override
- public Object instantiateItem(final View pager, final int position) {
- LayoutInflater inflater = LayoutInflater.from(context);
-
- View pageView = inflater.inflate(layouts[position], null, true);
- pageView.setLayoutParams(new ViewGroup.LayoutParams(
- WindowManager.LayoutParams.MATCH_PARENT,
- WindowManager.LayoutParams.MATCH_PARENT));
-
- if (pageView.findViewById(R.id.welcome_walkthrough_image) != null) {
- ImageView imageView = (ImageView) pageView.findViewById(R.id.welcome_walkthrough_image);
- imageView.setImageResource(images[position]);
-
- TextView titleView = (TextView) pageView.findViewById(R.id.welcome_walkthrough_title);
- titleView.setText(title[position]);
-
- TextView bodyView = (TextView) pageView.findViewById(R.id.welcome_walkthrough_body);
- bodyView.setText(body[position]);
- }
-
- ((ViewPager) pager).addView(pageView, 0);
- parent.instantiatePage(position);
- return pageView;
- }
-
- @Override
- public void destroyItem(View pager, int position, Object view) {
- ((ViewPager) pager).removeView((View) view);
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return view.equals(object);
- }
-
- @Override
- public void finishUpdate(View view) {
- //
- }
-
- @Override
- public void restoreState(Parcelable p, ClassLoader c) {
- //
- }
-
- @Override
- public Parcelable saveState() {
- return null;
- }
-
- @Override
- public void startUpdate(View view) {
- //
- }
-
- @Override
- public String getTitle(int position) {
- return context.getString(title[position]);
- }
-
-}
diff --git a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java b/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java
deleted file mode 100644
index 85f2d1121..000000000
--- a/astrid/src/com/todoroo/astrid/welcome/tutorial/WelcomeWalkthrough.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * Copyright (c) 2012 Todoroo Inc
- *
- * See the file "LICENSE" for the full license governing this code.
- */
-
-package com.todoroo.astrid.welcome.tutorial;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.AccountManagerCallback;
-import android.accounts.AccountManagerFuture;
-import android.app.ProgressDialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.view.ViewPager;
-import android.text.TextUtils;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.google.api.client.googleapis.extensions.android2.auth.GoogleAccountManager;
-import com.timsu.astrid.R;
-import com.todoroo.andlib.utility.DialogUtilities;
-import com.todoroo.astrid.actfm.ActFmGoogleAuthActivity;
-import com.todoroo.astrid.actfm.ActFmLoginActivity;
-import com.viewpagerindicator.CirclePageIndicator;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-public class WelcomeWalkthrough extends ActFmLoginActivity {
- private ViewPager mPager;
- private WelcomePagerAdapter mAdapter;
- private Account[] accounts;
- private CirclePageIndicator mIndicator;
- private View currentView;
-
- private String authToken;
- private boolean onSuccess = false;
- private boolean dismissDialog = false;
-
- public static final String KEY_SHOWED_WELCOME_LOGIN = "key_showed_welcome_login"; //$NON-NLS-1$
-
- public static final String TOKEN_MANUAL_SHOW = "manual"; //$NON-NLS-1$
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- super.onCreate(savedInstanceState);
-
- mAdapter = new WelcomePagerAdapter(this, getIntent().hasExtra(TOKEN_MANUAL_SHOW));
- mAdapter.parent = this;
- accounts = mAdapter.accounts;
-
- mPager = (ViewPager) findViewById(R.id.pager);
- mPager.setAdapter(mAdapter);
-
- mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
- mIndicator.setViewPager(mPager);
- if (mAdapter.getCount() <= 1) {
- mIndicator.setVisibility(View.GONE);
- }
-
- }
-
- @Override
- protected int getContentViewResource() {
- return R.layout.welcome_walkthrough;
- }
-
- @Override
- protected int getTitleResource() {
- return 0;
- }
-
- public void instantiatePage(int position) {
- if (position == mAdapter.getCount() - 1) {
- initializeUI();
- }
- }
-
- private int getLoginPageLayout() {
- return mAdapter.fallbackLoginPage;
- }
-
- @Override
- protected void initializeUI() {
- String email = null;
- if (accounts != null && accounts.length > 0 && !TextUtils.isEmpty(accounts[0].name)) {
- email = accounts[0].name;
- }
- Button simpleLogin = (Button) findViewById(R.id.quick_login_google);
- if (simpleLogin != null && !TextUtils.isEmpty(email)) {
- initializeSimpleUI(email);
- } else {
- if (mAdapter != null && mAdapter.layouts[mAdapter.layouts.length - 1] != getLoginPageLayout()) {
- mAdapter.changeLoginPage(getLoginPageLayout());
- }
- super.initializeUI();
- }
- }
-
- private void initializeSimpleUI(final String email) {
- Button simpleLogin = (Button) findViewById(R.id.quick_login_google);
- simpleLogin.setText(getString(R.string.actfm_quick_login, email));
- simpleLogin.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- final ProgressDialog pd = DialogUtilities.progressDialog(WelcomeWalkthrough.this, getString(R.string.gtasks_GLA_authenticating));
- pd.show();
- getAuthToken(email, pd);
- }
-
- private void getAuthToken(final String e,
- final ProgressDialog pd) {
- final GoogleAccountManager accountManager = new GoogleAccountManager(WelcomeWalkthrough.this);
- Account a = accountManager.getAccountByName(e);
- AccountManagerCallback callback = new AccountManagerCallback() {
- @Override
- public void run(final AccountManagerFuture future) {
- new Thread() {
- @Override
- public void run() {
- try {
- Bundle bundle = future.getResult(30, TimeUnit.SECONDS);
- if (bundle.containsKey(AccountManager.KEY_AUTHTOKEN)) {
- authToken = bundle.getString(AccountManager.KEY_AUTHTOKEN);
- if (!onSuccess) {
- accountManager.manager.invalidateAuthToken(ActFmGoogleAuthActivity.AUTH_TOKEN_TYPE, authToken);
- getAuthToken(e, pd);
- onSuccess = true;
- } else {
- onAuthTokenSuccess(e, authToken);
- dismissDialog = true;
- }
- } else {
- dismissDialog = true;
- }
- } catch (final Exception e) {
- Log.e("actfm-google-auth", "Login Error", e); //$NON-NLS-1$ //$NON-NLS-2$
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- int error = e instanceof IOException ? R.string.gtasks_GLA_errorIOAuth :
- R.string.gtasks_GLA_errorAuth;
- Toast.makeText(WelcomeWalkthrough.this,
- error,
- Toast.LENGTH_LONG).show();
- onAuthError();
- }
- });
- } finally {
- if (dismissDialog) {
- DialogUtilities.dismissDialog(WelcomeWalkthrough.this, pd);
- }
- }
- }
- }.start();
- }
- };
- accountManager.manager.getAuthToken(a, ActFmGoogleAuthActivity.AUTH_TOKEN_TYPE, null, WelcomeWalkthrough.this, callback, null);
- }
- });
-
- TextView rejectQuickLogin = (TextView) findViewById(R.id.quick_login_reject);
- rejectQuickLogin.setText(getString(R.string.actfm_quick_login_reject, email));
- rejectQuickLogin.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- switchToLoginPage();
- }
- });
-
- errors = (TextView) findViewById(R.id.error);
- }
-
- private void onAuthTokenSuccess(final String email, final String authToken) {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- authenticate(email, email, "", "google", authToken); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- }
-
- private void onAuthError() {
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- switchToLoginPage();
- }
- });
- }
-
- private void switchToLoginPage() {
- mAdapter.changeLoginPage(getLoginPageLayout());
- mPager.setAdapter(mAdapter);
- mPager.setCurrentItem(mAdapter.layouts.length - 1, false);
- initializeUI();
- }
-
- public void onPageChanged(View view, int position) {
- int currentPage = position;
- currentView = view;
- findViewById(R.id.next).setVisibility(
- position == mAdapter.getCount() - 1 ? View.GONE : View.VISIBLE);
-
- if (currentPage == mAdapter.getCount() - 1) {
- if (findViewById(R.id.fb_login) != null) {
- setupLoginLater();
- } else {
- OnClickListener done = new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- finish();
- }
- };
- View title = currentView.findViewById(R.id.welcome_walkthrough_title);
- if (title != null) {
- title.setOnClickListener(done);
- }
- View image = currentView.findViewById(R.id.welcome_walkthrough_image);
- if (image != null) {
- image.setOnClickListener(done);
- }
- }
- }
- mIndicator.setVisibility(currentPage == mAdapter.getCount() - 1 ? View.GONE : View.VISIBLE);
- }
-
- protected void setupPWLogin() {
- Button pwLogin = (Button) findViewById(R.id.pw_signup);
- pwLogin.setOnClickListener(signUpListener);
- }
-
- protected void setupLoginLater() {
- TextView loginLater = (TextView) currentView.findViewById(R.id.login_later);
- loginLater.setOnClickListener(loginLaterListener);
- loginLater.setVisibility(View.VISIBLE);
- }
-
-
- protected final OnClickListener loginLaterListener = new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- String title = getString(R.string.welcome_login_confirm_later_title);
- String confirmLater = getString(R.string.welcome_login_confirm_later_dialog);
- DialogUtilities.okCancelCustomDialog(WelcomeWalkthrough.this, title, confirmLater,
- R.string.welcome_login_confirm_later_ok,
- R.string.welcome_login_confirm_later_cancel,
- android.R.drawable.ic_dialog_alert,
- null, confirmLaterListener);
- }
-
- private final DialogInterface.OnClickListener confirmLaterListener = new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- finish();
- }
- };
- };
-
-}