diff --git a/app/src/main/java/org/shadowice/flocke/andotp/MainActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/MainActivity.java index 5e8574fa..44d51118 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/MainActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/MainActivity.java @@ -98,7 +98,8 @@ public class MainActivity extends AppCompatActivity { // About dialog private void showAbout() { - View messageView = getLayoutInflater().inflate(R.layout.dialog_about, null, false); + ViewGroup container = (ViewGroup) findViewById(R.id.main_content); + View messageView = getLayoutInflater().inflate(R.layout.dialog_about, container, false); String versionName = ""; try { @@ -234,16 +235,18 @@ public class MainActivity extends AppCompatActivity { } private void showSimpleSnackbar(String msg) { - Snackbar.make(fab, msg, Snackbar.LENGTH_LONG).setCallback(new Snackbar.Callback() { - @Override - public void onDismissed(Snackbar snackbar, int event) { - super.onDismissed(snackbar, event); + Snackbar.make(fab, msg, Snackbar.LENGTH_LONG) + .addCallback(new Snackbar.Callback() { + @Override + public void onDismissed(Snackbar snackbar, int event) { + super.onDismissed(snackbar, event); - if (entries.isEmpty()) { - showNoAccount(); - } - } - }).show(); + if (entries.isEmpty()) { + showNoAccount(); + } + } + }) + .show(); } private void showNoAccount(){ @@ -378,27 +381,18 @@ public class MainActivity extends AppCompatActivity { Snackbar.make(fab, R.string.msg_account_added, Snackbar.LENGTH_LONG).show(); } catch (Exception e) { - Snackbar.make(fab, R.string.msg_invalid_qr_code, Snackbar.LENGTH_LONG).setCallback(new Snackbar.Callback() { - @Override - public void onDismissed(Snackbar snackbar, int event) { - super.onDismissed(snackbar, event); - - if(entries.isEmpty()){ - showNoAccount(); - } - } - }).show(); + showSimpleSnackbar(R.string.msg_invalid_qr_code); return; } } else if (requestCode == INTENT_OPEN_DOCUMENT && resultCode == Activity.RESULT_OK) { - Uri file = null; + Uri file; if (intent != null) { file = intent.getData(); doImportJSON(file); } } else if (requestCode == INTENT_SAVE_DOCUMENT && resultCode == Activity.RESULT_OK) { - Uri file = null; + Uri file; if (intent != null) { file = intent.getData(); doExportJSON(file); @@ -432,7 +426,7 @@ public class MainActivity extends AppCompatActivity { @Override public void onClick(DialogInterface dialogInterface, int i) { adapter.getItem(pos).setLabel(input.getEditableText().toString()); - adapter.notifyDataSetChanged(); + adapter.notifyItemChanged(pos); SettingsHelper.store(getBaseContext(), entries); } diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml index b07561fc..bb823218 100644 --- a/app/src/main/res/layout/content_main.xml +++ b/app/src/main/res/layout/content_main.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" diff --git a/app/src/main/res/menu/menu_edit.xml b/app/src/main/res/menu/menu_edit.xml deleted file mode 100644 index 197e5c61..00000000 --- a/app/src/main/res/menu/menu_edit.xml +++ /dev/null @@ -1,18 +0,0 @@ -
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1eda8d0b..b7b9cc62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,9 +2,6 @@