Rename occurences of transform in demo app
PiperOrigin-RevId: 510384933
This commit is contained in:
parent
a1f7960eab
commit
58d653b702
@ -55,7 +55,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
|
||||
/**
|
||||
* An {@link Activity} that sets the configuration to use for transforming and playing media, using
|
||||
* An {@link Activity} that sets the configuration to use for exporting and playing media, using
|
||||
* {@link TransformerActivity}.
|
||||
*/
|
||||
public final class ConfigurationActivity extends AppCompatActivity {
|
||||
@ -73,7 +73,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
public static final String TRIM_END_MS = "trim_end_ms";
|
||||
public static final String ENABLE_FALLBACK = "enable_fallback";
|
||||
public static final String ENABLE_DEBUG_PREVIEW = "enable_debug_preview";
|
||||
public static final String ABORT_SLOW_TRANSFORMATION = "abort_slow_transformation";
|
||||
public static final String ABORT_SLOW_EXPORT = "abort_slow_export";
|
||||
public static final String HDR_MODE = "hdr_mode";
|
||||
public static final String AUDIO_EFFECTS_SELECTIONS = "audio_effects_selections";
|
||||
public static final String VIDEO_EFFECTS_SELECTIONS = "video_effects_selections";
|
||||
@ -222,7 +222,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
private @MonotonicNonNull CheckBox trimCheckBox;
|
||||
private @MonotonicNonNull CheckBox enableFallbackCheckBox;
|
||||
private @MonotonicNonNull CheckBox enableDebugPreviewCheckBox;
|
||||
private @MonotonicNonNull CheckBox abortSlowTransformationCheckBox;
|
||||
private @MonotonicNonNull CheckBox abortSlowExportCheckBox;
|
||||
private @MonotonicNonNull Spinner hdrModeSpinner;
|
||||
private @MonotonicNonNull Button selectAudioEffectsButton;
|
||||
private @MonotonicNonNull Button selectVideoEffectsButton;
|
||||
@ -255,7 +255,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.configuration_activity);
|
||||
|
||||
findViewById(R.id.transform_button).setOnClickListener(this::startTransformation);
|
||||
findViewById(R.id.export_button).setOnClickListener(this::startExport);
|
||||
|
||||
selectPresetFileButton = findViewById(R.id.select_preset_file_button);
|
||||
selectPresetFileButton.setOnClickListener(this::selectPresetFile);
|
||||
@ -325,7 +325,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
enableFallbackCheckBox = findViewById(R.id.enable_fallback_checkbox);
|
||||
enableDebugPreviewCheckBox = findViewById(R.id.enable_debug_preview_checkbox);
|
||||
|
||||
abortSlowTransformationCheckBox = findViewById(R.id.abort_slow_transformation_checkbox);
|
||||
abortSlowExportCheckBox = findViewById(R.id.abort_slow_export_checkbox);
|
||||
|
||||
ArrayAdapter<String> hdrModeAdapter =
|
||||
new ArrayAdapter<>(/* context= */ this, R.layout.spinner_item);
|
||||
@ -394,12 +394,12 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
"trimCheckBox",
|
||||
"enableFallbackCheckBox",
|
||||
"enableDebugPreviewCheckBox",
|
||||
"abortSlowTransformationCheckBox",
|
||||
"abortSlowExportCheckBox",
|
||||
"hdrModeSpinner",
|
||||
"audioEffectsSelections",
|
||||
"videoEffectsSelections"
|
||||
})
|
||||
private void startTransformation(View view) {
|
||||
private void startExport(View view) {
|
||||
Intent transformerIntent = new Intent(/* packageContext= */ this, TransformerActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(SHOULD_REMOVE_AUDIO, removeAudioCheckbox.isChecked());
|
||||
@ -435,7 +435,7 @@ public final class ConfigurationActivity extends AppCompatActivity {
|
||||
}
|
||||
bundle.putBoolean(ENABLE_FALLBACK, enableFallbackCheckBox.isChecked());
|
||||
bundle.putBoolean(ENABLE_DEBUG_PREVIEW, enableDebugPreviewCheckBox.isChecked());
|
||||
bundle.putBoolean(ABORT_SLOW_TRANSFORMATION, abortSlowTransformationCheckBox.isChecked());
|
||||
bundle.putBoolean(ABORT_SLOW_EXPORT, abortSlowExportCheckBox.isChecked());
|
||||
String selectedhdrMode = String.valueOf(hdrModeSpinner.getSelectedItem());
|
||||
bundle.putInt(HDR_MODE, checkNotNull(HDR_MODE_DESCRIPTIONS.get(selectedhdrMode)));
|
||||
bundle.putBooleanArray(AUDIO_EFFECTS_SELECTIONS, audioEffectsSelections);
|
||||
|
@ -105,7 +105,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
|
||||
/** An {@link Activity} that transforms and plays media using {@link Transformer}. */
|
||||
/** An {@link Activity} that exports and plays media using {@link Transformer}. */
|
||||
public final class TransformerActivity extends AppCompatActivity {
|
||||
private static final String TAG = "TransformerActivity";
|
||||
|
||||
@ -119,7 +119,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
private @MonotonicNonNull TextView informationTextView;
|
||||
private @MonotonicNonNull ViewGroup progressViewGroup;
|
||||
private @MonotonicNonNull LinearProgressIndicator progressIndicator;
|
||||
private @MonotonicNonNull Stopwatch transformationStopwatch;
|
||||
private @MonotonicNonNull Stopwatch exportStopwatch;
|
||||
private @MonotonicNonNull AspectRatioFrameLayout debugFrame;
|
||||
|
||||
@Nullable private DebugTextViewHelper debugTextViewHelper;
|
||||
@ -146,7 +146,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
displayInputButton = findViewById(R.id.display_input_button);
|
||||
displayInputButton.setOnClickListener(this::toggleInputVideoDisplay);
|
||||
|
||||
transformationStopwatch =
|
||||
exportStopwatch =
|
||||
Stopwatch.createUnstarted(
|
||||
new Ticker() {
|
||||
@Override
|
||||
@ -162,7 +162,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
|
||||
checkNotNull(progressIndicator);
|
||||
checkNotNull(informationTextView);
|
||||
checkNotNull(transformationStopwatch);
|
||||
checkNotNull(exportStopwatch);
|
||||
checkNotNull(inputCardView);
|
||||
checkNotNull(inputTextView);
|
||||
checkNotNull(inputImageView);
|
||||
@ -172,7 +172,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
checkNotNull(progressViewGroup);
|
||||
checkNotNull(debugFrame);
|
||||
checkNotNull(displayInputButton);
|
||||
startTransformation();
|
||||
startExport();
|
||||
|
||||
inputPlayerView.onResume();
|
||||
outputPlayerView.onResume();
|
||||
@ -185,9 +185,9 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
checkNotNull(transformer).cancel();
|
||||
transformer = null;
|
||||
|
||||
// The stop watch is reset after cancelling the transformation, in case cancelling causes the
|
||||
// stop watch to be stopped in a transformer callback.
|
||||
checkNotNull(transformationStopwatch).reset();
|
||||
// The stop watch is reset after cancelling the export, in case cancelling causes the stop watch
|
||||
// to be stopped in a transformer callback.
|
||||
checkNotNull(exportStopwatch).reset();
|
||||
|
||||
checkNotNull(inputPlayerView).onPause();
|
||||
checkNotNull(outputPlayerView).onPause();
|
||||
@ -207,11 +207,11 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
"debugTextView",
|
||||
"informationTextView",
|
||||
"progressIndicator",
|
||||
"transformationStopwatch",
|
||||
"exportStopwatch",
|
||||
"progressViewGroup",
|
||||
"debugFrame",
|
||||
})
|
||||
private void startTransformation() {
|
||||
private void startExport() {
|
||||
requestReadVideoPermission(/* activity= */ this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
@ -227,7 +227,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
try {
|
||||
Transformer transformer = createTransformer(bundle, filePath);
|
||||
EditedMediaItem editedMediaItem = createEditedMediaItem(mediaItem, bundle);
|
||||
transformationStopwatch.start();
|
||||
exportStopwatch.start();
|
||||
transformer.start(editedMediaItem, filePath);
|
||||
this.transformer = transformer;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
@ -235,7 +235,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
}
|
||||
inputCardView.setVisibility(View.GONE);
|
||||
outputPlayerView.setVisibility(View.GONE);
|
||||
informationTextView.setText(R.string.transformation_started);
|
||||
informationTextView.setText(R.string.export_started);
|
||||
progressViewGroup.setVisibility(View.VISIBLE);
|
||||
Handler mainHandler = new Handler(getMainLooper());
|
||||
ProgressHolder progressHolder = new ProgressHolder();
|
||||
@ -247,9 +247,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
&& transformer.getProgress(progressHolder) != PROGRESS_STATE_NOT_STARTED) {
|
||||
progressIndicator.setProgress(progressHolder.progress);
|
||||
informationTextView.setText(
|
||||
getString(
|
||||
R.string.transformation_timer,
|
||||
transformationStopwatch.elapsed(TimeUnit.SECONDS)));
|
||||
getString(R.string.export_timer, exportStopwatch.elapsed(TimeUnit.SECONDS)));
|
||||
mainHandler.postDelayed(/* r= */ this, /* delayMillis= */ 500);
|
||||
}
|
||||
}
|
||||
@ -283,7 +281,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
"displayInputButton",
|
||||
"debugTextView",
|
||||
"informationTextView",
|
||||
"transformationStopwatch",
|
||||
"exportStopwatch",
|
||||
"progressViewGroup",
|
||||
"debugFrame",
|
||||
})
|
||||
@ -310,7 +308,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
.setEnableFallback(bundle.getBoolean(ConfigurationActivity.ENABLE_FALLBACK))
|
||||
.build());
|
||||
|
||||
if (!bundle.getBoolean(ConfigurationActivity.ABORT_SLOW_TRANSFORMATION)) {
|
||||
if (!bundle.getBoolean(ConfigurationActivity.ABORT_SLOW_EXPORT)) {
|
||||
transformerBuilder.setMuxerFactory(
|
||||
new DefaultMuxer.Factory(/* maxDelayBetweenSamplesMs= */ C.TIME_UNSET));
|
||||
}
|
||||
@ -345,10 +343,10 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
private File createExternalCacheFile(String fileName) throws IOException {
|
||||
File file = new File(getExternalCacheDir(), fileName);
|
||||
if (file.exists() && !file.delete()) {
|
||||
throw new IllegalStateException("Could not delete the previous transformer output file");
|
||||
throw new IllegalStateException("Could not delete the previous export output file");
|
||||
}
|
||||
if (!file.createNewFile()) {
|
||||
throw new IllegalStateException("Could not create the transformer output file");
|
||||
throw new IllegalStateException("Could not create the export output file");
|
||||
}
|
||||
return file;
|
||||
}
|
||||
@ -356,7 +354,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
@RequiresNonNull({
|
||||
"inputCardView",
|
||||
"outputPlayerView",
|
||||
"transformationStopwatch",
|
||||
"exportStopwatch",
|
||||
"progressViewGroup",
|
||||
})
|
||||
private EditedMediaItem createEditedMediaItem(MediaItem mediaItem, @Nullable Bundle bundle)
|
||||
@ -618,13 +616,13 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
"informationTextView",
|
||||
"progressViewGroup",
|
||||
"debugFrame",
|
||||
"transformationStopwatch",
|
||||
"exportStopwatch",
|
||||
})
|
||||
private void onError(ExportException exportException) {
|
||||
if (transformationStopwatch.isRunning()) {
|
||||
transformationStopwatch.stop();
|
||||
if (exportStopwatch.isRunning()) {
|
||||
exportStopwatch.stop();
|
||||
}
|
||||
informationTextView.setText(R.string.transformation_error);
|
||||
informationTextView.setText(R.string.export_error);
|
||||
progressViewGroup.setVisibility(View.GONE);
|
||||
debugFrame.removeAllViews();
|
||||
Toast.makeText(getApplicationContext(), "Export error: " + exportException, Toast.LENGTH_LONG)
|
||||
@ -643,13 +641,12 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
"informationTextView",
|
||||
"progressViewGroup",
|
||||
"debugFrame",
|
||||
"transformationStopwatch",
|
||||
"exportStopwatch",
|
||||
})
|
||||
private void onCompleted(String filePath, MediaItem inputMediaItem) {
|
||||
transformationStopwatch.stop();
|
||||
exportStopwatch.stop();
|
||||
informationTextView.setText(
|
||||
getString(
|
||||
R.string.transformation_completed, transformationStopwatch.elapsed(TimeUnit.SECONDS)));
|
||||
getString(R.string.export_completed, exportStopwatch.elapsed(TimeUnit.SECONDS)));
|
||||
progressViewGroup.setVisibility(View.GONE);
|
||||
debugFrame.removeAllViews();
|
||||
inputCardView.setVisibility(View.VISIBLE);
|
||||
@ -774,7 +771,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
public SurfaceView getDebugPreviewSurfaceView(int width, int height) {
|
||||
checkState(
|
||||
surfaceView == null || (this.width == width && this.height == height),
|
||||
"Transformer should not change the output size mid-transformation.");
|
||||
"Transformer should not change the output size mid-export.");
|
||||
if (surfaceView != null) {
|
||||
return surfaceView;
|
||||
}
|
||||
|
@ -210,9 +210,9 @@
|
||||
android:layout_weight="1">
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/abort_slow_transformation" />
|
||||
android:text="@string/abort_slow_export" />
|
||||
<CheckBox
|
||||
android:id="@+id/abort_slow_transformation_checkbox"
|
||||
android:id="@+id/abort_slow_export_checkbox"
|
||||
android:layout_gravity="end"/>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
@ -247,17 +247,17 @@
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:text="@string/select_video_effects"
|
||||
app:layout_constraintBottom_toTopOf="@+id/transform_button"
|
||||
app:layout_constraintBottom_toTopOf="@+id/export_button"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<Button
|
||||
android:id="@+id/transform_button"
|
||||
android:id="@+id/export_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="28dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:text="@string/transform"
|
||||
android:text="@string/export"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
@ -29,20 +29,20 @@
|
||||
<string name="rotate" translatable="false">Rotate video (degrees)</string>
|
||||
<string name="enable_fallback" translatable="false">Enable fallback</string>
|
||||
<string name="enable_debug_preview" translatable="false">Enable debug preview</string>
|
||||
<string name="abort_slow_transformation" translatable="false">Abort slow transformation</string>
|
||||
<string name="abort_slow_export" translatable="false">Abort slow export</string>
|
||||
<string name="trim" translatable="false">Trim</string>
|
||||
<string name="hdr_mode" translatable="false">HDR mode</string>
|
||||
<string name="select_audio_effects" translatable="false">Add audio effects</string>
|
||||
<string name="select_video_effects" translatable="false">Add video effects</string>
|
||||
<string name="periodic_vignette_options" translatable="false">Periodic vignette options</string>
|
||||
<string name="no_media_pipe_error" translatable="false">Failed to load MediaPipeShaderProgram. Check the README for instructions.</string>
|
||||
<string name="transform" translatable="false">Transform</string>
|
||||
<string name="export" translatable="false">Export</string>
|
||||
<string name="debug_preview" translatable="false">Debug preview:</string>
|
||||
<string name="debug_preview_not_available" translatable="false">No debug preview available.</string>
|
||||
<string name="transformation_started" translatable="false">Transformation started</string>
|
||||
<string name="transformation_timer" translatable="false">Transformation started %d seconds ago.</string>
|
||||
<string name="transformation_completed" translatable="false">Transformation completed in %d seconds.</string>
|
||||
<string name="transformation_error" translatable="false">Transformation error</string>
|
||||
<string name="export_started" translatable="false">Export started</string>
|
||||
<string name="export_timer" translatable="false">Export started %d seconds ago.</string>
|
||||
<string name="export_completed" translatable="false">Export completed in %d seconds.</string>
|
||||
<string name="export_error" translatable="false">Export error</string>
|
||||
<string name="trim_range">Bounds in seconds</string>
|
||||
<string-array name="color_filter_options">
|
||||
<item>Grayscale</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user