summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/filterednumber/BlockedNumbersFragment.java52
-rw-r--r--src/com/android/dialer/settings/DialerSettingsActivity.java14
2 files changed, 57 insertions, 9 deletions
diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
index 87ba8bef6..b64f18691 100644
--- a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
+++ b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java
@@ -15,6 +15,8 @@
*/
package com.android.dialer.filterednumber;
+import com.google.common.base.MoreObjects;
+
import android.app.ListFragment;
import android.app.LoaderManager;
import android.content.Context;
@@ -32,11 +34,12 @@ 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.contacts.common.testing.NeededForTesting;
import com.android.dialer.R;
import com.android.dialer.compat.FilteredNumberCompat;
import com.android.dialer.database.FilteredNumberContract;
+import com.android.dialer.filterednumber.BlockedNumbersMigrator.Listener;
import com.android.dialer.filterednumber.FilteredNumbersUtil.CheckForSendToVoicemailContactListener;
import com.android.dialer.filterednumber.FilteredNumbersUtil.ImportSendToVoicemailContactsListener;
import com.android.dialer.voicemail.VisualVoicemailEnabledChecker;
@@ -46,9 +49,12 @@ public class BlockedNumbersFragment extends ListFragment
VisualVoicemailEnabledChecker.Callback {
private static final char ADD_BLOCKED_NUMBER_ICON_LETTER = '+';
+ private BlockedNumbersMigrator blockedNumbersMigratorForTest;
+ protected View migratePromoView;
+ private TextView blockedNumbersText;
+ private TextView footerText;
private BlockedNumbersAdapter mAdapter;
private VisualVoicemailEnabledChecker mVoicemailEnabledChecker;
-
private View mImportSettings;
private View mBlockedNumbersDisabledForEmergency;
private View mBlockedNumberListDivider;
@@ -81,6 +87,9 @@ public class BlockedNumbersFragment extends ListFragment
}
setListAdapter(mAdapter);
+ blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view);
+ migratePromoView = getListView().findViewById(R.id.migrate_promo);
+ getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this);
mImportSettings = getListView().findViewById(R.id.import_settings);
mBlockedNumbersDisabledForEmergency =
getListView().findViewById(R.id.blocked_numbers_disabled_for_emergency);
@@ -89,6 +98,8 @@ public class BlockedNumbersFragment extends ListFragment
getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this);
getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this);
+ footerText = (TextView) getActivity().findViewById(
+ R.id.blocked_number_footer_textview);
mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(),this);
mVoicemailEnabledChecker.asyncUpdate();
updateActiveVoicemailProvider();
@@ -124,13 +135,16 @@ public class BlockedNumbersFragment extends ListFragment
// 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()) {
+ migratePromoView.setVisibility(View.VISIBLE);
+ blockedNumbersText.setVisibility(View.GONE);
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);
-
- mImportSettings.setSystemUiVisibility(View.GONE);
+ mBlockedNumberListDivider.setVisibility(View.GONE);
+ mImportSettings.setVisibility(View.GONE);
getListView().findViewById(R.id.import_button).setOnClickListener(null);
getListView().findViewById(R.id.view_numbers_button).setOnClickListener(null);
+ mBlockedNumbersDisabledForEmergency.setVisibility(View.GONE);
+ footerText.setVisibility(View.GONE);
} else {
FilteredNumbersUtil.checkForSendToVoicemailContact(
getActivity(), new CheckForSendToVoicemailContactListener() {
@@ -143,7 +157,9 @@ public class BlockedNumbersFragment extends ListFragment
});
}
- if (FilteredNumbersUtil.hasRecentEmergencyCall(getContext())) {
+ // All views except migrate and the block list are hidden when new filtering is available
+ if (!FilteredNumberCompat.canUseNewFiltering()
+ && FilteredNumbersUtil.hasRecentEmergencyCall(getContext())) {
mBlockedNumbersDisabledForEmergency.setVisibility(View.VISIBLE);
} else {
mBlockedNumbersDisabledForEmergency.setVisibility(View.GONE);
@@ -190,7 +206,8 @@ public class BlockedNumbersFragment extends ListFragment
@Override
public void onClick(final View view) {
- BlockedNumbersSettingsActivity activity = (BlockedNumbersSettingsActivity) getActivity();
+ final BlockedNumbersSettingsActivity activity =
+ (BlockedNumbersSettingsActivity) getActivity();
if (activity == null) {
return;
}
@@ -208,8 +225,22 @@ public class BlockedNumbersFragment extends ListFragment
mImportSettings.setVisibility(View.GONE);
}
});
+ } else if (resId == R.id.migrate_promo_allow_button) {
+ view.setEnabled(false);
+ MoreObjects.firstNonNull(blockedNumbersMigratorForTest,
+ new BlockedNumbersMigrator(getContext().getContentResolver()))
+ .migrate(new Listener() {
+ @Override
+ public void onComplete() {
+ getContext().startActivity(
+ FilteredNumberCompat.createManageBlockedNumbersIntent(getContext()));
+ // Remove this activity from the backstack
+ activity.finish();
+ }
+ });
}
}
+
@Override
public void onVisualVoicemailEnabledStatusChanged(boolean newStatus){
updateActiveVoicemailProvider();
@@ -219,12 +250,15 @@ public class BlockedNumbersFragment extends ListFragment
if (getActivity() == null || getActivity().isFinishing()) {
return;
}
- TextView footerText = (TextView) getActivity().findViewById(
- R.id.blocked_number_footer_textview);
if (mVoicemailEnabledChecker.isVisualVoicemailEnabled()) {
footerText.setText(R.string.block_number_footer_message_vvm);
} else {
footerText.setText(R.string.block_number_footer_message_no_vvm);
}
}
+
+ @NeededForTesting
+ void setBlockedNumbersMigratorForTest(BlockedNumbersMigrator blockedNumbersMigrator) {
+ blockedNumbersMigratorForTest = blockedNumbersMigrator;
+ }
}
diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java
index fc689d037..9db3e0564 100644
--- a/src/com/android/dialer/settings/DialerSettingsActivity.java
+++ b/src/com/android/dialer/settings/DialerSettingsActivity.java
@@ -38,6 +38,7 @@ import java.util.List;
public class DialerSettingsActivity extends AppCompatPreferenceActivity {
protected SharedPreferences mPreferences;
+ private boolean migrationStatusOnBuildHeaders;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -46,6 +47,18 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity {
}
@Override
+ protected void onResume() {
+ super.onResume();
+ /*
+ * The headers need to be recreated if the migration status changed between when the headers
+ * were created and now.
+ */
+ if (migrationStatusOnBuildHeaders != FilteredNumberCompat.hasMigratedToNewBlocking()) {
+ invalidateHeaders();
+ }
+ }
+
+ @Override
public void onBuildHeaders(List<Header> target) {
Header displayOptionsHeader = new Header();
displayOptionsHeader.titleRes = R.string.display_options_title;
@@ -99,6 +112,7 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity {
blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label;
blockedCallsHeader.intent = FilteredNumberCompat.createManageBlockedNumbersIntent(this);
target.add(blockedCallsHeader);
+ migrationStatusOnBuildHeaders = FilteredNumberCompat.hasMigratedToNewBlocking();
}
if (isPrimaryUser
&& (TelephonyManagerCompat.isTtyModeSupported(telephonyManager)