style access selection

This commit is contained in:
Page Asgardius 2022-12-23 11:02:50 -07:00
parent 424caf8b87
commit ddffa7ccfe
6 changed files with 155 additions and 111 deletions

View file

@ -19,13 +19,15 @@ 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.Bucket;
import com.google.android.material.switchmaterial.SwitchMaterial;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AccountAdd extends AppCompatActivity { public class AccountAdd extends AppCompatActivity {
EditText aapick, aupick, appick, aepick, arpick, pdfpick; EditText aapick, aupick, appick, aepick, arpick, pdfpick;
String alias, username, password, endpoint, id, location, pdfendpoint; SwitchMaterial pathstyle;
String alias, username, password, endpoint, id, location, pdfendpoint, style;
AWSCredentials myCredentials; AWSCredentials myCredentials;
AmazonS3 s3client; AmazonS3 s3client;
Region region; Region region;
@ -41,6 +43,7 @@ public class AccountAdd extends AppCompatActivity {
arpick = (EditText)findViewById(R.id.region); arpick = (EditText)findViewById(R.id.region);
aupick = (EditText)findViewById(R.id.username); aupick = (EditText)findViewById(R.id.username);
appick = (EditText)findViewById(R.id.password); appick = (EditText)findViewById(R.id.password);
pathstyle = (SwitchMaterial) findViewById(R.id.pathstyle);
Button register = (Button)findViewById(R.id.addaccount); Button register = (Button)findViewById(R.id.addaccount);
Button accounttest = (Button)findViewById(R.id.testaccount); Button accounttest = (Button)findViewById(R.id.testaccount);
edit = getIntent().getBooleanExtra("edit", false); edit = getIntent().getBooleanExtra("edit", false);
@ -53,6 +56,11 @@ public class AccountAdd extends AppCompatActivity {
password = getIntent().getStringExtra("password"); password = getIntent().getStringExtra("password");
location = getIntent().getStringExtra("region"); location = getIntent().getStringExtra("region");
pdfendpoint = getIntent().getStringExtra("pdfendpoint"); pdfendpoint = getIntent().getStringExtra("pdfendpoint");
if (getIntent().getBooleanExtra("style", false)) {
pathstyle.setChecked(true);
} else {
pathstyle.setChecked(false);
}
aapick.setText(id); aapick.setText(id);
aepick.setText(endpoint); aepick.setText(endpoint);
//aapick.setEnabled(false); //aapick.setEnabled(false);
@ -76,6 +84,11 @@ public class AccountAdd extends AppCompatActivity {
location = arpick.getText().toString(); location = arpick.getText().toString();
username = aupick.getText().toString(); username = aupick.getText().toString();
password = appick.getText().toString(); password = appick.getText().toString();
if (pathstyle.isChecked()) {
style = "1";
} else {
style = "0";
}
MyDbHelper dbHelper = new MyDbHelper(AccountAdd.this); MyDbHelper dbHelper = new MyDbHelper(AccountAdd.this);
if (alias.equals("") && endpoint.equals("") && username.equals(getResources().getString(R.string.access_key))) { if (alias.equals("") && endpoint.equals("") && username.equals(getResources().getString(R.string.access_key))) {
endpoint = getResources().getString(R.string.endpoint_url); endpoint = getResources().getString(R.string.endpoint_url);
@ -96,10 +109,10 @@ public class AccountAdd extends AppCompatActivity {
location = "us-east-1"; location = "us-east-1";
} }
if (edit) { if (edit) {
db.execSQL("UPDATE account SET id=\""+alias+"\", endpoint=\""+endpoint+"\", username=\""+username+"\", password=\""+password+"\", region=\""+location+"\", pdfendpoint=\""+pdfendpoint+"\" WHERE id=\""+id+"\""); db.execSQL("UPDATE account SET id=\""+alias+"\", endpoint=\""+endpoint+"\", username=\""+username+"\", password=\""+password+"\", region=\""+location+"\", pdfendpoint=\""+pdfendpoint+"\", style=\""+style+"\" WHERE id=\""+id+"\"");
Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountsave_success), Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountsave_success), Toast.LENGTH_SHORT).show();
} else { } else {
db.execSQL("INSERT INTO account VALUES (\""+alias+"\", \""+endpoint+"\", \""+username+"\", \""+password+"\", \""+location+"\", \""+pdfendpoint+"\")"); db.execSQL("INSERT INTO account VALUES (\""+alias+"\", \""+endpoint+"\", \""+username+"\", \""+password+"\", \""+location+"\", \""+pdfendpoint+"\", \""+style+"\")");
Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_success), Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_success), Toast.LENGTH_SHORT).show();
} }
mainmenu(); mainmenu();

View file

@ -20,7 +20,7 @@ import java.util.ArrayList;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
static boolean DEFAULT_PATH_STYLE_ACCESS = true; boolean style;
String alias, username, password, endpoint, location, pdfendpoint; String alias, username, password, endpoint, location, pdfendpoint;
RecyclerView recyclerView; RecyclerView recyclerView;
SQLiteDatabase db; SQLiteDatabase db;
@ -219,7 +219,7 @@ public class MainActivity extends AppCompatActivity {
// Database Queries // Database Queries
try { try {
//This retrieves credentials from selected account //This retrieves credentials from selected account
String query = "SELECT endpoint, username, password, region, pdfendpoint FROM account where id=\""+ Name.get(position).toString()+ "\""; String query = "SELECT endpoint, username, password, region, pdfendpoint, style FROM account where id=\""+ Name.get(position).toString()+ "\"";
Cursor cursor = db.rawQuery(query,null); Cursor cursor = db.rawQuery(query,null);
if (cursor.moveToNext()){ if (cursor.moveToNext()){
endpoint = cursor.getString(0); endpoint = cursor.getString(0);
@ -227,6 +227,11 @@ public class MainActivity extends AppCompatActivity {
password = cursor.getString(2); password = cursor.getString(2);
location = cursor.getString(3); location = cursor.getString(3);
pdfendpoint = cursor.getString(4); pdfendpoint = cursor.getString(4);
if (cursor.getString(5).equals("1")) {
style = true;
} else {
style = false;
}
db.close(); db.close();
//This launch file explorer using selected account //This launch file explorer using selected account
explorer(); explorer();
@ -255,7 +260,7 @@ public class MainActivity extends AppCompatActivity {
try { try {
db = dbHelper.getWritableDatabase(); db = dbHelper.getWritableDatabase();
//This retrieves credentials from selected account //This retrieves credentials from selected account
String query = "SELECT id, endpoint, username, password, region, pdfendpoint FROM account where id=\""+ Name.get(position).toString()+ "\""; String query = "SELECT id, endpoint, username, password, region, pdfendpoint, style FROM account where id=\""+ Name.get(position).toString()+ "\"";
System.out.println(query); System.out.println(query);
Cursor cursor = db.rawQuery(query,null); Cursor cursor = db.rawQuery(query,null);
if (cursor.moveToNext()){ if (cursor.moveToNext()){
@ -265,6 +270,11 @@ public class MainActivity extends AppCompatActivity {
password = cursor.getString(3); password = cursor.getString(3);
location = cursor.getString(4); location = cursor.getString(4);
pdfendpoint = cursor.getString(5); pdfendpoint = cursor.getString(5);
if (cursor.getString(6).equals("1")) {
style = true;
} else {
style = false;
}
} }
db.close(); db.close();
//This launch account editor //This launch account editor
@ -363,6 +373,7 @@ public class MainActivity extends AppCompatActivity {
intent.putExtra("password", password); intent.putExtra("password", password);
intent.putExtra("region", location); intent.putExtra("region", location);
intent.putExtra("pdfendpoint", pdfendpoint); intent.putExtra("pdfendpoint", pdfendpoint);
intent.putExtra("style", style);
} }
intent.putExtra("edit", edit); intent.putExtra("edit", edit);
startActivity(intent); startActivity(intent);

View file

@ -5,7 +5,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
public class MyDbHelper extends SQLiteOpenHelper { public class MyDbHelper extends SQLiteOpenHelper {
private static final String usertable = "CREATE TABLE IF NOT EXISTS account(id text UNIQUE, endpoint text, username text, password text, region text, pdfendpoint text)"; private static final String usertable = "CREATE TABLE IF NOT EXISTS account(id text UNIQUE, endpoint text, username text, password text, region text, pdfendpoint text, style text)";
private static final String preftable = "CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)"; private static final String preftable = "CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)";
private static final String setvideocache = "INSERT INTO preferences VALUES ('videocache', '300')"; private static final String setvideocache = "INSERT INTO preferences VALUES ('videocache', '300')";
private static final String setvideotime = "INSERT INTO preferences VALUES ('videotime', '3')"; private static final String setvideotime = "INSERT INTO preferences VALUES ('videotime', '3')";

View file

@ -7,123 +7,141 @@
android:orientation="vertical" android:orientation="vertical"
tools:context=".AccountAdd"> tools:context=".AccountAdd">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/aliasLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="vertical">
android:padding="10dp"
tools:ignore="MissingConstraints" <TextView
tools:layout_editor_absoluteX="20dp"> android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accountadd_alias"
android:textAlignment="center"
android:textSize="25sp"/>
<EditText <EditText
android:id="@+id/alias" android:id="@+id/alias"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:hint="@string/accountadd_alias" android:hint="@string/accountadd_alias"
android:importantForAutofill="no"
android:inputType="text" android:inputType="text"
android:textColorHint="?attr/colorOnSecondary" android:textColorHint="?attr/colorOnSecondary"/>
tools:ignore="MissingConstraints" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accountadd_pdfendpoint"
android:textAlignment="center"
android:textSize="25sp"/>
<EditText <EditText
android:id="@+id/pdfendpoint" android:id="@+id/pdfendpoint"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_weight="1" android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:hint="@string/accountadd_pdfendpoint" android:hint="@string/accountadd_pdfendpoint"
android:importantForAutofill="no"
android:inputType="textUri" android:inputType="textUri"
android:textColorHint="?attr/colorOnSecondary" android:textColorHint="?attr/colorOnSecondary"/>
tools:ignore="MissingConstraints" />
</LinearLayout> <TextView
<LinearLayout
android:id="@+id/endpointLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:text="@string/accountadd_endpoint"
android:padding="10dp" android:textAlignment="center"
tools:ignore="MissingConstraints" android:textSize="25sp"/>
tools:layout_editor_absoluteX="20dp">
<EditText <EditText
android:id="@+id/endpoint" android:id="@+id/endpoint"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_weight="1" android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:hint="@string/accountadd_endpoint" android:hint="@string/accountadd_endpoint"
android:importantForAutofill="no"
android:inputType="textUri" android:inputType="textUri"
android:textColorHint="?attr/colorOnSecondary" android:textColorHint="?attr/colorOnSecondary"/>
tools:ignore="MissingConstraints" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accountadd_region"
android:textAlignment="center"
android:textSize="25sp"/>
<EditText <EditText
android:id="@+id/region" android:id="@+id/region"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:hint="@string/accountadd_region" android:hint="@string/accountadd_region"
android:importantForAutofill="no"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"
android:textColorHint="?attr/colorOnSecondary" android:textColorHint="?attr/colorOnSecondary"/>
tools:ignore="MissingConstraints" />
</LinearLayout> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accountadd_username"
android:textAlignment="center"
android:textSize="25sp"/>
<EditText <EditText
android:id="@+id/username" android:id="@+id/username"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:autofillHints="username" android:autofillHints="username"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:hint="@string/accountadd_username" android:hint="@string/accountadd_username"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"
android:textColorHint="?attr/colorOnSecondary" android:textColorHint="?attr/colorOnSecondary"/>
tools:ignore="MissingConstraints" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/accountadd_password"
android:textAlignment="center"
android:textSize="25sp"/>
<EditText <EditText
android:id="@+id/password" android:id="@+id/password"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="48dp"
android:autofillHints="username" android:autofillHints="password"
android:layout_weight="1"
android:focusable="true" android:focusable="true"
android:hint="@string/accountadd_password" android:hint="@string/accountadd_password"
android:inputType="textPassword" android:inputType="textPassword"
android:textColorHint="?attr/colorOnSecondary" android:textColorHint="?attr/colorOnSecondary"/>
tools:ignore="MissingConstraints" />
<LinearLayout <com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/linearLayout" android:id="@+id/pathstyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="80dp" android:layout_height="70dp"
android:orientation="horizontal" android:text="@string/path_style"
android:padding="10dp" android:textSize="24sp" />
tools:ignore="MissingConstraints"
tools:layout_editor_absoluteX="20dp">
<Button <Button
android:id="@+id/addaccount" android:id="@+id/addaccount"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="70dp"
android:layout_weight="1"
android:text="@string/accountadd_button" android:text="@string/accountadd_button"
tools:ignore="MissingConstraints" /> android:textColor="?android:attr/colorBackground"
android:textSize="24sp" />
<Button <Button
android:id="@+id/testaccount" android:id="@+id/testaccount"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="70dp"
android:layout_weight="1"
android:text="@string/accounttest_button" android:text="@string/accounttest_button"
tools:ignore="MissingConstraints" /> android:textColor="?android:attr/colorBackground"
android:textSize="24sp" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>

View file

@ -94,4 +94,5 @@
<string name="mediaplayer_multierror">Solo se puede reproducir un archivo multimedia a la vez</string> <string name="mediaplayer_multierror">Solo se puede reproducir un archivo multimedia a la vez</string>
<string name="playback_channel_name">Reproduccion de video</string> <string name="playback_channel_name">Reproduccion de video</string>
<string name="not_zero">este valor no puede ser cero</string> <string name="not_zero">este valor no puede ser cero</string>
<string name="path_style">Acceso de estilo de ruta</string>
</resources> </resources>

View file

@ -98,4 +98,5 @@
<string name="mediaplayer_multierror">Only one media file can be played at once</string> <string name="mediaplayer_multierror">Only one media file can be played at once</string>
<string name="playback_channel_name">Video Playback</string> <string name="playback_channel_name">Video Playback</string>
<string name="not_zero">This value cannot be zero</string> <string name="not_zero">This value cannot be zero</string>
<string name="path_style">Path style access</string>
</resources> </resources>