mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Work on first time wizard design
This commit is contained in:
parent
45722d7cfb
commit
dab540e121
@ -89,7 +89,11 @@
|
||||
android:name=".ui.CreateKeyActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
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
|
||||
android:name=".ui.EditKeyActivityOld"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
|
@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
@ -31,7 +32,11 @@ import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.devspark.appmsg.AppMsg;
|
||||
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@ -48,7 +53,8 @@ public class CreateKeyActivity extends ActionBarActivity {
|
||||
AutoCompleteTextView mNameEdit;
|
||||
AutoCompleteTextView mEmailEdit;
|
||||
EditText mPassphraseEdit;
|
||||
Button mCreateButton;
|
||||
View mCreateButton;
|
||||
CheckBox mUploadCheckbox;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -59,7 +65,8 @@ public class CreateKeyActivity extends ActionBarActivity {
|
||||
mNameEdit = (AutoCompleteTextView) findViewById(R.id.name);
|
||||
mEmailEdit = (AutoCompleteTextView) findViewById(R.id.email);
|
||||
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.setAdapter(
|
||||
@ -134,10 +141,15 @@ public class CreateKeyActivity extends ActionBarActivity {
|
||||
// handle messages by standard KeychainIntentServiceHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
// TODO
|
||||
// if (mUploadCheckbox.isChecked()) {
|
||||
// uploadKey();
|
||||
// } else {
|
||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||
CreateKeyActivity.this.setResult(RESULT_OK);
|
||||
CreateKeyActivity.this.finish();
|
||||
}
|
||||
// }
|
||||
}
|
||||
};
|
||||
|
||||
@ -166,6 +178,54 @@ public class CreateKeyActivity extends ActionBarActivity {
|
||||
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
|
||||
* set and the EditText gets the focus.
|
||||
@ -177,7 +237,7 @@ public class CreateKeyActivity extends ActionBarActivity {
|
||||
private static boolean isEditTextNotEmpty(Context context, EditText editText) {
|
||||
boolean output = true;
|
||||
if (editText.getText().toString().length() == 0) {
|
||||
editText.setError("empty!");
|
||||
editText.setError(context.getString(R.string.create_key_empty));
|
||||
editText.requestFocus();
|
||||
output = false;
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ public class EncryptFileFragment extends Fragment {
|
||||
public static final String ARG_FILENAME = "filename";
|
||||
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;
|
||||
|
||||
@ -109,10 +109,10 @@ public class EncryptFileFragment extends Fragment {
|
||||
mBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (Constants.KITKAT) {
|
||||
FileHelper.openDocument(EncryptFileFragment.this, mInputUri, "*/*", RESULT_CODE_FILE);
|
||||
FileHelper.openDocument(EncryptFileFragment.this, mInputUri, "*/*", REQUEST_CODE_FILE);
|
||||
} else {
|
||||
FileHelper.openFile(EncryptFileFragment.this, mFilename.getText().toString(), "*/*",
|
||||
RESULT_CODE_FILE);
|
||||
REQUEST_CODE_FILE);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -390,7 +390,7 @@ public class EncryptFileFragment extends Fragment {
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
case RESULT_CODE_FILE: {
|
||||
case REQUEST_CODE_FILE: {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
if (Constants.KITKAT) {
|
||||
mInputUri = data.getData();
|
||||
|
@ -24,8 +24,10 @@ import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class FirstTimeActivity extends ActionBarActivity {
|
||||
|
||||
@ -33,6 +35,8 @@ public class FirstTimeActivity extends ActionBarActivity {
|
||||
Button mImportKey;
|
||||
Button mSkipSetup;
|
||||
|
||||
public static final int REQUEST_CODE_CREATE_OR_IMPORT_KEY = 0x00007012;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -57,7 +61,7 @@ public class FirstTimeActivity extends ActionBarActivity {
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(FirstTimeActivity.this, ImportKeysActivity.class);
|
||||
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
|
||||
public void onClick(View v) {
|
||||
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) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == REQUEST_CODE_CREATE_OR_IMPORT_KEY) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
finishSetup();
|
||||
}
|
||||
} else {
|
||||
Log.e(Constants.TAG, "No valid request code!");
|
||||
}
|
||||
}
|
||||
|
||||
private void finishSetup() {
|
||||
|
@ -109,6 +109,8 @@ public class KeyListActivity extends DrawerActivity {
|
||||
return true;
|
||||
|
||||
case R.id.menu_key_list_debug_first_time:
|
||||
Preferences prefs = Preferences.getPreferences(this);
|
||||
prefs.setFirstTime(true);
|
||||
Intent intent = new Intent(this, FirstTimeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
@ -86,6 +86,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
private Button mButtonEmptyCreate;
|
||||
private Button mButtonEmptyImport;
|
||||
|
||||
public static final int REQUEST_CODE_CREATE_OR_IMPORT_KEY = 0x00007012;
|
||||
|
||||
/**
|
||||
* Load custom layout with StickyListView from library
|
||||
@ -104,11 +105,8 @@ public class KeyListFragment extends LoaderFragment
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), EditKeyActivityOld.class);
|
||||
intent.setAction(EditKeyActivityOld.ACTION_CREATE_KEY);
|
||||
intent.putExtra(EditKeyActivityOld.EXTRA_GENERATE_DEFAULT_KEYS, true);
|
||||
intent.putExtra(EditKeyActivityOld.EXTRA_USER_IDS, ""); // show user id view
|
||||
startActivityForResult(intent, 0);
|
||||
Intent intent = new Intent(getActivity(), CreateKeyActivity.class);
|
||||
startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
|
||||
}
|
||||
});
|
||||
mButtonEmptyImport = (Button) view.findViewById(R.id.key_list_empty_button_import);
|
||||
@ -117,8 +115,8 @@ public class KeyListFragment extends LoaderFragment
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), ImportKeysActivity.class);
|
||||
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE);
|
||||
startActivityForResult(intent, 0);
|
||||
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
|
||||
startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -1,22 +1,29 @@
|
||||
<?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_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="4dp"
|
||||
android:text="Enter Full Name, Email and Passphrase!"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="@string/create_key_text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:inputType="textPersonName"
|
||||
android:hint="Name"
|
||||
android:hint="@string/label_name"
|
||||
android:ems="10"
|
||||
android:id="@+id/name" />
|
||||
|
||||
@ -24,31 +31,52 @@
|
||||
android:id="@+id/email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="bla@example.com"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:hint="@string/label_email"
|
||||
android:ems="10"
|
||||
android:inputType="textEmailAddress" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:inputType="textPassword"
|
||||
android:hint="passphrase"
|
||||
android:hint="@string/label_passphrase"
|
||||
android:ems="10"
|
||||
android:id="@+id/passphrase"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/create_key_button"
|
||||
<CheckBox
|
||||
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" />
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/create_key_upload"
|
||||
android:id="@+id/create_key_upload" />
|
||||
|
||||
<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>
|
||||
</ScrollView>
|
@ -5,44 +5,6 @@
|
||||
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"
|
||||
@ -55,6 +17,7 @@
|
||||
android:background="@drawable/button_edgy" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/first_time_buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/first_time_cancel"
|
||||
@ -67,7 +30,7 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:text="@string/first_time_create_key"
|
||||
android:background="@drawable/button_edgy"
|
||||
android:drawableLeft="@drawable/ic_action_new_account" />
|
||||
@ -78,12 +41,53 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/first_time_import_key"
|
||||
android:background="@drawable/button_edgy"
|
||||
android:drawableLeft="@drawable/ic_action_download" />
|
||||
</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>
|
||||
|
@ -487,6 +487,11 @@
|
||||
<item>Revoke Subkey</item>
|
||||
</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 -->
|
||||
<string name="nav_keys">Keys</string>
|
||||
<string name="nav_encrypt">Sign and Encrypt</string>
|
||||
|
2
extern/spongycastle
vendored
2
extern/spongycastle
vendored
@ -1 +1 @@
|
||||
Subproject commit 41ef8b1f539dd3d8748865d68a34ed307f699eec
|
||||
Subproject commit a68ebd1ffc5af880903b2905c17e4f6ac0f13988
|
Loading…
Reference in New Issue
Block a user