diff options
Diffstat (limited to 'java')
6 files changed, 86 insertions, 18 deletions
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. + * + * <p>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}. + * + * <p>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"/> + <ImageView + android:layout_width="match_parent" + android:layout_height="2dp" + android:scaleType="fitXY" + android:src="@drawable/search_shadow" + android:layout_below="@+id/toolbar"/> + <!-- TODO(calderwoodra): investigate what this is for and why we want it. --> <!-- Host container for the contact tile drag shadow --> <FrameLayout diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml new file mode 100644 index 000000000..583ad20d5 --- /dev/null +++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_shadow.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2018 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. +--> + +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <gradient + android:startColor="#3333" + android:endColor="#0333" + android:type="linear" + android:angle="90"> + </gradient> +</shape>
\ 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 @@ <com.android.dialer.main.impl.toolbar.MainToolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/dialer_theme_color" 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<ViewHolder> collapseExpandedViewHolder(expandedViewHolder); - Worker<Pair<Context, Uri>, Integer> deleteVoicemail = this::deleteVoicemail; - SuccessListener<Integer> deleteVoicemailCallBack = this::onVoicemailDeleted; + Worker<Pair<Context, Uri>, 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<Context, Uri> contextUriPair) { + private Void deleteVoicemail(Pair<Context, Uri> 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; } /** |