From d637af51091dc86a197da6520484e10a356a421b Mon Sep 17 00:00:00 2001 From: Android Dialer Date: Tue, 26 Jun 2018 18:02:04 -0700 Subject: 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 --- .../settings/RecordVoicemailGreetingActivity.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'java') 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); + } + } } -- cgit v1.2.3