From 1407d25aa8f79e6ff5badc2ed8c234827c762a84 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Mon, 5 Feb 2018 17:45:51 -0800 Subject: Updated bottom nav to match redlines. Bug: 72525324 Test: manual PiperOrigin-RevId: 184615350 Change-Id: Ic5701d67111e38f73dfa4be31dd89115ad7f5bb8 --- .../com/android/dialer/main/impl/BottomNavBar.java | 184 --------------------- .../android/dialer/main/impl/BottomNavItem.java | 73 -------- .../com/android/dialer/main/impl/MainActivity.java | 2 +- .../dialer/main/impl/MainSearchController.java | 1 + .../dialer/main/impl/NewMainActivityPeer.java | 5 +- .../dialer/main/impl/OldMainActivityPeer.java | 5 +- .../dialer/main/impl/bottomnav/AndroidManifest.xml | 16 ++ .../dialer/main/impl/bottomnav/BottomNavBar.java | 184 +++++++++++++++++++++ .../dialer/main/impl/bottomnav/BottomNavItem.java | 90 ++++++++++ .../bottomnav/res/drawable/notification_badge.xml | 23 +++ .../bottomnav/res/layout/bottom_nav_bar_layout.xml | 52 ++++++ .../impl/bottomnav/res/layout/bottom_nav_item.xml | 62 +++++++ .../main/impl/bottomnav/res/values/colors.xml | 20 +++ .../main/impl/bottomnav/res/values/dimens.xml | 21 +++ .../main/impl/bottomnav/res/values/strings.xml | 26 +++ .../main/impl/res/drawable/notification_badge.xml | 22 --- .../main/impl/res/layout/bottom_nav_bar_layout.xml | 52 ------ .../main/impl/res/layout/bottom_nav_item.xml | 60 ------- .../android/dialer/main/impl/res/values/colors.xml | 20 --- .../dialer/main/impl/res/values/strings.xml | 9 - 20 files changed, 502 insertions(+), 425 deletions(-) delete mode 100644 java/com/android/dialer/main/impl/BottomNavBar.java delete mode 100644 java/com/android/dialer/main/impl/BottomNavItem.java create mode 100644 java/com/android/dialer/main/impl/bottomnav/AndroidManifest.xml create mode 100644 java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java create mode 100644 java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java create mode 100644 java/com/android/dialer/main/impl/bottomnav/res/drawable/notification_badge.xml create mode 100644 java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_bar_layout.xml create mode 100644 java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml create mode 100644 java/com/android/dialer/main/impl/bottomnav/res/values/colors.xml create mode 100644 java/com/android/dialer/main/impl/bottomnav/res/values/dimens.xml create mode 100644 java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml delete mode 100644 java/com/android/dialer/main/impl/res/drawable/notification_badge.xml delete mode 100644 java/com/android/dialer/main/impl/res/layout/bottom_nav_bar_layout.xml delete mode 100644 java/com/android/dialer/main/impl/res/layout/bottom_nav_item.xml delete mode 100644 java/com/android/dialer/main/impl/res/values/colors.xml (limited to 'java/com') diff --git a/java/com/android/dialer/main/impl/BottomNavBar.java b/java/com/android/dialer/main/impl/BottomNavBar.java deleted file mode 100644 index 97f526251..000000000 --- a/java/com/android/dialer/main/impl/BottomNavBar.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * 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 - */ - -package com.android.dialer.main.impl; - -import android.content.Context; -import android.support.annotation.IntDef; -import android.support.annotation.Nullable; -import android.util.AttributeSet; -import android.view.View; -import android.widget.LinearLayout; -import com.android.dialer.common.Assert; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.ArrayList; -import java.util.List; - -/** Dialer Bottom Nav Bar for {@link MainActivity}. */ -public final class BottomNavBar extends LinearLayout { - - /** Index for each tab in the bottom nav. */ - @Retention(RetentionPolicy.SOURCE) - @IntDef({ - TabIndex.SPEED_DIAL, - TabIndex.CALL_LOG, - TabIndex.CONTACTS, - TabIndex.VOICEMAIL, - }) - public @interface TabIndex { - int SPEED_DIAL = 0; - int CALL_LOG = 1; - int CONTACTS = 2; - int VOICEMAIL = 3; - } - - private final List listeners = new ArrayList<>(); - - private BottomNavItem speedDial; - private BottomNavItem callLog; - private BottomNavItem contacts; - private BottomNavItem voicemail; - private @TabIndex int selectedTab; - - public BottomNavBar(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - speedDial = findViewById(R.id.speed_dial_tab); - callLog = findViewById(R.id.call_log_tab); - contacts = findViewById(R.id.contacts_tab); - voicemail = findViewById(R.id.voicemail_tab); - - speedDial.setup(R.string.tab_title_speed_dial, R.drawable.quantum_ic_star_vd_theme_24); - callLog.setup(R.string.tab_title_call_history, R.drawable.quantum_ic_history_vd_theme_24); - contacts.setup(R.string.tab_title_contacts, R.drawable.quantum_ic_people_vd_theme_24); - voicemail.setup(R.string.tab_title_voicemail, R.drawable.quantum_ic_voicemail_vd_theme_24); - - speedDial.setOnClickListener( - v -> { - selectedTab = TabIndex.SPEED_DIAL; - setSelected(speedDial); - updateListeners(selectedTab); - }); - callLog.setOnClickListener( - v -> { - selectedTab = TabIndex.CALL_LOG; - setSelected(callLog); - updateListeners(selectedTab); - }); - contacts.setOnClickListener( - v -> { - selectedTab = TabIndex.CONTACTS; - setSelected(contacts); - updateListeners(selectedTab); - }); - voicemail.setOnClickListener( - v -> { - selectedTab = TabIndex.VOICEMAIL; - setSelected(voicemail); - updateListeners(selectedTab); - }); - } - - private void setSelected(View view) { - speedDial.setSelected(view == speedDial); - callLog.setSelected(view == callLog); - contacts.setSelected(view == contacts); - voicemail.setSelected(view == voicemail); - } - - /** - * Calls {@link View#performClick()} on the desired tab. - * - * @param tab {@link TabIndex} - */ - void selectTab(@TabIndex int tab) { - if (tab == TabIndex.SPEED_DIAL) { - speedDial.performClick(); - } else if (tab == TabIndex.CALL_LOG) { - callLog.performClick(); - } else if (tab == TabIndex.CONTACTS) { - contacts.performClick(); - } else if (tab == TabIndex.VOICEMAIL) { - voicemail.performClick(); - } else { - throw new IllegalStateException("Invalid tab: " + tab); - } - } - - void setNotificationCount(@TabIndex int tab, int count) { - if (tab == TabIndex.SPEED_DIAL) { - speedDial.setNotificationCount(count); - } else if (tab == TabIndex.CALL_LOG) { - callLog.setNotificationCount(count); - } else if (tab == TabIndex.CONTACTS) { - contacts.setNotificationCount(count); - } else if (tab == TabIndex.VOICEMAIL) { - voicemail.setNotificationCount(count); - } else { - throw new IllegalStateException("Invalid tab: " + tab); - } - } - - void addOnTabSelectedListener(OnBottomNavTabSelectedListener listener) { - listeners.add(listener); - } - - private void updateListeners(@TabIndex int tabIndex) { - for (OnBottomNavTabSelectedListener listener : listeners) { - switch (tabIndex) { - case TabIndex.SPEED_DIAL: - listener.onSpeedDialSelected(); - break; - case TabIndex.CALL_LOG: - listener.onCallLogSelected(); - break; - case TabIndex.CONTACTS: - listener.onContactsSelected(); - break; - case TabIndex.VOICEMAIL: - listener.onVoicemailSelected(); - break; - default: - throw Assert.createIllegalStateFailException("Invalid tab: " + tabIndex); - } - } - } - - public int getSelectedTab() { - return selectedTab; - } - - /** Listener for bottom nav tab's on click events. */ - public interface OnBottomNavTabSelectedListener { - - /** Speed dial tab was clicked. */ - void onSpeedDialSelected(); - - /** Call Log tab was clicked. */ - void onCallLogSelected(); - - /** Contacts tab was clicked. */ - void onContactsSelected(); - - /** Voicemail tab was clicked. */ - void onVoicemailSelected(); - } -} diff --git a/java/com/android/dialer/main/impl/BottomNavItem.java b/java/com/android/dialer/main/impl/BottomNavItem.java deleted file mode 100644 index af7399b6c..000000000 --- a/java/com/android/dialer/main/impl/BottomNavItem.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 - */ - -package com.android.dialer.main.impl; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.support.annotation.DrawableRes; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; -import android.util.AttributeSet; -import android.view.View; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; -import com.android.dialer.common.Assert; - -/** Navigation item in a bottom nav. */ -final class BottomNavItem extends LinearLayout { - - private ImageView image; - private TextView text; - private TextView notificationBadge; - - public BottomNavItem(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - image = findViewById(R.id.bottom_nav_item_image); - text = findViewById(R.id.bottom_nav_item_text); - notificationBadge = findViewById(R.id.notification_badge); - } - - @Override - public void setSelected(boolean selected) { - super.setSelected(selected); - int colorId = selected ? R.color.bottom_nav_icon_selected : R.color.bottom_nav_icon_deselected; - int color = getContext().getColor(colorId); - image.setImageTintList(ColorStateList.valueOf(color)); - text.setTextColor(color); - } - - void setup(@StringRes int stringRes, @DrawableRes int drawableRes) { - text.setText(stringRes); - image.setImageResource(drawableRes); - } - - void setNotificationCount(int count) { - Assert.checkArgument(count >= 0, "Invalid count: " + count); - if (count == 0) { - notificationBadge.setVisibility(View.GONE); - } else { - notificationBadge.setVisibility(View.VISIBLE); - notificationBadge.setText(String.format(Integer.toString(count))); - } - } -} diff --git a/java/com/android/dialer/main/impl/MainActivity.java b/java/com/android/dialer/main/impl/MainActivity.java index 24c3df575..85f9c9f4b 100644 --- a/java/com/android/dialer/main/impl/MainActivity.java +++ b/java/com/android/dialer/main/impl/MainActivity.java @@ -26,7 +26,7 @@ import com.android.dialer.interactions.PhoneNumberInteraction.DisambigDialogDism import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorCode; import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorListener; import com.android.dialer.main.MainActivityPeer; -import com.android.dialer.main.impl.BottomNavBar.TabIndex; +import com.android.dialer.main.impl.bottomnav.BottomNavBar.TabIndex; import com.android.dialer.util.TransactionSafeActivity; /** This is the main activity for dialer. It hosts favorites, call log, search, dialpad, etc... */ diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 62ecc5389..0296ec911 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -36,6 +36,7 @@ import com.android.dialer.constants.ActivityRequestCodes; import com.android.dialer.dialpadview.DialpadFragment; import com.android.dialer.dialpadview.DialpadFragment.DialpadListener; import com.android.dialer.dialpadview.DialpadFragment.OnDialpadQueryChangedListener; +import com.android.dialer.main.impl.bottomnav.BottomNavBar; import com.android.dialer.main.impl.toolbar.MainToolbar; import com.android.dialer.main.impl.toolbar.SearchBarListener; import com.android.dialer.searchfragment.list.NewSearchFragment; diff --git a/java/com/android/dialer/main/impl/NewMainActivityPeer.java b/java/com/android/dialer/main/impl/NewMainActivityPeer.java index cc4c3e7fd..789648928 100644 --- a/java/com/android/dialer/main/impl/NewMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/NewMainActivityPeer.java @@ -22,8 +22,9 @@ import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import com.android.dialer.calllog.ui.NewCallLogFragment; import com.android.dialer.main.MainActivityPeer; -import com.android.dialer.main.impl.BottomNavBar.OnBottomNavTabSelectedListener; -import com.android.dialer.main.impl.BottomNavBar.TabIndex; +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.voicemail.listui.NewVoicemailFragment; /** MainActivityPeer that implements the new fragments. */ diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index dd766d087..a27bdd23a 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -67,8 +67,9 @@ import com.android.dialer.dialpadview.DialpadFragment.LastOutgoingCallCallback; import com.android.dialer.dialpadview.DialpadFragment.OnDialpadQueryChangedListener; import com.android.dialer.interactions.PhoneNumberInteraction; import com.android.dialer.main.MainActivityPeer; -import com.android.dialer.main.impl.BottomNavBar.OnBottomNavTabSelectedListener; -import com.android.dialer.main.impl.BottomNavBar.TabIndex; +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.main.impl.toolbar.MainToolbar; import com.android.dialer.postcall.PostCall; import com.android.dialer.precall.PreCall; diff --git a/java/com/android/dialer/main/impl/bottomnav/AndroidManifest.xml b/java/com/android/dialer/main/impl/bottomnav/AndroidManifest.xml new file mode 100644 index 000000000..9b970f203 --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/AndroidManifest.xml @@ -0,0 +1,16 @@ + + diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java new file mode 100644 index 000000000..a580aee68 --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavBar.java @@ -0,0 +1,184 @@ +/* + * 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 + */ + +package com.android.dialer.main.impl.bottomnav; + +import android.content.Context; +import android.support.annotation.IntDef; +import android.support.annotation.Nullable; +import android.util.AttributeSet; +import android.view.View; +import android.widget.LinearLayout; +import com.android.dialer.common.Assert; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; +import java.util.List; + +/** Dialer Bottom Nav Bar for {@link MainActivity}. */ +public final class BottomNavBar extends LinearLayout { + + /** Index for each tab in the bottom nav. */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({ + TabIndex.SPEED_DIAL, + TabIndex.CALL_LOG, + TabIndex.CONTACTS, + TabIndex.VOICEMAIL, + }) + public @interface TabIndex { + int SPEED_DIAL = 0; + int CALL_LOG = 1; + int CONTACTS = 2; + int VOICEMAIL = 3; + } + + private final List listeners = new ArrayList<>(); + + private BottomNavItem speedDial; + private BottomNavItem callLog; + private BottomNavItem contacts; + private BottomNavItem voicemail; + private @TabIndex int selectedTab; + + public BottomNavBar(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + speedDial = findViewById(R.id.speed_dial_tab); + callLog = findViewById(R.id.call_log_tab); + contacts = findViewById(R.id.contacts_tab); + voicemail = findViewById(R.id.voicemail_tab); + + speedDial.setup(R.string.tab_title_speed_dial, R.drawable.quantum_ic_star_vd_theme_24); + callLog.setup(R.string.tab_title_call_history, R.drawable.quantum_ic_access_time_vd_theme_24); + contacts.setup(R.string.tab_title_contacts, R.drawable.quantum_ic_people_vd_theme_24); + voicemail.setup(R.string.tab_title_voicemail, R.drawable.quantum_ic_voicemail_vd_theme_24); + + speedDial.setOnClickListener( + v -> { + selectedTab = TabIndex.SPEED_DIAL; + setSelected(speedDial); + updateListeners(selectedTab); + }); + callLog.setOnClickListener( + v -> { + selectedTab = TabIndex.CALL_LOG; + setSelected(callLog); + updateListeners(selectedTab); + }); + contacts.setOnClickListener( + v -> { + selectedTab = TabIndex.CONTACTS; + setSelected(contacts); + updateListeners(selectedTab); + }); + voicemail.setOnClickListener( + v -> { + selectedTab = TabIndex.VOICEMAIL; + setSelected(voicemail); + updateListeners(selectedTab); + }); + } + + private void setSelected(View view) { + speedDial.setSelected(view == speedDial); + callLog.setSelected(view == callLog); + contacts.setSelected(view == contacts); + voicemail.setSelected(view == voicemail); + } + + /** + * Calls {@link View#performClick()} on the desired tab. + * + * @param tab {@link TabIndex} + */ + public void selectTab(@TabIndex int tab) { + if (tab == TabIndex.SPEED_DIAL) { + speedDial.performClick(); + } else if (tab == TabIndex.CALL_LOG) { + callLog.performClick(); + } else if (tab == TabIndex.CONTACTS) { + contacts.performClick(); + } else if (tab == TabIndex.VOICEMAIL) { + voicemail.performClick(); + } else { + throw new IllegalStateException("Invalid tab: " + tab); + } + } + + public void setNotificationCount(@TabIndex int tab, int count) { + if (tab == TabIndex.SPEED_DIAL) { + speedDial.setNotificationCount(count); + } else if (tab == TabIndex.CALL_LOG) { + callLog.setNotificationCount(count); + } else if (tab == TabIndex.CONTACTS) { + contacts.setNotificationCount(count); + } else if (tab == TabIndex.VOICEMAIL) { + voicemail.setNotificationCount(count); + } else { + throw new IllegalStateException("Invalid tab: " + tab); + } + } + + public void addOnTabSelectedListener(OnBottomNavTabSelectedListener listener) { + listeners.add(listener); + } + + private void updateListeners(@TabIndex int tabIndex) { + for (OnBottomNavTabSelectedListener listener : listeners) { + switch (tabIndex) { + case TabIndex.SPEED_DIAL: + listener.onSpeedDialSelected(); + break; + case TabIndex.CALL_LOG: + listener.onCallLogSelected(); + break; + case TabIndex.CONTACTS: + listener.onContactsSelected(); + break; + case TabIndex.VOICEMAIL: + listener.onVoicemailSelected(); + break; + default: + throw Assert.createIllegalStateFailException("Invalid tab: " + tabIndex); + } + } + } + + public int getSelectedTab() { + return selectedTab; + } + + /** Listener for bottom nav tab's on click events. */ + public interface OnBottomNavTabSelectedListener { + + /** Speed dial tab was clicked. */ + void onSpeedDialSelected(); + + /** Call Log tab was clicked. */ + void onCallLogSelected(); + + /** Contacts tab was clicked. */ + void onContactsSelected(); + + /** Voicemail tab was clicked. */ + void onVoicemailSelected(); + } +} diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java new file mode 100644 index 000000000..2c1b4f5d7 --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java @@ -0,0 +1,90 @@ +/* + * 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 + */ + +package com.android.dialer.main.impl.bottomnav; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.support.annotation.DrawableRes; +import android.support.annotation.Nullable; +import android.support.annotation.Px; +import android.support.annotation.StringRes; +import android.util.AttributeSet; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import com.android.dialer.common.Assert; + +/** Navigation item in a bottom nav. */ +final class BottomNavItem extends LinearLayout { + + private ImageView image; + private TextView text; + private TextView notificationBadge; + + public BottomNavItem(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + image = findViewById(R.id.bottom_nav_item_image); + text = findViewById(R.id.bottom_nav_item_text); + notificationBadge = findViewById(R.id.notification_badge); + } + + @Override + public void setSelected(boolean selected) { + super.setSelected(selected); + int colorId = selected ? R.color.bottom_nav_icon_selected : R.color.bottom_nav_icon_deselected; + int color = getContext().getColor(colorId); + image.setImageTintList(ColorStateList.valueOf(color)); + text.setTextColor(color); + } + + void setup(@StringRes int stringRes, @DrawableRes int drawableRes) { + text.setText(stringRes); + image.setImageResource(drawableRes); + } + + void setNotificationCount(int count) { + Assert.checkArgument(count >= 0, "Invalid count: " + count); + if (count == 0) { + notificationBadge.setVisibility(View.INVISIBLE); + } else { + String countString = count > 99 ? "99+" : String.format(Integer.toString(count)); + notificationBadge.setVisibility(View.VISIBLE); + notificationBadge.setText(countString); + + @Px int margin; + if (countString.length() == 1) { + margin = getContext().getResources().getDimensionPixelSize(R.dimen.badge_margin_length_1); + } else if (countString.length() == 2) { + margin = getContext().getResources().getDimensionPixelSize(R.dimen.badge_margin_length_2); + } else { + margin = getContext().getResources().getDimensionPixelSize(R.dimen.badge_margin_length_3); + } + + FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) image.getLayoutParams(); + params.setMarginStart(margin); + params.setMarginEnd(margin); + image.setLayoutParams(params); + } + } +} diff --git a/java/com/android/dialer/main/impl/bottomnav/res/drawable/notification_badge.xml b/java/com/android/dialer/main/impl/bottomnav/res/drawable/notification_badge.xml new file mode 100644 index 000000000..67e3f375d --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/res/drawable/notification_badge.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_bar_layout.xml b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_bar_layout.xml new file mode 100644 index 000000000..02ba3abd5 --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_bar_layout.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml new file mode 100644 index 000000000..5dddd3de5 --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/bottomnav/res/values/colors.xml b/java/com/android/dialer/main/impl/bottomnav/res/values/colors.xml new file mode 100644 index 000000000..b858b4f8c --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/res/values/colors.xml @@ -0,0 +1,20 @@ + + + + @color/dialer_theme_color + @color/dialer_secondary_text_color + diff --git a/java/com/android/dialer/main/impl/bottomnav/res/values/dimens.xml b/java/com/android/dialer/main/impl/bottomnav/res/values/dimens.xml new file mode 100644 index 000000000..8fd376bda --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/res/values/dimens.xml @@ -0,0 +1,21 @@ + + + + 10dp + 14dp + 22dp + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml b/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml new file mode 100644 index 000000000..ca5db1f49 --- /dev/null +++ b/java/com/android/dialer/main/impl/bottomnav/res/values/strings.xml @@ -0,0 +1,26 @@ + + + + + Recents + + Favorites + + Voicemail + + Contacts + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/res/drawable/notification_badge.xml b/java/com/android/dialer/main/impl/res/drawable/notification_badge.xml deleted file mode 100644 index 2d0dafe93..000000000 --- a/java/com/android/dialer/main/impl/res/drawable/notification_badge.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/res/layout/bottom_nav_bar_layout.xml b/java/com/android/dialer/main/impl/res/layout/bottom_nav_bar_layout.xml deleted file mode 100644 index 67c1a20df..000000000 --- a/java/com/android/dialer/main/impl/res/layout/bottom_nav_bar_layout.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/res/layout/bottom_nav_item.xml b/java/com/android/dialer/main/impl/res/layout/bottom_nav_item.xml deleted file mode 100644 index 2d9998af2..000000000 --- a/java/com/android/dialer/main/impl/res/layout/bottom_nav_item.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/res/values/colors.xml b/java/com/android/dialer/main/impl/res/values/colors.xml deleted file mode 100644 index 3d348653c..000000000 --- a/java/com/android/dialer/main/impl/res/values/colors.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - #FFFFFF - #B2FFFFFF - diff --git a/java/com/android/dialer/main/impl/res/values/strings.xml b/java/com/android/dialer/main/impl/res/values/strings.xml index 0fc1246d6..c842beeff 100644 --- a/java/com/android/dialer/main/impl/res/values/strings.xml +++ b/java/com/android/dialer/main/impl/res/values/strings.xml @@ -38,15 +38,6 @@ View Contacts - - Call History - - Speed Dial - - Voicemail - - Contacts - Voice search not available -- cgit v1.2.3 From 130b616419ea7e63c9a98dc7eacc73ff1add6b3a Mon Sep 17 00:00:00 2001 From: zachh Date: Mon, 5 Feb 2018 17:46:14 -0800 Subject: Don't set the "incomplete" bit for empty numbers. There will never be contact information for an empty number, so don't bother trying to look them up at render time. This also prevents a crash in the new voicemail fragment that occurs due to an assertion that voicemail rows will never be incomplete, when it may be possible for a voicemail to exist with an empty number. Also, don't set short numbers in VoicemailPopulator, since we don't expect this to be possible and would like to avoid crashing in the aforementioned assertion when using simulator. Test: unit PiperOrigin-RevId: 184615402 Change-Id: I5286112b57179e002f04de81c04475f30b3e1833 --- .../dialer/databasepopulator/VoicemailPopulator.java | 7 ------- .../dialer/phonelookup/cp2/Cp2LocalPhoneLookup.java | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'java/com') diff --git a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java index 97f6b0a32..2300150f4 100644 --- a/java/com/android/dialer/databasepopulator/VoicemailPopulator.java +++ b/java/com/android/dialer/databasepopulator/VoicemailPopulator.java @@ -72,13 +72,6 @@ public final class VoicemailPopulator { .setDurationSeconds(0) .setPhoneAccountComponentName(componentName) .setIsRead(true), - // Short number. - Voicemail.builder() - .setPhoneNumber("711") - .setTranscription("This is a short voicemail.") - .setDurationSeconds(12) - .setPhoneAccountComponentName(componentName) - .setIsRead(true), }; @WorkerThread diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2LocalPhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2LocalPhoneLookup.java index 95b14a41d..e051f473c 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2LocalPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2LocalPhoneLookup.java @@ -495,10 +495,18 @@ public final class Cp2LocalPhoneLookup implements PhoneLookup { } else if (deletedPhoneNumbers.contains(dialerPhoneNumber)) { infoBuilder.clear(); } else if (unprocessableNumbers.contains(dialerPhoneNumber)) { - // Don't clear the existing info when the number is unprocessable. It's - // likely that the existing info is up-to-date so keep it in place so that - // the UI doesn't pop when the query is completed at display time. - infoBuilder.setIsIncomplete(true); + // Don't ever set the "incomplete" bit for numbers which are empty; this + // causes unnecessary render time work because there will never be contact + // information for an empty number. It is also required to pass the + // assertion check in the new voicemail fragment, which verifies that no + // voicemails rows are considered "incomplete" (the voicemail fragment + // does not have the ability to fetch information at render time). + if (!dialerPhoneNumber.getNormalizedNumber().isEmpty()) { + // Don't clear the existing info when the number is unprocessable. It's + // likely that the existing info is up-to-date so keep it in place so + // that the UI doesn't pop when the query is completed at display time. + infoBuilder.setIsIncomplete(true); + } } // If the DialerPhoneNumber didn't change, add the unchanged existing info. -- cgit v1.2.3