account listing

This commit is contained in:
Page Asgardius 2022-09-04 10:56:19 -07:00
parent 35100aaf85
commit 6a7b5843ff
5 changed files with 93 additions and 7 deletions

View file

@ -5,11 +5,14 @@ import static com.amazonaws.regions.Regions.US_EAST_1;
import static com.amazonaws.services.s3.S3ClientOptions.DEFAULT_PATH_STYLE_ACCESS;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials;
@ -17,14 +20,20 @@ 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.GeneratePresignedUrlRequest;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
static boolean DEFAULT_PATH_STYLE_ACCESS = true;
String username, password, endpoint;
RecyclerView recyclerView;
ArrayList Name;
ArrayList Img;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -33,6 +42,70 @@ public class MainActivity extends AppCompatActivity {
username = getString(R.string.access_key);
password = getResources().getString(R.string.secret_key);
endpoint = getResources().getString(R.string.endpoint_url);
recyclerView = findViewById(R.id.alist);
// layout for vertical orientation
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(linearLayoutManager);
Thread listaccount = new Thread(new Runnable() {
@Override
public void run() {
try {
//Your code goes here
Name = new ArrayList<String>();
Img = new ArrayList<String>();
// Print bucket names
//System.out.println("Buckets:");
Name.add("account");
Img.add(R.drawable.account);
System.out.println(Name);
runOnUiThread(new Runnable() {
@Override
public void run() {
// Sending reference and data to Adapter
Adapter adapter = new Adapter(MainActivity.this, Img, Name);
// Setting Adapter to RecyclerView
recyclerView.setAdapter(adapter);
}
});
} 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();
}
});
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
finish();
}
}
});
listaccount.start();
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, int position) {
System.out.println("Click on "+Name.get(position).toString());
explorer();
}
@Override
public void onLongClick(View view, int position) {
System.out.println("Long click on "+Name.get(position).toString());
}
}));
//This is to launch video playback test
Button videotest = (Button)findViewById(R.id.vtest);
videotest.setOnClickListener(new View.OnClickListener(){

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -7,21 +7,23 @@
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="100dp"
android:text="@string/accountselect"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_margin="20dp"
android:orientation="horizontal"
android:padding="10dp"
tools:ignore="MissingConstraints">
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="20dp">
<Button
android:id="@+id/vtest"
@ -41,4 +43,14 @@
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/alist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="140dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:layout_editor_absoluteX="27dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -7,6 +7,7 @@
<string name="secret_key">DTMp5kftamr49Ke7</string>
<string name="bucketname">asgardiustest</string>
<string name="objectname">peces felices.mp4</string>
<string name="accountselect">Please choose an account</string>
<string name="explorer_test_button">File Explorer Test</string>
<string name="video_test_button">Video Test</string>
<string name="media_conn_fail">Cannot retrieve media file</string>