mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
api apps adapter with icons
This commit is contained in:
parent
2b303d3558
commit
4030739a99
28
OpenPGP-Keychain/res/layout/api_apps_adapter_list_item.xml
Normal file
28
OpenPGP-Keychain/res/layout/api_apps_adapter_list_item.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
|
android:gravity="left"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/api_apps_adapter_item_icon"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:src="@drawable/icon" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/api_apps_adapter_item_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toRightOf="@+id/api_apps_adapter_item_icon"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:text="Set in-code!"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -362,7 +362,6 @@
|
|||||||
|
|
||||||
<!-- Remote API -->
|
<!-- Remote API -->
|
||||||
<string name="api_no_apps">No registered applications!</string>
|
<string name="api_no_apps">No registered applications!</string>
|
||||||
<string name="api_unknown_app">Unknown app</string>
|
|
||||||
<string name="api_settings_show_advanced">Show advanced settings…</string>
|
<string name="api_settings_show_advanced">Show advanced settings…</string>
|
||||||
<string name="api_settings_hide_advanced">Hide advanced settings…</string>
|
<string name="api_settings_hide_advanced">Hide advanced settings…</string>
|
||||||
<string name="api_settings_no_key">No key selected</string>
|
<string name="api_settings_no_key">No key selected</string>
|
||||||
|
@ -145,7 +145,8 @@ public class AppSettingsActivity extends SherlockFragmentActivity {
|
|||||||
appName = (String) pm.getApplicationLabel(ai);
|
appName = (String) pm.getApplicationLabel(ai);
|
||||||
appIcon = pm.getApplicationIcon(ai);
|
appIcon = pm.getApplicationIcon(ai);
|
||||||
} catch (final NameNotFoundException e) {
|
} catch (final NameNotFoundException e) {
|
||||||
appName = getString(R.string.api_unknown_app);
|
// fallback
|
||||||
|
appName = mPackageName;
|
||||||
}
|
}
|
||||||
appNameView.setText(appName);
|
appNameView.setText(appName);
|
||||||
appIconView.setImageDrawable(appIcon);
|
appIconView.setImageDrawable(appIcon);
|
||||||
|
@ -28,6 +28,7 @@ import android.support.v4.widget.CursorAdapter;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class RegisteredAppsAdapter extends CursorAdapter {
|
public class RegisteredAppsAdapter extends CursorAdapter {
|
||||||
@ -44,28 +45,31 @@ public class RegisteredAppsAdapter extends CursorAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindView(View view, Context context, Cursor cursor) {
|
public void bindView(View view, Context context, Cursor cursor) {
|
||||||
TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name);
|
||||||
TextView text2 = (TextView) view.findViewById(android.R.id.text2);
|
ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon);
|
||||||
|
|
||||||
String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME));
|
String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME));
|
||||||
if (packageName != null) {
|
if (packageName != null) {
|
||||||
text2.setText(packageName);
|
|
||||||
|
|
||||||
// get application name
|
// get application name
|
||||||
try {
|
try {
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
||||||
|
|
||||||
text1.setText(pm.getApplicationLabel(ai));
|
text.setText(pm.getApplicationLabel(ai));
|
||||||
|
icon.setImageDrawable(pm.getApplicationIcon(ai));
|
||||||
} catch (final NameNotFoundException e) {
|
} catch (final NameNotFoundException e) {
|
||||||
text1.setText(R.string.api_unknown_app);
|
// fallback
|
||||||
|
text.setText(packageName);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// fallback
|
||||||
|
text.setText(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||||
return mInflater.inflate(android.R.layout.simple_list_item_2, null);
|
return mInflater.inflate(R.layout.api_apps_adapter_list_item, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user