mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-15 13:25:06 -05:00
Merge branch 'development' of github.com:open-keychain/open-keychain into development
This commit is contained in:
commit
5b1d834f91
@ -78,6 +78,10 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showProgressDialog(FragmentActivity activity) {
|
public void showProgressDialog(FragmentActivity activity) {
|
||||||
|
if (mProgressDialogFragment == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: This is a hack!, see
|
// TODO: This is a hack!, see
|
||||||
// http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult
|
// http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult
|
||||||
final FragmentManager manager = activity.getSupportFragmentManager();
|
final FragmentManager manager = activity.getSupportFragmentManager();
|
||||||
@ -94,7 +98,8 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
Bundle data = message.getData();
|
Bundle data = message.getData();
|
||||||
|
|
||||||
if (mProgressDialogFragment == null) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.os.Messenger;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
@ -44,6 +45,9 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AlphaAnimation;
|
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.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
@ -54,11 +58,14 @@ import com.getbase.floatingactionbutton.FloatingActionButton;
|
|||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
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.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
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.ContactHelper;
|
||||||
import org.sufficientlysecure.keychain.util.ExportHelper;
|
import org.sufficientlysecure.keychain.util.ExportHelper;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.Preferences;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -105,6 +114,10 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
private boolean mIsSecret = false;
|
private boolean mIsSecret = false;
|
||||||
private boolean mHasEncrypt = false;
|
private boolean mHasEncrypt = false;
|
||||||
private boolean mIsVerified = false;
|
private boolean mIsVerified = false;
|
||||||
|
private MenuItem mRefreshItem;
|
||||||
|
private boolean mIsRefreshing;
|
||||||
|
private Animation mRotate, mRotateSpin;
|
||||||
|
private View mRefresh;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -128,6 +141,51 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
mQrCode = (ImageView) findViewById(R.id.view_key_qr_code);
|
mQrCode = (ImageView) findViewById(R.id.view_key_qr_code);
|
||||||
mQrCodeLayout = (CardView) findViewById(R.id.view_key_qr_code_layout);
|
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();
|
mDataUri = getIntent().getData();
|
||||||
if (mDataUri == null) {
|
if (mDataUri == null) {
|
||||||
Log.e(Constants.TAG, "Data missing. Should be uri of key!");
|
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) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
super.onCreateOptionsMenu(menu);
|
super.onCreateOptionsMenu(menu);
|
||||||
getMenuInflater().inflate(R.menu.key_view, menu);
|
getMenuInflater().inflate(R.menu.key_view, menu);
|
||||||
|
mRefreshItem = menu.findItem(R.id.menu_key_view_refresh);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,16 +472,72 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
|
|
||||||
private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper)
|
private void updateFromKeyserver(Uri dataUri, ProviderHelper providerHelper)
|
||||||
throws ProviderHelper.NotFoundException {
|
throws ProviderHelper.NotFoundException {
|
||||||
|
|
||||||
|
mIsRefreshing = true;
|
||||||
|
mRefreshItem.setEnabled(false);
|
||||||
|
mRefreshItem.setActionView(mRefresh);
|
||||||
|
mRefresh.startAnimation(mRotate);
|
||||||
|
|
||||||
byte[] blob = (byte[]) providerHelper.getGenericData(
|
byte[] blob = (byte[]) providerHelper.getGenericData(
|
||||||
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
|
KeychainContract.KeyRings.buildUnifiedKeyRingUri(dataUri),
|
||||||
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
|
KeychainContract.Keys.FINGERPRINT, ProviderHelper.FIELD_TYPE_BLOB);
|
||||||
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
|
String fingerprint = KeyFormattingUtils.convertFingerprintToHex(blob);
|
||||||
|
|
||||||
Intent queryIntent = new Intent(this, ImportKeysActivity.class);
|
ParcelableKeyRing keyEntry = new ParcelableKeyRing(fingerprint, null, null);
|
||||||
queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT);
|
ArrayList<ParcelableKeyRing> entries = new ArrayList<>();
|
||||||
queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint);
|
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) {
|
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());
|
&& new Date(data.getLong(INDEX_EXPIRY) * 1000).before(new Date());
|
||||||
mIsVerified = data.getInt(INDEX_VERIFIED) > 0;
|
mIsVerified = data.getInt(INDEX_VERIFIED) > 0;
|
||||||
|
|
||||||
// re-create options menu based on mIsSecret, mIsVerified
|
// if the refresh animation isn't playing
|
||||||
supportInvalidateOptionsMenu();
|
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<String, Void, Bitmap> photoTask =
|
AsyncTask<String, Void, Bitmap> photoTask =
|
||||||
new AsyncTask<String, Void, Bitmap>() {
|
new AsyncTask<String, Void, Bitmap>() {
|
||||||
|
8
OpenKeychain/src/main/res/anim/rotate.xml
Normal file
8
OpenKeychain/src/main/res/anim/rotate.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromDegrees="0"
|
||||||
|
android:toDegrees="360"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:duration="800"
|
||||||
|
android:interpolator="@android:anim/linear_interpolator" />
|
8
OpenKeychain/src/main/res/anim/rotate_spin.xml
Normal file
8
OpenKeychain/src/main/res/anim/rotate_spin.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:fromDegrees="0"
|
||||||
|
android:toDegrees="360"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:duration="400"
|
||||||
|
android:interpolator="@android:anim/accelerate_decelerate_interpolator" />
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:padding="0dp"
|
||||||
|
android:src="@drawable/ic_refresh_white_24dp"
|
||||||
|
style="@style/Widget.AppCompat.ActionButton" />
|
Loading…
Reference in New Issue
Block a user