Fixes and icons for apps list, also add Password Store

This commit is contained in:
Dominik Schürmann 2014-10-25 21:15:05 +02:00
parent d3e0e823e3
commit 0abfff0b0e
4 changed files with 25 additions and 12 deletions

View File

@ -120,6 +120,7 @@ public class AppsListFragment extends ListFragment implements
private static final String TEMP_COLUMN_NAME = "NAME"; private static final String TEMP_COLUMN_NAME = "NAME";
private static final String TEMP_COLUMN_INSTALLED = "INSTALLED"; private static final String TEMP_COLUMN_INSTALLED = "INSTALLED";
private static final String TEMP_COLUMN_REGISTERED = "REGISTERED"; private static final String TEMP_COLUMN_REGISTERED = "REGISTERED";
private static final String TEMP_COLUMN_ICON_RES_ID = "ICON_RES_ID";
// These are the Contacts rows that we will retrieve. // These are the Contacts rows that we will retrieve.
static final String[] PROJECTION = new String[]{ static final String[] PROJECTION = new String[]{
@ -127,7 +128,8 @@ public class AppsListFragment extends ListFragment implements
ApiApps.PACKAGE_NAME, // 1 ApiApps.PACKAGE_NAME, // 1
"null as " + TEMP_COLUMN_NAME, // installed apps can retrieve app name from Android OS "null as " + TEMP_COLUMN_NAME, // installed apps can retrieve app name from Android OS
"0 as " + TEMP_COLUMN_INSTALLED, // changed later in cursor joiner "0 as " + TEMP_COLUMN_INSTALLED, // changed later in cursor joiner
"1 as " + TEMP_COLUMN_REGISTERED // if it is in db it is registered "1 as " + TEMP_COLUMN_REGISTERED, // if it is in db it is registered
"0 as " + TEMP_COLUMN_ICON_RES_ID // not used
}; };
private static final int INDEX_ID = 0; private static final int INDEX_ID = 0;
@ -135,6 +137,7 @@ public class AppsListFragment extends ListFragment implements
private static final int INDEX_NAME = 2; private static final int INDEX_NAME = 2;
private static final int INDEX_INSTALLED = 3; private static final int INDEX_INSTALLED = 3;
private static final int INDEX_REGISTERED = 4; private static final int INDEX_REGISTERED = 4;
private static final int INDEX_ICON_RES_ID = 5;
public Loader<Cursor> onCreateLoader(int id, Bundle args) { public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// This is called when a new Loader needs to be created. This // This is called when a new Loader needs to be created. This
@ -155,18 +158,22 @@ public class AppsListFragment extends ListFragment implements
ApiApps.PACKAGE_NAME, ApiApps.PACKAGE_NAME,
TEMP_COLUMN_NAME, TEMP_COLUMN_NAME,
TEMP_COLUMN_INSTALLED, TEMP_COLUMN_INSTALLED,
TEMP_COLUMN_REGISTERED TEMP_COLUMN_REGISTERED,
TEMP_COLUMN_ICON_RES_ID
}); });
availableAppsCursor.addRow(new Object[]{1, "com.fsck.k9", "K-9 Mail", 0, 0}); // NOTE: SORT ascending by package name, this is REQUIRED for CursorJoiner!
availableAppsCursor.addRow(new Object[]{1, "eu.siacs.conversations", "Conversations (Instant Messaging)", 0, 0}); // Drawables taken from projects res/drawables-xxhdpi/ic_launcher.png
// availableAppsCursor.addRow(new Object[]{1, "org.sufficientlysecure.keychain.demo", "API Example", 0, 0}); availableAppsCursor.addRow(new Object[]{1, "com.fsck.k9", "K-9 Mail", 0, 0, R.drawable.apps_k9});
availableAppsCursor.addRow(new Object[]{1, "com.zeapo.pwdstore", "Password Store", 0, 0, R.drawable.apps_password_store});
availableAppsCursor.addRow(new Object[]{1, "eu.siacs.conversations", "Conversations (Instant Messaging)", 0, 0, R.drawable.apps_conversations});
MatrixCursor mergedCursor = new MatrixCursor(new String[]{ MatrixCursor mergedCursor = new MatrixCursor(new String[]{
ApiApps._ID, ApiApps._ID,
ApiApps.PACKAGE_NAME, ApiApps.PACKAGE_NAME,
TEMP_COLUMN_NAME, TEMP_COLUMN_NAME,
TEMP_COLUMN_INSTALLED, TEMP_COLUMN_INSTALLED,
TEMP_COLUMN_REGISTERED TEMP_COLUMN_REGISTERED,
TEMP_COLUMN_ICON_RES_ID
}); });
CursorJoiner joiner = new CursorJoiner( CursorJoiner joiner = new CursorJoiner(
@ -181,11 +188,12 @@ public class AppsListFragment extends ListFragment implements
String packageName = availableAppsCursor.getString(INDEX_PACKAGE_NAME); String packageName = availableAppsCursor.getString(INDEX_PACKAGE_NAME);
mergedCursor.addRow(new Object[]{ mergedCursor.addRow(new Object[]{
availableAppsCursor.getLong(INDEX_ID), 1, // no need for unique _ID
packageName, packageName,
availableAppsCursor.getString(INDEX_NAME), availableAppsCursor.getString(INDEX_NAME),
isInstalled(packageName), isInstalled(packageName),
0 0,
availableAppsCursor.getInt(INDEX_ICON_RES_ID)
}); });
break; break;
} }
@ -194,11 +202,12 @@ public class AppsListFragment extends ListFragment implements
String packageName = data.getString(INDEX_PACKAGE_NAME); String packageName = data.getString(INDEX_PACKAGE_NAME);
mergedCursor.addRow(new Object[]{ mergedCursor.addRow(new Object[]{
data.getLong(INDEX_ID), 1, // no need for unique _ID
packageName, packageName,
null, null,
isInstalled(packageName), isInstalled(packageName),
1 1, // registered!
0 // icon is retrieved later
}); });
break; break;
} }
@ -215,11 +224,12 @@ public class AppsListFragment extends ListFragment implements
} }
mergedCursor.addRow(new Object[]{ mergedCursor.addRow(new Object[]{
data.getLong(INDEX_ID), 1, // no need for unique _ID
packageName, packageName,
name, name,
isInstalled(packageName), isInstalled(packageName),
1 1, // registered!
0 // icon is retrieved later
}); });
break; break;
} }
@ -309,8 +319,10 @@ public class AppsListFragment extends ListFragment implements
ImageView installIcon = (ImageView) view.findViewById(R.id.api_apps_adapter_install_icon); ImageView installIcon = (ImageView) view.findViewById(R.id.api_apps_adapter_install_icon);
String packageName = cursor.getString(INDEX_PACKAGE_NAME); String packageName = cursor.getString(INDEX_PACKAGE_NAME);
Log.d(Constants.TAG, "packageName: " + packageName);
int installed = cursor.getInt(INDEX_INSTALLED); int installed = cursor.getInt(INDEX_INSTALLED);
String name = cursor.getString(INDEX_NAME); String name = cursor.getString(INDEX_NAME);
int iconResName = cursor.getInt(INDEX_ICON_RES_ID);
// get application name and icon // get application name and icon
try { try {
@ -324,6 +336,7 @@ public class AppsListFragment extends ListFragment implements
text.setText(packageName); text.setText(packageName);
} else { } else {
text.setText(name); text.setText(name);
icon.setImageDrawable(getResources().getDrawable(iconResName));
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB