From 8d0847ca13ca46730756e1d3a3dff3d7d27fd18b Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 13 Oct 2015 13:07:58 -0700 Subject: 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 --- src/com/android/dialer/CallDetailActivity.java | 43 ++++++++++++-------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'src/com/android/dialer/CallDetailActivity.java') diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index 696168a8f..654a96fcf 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -71,8 +71,7 @@ import com.android.incallui.Call.LogState; */ 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. */ @@ -304,16 +303,6 @@ public class CallDetailActivity extends AppCompatActivity getCallDetails(); } - @Override - public void onBlockComplete(Uri uri) { - updateBlockActionItem(); - } - - @Override - public void onUndoBlockComplete() { - updateBlockActionItem(); - } - @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { @@ -406,17 +395,15 @@ public class CallDetailActivity extends AppCompatActivity 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 @@ public class CallDetailActivity extends AppCompatActivity } } + @Override + public void onChangeFilteredNumberSuccess() { + updateBlockActionItem(); + } + + @Override + public void onChangeFilteredNumberUndo() { + updateBlockActionItem(); + } + private void updateBlockActionItem() { if (mDetails == null) { return; -- cgit v1.2.3