Material Design: Full screen dialogs

This commit is contained in:
Dominik Schürmann 2015-01-26 00:50:35 +01:00
parent b4781343d9
commit e4e2d647c8
57 changed files with 209 additions and 273 deletions

View File

@ -1,3 +1,9 @@
# https://google.github.io/material-design-icons/
cd ./android-icon-copier/ cd ./android-icon-copier/
python copy OpenKeychain action white search 24 python copy OpenKeychain action white search 24
python copy OpenKeychain navigation white arrow_back 24 python copy OpenKeychain navigation white arrow_back 24
python copy OpenKeychain navigation white close 24
python copy OpenKeychain navigation white check 24
python copy OpenKeychain navigation black expand_less 24
python copy OpenKeychain navigation black expand_more 24
python copy OpenKeychain navigation white refresh 24

View File

@ -27,7 +27,6 @@ import android.view.View;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.BaseActivity; import org.sufficientlysecure.keychain.ui.BaseActivity;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.remote.AccountSettings; import org.sufficientlysecure.keychain.remote.AccountSettings;
import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.OperationResult;
@ -45,14 +44,18 @@ public class AccountSettingsActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Inflate a "Done" custom action bar // Inflate a "Done" custom action bar
ActionBarHelper.setOneButtonView(getSupportActionBar(), setFullScreenDialogDoneClose(R.string.api_settings_save,
R.string.api_settings_save, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// "Done"
save(); save();
} }
},
new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
}); });
@ -129,9 +132,4 @@ public class AccountSettingsActivity extends BaseActivity {
} }
} }
@Override
public void onBackPressed() {
save();
super.onBackPressed();
}
} }

View File

@ -40,7 +40,6 @@ import org.sufficientlysecure.keychain.remote.AccountSettings;
import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.remote.AppSettings;
import org.sufficientlysecure.keychain.ui.BaseActivity; import org.sufficientlysecure.keychain.ui.BaseActivity;
import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment; import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
@ -123,8 +122,8 @@ public class RemoteServiceActivity extends BaseActivity {
mAppSettingsFragment.setAppSettings(settings); mAppSettingsFragment.setAppSettings(settings);
// Inflate a "Done"/"Cancel" custom action bar view // Inflate a "Done"/"Cancel" custom action bar view
ActionBarHelper.setTwoButtonView(getSupportActionBar(), setFullScreenDialogTwoButtons(
R.string.api_register_allow, R.drawable.ic_action_done, R.string.api_register_allow, R.drawable.ic_check_white_24dp,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -137,7 +136,7 @@ public class RemoteServiceActivity extends BaseActivity {
RemoteServiceActivity.this.setResult(RESULT_OK, resultData); RemoteServiceActivity.this.setResult(RESULT_OK, resultData);
RemoteServiceActivity.this.finish(); RemoteServiceActivity.this.finish();
} }
}, R.string.api_register_disallow, R.drawable.ic_action_cancel, }, R.string.api_register_disallow, R.drawable.ic_close_white_24dp,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -179,8 +178,7 @@ public class RemoteServiceActivity extends BaseActivity {
mAccSettingsFragment.setAccSettings(settings); mAccSettingsFragment.setAccSettings(settings);
// Inflate a "Done"/"Cancel" custom action bar view // Inflate a "Done"/"Cancel" custom action bar view
ActionBarHelper.setTwoButtonView(getSupportActionBar(), setFullScreenDialogDoneClose(R.string.api_settings_save,
R.string.api_settings_save, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -208,7 +206,7 @@ public class RemoteServiceActivity extends BaseActivity {
RemoteServiceActivity.this.finish(); RemoteServiceActivity.this.finish();
} }
} }
}, R.string.api_settings_cancel, R.drawable.ic_action_cancel, },
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -216,8 +214,7 @@ public class RemoteServiceActivity extends BaseActivity {
RemoteServiceActivity.this.setResult(RESULT_CANCELED); RemoteServiceActivity.this.setResult(RESULT_CANCELED);
RemoteServiceActivity.this.finish(); RemoteServiceActivity.this.finish();
} }
} });
);
break; break;
} }
@ -264,8 +261,7 @@ public class RemoteServiceActivity extends BaseActivity {
initToolbar(); initToolbar();
// Inflate a "Done"/"Cancel" custom action bar view // Inflate a "Done"/"Cancel" custom action bar view
ActionBarHelper.setTwoButtonView(getSupportActionBar(), setFullScreenDialogDoneClose(R.string.btn_okay,
R.string.btn_okay, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -277,16 +273,15 @@ public class RemoteServiceActivity extends BaseActivity {
RemoteServiceActivity.this.setResult(RESULT_OK, resultData); RemoteServiceActivity.this.setResult(RESULT_OK, resultData);
RemoteServiceActivity.this.finish(); RemoteServiceActivity.this.finish();
} }
}, R.string.btn_do_not_save, R.drawable.ic_action_cancel, new View.OnClickListener() { },
new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// cancel // cancel
RemoteServiceActivity.this.setResult(RESULT_CANCELED); RemoteServiceActivity.this.setResult(RESULT_CANCELED);
RemoteServiceActivity.this.finish(); RemoteServiceActivity.this.finish();
} }
} });
);
// set text on view // set text on view
TextView textView = (TextView) findViewById(R.id.api_select_pub_keys_text); TextView textView = (TextView) findViewById(R.id.api_select_pub_keys_text);
@ -323,8 +318,7 @@ public class RemoteServiceActivity extends BaseActivity {
initToolbar(); initToolbar();
// Inflate a "Done" custom action bar view // Inflate a "Done" custom action bar view
ActionBarHelper.setOneButtonView(getSupportActionBar(), setFullScreenDialogClose(
R.string.btn_okay, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override

View File

@ -17,14 +17,21 @@
package org.sufficientlysecure.keychain.ui; package org.sufficientlysecure.keychain.ui;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
/** /**
* Sets action bar * Setups Toolbar
*/ */
public abstract class BaseActivity extends ActionBarActivity { public abstract class BaseActivity extends ActionBarActivity {
protected Toolbar mToolbar; protected Toolbar mToolbar;
@ -49,4 +56,75 @@ public abstract class BaseActivity extends ActionBarActivity {
protected void setActionBarIcon(int iconRes) { protected void setActionBarIcon(int iconRes) {
mToolbar.setNavigationIcon(iconRes); mToolbar.setNavigationIcon(iconRes);
} }
/**
* Inflate custom design to look like a full screen dialog, as specified in Material Design Guidelines
* see http://www.google.com/design/spec/components/dialogs.html#dialogs-full-screen-dialogs
*/
protected void setFullScreenDialogDoneClose(int doneText, View.OnClickListener doneOnClickListener,
View.OnClickListener cancelOnClickListener) {
setActionBarIcon(R.drawable.ic_close_white_24dp);
// Inflate the custom action bar view
final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(R.layout.full_screen_dialog, null);
TextView firstTextView = ((TextView) customActionBarView.findViewById(R.id.full_screen_dialog_done_text));
firstTextView.setText(doneText);
customActionBarView.findViewById(R.id.full_screen_dialog_done).setOnClickListener(
doneOnClickListener);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setCustomView(customActionBarView, new ActionBar.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT,
Gravity.END));
mToolbar.setNavigationOnClickListener(cancelOnClickListener);
}
/**
* Close button only
*/
protected void setFullScreenDialogClose(View.OnClickListener cancelOnClickListener) {
setActionBarIcon(R.drawable.ic_close_white_24dp);
getSupportActionBar().setDisplayShowTitleEnabled(true);
mToolbar.setNavigationOnClickListener(cancelOnClickListener);
}
/**
* Inflate custom design with two buttons using drawables.
* This does not conform to the Material Design Guidelines, but we deviate here as this is used
* to indicate "Allow access"/"Disallow access" to the API, which must be clearly indicated
*/
protected void setFullScreenDialogTwoButtons(int firstText, int firstDrawableId, View.OnClickListener firstOnClickListener,
int secondText, int secondDrawableId, View.OnClickListener secondOnClickListener) {
// Inflate the custom action bar view
final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.full_screen_dialog_2, null);
TextView firstTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text));
firstTextView.setText(firstText);
firstTextView.setCompoundDrawablesWithIntrinsicBounds(firstDrawableId, 0, 0, 0);
customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
firstOnClickListener);
TextView secondTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text));
secondTextView.setText(secondText);
secondTextView.setCompoundDrawablesWithIntrinsicBounds(secondDrawableId, 0, 0, 0);
customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
secondOnClickListener);
// Show the custom action bar view and hide the normal Home icon and title.
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(customActionBarView, new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
} }

View File

@ -29,7 +29,6 @@ import android.os.Messenger;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader; import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -66,7 +65,6 @@ import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
@ -148,10 +146,8 @@ public class EditKeyFragment extends LoaderFragment implements
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
((EditKeyActivity) getActivity()).setFullScreenDialogDoneClose(
// Inflate a "Done"/"Cancel" custom action bar view R.string.btn_save,
ActionBarHelper.setTwoButtonView(((ActionBarActivity) getActivity()).getSupportActionBar(),
R.string.btn_save, R.drawable.ic_action_save,
new OnClickListener() { new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -162,16 +158,13 @@ public class EditKeyFragment extends LoaderFragment implements
saveInDatabase(mCurrentPassphrase); saveInDatabase(mCurrentPassphrase);
} }
} }
}, R.string.menu_key_edit_cancel, R.drawable.ic_action_cancel, }, new OnClickListener() {
new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// cancel
getActivity().setResult(Activity.RESULT_CANCELED); getActivity().setResult(Activity.RESULT_CANCELED);
getActivity().finish(); getActivity().finish();
} }
} });
);
Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); Uri dataUri = getArguments().getParcelable(ARG_DATA_URI);
SaveKeyringParcel saveKeyringParcel = getArguments().getParcelable(ARG_SAVE_KEYRING_PARCEL); SaveKeyringParcel saveKeyringParcel = getArguments().getParcelable(ARG_SAVE_KEYRING_PARCEL);
@ -393,8 +386,8 @@ public class EditKeyFragment extends LoaderFragment implements
// cache new returned passphrase! // cache new returned passphrase!
mSaveKeyringParcel.mNewUnlock = new ChangeUnlockParcel( mSaveKeyringParcel.mNewUnlock = new ChangeUnlockParcel(
data.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE), data.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE),
null null
); );
} }
} }

View File

@ -22,7 +22,6 @@ import android.os.Bundle;
import android.view.View; import android.view.View;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
public class LogDisplayActivity extends BaseActivity { public class LogDisplayActivity extends BaseActivity {
@ -31,8 +30,7 @@ public class LogDisplayActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Inflate a "Done" custom action bar // Inflate a "Done" custom action bar
ActionBarHelper.setOneButtonView(getSupportActionBar(), setFullScreenDialogClose(
R.string.btn_okay, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -26,7 +26,6 @@ import android.widget.ImageView;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
@ -44,8 +43,7 @@ public class QrCodeViewActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Inflate a "Done" custom action bar // Inflate a "Done" custom action bar
ActionBarHelper.setOneButtonView(getSupportActionBar(), setFullScreenDialogClose(
R.string.btn_okay, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -24,7 +24,6 @@ import android.view.View;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
public class SelectPublicKeyActivity extends BaseActivity { public class SelectPublicKeyActivity extends BaseActivity {
@ -46,21 +45,19 @@ public class SelectPublicKeyActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Inflate a "Done"/"Cancel" custom action bar view // Inflate a "Done"/"Cancel" custom action bar view
ActionBarHelper.setTwoButtonView(getSupportActionBar(), R.string.btn_okay, R.drawable.ic_action_done, setFullScreenDialogDoneClose(R.string.btn_okay,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// ok
okClicked(); okClicked();
} }
}, R.string.btn_do_not_save, R.drawable.ic_action_cancel, new View.OnClickListener() { },
new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// cancel
cancelClicked(); cancelClicked();
} }
} });
);
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

View File

@ -27,7 +27,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.ui.widget.Editor; import org.sufficientlysecure.keychain.ui.widget.Editor;
import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener;
import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor; import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor;
@ -51,21 +50,19 @@ public class SettingsKeyServerActivity extends BaseActivity implements OnClickLi
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Inflate a "Done"/"Cancel" custom action bar view // Inflate a "Done"/"Cancel" custom action bar view
ActionBarHelper.setTwoButtonView(getSupportActionBar(), R.string.btn_okay, R.drawable.ic_action_done, setFullScreenDialogDoneClose(R.string.btn_save,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// ok
okClicked(); okClicked();
} }
}, R.string.btn_do_not_save, R.drawable.ic_action_cancel, new View.OnClickListener() { },
new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// cancel
cancelClicked(); cancelClicked();
} }
} });
);
mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View File

@ -25,7 +25,6 @@ import android.view.View;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
import org.sufficientlysecure.keychain.util.ExportHelper; import org.sufficientlysecure.keychain.util.ExportHelper;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
@ -42,8 +41,7 @@ public class ViewKeyAdvancedActivity extends BaseActivity {
mProviderHelper = new ProviderHelper(this); mProviderHelper = new ProviderHelper(this);
// Inflate a "Done" custom action bar // Inflate a "Done" custom action bar
ActionBarHelper.setOneButtonView(getSupportActionBar(), setFullScreenDialogClose(
R.string.btn_okay, R.drawable.ic_action_done,
new View.OnClickListener() { new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -164,7 +164,7 @@ public class SubkeysAdapter extends CursorAdapter {
? mSaveKeyringParcel.getSubkeyChange(keyId) ? mSaveKeyringParcel.getSubkeyChange(keyId)
: null; : null;
if (change.mDummyStrip) { if (change != null && change.mDummyStrip) {
algorithmStr.append(", "); algorithmStr.append(", ");
final SpannableString boldStripped = new SpannableString( final SpannableString boldStripped = new SpannableString(
context.getString(R.string.key_stripped) context.getString(R.string.key_stripped)

View File

@ -1,99 +0,0 @@
/*
* Copyright (C) 2013-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.util;
import android.app.Activity;
import android.support.v7.app.ActionBar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import org.sufficientlysecure.keychain.R;
public class ActionBarHelper {
/**
* Sets custom view on ActionBar for Done/Cancel activities
*
* @param actionBar
* @param firstText
* @param firstDrawableId
* @param firstOnClickListener
* @param secondText
* @param secondDrawableId
* @param secondOnClickListener
*/
public static void setTwoButtonView(ActionBar actionBar,
int firstText, int firstDrawableId, OnClickListener firstOnClickListener,
int secondText, int secondDrawableId, OnClickListener secondOnClickListener) {
// Inflate the custom action bar view
final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext()
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater.inflate(
R.layout.actionbar_custom_view_done_cancel, null);
TextView firstTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text));
firstTextView.setText(firstText);
firstTextView.setCompoundDrawablesWithIntrinsicBounds(firstDrawableId, 0, 0, 0);
customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
firstOnClickListener);
TextView secondTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_cancel_text));
secondTextView.setText(secondText);
secondTextView.setCompoundDrawablesWithIntrinsicBounds(secondDrawableId, 0, 0, 0);
customActionBarView.findViewById(R.id.actionbar_cancel).setOnClickListener(
secondOnClickListener);
// Show the custom action bar view and hide the normal Home icon and title.
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
/**
* Sets custom view on ActionBar for Done activities
*
* @param actionBar
* @param firstText
* @param firstOnClickListener
*/
public static void setOneButtonView(ActionBar actionBar, int firstText, int firstDrawableId,
OnClickListener firstOnClickListener) {
// Inflate a "Done" custom action bar view to serve as the "Up" affordance.
final LayoutInflater inflater = (LayoutInflater) actionBar.getThemedContext()
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View customActionBarView = inflater
.inflate(R.layout.actionbar_custom_view_done, null);
TextView firstTextView = ((TextView) customActionBarView.findViewById(R.id.actionbar_done_text));
firstTextView.setText(firstText);
firstTextView.setCompoundDrawablesWithIntrinsicBounds(firstDrawableId, 0, 0, 0);
customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(
firstOnClickListener);
// Show the custom action bar view and hide the normal Home icon and title.
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(customActionBarView);
}
}

View File

@ -33,17 +33,16 @@ import org.sufficientlysecure.keychain.R;
/** /**
* Class representing a LinearLayout that can fold and hide it's content when pressed * Class representing a LinearLayout that can fold and hide it's content when pressed
* To use just add the following to your xml layout * To use just add the following to your xml layout
* <p/>
<org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout * <org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout
android:layout_width="wrap_content" * android:layout_width="wrap_content"
android:layout_height="wrap_content" * android:layout_height="wrap_content"
custom:foldedLabel="@string/TEXT_TO_DISPLAY_WHEN_FOLDED" * custom:foldedLabel="@string/TEXT_TO_DISPLAY_WHEN_FOLDED"
custom:unFoldedLabel="@string/TEXT_TO_DISPLAY_WHEN_UNFOLDED"> * custom:unFoldedLabel="@string/TEXT_TO_DISPLAY_WHEN_UNFOLDED">
* <p/>
<include layout="@layout/ELEMENTS_TO_BE_FOLDED"/> * <include layout="@layout/ELEMENTS_TO_BE_FOLDED"/>
* <p/>
</org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout> * </org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout>
*/ */
public class FoldableLinearLayout extends LinearLayout { public class FoldableLinearLayout extends LinearLayout {
@ -75,6 +74,7 @@ public class FoldableLinearLayout extends LinearLayout {
/** /**
* Load given attributes to inner variables, * Load given attributes to inner variables,
*
* @param context * @param context
* @param attrs * @param attrs
*/ */
@ -87,8 +87,8 @@ public class FoldableLinearLayout extends LinearLayout {
a.recycle(); a.recycle();
} }
// If any attribute isn't found then set a default one // If any attribute isn't found then set a default one
mFoldedLabel = (mFoldedLabel == null) ? context.getString(R.id.none) : mFoldedLabel; mFoldedLabel = (mFoldedLabel == null) ? context.getString(R.string.none) : mFoldedLabel;
mUnFoldedLabel = (mUnFoldedLabel == null) ? context.getString(R.id.none) : mUnFoldedLabel; mUnFoldedLabel = (mUnFoldedLabel == null) ? context.getString(R.string.none) : mUnFoldedLabel;
} }
@Override @Override
@ -138,7 +138,7 @@ public class FoldableLinearLayout extends LinearLayout {
private void initialiseInnerViews() { private void initialiseInnerViews() {
mFoldableIcon = (ImageView) mFoldableLayout.findViewById(R.id.foldableIcon); mFoldableIcon = (ImageView) mFoldableLayout.findViewById(R.id.foldableIcon);
mFoldableIcon.setImageResource(R.drawable.ic_action_expand); mFoldableIcon.setImageResource(R.drawable.ic_expand_more_black_24dp);
mFoldableTextView = (TextView) mFoldableLayout.findViewById(R.id.foldableText); mFoldableTextView = (TextView) mFoldableLayout.findViewById(R.id.foldableText);
mFoldableTextView.setText(mFoldedLabel); mFoldableTextView.setText(mFoldedLabel);
@ -151,7 +151,7 @@ public class FoldableLinearLayout extends LinearLayout {
public void onClick(View view) { public void onClick(View view) {
mFolded = !mFolded; mFolded = !mFolded;
if (mFolded) { if (mFolded) {
mFoldableIcon.setImageResource(R.drawable.ic_action_collapse); mFoldableIcon.setImageResource(R.drawable.ic_expand_less_black_24dp);
mFoldableContainer.setVisibility(View.VISIBLE); mFoldableContainer.setVisibility(View.VISIBLE);
AlphaAnimation animation = new AlphaAnimation(0f, 1f); AlphaAnimation animation = new AlphaAnimation(0f, 1f);
animation.setDuration(mShortAnimationDuration); animation.setDuration(mShortAnimationDuration);
@ -159,12 +159,13 @@ public class FoldableLinearLayout extends LinearLayout {
mFoldableTextView.setText(mUnFoldedLabel); mFoldableTextView.setText(mUnFoldedLabel);
} else { } else {
mFoldableIcon.setImageResource(R.drawable.ic_action_expand); mFoldableIcon.setImageResource(R.drawable.ic_expand_more_black_24dp);
AlphaAnimation animation = new AlphaAnimation(1f, 0f); AlphaAnimation animation = new AlphaAnimation(1f, 0f);
animation.setDuration(mShortAnimationDuration); animation.setDuration(mShortAnimationDuration);
animation.setAnimationListener(new Animation.AnimationListener() { animation.setAnimationListener(new Animation.AnimationListener() {
@Override @Override
public void onAnimationStart(Animation animation) { } public void onAnimationStart(Animation animation) {
}
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
@ -173,7 +174,8 @@ public class FoldableLinearLayout extends LinearLayout {
} }
@Override @Override
public void onAnimationRepeat(Animation animation) { } public void onAnimationRepeat(Animation animation) {
}
}); });
mFoldableContainer.startAnimation(animation); mFoldableContainer.startAnimation(animation);
mFoldableTextView.setText(mFoldedLabel); mFoldableTextView.setText(mFoldedLabel);
@ -185,6 +187,7 @@ public class FoldableLinearLayout extends LinearLayout {
/** /**
* Adds provided child view to foldableContainer View * Adds provided child view to foldableContainer View
*
* @param child * @param child
*/ */
@Override @Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,26 +0,0 @@
<!--
Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="end" >
<include layout="@layout/actionbar_include_done_button" />
</LinearLayout>

View File

@ -1,28 +0,0 @@
<!--
Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
<include layout="@layout/actionbar_include_cancel_button" />
<include layout="@layout/actionbar_include_done_button" />
</LinearLayout>

View File

@ -17,7 +17,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:src="@drawable/ic_action_expand"/> android:src="@drawable/ic_expand_more_black_24dp"/>
<TextView <TextView
android:id="@+id/foldableText" android:id="@+id/foldableText"

View File

@ -0,0 +1,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
<include layout="@layout/full_screen_dialog_done_button" />
</LinearLayout>

View File

@ -0,0 +1,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="middle">
<include layout="@layout/full_screen_dialog_2_cancel_button" />
<include layout="@layout/full_screen_dialog_2_done_button" />
</LinearLayout>

View File

@ -1,19 +1,3 @@
<!--
Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actionbar_cancel" android:id="@+id/actionbar_cancel"
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
@ -30,12 +14,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:drawableLeft="@drawable/ic_action_cancel" android:drawableLeft="@drawable/ic_close_white_24dp"
android:drawablePadding="8dp" android:drawablePadding="8dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingRight="20dp" android:paddingRight="20dp"
android:filterTouchesWhenObscured="true" android:filterTouchesWhenObscured="true"
style="@style/Widget.AppCompat.Light.ActionBar.TabText" style="@style/Widget.AppCompat.Light.ActionBar.TabText"
android:textAllCaps="true"
android:textSize="14sp"
android:text="Cancel (set in-code!)" /> android:text="Cancel (set in-code!)" />
</FrameLayout> </FrameLayout>

View File

@ -1,19 +1,3 @@
<!--
Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actionbar_done" android:id="@+id/actionbar_done"
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
@ -30,12 +14,14 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:drawableLeft="@drawable/ic_action_done" android:drawableLeft="@drawable/ic_check_white_24dp"
android:drawablePadding="8dp" android:drawablePadding="8dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingRight="20dp" android:paddingRight="20dp"
android:filterTouchesWhenObscured="true" android:filterTouchesWhenObscured="true"
style="@style/Widget.AppCompat.Light.ActionBar.TabText" style="@style/Widget.AppCompat.Light.ActionBar.TabText"
android:textAllCaps="true"
android:textSize="14sp"
android:text="Done (set in-code!)" /> android:text="Done (set in-code!)" />
</FrameLayout> </FrameLayout>

View File

@ -0,0 +1,25 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/full_screen_dialog_done"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<!--
android:filterTouchesWhenObscured="true" to prevent Touch-Event Hijacking
https://blog.lookout.com/blog/2010/12/09/android-touch-event-hijacking/
-->
<TextView
android:id="@+id/full_screen_dialog_done_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center_vertical"
android:paddingRight="16dp"
android:paddingEnd="16dp"
style="@style/Widget.AppCompat.Light.ActionBar.TabText"
android:textAllCaps="true"
android:textSize="14sp"
android:filterTouchesWhenObscured="true"
android:text="Done (set in-code!)" />
</FrameLayout>

View File

@ -0,0 +1,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerPadding="12dp"
android:orientation="horizontal"
android:showDividers="end" >
<include layout="@layout/full_screen_dialog_2_done_button" />
</LinearLayout>

View File

@ -20,7 +20,7 @@
<string name="title_preferences">"Settings"</string> <string name="title_preferences">"Settings"</string>
<string name="title_cloud_search_preferences">"Cloud Search Preferences"</string> <string name="title_cloud_search_preferences">"Cloud Search Preferences"</string>
<string name="title_api_registered_apps">"Apps"</string> <string name="title_api_registered_apps">"Apps"</string>
<string name="title_key_server_preference">"Keyserver Preference"</string> <string name="title_key_server_preference">"Keyservers"</string>
<string name="title_change_passphrase">"Change Passphrase"</string> <string name="title_change_passphrase">"Change Passphrase"</string>
<string name="title_share_fingerprint_with">"Share fingerprint with…"</string> <string name="title_share_fingerprint_with">"Share fingerprint with…"</string>
<string name="title_share_key">"Share key with…"</string> <string name="title_share_key">"Share key with…"</string>

View File

@ -18,7 +18,7 @@
<!-- Background for the actions section (e.g. voice, submit) --> <!-- Background for the actions section (e.g. voice, submit) -->
<!--<item name="submitBackground">...</item>--> <!--<item name="submitBackground">...</item>-->
<!-- Close button icon --> <!-- Close button icon -->
<!--<item name="closeIcon">...</item>--> <item name="closeIcon">@drawable/ic_close_white_24dp</item>
<!-- Search button icon --> <!-- Search button icon -->
<!--<item name="searchIcon">...</item>--> <!--<item name="searchIcon">...</item>-->
<!-- Go/commit button icon --> <!-- Go/commit button icon -->