aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-07-16 09:49:37 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-07-16 09:49:37 +0200
commitc1c831e52b11fc976b06b0d850f62e7934f581f6 (patch)
treefb6b89351c0636c37ca7e12a88a82d1027f1e776 /OpenKeychain/src/main
parentd3c54d5f129ca24cbfa08208fc5c79c626897d4b (diff)
downloadopen-keychain-c1c831e52b11fc976b06b0d850f62e7934f581f6.tar.gz
open-keychain-c1c831e52b11fc976b06b0d850f62e7934f581f6.tar.bz2
open-keychain-c1c831e52b11fc976b06b0d850f62e7934f581f6.zip
New first time screen
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r--OpenKeychain/src/main/AndroidManifest.xml9
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java1
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java134
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java74
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java30
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/WizardActivity.java466
-rw-r--r--OpenKeychain/src/main/res/drawable/first_time_1.pngbin0 -> 43898 bytes
-rw-r--r--OpenKeychain/src/main/res/layout/create_key_activity.xml (renamed from OpenKeychain/src/main/res/layout/wizard_create_key_fragment.xml)13
-rw-r--r--OpenKeychain/src/main/res/layout/first_time_activity.xml89
-rw-r--r--OpenKeychain/src/main/res/layout/wizard_activity.xml98
-rw-r--r--OpenKeychain/src/main/res/layout/wizard_k9_fragment.xml43
-rw-r--r--OpenKeychain/src/main/res/layout/wizard_start_fragment.xml63
-rw-r--r--OpenKeychain/src/main/res/menu/key_list.xml6
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml7
15 files changed, 362 insertions, 681 deletions
diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml
index 2283235e7..af09019e8 100644
--- a/OpenKeychain/src/main/AndroidManifest.xml
+++ b/OpenKeychain/src/main/AndroidManifest.xml
@@ -81,9 +81,14 @@
</intent-filter>
</activity>
<activity
- android:name=".ui.WizardActivity"
+ android:name=".ui.FirstTimeActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
- android:label="@string/title_wizard"
+ android:label="@string/app_name"
+ android:windowSoftInputMode="stateHidden" />
+ <activity
+ android:name=".ui.CreateKeyActivity"
+ android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
+ android:label="@string/title_create_key"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".ui.EditKeyActivityOld"
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java
index e1bf1afa4..686a53f5b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java
@@ -68,6 +68,7 @@ public final class Constants {
public static final String FORCE_V3_SIGNATURES = "forceV3Signatures";
public static final String KEY_SERVERS = "keyServers";
public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion";
+ public static final String FIRST_TIME = "firstTime";
}
public static final class Defaults {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java
index 6f3d38ccd..d870b89f5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java
@@ -139,6 +139,16 @@ public class Preferences {
editor.commit();
}
+ public boolean getFirstTime() {
+ return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true);
+ }
+
+ public void setFirstTime(boolean value) {
+ SharedPreferences.Editor editor = mSharedPreferences.edit();
+ editor.putBoolean(Constants.Pref.FIRST_TIME, value);
+ editor.commit();
+ }
+
public String[] getKeyServers() {
String rawData = mSharedPreferences.getString(Constants.Pref.KEY_SERVERS,
Constants.Defaults.KEY_SERVERS);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java
new file mode 100644
index 000000000..3094c0e19
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.ui;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.util.Patterns;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.Button;
+import android.widget.EditText;
+
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.helper.ContactHelper;
+
+import java.util.regex.Matcher;
+
+public class CreateKeyActivity extends ActionBarActivity {
+
+ AutoCompleteTextView nameEdit;
+ AutoCompleteTextView emailEdit;
+ EditText passphraseEdit;
+ Button createButton;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.create_key_activity);
+
+ nameEdit = (AutoCompleteTextView) findViewById(R.id.name);
+ emailEdit = (AutoCompleteTextView) findViewById(R.id.email);
+ passphraseEdit = (EditText) findViewById(R.id.passphrase);
+ createButton = (Button) findViewById(R.id.create_key_button);
+
+ emailEdit.setThreshold(1); // Start working from first character
+ emailEdit.setAdapter(
+ new ArrayAdapter<String>
+ (this, android.R.layout.simple_spinner_dropdown_item,
+ ContactHelper.getPossibleUserEmails(this)
+ )
+ );
+ emailEdit.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+ String email = editable.toString();
+ if (email.length() > 0) {
+ Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
+ if (emailMatcher.matches()) {
+ emailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0,
+ R.drawable.uid_mail_ok, 0);
+ } else {
+ emailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0,
+ R.drawable.uid_mail_bad, 0);
+ }
+ } else {
+ // remove drawable if email is empty
+ emailEdit.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
+ }
+ }
+ });
+ nameEdit.setThreshold(1); // Start working from first character
+ nameEdit.setAdapter(
+ new ArrayAdapter<String>
+ (this, android.R.layout.simple_spinner_dropdown_item,
+ ContactHelper.getPossibleUserNames(this)
+ )
+ );
+
+ createButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ createKey();
+ }
+ });
+
+ }
+
+ private void createKey() {
+ if (isEditTextNotEmpty(this, nameEdit)
+ && isEditTextNotEmpty(this, emailEdit)
+ && isEditTextNotEmpty(this, passphraseEdit)) {
+
+ }
+ }
+
+ /**
+ * Checks if text of given EditText is not empty. If it is empty an error is
+ * set and the EditText gets the focus.
+ *
+ * @param context
+ * @param editText
+ * @return true if EditText is not empty
+ */
+ private static boolean isEditTextNotEmpty(Context context, EditText editText) {
+ boolean output = true;
+ if (editText.getText().toString().length() == 0) {
+ editText.setError("empty!");
+ editText.requestFocus();
+ output = false;
+ } else {
+ editText.setError(null);
+ }
+
+ return output;
+ }
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java
new file mode 100644
index 000000000..7de5e16b0
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/FirstTimeActivity.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.sufficientlysecure.keychain.ui;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.view.View;
+import android.view.Window;
+import android.widget.Button;
+
+import org.sufficientlysecure.keychain.R;
+
+public class FirstTimeActivity extends ActionBarActivity {
+
+ Button mCreateKey;
+ Button mImportKey;
+ Button mSkipSetup;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
+
+ setContentView(R.layout.first_time_activity);
+
+ mCreateKey = (Button) findViewById(R.id.first_time_create_key);
+ mImportKey = (Button) findViewById(R.id.first_time_import_key);
+ mSkipSetup = (Button) findViewById(R.id.first_time_cancel);
+
+ mSkipSetup.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(FirstTimeActivity.this, KeyListActivity.class);
+ startActivity(intent);
+ }
+ });
+
+ mImportKey.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(FirstTimeActivity.this, ImportKeysActivity.class);
+ intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
+ startActivity(intent);
+ }
+ });
+
+ mCreateKey.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(FirstTimeActivity.this, CreateKeyActivity.class);
+ startActivity(intent);
+ }
+ });
+
+ }
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
index da9986890..b4daf1822 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java
@@ -32,6 +32,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Constants.choice.algorithm;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.ExportHelper;
+import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
@@ -50,6 +51,15 @@ public class KeyListActivity extends DrawerActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Preferences prefs = Preferences.getPreferences(this);
+ if (prefs.getFirstTime()) {
+ prefs.setFirstTime(false);
+ Intent intent = new Intent(this, FirstTimeActivity.class);
+ startActivity(intent);
+ finish();
+ return;
+ }
+
mExportHelper = new ExportHelper(this);
setContentView(R.layout.key_list_activity);
@@ -63,9 +73,10 @@ public class KeyListActivity extends DrawerActivity {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.key_list, menu);
- if(Constants.DEBUG) {
+ if (Constants.DEBUG) {
menu.findItem(R.id.menu_key_list_debug_read).setVisible(true);
menu.findItem(R.id.menu_key_list_debug_write).setVisible(true);
+ menu.findItem(R.id.menu_key_list_debug_first_time).setVisible(true);
}
return true;
@@ -95,7 +106,7 @@ public class KeyListActivity extends DrawerActivity {
KeychainDatabase.debugRead(this);
AppMsg.makeText(this, "Restored from backup", AppMsg.STYLE_CONFIRM).show();
getContentResolver().notifyChange(KeychainContract.KeyRings.CONTENT_URI, null);
- } catch(IOException e) {
+ } catch (IOException e) {
Log.e(Constants.TAG, "IO Error", e);
AppMsg.makeText(this, "IO Error: " + e.getMessage(), AppMsg.STYLE_ALERT).show();
}
@@ -105,12 +116,18 @@ public class KeyListActivity extends DrawerActivity {
try {
KeychainDatabase.debugWrite(this);
AppMsg.makeText(this, "Backup successful", AppMsg.STYLE_CONFIRM).show();
- } catch(IOException e) {
+ } catch (IOException e) {
Log.e(Constants.TAG, "IO Error", e);
AppMsg.makeText(this, "IO Error: " + e.getMessage(), AppMsg.STYLE_ALERT).show();
}
return true;
+ case R.id.menu_key_list_debug_first_time:
+ Intent intent = new Intent(this, FirstTimeActivity.class);
+ startActivity(intent);
+ finish();
+ return true;
+
default:
return super.onOptionsItemSelected(item);
}
@@ -122,11 +139,8 @@ public class KeyListActivity extends DrawerActivity {
}
private void createKey() {
- Intent intent = new Intent(this, WizardActivity.class);
-// intent.setAction(EditKeyActivity.ACTION_CREATE_KEY);
-// intent.putExtra(EditKeyActivity.EXTRA_GENERATE_DEFAULT_KEYS, true);
-// intent.putExtra(EditKeyActivity.EXTRA_USER_IDS, ""); // show user id view
- startActivityForResult(intent, 0);
+ Intent intent = new Intent(this, CreateKeyActivity.class);
+ startActivity(intent);
}
private void createKeyExpert() {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/WizardActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/WizardActivity.java
deleted file mode 100644
index 7a2233524..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/WizardActivity.java
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.sufficientlysecure.keychain.ui;
-
-import android.app.Activity;
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-import android.support.v7.app.ActionBarActivity;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.Patterns;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.RadioGroup;
-import android.widget.TextView;
-
-import org.sufficientlysecure.htmltextview.HtmlTextView;
-import org.sufficientlysecure.keychain.Constants;
-import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.helper.ContactHelper;
-import org.sufficientlysecure.keychain.util.Log;
-
-import java.util.regex.Matcher;
-
-
-public class WizardActivity extends ActionBarActivity {
-
- private State mCurrentState;
-
- // values for mCurrentScreen
- private enum State {
- START, CREATE_KEY, IMPORT_KEY, K9
- }
-
- public static final int REQUEST_CODE_IMPORT = 0x00007703;
-
- Button mBackButton;
- Button mNextButton;
- StartFragment mStartFragment;
- CreateKeyFragment mCreateKeyFragment;
- K9Fragment mK9Fragment;
-
- private static final String K9_PACKAGE = "com.fsck.k9";
- // private static final String K9_MARKET_INTENT_URI_BASE = "market://details?id=%s";
-// private static final Intent K9_MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse(
-// String.format(K9_MARKET_INTENT_URI_BASE, K9_PACKAGE)));
- private static final Intent K9_MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/k9mail/k-9/releases/tag/4.904"));
-
- LinearLayout mProgressLayout;
- View mProgressLine;
- ProgressBar mProgressBar;
- ImageView mProgressImage;
- TextView mProgressText;
-
- /**
- * Checks if text of given EditText is not empty. If it is empty an error is
- * set and the EditText gets the focus.
- *
- * @param context
- * @param editText
- * @return true if EditText is not empty
- */
- private static boolean isEditTextNotEmpty(Context context, EditText editText) {
- boolean output = true;
- if (editText.getText().toString().length() == 0) {
- editText.setError("empty!");
- editText.requestFocus();
- output = false;
- } else {
- editText.setError(null);
- }
-
- return output;
- }
-
- public static class StartFragment extends Fragment {
- public static StartFragment newInstance() {
- StartFragment myFragment = new StartFragment();
-
- Bundle args = new Bundle();
- myFragment.setArguments(args);
-
- return myFragment;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return inflater.inflate(R.layout.wizard_start_fragment,
- container, false);
- }
- }
-
- public static class CreateKeyFragment extends Fragment {
- public static CreateKeyFragment newInstance() {
- CreateKeyFragment myFragment = new CreateKeyFragment();
-
- Bundle args = new Bundle();
- myFragment.setArguments(args);
-
- return myFragment;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.wizard_create_key_fragment,
- container, false);
-
- final AutoCompleteTextView emailView = (AutoCompleteTextView) view.findViewById(R.id.email);
- emailView.setThreshold(1); // Start working from first character
- emailView.setAdapter(
- new ArrayAdapter<String>
- (getActivity(), android.R.layout.simple_spinner_dropdown_item,
- ContactHelper.getPossibleUserEmails(getActivity())
- )
- );
- emailView.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- String email = editable.toString();
- if (email.length() > 0) {
- Matcher emailMatcher = Patterns.EMAIL_ADDRESS.matcher(email);
- if (emailMatcher.matches()) {
- emailView.setCompoundDrawablesWithIntrinsicBounds(0, 0,
- R.drawable.uid_mail_ok, 0);
- } else {
- emailView.setCompoundDrawablesWithIntrinsicBounds(0, 0,
- R.drawable.uid_mail_bad, 0);
- }
- } else {
- // remove drawable if email is empty
- emailView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
- }
- }
- });
- final AutoCompleteTextView nameView = (AutoCompleteTextView) view.findViewById(R.id.name);
- nameView.setThreshold(1); // Start working from first character
- nameView.setAdapter(
- new ArrayAdapter<String>
- (getActivity(), android.R.layout.simple_spinner_dropdown_item,
- ContactHelper.getPossibleUserNames(getActivity())
- )
- );
- return view;
- }
- }
-
- public static class K9Fragment extends Fragment {
- public static K9Fragment newInstance() {
- K9Fragment myFragment = new K9Fragment();
-
- Bundle args = new Bundle();
- myFragment.setArguments(args);
-
- return myFragment;
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.wizard_k9_fragment,
- container, false);
-
- HtmlTextView text = (HtmlTextView) v
- .findViewById(R.id.wizard_k9_text);
- text.setHtmlFromString("Install K9. It's good for you! Here is a screenhot how to enable OK in K9: (TODO)", true);
-
- return v;
- }
-
- }
-
- /**
- * Loads new fragment
- *
- * @param fragment
- */
- private void loadFragment(Fragment fragment) {
- FragmentManager fragmentManager = getSupportFragmentManager();
- FragmentTransaction fragmentTransaction = fragmentManager
- .beginTransaction();
- fragmentTransaction.replace(R.id.wizard_container,
- fragment);
- fragmentTransaction.commit();
- }
-
- /**
- * Instantiate View and initialize fragments for this Activity
- */
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.wizard_activity);
- mBackButton = (Button) findViewById(R.id.wizard_back);
- mNextButton = (Button) findViewById(R.id.wizard_next);
-
- // progress layout
- mProgressLayout = (LinearLayout) findViewById(R.id.wizard_progress);
- mProgressLine = findViewById(R.id.wizard_progress_line);
- mProgressBar = (ProgressBar) findViewById(R.id.wizard_progress_progressbar);
- mProgressImage = (ImageView) findViewById(R.id.wizard_progress_image);
- mProgressText = (TextView) findViewById(R.id.wizard_progress_text);
-
- changeToState(State.START);
- }
-
- private enum ProgressState {
- WORKING, ENABLED, DISABLED, ERROR
- }
-
- private void showProgress(ProgressState state, String text) {
- switch (state) {
- case WORKING:
- mProgressBar.setVisibility(View.VISIBLE);
- mProgressImage.setVisibility(View.GONE);
- break;
- case ENABLED:
- mProgressBar.setVisibility(View.GONE);
- mProgressImage.setVisibility(View.VISIBLE);
-// mProgressImage.setImageDrawable(getResources().getDrawable(
-// R.drawable.status_enabled));
- break;
- case DISABLED:
- mProgressBar.setVisibility(View.GONE);
- mProgressImage.setVisibility(View.VISIBLE);
-// mProgressImage.setImageDrawable(getResources().getDrawable(
-// R.drawable.status_disabled));
- break;
- case ERROR:
- mProgressBar.setVisibility(View.GONE);
- mProgressImage.setVisibility(View.VISIBLE);
-// mProgressImage.setImageDrawable(getResources().getDrawable(
-// R.drawable.status_fail));
- break;
-
- default:
- break;
- }
- mProgressText.setText(text);
-
- mProgressLine.setVisibility(View.VISIBLE);
- mProgressLayout.setVisibility(View.VISIBLE);
- }
-
- private void hideProgress() {
- mProgressLine.setVisibility(View.GONE);
- mProgressLayout.setVisibility(View.GONE);
- }
-
- public void nextOnClick(View view) {
- // close keyboard
- if (getCurrentFocus() != null) {
- InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- inputManager.hideSoftInputFromWindow(getCurrentFocus()
- .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- }
-
- switch (mCurrentState) {
- case START: {
- RadioGroup radioGroup = (RadioGroup) findViewById(R.id.wizard_start_radio_group);
- int selectedId = radioGroup.getCheckedRadioButtonId();
- switch (selectedId) {
- case R.id.wizard_start_new_key: {
- changeToState(State.CREATE_KEY);
- break;
- }
- case R.id.wizard_start_import: {
- changeToState(State.IMPORT_KEY);
- break;
- }
- case R.id.wizard_start_skip: {
- finish();
- break;
- }
- }
-
- mBackButton.setText(R.string.btn_back);
- break;
- }
- case CREATE_KEY:
- EditText nameEdit = (EditText) findViewById(R.id.name);
- EditText emailEdit = (EditText) findViewById(R.id.email);
- EditText passphraseEdit = (EditText) findViewById(R.id.passphrase);
-
- if (isEditTextNotEmpty(this, nameEdit)
- && isEditTextNotEmpty(this, emailEdit)
- && isEditTextNotEmpty(this, passphraseEdit)) {
-
-// SaveKeyringParcel newKey = new SaveKeyringParcel();
-// newKey.mAddUserIds.add(nameEdit.getText().toString() + " <"
-// + emailEdit.getText().toString() + ">");
-
-
- AsyncTask<String, Boolean, Boolean> generateTask = new AsyncTask<String, Boolean, Boolean>() {
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
-
- showProgress(ProgressState.WORKING, "generating key...");
- }
-
- @Override
- protected Boolean doInBackground(String... params) {
- return true;
- }
-
- @Override
- protected void onPostExecute(Boolean result) {
- super.onPostExecute(result);
-
- if (result) {
- showProgress(ProgressState.ENABLED, "key generated successfully!");
-
- changeToState(State.K9);
- } else {
- showProgress(ProgressState.ERROR, "error in key gen");
- }
- }
-
- };
-
- generateTask.execute("");
- }
- break;
- case K9: {
- RadioGroup radioGroup = (RadioGroup) findViewById(R.id.wizard_k9_radio_group);
- int selectedId = radioGroup.getCheckedRadioButtonId();
- switch (selectedId) {
- case R.id.wizard_k9_install: {
- try {
- startActivity(K9_MARKET_INTENT);
- } catch (ActivityNotFoundException e) {
- Log.e(Constants.TAG, "Activity not found for: " + K9_MARKET_INTENT);
- }
- break;
- }
- case R.id.wizard_k9_skip: {
- finish();
- break;
- }
- }
-
- finish();
- break;
- }
- default:
- break;
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- switch (requestCode) {
- case REQUEST_CODE_IMPORT: {
- if (resultCode == Activity.RESULT_OK) {
- // imported now...
- changeToState(State.K9);
- } else {
- // back to start
- changeToState(State.START);
- }
- break;
- }
-
- default: {
- super.onActivityResult(requestCode, resultCode, data);
-
- break;
- }
- }
- }
-
- public void backOnClick(View view) {
- switch (mCurrentState) {
- case START:
- finish();
- break;
- case CREATE_KEY:
- changeToState(State.START);
- break;
- case IMPORT_KEY:
- changeToState(State.START);
- break;
- default:
- changeToState(State.START);
- break;
- }
- }
-
- private void changeToState(State state) {
- switch (state) {
- case START: {
- mCurrentState = State.START;
- mStartFragment = StartFragment.newInstance();
- loadFragment(mStartFragment);
- mBackButton.setText(android.R.string.cancel);
- mNextButton.setText(R.string.btn_next);
- break;
- }
- case CREATE_KEY: {
- mCurrentState = State.CREATE_KEY;
- mCreateKeyFragment = CreateKeyFragment.newInstance();
- loadFragment(mCreateKeyFragment);
- break;
- }
- case IMPORT_KEY: {
- mCurrentState = State.IMPORT_KEY;
- Intent intent = new Intent(this, ImportKeysActivity.class);
- intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
- startActivityForResult(intent, REQUEST_CODE_IMPORT);
- break;
- }
- case K9: {
- mCurrentState = State.K9;
- mBackButton.setEnabled(false); // don't go back to import/create key
- mK9Fragment = K9Fragment.newInstance();
- loadFragment(mK9Fragment);
- break;
- }
- }
- }
-
-}
diff --git a/OpenKeychain/src/main/res/drawable/first_time_1.png b/OpenKeychain/src/main/res/drawable/first_time_1.png
new file mode 100644
index 000000000..1f340df5c
--- /dev/null
+++ b/OpenKeychain/src/main/res/drawable/first_time_1.png
Binary files differ
diff --git a/OpenKeychain/src/main/res/layout/wizard_create_key_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_activity.xml
index 258ea7223..673f43084 100644
--- a/OpenKeychain/src/main/res/layout/wizard_create_key_fragment.xml
+++ b/OpenKeychain/src/main/res/layout/create_key_activity.xml
@@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:padding="8dp"
android:orientation="vertical">
<TextView
@@ -38,4 +39,16 @@
android:layout_gravity="center_horizontal" />
+ <Button
+ android:id="@+id/create_key_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_horizontal"
+ android:layout_margin="8dp"
+ android:text="@string/first_time_create_key"
+ android:background="@drawable/button_edgy"
+ android:drawableLeft="@drawable/ic_action_new_account" />
+
+
</LinearLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/first_time_activity.xml b/OpenKeychain/src/main/res/layout/first_time_activity.xml
new file mode 100644
index 000000000..514f34212
--- /dev/null
+++ b/OpenKeychain/src/main/res/layout/first_time_activity.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="16dp"
+ android:paddingBottom="8dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="@string/app_name"
+ android:drawableLeft="@drawable/ic_launcher"
+ android:drawablePadding="16dp"
+ android:gravity="center"
+ android:layout_gravity="center_horizontal" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_marginLeft="64dp"
+ android:layout_marginRight="64dp"
+ android:layout_marginTop="16dp"
+ android:layout_marginBottom="16dp"
+ android:layout_height="256dp"
+ android:src="@drawable/first_time_1" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="64dp"
+ android:layout_marginRight="64dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/first_time_text1"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center_horizontal" />
+
+
+ </LinearLayout>
+
+ <Button
+ android:id="@+id/first_time_cancel"
+ android:layout_alignParentBottom="true"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:layout_marginLeft="8dp"
+ android:layout_marginRight="8dp"
+ android:text="@string/first_time_skip"
+ android:background="@drawable/button_edgy" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_above="@id/first_time_cancel"
+ android:orientation="horizontal">
+
+ <Button
+ android:id="@+id/first_time_create_key"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_weight="1"
+ android:layout_marginLeft="8dp"
+ android:layout_marginRight="8dp"
+ android:text="@string/first_time_create_key"
+ android:background="@drawable/button_edgy"
+ android:drawableLeft="@drawable/ic_action_new_account" />
+
+ <Button
+ android:id="@+id/first_time_import_key"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginLeft="8dp"
+ android:layout_marginRight="8dp"
+ android:text="@string/first_time_import_key"
+ android:background="@drawable/button_edgy"
+ android:drawableLeft="@drawable/ic_action_download" />
+ </LinearLayout>
+
+
+</RelativeLayout>
diff --git a/OpenKeychain/src/main/res/layout/wizard_activity.xml b/OpenKeychain/src/main/res/layout/wizard_activity.xml
deleted file mode 100644
index 299d07a76..000000000
--- a/OpenKeychain/src/main/res/layout/wizard_activity.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:id="@+id/wizard_buttons"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/wizard_back"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:onClick="backOnClick"
- android:text="cancel"
- style="@style/SelectableItem" />
-
- <View
- android:layout_width="1dip"
- android:layout_height="match_parent"
- android:layout_marginBottom="4dip"
- android:layout_marginTop="4dip"
- android:background="?android:attr/listDivider" />
-
- <Button
- android:id="@+id/wizard_next"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:onClick="nextOnClick"
- android:text="next"
- style="@style/SelectableItem" />
- </LinearLayout>
-
- <View
- android:id="@+id/wizard_progress_line"
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:layout_above="@+id/wizard_buttons"
- android:layout_marginLeft="4dip"
- android:layout_marginRight="4dip"
- android:background="?android:attr/listDivider"
- android:visibility="gone" />
-
- <LinearLayout
- android:id="@+id/wizard_progress"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_above="@+id/wizard_progress_line"
- android:visibility="gone">
-
- <ProgressBar
- android:id="@+id/wizard_progress_progressbar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <ImageView
- android:id="@+id/wizard_progress_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/icon_light_refresh" />
-
- <TextView
- android:id="@+id/wizard_progress_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="asd"
- android:textAppearance="?android:attr/textAppearanceMedium" />
- </LinearLayout>
-
- <View
- android:id="@+id/wizard_line2"
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:layout_above="@+id/wizard_progress"
- android:layout_marginLeft="4dip"
- android:layout_marginRight="4dip"
- android:background="?android:attr/listDivider" />
-
- <ScrollView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_above="@+id/wizard_line2">
-
- <LinearLayout
- android:id="@+id/wizard_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:padding="16dp" />
- </ScrollView>
-
-</RelativeLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/wizard_k9_fragment.xml b/OpenKeychain/src/main/res/layout/wizard_k9_fragment.xml
deleted file mode 100644
index 342adc37e..000000000
--- a/OpenKeychain/src/main/res/layout/wizard_k9_fragment.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <org.sufficientlysecure.htmltextview.HtmlTextView
- android:id="@+id/wizard_k9_text"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="4dp"
- android:text="Text..."
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <RadioGroup
- android:id="@+id/wizard_k9_radio_group"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <RadioButton
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:checked="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- style="@style/SelectableItem"
- android:text="install K9"
- android:id="@+id/wizard_k9_install" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <RadioButton
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:textAppearance="?android:attr/textAppearanceMedium"
- style="@style/SelectableItem"
- android:text="skip install"
- android:id="@+id/wizard_k9_skip" />
- </RadioGroup>
-
-</LinearLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/wizard_start_fragment.xml b/OpenKeychain/src/main/res/layout/wizard_start_fragment.xml
deleted file mode 100644
index 9e1403f74..000000000
--- a/OpenKeychain/src/main/res/layout/wizard_start_fragment.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingBottom="4dp"
- android:text="Welcome to OpenKeychain"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <TextView
- style="@style/SectionHeader"
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:layout_marginTop="14dp"
- android:text="What you wanna do today?"
- android:layout_weight="1" />
-
- <RadioGroup
- android:id="@+id/wizard_start_radio_group"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <RadioButton
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:checked="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- style="@style/SelectableItem"
- android:text="new key"
- android:id="@+id/wizard_start_new_key" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <RadioButton
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:textAppearance="?android:attr/textAppearanceMedium"
- style="@style/SelectableItem"
- android:text="import existing key"
- android:id="@+id/wizard_start_import" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:background="?android:attr/listDivider" />
-
- <RadioButton
- android:layout_width="match_parent"
- android:layout_height="?android:attr/listPreferredItemHeight"
- android:textAppearance="?android:attr/textAppearanceMedium"
- style="@style/SelectableItem"
- android:text="skip wizard"
- android:id="@+id/wizard_start_skip" />
- </RadioGroup>
-
-</LinearLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/menu/key_list.xml b/OpenKeychain/src/main/res/menu/key_list.xml
index ebb7314b8..78f29fe5e 100644
--- a/OpenKeychain/src/main/res/menu/key_list.xml
+++ b/OpenKeychain/src/main/res/menu/key_list.xml
@@ -43,4 +43,10 @@
android:title="Debug / DB backup"
android:visible="false" />
+ <item
+ android:id="@+id/menu_key_list_debug_first_time"
+ app:showAsAction="never"
+ android:title="Debug / Show first time screen"
+ android:visible="false" />
+
</menu>
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 80b8bb507..32e35b0ba 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -9,7 +9,6 @@
<string name="title_authentication">Passphrase</string>
<string name="title_create_key">Create Key</string>
<string name="title_edit_key">Edit Key</string>
- <string name="title_wizard">Welcome to OpenKeychain</string>
<string name="title_preferences">Preferences</string>
<string name="title_api_registered_apps">Apps</string>
<string name="title_key_server_preference">Keyserver Preference</string>
@@ -704,4 +703,10 @@
<string name="info_no_manual_account_creation">Do not create OpenKeychain-Accounts manually.\nFor more information, see Help.</string>
<string name="contact_show_key">Show key (%s)</string>
+ <!-- First Time -->
+ <string name="first_time_text1">Take back your privacy with OpenKeychain!</string>
+ <string name="first_time_create_key">Create Key</string>
+ <string name="first_time_import_key">Import Key</string>
+ <string name="first_time_skip">Skip Setup</string>
+
</resources>