diff options
Diffstat (limited to 'java')
9 files changed, 63 insertions, 73 deletions
diff --git a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java index 364ae6fad..317f24fef 100644 --- a/java/com/android/dialer/app/list/DialtactsPagerAdapter.java +++ b/java/com/android/dialer/app/list/DialtactsPagerAdapter.java @@ -18,7 +18,6 @@ package com.android.dialer.app.list; import android.app.Fragment; import android.app.FragmentManager; -import android.content.Context; import android.support.annotation.IntDef; import android.support.v13.app.FragmentPagerAdapter; import android.view.ViewGroup; @@ -26,11 +25,9 @@ import com.android.dialer.app.calllog.CallLogFragment; import com.android.dialer.app.calllog.VisualVoicemailCallLogFragment; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; -import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.contactsfragment.ContactsFragment; import com.android.dialer.contactsfragment.ContactsFragment.Header; import com.android.dialer.database.CallLogQueryHandler; -import com.android.dialer.speeddial.SpeedDialFragment; import com.android.dialer.util.ViewUtil; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -55,9 +52,7 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { private final List<Fragment> fragments = new ArrayList<>(); private final String[] tabTitles; - private final boolean useNewSpeedDialTab; private OldSpeedDialFragment oldSpeedDialFragment; - private SpeedDialFragment speedDialFragment; private CallLogFragment callLogFragment; private ContactsFragment contactsFragment; private CallLogFragment voicemailFragment; @@ -65,10 +60,8 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { private boolean hasActiveVoicemailProvider; public DialtactsPagerAdapter( - Context context, FragmentManager fm, String[] tabTitles, boolean hasVoicemailProvider) { + FragmentManager fm, String[] tabTitles, boolean hasVoicemailProvider) { super(fm); - useNewSpeedDialTab = - ConfigProviderBindings.get(context).getBoolean("enable_new_favorites_tab", false); this.tabTitles = tabTitles; hasActiveVoicemailProvider = hasVoicemailProvider; fragments.addAll(Collections.nCopies(TAB_COUNT_WITH_VOICEMAIL, null)); @@ -84,17 +77,10 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { LogUtil.d("ViewPagerAdapter.getItem", "position: %d", position); switch (getRtlPosition(position)) { case TAB_INDEX_SPEED_DIAL: - if (useNewSpeedDialTab) { - if (speedDialFragment == null) { - speedDialFragment = SpeedDialFragment.newInstance(); - } - return speedDialFragment; - } else { - if (oldSpeedDialFragment == null) { - oldSpeedDialFragment = new OldSpeedDialFragment(); - } - return oldSpeedDialFragment; + if (oldSpeedDialFragment == null) { + oldSpeedDialFragment = new OldSpeedDialFragment(); } + return oldSpeedDialFragment; case TAB_INDEX_HISTORY: if (callLogFragment == null) { callLogFragment = new CallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL); @@ -128,8 +114,6 @@ public class DialtactsPagerAdapter extends FragmentPagerAdapter { final Fragment fragment = (Fragment) super.instantiateItem(container, position); if (fragment instanceof OldSpeedDialFragment) { oldSpeedDialFragment = (OldSpeedDialFragment) fragment; - } else if (fragment instanceof SpeedDialFragment) { - speedDialFragment = (SpeedDialFragment) fragment; } else if (fragment instanceof CallLogFragment && position == TAB_INDEX_HISTORY) { callLogFragment = (CallLogFragment) fragment; } else if (fragment instanceof ContactsFragment) { diff --git a/java/com/android/dialer/app/list/ListsFragment.java b/java/com/android/dialer/app/list/ListsFragment.java index d314917ef..93e89230b 100644 --- a/java/com/android/dialer/app/list/ListsFragment.java +++ b/java/com/android/dialer/app/list/ListsFragment.java @@ -45,7 +45,6 @@ import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.dialer.logging.UiAction; import com.android.dialer.performancereport.PerformanceReport; -import com.android.dialer.speeddial.SpeedDialFragment; import com.android.dialer.util.PermissionsUtil; import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler; import com.android.dialer.voicemail.listui.error.VoicemailStatusCorruptionHandler.Source; @@ -199,7 +198,6 @@ public class ListsFragment extends Fragment viewPager = (DialerViewPager) parentView.findViewById(R.id.lists_pager); adapter = new DialtactsPagerAdapter( - getContext(), getChildFragmentManager(), tabTitles, prefs.getBoolean( @@ -456,11 +454,10 @@ public class ListsFragment extends Fragment } public boolean hasFrequents() { - Fragment page = - adapter.getItem(adapter.getRtlPosition(DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL)); - return page instanceof OldSpeedDialFragment - ? ((OldSpeedDialFragment) page).hasFrequents() - : ((SpeedDialFragment) page).hasFrequents(); + OldSpeedDialFragment page = + (OldSpeedDialFragment) + adapter.getItem(adapter.getRtlPosition(DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL)); + return page.hasFrequents(); } public RemoveView getRemoveView() { diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index b04e7b11b..dbeed0d69 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -140,7 +140,7 @@ public class MainSearchController implements SearchBarListener { fab.hide(); toolbar.slideUp(animate, fragmentContainer); - toolbar.expand(animate, Optional.absent()); + toolbar.expand(animate, Optional.absent(), /* requestFocus */ false); toolbarShadow.setVisibility(View.VISIBLE); activity.setTitle(R.string.dialpad_activity_title); @@ -390,7 +390,7 @@ public class MainSearchController implements SearchBarListener { Logger.get(activity).logScreenView(ScreenEvent.Type.MAIN_SEARCH, activity); fab.hide(); - toolbar.expand(/* animate=*/ true, query); + toolbar.expand(/* animate=*/ true, query, /* requestFocus */ true); toolbar.showKeyboard(); toolbarShadow.setVisibility(View.VISIBLE); hideBottomNav(); @@ -528,12 +528,15 @@ public class MainSearchController implements SearchBarListener { if (savedInstanceState.getBoolean(KEY_IS_FAB_HIDDEN, false)) { fab.hide(); } - if (savedInstanceState.getBoolean(KEY_IS_TOOLBAR_EXPANDED, false)) { - toolbar.expand(false, Optional.absent()); - } - if (savedInstanceState.getBoolean(KEY_IS_TOOLBAR_SLIDE_UP, false)) { + boolean isSlideUp = savedInstanceState.getBoolean(KEY_IS_TOOLBAR_SLIDE_UP, false); + if (isSlideUp) { toolbar.slideUp(false, fragmentContainer); } + if (savedInstanceState.getBoolean(KEY_IS_TOOLBAR_EXPANDED, false)) { + // If the toolbar is slide up, that means the dialpad is showing. Thus we don't want to + // request focus or we'll break physical/bluetooth keyboards typing. + toolbar.expand(/* animate */ false, Optional.absent(), /* requestFocus */ !isSlideUp); + } } public void addOnSearchShowListener(OnSearchShowListener listener) { diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index 960787972..0ab69a443 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -29,6 +29,7 @@ import com.android.dialer.main.MainActivityPeer; import com.android.dialer.main.impl.bottomnav.BottomNavBar; import com.android.dialer.main.impl.bottomnav.BottomNavBar.OnBottomNavTabSelectedListener; import com.android.dialer.main.impl.bottomnav.BottomNavBar.TabIndex; +import com.android.dialer.speeddial.SpeedDialFragment; import com.android.dialer.voicemail.listui.NewVoicemailFragment; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.MoreExecutors; @@ -89,6 +90,7 @@ public class NewMainActivityPeer implements MainActivityPeer { private static final class MainBottomNavBarBottomNavTabListener implements OnBottomNavTabSelectedListener { + private static final String SPEED_DIAL_TAG = "speed_dial"; private static final String CALL_LOG_TAG = "call_log"; private static final String VOICEMAIL_TAG = "voicemail"; @@ -104,7 +106,16 @@ public class NewMainActivityPeer implements MainActivityPeer { @Override public void onSpeedDialSelected() { hideAllFragments(); - // TODO(calderwoodra): Implement SpeedDialFragment when FragmentUtils#getParent works + SpeedDialFragment fragment = + (SpeedDialFragment) supportFragmentManager.findFragmentByTag(SPEED_DIAL_TAG); + if (fragment == null) { + supportFragmentManager + .beginTransaction() + .add(R.id.fragment_container, SpeedDialFragment.newInstance(), SPEED_DIAL_TAG) + .commit(); + } else { + supportFragmentManager.beginTransaction().show(fragment).commit(); + } } @Override @@ -143,8 +154,14 @@ public class NewMainActivityPeer implements MainActivityPeer { } } + // TODO(calderwoodra): fix overlapping fragments issue private void hideAllFragments() { FragmentTransaction supportTransaction = supportFragmentManager.beginTransaction(); + Fragment speedDialFragment = supportFragmentManager.findFragmentByTag(SPEED_DIAL_TAG); + if (speedDialFragment != null) { + supportTransaction.hide(speedDialFragment); + } + Fragment callLogFragment = supportFragmentManager.findFragmentByTag(CALL_LOG_TAG); if (callLogFragment != null) { if (callLogFragment.isVisible()) { @@ -158,6 +175,7 @@ public class NewMainActivityPeer implements MainActivityPeer { } supportTransaction.hide(callLogFragment); } + if (supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG) != null) { supportTransaction.hide(supportFragmentManager.findFragmentByTag(VOICEMAIL_TAG)); } diff --git a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java index 68876dde5..5e5db2c8c 100644 --- a/java/com/android/dialer/main/impl/toolbar/MainToolbar.java +++ b/java/com/android/dialer/main/impl/toolbar/MainToolbar.java @@ -113,9 +113,9 @@ public final class MainToolbar extends Toolbar implements PopupMenu.OnMenuItemCl searchBar.collapse(animate); } - /** @see SearchBarView#collapse(boolean) */ - public void expand(boolean animate, Optional<String> text) { - searchBar.expand(animate, text); + /** @see SearchBarView#expand(boolean, Optional, boolean) */ + public void expand(boolean animate, Optional<String> text, boolean requestFocus) { + searchBar.expand(animate, text, requestFocus); } public boolean isSlideUp() { diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java index 0cc76598c..8ea94299e 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java @@ -101,13 +101,17 @@ final class SearchBarView extends FrameLayout { listener.onVoiceButtonClicked( result -> { if (!TextUtils.isEmpty(result)) { - expand(true, Optional.of(result)); + expand(/* animate */ true, Optional.of(result), /* requestFocus */ true); } }); } - /** Expand the search bar and populate it with text if any exists. */ - /* package-private */ void expand(boolean animate, Optional<String> text) { + /** + * Expand the search bar and populate it with text if any exists. + * + * @param requestFocus should be false if showing the dialpad + */ + /* package-private */ void expand(boolean animate, Optional<String> text, boolean requestFocus) { if (isExpanded) { return; } @@ -133,7 +137,11 @@ final class SearchBarView extends FrameLayout { if (text.isPresent()) { searchBox.setText(text.get()); } - searchBox.requestFocus(); + // Don't request focus unless we're actually showing the search box, otherwise + // physical/bluetooth keyboards will type into this box when the dialpad is open. + if (requestFocus) { + searchBox.requestFocus(); + } setBackgroundResource(R.drawable.search_bar_background); } }); diff --git a/java/com/android/dialer/speeddial/DisambigDialog.java b/java/com/android/dialer/speeddial/DisambigDialog.java index ca02f41eb..1ee26f595 100644 --- a/java/com/android/dialer/speeddial/DisambigDialog.java +++ b/java/com/android/dialer/speeddial/DisambigDialog.java @@ -16,10 +16,7 @@ package com.android.dialer.speeddial; -import android.app.AlertDialog; import android.app.Dialog; -import android.app.DialogFragment; -import android.app.FragmentManager; import android.content.ContentResolver; import android.content.res.Resources; import android.database.Cursor; @@ -27,6 +24,9 @@ import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.FragmentManager; +import android.support.v7.app.AlertDialog; import android.text.TextUtils; import android.util.ArraySet; import android.view.LayoutInflater; @@ -37,7 +37,6 @@ import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; -import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.duo.DuoComponent; import com.android.dialer.precall.PreCall; import java.util.ArrayList; @@ -48,10 +47,14 @@ import java.util.Set; public class DisambigDialog extends DialogFragment { @VisibleForTesting public static final String DISAMBIG_DIALOG_TAG = "disambig_dialog"; + + @SuppressWarnings("unused") private static final String DISAMBIG_DIALOG_WORKER_TAG = "disambig_dialog_worker"; private final Set<String> phoneNumbers = new ArraySet<>(); private LinearLayout container; + + @SuppressWarnings("unused") private String lookupKey; /** Show a disambiguation dialog for a starred contact without a favorite communication avenue. */ @@ -71,12 +74,6 @@ public class DisambigDialog extends DialogFragment { } @Override - public void onResume() { - super.onResume(); - lookupContactInfo(); - } - - @Override public void onPause() { super.onPause(); // TODO(calderwoodra): for simplicity, just dismiss the dialog on configuration change and @@ -84,19 +81,6 @@ public class DisambigDialog extends DialogFragment { dismiss(); } - private void lookupContactInfo() { - DialerExecutorComponent.get(getContext()) - .dialerExecutorFactory() - .createUiTaskBuilder( - getFragmentManager(), - DISAMBIG_DIALOG_WORKER_TAG, - new LookupContactInfoWorker(getContext().getContentResolver())) - .onSuccess(this::insertOptions) - .onFailure(this::onLookupFailed) - .build() - .executeParallel(lookupKey); - } - /** * Inflates and inserts the following in the dialog: * @@ -106,6 +90,7 @@ public class DisambigDialog extends DialogFragment { * <li>Clickable voice option * </ul> */ + @SuppressWarnings("unused") private void insertOptions(Cursor cursor) { if (!cursorIsValid(cursor)) { dismiss(); @@ -197,11 +182,6 @@ public class DisambigDialog extends DialogFragment { return true; } - private void onLookupFailed(Throwable throwable) { - LogUtil.e("DisambigDialog.onLookupFailed", null, throwable); - insertOptions(null); - } - private static class LookupContactInfoWorker implements Worker<String, Cursor> { static final int NUMBER_INDEX = 0; diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index 979c894fe..03a3c75bf 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -16,13 +16,13 @@ package com.android.dialer.speeddial; -import android.app.Fragment; -import android.app.LoaderManager.LoaderCallbacks; import android.content.Intent; -import android.content.Loader; import android.database.Cursor; import android.os.Bundle; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.LoaderManager.LoaderCallbacks; +import android.support.v4.content.Loader; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; diff --git a/java/com/android/dialer/speeddial/StrequentContactsCursorLoader.java b/java/com/android/dialer/speeddial/StrequentContactsCursorLoader.java index 40d03846f..a2dcfdc40 100644 --- a/java/com/android/dialer/speeddial/StrequentContactsCursorLoader.java +++ b/java/com/android/dialer/speeddial/StrequentContactsCursorLoader.java @@ -17,13 +17,13 @@ package com.android.dialer.speeddial; import android.content.Context; -import android.content.CursorLoader; import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; +import android.support.v4.content.CursorLoader; /** Cursor Loader for strequent contacts. */ public final class StrequentContactsCursorLoader extends CursorLoader { |