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 static com.amazonaws.services.s3.S3ClientOptions.DEFAULT_PATH_STYLE_ACCESS;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.Toast;
import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.BasicAWSCredentials; 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.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.S3ClientOptions; import com.amazonaws.services.s3.S3ClientOptions;
import com.amazonaws.services.s3.model.Bucket;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import java.net.URL; import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
static boolean DEFAULT_PATH_STYLE_ACCESS = true; static boolean DEFAULT_PATH_STYLE_ACCESS = true;
String username, password, endpoint; String username, password, endpoint;
RecyclerView recyclerView;
ArrayList Name;
ArrayList Img;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -33,6 +42,70 @@ public class MainActivity extends AppCompatActivity {
username = getString(R.string.access_key); username = getString(R.string.access_key);
password = getResources().getString(R.string.secret_key); password = getResources().getString(R.string.secret_key);
endpoint = getResources().getString(R.string.endpoint_url); 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 //This is to launch video playback test
Button videotest = (Button)findViewById(R.id.vtest); Button videotest = (Button)findViewById(R.id.vtest);
videotest.setOnClickListener(new View.OnClickListener(){ 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"> tools:context=".MainActivity">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="30dp"
android:text="Hello World!" android:layout_marginTop="100dp"
app:layout_constraintBottom_toBottomOf="parent" android:text="@string/accountselect"
app:layout_constraintEnd_toEndOf="parent" android:textAlignment="center"
app:layout_constraintStart_toStartOf="parent" android:textSize="20sp"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<LinearLayout <LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="100dp"
android:layout_margin="20dp" android:layout_margin="20dp"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="10dp" android:padding="10dp"
tools:ignore="MissingConstraints"> tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="20dp">
<Button <Button
android:id="@+id/vtest" android:id="@+id/vtest"
@ -41,4 +43,14 @@
</LinearLayout> </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> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -7,6 +7,7 @@
<string name="secret_key">DTMp5kftamr49Ke7</string> <string name="secret_key">DTMp5kftamr49Ke7</string>
<string name="bucketname">asgardiustest</string> <string name="bucketname">asgardiustest</string>
<string name="objectname">peces felices.mp4</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="explorer_test_button">File Explorer Test</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>