image viewer
This commit is contained in:
parent
4e682b9334
commit
bf462225e7
9 changed files with 115 additions and 17 deletions
|
@ -1,17 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetDropDown">
|
|
||||||
<targetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
|
||||||
<value value="$USER_HOME$/.android/avd/4.7_WXGA_API_31.avd" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</targetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2022-09-08T15:30:22.967249Z" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -8,6 +8,7 @@
|
||||||
<entry key="app/src/main/res/layout/activity_account_add.xml" value="0.25" />
|
<entry key="app/src/main/res/layout/activity_account_add.xml" value="0.25" />
|
||||||
<entry key="app/src/main/res/layout/activity_bucket_select.xml" value="0.2" />
|
<entry key="app/src/main/res/layout/activity_bucket_select.xml" value="0.2" />
|
||||||
<entry key="app/src/main/res/layout/activity_file_share.xml" value="0.19610507246376813" />
|
<entry key="app/src/main/res/layout/activity_file_share.xml" value="0.19610507246376813" />
|
||||||
|
<entry key="app/src/main/res/layout/activity_image_viewer.xml" value="0.19610507246376813" />
|
||||||
<entry key="app/src/main/res/layout/activity_list_item.xml" value="0.19610507246376813" />
|
<entry key="app/src/main/res/layout/activity_list_item.xml" value="0.19610507246376813" />
|
||||||
<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" />
|
||||||
|
|
|
@ -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=".ImageViewer"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".TextViewer"
|
android:name=".TextViewer"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
66
app/src/main/java/asgardius/page/s3manager/ImageViewer.java
Normal file
66
app/src/main/java/asgardius/page/s3manager/ImageViewer.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,6 +127,9 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
else if (Name.get(i).toString().endsWith(".txt") || Name.get(i).toString().endsWith(".md")) {
|
else if (Name.get(i).toString().endsWith(".txt") || Name.get(i).toString().endsWith(".md")) {
|
||||||
Img.add(R.drawable.textfile);
|
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")
|
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(".oga") || Name.get(i).toString().endsWith(".mp3")
|
||||||
|| Name.get(i).toString().endsWith(".m4a") || Name.get(i).toString().endsWith(".flac")
|
|| 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)) {
|
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.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)) {
|
} else if (Img.get(position).equals(R.drawable.textfile)) {
|
||||||
//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());
|
||||||
|
@ -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) {
|
private void webbrowser (String url) {
|
||||||
|
|
||||||
Intent intent = new Intent(this, WebBrowser.class);
|
Intent intent = new Intent(this, WebBrowser.class);
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class TextViewer extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
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();
|
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||||
|
|
BIN
app/src/main/res/drawable/empty.png
Normal file
BIN
app/src/main/res/drawable/empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 591 B |
BIN
app/src/main/res/drawable/imagefile.png
Normal file
BIN
app/src/main/res/drawable/imagefile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
28
app/src/main/res/layout/activity_image_viewer.xml
Normal file
28
app/src/main/res/layout/activity_image_viewer.xml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?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=".ImageViewer">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imageViewer"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
app:srcCompat="@drawable/empty"
|
||||||
|
tools:layout_editor_absoluteX="0dp"
|
||||||
|
tools:layout_editor_absoluteY="82dp"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/simpleProgressBar"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:max="100"
|
||||||
|
android:progress="50"
|
||||||
|
android:padding="20dp"
|
||||||
|
tools:ignore="MissingConstraints"
|
||||||
|
android:indeterminate="true" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in a new issue