object list template
This commit is contained in:
parent
5ef12c7d83
commit
61e30dba3e
6 changed files with 123 additions and 12 deletions
|
@ -6,6 +6,7 @@
|
|||
<entry key="app/src/main/res/layout/activity_bucket_select.xml" value="0.2" />
|
||||
<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_object_select.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/activity_video_player.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/list_buckets.xml" value="0.19610507246376813" />
|
||||
</map>
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||
|
||||
public class BucketSelect extends AppCompatActivity {
|
||||
|
||||
AmazonS3 s3client;
|
||||
ArrayList Name;
|
||||
ArrayList Img;
|
||||
RecyclerView recyclerView;
|
||||
|
@ -46,7 +45,7 @@ public class BucketSelect extends AppCompatActivity {
|
|||
s3client.setEndpoint(endpoint);
|
||||
s3client.setS3ClientOptions(s3ClientOptions);
|
||||
|
||||
recyclerView = findViewById(R.id.recyclerview);
|
||||
recyclerView = findViewById(R.id.blist);
|
||||
|
||||
// layout for vertical orientation
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
|
@ -106,22 +105,24 @@ public class BucketSelect extends AppCompatActivity {
|
|||
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
|
||||
@Override
|
||||
public void onClick(View view, int position) {
|
||||
System.out.println("Click on "+Integer.toString(position));
|
||||
System.out.println("Click on "+Name.get(position).toString());
|
||||
explorer(Name.get(position).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongClick(View view, int position) {
|
||||
System.out.println("Long click on "+Integer.toString(position));
|
||||
System.out.println("Long click on "+Name.get(position).toString());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void explorer() {
|
||||
private void explorer(String bucket) {
|
||||
|
||||
Intent intent = new Intent(this, BucketSelect.class);
|
||||
Intent intent = new Intent(this, ObjectSelect.class);
|
||||
intent.putExtra("endpoint", endpoint);
|
||||
intent.putExtra("username", username);
|
||||
intent.putExtra("password", password);
|
||||
intent.putExtra("bucket", bucket);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,114 @@
|
|||
package asgardius.page.s3manager;
|
||||
|
||||
import static com.amazonaws.regions.Regions.US_EAST_1;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ObjectSelect extends AppCompatActivity {
|
||||
|
||||
ArrayList Name;
|
||||
ArrayList Img;
|
||||
RecyclerView recyclerView;
|
||||
String username, password, endpoint, bucket;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
endpoint = getIntent().getStringExtra("endpoint");
|
||||
username = getIntent().getStringExtra("username");
|
||||
password = getIntent().getStringExtra("password");
|
||||
bucket = getIntent().getStringExtra("bucket");
|
||||
setContentView(R.layout.activity_object_select);
|
||||
Region region = Region.getRegion(US_EAST_1);
|
||||
S3ClientOptions s3ClientOptions = S3ClientOptions.builder().build();
|
||||
s3ClientOptions.setPathStyleAccess(true);
|
||||
AWSCredentials myCredentials = new BasicAWSCredentials(username, password);
|
||||
AmazonS3 s3client = new AmazonS3Client(myCredentials, region);
|
||||
s3client.setEndpoint(endpoint);
|
||||
s3client.setS3ClientOptions(s3ClientOptions);
|
||||
|
||||
recyclerView = findViewById(R.id.olist);
|
||||
|
||||
// layout for vertical orientation
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
Thread listobject = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
//Your code goes here
|
||||
List<Bucket> buckets = s3client.listBuckets();
|
||||
//This convert bucket list to an array list
|
||||
Name = new ArrayList<String>();
|
||||
Img = new ArrayList<String>();
|
||||
// Print bucket names
|
||||
//System.out.println("Buckets:");
|
||||
int i=0;
|
||||
for (Bucket bucket : buckets) {
|
||||
//i++;
|
||||
//System.out.println(bucket.getName());
|
||||
Name.add(bucket.getName());
|
||||
//Img.add(R.drawable.ic_launcher_foreground);
|
||||
Img.add(R.drawable.bucket);
|
||||
}
|
||||
System.out.println(Name);
|
||||
|
||||
runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Sending reference and data to Adapter
|
||||
Adapter adapter = new Adapter(ObjectSelect.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();
|
||||
}
|
||||
}
|
||||
});
|
||||
listobject.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(Name.get(position).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongClick(View view, int position) {
|
||||
System.out.println("Long click on "+Name.get(position).toString());
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
tools:context=".BucketSelect">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerview"
|
||||
android:id="@+id/blist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
|
|
@ -6,4 +6,13 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:context=".ObjectSelect">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/olist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
tools:layout_editor_absoluteX="-27dp" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -2,11 +2,11 @@
|
|||
<string name="app_name">Asgardius S3 Manager</string>
|
||||
<string name="title_activity_video_player">VideoPlayer</string>
|
||||
<!-- don't forget removing s3 credentials before creating a git commit -->
|
||||
<string name="endpoint_url">s3server</string>
|
||||
<string name="access_key">username</string>
|
||||
<string name="secret_key">password</string>
|
||||
<string name="bucketname">bucket</string>
|
||||
<string name="objectname">object</string>
|
||||
<string name="endpoint_url">https://object.asgardius.company</string>
|
||||
<string name="access_key">asgardius</string>
|
||||
<string name="secret_key">DTMp5kftamr49Ke7</string>
|
||||
<string name="bucketname">asgardiustest</string>
|
||||
<string name="objectname">peces felices.mp4</string>
|
||||
<string name="explorer_test_button">File Explorer Test</string>
|
||||
<string name="video_test_button">Video Test</string>
|
||||
<string name="media_load_fail">Cannot load media file</string>
|
||||
|
|
Loading…
Reference in a new issue