summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2016-03-14 17:50:21 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-03-14 17:50:21 +0000
commit414cf94924769f8bc4ca72a8d198c7d278b1f958 (patch)
treeac1cf4892dd797c62043af80222584b1b7772b76
parent470dd5f28d6c3c005ab839e5fc238e679865e278 (diff)
parent6c5ea049202dc238d9d2c95b40d46c8007570664 (diff)
Merge "Hiding add number button in Blocked Management UI" into nyc-dev
am: 6c5ea04920 * commit '6c5ea049202dc238d9d2c95b40d46c8007570664': Hiding add number button in Blocked Management UI
-rw-r--r--src/com/android/dialer/compat/FilteredNumberCompat.java14
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumbersFragment.java18
2 files changed, 26 insertions, 6 deletions
diff --git a/src/com/android/dialer/compat/FilteredNumberCompat.java b/src/com/android/dialer/compat/FilteredNumberCompat.java
index c70df71b7..63a2a32cd 100644
--- a/src/com/android/dialer/compat/FilteredNumberCompat.java
+++ b/src/com/android/dialer/compat/FilteredNumberCompat.java
@@ -99,15 +99,25 @@ public class FilteredNumberCompat {
}
/**
- * @return {@code true} if the new filtering is enabled, {@code false} otherwise.
+ * @return {@code true} if the current SDK version supports using new filtering, {@code false}
+ * otherwise.
*/
- public static boolean useNewFiltering() {
+ public static boolean canUseNewFiltering() {
if (isEnabledForTest != null) {
return CompatUtils.isNCompatible() && isEnabledForTest;
}
return CompatUtils.isNCompatible() && isNewFilteringEnabled;
}
+ /**
+ * @return {@code true} if the new filtering should be used, i.e. it's enabled and any necessary
+ * migration has been performed, {@code false} otherwise.
+ */
+ public static boolean useNewFiltering() {
+ // TODO(maxwelb): Add shared preference for when the Dialer blocked list has been migrated
+ return canUseNewFiltering();
+ }
+
@NeededForTesting
public static void setIsEnabledForTest(Boolean isEnabled) {
isEnabledForTest = isEnabled;
diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
index a8786609b..38615cce8 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
@@ -32,8 +32,10 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.lettertiles.LetterTileDrawable;
import com.android.dialer.R;
+import com.android.dialer.compat.FilteredNumberCompat;
import com.android.dialer.database.FilteredNumberContract;
import com.android.dialer.filterednumber.FilteredNumbersUtil.CheckForSendToVoicemailContactListener;
import com.android.dialer.filterednumber.FilteredNumbersUtil.ImportSendToVoicemailContactsListener;
@@ -83,7 +85,7 @@ public class BlockedNumbersFragment extends ListFragment
mBlockedNumbersDisabledForEmergency =
getListView().findViewById(R.id.blocked_numbers_disabled_for_emergency);
mBlockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider);
- getListView().findViewById(R.id.import_button).setOnClickListener(this);;
+ getListView().findViewById(R.id.import_button).setOnClickListener(this);
getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this);
getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this);
@@ -118,6 +120,15 @@ public class BlockedNumbersFragment extends ListFragment
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(R.string.manage_blocked_numbers_label);
+ // If the device can use the framework blocking solution, users should not be able to add
+ // new blocked numbers from the Blocked Management UI. They will be shown a promo card
+ // asking them to migrate to new blocking instead.
+ if (FilteredNumberCompat.canUseNewFiltering()) {
+ getListView().findViewById(R.id.add_number_linear_layout).setVisibility(View.GONE);
+ getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(null);
+ mBlockedNumberListDivider.setVisibility(View.INVISIBLE);
+ }
+
FilteredNumbersUtil.checkForSendToVoicemailContact(
getActivity(), new CheckForSendToVoicemailContactListener() {
@Override
@@ -152,16 +163,15 @@ public class BlockedNumbersFragment extends ListFragment
};
final String selection = FilteredNumberContract.FilteredNumberColumns.TYPE
+ "=" + FilteredNumberContract.FilteredNumberTypes.BLOCKED_NUMBER;
- final CursorLoader cursorLoader = new CursorLoader(
+ return new CursorLoader(
getContext(), FilteredNumberContract.FilteredNumber.CONTENT_URI, projection,
selection, null, null);
- return cursorLoader;
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAdapter.swapCursor(data);
- if (data.getCount() == 0) {
+ if (FilteredNumberCompat.canUseNewFiltering() || data.getCount() == 0) {
mBlockedNumberListDivider.setVisibility(View.INVISIBLE);
} else {
mBlockedNumberListDivider.setVisibility(View.VISIBLE);