From 330e28b68d1047637b9d5cdb7bfd68b5e04028fe Mon Sep 17 00:00:00 2001 From: Page Asgardius Date: Mon, 5 Sep 2022 10:08:35 -0700 Subject: [PATCH] return to top after account add --- .../asgardius/page/s3manager/AccountAdd.java | 21 +++++++++++++++---- .../page/s3manager/MainActivity.java | 10 +++++++++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/asgardius/page/s3manager/AccountAdd.java b/app/src/main/java/asgardius/page/s3manager/AccountAdd.java index 51cda9f..f33bc50 100644 --- a/app/src/main/java/asgardius/page/s3manager/AccountAdd.java +++ b/app/src/main/java/asgardius/page/s3manager/AccountAdd.java @@ -2,6 +2,7 @@ package asgardius.page.s3manager; import androidx.appcompat.app.AppCompatActivity; +import android.content.Intent; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; @@ -30,24 +31,36 @@ public class AccountAdd extends AppCompatActivity { endpoint = aepick.getText().toString(); username = aupick.getText().toString(); password = appick.getText().toString(); - System.out.println("Alias " + alias); - System.out.println("Endpoint " + endpoint); - System.out.println("Username " + username); - System.out.println("Password " + password); MyDbHelper dbHelper = new MyDbHelper(AccountAdd.this); SQLiteDatabase db = dbHelper.getWritableDatabase(); if (alias.equals("") || endpoint.equals("") || username.equals("") || password.equals("")) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_null), Toast.LENGTH_SHORT).show(); + } else if (endpoint.startsWith("http://")) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.nosslwarning), Toast.LENGTH_SHORT).show(); + } else if (!endpoint.startsWith("https://")) { + Toast.makeText(getApplicationContext(),getResources().getString(R.string.invalid_url), Toast.LENGTH_SHORT).show(); } else if (db != null) { // Database Queries try { db.execSQL("INSERT INTO account VALUES (\""+alias+"\", \""+endpoint+"\", \""+username+"\", \""+password+"\")"); Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_success), Toast.LENGTH_SHORT).show(); + mainmenu(); } catch (Exception e) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_fail), Toast.LENGTH_SHORT).show(); } } } + }); } + + private void mainmenu() { + + Intent intent = new Intent(this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtra("EXIT", true); + startActivity(intent); + + } + } \ No newline at end of file diff --git a/app/src/main/java/asgardius/page/s3manager/MainActivity.java b/app/src/main/java/asgardius/page/s3manager/MainActivity.java index aba58dd..e2d03ee 100644 --- a/app/src/main/java/asgardius/page/s3manager/MainActivity.java +++ b/app/src/main/java/asgardius/page/s3manager/MainActivity.java @@ -136,6 +136,7 @@ public class MainActivity extends AppCompatActivity { try { db.execSQL("DELETE FROM account where id=\""+ Name.get(position).toString()+ "\""); Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountdel_success), Toast.LENGTH_SHORT).show(); + mainmenu(); } catch (Exception e) { Toast.makeText(getApplicationContext(),getResources().getString(R.string.accountadd_fail), Toast.LENGTH_SHORT).show(); } @@ -187,4 +188,13 @@ public class MainActivity extends AppCompatActivity { } + private void mainmenu() { + + Intent intent = new Intent(this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + intent.putExtra("EXIT", true); + startActivity(intent); + + } + } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 16af0a1..b3bbb97 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,6 +13,8 @@ Remove Account Account removed successfully Edit Account + Connections without SSL are not allowed + Endpoint URL must start with https:// File Explorer Test Video Test Cannot retrieve media file