@@ -25,11 +25,11 @@ final class DashcamSettingsController {
2525 private static final String KEY_SIGNATURE = "recordingSignature" ;
2626 private static final String KEY_SHOW_SPEED = "recordingShowSpeed" ;
2727 private static final int REQ_STORAGE = 1337 ;
28- private static final int DEFAULT_RECORDING_FPS = 15 ;
28+ private static final int DEFAULT_RECORDING_FPS = 25 ;
2929 private static final int MIN_RECORDING_FPS = 1 ;
3030 private static final int MAX_RECORDING_FPS = 60 ;
3131 private static final int MAX_SIGNATURE_LENGTH = 40 ;
32- private static final String RECORDS_DIR_NAME = "mg4_cam_records " ;
32+ private static final String RECORDS_DIR_NAME = "dashcam " ;
3333
3434 private final MainActivity activity ;
3535 private boolean syncingEnabled ;
@@ -47,8 +47,7 @@ void bind(
4747 EditText etSignature ,
4848 Switch swShowSpeed ,
4949 TextView tvRecordsPath ,
50- Button btnExportUsb
51- ) {
50+ Button btnExportUsb ) {
5251 int segmentMin = prefs .getInt (KEY_SEGMENT_MIN , 3 );
5352 int totalMin = Math .max (segmentMin , prefs .getInt (KEY_TOTAL_MIN , 30 ));
5453 int recordingFps = getRecordingFps (prefs );
@@ -59,16 +58,17 @@ void bind(
5958 swEnabled .setChecked (prefs .getBoolean (KEY_ENABLED , false ));
6059 syncingEnabled = false ;
6160 swEnabled .setOnCheckedChangeListener ((buttonView , checked ) -> {
62- if (syncingEnabled ) return ;
61+ if (syncingEnabled )
62+ return ;
6363 prefs .edit ().putBoolean (KEY_ENABLED , checked ).apply ();
6464 if (checked ) {
6565 if (!hasStoragePermission ()) {
6666 ActivityCompat .requestPermissions (
6767 activity ,
68- new String []{ Manifest .permission .WRITE_EXTERNAL_STORAGE },
69- REQ_STORAGE
70- );
71- Toast . makeText ( activity , R . string . settings_storage_permission_required , Toast . LENGTH_SHORT ) .show ();
68+ new String [] { Manifest .permission .WRITE_EXTERNAL_STORAGE },
69+ REQ_STORAGE );
70+ Toast . makeText ( activity , R . string . settings_storage_permission_required , Toast . LENGTH_SHORT )
71+ .show ();
7272 }
7373 saveFields (prefs , etSegmentMin , etTotalMin , etRecordingFps , etSignature , false );
7474 RecordingService .startIfNeeded (activity );
@@ -96,25 +96,24 @@ void bind(
9696 }
9797 if (swShowSpeed != null ) {
9898 swShowSpeed .setChecked (shouldShowSpeed (prefs ));
99- swShowSpeed .setOnCheckedChangeListener ((buttonView , checked ) ->
100- prefs .edit ().putBoolean (KEY_SHOW_SPEED , checked ).apply ()
101- );
99+ swShowSpeed .setOnCheckedChangeListener (
100+ (buttonView , checked ) -> prefs .edit ().putBoolean (KEY_SHOW_SPEED , checked ).apply ());
102101 }
103102 bindFields (prefs , etSegmentMin , etTotalMin , etRecordingFps , etSignature );
104103
105104 if (tvRecordsPath != null ) {
106105 tvRecordsPath .setText (getRecordsBaseDir ().getAbsolutePath ());
107106 }
108107 if (btnExportUsb != null ) {
109- btnExportUsb . setVisibility ( findMountedUsbRoot () == null ? android . view . View . GONE : android . view . View . VISIBLE );
110- btnExportUsb . setOnClickListener ( v ->
111- Toast . makeText ( activity , R . string . settings_usb_export_todo , Toast . LENGTH_LONG ). show ()
112- );
108+ btnExportUsb
109+ . setVisibility ( findMountedUsbRoot () == null ? android . view . View . GONE : android . view . View . VISIBLE );
110+ btnExportUsb . setOnClickListener (
111+ v -> Toast . makeText ( activity , R . string . settings_usb_export_todo , Toast . LENGTH_LONG ). show () );
113112 }
114113 }
115114
116115 private void bindFields (SharedPreferences prefs , EditText etSegmentMin , EditText etTotalMin ,
117- EditText etRecordingFps , EditText etSignature ) {
116+ EditText etRecordingFps , EditText etSignature ) {
118117 android .text .TextWatcher watcher = new SimpleTextWatcher () {
119118 @ Override
120119 public void afterTextChanged (Editable s ) {
@@ -129,27 +128,31 @@ public void afterTextChanged(Editable s) {
129128 }
130129
131130 private void bindEditText (EditText editText , android .text .TextWatcher watcher , Runnable onBlur ) {
132- if (editText == null ) return ;
131+ if (editText == null )
132+ return ;
133133 editText .addTextChangedListener (watcher );
134134 editText .setOnFocusChangeListener ((v , hasFocus ) -> {
135- if (!hasFocus ) onBlur .run ();
135+ if (!hasFocus )
136+ onBlur .run ();
136137 });
137138 }
138139
139140 private void saveFields (SharedPreferences prefs , EditText etSegmentMin , EditText etTotalMin ,
140- EditText etRecordingFps , EditText etSignature , boolean normalizeFields ) {
141+ EditText etRecordingFps , EditText etSignature , boolean normalizeFields ) {
141142 int segmentMin = parsePositiveInt (textOf (etSegmentMin ), 3 );
142143 int totalMin = parsePositiveInt (textOf (etTotalMin ), 30 );
143144 int recordingFps = clampRecordingFps (parsePositiveInt (textOf (etRecordingFps ), DEFAULT_RECORDING_FPS ));
144145 String signature = normalizeSignature (textOf (etSignature ));
145- if (totalMin < segmentMin ) totalMin = segmentMin ;
146+ if (totalMin < segmentMin )
147+ totalMin = segmentMin ;
146148 prefs .edit ()
147149 .putInt (KEY_SEGMENT_MIN , segmentMin )
148150 .putInt (KEY_TOTAL_MIN , totalMin )
149151 .putInt (KEY_RECORDING_FPS , recordingFps )
150152 .putString (KEY_SIGNATURE , signature )
151153 .apply ();
152- if (!normalizeFields ) return ;
154+ if (!normalizeFields )
155+ return ;
153156 normalizeField (etSegmentMin , segmentMin );
154157 normalizeField (etTotalMin , totalMin );
155158 normalizeField (etRecordingFps , recordingFps );
@@ -173,18 +176,22 @@ private static int clampRecordingFps(int fps) {
173176 }
174177
175178 private void normalizeField (EditText editText , int value ) {
176- if (editText == null ) return ;
179+ if (editText == null )
180+ return ;
177181 String normalized = String .valueOf (value );
178182 String current = textOf (editText );
179- if (normalized .equals (current )) return ;
183+ if (normalized .equals (current ))
184+ return ;
180185 editText .setText (normalized );
181186 editText .setSelection (editText .getText ().length ());
182187 }
183188
184189 private void normalizeField (EditText editText , String value ) {
185- if (editText == null ) return ;
190+ if (editText == null )
191+ return ;
186192 String current = textOf (editText );
187- if (value .equals (current )) return ;
193+ if (value .equals (current ))
194+ return ;
188195 editText .setText (value );
189196 editText .setSelection (editText .getText ().length ());
190197 }
@@ -203,7 +210,8 @@ private int parsePositiveInt(String s, int def) {
203210 }
204211
205212 private static String normalizeSignature (String value ) {
206- if (value == null ) return "" ;
213+ if (value == null )
214+ return "" ;
207215 String trimmed = value .trim ();
208216 if (trimmed .length () <= MAX_SIGNATURE_LENGTH ) {
209217 return trimmed ;
@@ -212,23 +220,25 @@ private static String normalizeSignature(String value) {
212220 }
213221
214222 private boolean hasStoragePermission () {
215- return ContextCompat .checkSelfPermission (activity , Manifest . permission . WRITE_EXTERNAL_STORAGE )
216- == PackageManager .PERMISSION_GRANTED ;
223+ return ContextCompat .checkSelfPermission (activity ,
224+ Manifest . permission . WRITE_EXTERNAL_STORAGE ) == PackageManager .PERMISSION_GRANTED ;
217225 }
218226
219227 static File getRecordsBaseDir () {
220228 File downloads = Environment .getExternalStoragePublicDirectory (Environment .DIRECTORY_DOWNLOADS );
221229 File dir = new File (downloads , RECORDS_DIR_NAME );
222- //noinspection ResultOfMethodCallIgnored
230+ // noinspection ResultOfMethodCallIgnored
223231 dir .mkdirs ();
224232 return dir ;
225233 }
226234
227235 private File findMountedUsbRoot () {
228236 File storageDir = new File ("/storage" );
229- if (!storageDir .exists ()) return null ;
237+ if (!storageDir .exists ())
238+ return null ;
230239 File [] roots = storageDir .listFiles ();
231- if (roots == null ) return null ;
240+ if (roots == null )
241+ return null ;
232242 for (File root : roots ) {
233243 if (root .isDirectory () && root .canRead () && root .canWrite ()) {
234244 return root ;
0 commit comments