summaryrefslogtreecommitdiff
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorTom Cooks <tommasogagliardi+github@gmail.com>2026-11-16 09:34:52 -0500
committerTom Cooks <tommasogagliardi+github@gmail.com>2026-11-16 09:34:52 -0500
commit5090b55eb7bc3a98b678e21b859fd01d2e30e554 (patch)
tree21fb8fb1dcb994231a0d0468345b64c0156c24e8 /app/src/main/java/com
parente0f907c9cc8f4cd11387bd943df9a0bdf2a0dbcf (diff)
downloadreccoon-5090b55eb7bc3a98b678e21b859fd01d2e30e554.tar.gz
Release RECCoon 1.1.2v1.1.2
- Refreshable MIC/SPK pickers with labels above the selectors. - WAV/M4A, MONO/STEREO and Silence alerts on one harmonised row. - Waveform and L/R meters under the record button, with Swap L/R. - Recordings saved in Downloads/RECCoon. - Confirmation before discarding and timer reset. - Player export next to Transcribe, transcript save timestamp. - Signed release APK for the F-Droid Binaries URL.
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/DeviceSpinnerAdapter.java48
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/Formats.java25
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/LevelMeterView.java28
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/MainActivity.java322
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/PlayerActivity.java51
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/RecordingStore.java42
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/TranscriptStore.java13
-rw-r--r--app/src/main/java/com/tomcooks/reccoon/TranscriptionEngine.java2
8 files changed, 389 insertions, 142 deletions
diff --git a/app/src/main/java/com/tomcooks/reccoon/DeviceSpinnerAdapter.java b/app/src/main/java/com/tomcooks/reccoon/DeviceSpinnerAdapter.java
new file mode 100644
index 0000000..9e4b770
--- /dev/null
+++ b/app/src/main/java/com/tomcooks/reccoon/DeviceSpinnerAdapter.java
@@ -0,0 +1,48 @@
+package com.tomcooks.reccoon;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import java.util.List;
+
+/**
+ * Adapter for the MIC / SPK device spinners. The first entry is always a
+ * refresh command, shown with an icon and a divider so it cannot be mistaken
+ * for a device.
+ */
+public final class DeviceSpinnerAdapter extends ArrayAdapter<String> {
+
+ private final LayoutInflater inflater;
+
+ public DeviceSpinnerAdapter(Context context, List<String> labels) {
+ super(context, android.R.layout.simple_spinner_item, labels);
+ inflater = LayoutInflater.from(context);
+ setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ return itemView(position, android.R.layout.simple_spinner_item, parent);
+ }
+
+ @Override
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ return itemView(position, android.R.layout.simple_spinner_dropdown_item, parent);
+ }
+
+ private View itemView(int position, int normalLayout, ViewGroup parent) {
+ if (position == 0) {
+ View view = inflater.inflate(R.layout.item_spinner_refresh, parent, false);
+ TextView label = view.findViewById(R.id.refreshText);
+ label.setText(getItem(position));
+ return view;
+ }
+ TextView text = (TextView) inflater.inflate(normalLayout, parent, false);
+ text.setText(getItem(position));
+ return text;
+ }
+}
diff --git a/app/src/main/java/com/tomcooks/reccoon/Formats.java b/app/src/main/java/com/tomcooks/reccoon/Formats.java
index 338fd58..c77cba3 100644
--- a/app/src/main/java/com/tomcooks/reccoon/Formats.java
+++ b/app/src/main/java/com/tomcooks/reccoon/Formats.java
@@ -8,7 +8,7 @@ public final class Formats {
private Formats() {
}
- /** Turns {@code reccoon-2026-09-24-153000-00001.wav} into a readable label. */
+ /** Turns {@code RECCoon_2026-09-24_15-30-00_00001.wav} into a readable label. */
public static String prettyName(String fileName) {
if (fileName == null) {
return "";
@@ -16,17 +16,30 @@ public final class Formats {
String core = fileName;
if (core.startsWith("reccoon-")) {
core = core.substring("reccoon-".length());
+ } else if (core.startsWith("RECCoon_")) {
+ core = core.substring("RECCoon_".length());
}
if (core.endsWith(".wav") || core.endsWith(".m4a")) {
core = core.substring(0, core.length() - 4);
}
- String[] parts = core.split("-");
+ String[] parts = core.replace('_', '-').split("-");
if (parts.length >= 4) {
String date = parts[0] + "-" + parts[1] + "-" + parts[2];
- String time = parts[3];
- String sequence = parts.length >= 5 ? parts[4] : "";
- if (time.length() == 6) {
- time = time.substring(0, 2) + ":" + time.substring(2, 4) + ":" + time.substring(4);
+ String time;
+ String sequence;
+ if (parts.length >= 7 && parts[3].length() == 2
+ && parts[4].length() == 2 && parts[5].length() == 2) {
+ // New RECCoon_yyyy-MM-dd_HH-mm-ss_xxxxx names.
+ time = parts[3] + ":" + parts[4] + ":" + parts[5];
+ sequence = parts[6];
+ } else {
+ // Historical reccoon-yyyy-MM-dd-HHmmss-xxxxx names.
+ time = parts[3];
+ if (time.length() == 6) {
+ time = time.substring(0, 2) + ":"
+ + time.substring(2, 4) + ":" + time.substring(4);
+ }
+ sequence = parts.length >= 5 ? parts[4] : "";
}
return date + " " + time + (sequence.isEmpty() ? "" : " #" + sequence);
}
diff --git a/app/src/main/java/com/tomcooks/reccoon/LevelMeterView.java b/app/src/main/java/com/tomcooks/reccoon/LevelMeterView.java
index 362ee6a..4dd8f97 100644
--- a/app/src/main/java/com/tomcooks/reccoon/LevelMeterView.java
+++ b/app/src/main/java/com/tomcooks/reccoon/LevelMeterView.java
@@ -6,10 +6,12 @@ import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
+import androidx.core.content.ContextCompat;
/**
* Two-channel (left/right) peak level meter with a decaying peak hold and a
@@ -26,6 +28,7 @@ public class LevelMeterView extends View {
private final Paint peakPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint labelPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint clipPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private final Drawable micIcon;
private final RectF barRect = new RectF();
@@ -54,6 +57,13 @@ public class LevelMeterView extends View {
clipPaint.setTextSize(11f * density);
clipPaint.setFakeBoldText(true);
clipPaint.setTextAlign(Paint.Align.RIGHT);
+
+ Drawable icon = ContextCompat.getDrawable(context, R.drawable.ic_mic);
+ if (icon != null) {
+ icon = icon.mutate();
+ icon.setTint(0xFF93A0B0);
+ }
+ micIcon = icon;
}
/** Feed one measurement window. Amplitudes are 0..1. */
@@ -92,13 +102,15 @@ public class LevelMeterView extends View {
float density = getResources().getDisplayMetrics().density;
float gap = 6f * density;
float barHeight = (getHeight() - gap) / 2f;
- float labelWidth = labelPaint.measureText("L") + 10f * density;
+ float iconSize = 14f * density;
+ float labelX = micIcon == null ? 0f : iconSize + 3f * density;
+ float labelWidth = labelX + labelPaint.measureText("L") + 10f * density;
float rightEdge = getWidth() - clipPaint.measureText("CLIP") - 10f * density;
drawBar(canvas, 0f, labelWidth, rightEdge - labelWidth, barHeight,
- leftLevel, leftPeak, "L");
+ leftLevel, leftPeak, "L", iconSize, labelX);
drawBar(canvas, barHeight + gap, labelWidth, rightEdge - labelWidth, barHeight,
- rightLevel, rightPeak, "R");
+ rightLevel, rightPeak, "R", iconSize, labelX);
if (System.currentTimeMillis() < clipUntil) {
float baseline = getHeight() / 2f - (clipPaint.descent() + clipPaint.ascent()) / 2f;
@@ -113,10 +125,16 @@ public class LevelMeterView extends View {
}
private void drawBar(Canvas canvas, float top, float left, float width, float height,
- float level, float peak, String label) {
+ float level, float peak, String label,
+ float iconSize, float labelX) {
float density = getResources().getDisplayMetrics().density;
float labelBaseline = top + height / 2f - (labelPaint.descent() + labelPaint.ascent()) / 2f;
- canvas.drawText(label, 0f, labelBaseline, labelPaint);
+ if (micIcon != null) {
+ int iconTop = Math.round(top + height / 2f - iconSize / 2f);
+ micIcon.setBounds(0, iconTop, Math.round(iconSize), iconTop + Math.round(iconSize));
+ micIcon.draw(canvas);
+ }
+ canvas.drawText(label, labelX, labelBaseline, labelPaint);
barRect.set(left, top, left + width, top + height);
canvas.drawRoundRect(barRect, height / 2f, height / 2f, backgroundPaint);
diff --git a/app/src/main/java/com/tomcooks/reccoon/MainActivity.java b/app/src/main/java/com/tomcooks/reccoon/MainActivity.java
index 37ff774..259acc6 100644
--- a/app/src/main/java/com/tomcooks/reccoon/MainActivity.java
+++ b/app/src/main/java/com/tomcooks/reccoon/MainActivity.java
@@ -25,13 +25,15 @@ import android.text.InputType;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
-import android.widget.ArrayAdapter;
+import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -65,7 +67,6 @@ public class MainActivity extends AppCompatActivity {
private static final String PREF_COMPRESS = "compress_recordings";
private static final String PREF_INPUT = "input_device";
private static final String PREF_SWAP = "swap_channels";
- private static final String PREF_MONITOR = "live_monitor";
private static final String PREF_OUTPUT = "output_device";
/** Spinner positions that are not a concrete {@link AudioDeviceInfo}. */
@@ -81,10 +82,16 @@ public class MainActivity extends AppCompatActivity {
private LevelMeterView levelMeter;
private WaveformView waveformView;
private AppCompatCheckBox silenceCheckbox;
- private AppCompatCheckBox monoCheckbox;
- private AppCompatCheckBox compressCheckbox;
- private AppCompatCheckBox swapCheckbox;
- private AppCompatCheckBox monitorCheckbox;
+ private RadioGroup formatGroup;
+ private RadioGroup channelGroup;
+ private RadioButton formatWav;
+ private RadioButton formatM4a;
+ private RadioButton monoButton;
+ private RadioButton stereoButton;
+ private ImageButton swapButton;
+ private LinearLayout deviceSelectorRow;
+ private LinearLayout inputRow;
+ private LinearLayout outputRow;
private Spinner inputSpinner;
private Spinner outputSpinner;
private final List<AudioDeviceInfo> inputDevices = new ArrayList<>();
@@ -94,6 +101,10 @@ public class MainActivity extends AppCompatActivity {
private LinearLayout recordingsContainer;
private TextView emptyText;
private int savedInterruptionFilter = -1;
+ private boolean swapChannels;
+ /** True while a device list is rebuilt, so selection callbacks are ignored. */
+ private boolean populatingInputs;
+ private boolean populatingOutputs;
private WavRecorder recorder;
private RecordingStore recordingStore;
@@ -118,10 +129,16 @@ public class MainActivity extends AppCompatActivity {
levelMeter = findViewById(R.id.levelMeter);
waveformView = findViewById(R.id.waveformView);
silenceCheckbox = findViewById(R.id.silenceCheckbox);
- monoCheckbox = findViewById(R.id.monoCheckbox);
- compressCheckbox = findViewById(R.id.compressCheckbox);
- swapCheckbox = findViewById(R.id.swapCheckbox);
- monitorCheckbox = findViewById(R.id.monitorCheckbox);
+ formatGroup = findViewById(R.id.formatGroup);
+ channelGroup = findViewById(R.id.channelGroup);
+ formatWav = findViewById(R.id.formatWav);
+ formatM4a = findViewById(R.id.formatM4a);
+ monoButton = findViewById(R.id.monoButton);
+ stereoButton = findViewById(R.id.stereoButton);
+ swapButton = findViewById(R.id.swapButton);
+ deviceSelectorRow = findViewById(R.id.deviceSelectorRow);
+ inputRow = findViewById(R.id.inputRow);
+ outputRow = findViewById(R.id.outputRow);
inputSpinner = findViewById(R.id.inputSpinner);
outputSpinner = findViewById(R.id.outputSpinner);
markButton = findViewById(R.id.markButton);
@@ -142,16 +159,16 @@ public class MainActivity extends AppCompatActivity {
}));
setUpSilence();
- setUpMono();
- setUpCompress();
+ setUpFormat();
+ setUpChannels();
setUpSwap();
- setUpMonitor();
+ configureDeviceSelectorLayout();
populateInputDevices();
populateOutputDevices();
markButton.setOnClickListener(v -> addMarker());
discardButton.setOnClickListener(v -> {
if (recording && !busy) {
- stopRecording(true);
+ confirmDiscard();
}
});
InsetsHelper.apply(findViewById(R.id.root));
@@ -286,44 +303,77 @@ public class MainActivity extends AppCompatActivity {
});
}
- private void setUpMono() {
+ private void setUpFormat() {
+ SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
+ boolean compress = prefs.getBoolean(PREF_COMPRESS, false);
+ formatM4a.setChecked(compress);
+ formatWav.setChecked(!compress);
+ formatGroup.setOnCheckedChangeListener((group, checkedId) ->
+ getSharedPreferences(PREFS, MODE_PRIVATE)
+ .edit().putBoolean(PREF_COMPRESS, checkedId == R.id.formatM4a).apply());
+ }
+
+ private void setUpChannels() {
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
boolean mono = prefs.getBoolean(PREF_MONO, false);
- monoCheckbox.setChecked(mono);
+ monoButton.setChecked(mono);
+ stereoButton.setChecked(!mono);
recorder.setForceMono(mono);
- monoCheckbox.setOnCheckedChangeListener((button, checked) -> {
+ channelGroup.setOnCheckedChangeListener((group, checkedId) -> {
+ boolean forceMono = checkedId == R.id.monoButton;
getSharedPreferences(PREFS, MODE_PRIVATE)
- .edit().putBoolean(PREF_MONO, checked).apply();
- recorder.setForceMono(checked);
+ .edit().putBoolean(PREF_MONO, forceMono).apply();
+ recorder.setForceMono(forceMono);
});
}
- private void setUpCompress() {
- SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
- compressCheckbox.setChecked(prefs.getBoolean(PREF_COMPRESS, false));
- compressCheckbox.setOnCheckedChangeListener((button, checked) ->
- getSharedPreferences(PREFS, MODE_PRIVATE)
- .edit().putBoolean(PREF_COMPRESS, checked).apply());
+ private void setUpSwap() {
+ swapChannels = getSharedPreferences(PREFS, MODE_PRIVATE)
+ .getBoolean(PREF_SWAP, false);
+ applySwapState();
+ swapButton.setOnClickListener(v -> {
+ swapChannels = !swapChannels;
+ getSharedPreferences(PREFS, MODE_PRIVATE)
+ .edit().putBoolean(PREF_SWAP, swapChannels).apply();
+ applySwapState();
+ });
}
- private void setUpSwap() {
- SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
- swapCheckbox.setChecked(prefs.getBoolean(PREF_SWAP, false));
- swapCheckbox.setOnCheckedChangeListener((button, checked) ->
- getSharedPreferences(PREFS, MODE_PRIVATE)
- .edit().putBoolean(PREF_SWAP, checked).apply());
+ private void applySwapState() {
+ swapButton.setSelected(swapChannels);
+ swapButton.setContentDescription(getString(R.string.swap_channels));
}
- private void setUpMonitor() {
- SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
- monitorCheckbox.setChecked(prefs.getBoolean(PREF_MONITOR, false));
- monitorCheckbox.setOnCheckedChangeListener((button, checked) -> {
- getSharedPreferences(PREFS, MODE_PRIVATE)
- .edit().putBoolean(PREF_MONITOR, checked).apply();
- if (checked) {
- Toast.makeText(this, R.string.monitor_warning, Toast.LENGTH_LONG).show();
- }
- });
+ /** Phones use one row; tablets keep the two pickers stacked. */
+ private void configureDeviceSelectorLayout() {
+ boolean sideBySide = getResources().getBoolean(R.bool.device_selectors_side_by_side);
+ LinearLayout.LayoutParams inputParams =
+ (LinearLayout.LayoutParams) inputRow.getLayoutParams();
+ LinearLayout.LayoutParams outputParams =
+ (LinearLayout.LayoutParams) outputRow.getLayoutParams();
+ if (sideBySide) {
+ deviceSelectorRow.setOrientation(LinearLayout.HORIZONTAL);
+ inputParams.width = 0;
+ inputParams.weight = 1f;
+ outputParams.width = 0;
+ outputParams.weight = 1f;
+ outputParams.leftMargin = dp(10);
+ outputParams.topMargin = 0;
+ } else {
+ deviceSelectorRow.setOrientation(LinearLayout.VERTICAL);
+ inputParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ inputParams.weight = 0f;
+ outputParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ outputParams.weight = 0f;
+ outputParams.leftMargin = 0;
+ outputParams.topMargin = dp(4);
+ }
+ inputRow.setLayoutParams(inputParams);
+ outputRow.setLayoutParams(outputParams);
+ }
+
+ private int dp(int value) {
+ return Math.round(value * getResources().getDisplayMetrics().density);
}
// --- Output source for live monitoring ---------------------------------
@@ -332,6 +382,7 @@ public class MainActivity extends AppCompatActivity {
int selected = getSharedPreferences(PREFS, MODE_PRIVATE).getInt(PREF_OUTPUT, OUTPUT_AUTO);
outputDevices.clear();
List<String> labels = new ArrayList<>();
+ labels.add(getString(R.string.output_refresh));
labels.add(getString(R.string.output_auto));
labels.add(getString(R.string.output_speaker));
@@ -351,51 +402,89 @@ public class MainActivity extends AppCompatActivity {
}
}
- ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
- android.R.layout.simple_spinner_item, labels);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- outputSpinner.setAdapter(adapter);
+ populatingOutputs = true;
+ outputSpinner.setAdapter(new DeviceSpinnerAdapter(this, labels));
+ int selection = 1;
if (selected == OUTPUT_SPEAKER) {
- outputSpinner.setSelection(1);
- return;
- }
- for (int i = 0; i < outputDevices.size(); i++) {
- if (outputDevices.get(i).getId() == selected) {
- outputSpinner.setSelection(i + 2);
- return;
+ selection = 2;
+ } else {
+ for (int i = 0; i < outputDevices.size(); i++) {
+ if (outputDevices.get(i).getId() == selected) {
+ selection = i + 3;
+ break;
+ }
}
}
- outputSpinner.setSelection(0);
+ outputSpinner.setSelection(selection);
+ outputSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ if (populatingOutputs) {
+ return;
+ }
+ if (position == 0) {
+ handler.post(MainActivity.this::refreshOutputs);
+ return;
+ }
+ int choice = selectedOutputId();
+ int saved = getSharedPreferences(PREFS, MODE_PRIVATE)
+ .getInt(PREF_OUTPUT, OUTPUT_AUTO);
+ if (choice == saved) {
+ // Programmatic restore (or a refresh that kept the same
+ // device): do not repeat the feedback warning.
+ return;
+ }
+ getSharedPreferences(PREFS, MODE_PRIVATE)
+ .edit().putInt(PREF_OUTPUT, choice).apply();
+ // A concrete output turns live monitoring on for the next
+ // recording; there is no separate Monitor switch any more.
+ if (position >= 2) {
+ Toast.makeText(MainActivity.this, R.string.monitor_warning,
+ Toast.LENGTH_LONG).show();
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Keep the current selection.
+ }
+ });
+ handler.post(() -> populatingOutputs = false);
+ }
+
+ private void refreshOutputs() {
+ populateOutputDevices();
+ Toast.makeText(this, R.string.output_refreshed, Toast.LENGTH_SHORT).show();
}
/** Resolves the spinner to a concrete device id, or -1 for the default. */
private int resolveOutputDeviceId() {
int position = outputSpinner.getSelectedItemPosition();
- if (position == 1) {
+ if (position == 2) {
return findBuiltinSpeakerId();
}
- if (position >= 2 && position - 2 < outputDevices.size()) {
- return outputDevices.get(position - 2).getId();
+ if (position >= 3 && position - 3 < outputDevices.size()) {
+ return outputDevices.get(position - 3).getId();
}
return OUTPUT_AUTO;
}
private int selectedOutputId() {
int position = outputSpinner.getSelectedItemPosition();
- if (position == 1) {
+ if (position == 2) {
return OUTPUT_SPEAKER;
}
- if (position >= 2 && position - 2 < outputDevices.size()) {
- return outputDevices.get(position - 2).getId();
+ if (position >= 3 && position - 3 < outputDevices.size()) {
+ return outputDevices.get(position - 3).getId();
}
return OUTPUT_AUTO;
}
private boolean selectedOutputIsBluetooth() {
int position = outputSpinner.getSelectedItemPosition();
- return position >= 2 && position - 2 < outputDevices.size()
- && isBluetoothOutput(outputDevices.get(position - 2));
+ return position >= 3 && position - 3 < outputDevices.size()
+ && isBluetoothOutput(outputDevices.get(position - 3));
}
private static boolean isBluetoothOutput(AudioDeviceInfo device) {
@@ -481,6 +570,7 @@ public class MainActivity extends AppCompatActivity {
int selected = getSharedPreferences(PREFS, MODE_PRIVATE).getInt(PREF_INPUT, INPUT_AUTO);
inputDevices.clear();
List<String> labels = new ArrayList<>();
+ labels.add(getString(R.string.input_refresh));
labels.add(getString(R.string.input_auto));
labels.add(getString(R.string.input_phone));
@@ -502,31 +592,61 @@ public class MainActivity extends AppCompatActivity {
}
}
- ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
- android.R.layout.simple_spinner_item, labels);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- inputSpinner.setAdapter(adapter);
+ populatingInputs = true;
+ inputSpinner.setAdapter(new DeviceSpinnerAdapter(this, labels));
+ int selection = 1;
if (selected == INPUT_PHONE) {
- inputSpinner.setSelection(1);
- return;
- }
- for (int i = 0; i < inputDevices.size(); i++) {
- if (inputDevices.get(i).getId() == selected) {
- inputSpinner.setSelection(i + 2);
- return;
+ selection = 2;
+ } else {
+ for (int i = 0; i < inputDevices.size(); i++) {
+ if (inputDevices.get(i).getId() == selected) {
+ selection = i + 3;
+ break;
+ }
}
}
- inputSpinner.setSelection(0);
+ inputSpinner.setSelection(selection);
+ inputSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ if (populatingInputs) {
+ return;
+ }
+ if (position == 0) {
+ handler.post(MainActivity.this::refreshInputs);
+ return;
+ }
+ int choice = selectedInputId();
+ int saved = getSharedPreferences(PREFS, MODE_PRIVATE)
+ .getInt(PREF_INPUT, INPUT_AUTO);
+ if (choice == saved) {
+ return;
+ }
+ getSharedPreferences(PREFS, MODE_PRIVATE)
+ .edit().putInt(PREF_INPUT, choice).apply();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Keep the current selection.
+ }
+ });
+ handler.post(() -> populatingInputs = false);
+ }
+
+ private void refreshInputs() {
+ populateInputDevices();
+ Toast.makeText(this, R.string.input_refreshed, Toast.LENGTH_SHORT).show();
}
private InputChoice resolveInput() {
int position = inputSpinner.getSelectedItemPosition();
- if (position == 1) {
+ if (position == 2) {
return new InputChoice(findBuiltinMicId(), false);
}
- if (position >= 2 && position - 2 < inputDevices.size()) {
- AudioDeviceInfo device = inputDevices.get(position - 2);
+ if (position >= 3 && position - 3 < inputDevices.size()) {
+ AudioDeviceInfo device = inputDevices.get(position - 3);
return new InputChoice(device.getId(), isBluetoothInput(device));
}
return new InputChoice(INPUT_AUTO, false);
@@ -534,19 +654,19 @@ public class MainActivity extends AppCompatActivity {
private int selectedInputId() {
int position = inputSpinner.getSelectedItemPosition();
- if (position == 1) {
+ if (position == 2) {
return INPUT_PHONE;
}
- if (position >= 2 && position - 2 < inputDevices.size()) {
- return inputDevices.get(position - 2).getId();
+ if (position >= 3 && position - 3 < inputDevices.size()) {
+ return inputDevices.get(position - 3).getId();
}
return INPUT_AUTO;
}
private boolean selectedInputIsBluetooth() {
int position = inputSpinner.getSelectedItemPosition();
- return position >= 2 && position - 2 < inputDevices.size()
- && isBluetoothInput(inputDevices.get(position - 2));
+ return position >= 3 && position - 3 < inputDevices.size()
+ && isBluetoothInput(inputDevices.get(position - 3));
}
private int findBuiltinMicId() {
@@ -718,9 +838,10 @@ public class MainActivity extends AppCompatActivity {
.edit().putInt(PREF_INPUT, selectedInputId()).apply();
recorder.setPreferredDeviceId(input.deviceId);
recorder.setBluetoothSco(input.bluetoothSco);
- recorder.setSwapChannels(swapCheckbox.isChecked());
- recorder.setForceMono(monoCheckbox.isChecked());
- recorder.setMonitoring(monitorCheckbox.isChecked());
+ recorder.setSwapChannels(swapChannels);
+ recorder.setForceMono(monoButton.isChecked());
+ boolean monitoring = selectedOutputId() != OUTPUT_AUTO;
+ recorder.setMonitoring(monitoring);
recorder.setMonitorDeviceId(resolveOutputDeviceId());
getSharedPreferences(PREFS, MODE_PRIVATE)
.edit().putInt(PREF_OUTPUT, selectedOutputId()).apply();
@@ -730,7 +851,7 @@ public class MainActivity extends AppCompatActivity {
Toast.makeText(this, R.string.err_record, Toast.LENGTH_LONG).show();
return;
}
- if (monitorCheckbox.isChecked() && !recorder.isMonitoring()) {
+ if (monitoring && !recorder.isMonitoring()) {
Toast.makeText(this, R.string.err_monitor, Toast.LENGTH_LONG).show();
}
@@ -762,6 +883,15 @@ public class MainActivity extends AppCompatActivity {
handler.post(timerRunnable);
}
+ private void confirmDiscard() {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.discard_confirm_title)
+ .setMessage(R.string.discard_confirm_message)
+ .setPositiveButton(R.string.ok, (dialog, which) -> stopRecording(true))
+ .setNegativeButton(R.string.cancel, null)
+ .show();
+ }
+
private void stopRecording(boolean discard) {
recording = false;
busy = true;
@@ -777,12 +907,14 @@ public class MainActivity extends AppCompatActivity {
blinkAnimator.cancel();
recIndicator.setVisibility(View.INVISIBLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- timerText.setText(formatDuration(elapsed));
+ timerText.setText(discard
+ ? getString(R.string.timer_zero)
+ : formatDuration(elapsed));
recordButton.setBackgroundResource(R.drawable.bg_record_idle);
recordButton.setContentDescription(getString(R.string.cd_record));
recordButton.setEnabled(false);
statusText.setText(discard ? R.string.status_discarding : R.string.status_saving);
- final boolean compress = compressCheckbox.isChecked();
+ final boolean compress = formatM4a.isChecked();
new Thread(() -> {
File wav;
@@ -840,6 +972,7 @@ public class MainActivity extends AppCompatActivity {
busy = false;
recordButton.setEnabled(true);
if (wasDiscarded) {
+ timerText.setText(R.string.timer_zero);
statusText.setText(R.string.discarded);
Toast.makeText(this, R.string.discarded, Toast.LENGTH_SHORT).show();
} else if (result != null) {
@@ -870,7 +1003,8 @@ public class MainActivity extends AppCompatActivity {
ContentValues values = new ContentValues();
values.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName);
values.put(MediaStore.MediaColumns.MIME_TYPE, mimeType);
- values.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS);
+ values.put(MediaStore.MediaColumns.RELATIVE_PATH,
+ Environment.DIRECTORY_DOWNLOADS + "/" + RecordingStore.SUBDIR);
values.put(MediaStore.MediaColumns.IS_PENDING, 1);
Uri uri = resolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, values);
@@ -895,9 +1029,11 @@ public class MainActivity extends AppCompatActivity {
@SuppressWarnings("deprecation")
private void saveToPublicDownloads(File source, String fileName, String mimeType)
throws IOException {
- File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
+ File downloads = Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_DOWNLOADS);
+ File dir = new File(downloads, RecordingStore.SUBDIR);
if (!dir.exists() && !dir.mkdirs()) {
- throw new IOException("Could not create the Downloads directory");
+ throw new IOException("Could not create the RECCoon directory");
}
File outFile = new File(dir, fileName);
try (InputStream in = new FileInputStream(source);
@@ -912,11 +1048,13 @@ public class MainActivity extends AppCompatActivity {
}
private String buildFileName(String extension) {
- String stamp = new SimpleDateFormat("yyyy-MM-dd-HHmmss", Locale.US).format(new Date());
+ String stamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US).format(new Date());
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
int next = prefs.getInt(PREF_COUNTER, 0) + 1;
prefs.edit().putInt(PREF_COUNTER, next).apply();
- return String.format(Locale.US, "reccoon-%s-%05d%s", stamp, next, extension);
+ // The folder (not this name) identifies RECCoon recordings; the prefix is
+ // only there to keep the files recognisable when shared elsewhere.
+ return String.format(Locale.US, "RECCoon_%s_%05d%s", stamp, next, extension);
}
private static void copy(InputStream in, OutputStream out) throws IOException {
diff --git a/app/src/main/java/com/tomcooks/reccoon/PlayerActivity.java b/app/src/main/java/com/tomcooks/reccoon/PlayerActivity.java
index 6d7d3f4..58647d7 100644
--- a/app/src/main/java/com/tomcooks/reccoon/PlayerActivity.java
+++ b/app/src/main/java/com/tomcooks/reccoon/PlayerActivity.java
@@ -14,14 +14,12 @@ import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
-import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SeekBar;
-import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -35,7 +33,7 @@ import java.util.Locale;
/**
* Plays a saved recording with a scrubber and transcribes it on device with
- * sherpa-onnx (multilingual Whisper: English and Italian).
+ * sherpa-onnx (NVIDIA Parakeet v3, multilingual).
*/
public class PlayerActivity extends AppCompatActivity {
@@ -57,7 +55,7 @@ public class PlayerActivity extends AppCompatActivity {
private Button playButton;
private Button speedButton;
private Button transcribeButton;
- private Spinner modelSpinner;
+ private Button exportButton;
private ProgressBar progressBar;
private LinearLayout transcriptContainer;
private LinearLayout markersSection;
@@ -73,6 +71,7 @@ public class PlayerActivity extends AppCompatActivity {
private TranscriptStore transcripts;
private MarkerStore markerStore;
private ModelRepository.Model downloadingModel;
+ private boolean hasTranscript;
private final ModelDownloadService.Listener downloadListener =
new ModelDownloadService.Listener() {
@@ -101,6 +100,7 @@ public class PlayerActivity extends AppCompatActivity {
public void onError(String message) {
runOnUiThread(() -> {
transcribeButton.setEnabled(true);
+ exportButton.setEnabled(hasTranscript);
progressBar.setVisibility(View.GONE);
statusText.setText(getString(R.string.err_download, message));
});
@@ -140,7 +140,7 @@ public class PlayerActivity extends AppCompatActivity {
playButton = findViewById(R.id.playButton);
speedButton = findViewById(R.id.speedButton);
transcribeButton = findViewById(R.id.transcribeButton);
- modelSpinner = findViewById(R.id.modelSpinner);
+ exportButton = findViewById(R.id.exportButton);
progressBar = findViewById(R.id.progressBar);
transcriptContainer = findViewById(R.id.transcriptContainer);
markersSection = findViewById(R.id.markersSection);
@@ -148,7 +148,6 @@ public class PlayerActivity extends AppCompatActivity {
titleText.setText(Formats.prettyName(recordingName));
- setUpSpinners();
setUpButtons();
setUpPlayer();
@@ -165,18 +164,6 @@ public class PlayerActivity extends AppCompatActivity {
handler.post(ticker);
}
- private void setUpSpinners() {
- ModelRepository.Model[] allModels = ModelRepository.Model.values();
- String[] modelLabels = new String[allModels.length];
- for (int i = 0; i < allModels.length; i++) {
- modelLabels[i] = allModels[i].label;
- }
- ArrayAdapter<String> modelAdapter = new ArrayAdapter<>(this,
- android.R.layout.simple_spinner_item, modelLabels);
- modelAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- modelSpinner.setAdapter(modelAdapter);
- }
-
private void setUpButtons() {
playButton.setOnClickListener(v -> togglePlay());
speedButton.setOnClickListener(v -> cycleSpeed());
@@ -184,7 +171,7 @@ public class PlayerActivity extends AppCompatActivity {
findViewById(R.id.forwardButton).setOnClickListener(v -> seekBy(10_000));
findViewById(R.id.shareButton).setOnClickListener(v -> shareRecording());
findViewById(R.id.renameButton).setOnClickListener(v -> showRenameDialog());
- findViewById(R.id.exportButton).setOnClickListener(v -> exportTranscript());
+ exportButton.setOnClickListener(v -> exportTranscript());
findViewById(R.id.deleteButton).setOnClickListener(v -> confirmDelete());
transcribeButton.setOnClickListener(v -> onTranscribeClicked());
@@ -416,12 +403,8 @@ public class PlayerActivity extends AppCompatActivity {
// --- Transcription ----------------------------------------------------
private void onTranscribeClicked() {
- ModelRepository.Model[] allModels = ModelRepository.Model.values();
- int position = modelSpinner.getSelectedItemPosition();
- if (position < 0 || position >= allModels.length) {
- position = 0;
- }
- ModelRepository.Model model = allModels[position];
+ // The model picker is hidden while Parakeet v3 is the only model.
+ ModelRepository.Model model = ModelRepository.Model.values()[0];
if (!models.isReady(model)) {
promptDownload(model);
@@ -443,6 +426,7 @@ public class PlayerActivity extends AppCompatActivity {
private void runDownload(ModelRepository.Model model) {
downloadingModel = model;
transcribeButton.setEnabled(false);
+ exportButton.setEnabled(false);
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(false);
progressBar.setProgress(0);
@@ -456,6 +440,7 @@ public class PlayerActivity extends AppCompatActivity {
private void runTranscription(ModelRepository.Model model) {
cancelled = false;
transcribeButton.setEnabled(false);
+ exportButton.setEnabled(false);
transcriptContainer.removeAllViews();
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(true);
@@ -487,7 +472,9 @@ public class PlayerActivity extends AppCompatActivity {
return;
} finally {
runOnUiThread(() -> {
- transcribeButton.setEnabled(true);
+ if (!hasTranscript) {
+ transcribeButton.setEnabled(true);
+ }
progressBar.setVisibility(View.GONE);
});
}
@@ -507,13 +494,23 @@ public class PlayerActivity extends AppCompatActivity {
private void showTranscript(TranscriptionEngine.Result result) {
transcriptContainer.removeAllViews();
if (result.segments.isEmpty()) {
+ hasTranscript = false;
+ transcribeButton.setEnabled(true);
+ exportButton.setEnabled(false);
statusText.setText(R.string.status_no_speech);
return;
}
for (TranscriptionEngine.Segment segment : result.segments) {
addTranscriptLine(segment);
}
- statusText.setText(R.string.status_transcript_saved);
+ hasTranscript = true;
+ transcribeButton.setEnabled(false);
+ exportButton.setEnabled(true);
+ if (result.savedAt == null || result.savedAt.isEmpty()) {
+ statusText.setText(R.string.status_transcript_saved);
+ } else {
+ statusText.setText(getString(R.string.status_transcript_saved_fmt, result.savedAt));
+ }
}
private void addTranscriptLine(TranscriptionEngine.Segment segment) {
diff --git a/app/src/main/java/com/tomcooks/reccoon/RecordingStore.java b/app/src/main/java/com/tomcooks/reccoon/RecordingStore.java
index b7a1c84..c28145e 100644
--- a/app/src/main/java/com/tomcooks/reccoon/RecordingStore.java
+++ b/app/src/main/java/com/tomcooks/reccoon/RecordingStore.java
@@ -13,9 +13,17 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-/** Lists the WAV files saved by RECCoon in the public Downloads folder. */
+/**
+ * Lists the recordings saved by RECCoon in {@code Downloads/RECCoon}.
+ *
+ * <p>The folder, not the file name, is the source of truth. Files written by
+ * older versions in the root of Downloads are still listed when they use the
+ * historical {@code reccoon-*} name, so upgrading does not hide them.
+ */
public final class RecordingStore {
+ public static final String SUBDIR = "RECCoon";
+
public static final class Recording {
public final String name;
public final Uri uri;
@@ -31,7 +39,7 @@ public final class RecordingStore {
}
}
- private static final String PREFIX = "reccoon-";
+ private static final String LEGACY_PREFIX = "reccoon-";
private static final String[] SUFFIXES = {".wav", ".m4a"};
private final Context context;
@@ -68,8 +76,9 @@ public final class RecordingStore {
MediaStore.MediaColumns.SIZE,
MediaStore.MediaColumns.DATE_MODIFIED,
};
- StringBuilder selection = new StringBuilder(MediaStore.MediaColumns.DISPLAY_NAME)
- .append(" LIKE ? AND (");
+ StringBuilder selection = new StringBuilder("(")
+ .append(MediaStore.MediaColumns.RELATIVE_PATH).append(" LIKE ? OR ")
+ .append(MediaStore.MediaColumns.DISPLAY_NAME).append(" LIKE ?) AND (");
for (int i = 0; i < SUFFIXES.length; i++) {
if (i > 0) {
selection.append(" OR ");
@@ -77,10 +86,11 @@ public final class RecordingStore {
selection.append(MediaStore.MediaColumns.DISPLAY_NAME).append(" LIKE ?");
}
selection.append(')');
- String[] args = new String[SUFFIXES.length + 1];
- args[0] = PREFIX + "%";
+ String[] args = new String[SUFFIXES.length + 2];
+ args[0] = Environment.DIRECTORY_DOWNLOADS + "/" + SUBDIR + "/%";
+ args[1] = LEGACY_PREFIX + "%";
for (int i = 0; i < SUFFIXES.length; i++) {
- args[i + 1] = "%" + SUFFIXES[i];
+ args[i + 2] = "%" + SUFFIXES[i];
}
try (Cursor cursor = context.getContentResolver().query(
MediaStore.Downloads.EXTERNAL_CONTENT_URI,
@@ -111,18 +121,26 @@ public final class RecordingStore {
@SuppressWarnings("deprecation")
private List<Recording> listFromDirectory() {
List<Recording> result = new ArrayList<>();
- File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
- File[] files = dir.listFiles((d, name) -> name.startsWith(PREFIX) && hasKnownSuffix(name));
+ File downloads = Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_DOWNLOADS);
+ addDirectory(result, new File(downloads, SUBDIR), false);
+ // Files saved before 1.1.0 lived in the root of Downloads.
+ addDirectory(result, downloads, true);
+ return result;
+ }
+
+ private void addDirectory(List<Recording> target, File dir, boolean legacyOnly) {
+ File[] files = dir.listFiles((d, name) ->
+ hasKnownSuffix(name) && (!legacyOnly || name.startsWith(LEGACY_PREFIX)));
if (files == null) {
- return result;
+ return;
}
for (File file : files) {
- result.add(new Recording(
+ target.add(new Recording(
file.getName(),
Uri.fromFile(file),
file.length(),
file.lastModified() / 1000L));
}
- return result;
}
}
diff --git a/app/src/main/java/com/tomcooks/reccoon/TranscriptStore.java b/app/src/main/java/com/tomcooks/reccoon/TranscriptStore.java
index 69d9439..84a0577 100644
--- a/app/src/main/java/com/tomcooks/reccoon/TranscriptStore.java
+++ b/app/src/main/java/com/tomcooks/reccoon/TranscriptStore.java
@@ -11,6 +11,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
/** Stores and loads transcript sidecar files in app-private storage. */
public final class TranscriptStore {
@@ -26,10 +29,15 @@ public final class TranscriptStore {
}
public void save(String recordingName, TranscriptionEngine.Result result) throws IOException {
+ if (result.savedAt == null || result.savedAt.isEmpty()) {
+ result.savedAt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US)
+ .format(new Date());
+ }
JSONObject root = new JSONObject();
JSONArray segments = new JSONArray();
try {
root.put("language", result.language == null ? "" : result.language);
+ root.put("savedAt", result.savedAt);
for (TranscriptionEngine.Segment segment : result.segments) {
JSONObject item = new JSONObject();
item.put("start", segment.startSeconds);
@@ -83,6 +91,11 @@ public final class TranscriptStore {
JSONObject root = new JSONObject(new String(buffer, 0, read, StandardCharsets.UTF_8));
TranscriptionEngine.Result result = new TranscriptionEngine.Result();
result.language = root.optString("language", "");
+ result.savedAt = root.optString("savedAt", "");
+ if (result.savedAt.isEmpty()) {
+ result.savedAt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US)
+ .format(new Date(file.lastModified()));
+ }
JSONArray segments = root.optJSONArray("segments");
if (segments != null) {
for (int i = 0; i < segments.length(); i++) {
diff --git a/app/src/main/java/com/tomcooks/reccoon/TranscriptionEngine.java b/app/src/main/java/com/tomcooks/reccoon/TranscriptionEngine.java
index 5483cbf..93a3971 100644
--- a/app/src/main/java/com/tomcooks/reccoon/TranscriptionEngine.java
+++ b/app/src/main/java/com/tomcooks/reccoon/TranscriptionEngine.java
@@ -65,6 +65,8 @@ public final class TranscriptionEngine {
public static final class Result {
public final List<Segment> segments = new ArrayList<>();
public String language = "";
+ /** Local save time, formatted as {@code yyyy-MM-dd'T'HH:mm:ss}. */
+ public String savedAt = "";
/** Plain transcript with one segment per paragraph. */
public String asText() {