From 814a5b4894426eea6d178018df767c22a5453c4d Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Mon, 12 Feb 2018 02:07:28 -0800 Subject: Fixed some search UI nits. - Search bar text no longer extends underneath the X/clear button. - Dialpad text is now preserved when it is lowered then raised again without leaving the search UI. - Search bar now has a shadow in the search UI Bug: 73088433 Test: tests for dialpad text logic PiperOrigin-RevId: 185350273 Change-Id: Ie4c968cba4f187af81121aa40d43c26a762cdd2b --- .../dialer/main/impl/MainSearchController.java | 37 +++++++++++++++++++--- .../dialer/main/impl/res/layout/main_activity.xml | 7 ++++ .../impl/toolbar/res/drawable/search_shadow.xml | 25 +++++++++++++++ .../toolbar/res/layout/expanded_search_bar.xml | 2 +- .../impl/toolbar/res/layout/toolbar_layout.xml | 1 - 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index f1486ba96..7098f8844 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -16,6 +16,7 @@ package com.android.dialer.main.impl; +import android.app.Fragment; import android.app.FragmentTransaction; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -131,7 +132,15 @@ public class MainSearchController implements SearchBarListener { transaction.commit(); } - /** Hides the dialpad, reveals the FAB and slides the toolbar back onto the screen. */ + /** + * Hides the dialpad, reveals the FAB and slides the toolbar back onto the screen. + * + *

This method intentionally "hides" and does not "remove" the dialpad in order to preserve its + * state (i.e. we call {@link FragmentTransaction#hide(Fragment)} instead of {@link + * FragmentTransaction#remove(Fragment)}. + * + * @see {@link #closeSearch(boolean)} to "remove" the dialpad. + */ private void hideDialpad(boolean animate, boolean bottomNavVisible) { Assert.checkArgument(isDialpadVisible()); @@ -159,7 +168,7 @@ public class MainSearchController implements SearchBarListener { @Override public void onAnimationEnd(Animation animation) { if (!(mainActivity.isFinishing() || mainActivity.isDestroyed())) { - mainActivity.getFragmentManager().beginTransaction().remove(dialpadFragment).commit(); + mainActivity.getFragmentManager().beginTransaction().hide(dialpadFragment).commit(); } } @@ -227,7 +236,10 @@ public class MainSearchController implements SearchBarListener { } } - /** Calls {@link #hideDialpad(boolean, boolean)} and removes the search fragment. */ + /** + * Calls {@link #hideDialpad(boolean, boolean)}, removes the search fragment and clears the + * dialpad. + */ private void closeSearch(boolean animate) { Assert.checkArgument(isSearchVisible()); if (isDialpadVisible()) { @@ -238,9 +250,17 @@ public class MainSearchController implements SearchBarListener { showBottomNav(); toolbar.collapse(animate); mainActivity.getFragmentManager().beginTransaction().remove(getSearchFragment()).commit(); + + // Clear the dialpad so the phone number isn't persisted between search sessions. + getDialpadFragment().clearDialpad(); } - @Nullable + /** + * Returns {@link DialpadFragment}. + * + *

Unless this method is being called for the first time in {@link #openSearch(Optional)} or + * {@link #showDialpad(boolean)}, it should never return null. + */ private DialpadFragment getDialpadFragment() { return (DialpadFragment) mainActivity.getFragmentManager().findFragmentByTag(DIALPAD_FRAGMENT_TAG); @@ -295,6 +315,15 @@ public class MainSearchController implements SearchBarListener { } else if (!isSearchVisible()) { transaction.show(getSearchFragment()); } + + // Add the dialpad fragment but keep it hidden + if (getDialpadFragment() == null) { + DialpadFragment dialpadFragment = new DialpadFragment(); + transaction + .add(R.id.dialpad_fragment_container, dialpadFragment, DIALPAD_FRAGMENT_TAG) + .hide(dialpadFragment); + } + transaction.commit(); } diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml index 2094a7329..d8b13a6c2 100644 --- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml +++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml @@ -67,6 +67,13 @@ android:id="@+id/toolbar" layout="@layout/toolbar_layout"/> + + + + + + + + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml index 4dbd4bf22..4e49accae 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml @@ -36,7 +36,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toEndOf="@+id/search_back_button" - android:layout_toStartOf="@+id/search_close_button" + android:layout_toStartOf="@+id/search_clear_button" android:layout_centerVertical="true" android:layout_marginStart="8dp" android:minHeight="48dp" diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml index 7c4cee2b3..59cc35451 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml @@ -16,7 +16,6 @@ Date: Mon, 12 Feb 2018 07:51:54 -0800 Subject: Delete and upload voicemail as deleted on the VM server When a voicemail is deleted we mark it as deleted in the database. However to ensure that a voicemail gets deleted on the server, we need to upload it as well by forcing a upload sync, which we do after a successful marking it as deleted. Bug: 73087132 Test: N/A PiperOrigin-RevId: 185377828 Change-Id: Ia023cd7c5c283034c78022bcb6d4ce78e410de76 --- .../voicemail/listui/NewVoicemailAdapter.java | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java index 044d8df6d..07a37c3cc 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java @@ -16,13 +16,16 @@ package com.android.dialer.voicemail.listui; import android.app.FragmentManager; +import android.content.ContentValues; import android.content.Context; +import android.content.Intent; import android.database.Cursor; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; import android.media.MediaPlayer.OnErrorListener; import android.media.MediaPlayer.OnPreparedListener; import android.net.Uri; +import android.provider.VoicemailContract.Voicemails; import android.support.annotation.IntDef; import android.support.annotation.Nullable; import android.support.annotation.WorkerThread; @@ -37,7 +40,6 @@ import android.view.ViewGroup; import com.android.dialer.calllogutils.CallLogDates; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.common.concurrent.DialerExecutor.SuccessListener; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.concurrent.ThreadUtil; @@ -48,6 +50,7 @@ import com.android.dialer.voicemail.listui.error.VoicemailErrorMessage; import com.android.dialer.voicemail.listui.error.VoicemailErrorMessageCreator; import com.android.dialer.voicemail.listui.error.VoicemailStatus; import com.android.dialer.voicemail.model.VoicemailEntry; +import com.android.voicemail.VoicemailClient; import com.google.common.collect.ImmutableList; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -637,32 +640,37 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter collapseExpandedViewHolder(expandedViewHolder); - Worker, Integer> deleteVoicemail = this::deleteVoicemail; - SuccessListener deleteVoicemailCallBack = this::onVoicemailDeleted; + Worker, Void> deleteVoicemail = this::deleteVoicemail; DialerExecutorComponent.get(context) .dialerExecutorFactory() - .createUiTaskBuilder(fragmentManager, "delete_voicemail", deleteVoicemail) - .onSuccess(deleteVoicemailCallBack) + .createNonUiTaskBuilder(deleteVoicemail) .build() .executeSerial(new Pair<>(context, voicemailUri)); notifyItemRemoved(expandedViewHolder.getAdapterPosition()); } - private void onVoicemailDeleted(Integer integer) { - LogUtil.i("NewVoicemailAdapter.onVoicemailDeleted", "return value:%d", integer); - Assert.checkArgument(integer == 1, "voicemail delete was not successful"); - } - @WorkerThread - private Integer deleteVoicemail(Pair contextUriPair) { + private Void deleteVoicemail(Pair contextUriPair) { Assert.isWorkerThread(); LogUtil.enterBlock("NewVoicemailAdapter.deleteVoicemail"); + Context context = contextUriPair.first; Uri uri = contextUriPair.second; LogUtil.i("NewVoicemailAdapter.deleteVoicemail", "deleting uri:%s", String.valueOf(uri)); - return context.getContentResolver().delete(uri, null, null); + ContentValues values = new ContentValues(); + values.put(Voicemails.DELETED, "1"); + + int numRowsUpdated = context.getContentResolver().update(uri, values, null, null); + + LogUtil.i("NewVoicemailAdapter.onVoicemailDeleted", "return value:%d", numRowsUpdated); + Assert.checkArgument(numRowsUpdated == 1, "voicemail delete was not successful"); + + Intent intent = new Intent(VoicemailClient.ACTION_UPLOAD); + intent.setPackage(context.getPackageName()); + context.sendBroadcast(intent); + return null; } /** -- cgit v1.2.3