13
13
14
14
import javax .annotation .Nonnull ;
15
15
16
- public class TermuxSharedProperties implements SharedPropertiesParser {
16
+ public class TermuxSharedProperties {
17
17
18
18
protected final Context mContext ;
19
19
protected final SharedProperties mSharedProperties ;
@@ -24,7 +24,7 @@ public class TermuxSharedProperties implements SharedPropertiesParser {
24
24
public TermuxSharedProperties (@ Nonnull Context context ) {
25
25
mContext = context ;
26
26
mPropertiesFile = TermuxPropertyConstants .getTermuxPropertiesFile ();
27
- mSharedProperties = new SharedProperties (context , mPropertiesFile , TermuxPropertyConstants .TERMUX_PROPERTIES_LIST , this );
27
+ mSharedProperties = new SharedProperties (context , mPropertiesFile , TermuxPropertyConstants .TERMUX_PROPERTIES_LIST , new SharedPropertiesParserClient () );
28
28
loadTermuxPropertiesFromDisk ();
29
29
}
30
30
@@ -146,24 +146,47 @@ public Object getInternalPropertyValue(String key, boolean cached) {
146
146
// {@link #loadTermuxPropertiesFromDisk()} call
147
147
// A null value can still be returned by
148
148
// {@link #getInternalPropertyValueFromValue(Context,String,String)} for some keys
149
- value = getInternalPropertyValueFromValue (mContext , key , null );
149
+ value = getInternalTermuxPropertyValueFromValue (mContext , key , null );
150
150
Logger .logWarn (LOG_TAG , "The value for \" " + key + "\" not found in SharedProperties cache, force returning default value: `" + value + "`" );
151
151
return value ;
152
152
}
153
153
} else {
154
154
// We get the property value directly from file and return its internal value
155
- return getInternalPropertyValueFromValue (mContext , key , mSharedProperties .getProperty (key , false ));
155
+ return getInternalTermuxPropertyValueFromValue (mContext , key , mSharedProperties .getProperty (key , false ));
156
156
}
157
157
}
158
158
159
+
160
+
161
+
162
+
159
163
/**
160
- * Override the
161
- * {@link SharedPropertiesParser#getInternalPropertyValueFromValue(Context,String,String)}
162
- * interface function.
164
+ * Get the internal {@link Object} value for the key passed from the file returned by
165
+ * {@link TermuxPropertyConstants#getTermuxPropertiesFile()}. The {@link Properties} object is
166
+ * read directly from the file and internal value is returned for the property value against the key.
167
+ *
168
+ * @param context The context for operations.
169
+ * @param key The key for which the internal object is required.
170
+ * @return Returns the {@link Object} object. This will be {@code null} if key is not found or
171
+ * the object stored against the key is {@code null}.
163
172
*/
164
- @ Override
165
- public Object getInternalPropertyValueFromValue (Context context , String key , String value ) {
166
- return getInternalTermuxPropertyValueFromValue (context , key , value );
173
+ public static Object getInternalPropertyValue (Context context , String key ) {
174
+ return SharedProperties .getInternalProperty (context , TermuxPropertyConstants .getTermuxPropertiesFile (), key , new SharedPropertiesParserClient ());
175
+ }
176
+
177
+ /**
178
+ * The class that implements the {@link SharedPropertiesParser} interface.
179
+ */
180
+ public static class SharedPropertiesParserClient implements SharedPropertiesParser {
181
+ /**
182
+ * Override the
183
+ * {@link SharedPropertiesParser#getInternalPropertyValueFromValue(Context,String,String)}
184
+ * interface function.
185
+ */
186
+ @ Override
187
+ public Object getInternalPropertyValueFromValue (Context context , String key , String value ) {
188
+ return getInternalTermuxPropertyValueFromValue (context , key , value );
189
+ }
167
190
}
168
191
169
192
/**
@@ -194,6 +217,8 @@ public static Object getInternalTermuxPropertyValueFromValue(Context context, St
194
217
return (int ) getBellBehaviourInternalPropertyValueFromValue (value );
195
218
case TermuxPropertyConstants .KEY_TERMINAL_CURSOR_BLINK_RATE :
196
219
return (int ) getTerminalCursorBlinkRateInternalPropertyValueFromValue (value );
220
+ case TermuxPropertyConstants .KEY_TERMINAL_TRANSCRIPT_ROWS :
221
+ return (int ) getTerminalTranscriptRowsInternalPropertyValueFromValue (value );
197
222
198
223
/* float */
199
224
case TermuxPropertyConstants .KEY_TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR :
@@ -263,9 +288,9 @@ public static int getBellBehaviourInternalPropertyValueFromValue(String value) {
263
288
264
289
/**
265
290
* Returns the int for the value if its not null and is between
266
- * {@code TermuxPropertyConstants#IVALUE_TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR_MIN } and
267
- * {@code TermuxPropertyConstants#IVALUE_TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR_MAX },
268
- * otherwise returns {@code TermuxPropertyConstants#DEFAULT_IVALUE_TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR }.
291
+ * {@code TermuxPropertyConstants#IVALUE_TERMINAL_CURSOR_BLINK_RATE_MIN } and
292
+ * {@code TermuxPropertyConstants#IVALUE_TERMINAL_CURSOR_BLINK_RATE_MAX },
293
+ * otherwise returns {@code TermuxPropertyConstants#DEFAULT_IVALUE_TERMINAL_CURSOR_BLINK_RATE }.
269
294
*
270
295
* @param value The {@link String} value to convert.
271
296
* @return Returns the internal value for value.
@@ -279,6 +304,24 @@ public static float getTerminalCursorBlinkRateInternalPropertyValueFromValue(Str
279
304
true , true , LOG_TAG );
280
305
}
281
306
307
+ /**
308
+ * Returns the int for the value if its not null and is between
309
+ * {@code TermuxPropertyConstants#IVALUE_TERMINAL_TRANSCRIPT_ROWS_MIN} and
310
+ * {@code TermuxPropertyConstants#IVALUE_TERMINAL_TRANSCRIPT_ROWS_MAX},
311
+ * otherwise returns {@code TermuxPropertyConstants#DEFAULT_IVALUE_TERMINAL_TRANSCRIPT_ROWS}.
312
+ *
313
+ * @param value The {@link String} value to convert.
314
+ * @return Returns the internal value for value.
315
+ */
316
+ public static float getTerminalTranscriptRowsInternalPropertyValueFromValue (String value ) {
317
+ return SharedProperties .getDefaultIfNotInRange (TermuxPropertyConstants .KEY_TERMINAL_TRANSCRIPT_ROWS ,
318
+ DataUtils .getIntFromString (value , TermuxPropertyConstants .DEFAULT_IVALUE_TERMINAL_TRANSCRIPT_ROWS ),
319
+ TermuxPropertyConstants .DEFAULT_IVALUE_TERMINAL_TRANSCRIPT_ROWS ,
320
+ TermuxPropertyConstants .IVALUE_TERMINAL_TRANSCRIPT_ROWS_MIN ,
321
+ TermuxPropertyConstants .IVALUE_TERMINAL_TRANSCRIPT_ROWS_MAX ,
322
+ true , true , LOG_TAG );
323
+ }
324
+
282
325
/**
283
326
* Returns the int for the value if its not null and is between
284
327
* {@code TermuxPropertyConstants#IVALUE_TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR_MIN} and
@@ -435,6 +478,10 @@ public int getTerminalCursorBlinkRate() {
435
478
return (int ) getInternalPropertyValue (TermuxPropertyConstants .KEY_TERMINAL_CURSOR_BLINK_RATE , true );
436
479
}
437
480
481
+ public int getTerminalTranscriptRows () {
482
+ return (int ) getInternalPropertyValue (TermuxPropertyConstants .KEY_TERMINAL_TRANSCRIPT_ROWS , true );
483
+ }
484
+
438
485
public float getTerminalToolbarHeightScaleFactor () {
439
486
return (float ) getInternalPropertyValue (TermuxPropertyConstants .KEY_TERMINAL_TOOLBAR_HEIGHT_SCALE_FACTOR , true );
440
487
}
0 commit comments