Slight change to "Use different key" submenu, possibly display Autocrypt Setup Message hint
This commit is contained in:
@@ -143,12 +143,13 @@ public class ApiPendingIntentFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PendingIntent createSelectSignKeyIdPendingIntent(Intent data, String packageName,
|
PendingIntent createSelectSignKeyIdPendingIntent(Intent data, String packageName,
|
||||||
byte[] packageSignature, String preferredUserId) {
|
byte[] packageSignature, String preferredUserId, boolean showAutocryptHint) {
|
||||||
Intent intent = new Intent(mContext, RemoteSelectIdKeyActivity.class);
|
Intent intent = new Intent(mContext, RemoteSelectIdKeyActivity.class);
|
||||||
intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(packageName));
|
intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(packageName));
|
||||||
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_PACKAGE_NAME, packageName);
|
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_PACKAGE_NAME, packageName);
|
||||||
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_PACKAGE_SIGNATURE, packageSignature);
|
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_PACKAGE_SIGNATURE, packageSignature);
|
||||||
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_USER_ID, preferredUserId);
|
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_USER_ID, preferredUserId);
|
||||||
|
intent.putExtra(RemoteSelectIdKeyActivity.EXTRA_SHOW_AUTOCRYPT_HINT, showAutocryptHint);
|
||||||
|
|
||||||
return createInternal(data, intent);
|
return createInternal(data, intent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -723,8 +723,9 @@ public class OpenPgpService extends Service {
|
|||||||
pi = mApiPendingIntentFactory.createSelectSignKeyIdLegacyPendingIntent(data, currentPkg, null);
|
pi = mApiPendingIntentFactory.createSelectSignKeyIdLegacyPendingIntent(data, currentPkg, null);
|
||||||
} else {
|
} else {
|
||||||
byte[] packageSignature = mApiPermissionHelper.getPackageCertificateOrError(currentPkg);
|
byte[] packageSignature = mApiPermissionHelper.getPackageCertificateOrError(currentPkg);
|
||||||
|
boolean showAutocryptHint = data.getBooleanExtra(OpenPgpApi.EXTRA_SHOW_AUTOCRYPT_HINT, false);
|
||||||
pi = mApiPendingIntentFactory.createSelectSignKeyIdPendingIntent(
|
pi = mApiPendingIntentFactory.createSelectSignKeyIdPendingIntent(
|
||||||
data, currentPkg, packageSignature, preferredUserId);
|
data, currentPkg, packageSignature, preferredUserId, showAutocryptHint);
|
||||||
}
|
}
|
||||||
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
|
result.putExtra(OpenPgpApi.RESULT_INTENT, pi);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import org.sufficientlysecure.keychain.livedata.KeyInfoInteractor.KeyInfo;
|
|||||||
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||||
import org.sufficientlysecure.keychain.remote.ui.dialog.RemoteSelectIdentityKeyPresenter.RemoteSelectIdentityKeyView;
|
import org.sufficientlysecure.keychain.remote.ui.dialog.RemoteSelectIdentityKeyPresenter.RemoteSelectIdentityKeyView;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||||
|
import org.sufficientlysecure.keychain.ui.MainActivity;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper.AbstractCallback;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper.AbstractCallback;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder;
|
||||||
@@ -76,6 +77,7 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
public static final String EXTRA_PACKAGE_NAME = "package_name";
|
public static final String EXTRA_PACKAGE_NAME = "package_name";
|
||||||
public static final String EXTRA_PACKAGE_SIGNATURE = "package_signature";
|
public static final String EXTRA_PACKAGE_SIGNATURE = "package_signature";
|
||||||
public static final String EXTRA_USER_ID = "user_id";
|
public static final String EXTRA_USER_ID = "user_id";
|
||||||
|
public static final String EXTRA_SHOW_AUTOCRYPT_HINT = "show_autocrypt_hint";
|
||||||
public static final String EXTRA_CURRENT_MASTER_KEY_ID = "current_master_key_id";
|
public static final String EXTRA_CURRENT_MASTER_KEY_ID = "current_master_key_id";
|
||||||
|
|
||||||
|
|
||||||
@@ -108,8 +110,9 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
String userId = intent.getStringExtra(EXTRA_USER_ID);
|
String userId = intent.getStringExtra(EXTRA_USER_ID);
|
||||||
String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
|
String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
|
||||||
byte[] packageSignature = intent.getByteArrayExtra(EXTRA_PACKAGE_SIGNATURE);
|
byte[] packageSignature = intent.getByteArrayExtra(EXTRA_PACKAGE_SIGNATURE);
|
||||||
|
boolean showAutocryptHint = intent.getBooleanExtra(EXTRA_SHOW_AUTOCRYPT_HINT, false);
|
||||||
|
|
||||||
presenter.setupFromIntentData(packageName, packageSignature, userId);
|
presenter.setupFromIntentData(packageName, packageSignature, userId, showAutocryptHint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RemoteSelectIdentityKeyDialogFragment extends DialogFragment {
|
public static class RemoteSelectIdentityKeyDialogFragment extends DialogFragment {
|
||||||
@@ -127,6 +130,7 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
private View buttonNoKeysExisting;
|
private View buttonNoKeysExisting;
|
||||||
private View buttonKeyListOther;
|
private View buttonKeyListOther;
|
||||||
private View buttonOverflow;
|
private View buttonOverflow;
|
||||||
|
private View buttonGotoOpenKeychain;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
@@ -156,6 +160,8 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
buttonGenOkBack = view.findViewById(R.id.button_genok_back);
|
buttonGenOkBack = view.findViewById(R.id.button_genok_back);
|
||||||
buttonGenOkFinish = view.findViewById(R.id.button_genok_finish);
|
buttonGenOkFinish = view.findViewById(R.id.button_genok_finish);
|
||||||
|
|
||||||
|
buttonGotoOpenKeychain = view.findViewById(R.id.button_goto_openkeychain);
|
||||||
|
|
||||||
keyChoiceList = view.findViewById(R.id.identity_key_list);
|
keyChoiceList = view.findViewById(R.id.identity_key_list);
|
||||||
keyChoiceList.setLayoutManager(new LinearLayoutManager(activity));
|
keyChoiceList.setLayoutManager(new LinearLayoutManager(activity));
|
||||||
keyChoiceList.addItemDecoration(
|
keyChoiceList.addItemDecoration(
|
||||||
@@ -200,6 +206,7 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
final KeyChoiceAdapter keyChoiceAdapter = new KeyChoiceAdapter(layoutInflater, getResources());
|
final KeyChoiceAdapter keyChoiceAdapter = new KeyChoiceAdapter(layoutInflater, getResources());
|
||||||
final TextView titleText = rootView.findViewById(R.id.text_title_select_key);
|
final TextView titleText = rootView.findViewById(R.id.text_title_select_key);
|
||||||
final TextView addressText = rootView.findViewById(R.id.text_user_id);
|
final TextView addressText = rootView.findViewById(R.id.text_user_id);
|
||||||
|
final TextView autocryptHint = rootView.findViewById(R.id.key_import_autocrypt_hint);
|
||||||
final ToolableViewAnimator layoutAnimator = rootView.findViewById(R.id.layout_animator);
|
final ToolableViewAnimator layoutAnimator = rootView.findViewById(R.id.layout_animator);
|
||||||
keyChoiceList.setAdapter(keyChoiceAdapter);
|
keyChoiceList.setAdapter(keyChoiceAdapter);
|
||||||
|
|
||||||
@@ -231,10 +238,16 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void setTitleClientIconAndName(Drawable drawable, CharSequence name) {
|
public void setTitleClientIconAndName(Drawable drawable, CharSequence name) {
|
||||||
titleText.setText(getString(R.string.title_select_key, name));
|
titleText.setText(getString(R.string.title_select_key, name));
|
||||||
|
autocryptHint.setText(getString(R.string.key_import_text_autocrypt_setup_msg, name));
|
||||||
// iconClientApp.setImageDrawable(drawable);
|
// iconClientApp.setImageDrawable(drawable);
|
||||||
setSelectionIcons(drawable);
|
setSelectionIcons(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setShowAutocryptHint(boolean showAutocryptHint) {
|
||||||
|
autocryptHint.setVisibility(showAutocryptHint ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
private void setSelectionIcons(Drawable drawable) {
|
private void setSelectionIcons(Drawable drawable) {
|
||||||
ConstantState constantState = drawable.getConstantState();
|
ConstantState constantState = drawable.getConstantState();
|
||||||
if (constantState == null) {
|
if (constantState == null) {
|
||||||
@@ -268,7 +281,7 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void showLayoutSelectKeyList() {
|
public void showLayoutSelectKeyList() {
|
||||||
layoutAnimator.setDisplayedChildId(R.id.select_key_layout_key_list);
|
layoutAnimator.setDisplayedChildId(R.id.select_key_layout_key_list);
|
||||||
buttonOverflow.setVisibility(View.GONE);
|
buttonOverflow.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -343,6 +356,17 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
});
|
});
|
||||||
menu.show();
|
menu.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showOpenKeychainIntent() {
|
||||||
|
Activity activity = getActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent intent = new Intent(activity.getApplicationContext(), MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,6 +386,8 @@ public class RemoteSelectIdKeyActivity extends FragmentActivity {
|
|||||||
buttonGenOkBack.setOnClickListener(view -> presenter.onClickGenerateOkBack());
|
buttonGenOkBack.setOnClickListener(view -> presenter.onClickGenerateOkBack());
|
||||||
buttonGenOkFinish.setOnClickListener(view -> presenter.onClickGenerateOkFinish());
|
buttonGenOkFinish.setOnClickListener(view -> presenter.onClickGenerateOkFinish());
|
||||||
|
|
||||||
|
buttonGotoOpenKeychain.setOnClickListener(view -> presenter.onClickGoToOpenKeychain());
|
||||||
|
|
||||||
keyChoiceList.addOnItemTouchListener(new RecyclerItemClickListener(getContext(),
|
keyChoiceList.addOnItemTouchListener(new RecyclerItemClickListener(getContext(),
|
||||||
(view, position) -> presenter.onKeyItemClick(position)));
|
(view, position) -> presenter.onKeyItemClick(position)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class RemoteSelectIdentityKeyPresenter {
|
|||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupFromIntentData(String packageName, byte[] packageSignature, String rawUserId) {
|
void setupFromIntentData(String packageName, byte[] packageSignature, String rawUserId, boolean clientHasAutocryptSetupMsg) {
|
||||||
try {
|
try {
|
||||||
setPackageInfo(packageName, packageSignature);
|
setPackageInfo(packageName, packageSignature);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
@@ -87,6 +87,7 @@ class RemoteSelectIdentityKeyPresenter {
|
|||||||
|
|
||||||
this.userId = OpenPgpUtils.splitUserId(rawUserId);
|
this.userId = OpenPgpUtils.splitUserId(rawUserId);
|
||||||
view.setAddressText(userId.email);
|
view.setAddressText(userId.email);
|
||||||
|
view.setShowAutocryptHint(clientHasAutocryptSetupMsg);
|
||||||
|
|
||||||
loadKeyInfo();
|
loadKeyInfo();
|
||||||
}
|
}
|
||||||
@@ -220,17 +221,22 @@ class RemoteSelectIdentityKeyPresenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onClickMenuListAllKeys() {
|
public void onClickMenuListAllKeys() {
|
||||||
viewModel.setListAllKeys(true);
|
viewModel.setListAllKeys(!viewModel.isListAllKeys());
|
||||||
loadKeyInfo();
|
loadKeyInfo();
|
||||||
view.showLayoutSelectKeyList();
|
view.showLayoutSelectKeyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClickGoToOpenKeychain() {
|
||||||
|
view.showOpenKeychainIntent();
|
||||||
|
}
|
||||||
|
|
||||||
interface RemoteSelectIdentityKeyView {
|
interface RemoteSelectIdentityKeyView {
|
||||||
void finishAndReturn(long masterKeyId);
|
void finishAndReturn(long masterKeyId);
|
||||||
void finishAsCancelled();
|
void finishAsCancelled();
|
||||||
|
|
||||||
void setAddressText(String text);
|
void setAddressText(String text);
|
||||||
void setTitleClientIconAndName(Drawable drawable, CharSequence name);
|
void setTitleClientIconAndName(Drawable drawable, CharSequence name);
|
||||||
|
void setShowAutocryptHint(boolean showAutocryptHint);
|
||||||
|
|
||||||
void showLayoutEmpty();
|
void showLayoutEmpty();
|
||||||
void showLayoutSelectNoKeys();
|
void showLayoutSelectNoKeys();
|
||||||
@@ -249,5 +255,7 @@ class RemoteSelectIdentityKeyPresenter {
|
|||||||
void showImportInternalError();
|
void showImportInternalError();
|
||||||
|
|
||||||
void displayOverflowMenu();
|
void displayOverflowMenu();
|
||||||
|
|
||||||
|
void showOpenKeychainIntent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,6 +297,47 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:id="@+id/button_goto_openkeychain"
|
||||||
|
android:background="?selectableItemBackground"
|
||||||
|
android:paddingLeft="12dp"
|
||||||
|
android:paddingRight="12dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_marginRight="12dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:src="@mipmap/ic_launcher"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="0dp"
|
||||||
|
android:paddingRight="0dp"
|
||||||
|
android:text="@string/button_goto_openkeychain"
|
||||||
|
android:clickable="false"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
style="?buttonBarButtonStyle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:id="@+id/key_import_autocrypt_hint"
|
||||||
|
android:text="@string/key_import_text_autocrypt_setup_msg"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="?buttonBarStyle"
|
style="?buttonBarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -2006,5 +2006,7 @@
|
|||||||
<string name="key_gen_finish">Finish</string>
|
<string name="key_gen_finish">Finish</string>
|
||||||
<string name="key_gen_done">Generated end-to-end key!</string>
|
<string name="key_gen_done">Generated end-to-end key!</string>
|
||||||
<string name="key_gen_finishing">Finishing setup…</string>
|
<string name="key_gen_finishing">Finishing setup…</string>
|
||||||
<string name="key_import_text">To import your key, you can either:\n\n① Open Autocrypt Setup Message from another e-mail app in K-9 Mail\n\n② Manually import in OpenKeychain</string>
|
<string name="key_import_text">To use an end-to-end key, it has to be imported into OpenKeychain.</string>
|
||||||
|
<string name="key_import_text_autocrypt_setup_msg">To import your existing setup from another device, you can also open an Autocrypt Setup Message in %s.</string>
|
||||||
|
<string name="button_goto_openkeychain">Go to OpenKeychain</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user