Polish call blocking rotation/undo behaviors.
+ Correctly dismiss filtered number dialog on rotate.
+ Polish listener interface, and extend across all block/unblock
and undo scenarios.
+ Update UI across all blocking scenarios (call log, call detail,
settings, blocked number list, blocked number search);
+ Conslidate creation of FilterNumberDialogFragment in a single
static method.
The listener interface is not ideal, because it does not maintain
state well across rotation and multiple instances. This option was
selected, however, because of the number of scenarios in which
the dialog is invoked and various circumstances (in a RecyclerView
list item, in a fragment, in an activity). This range of scenarios
makes it convoluted to implement a uniform mechanism in any other
way, so the approach opted for is to set a listener, and dismiss
the dialog on rotation..
Bug: 24638328
Bug: 24109819
Bug: 24871853
Change-Id: I2332edda2cae0341af3e80b13aa96af6068f75ac
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 696168a..654a96f 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -71,8 +71,7 @@
*/
public class CallDetailActivity extends AppCompatActivity
implements MenuItem.OnMenuItemClickListener, View.OnClickListener,
- FilterNumberDialogFragment.OnBlockListener,
- FilterNumberDialogFragment.OnUndoBlockListener {
+ FilterNumberDialogFragment.Callback {
private static final String TAG = CallDetailActivity.class.getSimpleName();
/** A long array extra containing ids of call log entries to display. */
@@ -305,16 +304,6 @@
}
@Override
- public void onBlockComplete(Uri uri) {
- updateBlockActionItem();
- }
-
- @Override
- public void onUndoBlockComplete() {
- updateBlockActionItem();
- }
-
- @Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
TouchPointManager.getInstance().setPoint((int) ev.getRawX(), (int) ev.getRawY());
@@ -406,17 +395,15 @@
public void onClick(View view) {
switch(view.getId()) {
case R.id.call_detail_action_block:
- // TODO: Use helper, this code is repeated in several places.
- FilterNumberDialogFragment newFragment =
- FilterNumberDialogFragment.newInstance(
- mBlockedNumberId, null, mNumber, null, mDisplayNumber);
- // TODO: Cleanup this listener pattern. This only works correctly for undoing
- // blocking, not undoing unblocking.
- newFragment.setOnBlockListener(this);
- newFragment.setOnUndoBlockListener(this);
- newFragment.setParentView(findViewById(R.id.call_detail));
- newFragment.show(
- getFragmentManager(), FilterNumberDialogFragment.BLOCK_DIALOG_FRAGMENT);
+ FilterNumberDialogFragment.show(
+ mBlockedNumberId,
+ null /* normalizedNumber */,
+ mNumber,
+ null /* countryIso */,
+ mDisplayNumber,
+ R.id.call_detail,
+ getFragmentManager(),
+ this);
break;
case R.id.call_detail_action_copy:
ClipboardUtils.copyText(mContext, null, mNumber, true);
@@ -431,6 +418,16 @@
}
}
+ @Override
+ public void onChangeFilteredNumberSuccess() {
+ updateBlockActionItem();
+ }
+
+ @Override
+ public void onChangeFilteredNumberUndo() {
+ updateBlockActionItem();
+ }
+
private void updateBlockActionItem() {
if (mDetails == null) {
return;