mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
Better leyout for account settings
This commit is contained in:
parent
f6d1b45007
commit
5e7eed239f
@ -29,6 +29,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -41,11 +42,12 @@ import org.sufficientlysecure.keychain.service.OperationResults;
|
|||||||
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment;
|
import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter;
|
||||||
|
import org.sufficientlysecure.keychain.ui.widget.KeySpinner;
|
||||||
|
import org.sufficientlysecure.keychain.ui.widget.SignKeySpinner;
|
||||||
import org.sufficientlysecure.keychain.util.AlgorithmNames;
|
import org.sufficientlysecure.keychain.util.AlgorithmNames;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class AccountSettingsFragment extends Fragment implements
|
public class AccountSettingsFragment extends Fragment {
|
||||||
SelectSecretKeyLayoutFragment.SelectSecretKeyCallback {
|
|
||||||
|
|
||||||
private static final int REQUEST_CODE_CREATE_KEY = 0x00008884;
|
private static final int REQUEST_CODE_CREATE_KEY = 0x00008884;
|
||||||
|
|
||||||
@ -58,8 +60,8 @@ public class AccountSettingsFragment extends Fragment implements
|
|||||||
private Spinner mHashAlgorithm;
|
private Spinner mHashAlgorithm;
|
||||||
private Spinner mCompression;
|
private Spinner mCompression;
|
||||||
|
|
||||||
private SelectSecretKeyLayoutFragment mSelectKeyFragment;
|
private SignKeySpinner mSelectKeySpinner;
|
||||||
private Button mCreateKeyButton;
|
private View mCreateKeyButton;
|
||||||
|
|
||||||
KeyValueSpinnerAdapter mEncryptionAdapter;
|
KeyValueSpinnerAdapter mEncryptionAdapter;
|
||||||
KeyValueSpinnerAdapter mHashAdapter;
|
KeyValueSpinnerAdapter mHashAdapter;
|
||||||
@ -73,7 +75,7 @@ public class AccountSettingsFragment extends Fragment implements
|
|||||||
this.mAccSettings = accountSettings;
|
this.mAccSettings = accountSettings;
|
||||||
|
|
||||||
mAccNameView.setText(accountSettings.getAccountName());
|
mAccNameView.setText(accountSettings.getAccountName());
|
||||||
mSelectKeyFragment.selectKey(accountSettings.getKeyId());
|
mSelectKeySpinner.setSelectedKeyId(accountSettings.getKeyId());
|
||||||
mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings
|
mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings
|
||||||
.getEncryptionAlgorithm()));
|
.getEncryptionAlgorithm()));
|
||||||
mHashAlgorithm.setSelection(mHashAdapter.getPosition(accountSettings.getHashAlgorithm()));
|
mHashAlgorithm.setSelection(mHashAdapter.getPosition(accountSettings.getHashAlgorithm()));
|
||||||
@ -90,26 +92,21 @@ public class AccountSettingsFragment extends Fragment implements
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set error String on key selection
|
|
||||||
*
|
|
||||||
* @param error
|
|
||||||
*/
|
|
||||||
public void setErrorOnSelectKeyFragment(String error) {
|
|
||||||
mSelectKeyFragment.setError(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initView(View view) {
|
private void initView(View view) {
|
||||||
mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getFragmentManager().findFragmentById(
|
mSelectKeySpinner = (SignKeySpinner) view.findViewById(R.id.api_account_settings_key_spinner);
|
||||||
R.id.api_account_settings_select_key_fragment);
|
|
||||||
mSelectKeyFragment.setCallback(this);
|
|
||||||
|
|
||||||
mAccNameView = (TextView) view.findViewById(R.id.api_account_settings_acc_name);
|
mAccNameView = (TextView) view.findViewById(R.id.api_account_settings_acc_name);
|
||||||
mEncryptionAlgorithm = (Spinner) view
|
mEncryptionAlgorithm = (Spinner) view
|
||||||
.findViewById(R.id.api_account_settings_encryption_algorithm);
|
.findViewById(R.id.api_account_settings_encryption_algorithm);
|
||||||
mHashAlgorithm = (Spinner) view.findViewById(R.id.api_account_settings_hash_algorithm);
|
mHashAlgorithm = (Spinner) view.findViewById(R.id.api_account_settings_hash_algorithm);
|
||||||
mCompression = (Spinner) view.findViewById(R.id.api_account_settings_compression);
|
mCompression = (Spinner) view.findViewById(R.id.api_account_settings_compression);
|
||||||
mCreateKeyButton = (Button) view.findViewById(R.id.api_account_settings_create_key);
|
mCreateKeyButton = view.findViewById(R.id.api_account_settings_create_key);
|
||||||
|
|
||||||
|
mSelectKeySpinner.setOnKeyChangedListener(new KeySpinner.OnKeyChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onKeyChanged(long masterKeyId) {
|
||||||
|
mAccSettings.setKeyId(masterKeyId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mCreateKeyButton.setOnClickListener(new View.OnClickListener() {
|
mCreateKeyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -181,7 +178,7 @@ public class AccountSettingsFragment extends Fragment implements
|
|||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
||||||
OperationResults.SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
OperationResults.SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
||||||
mSelectKeyFragment.selectKey(result.mRingMasterKeyId);
|
mSelectKeySpinner.setSelectedKeyId(result.mRingMasterKeyId);
|
||||||
} else {
|
} else {
|
||||||
Log.e(Constants.TAG, "missing result!");
|
Log.e(Constants.TAG, "missing result!");
|
||||||
}
|
}
|
||||||
@ -193,13 +190,4 @@ public class AccountSettingsFragment extends Fragment implements
|
|||||||
// execute activity's onActivityResult to show log notify
|
// execute activity's onActivityResult to show log notify
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* callback from select secret key fragment
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onKeySelected(long secretKeyId) {
|
|
||||||
mAccSettings.setKeyId(secretKeyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import android.text.style.BulletSpan;
|
|||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.sufficientlysecure.htmltextview.HtmlTextView;
|
import org.sufficientlysecure.htmltextview.HtmlTextView;
|
||||||
@ -184,8 +185,8 @@ public class RemoteServiceActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
// user needs to select a key!
|
// user needs to select a key!
|
||||||
if (mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
|
if (mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
|
||||||
mAccSettingsFragment.setErrorOnSelectKeyFragment(
|
// TODO
|
||||||
getString(R.string.api_register_error_select_key));
|
Toast.makeText(RemoteServiceActivity.this, getString(R.string.api_register_error_select_key), Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
if (mUpdateExistingAccount) {
|
if (mUpdateExistingAccount) {
|
||||||
Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(packageName);
|
Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(packageName);
|
||||||
|
@ -35,29 +35,55 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<fragment
|
<TextView
|
||||||
android:id="@+id/api_account_settings_select_key_fragment"
|
style="@style/SectionHeader"
|
||||||
android:name="org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:layout="@layout/select_secret_key_layout_fragment" />
|
android:text="@string/api_settings_settings" />
|
||||||
|
|
||||||
<Button
|
<TextView
|
||||||
android:id="@+id/api_account_settings_create_key"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/api_settings_key"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.SignKeySpinner
|
||||||
|
android:id="@+id/api_account_settings_key_spinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/api_account_settings_create_key"
|
||||||
|
style="@style/SelectableItem"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginBottom="4dp"
|
|
||||||
android:layout_marginRight="4dp"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:text="@string/api_settings_create_key"
|
android:text="@string/api_settings_create_key"
|
||||||
android:background="@drawable/button_edgy"
|
android:minHeight="48dp"
|
||||||
android:drawableLeft="@drawable/ic_action_accounts"
|
android:drawableRight="@drawable/ic_action_new_account"
|
||||||
android:textSize="14sp"/>
|
android:drawablePadding="8dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout
|
<org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
custom:foldedLabel="@string/api_settings_show_advanced"
|
custom:foldedLabel="@string/api_settings_show_advanced"
|
||||||
custom:unFoldedLabel="@string/api_settings_hide_advanced">
|
custom:unFoldedLabel="@string/api_settings_hide_advanced">
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
tools:layout="@layout/api_app_settings_fragment" />
|
tools:layout="@layout/api_app_settings_fragment" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
style="@style/SectionHeader"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/api_settings_accounts"
|
android:text="@string/api_settings_accounts" />
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/api_accounts_list_fragment"
|
android:id="@+id/api_accounts_list_fragment"
|
||||||
|
@ -5,67 +5,68 @@
|
|||||||
android:fillViewport="true">
|
android:fillViewport="true">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/selected_files_list"
|
android:id="@+id/selected_files_list"
|
||||||
android:dividerHeight="4dip"
|
android:dividerHeight="4dip"
|
||||||
android:divider="@android:color/transparent"
|
android:divider="@android:color/transparent"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dip"
|
android:layout_height="0dip"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dip"
|
android:layout_height="1dip"
|
||||||
android:background="?android:attr/listDivider"/>
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
<!-- Note: The following construct should be a widget, we use it quiet often -->
|
<!-- Note: The following construct should be a widget, we use it quiet often -->
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/action_encrypt_share"
|
android:id="@+id/action_encrypt_share"
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
style="@style/SelectableItem"
|
style="@style/SelectableItem"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
android:paddingRight="8dp"
|
android:paddingRight="8dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:text="@string/btn_encrypt_share_file"
|
android:text="@string/btn_encrypt_share_file"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:drawableRight="@drawable/ic_action_share"
|
android:drawableRight="@drawable/ic_action_share"
|
||||||
android:drawablePadding="8dp"
|
android:drawablePadding="8dp"
|
||||||
android:gravity="center_vertical"/>
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="1dip"
|
android:layout_width="1dip"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:background="?android:attr/listDivider"/>
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/action_encrypt_file"
|
android:id="@+id/action_encrypt_file"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_action_save"
|
android:src="@drawable/ic_action_save"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
style="@style/SelectableItem"/>
|
style="@style/SelectableItem" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -407,6 +407,8 @@
|
|||||||
<string name="api_settings_package_name">Package Name</string>
|
<string name="api_settings_package_name">Package Name</string>
|
||||||
<string name="api_settings_package_signature">SHA-256 of Package Signature</string>
|
<string name="api_settings_package_signature">SHA-256 of Package Signature</string>
|
||||||
<string name="api_settings_accounts">Accounts</string>
|
<string name="api_settings_accounts">Accounts</string>
|
||||||
|
<string name="api_settings_settings">Settings</string>
|
||||||
|
<string name="api_settings_key">My key for this account</string>
|
||||||
<string name="api_settings_accounts_empty">No accounts attached to this app.</string>
|
<string name="api_settings_accounts_empty">No accounts attached to this app.</string>
|
||||||
<string name="api_create_account_text">The app requests the creation of a new account. Please select one of your existing keys or create a new one.\nApps are restricted to the usage of keys you select here!</string>
|
<string name="api_create_account_text">The app requests the creation of a new account. Please select one of your existing keys or create a new one.\nApps are restricted to the usage of keys you select here!</string>
|
||||||
<string name="api_update_account_text">The key saved for this account has been deleted. Please select a different one!\nApps are restricted to the usage of keys you select here!</string>
|
<string name="api_update_account_text">The key saved for this account has been deleted. Please select a different one!\nApps are restricted to the usage of keys you select here!</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user