account picker

This commit is contained in:
Page Asgardius 2022-09-04 15:43:39 -07:00
parent 236a7c021b
commit 0bb4869178
3 changed files with 40 additions and 20 deletions

View file

@ -32,7 +32,7 @@ import java.util.List;
public class MainActivity extends AppCompatActivity {
static boolean DEFAULT_PATH_STYLE_ACCESS = true;
String username, password, endpoint;
String username, password, endpoint, aname;
RecyclerView recyclerView;
ArrayList Name;
ArrayList Img;
@ -41,9 +41,6 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
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);
@ -74,8 +71,6 @@ public class MainActivity extends AppCompatActivity {
public void run() {
try {
//Your code goes here
// Print bucket names
//System.out.println("Buckets:");
System.out.println(Name);
@ -111,9 +106,27 @@ public class MainActivity extends AppCompatActivity {
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());
//aname = Name.get(position).toString();
//System.out.println("Click on "+aname);
if (db != null) {
// Database Queries
System.out.println("Database OK");
try {
String query = "SELECT endpoint, username, password FROM account where id=\""+ Name.get(position).toString()+ "\"";
System.out.println(query);
Cursor cursor = db.rawQuery(query,null);
if (cursor.moveToNext()){
endpoint = cursor.getString(0);
username = cursor.getString(1);
password = cursor.getString(2);
explorer();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void onLongClick(View view, int position) {
@ -167,7 +180,7 @@ public class MainActivity extends AppCompatActivity {
if (db != null) {
// Database Queries
try {
db.execSQL("INSERT INTO account VALUES (\"test account\", \""+endpoint+"\", \""+username+"\", \""+password+"\")");
db.execSQL("INSERT INTO account VALUES (\"test account\", \""+getResources().getString(R.string.endpoint_url)+"\", \""+getString(R.string.access_key)+"\", \""+getResources().getString(R.string.secret_key)+"\")");
System.out.println("Insert OK");
} catch (Exception e) {
System.out.println("Insert error");

View file

@ -6,13 +6,20 @@
android:layout_height="match_parent"
tools:context=".AccountAdd">
<TextView android:text = "@string/accountadd_text"
<EditText
android:id="@+id/alias"
android:layout_width="match_parent"
android:layout_height="30dp"
android:id = "@+id/loginhint"
android:textSize = "25sp"
android:layout_alignParentTop = "true"
android:layout_centerHorizontal = "true"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="0dp"
android:focusable="true"
android:hint="@string/accountadd_alias"
android:importantForAutofill="no"
android:inputType="text"
android:textColorHighlight="#ff7eff15"
android:textColorHint="#ffff25e6"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints" />
<EditText
@ -21,7 +28,7 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="50dp"
android:layout_marginTop="48dp"
android:focusable="true"
android:hint="@string/accountadd_endpoint"
android:importantForAutofill="no"
@ -37,7 +44,7 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="96dp"
android:layout_marginTop="94dp"
android:autofillHints="username"
android:focusable="true"
android:hint="@string/accountadd_username"
@ -53,7 +60,7 @@
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="142dp"
android:layout_marginTop="140dp"
android:autofillHints="username"
android:focusable="true"
android:hint="@string/accountadd_password"
@ -70,7 +77,7 @@
android:layout_marginTop="160dp"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintTop_toBottomOf="@+id/loginhint"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="20dp">

View file

@ -7,7 +7,7 @@
<string name="secret_key">DTMp5kftamr49Ke7</string>
<string name="accountselect">Please choose an account</string>
<string name="accountadd_button">Add Account</string>
<string name="accountadd_text">Please add your account details</string>
<string name="accountadd_alias">Account Alias</string>
<string name="accountadd_endpoint">S3 Endpoint URL</string>
<string name="accountadd_username">S3 Access Key</string>
<string name="accountadd_password">S3 Secret Key</string>