diff --git a/app/build.gradle b/app/build.gradle
index 6f5063c..b05c95a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -9,8 +9,8 @@ android {
applicationId "asgardius.page.s3manager"
minSdk 24
targetSdk 33
- versionCode 23
- versionName "0.1.21"
+ versionCode 24
+ versionName "0.1.22"
setProperty("archivesBaseName", "s3-manager-$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1a20301..e7950e6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -19,6 +19,14 @@
android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31">
+
+
+
();
- Img = new ArrayList();
- String query = "SELECT id FROM account";
- Cursor cursor = db.rawQuery(query,null);
- while (cursor.moveToNext()){
- Name.add(cursor.getString(0));
- Img.add(R.drawable.account);
- }
- db.close();
- } else {
- Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
+ // Database Queries
+ Name = new ArrayList();
+ Img = new ArrayList();
+ String query = "SELECT id FROM account";
+ Cursor cursor = db.rawQuery(query,null);
+ while (cursor.moveToNext()){
+ Name.add(cursor.getString(0));
+ Img.add(R.drawable.account);
}
+ db.close();
+ getprefs.start();
runOnUiThread(new Runnable() {
@Override
@@ -208,12 +271,12 @@ public class MainActivity extends AppCompatActivity {
});
//This is to view app credits
- Button about = (Button)findViewById(R.id.about_button);
- about.setOnClickListener(new View.OnClickListener(){
+ Button settings = (Button)findViewById(R.id.settings_button);
+ settings.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
//buttonaction
- aboutPage();
+ settingsPage();
}
});
}
@@ -226,6 +289,8 @@ public class MainActivity extends AppCompatActivity {
intent.putExtra("password", password);
intent.putExtra("region", location);
intent.putExtra("pdfendpoint", pdfendpoint);
+ intent.putExtra("videocache", videocache);
+ intent.putExtra("videotime", videotime);
startActivity(intent);
}
@@ -246,11 +311,11 @@ public class MainActivity extends AppCompatActivity {
}
- private void aboutPage () {
+ private void settingsPage() {
- Intent intent = new Intent(this, WebBrowser.class);
- intent.putExtra("web_url", "file:///android_asset/about.htm");
- intent.putExtra("title", getResources().getString(R.string.about_button));
+ Intent intent = new Intent(this, Settings.class);
+ //intent.putExtra("web_url", "file:///android_asset/about.htm");
+ //intent.putExtra("title", getResources().getString(R.string.about_button));
startActivity(intent);
}
diff --git a/app/src/main/java/asgardius/page/s3manager/MyDbHelper.java b/app/src/main/java/asgardius/page/s3manager/MyDbHelper.java
index c215b7a..e2f9928 100644
--- a/app/src/main/java/asgardius/page/s3manager/MyDbHelper.java
+++ b/app/src/main/java/asgardius/page/s3manager/MyDbHelper.java
@@ -5,7 +5,10 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class MyDbHelper extends SQLiteOpenHelper {
- private static final String atcreate = "CREATE TABLE IF NOT EXISTS account(id text UNIQUE, endpoint text, username text, password text, region text, pdfendpoint text)";
+ private static final String usertable = "CREATE TABLE IF NOT EXISTS account(id text UNIQUE, endpoint text, username text, password text, region text, pdfendpoint text)";
+ private static final String preftable = "CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)";
+ private static final String setvideocache = "INSERT INTO preferences VALUES ('videocache', '300')";
+ private static final String setvideotime = "INSERT INTO preferences VALUES ('videotime', '3')";
//private static final String upgrade = "ALTER TABLE account add column pdfendpoint text";
private static final int DATABASE_VERSION = 1;
private static final String dbname = "accounts.sqlite3";
@@ -15,7 +18,10 @@ public class MyDbHelper extends SQLiteOpenHelper {
}
@Override
public void onCreate(SQLiteDatabase db) {
- db.execSQL(atcreate);
+ db.execSQL(usertable);
+ db.execSQL(preftable);
+ db.execSQL(setvideocache);
+ db.execSQL(setvideotime);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
index d48f2ab..e35bc14 100644
--- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
+++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java
@@ -50,6 +50,7 @@ public class ObjectSelect extends AppCompatActivity {
AWSCredentials myCredentials;
AmazonS3 s3client;
ProgressBar simpleProgressBar;
+ int videocache, videotime;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -62,6 +63,8 @@ public class ObjectSelect extends AppCompatActivity {
pdfendpoint = getIntent().getStringExtra("pdfendpoint");
prefix = getIntent().getStringExtra("prefix");
treelevel = getIntent().getIntExtra("treelevel", 0);
+ videocache = getIntent().getIntExtra("videocache", 40);
+ videotime = getIntent().getIntExtra("videotime", 1);
setContentView(R.layout.activity_object_select);
getSupportActionBar().setTitle(bucket+"/"+prefix);
region = Region.getRegion(location);
@@ -287,7 +290,7 @@ public class ObjectSelect extends AppCompatActivity {
Calendar mycal = Calendar.getInstance();
mycal.setTime(expiration);
//System.out.println("today is " + mycal.getTime());
- mycal.add(Calendar.HOUR, 6);
+ mycal.add(Calendar.HOUR, videotime);
//System.out.println("Expiration date: " + mycal.getTime());
expiration = mycal.getTime();
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString()).withExpiration(expiration);;
@@ -404,6 +407,7 @@ public class ObjectSelect extends AppCompatActivity {
Intent intent = new Intent(this, VideoPlayer.class);
intent.putExtra("video_url", url);
+ intent.putExtra("videocache", videocache);
startActivity(intent);
}
@@ -444,6 +448,8 @@ public class ObjectSelect extends AppCompatActivity {
intent.putExtra("treelevel", treelevel+1);
intent.putExtra("region", location);
intent.putExtra("pdfendpoint", pdfendpoint);
+ intent.putExtra("videocache", videocache);
+ intent.putExtra("videotime", videotime);
startActivity(intent);
}
@@ -459,6 +465,7 @@ public class ObjectSelect extends AppCompatActivity {
intent.putExtra("object", object);
intent.putExtra("region", location);
intent.putExtra("mediafile", mediafile);
+ intent.putExtra("videotime", videotime);
startActivity(intent);
}
diff --git a/app/src/main/java/asgardius/page/s3manager/Settings.java b/app/src/main/java/asgardius/page/s3manager/Settings.java
new file mode 100644
index 0000000..942d6d3
--- /dev/null
+++ b/app/src/main/java/asgardius/page/s3manager/Settings.java
@@ -0,0 +1,134 @@
+package asgardius.page.s3manager;
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import asgardius.page.s3manager.databinding.ActivitySettingsBinding;
+
+public class Settings extends AppCompatActivity {
+
+ private ActivitySettingsBinding binding;
+ MyDbHelper dbHelper;
+ SQLiteDatabase db;
+ String videocache, videotime;
+ EditText vcachepick, vtimepick;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ binding = ActivitySettingsBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
+ vcachepick = (EditText)findViewById(R.id.videocache);
+ vtimepick = (EditText)findViewById(R.id.videotime);
+ dbHelper = new MyDbHelper(this);
+ Thread getprefs = new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ //Your code goes here
+ // Database Queries
+ db = dbHelper.getWritableDatabase();
+ String query = "SELECT value FROM preferences where setting='videocache'";
+ Cursor cursor = db.rawQuery(query,null);
+ while (cursor.moveToNext()){
+ videocache = (cursor.getString(0));
+ }
+ query = "SELECT value FROM preferences where setting='videotime'";
+ cursor = db.rawQuery(query,null);
+ while (cursor.moveToNext()){
+ videotime = (cursor.getString(0));
+ }
+ db.close();
+ runOnUiThread(new Runnable() {
+
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void run() {
+ vcachepick.setText(videocache);
+ vtimepick.setText(videotime);
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ runOnUiThread(new Runnable() {
+
+ @Override
+ public void run() {
+ Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
+ }
+ });
+ //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
+ finish();
+ }
+ }
+ });
+ getprefs.start();
+
+ //This is to add new user account
+ Button saveprefs = (Button)findViewById(R.id.saveprefs);
+ saveprefs.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View view) {
+ //buttonaction
+ try {
+ videocache = vcachepick.getText().toString();
+ videotime = vtimepick.getText().toString();
+ if (videocache.equals("") || videotime.equals("")) {
+ Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_null), 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.close();
+ mainmenu();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
+ }
+ //This launch account add screen
+ //addaccount(false);
+ }
+ });
+
+ //This is to view app credits
+ Button about = (Button)findViewById(R.id.settings_button);
+ about.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View view) {
+ //buttonaction
+ aboutPage();
+ }
+ });
+ }
+
+ private void aboutPage () {
+
+ Intent intent = new Intent(this, WebBrowser.class);
+ intent.putExtra("web_url", "file:///android_asset/about.htm");
+ intent.putExtra("title", getResources().getString(R.string.about_button));
+ startActivity(intent);
+
+ }
+
+ private void mainmenu() {
+
+ Intent intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ intent.putExtra("EXIT", true);
+ startActivity(intent);
+
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/asgardius/page/s3manager/Share.java b/app/src/main/java/asgardius/page/s3manager/Share.java
index 978c075..dcd6769 100644
--- a/app/src/main/java/asgardius/page/s3manager/Share.java
+++ b/app/src/main/java/asgardius/page/s3manager/Share.java
@@ -36,6 +36,7 @@ public class Share extends AppCompatActivity {
GeneratePresignedUrlRequest request;
Date expiration;
URL objectURL;
+ int videotime;
public static String URLify(String str) {
str = str.trim();
@@ -85,6 +86,7 @@ public class Share extends AppCompatActivity {
location = getIntent().getStringExtra("region");
object = getIntent().getStringExtra("object");
mediafile = getIntent().getBooleanExtra("mediafile", false);
+ videotime = getIntent().getIntExtra("videotime", 1);
region = Region.getRegion(location);
s3ClientOptions = S3ClientOptions.builder().build();
myCredentials = new BasicAWSCredentials(username, password);
@@ -144,7 +146,7 @@ public class Share extends AppCompatActivity {
expiration = new Date();
mycal.setTime(expiration);
//System.out.println("today is " + mycal.getTime());
- mycal.add(Calendar.HOUR, 6);
+ mycal.add(Calendar.HOUR, videotime);
//System.out.println("Expiration date: " + mycal.getTime());
expiration = mycal.getTime();
request = new GeneratePresignedUrlRequest(bucket, object).withExpiration(expiration);
diff --git a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java
index e6730fe..3dad90d 100644
--- a/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java
+++ b/app/src/main/java/asgardius/page/s3manager/VideoPlayer.java
@@ -35,8 +35,9 @@ public class VideoPlayer extends AppCompatActivity {
private WifiManager.WifiLock mWifiLock;
private PowerManager.WakeLock mWakeLock;
private PowerManager powerManager;
- private long maxCacheSize = 1024 * 1024 * 1024;
+ private long maxCacheSize;
SimpleCache simpleCache;
+ int videocache;
ExoPlayer player;
@@ -50,6 +51,8 @@ public class VideoPlayer extends AppCompatActivity {
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Transistor:wake_lock");
//Get media url
String videoURL = getIntent().getStringExtra("video_url");
+ videocache = getIntent().getIntExtra("videocache", 40);
+ maxCacheSize = (long)videocache * 1024 * 1024;
playerView = findViewById(R.id.player_view);
// creating a variable for exoplayer
player = new ExoPlayer.Builder(this).build();
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 5deca80..1766de0 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -27,11 +27,11 @@
style="?android:attr/buttonStyle" />
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
new file mode 100644
index 0000000..c6c58c6
--- /dev/null
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/content_settings.xml b/app/src/main/res/layout/content_settings.xml
new file mode 100644
index 0000000..79a1dee
--- /dev/null
+++ b/app/src/main/res/layout/content_settings.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index c1fba4e..bf27075 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -85,4 +85,8 @@
Archivos
Debe establecer una fecha de expiración para compartir archivos
Descarga cancelada
+ Ajustes
+ Guardar ajustes
+ Tamaño máximo de cache multimedia (en MiB)
+ Tiempo de expiración para visor multimedia (en horas)
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 995cdd6..9cebc5d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -89,4 +89,8 @@
About this app
Dummy Button
DUMMY\nCONTENT
+ Settings
+ Save settings
+ Max media cache size (in MiB)
+ Expiration time for media viewer (in hours)
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 1a59a11..a689e45 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -26,4 +26,13 @@
- @color/light_blue_600
- @color/light_blue_A200
+
+
+
+
+
+
\ No newline at end of file