From 91cd89c9ca486624850cdb0aaec86882a30c18a7 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 28 Oct 2015 17:47:42 -0700 Subject: Rename activity for blocked numbers settings. Manage is more related to a specific screen, new name seems to make more sense based on location in settings menu of application. Bug: 25343277 Change-Id: Ia45c1b7aa91c045078fd1473500f5d474e1c598f --- .../filterednumber/BlockedNumbersFragment.java | 11 +- .../BlockedNumbersSettingsActivity.java | 156 +++++++++++++++++++++ .../dialer/filterednumber/FilteredNumbersUtil.java | 2 +- .../ManageBlockedNumbersActivity.java | 145 ------------------- .../dialer/list/BlockedListSearchFragment.java | 4 +- .../dialer/settings/DialerSettingsActivity.java | 4 +- 6 files changed, 166 insertions(+), 156 deletions(-) create mode 100644 src/com/android/dialer/filterednumber/BlockedNumbersSettingsActivity.java delete mode 100644 src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java (limited to 'src') diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java index 36978885a..853076c26 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java +++ b/src/com/android/dialer/filterednumber/BlockedNumbersFragment.java @@ -176,21 +176,20 @@ public class BlockedNumbersFragment extends ListFragment @Override public void onClick(final View view) { - ManageBlockedNumbersActivity manageBlockedNumbersActivity = - (ManageBlockedNumbersActivity) getActivity(); - if (manageBlockedNumbersActivity == null) { + BlockedNumbersSettingsActivity activity = (BlockedNumbersSettingsActivity) getActivity(); + if (activity == null) { return; } switch (view.getId()) { case R.id.add_number_button: - manageBlockedNumbersActivity.enterSearchUi(); + activity.showSearchUi(); break; case R.id.view_numbers_button: - manageBlockedNumbersActivity.showNumbersToImportPreviewUi(); + activity.showNumbersToImportPreviewUi(); break; case R.id.import_button: - FilteredNumbersUtil.importSendToVoicemailContacts(manageBlockedNumbersActivity, + FilteredNumbersUtil.importSendToVoicemailContacts(activity, new ImportSendToVoicemailContactsListener() { @Override public void onImportComplete() { diff --git a/src/com/android/dialer/filterednumber/BlockedNumbersSettingsActivity.java b/src/com/android/dialer/filterednumber/BlockedNumbersSettingsActivity.java new file mode 100644 index 000000000..1735ce543 --- /dev/null +++ b/src/com/android/dialer/filterednumber/BlockedNumbersSettingsActivity.java @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.dialer.filterednumber; + +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; +import android.view.MenuItem; +import android.widget.FrameLayout; +import android.widget.FrameLayout.LayoutParams; +import android.widget.Toast; + +import com.android.contacts.common.GeoUtil; +import com.android.contacts.common.dialog.IndeterminateProgressDialog; +import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; +import com.android.dialer.R; +import com.android.dialer.database.FilteredNumberAsyncQueryHandler; +import com.android.dialer.list.BlockedListSearchAdapter; +import com.android.dialer.list.OnListFragmentScrolledListener; +import com.android.dialer.list.BlockedListSearchFragment; +import com.android.dialer.list.SearchFragment; + +public class BlockedNumbersSettingsActivity extends AppCompatActivity + implements SearchFragment.HostInterface { + + private static final String TAG_BLOCKED_MANAGEMENT_FRAGMENT = "blocked_management"; + private static final String TAG_BLOCKED_SEARCH_FRAGMENT = "blocked_search"; + private static final String TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT = "view_numbers_to_import"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.blocked_numbers_activity); + + // If savedInstanceState != null, the Activity will automatically restore the last fragment. + if (savedInstanceState == null) { + showManagementUi(); + } + } + + /** + * Shows fragment with the list of currently blocked numbers and settings related to blocking. + */ + public void showManagementUi() { + BlockedNumbersFragment fragment = (BlockedNumbersFragment) getFragmentManager() + .findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT); + if (fragment == null) { + fragment = new BlockedNumbersFragment(); + } + + getFragmentManager().beginTransaction() + .replace(R.id.blocked_numbers_activity_container, fragment, + TAG_BLOCKED_MANAGEMENT_FRAGMENT) + .commit(); + } + + /** + * Shows fragment with search UI for browsing/finding numbers to block. + */ + public void showSearchUi() { + BlockedListSearchFragment fragment = (BlockedListSearchFragment) getFragmentManager() + .findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); + if (fragment == null) { + fragment = new BlockedListSearchFragment(); + fragment.setHasOptionsMenu(false); + fragment.setShowEmptyListForNullQuery(true); + fragment.setDirectorySearchEnabled(false); + } + + getFragmentManager().beginTransaction() + .replace(R.id.blocked_numbers_activity_container, fragment, + TAG_BLOCKED_SEARCH_FRAGMENT) + .addToBackStack(null) + .commit(); + } + + /** + * Shows fragment with UI to preview the numbers of contacts currently marked as + * send-to-voicemail in Contacts. These numbers can be imported into Dialer's blocked number + * list. + */ + public void showNumbersToImportPreviewUi() { + ViewNumbersToImportFragment fragment = (ViewNumbersToImportFragment) getFragmentManager() + .findFragmentByTag(TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT); + if (fragment == null) { + fragment = new ViewNumbersToImportFragment(); + } + + getFragmentManager().beginTransaction() + .replace(R.id.blocked_numbers_activity_container, fragment, + TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT) + .addToBackStack(null) + .commit(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + onBackPressed(); + return true; + } + return false; + } + + @Override + public void onBackPressed() { + // TODO: Achieve back navigation without overriding onBackPressed. + if (getFragmentManager().getBackStackEntryCount() > 0) { + getFragmentManager().popBackStack(); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean isActionBarShowing() { + return false; + } + + @Override + public boolean isDialpadShown() { + return false; + } + + @Override + public int getDialpadHeight() { + return 0; + } + + @Override + public int getActionBarHideOffset() { + return 0; + } + + @Override + public int getActionBarHeight() { + return 0; + } +} diff --git a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java index 4492c51e3..8a0d79233 100644 --- a/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java +++ b/src/com/android/dialer/filterednumber/FilteredNumbersUtil.java @@ -339,7 +339,7 @@ public class FilteredNumbersUtil { R.string.call_blocking_disabled_notification_text)); final Intent contentIntent = - new Intent(context, ManageBlockedNumbersActivity.class); + new Intent(context, BlockedNumbersSettingsActivity.class); builder.setContentIntent(PendingIntent.getActivity( context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); diff --git a/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java deleted file mode 100644 index 109fd97b5..000000000 --- a/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.dialer.filterednumber; - -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.util.Log; -import android.view.MenuItem; -import android.widget.FrameLayout; -import android.widget.FrameLayout.LayoutParams; -import android.widget.Toast; - -import com.android.contacts.common.GeoUtil; -import com.android.contacts.common.dialog.IndeterminateProgressDialog; -import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; -import com.android.dialer.R; -import com.android.dialer.database.FilteredNumberAsyncQueryHandler; -import com.android.dialer.list.BlockedListSearchAdapter; -import com.android.dialer.list.OnListFragmentScrolledListener; -import com.android.dialer.list.BlockedListSearchFragment; -import com.android.dialer.list.SearchFragment; - -public class ManageBlockedNumbersActivity extends AppCompatActivity - implements SearchFragment.HostInterface { - - private static final String TAG_BLOCKED_MANAGEMENT_FRAGMENT = "blocked_management"; - private static final String TAG_BLOCKED_SEARCH_FRAGMENT = "blocked_search"; - private static final String TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT = "view_numbers_to_import"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.blocked_numbers_activity); - - // If savedInstanceState != null, the Activity will automatically restore the last fragment. - if (savedInstanceState == null) { - showManagementUi(); - } - } - - public void showManagementUi() { - BlockedNumbersFragment fragment = (BlockedNumbersFragment) getFragmentManager() - .findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT); - if (fragment == null) { - fragment = new BlockedNumbersFragment(); - } - - getFragmentManager().beginTransaction() - .replace(R.id.blocked_numbers_activity_container, fragment, - TAG_BLOCKED_MANAGEMENT_FRAGMENT) - .commit(); - } - - public void enterSearchUi() { - BlockedListSearchFragment fragment = (BlockedListSearchFragment) getFragmentManager() - .findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); - if (fragment == null) { - fragment = new BlockedListSearchFragment(); - fragment.setHasOptionsMenu(false); - fragment.setShowEmptyListForNullQuery(true); - fragment.setDirectorySearchEnabled(false); - } - - getFragmentManager().beginTransaction() - .replace(R.id.blocked_numbers_activity_container, fragment, - TAG_BLOCKED_SEARCH_FRAGMENT) - .addToBackStack(null) - .commit(); - } - - public void showNumbersToImportPreviewUi() { - ViewNumbersToImportFragment fragment = (ViewNumbersToImportFragment) getFragmentManager() - .findFragmentByTag(TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT); - if (fragment == null) { - fragment = new ViewNumbersToImportFragment(); - } - - getFragmentManager().beginTransaction() - .replace(R.id.blocked_numbers_activity_container, fragment, - TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT) - .addToBackStack(null) - .commit(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - if (item.getItemId() == android.R.id.home) { - onBackPressed(); - return true; - } - return false; - } - - @Override - public void onBackPressed() { - // TODO: Achieve back navigation without overriding onBackPressed. - if (getFragmentManager().getBackStackEntryCount() > 0) { - getFragmentManager().popBackStack(); - } else { - super.onBackPressed(); - } - } - - @Override - public boolean isActionBarShowing() { - return false; - } - - @Override - public boolean isDialpadShown() { - return false; - } - - @Override - public int getDialpadHeight() { - return 0; - } - - @Override - public int getActionBarHideOffset() { - return 0; - } - - @Override - public int getActionBarHeight() { - return 0; - } -} diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 805d969a3..d740b3d4c 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -35,7 +35,7 @@ import com.android.dialer.R; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; import com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnCheckBlockedListener; import com.android.dialer.filterednumber.BlockNumberDialogFragment; -import com.android.dialer.filterednumber.ManageBlockedNumbersActivity; +import com.android.dialer.filterednumber.BlockedNumbersSettingsActivity; import com.android.dialer.widget.SearchEditTextLayout; public class BlockedListSearchFragment extends RegularSearchFragment @@ -200,7 +200,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment @Override public void onChangeFilteredNumberSuccess() { - ManageBlockedNumbersActivity activity = (ManageBlockedNumbersActivity) getActivity(); + BlockedNumbersSettingsActivity activity = (BlockedNumbersSettingsActivity) getActivity(); if (activity == null) { return; } diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java index 6fcd22195..d0bfbc211 100644 --- a/src/com/android/dialer/settings/DialerSettingsActivity.java +++ b/src/com/android/dialer/settings/DialerSettingsActivity.java @@ -28,7 +28,7 @@ import android.view.MenuItem; import android.widget.Toast; import com.android.dialer.R; -import com.android.dialer.filterednumber.ManageBlockedNumbersActivity; +import com.android.dialer.filterednumber.BlockedNumbersSettingsActivity; import java.util.List; @@ -88,7 +88,7 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { Header blockedCallsHeader = new Header(); blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label; - blockedCallsHeader.intent = new Intent(this, ManageBlockedNumbersActivity.class); + blockedCallsHeader.intent = new Intent(this, BlockedNumbersSettingsActivity.class); target.add(blockedCallsHeader); if (telephonyManager.isTtyModeSupported() -- cgit v1.2.3