pdf support via pdfjs
This commit is contained in:
parent
74700dd23f
commit
c34010680f
4 changed files with 23 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
BIN
app/src/main/res/drawable/pdffile.png
Normal file
BIN
app/src/main/res/drawable/pdffile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -2,6 +2,7 @@
|
|||
<string name="app_name" translatable="false">S3 Manager</string>
|
||||
<string name="aws_endpoint" translatable="false">.amazonaws.com</string>
|
||||
<string name="endpoint_url" translatable="false">https://object.asgardius.company</string>
|
||||
<string name="pdf_reader" translatable="false">https://office.asgardius.company/pdfjs/web/viewer.html?file=</string>
|
||||
<string name="access_key" translatable="false">google</string>
|
||||
<string name="account_list">Account list</string>
|
||||
<string name="bucket_list">Bucket list</string>
|
||||
|
|
Loading…
Reference in a new issue