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 { 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, aname;
RecyclerView recyclerView; RecyclerView recyclerView;
ArrayList Name; ArrayList Name;
ArrayList Img; ArrayList Img;
@ -41,9 +41,6 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); 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); recyclerView = findViewById(R.id.alist);
@ -74,8 +71,6 @@ public class MainActivity extends AppCompatActivity {
public void run() { public void run() {
try { try {
//Your code goes here //Your code goes here
// Print bucket names
//System.out.println("Buckets:");
System.out.println(Name); System.out.println(Name);
@ -111,8 +106,26 @@ public class MainActivity extends AppCompatActivity {
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() { recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getApplicationContext(), recyclerView, new RecyclerTouchListener.ClickListener() {
@Override @Override
public void onClick(View view, int position) { public void onClick(View view, int position) {
System.out.println("Click on "+Name.get(position).toString()); //aname = Name.get(position).toString();
explorer(); //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 @Override
@ -167,7 +180,7 @@ public class MainActivity extends AppCompatActivity {
if (db != null) { if (db != null) {
// Database Queries // Database Queries
try { 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"); System.out.println("Insert OK");
} catch (Exception e) { } catch (Exception e) {
System.out.println("Insert error"); System.out.println("Insert error");

View file

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

View file

@ -7,7 +7,7 @@
<string name="secret_key">DTMp5kftamr49Ke7</string> <string name="secret_key">DTMp5kftamr49Ke7</string>
<string name="accountselect">Please choose an account</string> <string name="accountselect">Please choose an account</string>
<string name="accountadd_button">Add 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_endpoint">S3 Endpoint URL</string>
<string name="accountadd_username">S3 Access Key</string> <string name="accountadd_username">S3 Access Key</string>
<string name="accountadd_password">S3 Secret Key</string> <string name="accountadd_password">S3 Secret Key</string>