buffer settings

This commit is contained in:
Page Asgardius 2022-10-08 09:34:20 -07:00
parent fa314adfc3
commit bf03f92dbc
6 changed files with 38 additions and 4 deletions

View file

@ -21,6 +21,7 @@
tools:targetApi="31">
<activity
android:name=".Settings"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|keyboardHidden"
android:exported="false"
android:label="@string/settings">
<meta-data

View file

@ -54,6 +54,7 @@ public class AccountAdd extends AppCompatActivity {
location = getIntent().getStringExtra("region");
pdfendpoint = getIntent().getStringExtra("pdfendpoint");
aapick.setText(id);
aepick.setText(endpoint);
//aapick.setEnabled(false);
aupick.setText(username);
appick.setText(password);

View file

@ -20,8 +20,8 @@ public class Settings extends AppCompatActivity {
private ActivitySettingsBinding binding;
MyDbHelper dbHelper;
SQLiteDatabase db;
String videocache, videotime;
EditText vcachepick, vtimepick;
String videocache, videotime, buffersize;
EditText vcachepick, vtimepick, bsizepick;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -31,6 +31,7 @@ public class Settings extends AppCompatActivity {
setContentView(binding.getRoot());
vcachepick = (EditText)findViewById(R.id.videocache);
vtimepick = (EditText)findViewById(R.id.videotime);
bsizepick = (EditText)findViewById(R.id.buffersize);
dbHelper = new MyDbHelper(this);
Thread getprefs = new Thread(new Runnable() {
@ -50,6 +51,11 @@ public class Settings extends AppCompatActivity {
while (cursor.moveToNext()){
videotime = (cursor.getString(0));
}
query = "SELECT value FROM preferences where setting='buffersize'";
cursor = db.rawQuery(query,null);
while (cursor.moveToNext()){
buffersize = (cursor.getString(0));
}
db.close();
runOnUiThread(new Runnable() {
@ -58,6 +64,7 @@ public class Settings extends AppCompatActivity {
public void run() {
vcachepick.setText(videocache);
vtimepick.setText(videotime);
bsizepick.setText(buffersize);
}
});
} catch (Exception e) {
@ -85,14 +92,18 @@ public class Settings extends AppCompatActivity {
try {
videocache = vcachepick.getText().toString();
videotime = vtimepick.getText().toString();
if (videocache.equals("") || videotime.equals("")) {
buffersize = bsizepick.getText().toString();
if (videocache.equals("") || videotime.equals("") || buffersize.equals("")) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_null), Toast.LENGTH_SHORT).show();
}else if (Integer.parseInt(videotime) > 168) {
} else if (Integer.parseInt(buffersize) <= 2000) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.buffersize_error), Toast.LENGTH_SHORT).show();
} else if (Integer.parseInt(videotime) > 168) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.invalid_expiration_date), Toast.LENGTH_SHORT).show();
} else {
db = dbHelper.getWritableDatabase();
db.execSQL("UPDATE preferences SET value='" + videocache + "' where setting='videocache'");
db.execSQL("UPDATE preferences SET value='" + videotime + "' where setting='videotime'");
db.execSQL("UPDATE preferences SET value='" + buffersize + "' where setting='buffersize'");
db.close();
mainmenu();
}

View file

@ -48,6 +48,23 @@
android:inputType="number"
android:textColorHint="?attr/colorOnSecondary"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/buffersize"
android:textAlignment="center"
android:textSize="25sp"/>
<EditText
android:id="@+id/buffersize"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_weight="1"
android:focusable="true"
android:hint="@string/buffersize"
android:inputType="number"
android:textColorHint="?attr/colorOnSecondary"/>
<Button
android:id="@+id/saveprefs"
android:layout_width="match_parent"

View file

@ -89,4 +89,6 @@
<string name="save_settings">Guardar ajustes</string>
<string name="videocache">Tamaño máximo de cache multimedia (en MiB)</string>
<string name="videotime">Tiempo de expiración para visor multimedia (en horas)</string>
<string name="buffersize">Tamaño del buffer del reproductor multimedia (en milisegundos)</string>
<string name="buffersize_error">El tamaño del búfer debe ser de al menos 2001 milisegundos</string>
</resources>

View file

@ -93,4 +93,6 @@
<string name="save_settings">Save settings</string>
<string name="videocache">Max media cache size (in MiB)</string>
<string name="videotime">Expiration time for media viewer (in hours)</string>
<string name="buffersize">Media player buffer size (in milliseconds)</string>
<string name="buffersize_error">Buffer size must be at least 2001 milliseconds</string>
</resources>