diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..ac93b0d --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index bd29643..5d43582 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "asgardius.page.s3manager" minSdk 24 targetSdk 33 - versionCode 11 - versionName "0.1.9" + versionCode 12 + versionName "0.1.10" setProperty("archivesBaseName", "s3-manager-$versionName") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/assets/about.htm b/app/src/main/assets/about.htm index cd339d0..7ba4b90 100644 --- a/app/src/main/assets/about.htm +++ b/app/src/main/assets/about.htm @@ -12,10 +12,13 @@
  • Amazon Web Services SDK 2.53.0
  • ExoPlayer 2.18.1
  • Adwaita Icon Theme for GNOME 43
  • +
  • pdf.js
  • This software released under GNU General Public License 3

    You can find source code at https://patrice.asgardius.company/gitea/asgardius/s3manager
    + You need to setup a pdf.js server to use pdf viewer. Just download latest version from official website and upload to any web server with ssl on same root domain than S3 server (can be same subdomain or a different one). Then set url to pdfjs root folder like https://example.com/pdfjs-dist +
    You can find technical support on official forum https://forum.asgardius.company/t/s3-manager

    diff --git a/app/src/main/java/asgardius/page/s3manager/AccountAdd.java b/app/src/main/java/asgardius/page/s3manager/AccountAdd.java index 09b2d79..6c4de51 100644 --- a/app/src/main/java/asgardius/page/s3manager/AccountAdd.java +++ b/app/src/main/java/asgardius/page/s3manager/AccountAdd.java @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.List; public class AccountAdd extends AppCompatActivity { - EditText aapick, aupick, appick, aepick, arpick; - String alias, username, password, endpoint, id, location; + EditText aapick, aupick, appick, aepick, arpick, pdfpick; + String alias, username, password, endpoint, id, location, pdfendpoint; AWSCredentials myCredentials; AmazonS3 s3client; Region region; @@ -36,6 +36,7 @@ public class AccountAdd extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_account_add); aapick = (EditText)findViewById(R.id.alias); + pdfpick = (EditText)findViewById(R.id.pdfendpoint); aepick = (EditText)findViewById(R.id.endpoint); arpick = (EditText)findViewById(R.id.region); aupick = (EditText)findViewById(R.id.username); @@ -51,12 +52,14 @@ public class AccountAdd extends AppCompatActivity { username = getIntent().getStringExtra("username"); password = getIntent().getStringExtra("password"); location = getIntent().getStringExtra("region"); + pdfendpoint = getIntent().getStringExtra("pdfendpoint"); aapick.setText(id); //aapick.setEnabled(false); aepick.setText(endpoint); aupick.setText(username); appick.setText(password); arpick.setText(location); + pdfpick.setText(pdfendpoint); } else{ getSupportActionBar().setTitle(getResources().getString(R.string.accountadd_button)); } @@ -68,6 +71,7 @@ public class AccountAdd extends AppCompatActivity { public void onClick(View view) { //buttonaction alias = aapick.getText().toString(); + pdfendpoint = pdfpick.getText().toString(); endpoint = aepick.getText().toString(); location = arpick.getText().toString(); username = aupick.getText().toString(); @@ -76,11 +80,12 @@ public class AccountAdd extends AppCompatActivity { if (alias.equals("") && endpoint.equals("") && username.equals(getResources().getString(R.string.access_key))) { endpoint = getResources().getString(R.string.endpoint_url); alias = "Google Test"; + pdfendpoint = getResources().getString(R.string.pdf_reader); } SQLiteDatabase db = dbHelper.getWritableDatabase(); if (alias.equals("") || endpoint.equals("") || username.equals("") || password.equals("")) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_null), Toast.LENGTH_SHORT).show(); - } else if (endpoint.startsWith("http://")) { + } else if (endpoint.startsWith("http://") || pdfendpoint.startsWith("http://")) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.nosslwarning), Toast.LENGTH_SHORT).show(); } else if (!endpoint.startsWith("https://")) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.invalid_url), Toast.LENGTH_SHORT).show(); @@ -91,10 +96,10 @@ public class AccountAdd extends AppCompatActivity { location = "us-east-1"; } if (edit) { - db.execSQL("UPDATE account SET id=\""+id+"\", endpoint=\""+endpoint+"\", username=\""+username+"\", password=\""+password+"\", region=\""+location+"\" WHERE id=\""+id+"\""); + db.execSQL("UPDATE account SET id=\""+id+"\", endpoint=\""+endpoint+"\", username=\""+username+"\", password=\""+password+"\", region=\""+location+"\", pdfendpoint=\""+pdfendpoint+"\" WHERE id=\""+id+"\""); Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountsave_success), Toast.LENGTH_SHORT).show(); } else { - db.execSQL("INSERT INTO account VALUES (\""+alias+"\", \""+endpoint+"\", \""+username+"\", \""+password+"\", \""+location+"\")"); + db.execSQL("INSERT INTO account VALUES (\""+alias+"\", \""+endpoint+"\", \""+username+"\", \""+password+"\", \""+location+"\", \""+pdfendpoint+"\")"); Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_success), Toast.LENGTH_SHORT).show(); } mainmenu(); diff --git a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java index b39a139..60e4e28 100644 --- a/app/src/main/java/asgardius/page/s3manager/BucketSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/BucketSelect.java @@ -40,7 +40,7 @@ public class BucketSelect extends AppCompatActivity { ArrayList Name; ArrayList Img; RecyclerView recyclerView; - String username, password, endpoint, prefix, location, file; + String username, password, endpoint, prefix, location, file, pdfendpoint; int treelevel; Region region; S3ClientOptions s3ClientOptions; @@ -55,6 +55,7 @@ public class BucketSelect extends AppCompatActivity { username = getIntent().getStringExtra("username"); password = getIntent().getStringExtra("password"); location = getIntent().getStringExtra("region"); + pdfendpoint = getIntent().getStringExtra("pdfendpoint"); prefix = ""; setContentView(R.layout.activity_bucket_select); region = Region.getRegion("us-east-1"); @@ -189,6 +190,7 @@ public class BucketSelect extends AppCompatActivity { intent.putExtra("prefix", prefix); intent.putExtra("treelevel", treelevel); intent.putExtra("region", location); + intent.putExtra("pdfendpoint", pdfendpoint); startActivity(intent); } diff --git a/app/src/main/java/asgardius/page/s3manager/MainActivity.java b/app/src/main/java/asgardius/page/s3manager/MainActivity.java index c42b942..88b4664 100644 --- a/app/src/main/java/asgardius/page/s3manager/MainActivity.java +++ b/app/src/main/java/asgardius/page/s3manager/MainActivity.java @@ -21,7 +21,7 @@ import java.util.ArrayList; public class MainActivity extends AppCompatActivity { static boolean DEFAULT_PATH_STYLE_ACCESS = true; - String alias, username, password, endpoint, location; + String alias, username, password, endpoint, location, pdfendpoint; RecyclerView recyclerView; SQLiteDatabase db; ArrayList Name; @@ -98,18 +98,20 @@ public class MainActivity extends AppCompatActivity { if (db != null) { // Database Queries try { - String query = "SELECT endpoint, username, password, region FROM account where id=\""+ Name.get(position).toString()+ "\""; + String query = "SELECT endpoint, username, password, region, pdfendpoint FROM account where id=\""+ Name.get(position).toString()+ "\""; Cursor cursor = db.rawQuery(query,null); if (cursor.moveToNext()){ endpoint = cursor.getString(0); username = cursor.getString(1); password = cursor.getString(2); location = cursor.getString(3); + pdfendpoint = cursor.getString(4); db.close(); explorer(); } } catch (Exception e) { e.printStackTrace(); + db.execSQL("ALTER TABLE account add column pdfendpoint text"); } } @@ -131,7 +133,7 @@ public class MainActivity extends AppCompatActivity { if (menuItem.getTitle() == getResources().getString(R.string.accountedit_button)) { try { db = dbHelper.getWritableDatabase(); - String query = "SELECT id, endpoint, username, password, region FROM account where id=\""+ Name.get(position).toString()+ "\""; + String query = "SELECT id, endpoint, username, password, region, pdfendpoint FROM account where id=\""+ Name.get(position).toString()+ "\""; System.out.println(query); Cursor cursor = db.rawQuery(query,null); if (cursor.moveToNext()){ @@ -140,12 +142,14 @@ public class MainActivity extends AppCompatActivity { username = cursor.getString(2); password = cursor.getString(3); location = cursor.getString(4); + pdfendpoint = cursor.getString(5); } db.close(); addaccount(true); //Toast.makeText(MainActivity.this, "This feature is not yet implemented", Toast.LENGTH_SHORT).show(); } catch (Exception e) { e.printStackTrace(); + db.execSQL("ALTER TABLE account add column pdfendpoint text"); } } else if (menuItem.getTitle() == getResources().getString(R.string.accountdel_button)) { @@ -218,6 +222,7 @@ public class MainActivity extends AppCompatActivity { intent.putExtra("username", username); intent.putExtra("password", password); intent.putExtra("region", location); + intent.putExtra("pdfendpoint", pdfendpoint); startActivity(intent); } @@ -231,6 +236,7 @@ public class MainActivity extends AppCompatActivity { intent.putExtra("username", username); intent.putExtra("password", password); intent.putExtra("region", location); + intent.putExtra("pdfendpoint", pdfendpoint); } intent.putExtra("edit", edit); 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 34d144f..0674507 100644 --- a/app/src/main/java/asgardius/page/s3manager/MyDbHelper.java +++ b/app/src/main/java/asgardius/page/s3manager/MyDbHelper.java @@ -5,7 +5,9 @@ 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)"; + 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 atupgrade = "ALTER TABLE account add column pdfendpoint text"; + private static final int DATABASE_VERSION = 1; private static final String dbname = "accounts.sqlite3"; private static final int dbversion = 3; public MyDbHelper(Context context) { @@ -17,6 +19,6 @@ public class MyDbHelper extends SQLiteOpenHelper { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - + db.execSQL(atupgrade); } } diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index 876487a..f3b53f2 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -29,6 +29,7 @@ import com.amazonaws.services.s3.model.ObjectListing; import com.amazonaws.services.s3.model.S3ObjectSummary; import java.net.URL; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; @@ -40,7 +41,7 @@ public class ObjectSelect extends AppCompatActivity { ArrayList Img; //ArrayList object; RecyclerView recyclerView; - String username, password, endpoint, bucket, prefix, location; + String username, password, endpoint, bucket, prefix, location, pdfendpoint; int treelevel; String[] filename; Region region; @@ -57,6 +58,7 @@ public class ObjectSelect extends AppCompatActivity { password = getIntent().getStringExtra("password"); bucket = getIntent().getStringExtra("bucket"); location = getIntent().getStringExtra("region"); + pdfendpoint = getIntent().getStringExtra("pdfendpoint"); prefix = getIntent().getStringExtra("prefix"); treelevel = getIntent().getIntExtra("treelevel", 0); setContentView(R.layout.activity_object_select); @@ -132,6 +134,9 @@ public class ObjectSelect extends AppCompatActivity { else if (Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".txt") || Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".md")) { Img.add(R.drawable.textfile); } + else if (Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".pdf")) { + Img.add(R.drawable.pdffile); + } else if (Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".jpg") || Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".jpeg") || Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".png") || Name.get(i).toString().toLowerCase(Locale.ROOT).endsWith(".gif")) { Img.add(R.drawable.imagefile); } @@ -219,6 +224,23 @@ public class ObjectSelect extends AppCompatActivity { } catch (Exception e) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); } + } else if (Img.get(position).equals(R.drawable.pdffile)) { + //load media file + try { + GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString()); + URL objectURL = s3client.generatePresignedUrl(request); + //System.out.println(getResources().getString(R.string.pdf_reader)+ URLEncoder.encode(objectURL.toString(), "UTF-8" )); + if (pdfendpoint == null) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.pdf_reader_notready), Toast.LENGTH_SHORT).show(); + } else if (pdfendpoint.endsWith("/")) { + webBrowser(pdfendpoint + "web/viewer.html?file=" + URLEncoder.encode(objectURL.toString(), "UTF-8" ), Name.get(position).toString()); + } else { + webBrowser(pdfendpoint + "/web/viewer.html?file=" + URLEncoder.encode(objectURL.toString(), "UTF-8" ), Name.get(position).toString()); + } + + } catch (Exception e) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + } } else if (Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile)) { //load media file try { @@ -350,6 +372,7 @@ public class ObjectSelect extends AppCompatActivity { intent.putExtra("prefix", prefix + object); intent.putExtra("treelevel", treelevel+1); intent.putExtra("region", location); + intent.putExtra("pdfendpoint", pdfendpoint); startActivity(intent); } diff --git a/app/src/main/java/asgardius/page/s3manager/WebBrowser.java b/app/src/main/java/asgardius/page/s3manager/WebBrowser.java index 773b341..a10afb4 100644 --- a/app/src/main/java/asgardius/page/s3manager/WebBrowser.java +++ b/app/src/main/java/asgardius/page/s3manager/WebBrowser.java @@ -3,12 +3,14 @@ package asgardius.page.s3manager; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; +import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class WebBrowser extends AppCompatActivity { - private WebView npw; + private WebView browser; + WebSettings webSettings; String webURL, pagetitle; @Override protected void onCreate(Bundle savedInstanceState) { @@ -19,9 +21,11 @@ public class WebBrowser extends AppCompatActivity { webURL = getIntent().getStringExtra("web_url"); pagetitle = getIntent().getStringExtra("title"); getSupportActionBar().setTitle(pagetitle); - npw =(WebView)findViewById(R.id.webview); - npw.setWebViewClient(new MyBrowser()); - npw.loadUrl(webURL); + browser =(WebView)findViewById(R.id.webview); + webSettings = browser.getSettings(); + webSettings.setJavaScriptEnabled(true); + browser.setWebViewClient(new MyBrowser()); + browser.loadUrl(webURL); } catch (Exception e) { e.printStackTrace(); finish(); diff --git a/app/src/main/res/drawable/pdffile.png b/app/src/main/res/drawable/pdffile.png new file mode 100644 index 0000000..547b124 Binary files /dev/null and b/app/src/main/res/drawable/pdffile.png differ diff --git a/app/src/main/res/layout/activity_account_add.xml b/app/src/main/res/layout/activity_account_add.xml index f4d3e41..a25b90f 100644 --- a/app/src/main/res/layout/activity_account_add.xml +++ b/app/src/main/res/layout/activity_account_add.xml @@ -7,10 +7,20 @@ android:orientation="vertical" tools:context=".AccountAdd"> - + + + + + + Acerca de esta app Botón de prueba Contenido de prueba + servidor pdfjs + Necesita configurar un servidor pdf.js \ 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 d2a4560..bc82eb8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,6 +2,8 @@ S3 Manager .amazonaws.com https://object.asgardius.company + https://office.asgardius.company/pdfjs + You need to setup a pdf.js server google Account list Bucket list @@ -45,6 +47,7 @@ Test credentials Credentials are correct Account Alias + pdfjs server S3 Endpoint URL S3 Region S3 Access Key