code cleanup

This commit is contained in:
Page Asgardius 2023-01-07 10:16:01 -07:00
parent 19cc86b45e
commit eddc353a82
13 changed files with 39 additions and 89 deletions

View file

@ -1,9 +1,5 @@
package asgardius.page.s3manager;
import static com.amazonaws.regions.Regions.US_EAST_1;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
@ -12,6 +8,8 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
@ -21,7 +19,6 @@ import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.Bucket;
import com.google.android.material.switchmaterial.SwitchMaterial;
import java.util.ArrayList;
import java.util.List;
public class AccountAdd extends AppCompatActivity {

View file

@ -7,10 +7,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import asgardius.page.s3manager.BucketSelect;
public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder>{
ArrayList Img, Name;

View file

@ -38,7 +38,7 @@ public class BucketSelect extends AppCompatActivity {
ArrayList Name;
ArrayList Img;
RecyclerView recyclerView;
String username, password, endpoint, prefix, location, file, pdfendpoint;
String username, password, endpoint, prefix, location, pdfendpoint;
boolean style, isplaylist;
Region region;
S3ClientOptions s3ClientOptions;
@ -302,7 +302,7 @@ public class BucketSelect extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();

View file

@ -1,13 +1,13 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
@ -16,9 +16,6 @@ import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.BucketCrossOriginConfiguration;
import com.amazonaws.services.s3.model.CORSRule;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import java.net.URI;
import java.net.URISyntaxException;
@ -66,7 +63,7 @@ public class CorsConfig extends AppCompatActivity {
try {
s3client = new AmazonS3Client(myCredentials, region);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
s3client.setEndpoint(endpoint);
s3ClientOptions.setPathStyleAccess(style);
@ -124,7 +121,7 @@ public class CorsConfig extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();

View file

@ -1,9 +1,6 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
@ -11,19 +8,14 @@ import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.DeleteObjectsRequest;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import java.util.ArrayList;
import java.util.List;
public class CreateBucket extends AppCompatActivity {
String username, password, endpoint, bucket, location;
@ -89,7 +81,7 @@ public class CreateBucket extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();

View file

@ -1,22 +1,18 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.otaliastudios.zoom.ZoomImageView;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.stream.Collectors;
public class ImageViewer extends AppCompatActivity {
String videoURL, title;
@ -71,7 +67,7 @@ public class ImageViewer extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
});

View file

@ -1,26 +1,23 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Region;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import java.util.ArrayList;
import java.util.List;
public class ObjectInfo extends AppCompatActivity {
@ -67,7 +64,7 @@ public class ObjectInfo extends AppCompatActivity {
try {
s3client = new AmazonS3Client(myCredentials, region);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
s3client.setEndpoint(endpoint);
s3ClientOptions.setPathStyleAccess(style);
@ -140,7 +137,7 @@ public class ObjectInfo extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();

View file

@ -79,7 +79,7 @@ public class ObjectSelect extends AppCompatActivity {
try {
s3client = new AmazonS3Client(myCredentials, region);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
s3client.setEndpoint(endpoint);
s3ClientOptions.setPathStyleAccess(style);
@ -232,7 +232,7 @@ public class ObjectSelect extends AppCompatActivity {
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
}
@ -253,7 +253,7 @@ public class ObjectSelect extends AppCompatActivity {
URL objectURL = s3client.generatePresignedUrl(request);
imageViewer(objectURL.toString(), Name.get(position).toString());
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
} /*else if (Img.get(position).equals(R.drawable.textfile)) {
//load media file
@ -262,7 +262,7 @@ public class ObjectSelect extends AppCompatActivity {
URL objectURL = s3client.generatePresignedUrl(request);
textViewer(objectURL.toString());
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
}*/ else if (Img.get(position).equals(R.drawable.webpage) || Img.get(position).equals(R.drawable.ptextfile)) {
//load media file
@ -271,7 +271,7 @@ public class ObjectSelect extends AppCompatActivity {
URL objectURL = s3client.generatePresignedUrl(request);
webBrowser(objectURL.toString(), Name.get(position).toString());
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
} else if (Img.get(position).equals(R.drawable.pdffile)) {
//load media file
@ -307,10 +307,10 @@ public class ObjectSelect extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
}
@ -357,10 +357,10 @@ public class ObjectSelect extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
}
@ -501,7 +501,7 @@ public class ObjectSelect extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
}
@ -679,10 +679,10 @@ public class ObjectSelect extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
}

View file

@ -109,7 +109,7 @@ public class Share extends AppCompatActivity {
try {
s3client = new AmazonS3Client(myCredentials, region);
} catch (Exception e) {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
}
s3client.setEndpoint(endpoint);
s3ClientOptions.setPathStyleAccess(style);

View file

@ -1,7 +1,5 @@
package asgardius.page.s3manager;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@ -9,18 +7,11 @@ import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import androidx.appcompat.app.AppCompatActivity;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.stream.Collectors;
public class TextViewer extends AppCompatActivity {
@ -66,11 +57,11 @@ public class TextViewer extends AppCompatActivity {
@Override
public void run() {
Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
//Toast.makeText(getApplicationContext(),e.toString(), Toast.LENGTH_SHORT).show();
finish();
}
}

View file

@ -35,7 +35,6 @@ import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.ui.PlayerNotificationManager;
import com.google.android.exoplayer2.ui.StyledPlayerView;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
@ -195,15 +194,9 @@ public class VideoPlayer extends AppCompatActivity {
if(success) {
player.pause();
} else {
if (cause instanceof HttpDataSource.HttpDataSourceException) {
// An HTTP error occurred.
//System.out.println("Playback error F");
Toast.makeText(getApplicationContext(), getResources().getString(R.string.media_conn_fail), Toast.LENGTH_SHORT).show();
} else {
// An HTTP error occurred.
//System.out.println("Playback error F");
Toast.makeText(getApplicationContext(), getResources().getString(R.string.media_wrong_type), Toast.LENGTH_SHORT).show();
}
// An HTTP error occurred.
//System.out.println("Playback error F");
Toast.makeText(getApplicationContext(), Objects.requireNonNull(error.getCause()).toString(), Toast.LENGTH_SHORT).show();
player.release();
finish();
}

View file

@ -62,15 +62,8 @@
<string name="accountsave_success">Cuenta editada exitosamente</string>
<string name="nosslwarning">No se permiten las conexiones sin SSL</string>
<string name="invalid_url">La URL del endpoint debe iniciar con https://</string>
<string name="explorer_test_button">Probar explorador de archivos</string>
<string name="unsupported_file">Tipo de archivo no soportado</string>
<string name="test_server_button">Conectar al servidor de pruebas</string>
<string name="media_conn_fail">No se pudo obtener el archivo remoto</string>
<string name="media_wrong_type">Archivo multimedia inválido</string>
<string name="media_list_fail">No se pudo conectar al servidor</string>
<string name="about_button">Acerca de esta app</string>
<string name="dummy_button">Botón de prueba</string>
<string name="dummy_content">Contenido de prueba</string>
<string name="accountadd_pdfendpoint">servidor pdfjs</string>
<string name="pdf_reader_notready">Necesita configurar un servidor pdf.js</string>
<string name="share_date">D</string>

View file

@ -87,15 +87,8 @@
<string name="accountsave_success">Account edited successfully</string>
<string name="nosslwarning">Connections without SSL are not allowed</string>
<string name="invalid_url">Endpoint URL must start with https://</string>
<string name="explorer_test_button">File Explorer Test</string>
<string name="unsupported_file">Unsupported file type</string>
<string name="test_server_button">Connect to test server</string>
<string name="media_conn_fail">Cannot retrieve remote file</string>
<string name="media_wrong_type">Invalid media file</string>
<string name="media_list_fail">Cannot connect to server</string>
<string name="about_button">About this app</string>
<string name="dummy_button">Dummy Button</string>
<string name="dummy_content">DUMMY\nCONTENT</string>
<string name="settings">Settings</string>
<string name="save_settings">Save settings</string>
<string name="videocache">Max media cache size (in MiB)</string>