web browser implemented

This commit is contained in:
Page Asgardius 2022-09-06 03:58:42 -07:00
parent fb13bfe897
commit 745c8fff7a
7 changed files with 66 additions and 2 deletions

View file

@ -9,6 +9,7 @@
<entry key="app/src/main/res/layout/activity_main.xml" value="0.1" /> <entry key="app/src/main/res/layout/activity_main.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_object_select.xml" value="0.1" /> <entry key="app/src/main/res/layout/activity_object_select.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" /> <entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" />
<entry key="app/src/main/res/layout/activity_web_view.xml" value="0.17119565217391305" />
<entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" /> <entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" />
<entry key="app/src/main/res/menu/popup_menu.xml" value="0.2713541666666667" /> <entry key="app/src/main/res/menu/popup_menu.xml" value="0.2713541666666667" />
</map> </map>

View file

@ -15,6 +15,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AsgardiusS3Manager" android:theme="@style/Theme.AsgardiusS3Manager"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".WebBrowser"
android:exported="false" />
<activity <activity
android:name=".AccountAdd" android:name=".AccountAdd"
android:exported="false" /> android:exported="false" />

View file

@ -126,6 +126,9 @@ public class ObjectSelect extends AppCompatActivity {
|| Name.get(i).toString().endsWith(".webm") || Name.get(i).toString().endsWith(".m4v")) { || Name.get(i).toString().endsWith(".webm") || Name.get(i).toString().endsWith(".m4v")) {
Img.add(R.drawable.videofile); Img.add(R.drawable.videofile);
} }
else if (Name.get(i).toString().endsWith(".htm") || Name.get(i).toString().endsWith(".html")) {
Img.add(R.drawable.webpage);
}
else { else {
Img.add(R.drawable.unknownfile); Img.add(R.drawable.unknownfile);
} }
@ -181,7 +184,12 @@ public class ObjectSelect extends AppCompatActivity {
if (Img.get(position).equals(R.drawable.folder)) { if (Img.get(position).equals(R.drawable.folder)) {
//go to subfolder //go to subfolder
explorer(Name.get(position).toString()); explorer(Name.get(position).toString());
} else if (Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile)) { } else if (Img.get(position).equals(R.drawable.webpage)) {
//load media file
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
URL objectURL = s3client.generatePresignedUrl(request);
webbrowser(objectURL.toString());
} else if (Img.get(position).equals(R.drawable.audiofile) || Img.get(position).equals(R.drawable.videofile)) {
//load media file //load media file
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString()); GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString());
URL objectURL = s3client.generatePresignedUrl(request); URL objectURL = s3client.generatePresignedUrl(request);
@ -206,6 +214,14 @@ public class ObjectSelect extends AppCompatActivity {
} }
private void webbrowser (String url) {
Intent intent = new Intent(this, WebBrowser.class);
intent.putExtra("web_url", url);
startActivity(intent);
}
private void explorer(String object) { private void explorer(String object) {
Intent intent = new Intent(this, ObjectSelect.class); Intent intent = new Intent(this, ObjectSelect.class);

View file

@ -0,0 +1,30 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebBrowser extends AppCompatActivity {
private WebView npw;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_browser);
String webURL = getIntent().getStringExtra("web_url");
//This initializes webview object
npw =(WebView)findViewById(R.id.webview);
npw.setWebViewClient(new MyBrowser());
npw.loadUrl(webURL);
}
private class MyBrowser extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WebBrowser">
<WebView android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -16,7 +16,7 @@
<string name="nosslwarning">Connections without SSL are not allowed</string> <string name="nosslwarning">Connections without SSL are not allowed</string>
<string name="invalid_url">Endpoint URL must start with https://</string> <string name="invalid_url">Endpoint URL must start with https://</string>
<string name="explorer_test_button">File Explorer Test</string> <string name="explorer_test_button">File Explorer Test</string>
<string name="unsupported_file">Unsupported media file</string> <string name="unsupported_file">Unsupported file type</string>
<string name="video_test_button">Video Test</string> <string name="video_test_button">Video Test</string>
<string name="media_conn_fail">Cannot retrieve media file</string> <string name="media_conn_fail">Cannot retrieve media file</string>
<string name="media_wrong_type">Invalid media file</string> <string name="media_wrong_type">Invalid media file</string>