diff options
author | Andrew Lee <anwlee@google.com> | 2015-10-12 18:57:28 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-12 18:57:28 +0000 |
commit | ee26c6ee835300aec555e1f3e062f785cb1677fc (patch) | |
tree | 1099f753dd294cef175bd7f8ecf3c9383b3a78cf | |
parent | cc537470e9b87878982b429c4173a21481e253c7 (diff) | |
parent | b34b9b34d3759c0b313d9fe08c8010a659807c62 (diff) |
am b34b9b34: Merge "Combine blocked number fragments into Activity." into ub-contactsdialer-a-dev
* commit 'b34b9b34d3759c0b313d9fe08c8010a659807c62':
Combine blocked number fragments into Activity.
-rw-r--r-- | AndroidManifest.xml | 24 | ||||
-rw-r--r-- | res/layout/blocked_number_fragment.xml | 9 | ||||
-rw-r--r-- | res/layout/blocked_numbers_activity.xml (renamed from res/layout/search_activity.xml) | 4 | ||||
-rw-r--r-- | res/values/dimens.xml | 2 | ||||
-rw-r--r-- | res/values/strings.xml | 4 | ||||
-rw-r--r-- | res/values/styles.xml | 15 | ||||
-rw-r--r-- | src/com/android/dialer/filterednumber/BlockedNumberFragment.java | 13 | ||||
-rw-r--r-- | src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java (renamed from src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java) | 143 | ||||
-rw-r--r-- | src/com/android/dialer/list/BlockedListSearchFragment.java | 30 | ||||
-rw-r--r-- | src/com/android/dialer/list/SearchFragment.java | 4 | ||||
-rw-r--r-- | src/com/android/dialer/settings/DialerSettingsActivity.java | 6 |
11 files changed, 168 insertions, 86 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 94333eb1e..f85f25e57 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -142,17 +142,17 @@ </activity> <activity android:name="com.android.dialer.settings.DialerSettingsActivity" - android:label="@string/dialer_settings_label" - android:parentActivityName="com.android.dialer.DialtactsActivity" - android:theme="@style/SettingsStyle" - android:exported="false"> + android:label="@string/dialer_settings_label" + android:parentActivityName="com.android.dialer.DialtactsActivity" + android:theme="@style/SettingsStyle" + android:exported="false"> </activity> - <activity android:name="com.android.dialer.filterednumber.BlockedNumberSearchActivity" - android:label="@string/dialer_settings_label" + <activity android:name="com.android.dialer.filterednumber.ManageBlockedNumbersActivity" + android:label="@string/manage_blocked_numbers_label" android:parentActivityName="com.android.dialer.settings.DialerSettingsActivity" - android:theme="@style/DialtactsActivityTheme" - android:windowSoftInputMode="stateVisible"> + android:theme="@style/ManageBlockedNumbersStyle" + android:exported="false"> </activity> <activity android:name="com.android.dialer.calllog.CallLogActivity" @@ -162,11 +162,9 @@ </activity> <activity android:name="com.android.dialer.CallDetailActivity" - android:label="@string/callDetailTitle" - android:theme="@style/CallDetailActivityTheme" - android:icon="@mipmap/ic_launcher_phone" - android:parentActivityName="com.android.dialer.calllog.CallLogActivity" - > + android:label="@string/callDetailTitle" + android:theme="@style/CallDetailActivityTheme" + android:icon="@mipmap/ic_launcher_phone"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> diff --git a/res/layout/blocked_number_fragment.xml b/res/layout/blocked_number_fragment.xml index bbface6de..e86ccb596 100644 --- a/res/layout/blocked_number_fragment.xml +++ b/res/layout/blocked_number_fragment.xml @@ -16,10 +16,11 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/blocked_number_fragment" - android:orientation="vertical" - android:background="@color/blocked_number_background" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:orientation="vertical" + android:paddingTop="?android:attr/actionBarSize" + android:background="@color/blocked_number_background"> <android.support.v7.widget.CardView android:layout_width="match_parent" @@ -54,4 +55,4 @@ </android.support.v7.widget.CardView> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/res/layout/search_activity.xml b/res/layout/blocked_numbers_activity.xml index 8feeac20d..b5810b7fa 100644 --- a/res/layout/search_activity.xml +++ b/res/layout/blocked_numbers_activity.xml @@ -15,7 +15,7 @@ --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/search_activity_container" + android:id="@+id/blocked_numbers_activity_container" android:layout_width="match_parent" android:layout_height="match_parent"> -</FrameLayout>
\ No newline at end of file +</FrameLayout> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 38e4d0e6e..b38994b64 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -81,7 +81,7 @@ room to the search box--> <dimen name="action_bar_height">56dp</dimen> <dimen name="action_bar_height_large">64dp</dimen> - <dimen name="action_bar_elevation">2dp</dimen> + <dimen name="action_bar_elevation">3dp</dimen> <dimen name="tab_height">43dp</dimen> <!-- actionbar height + tab height --> <dimen name="actionbar_and_tab_height">107dp</dimen> diff --git a/res/values/strings.xml b/res/values/strings.xml index 3f4b9e2a6..a4b64a94d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -830,8 +830,8 @@ <!-- Label for the call settings section [CHAR LIMIT=30] --> <string name="call_settings_label">Calls</string> - <!-- Label for the blocked calls settings section [CHAR LIMIT=30] --> - <string name="blocked_calls_settings_label">Spam and blocked calls</string> + <!-- Label for the blocked numbers settings section [CHAR LIMIT=30] --> + <string name="manage_blocked_numbers_label">Blocked numbers</string> <!-- Text informing the user they have previously marked contacts to be sent to voicemail. This will be followed by two buttons, 1) to view who is marked to be sent to voicemail diff --git a/res/values/styles.xml b/res/values/styles.xml index 005fd4587..f21d62f80 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -241,6 +241,21 @@ <item name="android:textColorLink">@color/dialtacts_theme_color</item> </style> + <style name="ManageBlockedNumbersStyle" parent="SettingsStyle"> + <!-- Styles that require AppCompat compatibility, remember to update both sets --> + <item name="android:windowActionBarOverlay">true</item> + <item name="windowActionBarOverlay">true</item> + <item name="android:actionBarStyle">@style/ManageBlockedNumbersActionBarStyle</item> + <item name="actionBarStyle">@style/ManageBlockedNumbersActionBarStyle</item> + <item name="android:fastScrollTrackDrawable">@null</item> + </style> + + <style name="ManageBlockedNumbersActionBarStyle" parent="DialtactsActionBarWithoutTitleStyle"> + <!-- Styles that require AppCompat compatibility, remember to update both sets --> + <item name="android:height">@dimen/action_bar_height</item> + <item name="height">@dimen/action_bar_height</item> + </style> + <!-- Inherit from Theme.Material.Light.Dialog instead of Theme.Material.Light.Dialog.Alert since the Alert dialog is private. They are identical anyway. --> <style name="AlertDialogTheme" parent="@android:style/Theme.Material.Light.Dialog"> diff --git a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java index 79e5861dc..e12fd6b38 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberFragment.java +++ b/src/com/android/dialer/filterednumber/BlockedNumberFragment.java @@ -27,7 +27,6 @@ import android.view.View; import android.view.ViewGroup; import com.android.dialer.R; -import com.android.dialer.database.FilteredNumberAsyncQueryHandler; import com.android.dialer.database.FilteredNumberContract; public class BlockedNumberFragment extends ListFragment implements @@ -38,12 +37,14 @@ public class BlockedNumberFragment extends ListFragment implements @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + LayoutInflater inflater = LayoutInflater.from(getContext()); getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null)); if (mAdapter == null) { mAdapter = new BlockedNumberAdapter(getContext()); } setListAdapter(mAdapter); + getActivity().findViewById(R.id.add_number_button).setOnClickListener(this); getListView().getEmptyView().findViewById(R.id.add_number_button).setOnClickListener(this); } @@ -61,8 +62,8 @@ public class BlockedNumberFragment extends ListFragment implements } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView( + LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.blocked_number_fragment, container, false); return view; } @@ -95,6 +96,10 @@ public class BlockedNumberFragment extends ListFragment implements @Override public void onClick(final View v) { - startActivity(new Intent(getActivity(), BlockedNumberSearchActivity.class)); + ManageBlockedNumbersActivity manageBlockedNumbersActivity = + (ManageBlockedNumbersActivity) getActivity(); + if (manageBlockedNumbersActivity != null && v.getId() == R.id.add_number_button) { + manageBlockedNumbersActivity.enterSearchUi(); + } } } diff --git a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java index cfa404f05..356c55cee 100644 --- a/src/com/android/dialer/filterednumber/BlockedNumberSearchActivity.java +++ b/src/com/android/dialer/filterednumber/ManageBlockedNumbersActivity.java @@ -18,6 +18,7 @@ package com.android.dialer.filterednumber; import android.app.Fragment; import android.app.FragmentTransaction; import android.content.Intent; +import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBar; @@ -26,6 +27,7 @@ import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.util.TypedValue; +import android.view.MenuItem; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; @@ -42,16 +44,23 @@ import com.android.dialer.list.BlockedListSearchFragment; import com.android.dialer.list.SearchFragment; import com.android.dialer.widget.SearchEditTextLayout; -public class BlockedNumberSearchActivity extends AppCompatActivity +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 FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; + + private BlockedNumberFragment mManagementFragment; private SearchFragment mSearchFragment; + private EditText mSearchView; private ActionBar mActionBar; private String mSearchQuery; + private boolean mIsShowingManagementUi; + private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -72,17 +81,93 @@ public class BlockedNumberSearchActivity extends AppCompatActivity } }; + private final SearchEditTextLayout.Callback mSearchLayoutCallback = + new SearchEditTextLayout.Callback() { + @Override + public void onBackButtonClicked() { + showManagementUi(); + } + + @Override + public void onSearchViewClicked() { + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.blocked_numbers_activity); + mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler(getContentResolver()); - setContentView(R.layout.search_activity); + showManagementUi(); + } + + private void showManagementUi() { + mIsShowingManagementUi = true; + + showManagementUiActionBar(); + + final FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (mSearchFragment != null) { + transaction.hide(mSearchFragment); + } + + BlockedNumberFragment fragment = (BlockedNumberFragment) getFragmentManager() + .findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT); + if (fragment == null) { + fragment = new BlockedNumberFragment(); + transaction.add(R.id.blocked_numbers_activity_container, fragment, + TAG_BLOCKED_MANAGEMENT_FRAGMENT); + } else { + transaction.show(fragment); + } + transaction.commit(); + } + private void showManagementUiActionBar() { + mActionBar = getSupportActionBar(); + ColorDrawable backgroundDrawable = new ColorDrawable(getColor(R.color.dialer_theme_color)); + mActionBar.setBackgroundDrawable(backgroundDrawable); + mActionBar.setElevation(getResources().getDimensionPixelSize(R.dimen.action_bar_elevation)); + mActionBar.setDisplayShowCustomEnabled(false); + mActionBar.setDisplayHomeAsUpEnabled(true); + mActionBar.setDisplayShowHomeEnabled(true); + mActionBar.setDisplayShowTitleEnabled(true); + mActionBar.setTitle(R.string.manage_blocked_numbers_label); + } + + public void enterSearchUi() { + mIsShowingManagementUi = false; + + showSearchUiActionBar(); + + final FragmentTransaction transaction = getFragmentManager().beginTransaction(); + if (mManagementFragment != null) { + transaction.hide(mManagementFragment); + } + + BlockedListSearchFragment fragment = (BlockedListSearchFragment) getFragmentManager() + .findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); + if (fragment == null) { + fragment = new BlockedListSearchFragment(); + fragment.setHasOptionsMenu(false); + fragment.setShowEmptyListForNullQuery(true); + fragment.setDirectorySearchEnabled(false); + transaction.add(R.id.blocked_numbers_activity_container, fragment, + TAG_BLOCKED_SEARCH_FRAGMENT); + } else { + transaction.show(fragment); + } + transaction.commit(); + } + + private void showSearchUiActionBar() { mActionBar = getSupportActionBar(); mActionBar.setCustomView(R.layout.search_edittext); mActionBar.setBackgroundDrawable(null); + mActionBar.setElevation(0); mActionBar.setDisplayShowCustomEnabled(true); mActionBar.setDisplayHomeAsUpEnabled(false); mActionBar.setDisplayShowHomeEnabled(false); @@ -90,49 +175,41 @@ public class BlockedNumberSearchActivity extends AppCompatActivity final SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) mActionBar .getCustomView().findViewById(R.id.search_view_container); searchEditTextLayout.expand(false, true); - searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() { - @Override - public void onBackButtonClicked() { - onBackPressed(); - } - - @Override - public void onSearchViewClicked() { - } - }); + searchEditTextLayout.setCallback(mSearchLayoutCallback); mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); mSearchView.setHint(R.string.block_number_search_hint); + + // TODO: Don't set custom text size; use default search text size. mSearchView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.blocked_number_search_text_size)); - - enterSearchUi(); } - private void enterSearchUi() { - if (mSearchFragment != null) { - return; + @Override + public void onAttachFragment(Fragment fragment) { + if (fragment instanceof BlockedNumberFragment) { + mManagementFragment = (BlockedNumberFragment) fragment; + } else if (fragment instanceof BlockedListSearchFragment) { + mSearchFragment = (BlockedListSearchFragment) fragment; } - final FragmentTransaction transaction = getFragmentManager().beginTransaction(); - BlockedListSearchFragment fragment = (BlockedListSearchFragment) getFragmentManager() - .findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); - if (fragment == null) { - fragment = new BlockedListSearchFragment(); - transaction.add(R.id.search_activity_container, fragment, TAG_BLOCKED_SEARCH_FRAGMENT); - } else { - transaction.show(fragment); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + onBackPressed(); + return true; } - fragment.setHasOptionsMenu(false); - fragment.setShowEmptyListForNullQuery(true); - fragment.setDirectorySearchEnabled(false); - transaction.commit(); + return false; } @Override - public void onAttachFragment(Fragment fragment) { - if (fragment instanceof BlockedListSearchFragment) { - mSearchFragment = (BlockedListSearchFragment) fragment; + public void onBackPressed() { + if (mIsShowingManagementUi) { + super.onBackPressed(); + } else { + showManagementUi(); } } @@ -158,6 +235,6 @@ public class BlockedNumberSearchActivity extends AppCompatActivity @Override public int getActionBarHeight() { - return getResources().getDimensionPixelSize(R.dimen.action_bar_height_large); + return getSupportActionBar().getHeight(); } } diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index 675081254..eef24afb1 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -86,13 +86,9 @@ public class BlockedListSearchFragment extends RegularSearchFragment { private void blockNumber(final String number) { final String countryIso = GeoUtil.getCurrentCountryIso(getContext()); - final IndeterminateProgressDialog progressDialog = - IndeterminateProgressDialog.show(getFragmentManager(), - getString(R.string.checkingNumber, number), null, 500); final String normalizedNumber = FilteredNumberAsyncQueryHandler.getNormalizedNumber(number, countryIso); if (normalizedNumber == null) { - progressDialog.dismiss(); Toast.makeText(getContext(), getString(R.string.invalidNumber, number), Toast.LENGTH_SHORT).show(); return; @@ -100,12 +96,11 @@ public class BlockedListSearchFragment extends RegularSearchFragment { final OnCheckBlockedListener onCheckListener = new OnCheckBlockedListener() { @Override public void onCheckComplete(Integer id) { - progressDialog.dismiss(); if (id == null) { final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment .newInstance(id, normalizedNumber, number, countryIso, number); newFragment.setParentView( - getActivity().findViewById(R.id.search_activity_container)); + getActivity().findViewById(R.id.blocked_numbers_activity_container)); newFragment.show( getFragmentManager(), FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT); } else { @@ -118,9 +113,11 @@ public class BlockedListSearchFragment extends RegularSearchFragment { onCheckListener, normalizedNumber, number, countryIso); } - private void blockContactNumber(final BlockedListSearchAdapter adapter, - final ContactListItemView view, final String number, - final Integer blockId) { + private void blockContactNumber( + final BlockedListSearchAdapter adapter, + final ContactListItemView view, + final String number, + final Integer blockId) { final String countryIso = GeoUtil.getCurrentCountryIso(getContext()); final String normalizedNumber = FilteredNumberAsyncQueryHandler.getNormalizedNumber(number, countryIso); @@ -136,19 +133,8 @@ public class BlockedListSearchFragment extends RegularSearchFragment { } final FilterNumberDialogFragment newFragment = FilterNumberDialogFragment .newInstance(blockId, normalizedNumber, number, countryIso, number); - newFragment.setParentView(getActivity().findViewById(R.id.search_activity_container)); - newFragment.setOnUndoBlockListener(new FilterNumberDialogFragment.OnUndoBlockListener() { - @Override - public void onUndoBlockComplete() { - adapter.setViewUnblocked(view); - } - }); - newFragment.setOnBlockListener(new FilterNumberDialogFragment.OnBlockListener() { - @Override - public void onBlockComplete(Uri uri) { - adapter.setViewBlocked(view, Long.valueOf(ContentUris.parseId(uri)).intValue()); - } - }); + newFragment.setParentView( + getActivity().findViewById(R.id.blocked_numbers_activity_container)); newFragment.show(getFragmentManager(), FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT); } } diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index 1c895d3af..c8711e769 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -289,12 +289,12 @@ public class SearchFragment extends PhoneNumberPickerFragment { public void updatePosition(boolean animate) { // Use negative shadow height instead of 0 to account for the 9-patch's shadow. int startTranslationValue = - mActivity.isDialpadShown() ? mActionBarHeight - mShadowHeight: -mShadowHeight; + mActivity.isDialpadShown() ? mActionBarHeight - mShadowHeight : -mShadowHeight; int endTranslationValue = 0; // Prevents ListView from being translated down after a rotation when the ActionBar is up. if (animate || mActivity.isActionBarShowing()) { endTranslationValue = - mActivity.isDialpadShown() ? 0 : mActionBarHeight -mShadowHeight; + mActivity.isDialpadShown() ? 0 : mActionBarHeight - mShadowHeight; } if (animate) { // If the dialpad will be shown, then this animation involves sliding the list up. diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java index 58b0ab8e6..6fcd22195 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.BlockedNumberFragment; +import com.android.dialer.filterednumber.ManageBlockedNumbersActivity; import java.util.List; @@ -87,8 +87,8 @@ public class DialerSettingsActivity extends AppCompatPreferenceActivity { } Header blockedCallsHeader = new Header(); - blockedCallsHeader.titleRes = R.string.blocked_calls_settings_label; - blockedCallsHeader.fragment = BlockedNumberFragment.class.getName(); + blockedCallsHeader.titleRes = R.string.manage_blocked_numbers_label; + blockedCallsHeader.intent = new Intent(this, ManageBlockedNumbersActivity.class); target.add(blockedCallsHeader); if (telephonyManager.isTtyModeSupported() |