return to top after account add
This commit is contained in:
parent
c2ff9d7505
commit
330e28b68d
3 changed files with 29 additions and 4 deletions
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -13,6 +13,8 @@
|
|||
<string name="accountdel_button">Remove Account</string>
|
||||
<string name="accountdel_success">Account removed successfully</string>
|
||||
<string name="accountedit_button">Edit Account</string>
|
||||
<string name="nosslwarning">Connections without SSL are not allowed</string>
|
||||
<string name="invalid_url">Endpoint URL must start with https://</string>
|
||||
<string name="explorer_test_button">File Explorer Test</string>
|
||||
<string name="video_test_button">Video Test</string>
|
||||
<string name="media_conn_fail">Cannot retrieve media file</string>
|
||||
|
|
Loading…
Reference in a new issue