Rename cancel to pause in Transformer demo

The user might expect this button to back out to the configuration activity,
but actually it toggles pause/resume (though `cancel` is the method called).

PiperOrigin-RevId: 647273416
This commit is contained in:
andrewlewis 2024-06-27 04:56:41 -07:00 committed by Copybara-Service
parent 727645179b
commit dcbded0fa9
3 changed files with 9 additions and 9 deletions

View File

@ -130,7 +130,7 @@ public final class TransformerActivity extends AppCompatActivity {
private TextView informationTextView; private TextView informationTextView;
private ViewGroup progressViewGroup; private ViewGroup progressViewGroup;
private LinearProgressIndicator progressIndicator; private LinearProgressIndicator progressIndicator;
private Button cancelButton; private Button pauseButton;
private Button resumeButton; private Button resumeButton;
private Stopwatch exportStopwatch; private Stopwatch exportStopwatch;
private AspectRatioFrameLayout debugFrame; private AspectRatioFrameLayout debugFrame;
@ -157,8 +157,8 @@ public final class TransformerActivity extends AppCompatActivity {
informationTextView = findViewById(R.id.information_text_view); informationTextView = findViewById(R.id.information_text_view);
progressViewGroup = findViewById(R.id.progress_view_group); progressViewGroup = findViewById(R.id.progress_view_group);
progressIndicator = findViewById(R.id.progress_indicator); progressIndicator = findViewById(R.id.progress_indicator);
cancelButton = findViewById(R.id.cancel_button); pauseButton = findViewById(R.id.pause_button);
cancelButton.setOnClickListener(view -> cancelExport()); pauseButton.setOnClickListener(view -> pauseExport());
resumeButton = findViewById(R.id.resume_button); resumeButton = findViewById(R.id.resume_button);
resumeButton.setOnClickListener(view -> startExport()); resumeButton.setOnClickListener(view -> startExport());
debugFrame = findViewById(R.id.debug_aspect_ratio_frame_layout); debugFrame = findViewById(R.id.debug_aspect_ratio_frame_layout);
@ -241,7 +241,7 @@ public final class TransformerActivity extends AppCompatActivity {
debugTextView.setVisibility(View.GONE); debugTextView.setVisibility(View.GONE);
informationTextView.setText(R.string.export_started); informationTextView.setText(R.string.export_started);
progressViewGroup.setVisibility(View.VISIBLE); progressViewGroup.setVisibility(View.VISIBLE);
cancelButton.setVisibility(View.VISIBLE); pauseButton.setVisibility(View.VISIBLE);
resumeButton.setVisibility(View.GONE); resumeButton.setVisibility(View.GONE);
progressIndicator.setProgress(0); progressIndicator.setProgress(0);
Handler mainHandler = new Handler(getMainLooper()); Handler mainHandler = new Handler(getMainLooper());
@ -799,11 +799,11 @@ public final class TransformerActivity extends AppCompatActivity {
} }
} }
private void cancelExport() { private void pauseExport() {
transformer.cancel(); transformer.cancel();
transformer = null; transformer = null;
exportStopwatch.stop(); exportStopwatch.stop();
cancelButton.setVisibility(View.GONE); pauseButton.setVisibility(View.GONE);
resumeButton.setVisibility(View.VISIBLE); resumeButton.setVisibility(View.VISIBLE);
if (oldOutputFile != null) { if (oldOutputFile != null) {
oldOutputFile.delete(); oldOutputFile.delete();

View File

@ -154,10 +154,10 @@
android:text="@string/debug_preview" /> android:text="@string/debug_preview" />
<Button <Button
android:id="@+id/cancel_button" android:id="@+id/pause_button"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:text="@string/cancel"/> android:text="@string/pause"/>
<Button <Button
android:id="@+id/resume_button" android:id="@+id/resume_button"

View File

@ -42,7 +42,7 @@
<string name="no_media_pipe_error" translatable="false">Failed to load MediaPipeShaderProgram. Check the README for instructions.</string> <string name="no_media_pipe_error" translatable="false">Failed to load MediaPipeShaderProgram. Check the README for instructions.</string>
<string name="export" translatable="false">Export</string> <string name="export" translatable="false">Export</string>
<string name="debug_preview" translatable="false">Debug preview:</string> <string name="debug_preview" translatable="false">Debug preview:</string>
<string name="cancel" translatable="false">Cancel</string> <string name="pause" translatable="false">Pause</string>
<string name="resume" translatable="false">Resume</string> <string name="resume" translatable="false">Resume</string>
<string name="debug_preview_not_available" translatable="false">No debug preview available.</string> <string name="debug_preview_not_available" translatable="false">No debug preview available.</string>
<string name="export_started" translatable="false">Export started</string> <string name="export_started" translatable="false">Export started</string>