From e72f9482de02a04285c7167d1718f53f9aaff56c Mon Sep 17 00:00:00 2001 From: sabowitz Date: Wed, 27 Jun 2018 15:39:01 -0700 Subject: Add voicemail greeting setting screen to voicemail settings. Test: "No tests" PiperOrigin-RevId: 202382580 Change-Id: Ia2dfc2ed10a0500b2b949e3b177279d35ac397e7 --- .../dialer/voicemail/settings/AndroidManifest.xml | 10 +- .../settings/CurrentVoicemailGreetingActivity.java | 139 +++++++++++++++++++++ .../drawable-xhdpi/ic_arrow_back_grey600_48dp.png | Bin 0 -> 208 bytes .../ic_circles_add_googblue_48dp.png | Bin 0 -> 1456 bytes .../ic_play_circle_filled_googblue_48dp.png | Bin 0 -> 1009 bytes .../ic_stop_circle_filled_blue_24dp.png | Bin 0 -> 369 bytes .../layout/activity_current_voicemail_greeting.xml | 104 +++++++++++++++ .../voicemail/settings/res/values/strings.xml | 6 + 8 files changed, 256 insertions(+), 3 deletions(-) create mode 100644 java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_arrow_back_grey600_48dp.png create mode 100644 java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_circles_add_googblue_48dp.png create mode 100644 java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_play_circle_filled_googblue_48dp.png create mode 100644 java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_stop_circle_filled_blue_24dp.png (limited to 'java') diff --git a/java/com/android/dialer/voicemail/settings/AndroidManifest.xml b/java/com/android/dialer/voicemail/settings/AndroidManifest.xml index 71a70da7e..8506ddd41 100644 --- a/java/com/android/dialer/voicemail/settings/AndroidManifest.xml +++ b/java/com/android/dialer/voicemail/settings/AndroidManifest.xml @@ -13,12 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. --> - - @@ -43,7 +41,13 @@ android:parentActivityName="com.android.dialer.app.settings.DialerSettingsActivity" android:theme="@style/SettingsStyle"> - + + + diff --git a/java/com/android/dialer/voicemail/settings/CurrentVoicemailGreetingActivity.java b/java/com/android/dialer/voicemail/settings/CurrentVoicemailGreetingActivity.java index 2b6f27bc3..ff7ae97cc 100644 --- a/java/com/android/dialer/voicemail/settings/CurrentVoicemailGreetingActivity.java +++ b/java/com/android/dialer/voicemail/settings/CurrentVoicemailGreetingActivity.java @@ -16,15 +16,154 @@ package com.android.dialer.voicemail.settings; +import android.Manifest; import android.app.Activity; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.media.MediaPlayer; import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.ActivityCompat; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ImageButton; +import android.widget.TextView; +import com.android.dialer.common.LogUtil; +import com.android.dialer.widget.DialerToolbar; +import java.io.IOException; +import java.util.Locale; /** Activity to display current voicemail greeting and allow user to navigate to record a new one */ public class CurrentVoicemailGreetingActivity extends Activity { + public static final String VOICEMAIL_GREETING_FILEPATH_KEY = "canonVoicemailGreetingFilePathKey"; + + private static final int REQUEST_RECORD_AUDIO_PERMISSION = 200; + + private boolean permissionToRecordAccepted = false; + + private ImageButton changeGreetingButton; + private ImageButton playButton; + + private DialerToolbar currentVoicemailGreetingDialerToolbar; + + private int greetingDuration = -1; + + private MediaPlayer mediaPlayer; + + private TextView playbackProgressLabel; + private View playbackDisplay; + + private String voicemailGreetingFilePath = ""; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_current_voicemail_greeting); + + playbackDisplay = findViewById(R.id.current_voicemail_greeting_recording_display); + playbackProgressLabel = (TextView) findViewById(R.id.playback_progress_text_view); + currentVoicemailGreetingDialerToolbar = (DialerToolbar) findViewById(R.id.toolbar); + + currentVoicemailGreetingDialerToolbar.setTitle( + R.string.voicemail_change_greeting_preference_title); + + changeGreetingButton = (ImageButton) findViewById(R.id.change_greeting_button); + changeGreetingButton.setOnClickListener( + new OnClickListener() { + @Override + public void onClick(View v) { + // TODO(sabowitz): Implement this in CL child beta01. + } + }); + + playButton = (ImageButton) findViewById(R.id.play_button); + playButton.setOnClickListener( + new OnClickListener() { + @Override + public void onClick(View v) { + // TODO(sabowitz): Finish implementing this in CL child beta02. + } + }); + + displayCurrentVoicemailGreetingStatus(); + } + + @Override + public void onStart() { + ActivityCompat.requestPermissions( + this, new String[] {Manifest.permission.RECORD_AUDIO}, REQUEST_RECORD_AUDIO_PERMISSION); + + if (isGreetingRecorded()) { + mediaPlayer = new MediaPlayer(); + try { + mediaPlayer.setDataSource(voicemailGreetingFilePath); + mediaPlayer.prepare(); + } catch (IOException e) { + LogUtil.e("CurrentVoicemailGreetingActivity.onStart", "mediaPlayer setup failed."); + } + } + super.onStart(); + } + + @Override + public void onPause() { + if (isGreetingRecorded()) { + if (mediaPlayer.isPlaying()) { + mediaPlayer.release(); + mediaPlayer = null; + } + } + super.onPause(); + } + + @Override + public void onRequestPermissionsResult( + int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + + if (requestCode == REQUEST_RECORD_AUDIO_PERMISSION) { + permissionToRecordAccepted = grantResults[0] == PackageManager.PERMISSION_GRANTED; + } + if (!permissionToRecordAccepted) { + LogUtil.w( + "CurrentVoicemailGreetingActivity.onRequestPermissionsResult", + "permissionToRecordAccepted = false."); + // TODO(sabowitz): Implement error dialog logic in a child CL. + } + } + + private boolean isGreetingRecorded() { + Intent intent = getIntent(); + if (intent.hasExtra(VOICEMAIL_GREETING_FILEPATH_KEY)) { + String filePathProxy = intent.getStringExtra(VOICEMAIL_GREETING_FILEPATH_KEY); + if (filePathProxy == null || filePathProxy.length() == 0) { + return false; + } + if (mediaPlayer == null) { + mediaPlayer = new MediaPlayer(); + } + try { + mediaPlayer.setDataSource(filePathProxy); + int durationProxy = mediaPlayer.getDuration(); + greetingDuration = durationProxy; + voicemailGreetingFilePath = filePathProxy; + mediaPlayer = null; + return true; + } catch (IOException e) { + LogUtil.e("CurrentVoicemailGreetingActivity.isGreetingRecorded", "bad filepath."); + mediaPlayer = null; + return false; + } + } + return false; + } + + private void displayCurrentVoicemailGreetingStatus() { + if (isGreetingRecorded()) { + String durationLabel = String.format(Locale.US, "00:%d", greetingDuration); + playbackProgressLabel.setText(durationLabel); + } else { + playbackDisplay.setVisibility(View.GONE); + } } } diff --git a/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_arrow_back_grey600_48dp.png b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_arrow_back_grey600_48dp.png new file mode 100644 index 000000000..0a379b484 Binary files /dev/null and b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_arrow_back_grey600_48dp.png differ diff --git a/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_circles_add_googblue_48dp.png b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_circles_add_googblue_48dp.png new file mode 100644 index 000000000..5ae52308d Binary files /dev/null and b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_circles_add_googblue_48dp.png differ diff --git a/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_play_circle_filled_googblue_48dp.png b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_play_circle_filled_googblue_48dp.png new file mode 100644 index 000000000..065775861 Binary files /dev/null and b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_play_circle_filled_googblue_48dp.png differ diff --git a/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_stop_circle_filled_blue_24dp.png b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_stop_circle_filled_blue_24dp.png new file mode 100644 index 000000000..520f860fa Binary files /dev/null and b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_stop_circle_filled_blue_24dp.png differ diff --git a/java/com/android/dialer/voicemail/settings/res/layout/activity_current_voicemail_greeting.xml b/java/com/android/dialer/voicemail/settings/res/layout/activity_current_voicemail_greeting.xml index 81d175a4f..30558344e 100644 --- a/java/com/android/dialer/voicemail/settings/res/layout/activity_current_voicemail_greeting.xml +++ b/java/com/android/dialer/voicemail/settings/res/layout/activity_current_voicemail_greeting.xml @@ -21,4 +21,108 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.android.dialer.voicemail.settings.CurrentVoicemailGreetingActivity"> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/com/android/dialer/voicemail/settings/res/values/strings.xml b/java/com/android/dialer/voicemail/settings/res/values/strings.xml index 14793fd33..971f37a2e 100644 --- a/java/com/android/dialer/voicemail/settings/res/values/strings.xml +++ b/java/com/android/dialer/voicemail/settings/res/values/strings.xml @@ -36,6 +36,12 @@ Voicemail greeting + + Record a greeting + + + My voicemail greeting + Tap to Record -- cgit v1.2.3 From f375be6e66c0c06db3a8f045b31425153b9a0902 Mon Sep 17 00:00:00 2001 From: wangqi Date: Wed, 27 Jun 2018 16:44:26 -0700 Subject: UI refresh for search fragment. Bug: 79879991 Test: manual PiperOrigin-RevId: 202392606 Change-Id: I24ba1177d11433b76bf6fe0c64d97368a6a1e328 --- .../dialer/main/impl/toolbar/res/layout/expanded_search_bar.xml | 5 ++--- .../dialer/searchfragment/common/res/layout/search_contact_row.xml | 6 ++---- .../android/dialer/searchfragment/list/res/layout/header_layout.xml | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'java') 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 e5b72f233..9ae884d8b 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 @@ -29,7 +29,7 @@ android:background="?attr/selectableItemBackgroundBorderless" android:contentDescription="@string/action_menu_back_from_search" android:src="@drawable/quantum_ic_arrow_back_vd_theme_24" - android:tint="?android:attr/colorPrimary"/> + android:tint="?colorIcon"/> + style="@style/Dialer.TextAppearance.Primary"/> diff --git a/java/com/android/dialer/searchfragment/list/res/layout/header_layout.xml b/java/com/android/dialer/searchfragment/list/res/layout/header_layout.xml index ff59206ad..16f3701c6 100644 --- a/java/com/android/dialer/searchfragment/list/res/layout/header_layout.xml +++ b/java/com/android/dialer/searchfragment/list/res/layout/header_layout.xml @@ -27,5 +27,5 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - style="@style/Dialer.TextAppearance.Secondary.Ellipsize"/> + style="@style/Dialer.TextAppearance.OVERLINE.Ellipsize"/> -- cgit v1.2.3 From 6310dfd04e0d3561d1ef58121046e6255eac8c87 Mon Sep 17 00:00:00 2001 From: linyuh Date: Thu, 28 Jun 2018 10:14:11 -0700 Subject: Also ignore IllegalStateException thrown by SQLiteClosable when coalescing fails. Test: Manual PiperOrigin-RevId: 202499434 Change-Id: Ie41eeb782072d82c5613b44be99649f43807498d --- .../android/dialer/calllog/database/Coalescer.java | 84 +++++++++++++++++----- .../dialer/calllog/ui/NewCallLogFragment.java | 19 +++-- 2 files changed, 73 insertions(+), 30 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/calllog/database/Coalescer.java b/java/com/android/dialer/calllog/database/Coalescer.java index 2ad9f9a97..fd751e767 100644 --- a/java/com/android/dialer/calllog/database/Coalescer.java +++ b/java/com/android/dialer/calllog/database/Coalescer.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog.database; import android.database.Cursor; +import android.database.StaleDataException; import android.provider.CallLog.Calls; import android.support.annotation.NonNull; import android.support.annotation.WorkerThread; @@ -85,34 +86,72 @@ public class Coalescer { @WorkerThread @NonNull private ImmutableList coalesceInternal( - Cursor allAnnotatedCallLogRowsSortedByTimestampDesc) { + Cursor allAnnotatedCallLogRowsSortedByTimestampDesc) throws ExpectedCoalescerException { Assert.isWorkerThread(); - if (!allAnnotatedCallLogRowsSortedByTimestampDesc.moveToFirst()) { - return ImmutableList.of(); - } - ImmutableList.Builder coalescedRowListBuilder = new ImmutableList.Builder<>(); - RowCombiner rowCombiner = new RowCombiner(allAnnotatedCallLogRowsSortedByTimestampDesc); - rowCombiner.startNewGroup(); + try { + if (!allAnnotatedCallLogRowsSortedByTimestampDesc.moveToFirst()) { + return ImmutableList.of(); + } - long coalescedRowId = 0; - do { - boolean isRowMerged = rowCombiner.mergeRow(allAnnotatedCallLogRowsSortedByTimestampDesc); + RowCombiner rowCombiner = new RowCombiner(allAnnotatedCallLogRowsSortedByTimestampDesc); + rowCombiner.startNewGroup(); - if (isRowMerged) { - allAnnotatedCallLogRowsSortedByTimestampDesc.moveToNext(); - } + long coalescedRowId = 0; + do { + boolean isRowMerged = rowCombiner.mergeRow(allAnnotatedCallLogRowsSortedByTimestampDesc); + + if (isRowMerged) { + allAnnotatedCallLogRowsSortedByTimestampDesc.moveToNext(); + } + + if (!isRowMerged || allAnnotatedCallLogRowsSortedByTimestampDesc.isAfterLast()) { + coalescedRowListBuilder.add( + rowCombiner.combine().toBuilder().setId(coalescedRowId++).build()); + rowCombiner.startNewGroup(); + } + } while (!allAnnotatedCallLogRowsSortedByTimestampDesc.isAfterLast()); + + return coalescedRowListBuilder.build(); - if (!isRowMerged || allAnnotatedCallLogRowsSortedByTimestampDesc.isAfterLast()) { - coalescedRowListBuilder.add( - rowCombiner.combine().toBuilder().setId(coalescedRowId++).build()); - rowCombiner.startNewGroup(); + } catch (Exception exception) { + // Coalescing can fail if cursor "allAnnotatedCallLogRowsSortedByTimestampDesc" is closed by + // its loader while the work is still in progress. + // + // This can happen when the loader restarts and finishes loading data before the coalescing + // work is completed. + // + // This kind of failure doesn't have to crash the app as coalescing will be restarted on the + // latest data obtained by the loader. Therefore, we inspect the exception here and throw an + // ExpectedCoalescerException if it is the case described above. + // + // The type of expected exception depends on whether AbstractWindowedCursor#checkPosition() is + // called when the cursor is closed. + // (1) If it is called before the cursor is closed, we will get IllegalStateException thrown + // by SQLiteClosable when it attempts to acquire a reference to the database. + // (2) Otherwise, we will get StaleDataException thrown by AbstractWindowedCursor's + // checkPosition() method. + // + // Note that it would be more accurate to inspect the stack trace to locate the origin of the + // exception. However, according to the documentation on Throwable#getStackTrace, "some + // virtual machines may, under some circumstances, omit one or more stack frames from the + // stack trace". "In the extreme case, a virtual machine that has no stack trace information + // concerning this throwable is permitted to return a zero-length array from this method." + // Therefore, the best we can do is to inspect the message in the exception. + // TODO(linyuh): try to avoid the expected failure. + String message = exception.getMessage(); + if (message != null + && ((exception instanceof StaleDataException + && message.startsWith("Attempting to access a closed CursorWindow")) + || (exception instanceof IllegalStateException + && message.startsWith("attempt to re-open an already-closed object")))) { + throw new ExpectedCoalescerException(exception); } - } while (!allAnnotatedCallLogRowsSortedByTimestampDesc.isAfterLast()); - return coalescedRowListBuilder.build(); + throw exception; + } } /** Combines rows from {@link AnnotatedCallLog} into a {@link CoalescedRow}. */ @@ -337,4 +376,11 @@ public class Coalescer { return dialerPhoneNumberUtil.isMatch(groupPhoneNumber, rowPhoneNumber); } } + + /** A checked exception thrown when expected failure happens when coalescing is in progress. */ + public static final class ExpectedCoalescerException extends Exception { + ExpectedCoalescerException(Throwable throwable) { + super("Expected coalescing exception", throwable); + } + } } diff --git a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java index 4141fe723..5e72a1af3 100644 --- a/java/com/android/dialer/calllog/ui/NewCallLogFragment.java +++ b/java/com/android/dialer/calllog/ui/NewCallLogFragment.java @@ -17,7 +17,6 @@ package com.android.dialer.calllog.ui; import android.app.Activity; import android.database.Cursor; -import android.database.StaleDataException; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; @@ -34,6 +33,7 @@ import android.view.ViewGroup; import com.android.dialer.calllog.CallLogComponent; import com.android.dialer.calllog.RefreshAnnotatedCallLogReceiver; import com.android.dialer.calllog.database.CallLogDatabaseComponent; +import com.android.dialer.calllog.database.Coalescer; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; @@ -337,16 +337,13 @@ public final class NewCallLogFragment extends Fragment implements LoaderCallback } }, throwable -> { - if (throwable instanceof StaleDataException) { - // Coalescing can fail if the cursor passed to Coalescer is closed by the loader while - // the work is still in progress. - // This can happen when the loader restarts and finishes loading data before the - // coalescing work is completed. - // This failure doesn't need to be thrown as coalescing will be restarted on the latest - // data obtained by the loader. - // TODO(linyuh): Also throw an exception if the failure above can be avoided. - LogUtil.e("NewCallLogFragment.onLoadFinished", "coalescing failed", throwable); - } else { + // Coalescing can fail if the cursor passed to Coalescer is closed by the loader while + // the work is still in progress. + // This can happen when the loader restarts and finishes loading data before the + // coalescing work is completed. + // This failure is identified by ExpectedCoalescerException and doesn't need to be + // thrown as coalescing will be restarted on the latest data obtained by the loader. + if (!(throwable instanceof Coalescer.ExpectedCoalescerException)) { throw new AssertionError(throwable); } }); -- cgit v1.2.3 From 96bc372701f3cf11fa197039bee6f98e09ba30eb Mon Sep 17 00:00:00 2001 From: linyuh Date: Thu, 28 Jun 2018 12:41:13 -0700 Subject: Use ConcurrentMap to log Contacts Provider metrics in the old call log. Bug: 80482741 Test: None PiperOrigin-RevId: 202526514 Change-Id: Ia92b95b288638ccb77d3bac16bd8c5589326bf61 --- java/com/android/dialer/app/calllog/CallLogAdapter.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'java') diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index f5474eec6..485683b09 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -100,6 +100,8 @@ import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; import java.util.ArrayList; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; /** Adapter class to fill in data for the Call Log. */ public class CallLogAdapter extends GroupingListAdapter @@ -158,9 +160,12 @@ public class CallLogAdapter extends GroupingListAdapter /** * Maps a raw input number to match info. We only log one MatchInfo per raw input number to reduce * the amount of data logged. + * + *

Note that this has to be a {@link ConcurrentMap} as the match info for each row in the UI is + * loaded in a background thread spawned when the ViewHolder is bound. */ - private final Map contactsProviderMatchInfos = - new ArrayMap<>(); + private final ConcurrentMap contactsProviderMatchInfos = + new ConcurrentHashMap<>(); private final ActionMode.Callback actionModeCallback = new ActionMode.Callback() { @@ -1464,6 +1469,7 @@ public class CallLogAdapter extends GroupingListAdapter notifyDataSetChanged(); } + @WorkerThread private void logCp2Metrics(PhoneCallDetails details, ContactInfo contactInfo) { if (details == null) { return; -- cgit v1.2.3 From 53a524743f84155de2773cd9ad2da011e4435ceb Mon Sep 17 00:00:00 2001 From: wangqi Date: Thu, 28 Jun 2018 13:15:02 -0700 Subject: UI refresh for FAB. Bug: 73963403 Test: manual PiperOrigin-RevId: 202531720 Change-Id: I11ec4567dce161c5d3199e0159fe838b036489d7 --- java/com/android/dialer/main/impl/res/layout/main_activity.xml | 2 +- java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml | 4 ++-- java/com/android/dialer/theme/base/res/values/theme_dialer_light.xml | 4 ++-- .../com/android/dialer/theme/hidden/res/values/colors_dialer_dark.xml | 1 - .../android/dialer/theme/hidden/res/values/colors_dialer_light.xml | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) (limited to 'java') 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 5cb457ec9..76d709c16 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 @@ -64,7 +64,7 @@ android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_margin="16dp" + android:layout_margin="24dp" android:layout_gravity="end|bottom" android:src="@drawable/quantum_ic_dialpad_white_24" android:contentDescription="@string/dialpad_button_content_description" diff --git a/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml b/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml index d03a96bc4..d2cc0fc9c 100644 --- a/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml +++ b/java/com/android/dialer/theme/base/res/values/theme_dialer_dark.xml @@ -51,8 +51,8 @@ @color/dialer_dark_theme_color @color/dialer_dark_theme_color_dark @color/dialer_dark_theme_color_dark - @color/dialer_dark_secondary_color - @color/dialer_dark_secondary_color + @color/dialer_dark_theme_color + @color/dialer_dark_theme_color ?android:attr/colorPrimary diff --git a/java/com/android/dialer/theme/base/res/values/theme_dialer_light.xml b/java/com/android/dialer/theme/base/res/values/theme_dialer_light.xml index 8aa87dfdb..69ecba41e 100644 --- a/java/com/android/dialer/theme/base/res/values/theme_dialer_light.xml +++ b/java/com/android/dialer/theme/base/res/values/theme_dialer_light.xml @@ -57,8 +57,8 @@ @color/dialer_theme_color @color/dialer_theme_color_dark @color/dialer_theme_color_dark - @color/dialer_secondary_color - @color/dialer_secondary_color + @color/dialer_theme_color + @color/dialer_theme_color ?android:attr/colorPrimary diff --git a/java/com/android/dialer/theme/hidden/res/values/colors_dialer_dark.xml b/java/com/android/dialer/theme/hidden/res/values/colors_dialer_dark.xml index e48474e9f..41c5fd1c5 100644 --- a/java/com/android/dialer/theme/hidden/res/values/colors_dialer_dark.xml +++ b/java/com/android/dialer/theme/hidden/res/values/colors_dialer_dark.xml @@ -18,5 +18,4 @@ #5195EA #335195EA #2374CE - #5195EA diff --git a/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml b/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml index 4621be115..ec2f2629e 100644 --- a/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml +++ b/java/com/android/dialer/theme/hidden/res/values/colors_dialer_light.xml @@ -18,5 +18,4 @@ @color/google_blue_600 #332A56C6 #1C3AA9 - #F50057 -- cgit v1.2.3 From 9af4b65fa7717a647e3c8996cbbbcc93637aeab4 Mon Sep 17 00:00:00 2001 From: wangqi Date: Thu, 28 Jun 2018 13:39:44 -0700 Subject: UI refresh for bottom nav bar. Bug: 73963403 Test: manual PiperOrigin-RevId: 202535473 Change-Id: Iccb4e72c63cbf031399448ee2def5dcb3a152081 --- .../dialer/main/impl/bottomnav/BottomNavItem.java | 22 ++------ .../bottomnav/res/drawable/notification_badge.xml | 6 +-- .../impl/bottomnav/res/layout/bottom_nav_item.xml | 62 ++++++++++------------ .../main/impl/bottomnav/res/values/dimens.xml | 21 -------- .../dialer/theme/common/res/values/colors.xml | 2 +- .../dialer/theme/common/res/values/text_styles.xml | 6 +++ 6 files changed, 39 insertions(+), 80 deletions(-) delete mode 100644 java/com/android/dialer/main/impl/bottomnav/res/values/dimens.xml (limited to 'java') diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java index 4794b8823..48cfc8160 100644 --- a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java @@ -20,20 +20,18 @@ 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.RelativeLayout; import android.widget.TextView; import com.android.dialer.common.Assert; import com.android.dialer.configprovider.ConfigProviderComponent; import com.android.dialer.theme.base.ThemeComponent; /** Navigation item in a bottom nav. */ -final class BottomNavItem extends LinearLayout { +final class BottomNavItem extends RelativeLayout { private ImageView image; private TextView text; @@ -57,7 +55,7 @@ final class BottomNavItem extends LinearLayout { int colorId = selected ? ThemeComponent.get(getContext()).theme().getColorPrimary() - : ThemeComponent.get(getContext()).theme().getTextColorSecondary(); + : ThemeComponent.get(getContext()).theme().getColorIcon(); image.setImageTintList(ColorStateList.valueOf(colorId)); text.setTextColor(colorId); } @@ -87,20 +85,6 @@ final class BottomNavItem extends LinearLayout { } 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 index 65bc8f9b4..e02d7c441 100644 --- 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 @@ -16,8 +16,6 @@ --> - - - + android:shape="oval"> + \ 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 index 02874a9d8..8c0705fe0 100644 --- 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 @@ -16,49 +16,41 @@ --> + android:minWidth="80dp"> - - - - - - + + + android:layout_below="@id/bottom_nav_item_image" + android:layout_centerHorizontal="true" + android:gravity="center_horizontal"/> \ No newline at end of file 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 deleted file mode 100644 index 8fd376bda..000000000 --- a/java/com/android/dialer/main/impl/bottomnav/res/values/dimens.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - 10dp - 14dp - 22dp - \ No newline at end of file diff --git a/java/com/android/dialer/theme/common/res/values/colors.xml b/java/com/android/dialer/theme/common/res/values/colors.xml index 207d29c80..0af550fce 100644 --- a/java/com/android/dialer/theme/common/res/values/colors.xml +++ b/java/com/android/dialer/theme/common/res/values/colors.xml @@ -27,7 +27,7 @@ #A52714 #097138 - #C53929 + #EA4335 #CFD8DC diff --git a/java/com/android/dialer/theme/common/res/values/text_styles.xml b/java/com/android/dialer/theme/common/res/values/text_styles.xml index df5dafa31..1f2d6c728 100644 --- a/java/com/android/dialer/theme/common/res/values/text_styles.xml +++ b/java/com/android/dialer/theme/common/res/values/text_styles.xml @@ -37,6 +37,12 @@ sans-serif-medium + +