Better leyout for account settings

This commit is contained in:
Dominik Schürmann 2014-08-31 20:26:06 +02:00
parent f6d1b45007
commit 5e7eed239f
6 changed files with 113 additions and 95 deletions

View File

@ -29,6 +29,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import org.sufficientlysecure.keychain.Constants;
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.SelectSecretKeyLayoutFragment;
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.Log;
public class AccountSettingsFragment extends Fragment implements
SelectSecretKeyLayoutFragment.SelectSecretKeyCallback {
public class AccountSettingsFragment extends Fragment {
private static final int REQUEST_CODE_CREATE_KEY = 0x00008884;
@ -58,8 +60,8 @@ public class AccountSettingsFragment extends Fragment implements
private Spinner mHashAlgorithm;
private Spinner mCompression;
private SelectSecretKeyLayoutFragment mSelectKeyFragment;
private Button mCreateKeyButton;
private SignKeySpinner mSelectKeySpinner;
private View mCreateKeyButton;
KeyValueSpinnerAdapter mEncryptionAdapter;
KeyValueSpinnerAdapter mHashAdapter;
@ -73,7 +75,7 @@ public class AccountSettingsFragment extends Fragment implements
this.mAccSettings = accountSettings;
mAccNameView.setText(accountSettings.getAccountName());
mSelectKeyFragment.selectKey(accountSettings.getKeyId());
mSelectKeySpinner.setSelectedKeyId(accountSettings.getKeyId());
mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings
.getEncryptionAlgorithm()));
mHashAlgorithm.setSelection(mHashAdapter.getPosition(accountSettings.getHashAlgorithm()));
@ -90,26 +92,21 @@ public class AccountSettingsFragment extends Fragment implements
return view;
}
/**
* Set error String on key selection
*
* @param error
*/
public void setErrorOnSelectKeyFragment(String error) {
mSelectKeyFragment.setError(error);
}
private void initView(View view) {
mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getFragmentManager().findFragmentById(
R.id.api_account_settings_select_key_fragment);
mSelectKeyFragment.setCallback(this);
mSelectKeySpinner = (SignKeySpinner) view.findViewById(R.id.api_account_settings_key_spinner);
mAccNameView = (TextView) view.findViewById(R.id.api_account_settings_acc_name);
mEncryptionAlgorithm = (Spinner) view
.findViewById(R.id.api_account_settings_encryption_algorithm);
mHashAlgorithm = (Spinner) view.findViewById(R.id.api_account_settings_hash_algorithm);
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() {
@Override
@ -181,7 +178,7 @@ public class AccountSettingsFragment extends Fragment implements
if (resultCode == Activity.RESULT_OK) {
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
OperationResults.SaveKeyringResult result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
mSelectKeyFragment.selectKey(result.mRingMasterKeyId);
mSelectKeySpinner.setSelectedKeyId(result.mRingMasterKeyId);
} else {
Log.e(Constants.TAG, "missing result!");
}
@ -193,13 +190,4 @@ public class AccountSettingsFragment extends Fragment implements
// execute activity's onActivityResult to show log notify
super.onActivityResult(requestCode, resultCode, data);
}
/**
* callback from select secret key fragment
*/
@Override
public void onKeySelected(long secretKeyId) {
mAccSettings.setKeyId(secretKeyId);
}
}

View File

@ -34,6 +34,7 @@ import android.text.style.BulletSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import org.openintents.openpgp.util.OpenPgpApi;
import org.sufficientlysecure.htmltextview.HtmlTextView;
@ -184,8 +185,8 @@ public class RemoteServiceActivity extends ActionBarActivity {
// user needs to select a key!
if (mAccSettingsFragment.getAccSettings().getKeyId() == Constants.key.none) {
mAccSettingsFragment.setErrorOnSelectKeyFragment(
getString(R.string.api_register_error_select_key));
// TODO
Toast.makeText(RemoteServiceActivity.this, getString(R.string.api_register_error_select_key), Toast.LENGTH_LONG).show();
} else {
if (mUpdateExistingAccount) {
Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(packageName);

View File

@ -35,29 +35,55 @@
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<fragment
android:id="@+id/api_account_settings_select_key_fragment"
android:name="org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment"
<TextView
style="@style/SectionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/select_secret_key_layout_fragment" />
android:text="@string/api_settings_settings" />
<Button
android:id="@+id/api_account_settings_create_key"
android:layout_width="wrap_content"
<TextView
android:layout_width="match_parent"
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_gravity="center_vertical"
android:layout_marginBottom="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:text="@string/api_settings_create_key"
android:background="@drawable/button_edgy"
android:drawableLeft="@drawable/ic_action_accounts"
android:textSize="14sp"/>
android:minHeight="48dp"
android:drawableRight="@drawable/ic_action_new_account"
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
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
custom:foldedLabel="@string/api_settings_show_advanced"
custom:unFoldedLabel="@string/api_settings_hide_advanced">

View File

@ -25,10 +25,10 @@
tools:layout="@layout/api_app_settings_fragment" />
<TextView
style="@style/SectionHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/api_settings_accounts"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:text="@string/api_settings_accounts" />
<FrameLayout
android:id="@+id/api_accounts_list_fragment"

View File

@ -5,67 +5,68 @@
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical">
<ListView
android:id="@+id/selected_files_list"
android:dividerHeight="4dip"
android:divider="@android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="8dp"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"/>
android:id="@+id/selected_files_list"
android:dividerHeight="4dip"
android:divider="@android:color/transparent"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_marginTop="8dp"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider"/>
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="?android:attr/listDivider" />
<!-- Note: The following construct should be a widget, we use it quiet often -->
<LinearLayout
android:id="@+id/action_encrypt_share"
android:paddingLeft="8dp"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_marginBottom="8dp"
android:clickable="true"
style="@style/SelectableItem"
android:orientation="horizontal">
android:id="@+id/action_encrypt_share"
android:paddingLeft="8dp"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_marginBottom="8dp"
android:clickable="true"
style="@style/SelectableItem"
android:orientation="horizontal">
<TextView
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="@string/btn_encrypt_share_file"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_share"
android:drawablePadding="8dp"
android:gravity="center_vertical"/>
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="0dip"
android:layout_height="match_parent"
android:text="@string/btn_encrypt_share_file"
android:layout_weight="1"
android:drawableRight="@drawable/ic_action_share"
android:drawablePadding="8dp"
android:gravity="center_vertical" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider"/>
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/action_encrypt_file"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_save"
android:layout_gravity="center_vertical"
style="@style/SelectableItem"/>
android:id="@+id/action_encrypt_file"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_save"
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
</LinearLayout>
</LinearLayout>

View File

@ -407,6 +407,8 @@
<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_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_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>