Work on first time wizard design

This commit is contained in:
Dominik Schürmann 2014-07-27 17:56:52 +02:00
parent 45722d7cfb
commit dab540e121
11 changed files with 216 additions and 108 deletions

View File

@ -89,7 +89,11 @@
android:name=".ui.CreateKeyActivity" android:name=".ui.CreateKeyActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_create_key" android:label="@string/title_create_key"
android:windowSoftInputMode="stateHidden" /> android:windowSoftInputMode="stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.KeyListActivity" />
</activity>
<activity <activity
android:name=".ui.EditKeyActivityOld" android:name=".ui.EditKeyActivityOld"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard" android:configChanges="orientation|screenSize|keyboardHidden|keyboard"

View File

@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
@ -31,7 +32,11 @@ import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner;
import com.devspark.appmsg.AppMsg;
import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.bcpg.sig.KeyFlags;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
@ -48,7 +53,8 @@ public class CreateKeyActivity extends ActionBarActivity {
AutoCompleteTextView mNameEdit; AutoCompleteTextView mNameEdit;
AutoCompleteTextView mEmailEdit; AutoCompleteTextView mEmailEdit;
EditText mPassphraseEdit; EditText mPassphraseEdit;
Button mCreateButton; View mCreateButton;
CheckBox mUploadCheckbox;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -59,7 +65,8 @@ public class CreateKeyActivity extends ActionBarActivity {
mNameEdit = (AutoCompleteTextView) findViewById(R.id.name); mNameEdit = (AutoCompleteTextView) findViewById(R.id.name);
mEmailEdit = (AutoCompleteTextView) findViewById(R.id.email); mEmailEdit = (AutoCompleteTextView) findViewById(R.id.email);
mPassphraseEdit = (EditText) findViewById(R.id.passphrase); mPassphraseEdit = (EditText) findViewById(R.id.passphrase);
mCreateButton = (Button) findViewById(R.id.create_key_button); mCreateButton = findViewById(R.id.create_key_button);
mUploadCheckbox = (CheckBox) findViewById(R.id.create_key_upload);
mEmailEdit.setThreshold(1); // Start working from first character mEmailEdit.setThreshold(1); // Start working from first character
mEmailEdit.setAdapter( mEmailEdit.setAdapter(
@ -134,10 +141,15 @@ public class CreateKeyActivity extends ActionBarActivity {
// handle messages by standard KeychainIntentServiceHandler first // handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message); super.handleMessage(message);
// TODO
// if (mUploadCheckbox.isChecked()) {
// uploadKey();
// } else {
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
CreateKeyActivity.this.setResult(RESULT_OK); CreateKeyActivity.this.setResult(RESULT_OK);
CreateKeyActivity.this.finish(); CreateKeyActivity.this.finish();
} }
// }
} }
}; };
@ -166,6 +178,54 @@ public class CreateKeyActivity extends ActionBarActivity {
startService(intent); startService(intent);
} }
private void uploadKey() {
// Send all information needed to service to upload key in other thread
Intent intent = new Intent(this, KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING);
// set data uri as path to keyring
// TODO
// Uri blobUri = KeychainContract.KeyRingData.buildPublicKeyRingUri(mDataUri);
// intent.setData(blobUri);
// fill values for this action
Bundle data = new Bundle();
Spinner keyServer = (Spinner) findViewById(R.id.upload_key_keyserver);
String server = (String) keyServer.getSelectedItem();
data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, server);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
// Message is received after uploading is done in KeychainIntentService
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this,
getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL) {
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
AppMsg.makeText(CreateKeyActivity.this, R.string.key_send_success,
AppMsg.STYLE_INFO).show();
CreateKeyActivity.this.setResult(RESULT_OK);
CreateKeyActivity.this.finish();
}
}
};
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);
// start service with intent
startService(intent);
}
/** /**
* Checks if text of given EditText is not empty. If it is empty an error is * Checks if text of given EditText is not empty. If it is empty an error is
* set and the EditText gets the focus. * set and the EditText gets the focus.
@ -177,7 +237,7 @@ public class CreateKeyActivity extends ActionBarActivity {
private static boolean isEditTextNotEmpty(Context context, EditText editText) { private static boolean isEditTextNotEmpty(Context context, EditText editText) {
boolean output = true; boolean output = true;
if (editText.getText().toString().length() == 0) { if (editText.getText().toString().length() == 0) {
editText.setError("empty!"); editText.setError(context.getString(R.string.create_key_empty));
editText.requestFocus(); editText.requestFocus();
output = false; output = false;
} else { } else {

View File

@ -58,7 +58,7 @@ public class EncryptFileFragment extends Fragment {
public static final String ARG_FILENAME = "filename"; public static final String ARG_FILENAME = "filename";
public static final String ARG_ASCII_ARMOR = "ascii_armor"; public static final String ARG_ASCII_ARMOR = "ascii_armor";
private static final int RESULT_CODE_FILE = 0x00007003; private static final int REQUEST_CODE_FILE = 0x00007003;
private EncryptActivityInterface mEncryptInterface; private EncryptActivityInterface mEncryptInterface;
@ -109,10 +109,10 @@ public class EncryptFileFragment extends Fragment {
mBrowse.setOnClickListener(new View.OnClickListener() { mBrowse.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
if (Constants.KITKAT) { if (Constants.KITKAT) {
FileHelper.openDocument(EncryptFileFragment.this, mInputUri, "*/*", RESULT_CODE_FILE); FileHelper.openDocument(EncryptFileFragment.this, mInputUri, "*/*", REQUEST_CODE_FILE);
} else { } else {
FileHelper.openFile(EncryptFileFragment.this, mFilename.getText().toString(), "*/*", FileHelper.openFile(EncryptFileFragment.this, mFilename.getText().toString(), "*/*",
RESULT_CODE_FILE); REQUEST_CODE_FILE);
} }
} }
}); });
@ -390,7 +390,7 @@ public class EncryptFileFragment extends Fragment {
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) { switch (requestCode) {
case RESULT_CODE_FILE: { case REQUEST_CODE_FILE: {
if (resultCode == Activity.RESULT_OK && data != null) { if (resultCode == Activity.RESULT_OK && data != null) {
if (Constants.KITKAT) { if (Constants.KITKAT) {
mInputUri = data.getData(); mInputUri = data.getData();

View File

@ -24,8 +24,10 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.widget.Button; import android.widget.Button;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.util.Log;
public class FirstTimeActivity extends ActionBarActivity { public class FirstTimeActivity extends ActionBarActivity {
@ -33,6 +35,8 @@ public class FirstTimeActivity extends ActionBarActivity {
Button mImportKey; Button mImportKey;
Button mSkipSetup; Button mSkipSetup;
public static final int REQUEST_CODE_CREATE_OR_IMPORT_KEY = 0x00007012;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -57,7 +61,7 @@ public class FirstTimeActivity extends ActionBarActivity {
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(FirstTimeActivity.this, ImportKeysActivity.class); Intent intent = new Intent(FirstTimeActivity.this, ImportKeysActivity.class);
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN); intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
startActivityForResult(intent, 1); startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
} }
}); });
@ -65,7 +69,7 @@ public class FirstTimeActivity extends ActionBarActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(FirstTimeActivity.this, CreateKeyActivity.class); Intent intent = new Intent(FirstTimeActivity.this, CreateKeyActivity.class);
startActivityForResult(intent, 1); startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
} }
}); });
@ -75,9 +79,13 @@ public class FirstTimeActivity extends ActionBarActivity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_CREATE_OR_IMPORT_KEY) {
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
finishSetup(); finishSetup();
} }
} else {
Log.e(Constants.TAG, "No valid request code!");
}
} }
private void finishSetup() { private void finishSetup() {

View File

@ -109,6 +109,8 @@ public class KeyListActivity extends DrawerActivity {
return true; return true;
case R.id.menu_key_list_debug_first_time: case R.id.menu_key_list_debug_first_time:
Preferences prefs = Preferences.getPreferences(this);
prefs.setFirstTime(true);
Intent intent = new Intent(this, FirstTimeActivity.class); Intent intent = new Intent(this, FirstTimeActivity.class);
startActivity(intent); startActivity(intent);
finish(); finish();

View File

@ -86,6 +86,7 @@ public class KeyListFragment extends LoaderFragment
private Button mButtonEmptyCreate; private Button mButtonEmptyCreate;
private Button mButtonEmptyImport; private Button mButtonEmptyImport;
public static final int REQUEST_CODE_CREATE_OR_IMPORT_KEY = 0x00007012;
/** /**
* Load custom layout with StickyListView from library * Load custom layout with StickyListView from library
@ -104,11 +105,8 @@ public class KeyListFragment extends LoaderFragment
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getActivity(), EditKeyActivityOld.class); Intent intent = new Intent(getActivity(), CreateKeyActivity.class);
intent.setAction(EditKeyActivityOld.ACTION_CREATE_KEY); startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
intent.putExtra(EditKeyActivityOld.EXTRA_GENERATE_DEFAULT_KEYS, true);
intent.putExtra(EditKeyActivityOld.EXTRA_USER_IDS, ""); // show user id view
startActivityForResult(intent, 0);
} }
}); });
mButtonEmptyImport = (Button) view.findViewById(R.id.key_list_empty_button_import); mButtonEmptyImport = (Button) view.findViewById(R.id.key_list_empty_button_import);
@ -117,8 +115,8 @@ public class KeyListFragment extends LoaderFragment
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getActivity(), ImportKeysActivity.class); Intent intent = new Intent(getActivity(), ImportKeysActivity.class);
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE); intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
startActivityForResult(intent, 0); startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
} }
}); });

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent"> android:layout_height="match_parent">

View File

@ -1,22 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="4dp" android:paddingTop="16dp"
android:text="Enter Full Name, Email and Passphrase!" android:paddingBottom="8dp"
android:text="@string/create_key_text"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<AutoCompleteTextView <AutoCompleteTextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:inputType="textPersonName" android:inputType="textPersonName"
android:hint="Name" android:hint="@string/label_name"
android:ems="10" android:ems="10"
android:id="@+id/name" /> android:id="@+id/name" />
@ -24,31 +31,52 @@
android:id="@+id/email" android:id="@+id/email"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="bla@example.com" android:layout_marginBottom="8dp"
android:layout_weight="1" android:hint="@string/label_email"
android:ems="10" android:ems="10"
android:inputType="textEmailAddress" /> android:inputType="textEmailAddress" />
<EditText <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:inputType="textPassword" android:inputType="textPassword"
android:hint="passphrase" android:hint="@string/label_passphrase"
android:ems="10" android:ems="10"
android:id="@+id/passphrase" android:id="@+id/passphrase"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_horizontal" />
<CheckBox
<Button
android:id="@+id/create_key_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_marginBottom="8dp"
android:layout_gravity="center_horizontal" android:text="@string/create_key_upload"
android:layout_margin="8dp" android:id="@+id/create_key_upload" />
android:text="@string/first_time_create_key"
android:background="@drawable/button_edgy"
android:drawableLeft="@drawable/ic_action_new_account" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/create_key_button"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/first_time_create_key"
android:minHeight="?android:attr/listPreferredItemHeight"
android:drawableRight="@drawable/ic_action_new_account"
android:drawablePadding="8dp"
android:gravity="center_vertical"
android:clickable="true"
style="@style/SelectableItem" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
</LinearLayout> </LinearLayout>
</ScrollView>

View File

@ -5,44 +5,6 @@
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingBottom="8dp"> 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 <Button
android:id="@+id/first_time_cancel" android:id="@+id/first_time_cancel"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
@ -55,6 +17,7 @@
android:background="@drawable/button_edgy" /> android:background="@drawable/button_edgy" />
<LinearLayout <LinearLayout
android:id="@+id/first_time_buttons"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_above="@id/first_time_cancel" android:layout_above="@id/first_time_cancel"
@ -67,7 +30,7 @@
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginRight="8dp" android:layout_marginRight="4dp"
android:text="@string/first_time_create_key" android:text="@string/first_time_create_key"
android:background="@drawable/button_edgy" android:background="@drawable/button_edgy"
android:drawableLeft="@drawable/ic_action_new_account" /> android:drawableLeft="@drawable/ic_action_new_account" />
@ -78,12 +41,53 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp" android:layout_marginLeft="4dp"
android:layout_marginRight="8dp" android:layout_marginRight="8dp"
android:text="@string/first_time_import_key" android:text="@string/first_time_import_key"
android:background="@drawable/button_edgy" android:background="@drawable/button_edgy"
android:drawableLeft="@drawable/ic_action_download" /> android:drawableLeft="@drawable/ic_action_download" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_above="@+id/first_time_buttons">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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_height="0dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:adjustViewBounds="true"
android:src="@drawable/first_time_1"
android:layout_gravity="center_horizontal"
android:layout_weight="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"
android:layout_marginBottom="16dp" />
</LinearLayout>
</RelativeLayout> </RelativeLayout>

View File

@ -487,6 +487,11 @@
<item>Revoke Subkey</item> <item>Revoke Subkey</item>
</string-array> </string-array>
<!-- Create key -->
<string name="create_key_text">Enter Full Name, Email and Passphrase!</string>
<string name="create_key_upload">Upload key to keyserver</string>
<string name="create_key_empty">This field is required</string>
<!-- Navigation Drawer --> <!-- Navigation Drawer -->
<string name="nav_keys">Keys</string> <string name="nav_keys">Keys</string>
<string name="nav_encrypt">Sign and Encrypt</string> <string name="nav_encrypt">Sign and Encrypt</string>

2
extern/spongycastle vendored

@ -1 +1 @@
Subproject commit 41ef8b1f539dd3d8748865d68a34ed307f699eec Subproject commit a68ebd1ffc5af880903b2905c17e4f6ac0f13988