diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index c3ebb80..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 79b787b..5a1c707 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,6 +8,7 @@ + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 94ff6e8..e0fe23b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,9 @@ android:supportsRtl="true" android:theme="@style/Theme.AsgardiusS3Manager" tools:targetApi="31"> + diff --git a/app/src/main/java/asgardius/page/s3manager/ImageViewer.java b/app/src/main/java/asgardius/page/s3manager/ImageViewer.java new file mode 100644 index 0000000..9d2d068 --- /dev/null +++ b/app/src/main/java/asgardius/page/s3manager/ImageViewer.java @@ -0,0 +1,66 @@ +package asgardius.page.s3manager; + +import androidx.appcompat.app.AppCompatActivity; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.View; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.Toast; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.stream.Collectors; + +public class ImageViewer extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_image_viewer); + final ProgressBar simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar); + String videoURL = getIntent().getStringExtra("video_url"); + ImageView iv=(ImageView) findViewById(R.id.imageViewer); + System.out.println(videoURL); + Thread imgread = new Thread(new Runnable() { + + @Override + public void run() { + try { + //Your code goes here + URL thumb_u = new URL(videoURL); + Drawable thumb_d = Drawable.createFromStream(thumb_u.openStream(), "src"); + + runOnUiThread(new Runnable() { + + @Override + public void run() { + // Sending reference and data to Adapter + simpleProgressBar.setVisibility(View.INVISIBLE); + iv.setImageDrawable(thumb_d); + + } + }); + //System.out.println("tree "+treelevel); + //System.out.println("prefix "+prefix); + + } catch (Exception e) { + e.printStackTrace(); + runOnUiThread(new Runnable() { + + @Override + public void run() { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + finish(); + } + }); + //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + finish(); + } + } + }); + imgread.start(); + } +} \ No newline at end of file diff --git a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java index 636eb1a..6207990 100644 --- a/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java +++ b/app/src/main/java/asgardius/page/s3manager/ObjectSelect.java @@ -127,6 +127,9 @@ public class ObjectSelect extends AppCompatActivity { else if (Name.get(i).toString().endsWith(".txt") || Name.get(i).toString().endsWith(".md")) { Img.add(R.drawable.textfile); } + else if (Name.get(i).toString().endsWith(".jpg") || Name.get(i).toString().endsWith(".png") || Name.get(i).toString().endsWith(".gif")) { + Img.add(R.drawable.imagefile); + } else if (Name.get(i).toString().endsWith(".opus") || Name.get(i).toString().endsWith(".ogg") || Name.get(i).toString().endsWith(".oga") || Name.get(i).toString().endsWith(".mp3") || Name.get(i).toString().endsWith(".m4a") || Name.get(i).toString().endsWith(".flac") @@ -195,6 +198,11 @@ public class ObjectSelect extends AppCompatActivity { if (Img.get(position).equals(R.drawable.folder)) { //go to subfolder explorer(Name.get(position).toString()); + } else if (Img.get(position).equals(R.drawable.imagefile)) { + //load media file + GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString()); + URL objectURL = s3client.generatePresignedUrl(request); + imageviewer(objectURL.toString()); } else if (Img.get(position).equals(R.drawable.textfile)) { //load media file GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, prefix + Name.get(position).toString()); @@ -262,6 +270,14 @@ public class ObjectSelect extends AppCompatActivity { } + private void imageviewer(String url) { + + Intent intent = new Intent(this, ImageViewer.class); + intent.putExtra("video_url", url); + startActivity(intent); + + } + private void webbrowser (String url) { Intent intent = new Intent(this, WebBrowser.class); diff --git a/app/src/main/java/asgardius/page/s3manager/TextViewer.java b/app/src/main/java/asgardius/page/s3manager/TextViewer.java index 8379945..c710fff 100644 --- a/app/src/main/java/asgardius/page/s3manager/TextViewer.java +++ b/app/src/main/java/asgardius/page/s3manager/TextViewer.java @@ -66,6 +66,7 @@ public class TextViewer extends AppCompatActivity { @Override public void run() { Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); + finish(); } }); //Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show(); diff --git a/app/src/main/res/drawable/empty.png b/app/src/main/res/drawable/empty.png new file mode 100644 index 0000000..ceccebb Binary files /dev/null and b/app/src/main/res/drawable/empty.png differ diff --git a/app/src/main/res/drawable/imagefile.png b/app/src/main/res/drawable/imagefile.png new file mode 100644 index 0000000..6709bf6 Binary files /dev/null and b/app/src/main/res/drawable/imagefile.png differ diff --git a/app/src/main/res/layout/activity_image_viewer.xml b/app/src/main/res/layout/activity_image_viewer.xml new file mode 100644 index 0000000..5285ebb --- /dev/null +++ b/app/src/main/res/layout/activity_image_viewer.xml @@ -0,0 +1,28 @@ + + + + + + + + \ No newline at end of file