object-info-interface
This commit is contained in:
parent
c86383cfb0
commit
ac1858ba2b
4 changed files with 63 additions and 5 deletions
|
@ -15,6 +15,10 @@ 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 java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ObjectInfo extends AppCompatActivity {
|
public class ObjectInfo extends AppCompatActivity {
|
||||||
String username, password, endpoint, bucket, object, location;
|
String username, password, endpoint, bucket, object, location;
|
||||||
|
@ -23,7 +27,8 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
AWSCredentials myCredentials;
|
AWSCredentials myCredentials;
|
||||||
AmazonS3 s3client;
|
AmazonS3 s3client;
|
||||||
ProgressBar simpleProgressBar;
|
ProgressBar simpleProgressBar;
|
||||||
TextView filesize;
|
TextView filesize, filesizeinfo;
|
||||||
|
boolean isobject, isfolder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -31,6 +36,7 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_object_info);
|
setContentView(R.layout.activity_object_info);
|
||||||
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
simpleProgressBar = (ProgressBar) findViewById(R.id.simpleProgressBar);
|
||||||
filesize = (TextView) findViewById(R.id.size);
|
filesize = (TextView) findViewById(R.id.size);
|
||||||
|
filesizeinfo = (TextView) findViewById(R.id.size_info);
|
||||||
endpoint = getIntent().getStringExtra("endpoint");
|
endpoint = getIntent().getStringExtra("endpoint");
|
||||||
username = getIntent().getStringExtra("username");
|
username = getIntent().getStringExtra("username");
|
||||||
password = getIntent().getStringExtra("password");
|
password = getIntent().getStringExtra("password");
|
||||||
|
@ -50,6 +56,55 @@ public class ObjectInfo extends AppCompatActivity {
|
||||||
s3ClientOptions.setPathStyleAccess(true);
|
s3ClientOptions.setPathStyleAccess(true);
|
||||||
}
|
}
|
||||||
s3client.setS3ClientOptions(s3ClientOptions);
|
s3client.setS3ClientOptions(s3ClientOptions);
|
||||||
simpleProgressBar.setVisibility(View.INVISIBLE);
|
Thread getInfo = new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
//Your code goes here
|
||||||
|
if (object == null) {
|
||||||
|
isobject = false;
|
||||||
|
} else {
|
||||||
|
isobject = true;
|
||||||
|
if (object.endsWith("/")) {
|
||||||
|
isfolder = true;
|
||||||
|
} else {
|
||||||
|
isfolder = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (isobject) {
|
||||||
|
if (isfolder) {
|
||||||
|
filesizeinfo.setText(getResources().getString(R.string.folder_size));
|
||||||
|
} else {
|
||||||
|
filesizeinfo.setText(getResources().getString(R.string.file_size));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
filesizeinfo.setText(getResources().getString(R.string.bucket_size));
|
||||||
|
}
|
||||||
|
simpleProgressBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getInfo.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,6 @@
|
||||||
android:id="@+id/size_info"
|
android:id="@+id/size_info"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/object_size"
|
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="25sp" />
|
android:textSize="25sp" />
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,9 @@
|
||||||
<string name="expiration_time">Hora de expiración</string>
|
<string name="expiration_time">Hora de expiración</string>
|
||||||
<string name="create_link">Crear enlace al archivo</string>
|
<string name="create_link">Crear enlace al archivo</string>
|
||||||
<string name="invalid_expiration_date">La fecha de caducidad debe ser inferior a 7 días</string>
|
<string name="invalid_expiration_date">La fecha de caducidad debe ser inferior a 7 días</string>
|
||||||
<string name="object_size">Tamaño del objeto</string>
|
<string name="file_size">Tamaño del archivo</string>
|
||||||
<string name="object_info">Propiedades</string>
|
<string name="object_info">Propiedades</string>
|
||||||
<string name="file_external">Abir en</string>
|
<string name="file_external">Abir en</string>
|
||||||
|
<string name="folder_size">Tamaño de la carpeta</string>
|
||||||
|
<string name="bucket_size">Tamaño del bucket</string>
|
||||||
</resources>
|
</resources>
|
|
@ -41,7 +41,9 @@
|
||||||
<string name="download_failed">Download failed</string>
|
<string name="download_failed">Download failed</string>
|
||||||
<string name="success">Success</string>
|
<string name="success">Success</string>
|
||||||
<string name="object_info">Properties</string>
|
<string name="object_info">Properties</string>
|
||||||
<string name="object_size">Object Size</string>
|
<string name="file_size">File Size</string>
|
||||||
|
<string name="folder_size">Folder Size</string>
|
||||||
|
<string name="bucket_size">Bucket Size</string>
|
||||||
<string name="create_bucket">Create new bucket</string>
|
<string name="create_bucket">Create new bucket</string>
|
||||||
<string name="create_bucket_success">Bucket created successfully</string>
|
<string name="create_bucket_success">Bucket created successfully</string>
|
||||||
<string name="upload_file_here">Upload file in current folder</string>
|
<string name="upload_file_here">Upload file in current folder</string>
|
||||||
|
|
Loading…
Reference in a new issue