-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/io/github/storagereloaded/android/DatabaseSettingsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.github.storagereloaded.android; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.os.Bundle; | ||
import android.widget.EditText; | ||
|
||
import com.google.android.material.appbar.MaterialToolbar; | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder; | ||
import com.google.android.material.textfield.TextInputLayout; | ||
|
||
public class DatabaseSettingsActivity extends AppCompatActivity { | ||
|
||
EditText name; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_database_settings); | ||
|
||
MaterialToolbar toolbar = findViewById(R.id.toolbar); | ||
toolbar.setNavigationOnClickListener(v -> onBackPressed()); | ||
|
||
TextInputLayout til = findViewById(R.id.database_name); | ||
name = til.getEditText(); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (name.getText().toString().equals("")) | ||
finish(); | ||
else | ||
showUnsavedDialog(); | ||
} | ||
|
||
private void showUnsavedDialog() { | ||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this); | ||
builder.setTitle(R.string.unsaved_dialog_title); | ||
builder.setMessage(R.string.unsaved_dialog_description); | ||
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> finish()); | ||
builder.setNegativeButton(android.R.string.cancel, null); | ||
|
||
builder.create().show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.google.android.material.appbar.MaterialToolbar | ||
android:id="@+id/toolbar" | ||
style="@style/Widget.MaterialComponents.Toolbar.Primary" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
app:menu="@menu/menu_database_settings" | ||
app:navigationIcon="@drawable/ic_baseline_close_24" | ||
app:title="@string/title_activity_database_settings" /> | ||
|
||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="16dp" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior"> | ||
|
||
<com.google.android.material.textfield.TextInputLayout | ||
android:id="@+id/database_name" | ||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="8dp" | ||
android:hint="@string/database_name"> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:imeOptions="actionDone" | ||
android:inputType="text" | ||
android:textColor="?attr/colorOnBackground" /> | ||
|
||
</com.google.android.material.textfield.TextInputLayout> | ||
</LinearLayout> | ||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<item | ||
android:id="@+id/save" | ||
android:title="@string/save" | ||
app:showAsAction="always" /> | ||
<item | ||
android:id="@+id/delete" | ||
android:title="@string/delete" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters