summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Dialer <noreply@google.com>2018-06-26 18:02:04 -0700
committerCopybara-Service <copybara-piper@google.com>2018-06-27 11:08:05 -0700
commitd637af51091dc86a197da6520484e10a356a421b (patch)
tree4c051c4a8702f4256f83f0e55182e27b2ed5b840
parent20f8f6018e0f80083ebbabb43965ec19996d5f87 (diff)
Added method to set Save and Redo buttons enabled/disabled
Added logic to setState() method to change state of buttons Test: "N/A" PiperOrigin-RevId: 202229300 Change-Id: I0f1ed20a41c59431edf4684e57bdbce18a8d7dbd
-rw-r--r--java/com/android/dialer/voicemail/settings/RecordVoicemailGreetingActivity.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/java/com/android/dialer/voicemail/settings/RecordVoicemailGreetingActivity.java b/java/com/android/dialer/voicemail/settings/RecordVoicemailGreetingActivity.java
index 39a791d5f..89e45dca7 100644
--- a/java/com/android/dialer/voicemail/settings/RecordVoicemailGreetingActivity.java
+++ b/java/com/android/dialer/voicemail/settings/RecordVoicemailGreetingActivity.java
@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.support.annotation.IntDef;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.Button;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -46,14 +47,21 @@ public class RecordVoicemailGreetingActivity extends Activity implements OnClick
private int currentState;
private int duration;
private RecordButton recordButton;
+ private Button saveButton;
+ private Button redoButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_record_voicemail_greeting);
+ recordButton = findViewById(R.id.record_button);
+ saveButton = findViewById(R.id.save_button);
+ redoButton = findViewById(R.id.redo_button);
+
duration = 0;
setState(RECORD_GREETING_INIT);
+ recordButton.setOnClickListener(this);
}
@Override
@@ -83,18 +91,32 @@ public class RecordVoicemailGreetingActivity extends Activity implements OnClick
case RECORD_GREETING_INIT:
recordButton.setState(state);
recordButton.setTracks(0, 0);
+ setSaveRedoButtonsEnabled(false);
break;
case RECORD_GREETING_PLAYING_BACK:
case RECORD_GREETING_RECORDED:
recordButton.setState(state);
recordButton.setTracks(0, (float) duration / MAX_GREETING_DURATION_MS);
+ setSaveRedoButtonsEnabled(true);
break;
case RECORD_GREETING_RECORDING:
recordButton.setState(state);
recordButton.setTracks(0, 1f);
+ setSaveRedoButtonsEnabled(false);
break;
default:
break;
}
}
+
+ /** Enables/Disables save and redo buttons in the layout */
+ private void setSaveRedoButtonsEnabled(boolean enabled) {
+ if (enabled) {
+ saveButton.setVisibility(View.VISIBLE);
+ redoButton.setVisibility(View.VISIBLE);
+ } else {
+ saveButton.setVisibility(View.GONE);
+ redoButton.setVisibility(View.GONE);
+ }
+ }
}