Fix some random bugs/deprecations

This commit is contained in:
Jakob Nixdorf 2017-07-02 21:51:32 +02:00
parent ce6d04ce9e
commit 7e3748f18b
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
4 changed files with 18 additions and 45 deletions

View file

@ -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,7 +235,8 @@ public class MainActivity extends AppCompatActivity {
}
private void showSimpleSnackbar(String msg) {
Snackbar.make(fab, msg, Snackbar.LENGTH_LONG).setCallback(new Snackbar.Callback() {
Snackbar.make(fab, msg, Snackbar.LENGTH_LONG)
.addCallback(new Snackbar.Callback() {
@Override
public void onDismissed(Snackbar snackbar, int event) {
super.onDismissed(snackbar, event);
@ -243,7 +245,8 @@ public class MainActivity extends AppCompatActivity {
showNoAccount();
}
}
}).show();
})
.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);
}

View file

@ -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"

View file

@ -1,18 +0,0 @@
<menu 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"
>
<item
android:id="@+id/action_edit"
android:orderInCategory="100"
android:icon="@android:drawable/ic_menu_edit"
app:showAsAction="ifRoom"
android:title="@string/menu_edit" />
<item
android:id="@+id/action_delete"
android:orderInCategory="100"
android:icon="@android:drawable/ic_menu_delete"
app:showAsAction="ifRoom"
android:title="@string/menu_delete" />
</menu>

View file

@ -2,9 +2,6 @@
<string name="app_name">andOTP</string>
<string name="app_launcher">OTP Authenticator</string>
<string name="no_accounts">No account has been added yet</string>
<string name="menu_delete">Delete</string>
<string name="menu_edit">Edit</string>
<string name="menu_scan">Scan QR Code</string>
<string name="menu_about">About</string>
<string name="menu_submenu_backup">Import / Export</string>
<string name="menu_export">Export (JSON)</string>
@ -16,7 +13,6 @@
<string name="msg_confirm_delete">Are you sure you want do remove this account?</string>
<string name="msg_account_removed">Account removed</string>
<string name="button_add">Add</string>
<string name="button_remove">Remove</string>
<string name="alert_rename">Rename</string>
<string name="alert_remove">"Remove "</string>
<string name="msg_camera_permission">Camera permission not granted</string>