From fe31883f661d55c20903cf1b249dc46395b57c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 27 Feb 2015 22:40:52 +0100 Subject: Keybase header text --- .../java/org/sufficientlysecure/keychain/ui/ViewKeyTrustFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyTrustFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyTrustFragment.java index 5483d16b8..25edc7a02 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyTrustFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyTrustFragment.java @@ -80,7 +80,7 @@ public class ViewKeyTrustFragment extends LoaderFragment implements @Override public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_trust_fragment, getContainer()); + View view = inflater.inflate(R.layout.view_key_adv_keybase_fragment, getContainer()); mInflater = inflater; mTrustReadout = (TextView) view.findViewById(R.id.view_key_trust_readout); @@ -299,7 +299,7 @@ public class ViewKeyTrustFragment extends LoaderFragment implements int rowNumber = 1; for (CharSequence s : result.mProofs) { - TableRow row = (TableRow) mInflater.inflate(R.layout.view_key_keybase_proof, null); + TableRow row = (TableRow) mInflater.inflate(R.layout.view_key_adv_keybase_proof, null); TextView number = (TextView) row.findViewById(R.id.proof_number); TextView text = (TextView) row.findViewById(R.id.proof_text); number.setText(Integer.toString(rowNumber++) + ". "); -- cgit v1.2.3 From 80c159056d8efc4dd82c36a2c168511d34d6e8b4 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 27 Feb 2015 22:46:40 +0100 Subject: show refresh key progress inline --- .../service/KeychainIntentServiceHandler.java | 7 +- .../keychain/ui/ViewKeyActivity.java | 132 +++++++++++++++++++-- 2 files changed, 131 insertions(+), 8 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java index ceb0a2d2b..635fe86f1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentServiceHandler.java @@ -78,6 +78,10 @@ public class KeychainIntentServiceHandler extends Handler { } public void showProgressDialog(FragmentActivity activity) { + if (mProgressDialogFragment == null) { + return; + } + // TODO: This is a hack!, see // http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult final FragmentManager manager = activity.getSupportFragmentManager(); @@ -94,7 +98,8 @@ public class KeychainIntentServiceHandler extends Handler { Bundle data = message.getData(); if (mProgressDialogFragment == null) { - Log.e(Constants.TAG, "Progress has not been updated because mProgressDialogFragment was null!"); + // Log.e(Constants.TAG, + // "Progress has not been updated because mProgressDialogFragment was null!"); return; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index afb742079..f6c56d965 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -33,6 +33,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.os.Messenger; import android.provider.ContactsContract; import android.provider.Settings; import android.support.v4.app.ActivityCompat; @@ -44,6 +45,9 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.view.animation.Animation.AnimationListener; +import android.view.animation.AnimationUtils; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -54,11 +58,14 @@ import com.getbase.floatingactionbutton.FloatingActionButton; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; +import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.KeyRing; import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.ui.util.FormattingUtils; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; @@ -68,7 +75,9 @@ import org.sufficientlysecure.keychain.ui.widget.AspectRatioImageView; import org.sufficientlysecure.keychain.util.ContactHelper; import org.sufficientlysecure.keychain.util.ExportHelper; import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.Preferences; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -105,6 +114,10 @@ public class ViewKeyActivity extends BaseActivity implements private boolean mIsSecret = false; private boolean mHasEncrypt = false; private boolean mIsVerified = false; + private MenuItem mRefreshItem; + private boolean mIsRefreshing; + private Animation mRotate, mRotateSpin; + private View mRefresh; @Override protected void onCreate(Bundle savedInstanceState) { @@ -128,6 +141,51 @@ public class ViewKeyActivity extends BaseActivity implements mQrCode = (ImageView) findViewById(R.id.view_key_qr_code); mQrCodeLayout = (CardView) findViewById(R.id.view_key_qr_code_layout); + mRotateSpin = AnimationUtils.loadAnimation(this, R.anim.rotate_spin); + mRotateSpin.setAnimationListener(new AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + mRefreshItem.getActionView().clearAnimation(); + mRefreshItem.setActionView(null); + mRefreshItem.setEnabled(true); + + // this is a deferred call + supportInvalidateOptionsMenu(); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + mRotate = AnimationUtils.loadAnimation(this, R.anim.rotate); + mRotate.setRepeatCount(Animation.INFINITE); + mRotate.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + if (!mIsRefreshing) { + mRefreshItem.getActionView().clearAnimation(); + mRefreshItem.getActionView().startAnimation(mRotateSpin); + } + } + }); + mRefresh = getLayoutInflater().inflate(R.layout.indeterminate_progress, null); + mDataUri = getIntent().getData(); if (mDataUri == null) { Log.e(Constants.TAG, "Data missing. Should be uri of key!"); @@ -222,7 +280,7 @@ public class ViewKeyActivity extends BaseActivity implements public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.key_view, menu); - + mRefreshItem = menu.findItem(R.id.menu_key_view_refresh); return true; } @@ -414,16 +472,72 @@ public class ViewKeyActivity extends BaseActivity implements private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper) throws ProviderHelper.NotFoundException { + + mIsRefreshing = true; + mRefreshItem.setEnabled(false); + mRefreshItem.setActionView(mRefresh); + mRefresh.startAnimation(mRotate); + byte[] blob = (byte[]) providerHelper.getGenericData( KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri), KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB); String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob); - Intent queryIntent = new Intent(this, ImportKeysActivity.class); - queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT); - queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); + ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null); + ArrayList entries = new ArrayList<>(); + entries.add(keyEntry); + + // Message is received after importing is done in KeychainIntentService + KeychainIntentServiceHandler serviceHandler = new KeychainIntentServiceHandler(this) { + public void handleMessage(Message message) { + // handle messages by standard KeychainIntentServiceHandler first + super.handleMessage(message); + + if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + // get returned data bundle + Bundle returnData = message.getData(); + + mIsRefreshing = false; + + if (returnData == null) { + finish(); + return; + } + final ImportKeyResult result = + returnData.getParcelable(OperationResult.EXTRA_RESULT); + result.createNotify(ViewKeyActivity.this).show(); + } + } + }; + + // fill values for this action + Bundle data = new Bundle(); + + // search config + { + Preferences prefs = Preferences.getPreferences(this); + Preferences.CloudSearchPrefs cloudPrefs = + new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver()); + data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver); + } + + data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, entries); + + // Send all information needed to service to query keys in other thread + Intent intent = new Intent(this, KeychainIntentService.class); + intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING); + intent.putExtra(KeychainIntentService.EXTRA_DATA, data); + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(serviceHandler); + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + + // show progress dialog + serviceHandler.showProgressDialog(this); + + // start service with intent + startService(intent); - startActivityForResult(queryIntent, 0); } private void editKey(Uri dataUri) { @@ -634,8 +748,12 @@ public class ViewKeyActivity extends BaseActivity implements && new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date()); mIsVerified = data.getInt(INDEX_VERIFIED) > 0; - // re-create options menu based on mIsSecret, mIsVerified - supportInvalidateOptionsMenu(); + // if the refresh animation isn't playing + if (!mRotate.hasStarted() && !mRotateSpin.hasStarted()) { + // re-create options menu based on mIsSecret, mIsVerified + supportInvalidateOptionsMenu(); + // this is done at the end of the animation otherwise + } AsyncTask photoTask = new AsyncTask() { -- cgit v1.2.3 From fd2f858b12974629c612d366017669f640bf3254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 27 Feb 2015 22:47:39 +0100 Subject: Fix status images in user id adapter --- .../sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index ad7c9e430..8c0ab9165 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -72,19 +72,19 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes, SaveKeyringParcel saveKeyringParcel) { - this(context, c, flags, showCheckBoxes, false, saveKeyringParcel); + this(context, c, flags, showCheckBoxes, true, saveKeyringParcel); } public UserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { - this(context, c, flags, showCheckBoxes, false, null); + this(context, c, flags, showCheckBoxes, true, null); } public UserIdsAdapter(Context context, Cursor c, int flags, SaveKeyringParcel saveKeyringParcel) { - this(context, c, flags, false, false, saveKeyringParcel); + this(context, c, flags, false, true, saveKeyringParcel); } public UserIdsAdapter(Context context, Cursor c, int flags) { - this(context, c, flags, false, false, null); + this(context, c, flags, false, true, null); } @Override -- cgit v1.2.3 From 863f4e6ac18edbeb0dde5c79b5a4808f7915dd0c Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 27 Feb 2015 23:09:17 +0100 Subject: hand through result in CertifyFingerprintActivity --- .../sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java index 777288e69..c75f6d838 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java @@ -83,8 +83,8 @@ public class CertifyFingerprintActivity extends BaseActivity { protected void onActivityResult(int requestCode, int resultCode, Intent data) { // if a result has been returned, display a notify if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) { - OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); - result.createNotify(this).show(); + setResult(RESULT_OK, data); + finish(); } else { super.onActivityResult(requestCode, resultCode, data); } -- cgit v1.2.3 From aec9bdfc1e30c590a22d4860b9e955c5cb570a3a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 27 Feb 2015 23:09:35 +0100 Subject: transition status color in key view --- .../keychain/ui/ViewKeyActivity.java | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index f6c56d965..d14455511 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -18,11 +18,14 @@ package org.sufficientlysecure.keychain.ui; +import android.animation.ArgbEvaluator; +import android.animation.ObjectAnimator; import android.annotation.TargetApi; import android.app.ActivityOptions; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; +import android.graphics.Color; import android.net.Uri; import android.nfc.NdefMessage; import android.nfc.NdefRecord; @@ -717,6 +720,8 @@ public class ViewKeyActivity extends BaseActivity implements } } + int mPreviousColor = 0; + @Override public void onLoadFinished(Loader loader, Cursor data) { /* TODO better error handling? May cause problems when a key is deleted, @@ -861,9 +866,31 @@ public class ViewKeyActivity extends BaseActivity implements mFab.setVisibility(View.VISIBLE); } } - mToolbar.setBackgroundColor(color); - mStatusBar.setBackgroundColor(color); - mBigToolbar.setBackgroundColor(color); + + if (mPreviousColor == 0 || mPreviousColor == color) { + mToolbar.setBackgroundColor(color); + mStatusBar.setBackgroundColor(color); + mBigToolbar.setBackgroundColor(color); + mPreviousColor = color; + } else { + ObjectAnimator colorFade1 = + ObjectAnimator.ofObject(mToolbar, "backgroundColor", + new ArgbEvaluator(), mPreviousColor, color); + ObjectAnimator colorFade2 = + ObjectAnimator.ofObject(mStatusBar, "backgroundColor", + new ArgbEvaluator(), mPreviousColor, color); + ObjectAnimator colorFade3 = + ObjectAnimator.ofObject(mBigToolbar, "backgroundColor", + new ArgbEvaluator(), mPreviousColor, color); + + colorFade1.setDuration(800); + colorFade2.setDuration(800); + colorFade3.setDuration(800); + colorFade1.start(); + colorFade2.start(); + colorFade3.start(); + mPreviousColor = color; + } mStatusImage.setAlpha(80); -- cgit v1.2.3 From 200d4a6bb6185242afa566d09d10d5b0ba62d58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 27 Feb 2015 23:39:36 +0100 Subject: Remove swipte to refresh src, fix padding in key list --- .../keychain/ui/KeyListFragment.java | 68 --------------- .../ui/widget/ListAwareSwipeRefreshLayout.java | 99 ---------------------- 2 files changed, 167 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 99714b4a0..ba9a96b28 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -36,8 +36,6 @@ import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.CursorAdapter; -import android.support.v4.widget.NoScrollableSwipeRefreshLayout; -import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.view.ActionMode; @@ -45,7 +43,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -73,7 +70,6 @@ import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.util.Highlighter; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; -import org.sufficientlysecure.keychain.ui.widget.ListAwareSwipeRefreshLayout; import org.sufficientlysecure.keychain.util.ExportHelper; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; @@ -97,7 +93,6 @@ public class KeyListFragment extends LoaderFragment private KeyListAdapter mAdapter; private StickyListHeadersListView mStickyList; - private ListAwareSwipeRefreshLayout mSwipeRefreshLayout; // saves the mode object for multiselect, needed for reset at some point private ActionMode mActionMode = null; @@ -152,73 +147,10 @@ public class KeyListFragment extends LoaderFragment } }); - mSwipeRefreshLayout = (ListAwareSwipeRefreshLayout) view.findViewById(R.id.key_list_swipe_container); - mSwipeRefreshLayout.setOnRefreshListener(new NoScrollableSwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - KeychainIntentServiceHandler finishedHandler = new KeychainIntentServiceHandler(getActivity()) { - public void handleMessage(Message message) { - if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { - mSwipeRefreshLayout.setRefreshing(false); - } - } - }; - // new KeyUpdateHelper().updateAllKeys(getActivity(), finishedHandler); - updateActionbarForSwipe(false); - } - }); - mSwipeRefreshLayout.setColorScheme( - R.color.android_purple_dark, - R.color.android_purple_light, - R.color.android_purple_dark, - R.color.android_purple_light); - mSwipeRefreshLayout.setStickyListHeadersListView(mStickyList); - mSwipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_MOVE) { - updateActionbarForSwipe(true); - } else { - updateActionbarForSwipe(false); - } - return false; - } - }); - // Just disable for now - mSwipeRefreshLayout.setIsLocked(true); return root; } - private void updateActionbarForSwipe(boolean show) { - ActionBarActivity activity = (ActionBarActivity) getActivity(); - ActionBar bar = activity.getSupportActionBar(); - - if (show) { - bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); - bar.setDisplayUseLogoEnabled(false); - bar.setCustomView(R.layout.custom_actionbar); - TextView title = (TextView) getActivity().findViewById(R.id.custom_actionbar_text); - title.setText(R.string.swipe_to_update); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { -// hideMenu = true; -// activity.invalidateOptionsMenu(); - } - } else { - bar.setTitle(getActivity().getTitle()); - bar.setDisplayHomeAsUpEnabled(true); - bar.setDisplayShowTitleEnabled(true); - bar.setDisplayUseLogoEnabled(true); - bar.setDisplayShowHomeEnabled(true); - bar.setDisplayShowCustomEnabled(false); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { -// hideMenu = false; -// activity.invalidateOptionsMenu(); - } - } - } - /** * Define Adapter and Loader on create of Activity */ diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java deleted file mode 100644 index 3403208d7..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/ListAwareSwipeRefreshLayout.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2014 Daniel Albert - * - * 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 . - */ - -package org.sufficientlysecure.keychain.ui.widget; - -import android.content.Context; -import android.support.v4.widget.NoScrollableSwipeRefreshLayout; -import android.util.AttributeSet; -import android.view.MotionEvent; - -import se.emilsjolander.stickylistheaders.StickyListHeadersListView; - -public class ListAwareSwipeRefreshLayout extends NoScrollableSwipeRefreshLayout { - - private StickyListHeadersListView mStickyListHeadersListView = null; - private boolean mIsLocked = false; - - /** - * Constructors - */ - public ListAwareSwipeRefreshLayout(Context context) { - super(context); - } - - public ListAwareSwipeRefreshLayout(Context context, AttributeSet attrs) { - super(context, attrs); - } - - /** - * Getters / Setters - */ - public void setStickyListHeadersListView(StickyListHeadersListView stickyListHeadersListView) { - mStickyListHeadersListView = stickyListHeadersListView; - } - - public StickyListHeadersListView getStickyListHeadersListView() { - return mStickyListHeadersListView; - } - - public void setIsLocked(boolean locked) { - mIsLocked = locked; - } - - public boolean getIsLocked() { - return mIsLocked; - } - - @Override - public boolean canChildScrollUp() { - if (mStickyListHeadersListView == null) { - return super.canChildScrollUp(); - } - - return (mIsLocked || ( - mStickyListHeadersListView.getWrappedList().getChildCount() > 0 - && (mStickyListHeadersListView.getWrappedList().getChildAt(0).getTop() < 0 - || mStickyListHeadersListView.getFirstVisiblePosition() > 0) - ) - ); - } - - /** Called on a touch event, this method exempts a small area in the upper right from pull to - * refresh handling. - * - * If the touch event happens somewhere in the upper right corner of the screen, we return false - * to indicate that the event was not handled. This ensures events in that area are always - * handed through to the list scrollbar handle. For all other cases, we pass the message through - * to the pull to refresh handler. - */ - @Override - public boolean onTouchEvent(MotionEvent event) { - // The device may be null. This actually happens - if (event.getDevice() != null) { - // MotionEvent.AXIS_X is api level 12, for some reason, so we use a constant 0 here - float ratioX = event.getX() / event.getDevice().getMotionRange(0).getMax(); - float ratioY = event.getY() / event.getDevice().getMotionRange(1).getMax(); - // if this is the upper right corner, don't handle as pull to refresh event - if (ratioX > 0.85f && ratioY < 0.15f) { - return false; - } - } - return super.onTouchEvent(event); - } - -} \ No newline at end of file -- cgit v1.2.3 From f2a9a41840a370864537239e106da2e932aa9d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 27 Feb 2015 23:47:15 +0100 Subject: Enable multi line snackbar option --- .../main/java/org/sufficientlysecure/keychain/ui/util/Notify.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java index 6f8c477c0..f6c979139 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java @@ -24,6 +24,7 @@ import android.graphics.Color; import com.nispok.snackbar.Snackbar; import com.nispok.snackbar.Snackbar.SnackbarDuration; import com.nispok.snackbar.SnackbarManager; +import com.nispok.snackbar.enums.SnackbarType; import com.nispok.snackbar.listeners.ActionClickListener; import org.sufficientlysecure.keychain.R; @@ -48,6 +49,7 @@ public class Notify { Snackbar bar = Snackbar.with(activity) .text(text) + .type(SnackbarType.MULTI_LINE) .duration(SnackbarDuration.LENGTH_LONG); switch (style) { @@ -67,7 +69,8 @@ public class Notify { public static Showable createNotify (Activity activity, int resId, int duration, Style style) { final Snackbar bar = Snackbar.with(activity) - .text(resId); + .text(resId) + .type(SnackbarType.MULTI_LINE); if (duration == LENGTH_INDEFINITE) { bar.duration(SnackbarDuration.LENGTH_INDEFINITE); } else { @@ -104,6 +107,7 @@ public class Notify { final Snackbar bar = Snackbar.with(activity) .text(msg) .actionLabel(resIdAction) + .type(SnackbarType.MULTI_LINE) .actionListener(new ActionClickListener() { @Override public void onActionClicked(Snackbar snackbar) { -- cgit v1.2.3 From 8cfba4c0fb3ebf7b24c0c8ede6887b3bde43259f Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 27 Feb 2015 23:52:51 +0100 Subject: slightly longer color fade duration --- .../java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index d14455511..bbf35e497 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -883,9 +883,9 @@ public class ViewKeyActivity extends BaseActivity implements ObjectAnimator.ofObject(mBigToolbar, "backgroundColor", new ArgbEvaluator(), mPreviousColor, color); - colorFade1.setDuration(800); - colorFade2.setDuration(800); - colorFade3.setDuration(800); + colorFade1.setDuration(1200); + colorFade2.setDuration(1200); + colorFade3.setDuration(1200); colorFade1.start(); colorFade2.start(); colorFade3.start(); -- cgit v1.2.3 From 582caaba97c288de88b7a957cdf1b6f5bc84ed31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 27 Feb 2015 23:56:53 +0100 Subject: Reorder advanced key view --- .../keychain/ui/ViewKeyAdvActivity.java | 12 +- .../keychain/ui/ViewKeyAdvMainFragment.java | 236 --------------------- .../keychain/ui/ViewKeyAdvUserIdsFragment.java | 184 ++++++++++++++++ 3 files changed, 190 insertions(+), 242 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java index 894529cc5..9d79b377c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvActivity.java @@ -124,16 +124,16 @@ public class ViewKeyAdvActivity extends BaseActivity implements mTabsAdapter = new PagerTabStripAdapter(this); mViewPager.setAdapter(mTabsAdapter); - Bundle mainBundle = new Bundle(); - mainBundle.putParcelable(ViewKeyAdvMainFragment.ARG_DATA_URI, dataUri); - mTabsAdapter.addTab(ViewKeyAdvMainFragment.class, - mainBundle, getString(R.string.key_view_tab_main)); - Bundle shareBundle = new Bundle(); - shareBundle.putParcelable(ViewKeyAdvMainFragment.ARG_DATA_URI, dataUri); + shareBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri); mTabsAdapter.addTab(ViewKeyAdvShareFragment.class, shareBundle, getString(R.string.key_view_tab_share)); + Bundle userIdsBundle = new Bundle(); + userIdsBundle.putParcelable(ViewKeyAdvUserIdsFragment.ARG_DATA_URI, dataUri); + mTabsAdapter.addTab(ViewKeyAdvUserIdsFragment.class, + userIdsBundle, getString(R.string.section_user_ids)); + Bundle keysBundle = new Bundle(); keysBundle.putParcelable(ViewKeyAdvSubkeysFragment.ARG_DATA_URI, dataUri); mTabsAdapter.addTab(ViewKeyAdvSubkeysFragment.class, diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java deleted file mode 100644 index fc107d794..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvMainFragment.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * Copyright (C) 2014 Vincent Breitmoser - * - * 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 . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.content.Intent; -import android.database.Cursor; -import android.graphics.PorterDuff; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ImageView; -import android.widget.ListView; - -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException; -import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; -import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; -import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; -import org.sufficientlysecure.keychain.util.Log; - -import java.util.Date; - -public class ViewKeyAdvMainFragment extends LoaderFragment implements - LoaderManager.LoaderCallbacks { - - public static final String ARG_DATA_URI = "uri"; - - private View mActionCertify; - private View mActionCertifyText; - private ImageView mActionCertifyImage; - - private ListView mUserIds; - - private static final int LOADER_ID_UNIFIED = 0; - private static final int LOADER_ID_USER_IDS = 1; - - private UserIdsAdapter mUserIdsAdapter; - - private Uri mDataUri; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { - View root = super.onCreateView(inflater, superContainer, savedInstanceState); - View view = inflater.inflate(R.layout.view_key_adv_main_fragment, getContainer()); - - mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); - mActionCertify = view.findViewById(R.id.view_key_action_certify); - mActionCertifyText = view.findViewById(R.id.view_key_action_certify_text); - mActionCertifyImage = (ImageView) view.findViewById(R.id.view_key_action_certify_image); - // make certify image gray, like action icons - mActionCertifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light), - PorterDuff.Mode.SRC_IN); - - mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - showUserIdInfo(position); - } - }); - - return root; - } - - private void showUserIdInfo(final int position) { - final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); - final int isVerified = mUserIdsAdapter.getIsVerified(position); - - DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { - public void run() { - UserIdInfoDialogFragment dialogFragment = - UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); - - dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); - } - }); - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); - if (dataUri == null) { - Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); - getActivity().finish(); - return; - } - - loadData(dataUri); - } - - private void loadData(Uri dataUri) { - mDataUri = dataUri; - - Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); - - mActionCertify.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - certify(mDataUri); - } - }); - - mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); - mUserIds.setAdapter(mUserIdsAdapter); - - // Prepare the loaders. Either re-connect with an existing ones, - // or start new ones. - getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); - getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); - } - - static final String[] UNIFIED_PROJECTION = new String[]{ - KeyRings._ID, KeyRings.MASTER_KEY_ID, - KeyRings.HAS_ANY_SECRET, KeyRings.IS_REVOKED, KeyRings.EXPIRY, KeyRings.HAS_ENCRYPT - }; - static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; - static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; - static final int INDEX_UNIFIED_IS_REVOKED = 3; - static final int INDEX_UNIFIED_EXPIRY = 4; - static final int INDEX_UNIFIED_HAS_ENCRYPT = 5; - - public Loader onCreateLoader(int id, Bundle args) { - setContentShown(false); - - switch (id) { - case LOADER_ID_UNIFIED: { - Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); - } - case LOADER_ID_USER_IDS: { - Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, - UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); - } - - default: - return null; - } - } - - public void onLoadFinished(Loader loader, Cursor data) { - /* TODO better error handling? May cause problems when a key is deleted, - * because the notification triggers faster than the activity closes. - */ - // Avoid NullPointerExceptions... - if (data.getCount() == 0) { - return; - } - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - switch (loader.getId()) { - case LOADER_ID_UNIFIED: { - if (data.moveToFirst()) { - - // If this key is revoked, it cannot be used for anything! - if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { - mActionCertify.setEnabled(false); - mActionCertifyText.setEnabled(false); - } else { - - Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); - if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { - mActionCertify.setEnabled(false); - mActionCertifyText.setEnabled(false); - } else { - mActionCertify.setEnabled(true); - mActionCertifyText.setEnabled(true); - } - } - - break; - } - } - - case LOADER_ID_USER_IDS: { - mUserIdsAdapter.swapCursor(data); - break; - } - - } - setContentShown(true); - } - - /** - * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. - * We need to make sure we are no longer using it. - */ - public void onLoaderReset(Loader loader) { - switch (loader.getId()) { - case LOADER_ID_USER_IDS: - mUserIdsAdapter.swapCursor(null); - break; - } - } - - private void certify(Uri dataUri) { - long keyId = 0; - try { - keyId = new ProviderHelper(getActivity()) - .getCachedPublicKeyRing(dataUri) - .extractOrGetMasterKeyId(); - } catch (PgpKeyNotFoundException e) { - Log.e(Constants.TAG, "key not found!", e); - } - Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); - certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); - startActivityForResult(certifyIntent, 0); - } - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java new file mode 100644 index 000000000..c4e6639a8 --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * Copyright (C) 2014 Vincent Breitmoser + * + * 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 . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ListView; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets; +import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; +import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; +import org.sufficientlysecure.keychain.util.Log; + +public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements + LoaderManager.LoaderCallbacks { + + public static final String ARG_DATA_URI = "uri"; + + private ListView mUserIds; + + private static final int LOADER_ID_UNIFIED = 0; + private static final int LOADER_ID_USER_IDS = 1; + + private UserIdsAdapter mUserIdsAdapter; + + private Uri mDataUri; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) { + View root = super.onCreateView(inflater, superContainer, savedInstanceState); + View view = inflater.inflate(R.layout.view_key_adv_main_fragment, getContainer()); + + mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); + + mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + showUserIdInfo(position); + } + }); + + return root; + } + + private void showUserIdInfo(final int position) { + final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position); + final int isVerified = mUserIdsAdapter.getIsVerified(position); + + DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { + public void run() { + UserIdInfoDialogFragment dialogFragment = + UserIdInfoDialogFragment.newInstance(isRevoked, isVerified); + + dialogFragment.show(getActivity().getSupportFragmentManager(), "userIdInfoDialog"); + } + }); + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); + if (dataUri == null) { + Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); + getActivity().finish(); + return; + } + + loadData(dataUri); + } + + private void loadData(Uri dataUri) { + mDataUri = dataUri; + + Log.i(Constants.TAG, "mDataUri: " + mDataUri.toString()); + + mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0); + mUserIds.setAdapter(mUserIdsAdapter); + + // Prepare the loaders. Either re-connect with an existing ones, + // or start new ones. + getLoaderManager().initLoader(LOADER_ID_UNIFIED, null, this); + getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); + } + + static final String[] UNIFIED_PROJECTION = new String[]{ + KeyRings._ID, KeyRings.MASTER_KEY_ID, + KeyRings.HAS_ANY_SECRET, KeyRings.IS_REVOKED, KeyRings.EXPIRY, KeyRings.HAS_ENCRYPT + }; + static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; + static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; + static final int INDEX_UNIFIED_IS_REVOKED = 3; + static final int INDEX_UNIFIED_EXPIRY = 4; + static final int INDEX_UNIFIED_HAS_ENCRYPT = 5; + + public Loader onCreateLoader(int id, Bundle args) { + setContentShown(false); + + switch (id) { + case LOADER_ID_UNIFIED: { + Uri baseUri = KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null); + } + case LOADER_ID_USER_IDS: { + Uri baseUri = UserPackets.buildUserIdsUri(mDataUri); + return new CursorLoader(getActivity(), baseUri, + UserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + } + + default: + return null; + } + } + + public void onLoadFinished(Loader loader, Cursor data) { + /* TODO better error handling? May cause problems when a key is deleted, + * because the notification triggers faster than the activity closes. + */ + // Avoid NullPointerExceptions... + if (data.getCount() == 0) { + return; + } + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + switch (loader.getId()) { + case LOADER_ID_UNIFIED: { + if (data.moveToFirst()) { + + + break; + } + } + + case LOADER_ID_USER_IDS: { + mUserIdsAdapter.swapCursor(data); + break; + } + + } + setContentShown(true); + } + + /** + * This is called when the last Cursor provided to onLoadFinished() above is about to be closed. + * We need to make sure we are no longer using it. + */ + public void onLoaderReset(Loader loader) { + switch (loader.getId()) { + case LOADER_ID_USER_IDS: + mUserIdsAdapter.swapCursor(null); + break; + } + } + +} -- cgit v1.2.3 From 0669193e7517920972e4bb577c1bec04fa7b594f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 28 Feb 2015 00:22:31 +0100 Subject: Simplify MainActivity --- .../keychain/ui/MainActivity.java | 25 ++++++++++- .../keychain/ui/NavDrawerActivity.java | 50 ---------------------- 2 files changed, 23 insertions(+), 52 deletions(-) delete mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index 2f29f9360..04350a57d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -23,13 +23,34 @@ import android.os.Bundle; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; +import org.sufficientlysecure.keychain.remote.ui.AppsListFragment; import org.sufficientlysecure.keychain.util.Preferences; -public class MainActivity extends NavDrawerActivity { +import it.neokree.materialnavigationdrawer.MaterialNavigationDrawer; + +public class MainActivity extends MaterialNavigationDrawer { @Override public void init(Bundle savedInstanceState) { - super.init(savedInstanceState); + // don't open drawer on first run + disableLearningPattern(); + +// addMultiPaneSupport(); + + // set the header image + // create and set the header + setDrawerHeaderImage(R.drawable.drawer_header); + + // create sections + addSection(newSection(getString(R.string.nav_keys), R.drawable.ic_vpn_key_black_24dp, new KeyListFragment())); + addSection(newSection(getString(R.string.nav_encrypt_decrypt), R.drawable.ic_lock_black_24dp, new EncryptDecryptOverviewFragment())); + addSection(newSection(getString(R.string.title_api_registered_apps), R.drawable.ic_apps_black_24dp, new AppsListFragment())); + + // create bottom section + addBottomSection(newSection(getString(R.string.menu_preferences), R.drawable.ic_settings_black_24dp, new Intent(this, SettingsActivity.class))); + addBottomSection(newSection(getString(R.string.menu_help), R.drawable.ic_help_black_24dp, new Intent(this, HelpActivity.class))); + + // if this is the first time show first time activity Preferences prefs = Preferences.getPreferences(this); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java deleted file mode 100644 index fb23c7d3a..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NavDrawerActivity.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2015 Dominik Schürmann - * - * 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 . - */ - -package org.sufficientlysecure.keychain.ui; - -import android.content.Intent; -import android.os.Bundle; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.remote.ui.AppsListFragment; - -import it.neokree.materialnavigationdrawer.MaterialNavigationDrawer; - -public abstract class NavDrawerActivity extends MaterialNavigationDrawer { - - @Override - public void init(Bundle savedInstanceState) { - // don't open drawer on first run - disableLearningPattern(); - -// addMultiPaneSupport(); - - // set the header image - // create and set the header - setDrawerHeaderImage(R.drawable.drawer_header); - - // create sections - addSection(newSection(getString(R.string.nav_keys), R.drawable.ic_vpn_key_black_24dp, new KeyListFragment())); - addSection(newSection(getString(R.string.nav_encrypt_decrypt), R.drawable.ic_lock_black_24dp, new EncryptDecryptOverviewFragment())); - addSection(newSection(getString(R.string.title_api_registered_apps), R.drawable.ic_apps_black_24dp, new AppsListFragment())); - - // create bottom section - addBottomSection(newSection(getString(R.string.menu_preferences), R.drawable.ic_settings_black_24dp, new Intent(this, SettingsActivity.class))); - addBottomSection(newSection(getString(R.string.menu_help), R.drawable.ic_help_black_24dp, new Intent(this, HelpActivity.class))); - } -} -- cgit v1.2.3 From 9c62c3fd3985958a43707c7a25f07744a6cfcb95 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 00:28:20 +0100 Subject: control flow for moving the fab up with snackbar --- .../keychain/ui/KeyListFragment.java | 31 ++++++++++++++++- .../keychain/ui/MainActivity.java | 20 +++++++++-- .../keychain/ui/util/Notify.java | 39 ++++++++++++++++++++-- 3 files changed, 85 insertions(+), 5 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index ba9a96b28..bf3498f2f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -46,14 +46,19 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; +import android.view.ViewGroup.MarginLayoutParams; +import android.view.animation.TranslateAnimation; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; +import android.widget.RelativeLayout; import android.widget.TextView; import com.getbase.floatingactionbutton.FloatingActionButton; +import com.getbase.floatingactionbutton.FloatingActionsMenu; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -71,6 +76,7 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.Notify; import org.sufficientlysecure.keychain.util.ExportHelper; +import org.sufficientlysecure.keychain.util.FabContainer; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Preferences; @@ -87,7 +93,7 @@ import se.emilsjolander.stickylistheaders.StickyListHeadersListView; */ public class KeyListFragment extends LoaderFragment implements SearchView.OnQueryTextListener, AdapterView.OnItemClickListener, - LoaderManager.LoaderCallbacks { + LoaderManager.LoaderCallbacks, FabContainer { ExportHelper mExportHelper; @@ -102,6 +108,8 @@ public class KeyListFragment extends LoaderFragment private String mQuery; private SearchView mSearchView; + private FloatingActionsMenu mFab; + private FloatingActionButton mFabQrCode; private FloatingActionButton mFabCloud; private FloatingActionButton mFabFile; @@ -124,6 +132,8 @@ public class KeyListFragment extends LoaderFragment mStickyList = (StickyListHeadersListView) view.findViewById(R.id.key_list_list); mStickyList.setOnItemClickListener(this); + mFab = (FloatingActionsMenu) view.findViewById(R.id.fab_main); + mFabQrCode = (FloatingActionButton) view.findViewById(R.id.fab_add_qr_code); mFabCloud = (FloatingActionButton) view.findViewById(R.id.fab_add_cloud); mFabFile = (FloatingActionButton) view.findViewById(R.id.fab_add_file); @@ -609,6 +619,25 @@ public class KeyListFragment extends LoaderFragment } } + LayoutParams mFabOrigin = null; + @Override + public void fabMoveUp(int height) { + if (mFabOrigin == null) { + mFabOrigin = mFab.getLayoutParams(); + } + + // TODO reposition properly! + MarginLayoutParams marginParams = new MarginLayoutParams(mFabOrigin); + marginParams.setMargins(0, 0, 16, 16+height); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams); + mFab.setLayoutParams(layoutParams); + } + + @Override + public void fabRestorePosition() { + mFab.setLayoutParams(mFabOrigin); + } + /** * Implements StickyListHeadersAdapter from library */ diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index 04350a57d..fd2f1b1d2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -25,10 +25,11 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.remote.ui.AppsListFragment; import org.sufficientlysecure.keychain.util.Preferences; +import org.sufficientlysecure.keychain.util.FabContainer; import it.neokree.materialnavigationdrawer.MaterialNavigationDrawer; -public class MainActivity extends MaterialNavigationDrawer { +public class MainActivity extends MaterialNavigationDrawer implements FabContainer { @Override public void init(Bundle savedInstanceState) { @@ -51,7 +52,6 @@ public class MainActivity extends MaterialNavigationDrawer { addBottomSection(newSection(getString(R.string.menu_help), R.drawable.ic_help_black_24dp, new Intent(this, HelpActivity.class))); - // if this is the first time show first time activity Preferences prefs = Preferences.getPreferences(this); if (prefs.isFirstTime()) { @@ -68,4 +68,20 @@ public class MainActivity extends MaterialNavigationDrawer { } } + @Override + public void fabMoveUp(int height) { + Object fragment = getCurrentSection().getTargetFragment(); + if (fragment instanceof FabContainer) { + ((FabContainer) fragment).fabMoveUp(height); + } + } + + @Override + public void fabRestorePosition() { + Object fragment = getCurrentSection().getTargetFragment(); + if (fragment instanceof FabContainer) { + ((FabContainer) fragment).fabRestorePosition(); + } + } + } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java index f6c979139..1c6f3bd3e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java @@ -19,15 +19,16 @@ package org.sufficientlysecure.keychain.ui.util; import android.app.Activity; import android.content.res.Resources; -import android.graphics.Color; import com.nispok.snackbar.Snackbar; import com.nispok.snackbar.Snackbar.SnackbarDuration; import com.nispok.snackbar.SnackbarManager; import com.nispok.snackbar.enums.SnackbarType; import com.nispok.snackbar.listeners.ActionClickListener; +import com.nispok.snackbar.listeners.EventListener; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.util.FabContainer; /** * Notify wrapper which allows a more easy use of different notification libraries @@ -45,13 +46,47 @@ public class Notify { * @param text Text to show * @param style Notification styling */ - public static void showNotify(Activity activity, CharSequence text, Style style) { + public static void showNotify(final Activity activity, CharSequence text, Style style) { Snackbar bar = Snackbar.with(activity) .text(text) .type(SnackbarType.MULTI_LINE) .duration(SnackbarDuration.LENGTH_LONG); + if (activity instanceof FabContainer) { + bar.eventListener(new EventListener() { + @Override + public void onShow(Snackbar snackbar) { + ((FabContainer) activity).fabMoveUp(snackbar.getHeight()); + } + + @Override + public void onShowByReplace(Snackbar snackbar) { + + } + + @Override + public void onShown(Snackbar snackbar) { + + } + + @Override + public void onDismiss(Snackbar snackbar) { + ((FabContainer) activity).fabRestorePosition(); + } + + @Override + public void onDismissByReplace(Snackbar snackbar) { + + } + + @Override + public void onDismissed(Snackbar snackbar) { + + } + }); + } + switch (style) { case OK: break; -- cgit v1.2.3 From 453b67f7a8cb274d794843e54d6d050a7ef7a98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 28 Feb 2015 00:38:53 +0100 Subject: Update from transifex --- .../src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index 04350a57d..ed9f3a02d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -50,8 +50,6 @@ public class MainActivity extends MaterialNavigationDrawer { addBottomSection(newSection(getString(R.string.menu_preferences), R.drawable.ic_settings_black_24dp, new Intent(this, SettingsActivity.class))); addBottomSection(newSection(getString(R.string.menu_help), R.drawable.ic_help_black_24dp, new Intent(this, HelpActivity.class))); - - // if this is the first time show first time activity Preferences prefs = Preferences.getPreferences(this); if (prefs.isFirstTime()) { -- cgit v1.2.3 From 67093ccba244a1ba24c12acd4ce294d37aa09254 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 00:39:55 +0100 Subject: forgot to commit FabContainer --- .../java/org/sufficientlysecure/keychain/util/FabContainer.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FabContainer.java (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FabContainer.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FabContainer.java new file mode 100644 index 000000000..116b98d1e --- /dev/null +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/FabContainer.java @@ -0,0 +1,8 @@ +package org.sufficientlysecure.keychain.util; + +public interface FabContainer { + + void fabMoveUp(int height); + void fabRestorePosition(); + +} -- cgit v1.2.3 From d64b8f47d10b15903978a378bc6acf998ae3f890 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 01:17:45 +0100 Subject: animate FAB to move up and down when a snackbar appears --- .../keychain/ui/KeyListFragment.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index bf3498f2f..6e2b46da0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui; +import android.animation.ObjectAnimator; import android.annotation.TargetApi; import android.app.ProgressDialog; import android.content.Context; @@ -619,23 +620,21 @@ public class KeyListFragment extends LoaderFragment } } - LayoutParams mFabOrigin = null; @Override public void fabMoveUp(int height) { - if (mFabOrigin == null) { - mFabOrigin = mFab.getLayoutParams(); - } - - // TODO reposition properly! - MarginLayoutParams marginParams = new MarginLayoutParams(mFabOrigin); - marginParams.setMargins(0, 0, 16, 16+height); - RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams); - mFab.setLayoutParams(layoutParams); + ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, "translationY", 0, -height); + // we're a little behind, so skip 1/10 of the time + anim.setDuration(270); + anim.start(); } @Override public void fabRestorePosition() { - mFab.setLayoutParams(mFabOrigin); + ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, "translationY", 0); + // we're a little ahead, so wait a few ms + anim.setStartDelay(70); + anim.setDuration(300); + anim.start(); } /** -- cgit v1.2.3 From cc5b0dae06d2be11c9c677734d9d7dcfaf4f6078 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 01:31:24 +0100 Subject: collapse fab on action selected closes #1057 --- .../main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 6e2b46da0..0c53a3bc1 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -142,18 +142,21 @@ public class KeyListFragment extends LoaderFragment mFabQrCode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { + mFab.collapse(); scanQrCode(); } }); mFabCloud.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { + mFab.collapse(); searchCloud(); } }); mFabFile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { + mFab.collapse(); importFile(); } }); -- cgit v1.2.3 From 6ba03c0f13bb1301f40abf4bca2d2ec432186642 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 01:32:15 +0100 Subject: clean up warnings in KeyListFragment --- .../keychain/ui/KeyListFragment.java | 42 ++++++---------------- 1 file changed, 10 insertions(+), 32 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 0c53a3bc1..496048582 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -37,7 +37,6 @@ import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.CursorAdapter; -import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.view.ActionMode; import android.view.LayoutInflater; @@ -47,15 +46,11 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; -import android.view.ViewGroup.MarginLayoutParams; -import android.view.animation.TranslateAnimation; import android.widget.AbsListView.MultiChoiceModeListener; import android.widget.AdapterView; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.ListView; -import android.widget.RelativeLayout; import android.widget.TextView; import com.getbase.floatingactionbutton.FloatingActionButton; @@ -104,17 +99,10 @@ public class KeyListFragment extends LoaderFragment // saves the mode object for multiselect, needed for reset at some point private ActionMode mActionMode = null; - private boolean mShowAllKeys = true; - private String mQuery; - private SearchView mSearchView; private FloatingActionsMenu mFab; - private FloatingActionButton mFabQrCode; - private FloatingActionButton mFabCloud; - private FloatingActionButton mFabFile; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -135,25 +123,25 @@ public class KeyListFragment extends LoaderFragment mFab = (FloatingActionsMenu) view.findViewById(R.id.fab_main); - mFabQrCode = (FloatingActionButton) view.findViewById(R.id.fab_add_qr_code); - mFabCloud = (FloatingActionButton) view.findViewById(R.id.fab_add_cloud); - mFabFile = (FloatingActionButton) view.findViewById(R.id.fab_add_file); + FloatingActionButton fabQrCode = (FloatingActionButton) view.findViewById(R.id.fab_add_qr_code); + FloatingActionButton fabCloud = (FloatingActionButton) view.findViewById(R.id.fab_add_cloud); + FloatingActionButton fabFile = (FloatingActionButton) view.findViewById(R.id.fab_add_file); - mFabQrCode.setOnClickListener(new OnClickListener() { + fabQrCode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mFab.collapse(); scanQrCode(); } }); - mFabCloud.setOnClickListener(new OnClickListener() { + fabCloud.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mFab.collapse(); searchCloud(); } }); - mFabFile.setOnClickListener(new OnClickListener() { + fabFile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mFab.collapse(); @@ -221,7 +209,7 @@ public class KeyListFragment extends LoaderFragment } case R.id.menu_key_list_multi_export: { ids = mAdapter.getCurrentSelectedMasterKeyIds(); - ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity()); + ExportHelper mExportHelper = new ExportHelper(getActivity()); mExportHelper.showExportKeysDialog(ids, Constants.Path.APP_DIR_FILE, mAdapter.isAnySecretSelected()); break; @@ -247,7 +235,7 @@ public class KeyListFragment extends LoaderFragment public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { if (checked) { - mAdapter.setNewSelection(position, checked); + mAdapter.setNewSelection(position, true); } else { mAdapter.removeSelection(position); } @@ -316,14 +304,6 @@ public class KeyListFragment extends LoaderFragment whereArgs[i] = "%" + words[i] + "%"; } } - if (!mShowAllKeys) { - if (where == null) { - where = ""; - } else { - where += " AND "; - } - where += KeyRings.VERIFIED + " != 0"; - } // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. @@ -387,7 +367,6 @@ public class KeyListFragment extends LoaderFragment /** * Show dialog to delete key * - * @param masterKeyIds * @param hasSecret must contain whether the list of masterKeyIds contains a secret key or not */ public void showDeleteKeyDialog(final ActionMode mode, long[] masterKeyIds, boolean hasSecret) { @@ -439,10 +418,10 @@ public class KeyListFragment extends LoaderFragment // Get the searchview MenuItem searchItem = menu.findItem(R.id.menu_key_list_search); - mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem); + SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); // Execute this when searching - mSearchView.setOnQueryTextListener(this); + searchView.setOnQueryTextListener(this); // Erase search result without focus MenuItemCompat.setOnActionExpandListener(searchItem, new MenuItemCompat.OnActionExpandListener() { @@ -540,7 +519,6 @@ public class KeyListFragment extends LoaderFragment return true; } - private void searchCloud() { Intent importIntent = new Intent(getActivity(), ImportKeysActivity.class); importIntent.putExtra(ImportKeysActivity.EXTRA_QUERY, (String) null); // hack to show only cloud tab -- cgit v1.2.3 From e4d91de8d299e01b11faf8e72278025c428eac8e Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 01:37:57 +0100 Subject: small Notify cleanup --- .../keychain/ui/util/Notify.java | 26 ++-------------------- 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java index 1c6f3bd3e..1c35ec9cc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java @@ -25,7 +25,7 @@ import com.nispok.snackbar.Snackbar.SnackbarDuration; import com.nispok.snackbar.SnackbarManager; import com.nispok.snackbar.enums.SnackbarType; import com.nispok.snackbar.listeners.ActionClickListener; -import com.nispok.snackbar.listeners.EventListener; +import com.nispok.snackbar.listeners.EventListenerAdapter; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.FabContainer; @@ -42,7 +42,6 @@ public class Notify { /** * Shows a simple in-layout notification with the CharSequence given as parameter - * @param activity * @param text Text to show * @param style Notification styling */ @@ -54,36 +53,16 @@ public class Notify { .duration(SnackbarDuration.LENGTH_LONG); if (activity instanceof FabContainer) { - bar.eventListener(new EventListener() { + bar.eventListener(new EventListenerAdapter() { @Override public void onShow(Snackbar snackbar) { ((FabContainer) activity).fabMoveUp(snackbar.getHeight()); } - @Override - public void onShowByReplace(Snackbar snackbar) { - - } - - @Override - public void onShown(Snackbar snackbar) { - - } - @Override public void onDismiss(Snackbar snackbar) { ((FabContainer) activity).fabRestorePosition(); } - - @Override - public void onDismissByReplace(Snackbar snackbar) { - - } - - @Override - public void onDismissed(Snackbar snackbar) { - - } }); } @@ -178,7 +157,6 @@ public class Notify { /** * Shows a simple in-layout notification with the resource text from given id - * @param activity * @param resId ResourceId of notification text * @param style Notification styling * @throws Resources.NotFoundException -- cgit v1.2.3 From f3710b12f6a9c40b43f973c02790136fb17065ac Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 02:30:59 +0100 Subject: fab support for all notify types --- .../keychain/ui/util/Notify.java | 52 ++++++++++++---------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java index 1c35ec9cc..8686b605f 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java @@ -47,24 +47,8 @@ public class Notify { */ public static void showNotify(final Activity activity, CharSequence text, Style style) { - Snackbar bar = Snackbar.with(activity) - .text(text) - .type(SnackbarType.MULTI_LINE) - .duration(SnackbarDuration.LENGTH_LONG); - - if (activity instanceof FabContainer) { - bar.eventListener(new EventListenerAdapter() { - @Override - public void onShow(Snackbar snackbar) { - ((FabContainer) activity).fabMoveUp(snackbar.getHeight()); - } - - @Override - public void onDismiss(Snackbar snackbar) { - ((FabContainer) activity).fabRestorePosition(); - } - }); - } + Snackbar bar = getSnackbar(activity) + .text(text); switch (style) { case OK: @@ -82,9 +66,9 @@ public class Notify { } public static Showable createNotify (Activity activity, int resId, int duration, Style style) { - final Snackbar bar = Snackbar.with(activity) - .text(resId) - .type(SnackbarType.MULTI_LINE); + final Snackbar bar = getSnackbar(activity) + .text(resId); + if (duration == LENGTH_INDEFINITE) { bar.duration(SnackbarDuration.LENGTH_INDEFINITE); } else { @@ -118,16 +102,17 @@ public class Notify { public static Showable createNotify(Activity activity, String msg, int duration, Style style, final ActionListener listener, int resIdAction) { - final Snackbar bar = Snackbar.with(activity) + + final Snackbar bar = getSnackbar(activity) .text(msg) .actionLabel(resIdAction) - .type(SnackbarType.MULTI_LINE) .actionListener(new ActionClickListener() { @Override public void onActionClicked(Snackbar snackbar) { listener.onAction(); } }); + if (duration == LENGTH_INDEFINITE) { bar.duration(SnackbarDuration.LENGTH_INDEFINITE); } else { @@ -165,6 +150,27 @@ public class Notify { showNotify(activity, activity.getResources().getText(resId), style); } + private static Snackbar getSnackbar(final Activity activity) { + Snackbar bar = Snackbar.with(activity) + .type(SnackbarType.MULTI_LINE) + .duration(SnackbarDuration.LENGTH_LONG); + + if (activity instanceof FabContainer) { + bar.eventListener(new EventListenerAdapter() { + @Override + public void onShow(Snackbar snackbar) { + ((FabContainer) activity).fabMoveUp(snackbar.getHeight()); + } + + @Override + public void onDismiss(Snackbar snackbar) { + ((FabContainer) activity).fabRestorePosition(); + } + }); + } + return bar; + } + public interface Showable { public void show(); -- cgit v1.2.3 From 2ae4d6ce05e6ca1585239b779b1dd6f39f58050a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Feb 2015 04:28:21 +0100 Subject: pass through messenger to certify service from ViewKeyActivity the idea here is to handle progress and result of the CertifyActivity directly in ViewKeyActivity by passing a messenger through to it. this allows smoother transition from an uncertified to certified state. --- .../keychain/ui/CertifyFingerprintActivity.java | 12 --- .../keychain/ui/CertifyFingerprintFragment.java | 16 +++- .../keychain/ui/CertifyKeyFragment.java | 86 +++++++++++++--------- .../keychain/ui/ViewKeyActivity.java | 22 +++++- 4 files changed, 87 insertions(+), 49 deletions(-) (limited to 'OpenKeychain/src/main/java/org') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java index c75f6d838..b7c80c1ed 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintActivity.java @@ -17,14 +17,12 @@ package org.sufficientlysecure.keychain.ui; -import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.util.Log; public class CertifyFingerprintActivity extends BaseActivity { @@ -79,14 +77,4 @@ public class CertifyFingerprintActivity extends BaseActivity { getSupportFragmentManager().executePendingTransactions(); } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - // if a result has been returned, display a notify - if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) { - setResult(RESULT_OK, data); - finish(); - } else { - super.onActivityResult(requestCode, resultCode, data); - } - } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java index aef705ee9..a6b8a0e85 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyFingerprintFragment.java @@ -41,6 +41,8 @@ import org.sufficientlysecure.keychain.util.Log; public class CertifyFingerprintFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks { + static final int REQUEST_CERTIFY = 1; + public static final String ARG_DATA_URI = "uri"; private TextView mFingerprint; @@ -177,8 +179,20 @@ public class CertifyFingerprintFragment extends LoaderFragment implements Log.e(Constants.TAG, "key not found!", e); } Intent certifyIntent = new Intent(getActivity(), CertifyKeyActivity.class); + certifyIntent.putExtras(getActivity().getIntent()); certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId}); - startActivityForResult(certifyIntent, 0); + startActivityForResult(certifyIntent, REQUEST_CERTIFY); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + // always just pass this one through + if (requestCode == REQUEST_CERTIFY) { + getActivity().setResult(resultCode, data); + getActivity().finish(); + return; + } + super.onActivityResult(requestCode, resultCode, data); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java index 50d5e3229..e1467ec61 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java @@ -31,6 +31,7 @@ import android.os.Bundle; import android.os.Message; import android.os.Messenger; import android.os.Parcel; +import android.os.Parcelable; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; @@ -94,6 +95,7 @@ public class CertifyKeyFragment extends LoaderFragment private static final int INDEX_IS_REVOKED = 4; private MultiUserIdsAdapter mUserIdsAdapter; + private Messenger mPassthroughMessenger; @Override public void onActivityCreated(Bundle savedInstanceState) { @@ -109,6 +111,9 @@ public class CertifyKeyFragment extends LoaderFragment return; } + mPassthroughMessenger = getActivity().getIntent().getParcelableExtra( + KeychainIntentService.EXTRA_MESSENGER); + // preselect certify key id if given long certifyKeyId = getActivity().getIntent().getLongExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none); if (certifyKeyId != Constants.key.none) { @@ -332,7 +337,6 @@ public class CertifyKeyFragment extends LoaderFragment } } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { @@ -362,51 +366,63 @@ public class CertifyKeyFragment extends LoaderFragment return; } + Bundle data = new Bundle(); + { + // fill values for this action + CertifyActionsParcel parcel = new CertifyActionsParcel(mSignMasterKeyId); + parcel.mCertifyActions.addAll(certifyActions); + + data.putParcelable(KeychainIntentService.CERTIFY_PARCEL, parcel); + if (mUploadKeyCheckbox.isChecked()) { + String keyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver(); + data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, keyserver); + } + } + // Send all information needed to service to sign key in other thread Intent intent = new Intent(getActivity(), KeychainIntentService.class); - intent.setAction(KeychainIntentService.ACTION_CERTIFY_KEYRING); - - // fill values for this action - CertifyActionsParcel parcel = new CertifyActionsParcel(mSignMasterKeyId); - parcel.mCertifyActions.addAll(certifyActions); - - Bundle data = new Bundle(); - data.putParcelable(KeychainIntentService.CERTIFY_PARCEL, parcel); - if (mUploadKeyCheckbox.isChecked()) { - String keyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver(); - data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, keyserver); - } intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after signing is done in KeychainIntentService - KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(), - getString(R.string.progress_certifying), ProgressDialog.STYLE_SPINNER, true) { - public void handleMessage(Message message) { - // handle messages by standard KeychainIntentServiceHandler first - super.handleMessage(message); - - if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { - Bundle data = message.getData(); - CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT); - - Intent intent = new Intent(); - intent.putExtra(CertifyResult.EXTRA_RESULT, result); - getActivity().setResult(Activity.RESULT_OK, intent); - getActivity().finish(); + if (mPassthroughMessenger != null) { + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, mPassthroughMessenger); + } else { + + // Message is received after signing is done in KeychainIntentService + KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(), + getString(R.string.progress_certifying), ProgressDialog.STYLE_SPINNER, true) { + public void handleMessage(Message message) { + // handle messages by standard KeychainIntentServiceHandler first + super.handleMessage(message); + + if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + Bundle data = message.getData(); + CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT); + + Intent intent = new Intent(); + intent.putExtra(CertifyResult.EXTRA_RESULT, result); + getActivity().setResult(Activity.RESULT_OK, intent); + getActivity().finish(); + } } - } - }; + }; - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(saveHandler); - intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(saveHandler); + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); - // show progress dialog - saveHandler.showProgressDialog(getActivity()); + // show progress dialog + saveHandler.showProgressDialog(getActivity()); + } // start service with intent getActivity().startService(intent); + + if (mPassthroughMessenger != null) { + getActivity().setResult(Activity.RESULT_OK); + getActivity().finish(); + } + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index bbf35e497..f7d402c0b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -21,11 +21,11 @@ package org.sufficientlysecure.keychain.ui; import android.animation.ArgbEvaluator; import android.animation.ObjectAnimator; import android.annotation.TargetApi; +import android.app.Activity; import android.app.ActivityOptions; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; -import android.graphics.Color; import android.net.Uri; import android.nfc.NdefMessage; import android.nfc.NdefRecord; @@ -62,6 +62,7 @@ import com.getbase.floatingactionbutton.FloatingActionButton; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; +import org.sufficientlysecure.keychain.operations.results.CertifyResult; import org.sufficientlysecure.keychain.operations.results.ImportKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.KeyRing; @@ -385,6 +386,25 @@ public class ViewKeyActivity extends BaseActivity implements private void certifyFingeprint(Uri dataUri) { Intent intent = new Intent(this, CertifyFingerprintActivity.class); intent.setData(dataUri); + + // Message is received after signing is done in KeychainIntentService + KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this) { + public void handleMessage(Message message) { + // handle messages by standard KeychainIntentServiceHandler first + super.handleMessage(message); + + if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + Bundle data = message.getData(); + CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT); + + result.createNotify(ViewKeyActivity.this).show(); + } + } + }; + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(saveHandler); + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + startActivityForResult(intent, 0); } -- cgit v1.2.3