mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-11 05:28:26 -05:00
Fix intent for api, fix slection dialog in demo
This commit is contained in:
parent
ca8f8e3ff7
commit
a4ae976284
@ -11,10 +11,10 @@
|
||||
<!-- android:key="aidl_demo2" -->
|
||||
<!-- android:title="AIDL Demo (ACCESS_KEYS permission)" /> -->
|
||||
<!-- </PreferenceCategory> -->
|
||||
<PreferenceCategory android:title="Crypto Provider" >
|
||||
<PreferenceCategory android:title="OpenPGP Provider" >
|
||||
<Preference
|
||||
android:key="crypto_provider_demo"
|
||||
android:title="Crypto Provider" />
|
||||
android:key="openpgp_provider_demo"
|
||||
android:title="OpenPGP Provider" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
@ -50,7 +50,7 @@ public class BaseActivity extends PreferenceActivity {
|
||||
// find preferences
|
||||
mIntentDemo = (Preference) findPreference("intent_demo");
|
||||
mContentProviderDemo = (Preference) findPreference("content_provider_demo");
|
||||
mCryptoProvider = (Preference) findPreference("crypto_provider_demo");
|
||||
mCryptoProvider = (Preference) findPreference("openpgp_provider_demo");
|
||||
mAidlDemo = (Preference) findPreference("aidl_demo");
|
||||
mAidlDemo2 = (Preference) findPreference("aidl_demo2");
|
||||
|
||||
|
@ -186,12 +186,12 @@ public class OpenPgpProviderActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
private static class OpenPGPProviderElement {
|
||||
private static class OpenPgpProviderElement {
|
||||
private String packageName;
|
||||
private String simpleName;
|
||||
private Drawable icon;
|
||||
|
||||
public OpenPGPProviderElement(String packageName, String simpleName, Drawable icon) {
|
||||
public OpenPgpProviderElement(String packageName, String simpleName, Drawable icon) {
|
||||
this.packageName = packageName;
|
||||
this.simpleName = simpleName;
|
||||
this.icon = icon;
|
||||
@ -206,7 +206,7 @@ public class OpenPgpProviderActivity extends Activity {
|
||||
private void selectCryptoProvider() {
|
||||
Intent intent = new Intent(IOpenPgpService.class.getName());
|
||||
|
||||
final ArrayList<OpenPGPProviderElement> providerList = new ArrayList<OpenPGPProviderElement>();
|
||||
final ArrayList<OpenPgpProviderElement> providerList = new ArrayList<OpenPgpProviderElement>();
|
||||
|
||||
List<ResolveInfo> resInfo = getPackageManager().queryIntentServices(intent, 0);
|
||||
if (!resInfo.isEmpty()) {
|
||||
@ -218,62 +218,70 @@ public class OpenPgpProviderActivity extends Activity {
|
||||
String simpleName = String.valueOf(resolveInfo.serviceInfo
|
||||
.loadLabel(getPackageManager()));
|
||||
Drawable icon = resolveInfo.serviceInfo.loadIcon(getPackageManager());
|
||||
providerList.add(new OpenPGPProviderElement(packageName, simpleName, icon));
|
||||
providerList.add(new OpenPgpProviderElement(packageName, simpleName, icon));
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle("Select OpenPGP Provider!");
|
||||
alert.setCancelable(false);
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
alert.setTitle("Select OpenPGP Provider!");
|
||||
alert.setCancelable(false);
|
||||
|
||||
if (!providerList.isEmpty()) {
|
||||
if (!providerList.isEmpty()) {
|
||||
// add "disable OpenPGP provider"
|
||||
providerList.add(0, new OpenPgpProviderElement(null, "Disable OpenPGP Provider", getResources()
|
||||
.getDrawable(android.R.drawable.ic_menu_close_clear_cancel)));
|
||||
|
||||
// Init ArrayAdapter with Crypto Providers
|
||||
ListAdapter adapter = new ArrayAdapter<OpenPGPProviderElement>(this,
|
||||
android.R.layout.select_dialog_item, android.R.id.text1, providerList) {
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = super.getView(position, convertView, parent);
|
||||
TextView tv = (TextView) v.findViewById(android.R.id.text1);
|
||||
// Init ArrayAdapter with OpenPGP Providers
|
||||
ListAdapter adapter = new ArrayAdapter<OpenPgpProviderElement>(this,
|
||||
android.R.layout.select_dialog_item, android.R.id.text1, providerList) {
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = super.getView(position, convertView, parent);
|
||||
TextView tv = (TextView) v.findViewById(android.R.id.text1);
|
||||
|
||||
// Put the image on the TextView
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(providerList.get(position).icon,
|
||||
null, null, null);
|
||||
// Put the image on the TextView
|
||||
tv.setCompoundDrawablesWithIntrinsicBounds(providerList.get(position).icon,
|
||||
null, null, null);
|
||||
|
||||
// Add margin between image and text (support various screen densities)
|
||||
int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
|
||||
tv.setCompoundDrawablePadding(dp5);
|
||||
// Add margin between image and text (support various screen densities)
|
||||
int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f);
|
||||
tv.setCompoundDrawablePadding(dp5);
|
||||
|
||||
return v;
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
alert.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
String packageName = providerList.get(position).packageName;
|
||||
|
||||
if (packageName == null) {
|
||||
dialog.cancel();
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
// bind to service
|
||||
mCryptoServiceConnection = new OpenPgpServiceConnection(
|
||||
OpenPgpProviderActivity.this, packageName);
|
||||
mCryptoServiceConnection.bindToService();
|
||||
|
||||
alert.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int position) {
|
||||
String packageName = providerList.get(position).packageName;
|
||||
|
||||
// bind to service
|
||||
mCryptoServiceConnection = new OpenPgpServiceConnection(
|
||||
OpenPgpProviderActivity.this, packageName);
|
||||
mCryptoServiceConnection.bindToService();
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert.setMessage("No OpenPGP Provider installed!");
|
||||
}
|
||||
|
||||
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
finish();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog ad = alert.create();
|
||||
ad.show();
|
||||
} else {
|
||||
alert.setMessage("No OpenPGP Provider installed!");
|
||||
}
|
||||
|
||||
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog ad = alert.create();
|
||||
ad.show();
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,7 @@
|
||||
<!-- android:permission="org.sufficientlysecure.keychain.permission.ACCESS_API" /> -->
|
||||
|
||||
|
||||
<!-- OpenPGP Remote Service API internal -->
|
||||
<!-- OpenPGP API internal classes (not exported) -->
|
||||
|
||||
<activity
|
||||
android:name="org.sufficientlysecure.keychain.openpgp_api.OpenPgpServiceActivity"
|
||||
@ -399,7 +399,7 @@
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:exported="false" />
|
||||
|
||||
<!-- OpenPGP Remote Service API -->
|
||||
<!-- OpenPGP API -->
|
||||
|
||||
<service
|
||||
android:name="org.sufficientlysecure.keychain.openpgp_api.OpenPgpService"
|
||||
@ -407,7 +407,7 @@
|
||||
android:exported="true"
|
||||
android:process=":openpgp_api" >
|
||||
<intent-filter>
|
||||
<action android:name="org.openintents.crypto.ICryptoService" />
|
||||
<action android:name="org.openintents.openpgp.IOpenPgpService" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
|
Loading…
Reference in New Issue
Block a user