From c34010680f92fe200ee19ac7a7fcaf127b471e16 Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Sat, 17 Sep 2022 12:35:34 -0700 Subject: [PATCH] pdf support via pdfjs --- .../asgardius/page/s3manager/ObjectSelect.java | 14 ++++++++++++++ .../asgardius/page/s3manager/WebBrowser.java | 12 ++++++++---- app/src/main/res/drawable/pdffile.png | Bin 0 -> 11584 bytes app/src/main/res/values/strings.xml | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/pdffile.png diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index 876487a..d8a4ed5 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; @@ -132,6 +133,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 +223,16 @@ 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" )); + webBrowser(getResources().getString(R.string.pdf_reader)+ 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 { 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 0000000000000000000000000000000000000000..547b1240d0562996820d3f9f399c72a3705c869c GIT binary patch literal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X3k{<{BbQf5YTTg z-gNbSzg3Kx3X}-Tv>P8~C`&Per0Yu!w(nNEPFLtxzaA0o7NXlc-YLy&+f}kP*NINR zx6pV)Qp@Yfm$d%G>EteDa|BOMk6hoGiC0_g(6oUkZC>k@5c0#d5U+!zwRi2oGp{}$-3l*PTVHw>-!??Ed0aa_RXTz$W&Ab6j!KUvAMCaa zX`5>6OXqm)&=9@(-KEZXs5QBGUy02-U#HGQv9HQr3ld2OncKxC-&`HH7Z~gR^mY(M zKb+TfP`_)adTo2xb+`XLD+o9l*lnb=v)T#|5xz0>jyisLj{UZG->&F;bvF}*(} zinFGdGT+RSbnR;6jqRolk6L{6!%;Jg3)20A{Z;?ze<$JmYezP+#w%jm>PzPdvI?vz zrR|p+GvQH-{)Yj<8T{xfwT<~Qmw-+G?Y*7XD^Go0|1tET{qM1K5*VyfTQbH?)6`dH z9@823c7{~CT;@x;AT~`K{!#{uK?+JI(uyCLxNK~_fYLn`GKDi_KxtaZcx33b>2~7^ k6ZN?2b@2b~moP+U+WB)P@2-C8yS3 Manager .amazonaws.com https://object.asgardius.company + https://office.asgardius.company/pdfjs/web/viewer.html?file= google Account list Bucket list