diff options
author | Danesh M <daneshm90@gmail.com> | 2015-09-05 21:08:10 -0700 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2016-01-03 14:47:33 -0800 |
commit | e46f635ef5ac3e917a6775db96e3576d9333f965 (patch) | |
tree | 5f8576b2716045839983ca33b734607aad049c52 /src/com/android/settings/cyanogenmod | |
parent | 891fec297841445431a73d76aa0f69e7feda0cea (diff) | |
download | packages_apps_Settings-e46f635ef5ac3e917a6775db96e3576d9333f965.zip packages_apps_Settings-e46f635ef5ac3e917a6775db96e3576d9333f965.tar.gz packages_apps_Settings-e46f635ef5ac3e917a6775db96e3576d9333f965.tar.bz2 |
Settings : Update filterSpam to new contract
Needed for http://review.cyanogenmod.org/#/c/108424/
Change-Id: I5ad5f376d37e5bf0b213f9266581b5c503971174
Diffstat (limited to 'src/com/android/settings/cyanogenmod')
-rw-r--r-- | src/com/android/settings/cyanogenmod/SpamList.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/com/android/settings/cyanogenmod/SpamList.java b/src/com/android/settings/cyanogenmod/SpamList.java index 0fb23c8..1403987 100644 --- a/src/com/android/settings/cyanogenmod/SpamList.java +++ b/src/com/android/settings/cyanogenmod/SpamList.java @@ -40,7 +40,8 @@ public class SpamList extends ListFragment { private static final int MENU_NOTIFICATIONS = Menu.FIRST; private static final Uri PACKAGES_URI; - private static final Uri PACKAGES_NOTIFICATION_URI; + private static final Uri MESSAGES_URI; + static { Uri.Builder builder = new Uri.Builder(); builder.scheme(ContentResolver.SCHEME_CONTENT); @@ -48,8 +49,9 @@ public class SpamList extends ListFragment { builder.encodedPath("packages"); PACKAGES_URI = builder.build(); - builder.encodedPath("message").build(); - PACKAGES_NOTIFICATION_URI = builder.build(); + MESSAGES_URI = builder + .encodedPath("messages") + .build(); } private SpamAdapter mAdapter; @@ -142,7 +144,7 @@ public class SpamList extends ListFragment { } private static class ItemInfo { - int id; + String id; } private static final class PackageInfo extends ItemInfo { @@ -160,8 +162,10 @@ public class SpamList extends ListFragment { private class FetchFilters extends AsyncTask<Void, Void, List<ItemInfo>> { private void addNotificationsForPackage(PackageInfo pInfo, List<ItemInfo> items) { - Uri notificationUri = Uri.withAppendedPath(PACKAGES_NOTIFICATION_URI, String.valueOf(pInfo.id)); - Cursor c = getActivity().getContentResolver().query(notificationUri, null, null, null, null); + String selection = SpamContract.NotificationTable.PACKAGE_ID + "=?"; + String[] selectionArgs = new String[] {pInfo.id}; + Cursor c = getActivity().getContentResolver().query(MESSAGES_URI, null, selection, + selectionArgs, null); if (c != null) { int notificationIdIndex = c.getColumnIndex(SpamContract.NotificationTable.ID); int notificationMessageIndex = c.getColumnIndex(SpamContract.NotificationTable.MESSAGE_TEXT); @@ -170,7 +174,7 @@ public class SpamList extends ListFragment { while (c.moveToNext()) { NotificationInfo nInfo = new NotificationInfo(); nInfo.messageText = c.getString(notificationMessageIndex); - nInfo.id = c.getInt(notificationIdIndex); + nInfo.id = c.getString(notificationIdIndex); nInfo.date = c.getLong(notificationBlockedIndex); nInfo.count = c.getInt(notificationCountIndex); nInfo.appLabel = pInfo.applicationLabel; @@ -192,7 +196,7 @@ public class SpamList extends ListFragment { PackageInfo pInfo = new PackageInfo(); pInfo.packageName = c.getString(packageNameIndex); getAppInfo(pInfo); - pInfo.id = c.getInt(packageIdIndex); + pInfo.id = c.getString(packageIdIndex); items.add(pInfo); addNotificationsForPackage(pInfo, items); } @@ -258,9 +262,12 @@ public class SpamList extends ListFragment { public void removeItem(int position) { ItemInfo item = mItems.get(position); - Uri uri = Uri.withAppendedPath(PACKAGES_NOTIFICATION_URI, - String.valueOf(((NotificationInfo) item).id)); - getActivity().getContentResolver().delete(uri, null, null); + Uri.Builder builder = new Uri.Builder(); + builder.scheme(ContentResolver.SCHEME_CONTENT); + builder.authority(SpamFilter.AUTHORITY); + builder.encodedPath(SpamFilter.MESSAGE_PATH); + builder.appendEncodedPath(((NotificationInfo) item).id); + getActivity().getContentResolver().delete(builder.build(), null, null); notifyDataSetChanged(); } |