diff options
18 files changed, 435 insertions, 93 deletions
diff --git a/assets/quantum/res/drawable/quantum_ic_call_made_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_call_made_vd_theme_24.xml new file mode 100644 index 000000000..60692272b --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_call_made_vd_theme_24.xml @@ -0,0 +1,25 @@ +<!-- + ~ 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 + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="@android:color/white" + android:pathData="M9,5v2h6.59L4,18.59 5.41,20 17,8.41V15h2V5z"/> +</vector> diff --git a/assets/quantum/res/drawable/quantum_ic_call_missed_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_call_missed_vd_theme_24.xml new file mode 100644 index 000000000..657dbf56a --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_call_missed_vd_theme_24.xml @@ -0,0 +1,25 @@ +<!-- + ~ 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 + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="@android:color/white" + android:pathData="M19.59,7L12,14.59 6.41,9H11V7H3v8h2v-4.59l7,7 9,-9z"/> +</vector> diff --git a/assets/quantum/res/drawable/quantum_ic_call_received_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_call_received_vd_theme_24.xml new file mode 100644 index 000000000..a4895325a --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_call_received_vd_theme_24.xml @@ -0,0 +1,25 @@ +<!-- + ~ 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 + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="@android:color/white" + android:pathData="M20,5.41L18.59,4 7,15.59V9H5v10h10v-2H8.41z"/> +</vector> diff --git a/assets/quantum/res/drawable/quantum_ic_signal_wifi_4_bar_vd_theme_24.xml b/assets/quantum/res/drawable/quantum_ic_signal_wifi_4_bar_vd_theme_24.xml new file mode 100644 index 000000000..8f0b0d213 --- /dev/null +++ b/assets/quantum/res/drawable/quantum_ic_signal_wifi_4_bar_vd_theme_24.xml @@ -0,0 +1,25 @@ +<!-- + ~ 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 + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="@android:color/white" + android:pathData="M12.01,21.49L23.64,7c-0.45,-0.34 -4.93,-4 -11.64,-4C5.28,3 0.81,6.66 0.36,7l11.63,14.49 0.01,0.01 0.01,-0.01z"/> +</vector> diff --git a/java/com/android/dialer/app/MainComponent.java b/java/com/android/dialer/app/MainComponent.java index b19ad908e..9d328491d 100644 --- a/java/com/android/dialer/app/MainComponent.java +++ b/java/com/android/dialer/app/MainComponent.java @@ -46,6 +46,16 @@ public class MainComponent { } } + public static boolean isNuiComponentEnabled(Context context) { + if (!isNewUiEnabled(context)) { + return false; + } + return context + .getPackageManager() + .getComponentEnabledSetting(new ComponentName(context, getComponentName())) + == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; + } + /** * Enables the NUI activity component. By default the component is disabled and can't be accessed. * Once the component has been enabled the user will get an option to use the new UI to handle @@ -55,7 +65,7 @@ public class MainComponent { context .getPackageManager() .setComponentEnabledSetting( - new ComponentName(context, "com.android.dialer.main.impl.MainActivity"), + new ComponentName(context, getComponentName()), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); } @@ -87,9 +97,21 @@ public class MainComponent { */ public static Intent getIntent(Context context) { Intent intent = new Intent(); - intent.setComponent(new ComponentName(context, "com.android.dialer.main.impl.MainActivity")); + intent.setComponent(new ComponentName(context, getComponentName())); intent.setAction(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; } + + public static Intent getShowCallLogIntent(Context context) { + Intent intent = new Intent(); + intent.setComponent(new ComponentName(context, getComponentName())); + intent.setAction("ACTION_SHOW_TAB"); + intent.putExtra("EXTRA_SHOW_TAB", 1); + return intent; + } + + private static String getComponentName() { + return "com.android.dialer.main.impl.MainActivity"; + } } diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index b8ec168f6..51df70219 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -85,6 +85,7 @@ import com.android.dialer.logging.ContactSource; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.UiAction; +import com.android.dialer.main.MainActivityPeer; import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.phonenumbercache.CallLogQuery; import com.android.dialer.phonenumbercache.ContactInfo; @@ -382,10 +383,11 @@ public class CallLogAdapter extends GroupingListAdapter if (activityType == ACTIVITY_TYPE_DIALTACTS) { if (v.getContext() instanceof CallLogFragmentListener) { ((CallLogFragmentListener) v.getContext()).updateTabUnreadCounts(); - } else if (v.getContext() instanceof FragmentUtilListener) { + } else if (v.getContext() instanceof MainActivityPeer.PeerSupplier) { // This is really bad, but we must do this to prevent a dependency cycle, enforce // best practices in new code, and avoid refactoring DialtactsActivity. - ((FragmentUtilListener) v.getContext()) + ((FragmentUtilListener) + ((MainActivityPeer.PeerSupplier) v.getContext()).getPeer()) .getImpl(CallLogFragmentListener.class) .updateTabUnreadCounts(); } else { diff --git a/java/com/android/dialer/app/calllog/MissedCallNotifier.java b/java/com/android/dialer/app/calllog/MissedCallNotifier.java index dd92bb4e2..417f8f0f9 100644 --- a/java/com/android/dialer/app/calllog/MissedCallNotifier.java +++ b/java/com/android/dialer/app/calllog/MissedCallNotifier.java @@ -43,6 +43,7 @@ import android.util.ArraySet; import com.android.contacts.common.ContactsUtils; import com.android.contacts.common.compat.PhoneNumberUtilsCompat; import com.android.dialer.app.DialtactsActivity; +import com.android.dialer.app.MainComponent; import com.android.dialer.app.R; import com.android.dialer.app.calllog.CallLogNotificationsQueryHelper.NewCall; import com.android.dialer.app.contactinfo.ContactPhotoLoader; @@ -470,8 +471,13 @@ public class MissedCallNotifier implements Worker<Pair<Integer, String>, Void> { * @param callUri Uri of the call to jump to. May be null */ private PendingIntent createCallLogPendingIntent(@Nullable Uri callUri) { - Intent contentIntent = - DialtactsActivity.getShowTabIntent(context, DialtactsPagerAdapter.TAB_INDEX_HISTORY); + Intent contentIntent; + if (MainComponent.isNuiComponentEnabled(context)) { + contentIntent = MainComponent.getShowCallLogIntent(context); + } else { + contentIntent = + DialtactsActivity.getShowTabIntent(context, DialtactsPagerAdapter.TAB_INDEX_HISTORY); + } // TODO (a bug): scroll to call contentIntent.setData(callUri); return PendingIntent.getActivity(context, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java index ab9429951..ee114b5f9 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java @@ -17,9 +17,11 @@ package com.android.dialer.calllog.ui; import android.content.Context; import android.content.Intent; +import android.content.res.ColorStateList; import android.database.Cursor; import android.net.Uri; import android.provider.CallLog.Calls; +import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; @@ -32,8 +34,8 @@ import com.android.dialer.calllog.ui.menu.NewCallLogMenu; import com.android.dialer.calllogutils.CallLogContactTypes; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; -import com.android.dialer.calllogutils.CallTypeIconsView; import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.compat.AppCompatConstants; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.contactphoto.NumberAttributeConverter; @@ -49,10 +51,13 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { private final Context context; private final TextView primaryTextView; + private final TextView callCountTextView; private final TextView secondaryTextView; private final QuickContactBadge quickContactBadge; - private final CallTypeIconsView primaryCallTypeIconsView; // Used for Wifi, HD icons - private final CallTypeIconsView secondaryCallTypeIconsView; // Used for call types + private final ImageView callTypeIcon; + private final ImageView hdIcon; + private final ImageView wifiIcon; + private final ImageView assistedDialIcon; private final TextView phoneAccountView; private final ImageView menuButton; @@ -66,10 +71,13 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { super(view); this.context = view.getContext(); primaryTextView = view.findViewById(R.id.primary_text); + callCountTextView = view.findViewById(R.id.call_count); secondaryTextView = view.findViewById(R.id.secondary_text); quickContactBadge = view.findViewById(R.id.quick_contact_photo); - primaryCallTypeIconsView = view.findViewById(R.id.primary_call_type_icons); - secondaryCallTypeIconsView = view.findViewById(R.id.secondary_call_type_icons); + callTypeIcon = view.findViewById(R.id.call_type_icon); + hdIcon = view.findViewById(R.id.hd_icon); + wifiIcon = view.findViewById(R.id.wifi_icon); + assistedDialIcon = view.findViewById(R.id.assisted_dial_icon); phoneAccountView = view.findViewById(R.id.phone_account); menuButton = view.findViewById(R.id.menu_button); @@ -103,27 +111,32 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { if (isNewMissedCall(row)) { primaryTextView.setTextAppearance(R.style.primary_textview_new_call); - // TODO(zachh): Styling for call type icons when the call is new. + callCountTextView.setTextAppearance(R.style.primary_textview_new_call); secondaryTextView.setTextAppearance(R.style.secondary_textview_new_call); + phoneAccountView.setTextAppearance(R.style.phoneaccount_textview_new_call); } else { primaryTextView.setTextAppearance(R.style.primary_textview); + callCountTextView.setTextAppearance(R.style.primary_textview); secondaryTextView.setTextAppearance(R.style.secondary_textview); + phoneAccountView.setTextAppearance(R.style.phoneaccount_textview); } setNumberCalls(row); setPhoto(row); - setPrimaryCallTypes(row); - setSecondaryCallTypes(row); + setFeatureIcons(row); + setCallTypeIcon(row); setPhoneAccounts(row); setOnClickListenerForRow(row); setOnClickListenerForMenuButon(row); } private void setNumberCalls(CoalescedRow row) { - // TODO(zachh): Number of calls shouldn't be text, but a circle with a number inside. int numberCalls = row.coalescedIds().getCoalescedIdCount(); if (numberCalls > 1) { - primaryTextView.append(String.format(Locale.getDefault(), " (%d)", numberCalls)); + callCountTextView.setText(String.format(Locale.getDefault(), "(%d)", numberCalls)); + callCountTextView.setVisibility(View.VISIBLE); + } else { + callCountTextView.setVisibility(View.GONE); } } @@ -149,22 +162,75 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { return TextUtils.isEmpty(uri) ? null : Uri.parse(uri); } - private void setPrimaryCallTypes(CoalescedRow row) { - primaryCallTypeIconsView.setShowHd( - (row.features() & Calls.FEATURES_HD_CALL) == Calls.FEATURES_HD_CALL); - primaryCallTypeIconsView.setShowWifi( - MotorolaUtils.shouldShowWifiIconInCallLog(context, row.features())); - primaryCallTypeIconsView.setShowAssistedDialed( - (row.features() & TelephonyManagerCompat.FEATURES_ASSISTED_DIALING) - == TelephonyManagerCompat.FEATURES_ASSISTED_DIALING); + private void setFeatureIcons(CoalescedRow row) { + ColorStateList colorStateList = + ColorStateList.valueOf( + context.getColor( + isNewMissedCall(row) + ? R.color.feature_icon_unread_color + : R.color.feature_icon_read_color)); + + // Handle HD Icon + if ((row.features() & Calls.FEATURES_HD_CALL) == Calls.FEATURES_HD_CALL) { + hdIcon.setVisibility(View.VISIBLE); + hdIcon.setImageTintList(colorStateList); + } else { + hdIcon.setVisibility(View.GONE); + } + + // Handle Wifi Icon + if (MotorolaUtils.shouldShowWifiIconInCallLog(context, row.features())) { + wifiIcon.setVisibility(View.VISIBLE); + wifiIcon.setImageTintList(colorStateList); + } else { + wifiIcon.setVisibility(View.GONE); + } + + // Handle Assisted Dialing Icon + if ((row.features() & TelephonyManagerCompat.FEATURES_ASSISTED_DIALING) + == TelephonyManagerCompat.FEATURES_ASSISTED_DIALING) { + assistedDialIcon.setVisibility(View.VISIBLE); + assistedDialIcon.setImageTintList(colorStateList); + } else { + assistedDialIcon.setVisibility(View.GONE); + } } - private void setSecondaryCallTypes(CoalescedRow row) { - // Only call type icon is shown before the secondary text. - secondaryCallTypeIconsView.clear(); - secondaryCallTypeIconsView.add(row.callType()); + private void setCallTypeIcon(CoalescedRow row) { + @DrawableRes int resId; + switch (row.callType()) { + case AppCompatConstants.CALLS_INCOMING_TYPE: + case AppCompatConstants.CALLS_ANSWERED_EXTERNALLY_TYPE: + resId = R.drawable.quantum_ic_call_received_vd_theme_24; + break; + case AppCompatConstants.CALLS_OUTGOING_TYPE: + resId = R.drawable.quantum_ic_call_made_vd_theme_24; + break; + case AppCompatConstants.CALLS_MISSED_TYPE: + resId = R.drawable.quantum_ic_call_missed_vd_theme_24; + break; + case AppCompatConstants.CALLS_VOICEMAIL_TYPE: + throw new IllegalStateException("Voicemails not expected in call log"); + case AppCompatConstants.CALLS_BLOCKED_TYPE: + resId = R.drawable.quantum_ic_block_vd_theme_24; + break; + default: + // It is possible for users to end up with calls with unknown call types in their + // call history, possibly due to 3rd party call log implementations (e.g. to + // distinguish between rejected and missed calls). Instead of crashing, just + // assume that all unknown call types are missed calls. + resId = R.drawable.quantum_ic_call_missed_vd_theme_24; + break; + } + callTypeIcon.setImageResource(resId); - // TODO(zachh): Per new mocks, may need to add method to CallTypeIconsView to disable coloring. + if (isNewMissedCall(row)) { + callTypeIcon.setImageTintList( + ColorStateList.valueOf(context.getColor(R.color.call_type_icon_unread_color))); + } else { + callTypeIcon.setImageTintList( + ColorStateList.valueOf(context.getColor(R.color.call_type_icon_read_color))); + } } private void setPhoneAccounts(CoalescedRow row) { @@ -172,6 +238,8 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { phoneAccountView.setText(row.phoneAccountLabel()); phoneAccountView.setTextColor(row.phoneAccountColor()); phoneAccountView.setVisibility(View.VISIBLE); + } else { + phoneAccountView.setVisibility(View.GONE); } } diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml index 77ba68124..093f866fc 100644 --- a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml +++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_entry.xml @@ -19,33 +19,31 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/call_log_entry_top_margin" - android:paddingTop="@dimen/call_log_entry_padding_top_start" - android:paddingBottom="@dimen/call_log_entry_padding_bottom_end" - android:paddingStart="@dimen/call_log_entry_padding_top_start" - android:paddingEnd="@dimen/call_log_entry_padding_bottom_end" - android:gravity="center_vertical"> + android:minHeight="72dp"> <QuickContactBadge android:id="@+id/quick_contact_photo" - android:layout_width="@dimen/call_log_entry_photo_size" - android:layout_height="@dimen/call_log_entry_photo_size" + android:layout_width="40dp" + android:layout_height="40dp" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" android:layout_centerVertical="true" - android:padding="@dimen/call_log_entry_photo_padding" android:focusable="true"/> - <LinearLayout + <!-- The frame layout is necessary to avoid clipping the icons and ellipsize the text when the + content is too wide to fit. + --> + <FrameLayout + android:id="@+id/primary_row" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerVertical="true" android:layout_toEndOf="@+id/quick_contact_photo" - android:layout_toStartOf="@+id/menu_button" - android:orientation="vertical"> + android:layout_toStartOf="@+id/menu_button"> - <!-- TODO(zachh): Optimize this layout --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginTop="14dp" android:orientation="horizontal"> <TextView @@ -53,57 +51,95 @@ style="@style/PrimaryText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/> + android:layout_weight="1" + android:layout_marginEnd="6dp" + android:ellipsize="end" + android:lineSpacingMultiplier="1.5" + android:singleLine="true"/> - <!-- HD and Wifi icons are shown adjacent to primary text. Call types are shown adjacent to - secondary text (below). --> - <com.android.dialer.calllogutils.CallTypeIconsView - android:id="@+id/primary_call_type_icons" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="12dp" - android:layout_gravity="center_vertical"/> - </LinearLayout> + <ImageView + android:id="@+id/hd_icon" + android:layout_width="wrap_content" + android:layout_height="18dp" + android:layout_gravity="center_vertical" + android:src="@drawable/quantum_ic_hd_vd_theme_24" + /> - <!-- TODO(zachh): Optimize this layout --> - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal"> + <ImageView + android:id="@+id/wifi_icon" + android:layout_width="wrap_content" + android:layout_height="18dp" + android:layout_gravity="center_vertical" + android:src="@drawable/quantum_ic_signal_wifi_4_bar_vd_theme_24" + /> - <!-- Only call types are shown adjacent to secondary text. HD and Wifi icons are shown - adjacent to primary text (above). --> - <com.android.dialer.calllogutils.CallTypeIconsView - android:id="@+id/secondary_call_type_icons" + <ImageView + android:id="@+id/assisted_dial_icon" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="12dp" - android:layout_gravity="center_vertical"/> + android:layout_height="18dp" + android:layout_gravity="center_vertical" + android:src="@drawable/quantum_ic_language_vd_theme_24" + /> <TextView - android:id="@+id/secondary_text" - style="@style/SecondaryText" + android:id="@+id/call_count" + style="@style/PrimaryText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/call_log_entry_photo_text_margin"/> + android:layout_marginEnd="6dp" + android:lineSpacingMultiplier="1.5"/> + </LinearLayout> + </FrameLayout> + + <LinearLayout + android:id="@+id/secondary_row" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/primary_row" + android:layout_toEndOf="@+id/quick_contact_photo" + android:orientation="horizontal"> + + <ImageView + android:id="@+id/call_type_icon" + android:layout_width="wrap_content" + android:layout_height="18dp" + android:layout_gravity="center_vertical" + /> <TextView - android:id="@+id/phone_account" + android:id="@+id/secondary_text" style="@style/SecondaryText" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/call_log_entry_photo_text_margin" - android:visibility="gone"/> + android:ellipsize="end" + android:lineSpacingMultiplier="1.4" + android:singleLine="true"/> </LinearLayout> + <TextView + android:id="@+id/phone_account" + style="@style/SecondaryText" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@+id/secondary_row" + android:layout_toEndOf="@+id/quick_contact_photo" + android:ellipsize="end" + android:singleLine="true" + android:visibility="gone"/> + <ImageView android:id="@+id/menu_button" - android:layout_width="@dimen/call_log_entry_menu_button_size" - android:layout_height="@dimen/call_log_entry_menu_button_size" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="12dp" + android:layout_marginBottom="12dp" + android:layout_marginStart="4dp" + android:layout_marginEnd="4dp" android:layout_alignParentEnd="true" android:layout_centerVertical="true" + android:padding="12dp" android:background="?android:attr/selectableItemBackgroundBorderless" android:scaleType="center" android:src="@drawable/quantum_ic_more_vert_vd_theme_24" diff --git a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_header.xml b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_header.xml index 13575db55..e86ece534 100644 --- a/java/com/android/dialer/calllog/ui/res/layout/new_call_log_header.xml +++ b/java/com/android/dialer/calllog/ui/res/layout/new_call_log_header.xml @@ -16,14 +16,16 @@ --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:minHeight="48dp" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:height="48dp"> + android:layout_height="wrap_content"> <TextView android:id="@+id/new_call_log_header_text" - style="@style/SecondaryText" + style="@style/SubHeader" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/call_log_action_icon_margin_start" - android:layout_centerVertical="true"/> + android:layout_marginStart="16dp" + android:layout_marginTop="8dp" + android:layout_centerVertical="true" + android:layout_gravity="center_vertical"/> </RelativeLayout> diff --git a/java/com/android/dialer/calllog/ui/res/values/dimens.xml b/java/com/android/dialer/calllog/ui/res/values/colors.xml index bfb4c99d7..0a6d512ef 100644 --- a/java/com/android/dialer/calllog/ui/res/values/dimens.xml +++ b/java/com/android/dialer/calllog/ui/res/values/colors.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- - ~ Copyright (C) 2017 The Android Open Source Project + ~ 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. @@ -14,15 +14,11 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License --> -<resources> - <!-- call log entries --> - <dimen name="call_log_entry_top_margin">6dp</dimen> - <dimen name="call_log_entry_padding_bottom_end">16dp</dimen> - <dimen name="call_log_entry_padding_top_start">12dp</dimen> - <dimen name="call_log_entry_photo_size">48dp</dimen> - <dimen name="call_log_entry_photo_padding">4dp</dimen> - <dimen name="call_log_entry_photo_text_margin">8dp</dimen> - <dimen name="call_log_entry_menu_button_size">48dp</dimen> +<resources> + <color name="feature_icon_read_color">#9E9E9E</color> + <color name="feature_icon_unread_color">#474747</color> -</resources> + <color name="call_type_icon_read_color">#757575</color> + <color name="call_type_icon_unread_color">#D32F2F</color> +</resources>
\ No newline at end of file diff --git a/java/com/android/dialer/calllog/ui/res/values/styles.xml b/java/com/android/dialer/calllog/ui/res/values/styles.xml index f8502370a..d521feed4 100644 --- a/java/com/android/dialer/calllog/ui/res/values/styles.xml +++ b/java/com/android/dialer/calllog/ui/res/values/styles.xml @@ -31,9 +31,17 @@ <item name="android:fontFamily">sans-serif</item> </style> + <style name="phoneaccount_textview"> + <item name="android:fontFamily">sans-serif</item> + </style> + <style name="secondary_textview_new_call"> <item name="android:textColor">@color/missed_call</item> <item name="android:fontFamily">sans-serif-medium</item> </style> + <style name="phoneaccount_textview_new_call"> + <item name="android:fontFamily">sans-serif-medium</item> + </style> + </resources>
\ No newline at end of file diff --git a/java/com/android/dialer/main/impl/BottomNavBar.java b/java/com/android/dialer/main/impl/BottomNavBar.java index 6d43ee29d..97f526251 100644 --- a/java/com/android/dialer/main/impl/BottomNavBar.java +++ b/java/com/android/dialer/main/impl/BottomNavBar.java @@ -29,7 +29,7 @@ import java.util.ArrayList; import java.util.List; /** Dialer Bottom Nav Bar for {@link MainActivity}. */ -final class BottomNavBar extends LinearLayout { +public final class BottomNavBar extends LinearLayout { /** Index for each tab in the bottom nav. */ @Retention(RetentionPolicy.SOURCE) diff --git a/java/com/android/dialer/main/impl/MainActivity.java b/java/com/android/dialer/main/impl/MainActivity.java index 1a79fbab3..24c3df575 100644 --- a/java/com/android/dialer/main/impl/MainActivity.java +++ b/java/com/android/dialer/main/impl/MainActivity.java @@ -26,6 +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.util.TransactionSafeActivity; /** This is the main activity for dialer. It hosts favorites, call log, search, dialpad, etc... */ @@ -38,6 +39,21 @@ public final class MainActivity extends TransactionSafeActivity private MainActivityPeer activePeer; + public static Intent getShowCallLogIntent(Context context) { + return getShowTabIntent(context, TabIndex.CALL_LOG); + } + + /** Returns intent that will open MainActivity to the specified tab. */ + public static Intent getShowTabIntent(Context context, @TabIndex int tabIndex) { + if (ConfigProviderComponent.get(context) + .getConfigProvider() + .getBoolean("nui_peer_enabled", false)) { + // TODO(calderwoodra): implement this in NewMainActivityPeer + return null; + } + return OldMainActivityPeer.getShowTabIntent(context, tabIndex); + } + /** * @param context Context of the application package implementing MainActivity class. * @return intent for MainActivity.class diff --git a/java/com/android/dialer/main/impl/MainSearchController.java b/java/com/android/dialer/main/impl/MainSearchController.java index 1defdf578..62ecc5389 100644 --- a/java/com/android/dialer/main/impl/MainSearchController.java +++ b/java/com/android/dialer/main/impl/MainSearchController.java @@ -84,8 +84,17 @@ final class MainSearchController implements SearchBarListener { this.toolbar = toolbar; } + /** Should be called if we're showing the dialpad because of a new ACTION_DIAL intent. */ + public void showDialpadFromNewIntent(boolean animate) { + showDialpad(animate, true); + } + /** Shows the dialpad, hides the FAB and slides the toolbar off screen. */ public void showDialpad(boolean animate) { + showDialpad(animate, false); + } + + private void showDialpad(boolean animate, boolean fromNewIntent) { Assert.checkArgument(!isDialpadVisible()); fab.hide(); @@ -106,9 +115,11 @@ final class MainSearchController implements SearchBarListener { // Show Dialpad if (getDialpadFragment() == null) { DialpadFragment dialpadFragment = new DialpadFragment(); + dialpadFragment.setStartedFromNewIntent(fromNewIntent); transaction.add(R.id.dialpad_fragment_container, dialpadFragment, DIALPAD_FRAGMENT_TAG); } else { DialpadFragment dialpadFragment = getDialpadFragment(); + dialpadFragment.setStartedFromNewIntent(fromNewIntent); transaction.show(dialpadFragment); } transaction.commit(); diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 16b74d5ff..dd766d087 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -31,6 +31,7 @@ import android.provider.ContactsContract.QuickContact; import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.Toolbar; +import android.telecom.PhoneAccount; import android.view.View; import android.widget.ImageView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; @@ -91,6 +92,11 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private static final String KEY_CURRENT_TAB = "current_tab"; private static final String KEY_LAST_TAB = "last_tab"; + /** Action and extra to let the activity know which tab to open up to. */ + private static final String ACTION_SHOW_TAB = "ACTION_SHOW_TAB"; + + private static final String EXTRA_SHOW_TAB = "EXTRA_SHOW_TAB"; + private final MainActivity mainActivity; // Contacts @@ -125,6 +131,22 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private View snackbarContainer; private UiListener<String> getLastOutgoingCallListener; + public static Intent getShowTabIntent(Context context, @TabIndex int tabIndex) { + Intent intent = new Intent(context, MainActivity.class); + intent.setAction(ACTION_SHOW_TAB); + intent.putExtra(EXTRA_SHOW_TAB, tabIndex); + // TODO(calderwoodra): Do we need to set some URI data here + return intent; + } + + static boolean isShowTabIntent(Intent intent) { + return ACTION_SHOW_TAB.equals(intent.getAction()) && intent.hasExtra(EXTRA_SHOW_TAB); + } + + static @TabIndex int getTabFromIntent(Intent intent) { + return intent.getIntExtra(EXTRA_SHOW_TAB, -1); + } + public OldMainActivityPeer(MainActivity mainActivity) { this.mainActivity = mainActivity; } @@ -193,13 +215,52 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen searchController.onRestoreInstanceState(savedInstanceState); bottomNav.selectTab(savedInstanceState.getInt(KEY_CURRENT_TAB)); } else { - lastTabController.selectLastTab(); + showTabOnIntent(mainActivity.getIntent()); } } @Override public void onNewIntent(Intent intent) { - lastTabController.selectLastTab(); + showTabOnIntent(intent); + } + + private void showTabOnIntent(Intent intent) { + if (isShowTabIntent(intent)) { + bottomNav.selectTab(getTabFromIntent(intent)); + return; + } + + if (isDialIntent(intent)) { + searchController.showDialpadFromNewIntent(false); + // Dialpad will grab the intent and populate the number + return; + } + + if (lastTabController.isEnabled) { + lastTabController.selectLastTab(); + return; + } + + bottomNav.selectTab(TabIndex.SPEED_DIAL); + } + + /** Returns true if the given intent contains a phone number to populate the dialer with */ + private boolean isDialIntent(Intent intent) { + if (intent == null || intent.getData() == null) { + return false; + } + + if (Intent.ACTION_DIAL.equals(intent.getAction())) { + return true; + } + + if (Intent.ACTION_VIEW.equals(intent.getAction())) { + Uri data = intent.getData(); + if (data != null && PhoneAccount.SCHEME_TEL.equals(data.getScheme())) { + return true; + } + } + return false; } @Override diff --git a/java/com/android/dialer/oem/MotorolaUtils.java b/java/com/android/dialer/oem/MotorolaUtils.java index 5a0800eeb..c1e2da256 100644 --- a/java/com/android/dialer/oem/MotorolaUtils.java +++ b/java/com/android/dialer/oem/MotorolaUtils.java @@ -18,6 +18,7 @@ package com.android.dialer.oem; import android.content.Context; import android.content.res.Resources; import android.provider.CallLog.Calls; +import android.support.annotation.VisibleForTesting; import android.telephony.TelephonyManager; import com.android.dialer.common.LogUtil; import com.android.dialer.common.PackageUtils; @@ -40,7 +41,7 @@ public class MotorolaUtils { private static final String HD_CALL_FEATRURE = "com.motorola.software.sprint.hd_call"; // This is used to check if a Motorola device supports WiFi call feature, by checking if a certain // package is enabled. - private static final String WIFI_CALL_PACKAGE_NAME = "com.motorola.sprintwfc"; + @VisibleForTesting public static final String WIFI_CALL_PACKAGE_NAME = "com.motorola.sprintwfc"; // Thi is used to check if a Motorola device supports hidden menu feature. private static final String HIDDEN_MENU_FEATURE = "com.motorola.software.sprint.hidden_menu"; @@ -126,4 +127,10 @@ public class MotorolaUtils { } return supportSprintWifiCall; } + + @VisibleForTesting + public static void resetForTest() { + hasCheckedSprintWifiCall = false; + supportSprintWifiCall = false; + } } diff --git a/java/com/android/dialer/theme/res/values/themes.xml b/java/com/android/dialer/theme/res/values/themes.xml index 0c07f3794..1c5706623 100644 --- a/java/com/android/dialer/theme/res/values/themes.xml +++ b/java/com/android/dialer/theme/res/values/themes.xml @@ -69,4 +69,11 @@ <item name="android:ellipsize">end</item> <item name="android:maxLines">1</item> </style> + + <style name="SubHeader" parent="TextAppearance.AppCompat"> + <item name="android:textColor">#212121</item> + <item name="android:textSize">14sp</item> + <item name="android:lineSpacingMultiplier">1.1</item> + </style> + </resources> |