Rename "preset file" to just "preset" in transformer demo

The new name means we can add streams and other sources that aren't files in
future, for example, screen recording input.

PiperOrigin-RevId: 641894319
This commit is contained in:
andrewlewis 2024-06-10 07:27:24 -07:00 committed by Copybara-Service
parent 34966f5d86
commit a1f21d976c
3 changed files with 18 additions and 19 deletions

View File

@ -154,7 +154,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
private Runnable onPermissionsGranted; private Runnable onPermissionsGranted;
private ActivityResultLauncher<Intent> videoLocalFilePickerLauncher; private ActivityResultLauncher<Intent> videoLocalFilePickerLauncher;
private ActivityResultLauncher<Intent> overlayLocalFilePickerLauncher; private ActivityResultLauncher<Intent> overlayLocalFilePickerLauncher;
private Button selectPresetFileButton; private Button selectPresetButton;
private Button selectLocalFileButton; private Button selectLocalFileButton;
private TextView selectedFileTextView; private TextView selectedFileTextView;
private CheckBox removeAudioCheckbox; private CheckBox removeAudioCheckbox;
@ -178,7 +178,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
private Button selectVideoEffectsButton; private Button selectVideoEffectsButton;
private boolean[] audioEffectsSelections; private boolean[] audioEffectsSelections;
private boolean[] videoEffectsSelections; private boolean[] videoEffectsSelections;
private String[] presetFileDescriptions; private String[] presetDescriptions;
private Uri localFileUri; private Uri localFileUri;
private int inputUriPosition; private int inputUriPosition;
private long trimStartMs; private long trimStartMs;
@ -217,8 +217,8 @@ public final class ConfigurationActivity extends AppCompatActivity {
new ActivityResultContracts.StartActivityForResult(), new ActivityResultContracts.StartActivityForResult(),
this::overlayLocalFilePickerLauncherResult); this::overlayLocalFilePickerLauncherResult);
selectPresetFileButton = findViewById(R.id.select_preset_file_button); selectPresetButton = findViewById(R.id.select_preset_button);
selectPresetFileButton.setOnClickListener(view -> selectPresetFile()); selectPresetButton.setOnClickListener(view -> selectPreset());
selectLocalFileButton = findViewById(R.id.select_local_file_button); selectLocalFileButton = findViewById(R.id.select_local_file_button);
selectLocalFileButton.setOnClickListener( selectLocalFileButton.setOnClickListener(
@ -228,8 +228,8 @@ public final class ConfigurationActivity extends AppCompatActivity {
/* mimeTypes= */ new String[] {"image/*", "video/*", "audio/*"})); /* mimeTypes= */ new String[] {"image/*", "video/*", "audio/*"}));
selectedFileTextView = findViewById(R.id.selected_file_text_view); selectedFileTextView = findViewById(R.id.selected_file_text_view);
presetFileDescriptions = getResources().getStringArray(R.array.preset_descriptions); presetDescriptions = getResources().getStringArray(R.array.preset_descriptions);
selectedFileTextView.setText(presetFileDescriptions[inputUriPosition]); selectedFileTextView.setText(presetDescriptions[inputUriPosition]);
removeAudioCheckbox = findViewById(R.id.remove_audio_checkbox); removeAudioCheckbox = findViewById(R.id.remove_audio_checkbox);
removeAudioCheckbox.setOnClickListener(this::onRemoveAudio); removeAudioCheckbox.setOnClickListener(this::onRemoveAudio);
@ -339,7 +339,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
super.onResume(); super.onResume();
@Nullable Uri intentUri = getIntent().getData(); @Nullable Uri intentUri = getIntent().getData();
if (intentUri != null) { if (intentUri != null) {
selectPresetFileButton.setEnabled(false); selectPresetButton.setEnabled(false);
selectLocalFileButton.setEnabled(false); selectLocalFileButton.setEnabled(false);
selectedFileTextView.setText(intentUri.toString()); selectedFileTextView.setText(intentUri.toString());
} }
@ -419,28 +419,27 @@ public final class ConfigurationActivity extends AppCompatActivity {
} else if (localFileUri != null) { } else if (localFileUri != null) {
intentUri = localFileUri; intentUri = localFileUri;
} else { } else {
String[] presetFileUris = getResources().getStringArray(R.array.preset_uris); String[] presetUris = getResources().getStringArray(R.array.preset_uris);
intentUri = Uri.parse(presetFileUris[inputUriPosition]); intentUri = Uri.parse(presetUris[inputUriPosition]);
} }
transformerIntent.setData(intentUri); transformerIntent.setData(intentUri);
startActivity(transformerIntent); startActivity(transformerIntent);
} }
private void selectPresetFile() { private void selectPreset() {
new AlertDialog.Builder(/* context= */ this) new AlertDialog.Builder(/* context= */ this)
.setTitle(R.string.select_preset_file_title) .setTitle(R.string.select_preset_title)
.setSingleChoiceItems( .setSingleChoiceItems(presetDescriptions, inputUriPosition, this::selectPresetInDialog)
presetFileDescriptions, inputUriPosition, this::selectPresetFileInDialog)
.setPositiveButton(android.R.string.ok, /* listener= */ null) .setPositiveButton(android.R.string.ok, /* listener= */ null)
.create() .create()
.show(); .show();
} }
private void selectPresetFileInDialog(DialogInterface dialog, int which) { private void selectPresetInDialog(DialogInterface dialog, int which) {
inputUriPosition = which; inputUriPosition = which;
localFileUri = null; localFileUri = null;
selectedFileTextView.setText(presetFileDescriptions[inputUriPosition]); selectedFileTextView.setText(presetDescriptions[inputUriPosition]);
} }
private void selectLocalFile( private void selectLocalFile(

View File

@ -33,12 +33,12 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<Button <Button
android:id="@+id/select_preset_file_button" android:id="@+id/select_preset_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:text="@string/select_preset_file_title" android:text="@string/select_preset_title"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/configuration_text_view" /> app:layout_constraintTop_toBottomOf="@+id/configuration_text_view" />
@ -66,7 +66,7 @@
android:gravity="center" android:gravity="center"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/select_preset_file_button" /> app:layout_constraintTop_toBottomOf="@+id/select_preset_button" />
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"

View File

@ -16,7 +16,7 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" translatable="false">Transformer Demo</string> <string name="app_name" translatable="false">Transformer Demo</string>
<string name="configuration" translatable="false">Configuration</string> <string name="configuration" translatable="false">Configuration</string>
<string name="select_preset_file_title" translatable="false">Choose preset file</string> <string name="select_preset_title" translatable="false">Choose preset input</string>
<string name="select_local_file_title">Choose local file</string> <string name="select_local_file_title">Choose local file</string>
<string name="local_file_picker_failed">File couldn\'t be opened. Please try again.</string> <string name="local_file_picker_failed">File couldn\'t be opened. Please try again.</string>
<string name="remove_audio" translatable="false">Remove audio</string> <string name="remove_audio" translatable="false">Remove audio</string>