summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorsabowitz <sabowitz@google.com>2018-06-27 15:39:01 -0700
committerCopybara-Service <copybara-piper@google.com>2018-06-28 16:22:44 -0700
commite72f9482de02a04285c7167d1718f53f9aaff56c (patch)
tree2d0a783b7624295ce4278eb2157d6031b2805a47 /java
parent2e3e5ff3f2dfd4106b22835c1bf68bf551dcc032 (diff)
Add voicemail greeting setting screen to voicemail settings.
Test: "No tests" PiperOrigin-RevId: 202382580 Change-Id: Ia2dfc2ed10a0500b2b949e3b177279d35ac397e7
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/voicemail/settings/AndroidManifest.xml10
-rw-r--r--java/com/android/dialer/voicemail/settings/CurrentVoicemailGreetingActivity.java139
-rw-r--r--java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_arrow_back_grey600_48dp.pngbin0 -> 208 bytes
-rw-r--r--java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_circles_add_googblue_48dp.pngbin0 -> 1456 bytes
-rw-r--r--java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_play_circle_filled_googblue_48dp.pngbin0 -> 1009 bytes
-rw-r--r--java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_stop_circle_filled_blue_24dp.pngbin0 -> 369 bytes
-rw-r--r--java/com/android/dialer/voicemail/settings/res/layout/activity_current_voicemail_greeting.xml104
-rw-r--r--java/com/android/dialer/voicemail/settings/res/values/strings.xml6
8 files changed, 256 insertions, 3 deletions
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.
-->
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.dialer.voicemail.settings">
<application>
-
<!-- Causes the "Voicemail" item under "Calls" setting to be hidden. The voicemail module will
be handling the settings. Has no effect before OC where dialer cannot provide voicemail
settings -->
@@ -43,7 +41,13 @@
android:parentActivityName="com.android.dialer.app.settings.DialerSettingsActivity"
android:theme="@style/SettingsStyle">
</activity>
- <activity android:name=".CurrentVoicemailGreetingActivity">
+ <activity
+ android:name=".CurrentVoicemailGreetingActivity"
+ android:label="@string/voicemail_change_greeting_preference_title"
+ android:parentActivityName="com.android.dialer.app.settings.DialerSettingsActivity"
+ android:exported="true">
+ <!-- TODO(a bug): delete android:exported="true" closer to submitting -->
</activity>
</application>
+
</manifest>
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
--- /dev/null
+++ b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_arrow_back_grey600_48dp.png
Binary files 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
--- /dev/null
+++ b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_circles_add_googblue_48dp.png
Binary files 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
--- /dev/null
+++ b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_play_circle_filled_googblue_48dp.png
Binary files 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
--- /dev/null
+++ b/java/com/android/dialer/voicemail/settings/res/drawable-xhdpi/ic_stop_circle_filled_blue_24dp.png
Binary files 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">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_alignParentTop="true"
+ android:layout_centerHorizontal="true"
+ android:orientation="vertical">
+ <com.android.dialer.widget.DialerToolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:accessibilityHeading="false"
+ android:title="@string/voicemail_change_greeting_preference_title">
+ </com.android.dialer.widget.DialerToolbar>
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@color/dialer_divider_line_color"
+ />
+
+ <!-- Change Greeting Panel -->
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="72dp"
+ android:layout_marginTop="8dp"
+ android:layout_marginBottom="7dp"
+ android:orientation="horizontal"
+ android:visibility="visible">
+
+ <!-- Change Greeting Button -->
+ <ImageButton
+ android:id="@+id/change_greeting_button"
+ style="@android:style/Widget.Material.Light.ImageButton"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_marginStart="16dp"
+ android:layout_gravity="center_vertical"
+ android:background="?android:attr/colorBackground"
+ android:foregroundGravity="center_vertical"
+ android:scaleType="centerCrop"
+ android:src="@drawable/ic_circles_add_googblue_48dp"/>
+
+ <TextView
+ android:id="@+id/textView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginStart="17dp"
+ android:layout_gravity="center_vertical"
+ android:text="@string/current_voicemail_greeting_record_instruction"
+ style="@style/Dialer.TextAppearance.Primary"/>
+
+ </LinearLayout>
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@color/dialer_divider_line_color"
+ />
+ <LinearLayout
+ android:id="@+id/current_voicemail_greeting_recording_display"
+ android:layout_width="match_parent"
+ android:layout_height="72dp"
+ android:background="?android:attr/colorBackground"
+ android:orientation="horizontal">
+ <!-- Play Button -->
+ <ImageButton
+ android:id="@+id/play_button"
+ style="@android:style/Widget.Material.Light.ImageButton"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:layout_marginStart="16dp"
+ android:layout_gravity="center_vertical"
+ android:adjustViewBounds="false"
+ android:background="?android:attr/colorBackground"
+ android:cropToPadding="false"
+ android:scaleType="centerCrop"
+ android:src="@drawable/ic_play_circle_filled_googblue_48dp"/>
+
+ <LinearLayout
+ android:layout_width="232dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_marginStart="16dp"
+ android:layout_gravity="center_vertical"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/current_voicemail_greeting_recording_title_textview"
+ style="@style/Dialer.TextAppearance.Primary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/current_voicemail_greeting_recording_title"/>
+ <TextView
+ android:id="@+id/playback_progress_text_view"
+ style="@style/Dialer.TextAppearance.Secondary"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
+ </LinearLayout>
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dp"
+ android:background="@color/dialer_divider_line_color"
+ />
+ </LinearLayout>
</RelativeLayout>
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 @@
<!-- Title for changing voicemail greeting activity [CHAR LIMIT=40] -->
<string name="voicemail_change_greeting_preference_title">Voicemail greeting</string>
+ <!-- Text instruction shown on the current voicemail greeting display screen [CHAR LIMIT=20] -->
+ <string name="current_voicemail_greeting_record_instruction">Record a greeting</string>
+
+ <!-- Title for voicemail greeting, if one is already recorded. -->
+ <string name="current_voicemail_greeting_recording_title">My voicemail greeting</string>
+
<!-- Text shown on the record voicemail activity [CHAR LIMIT=20] -->
<string name="change_greeting_text">Tap to Record</string>