From 4c89bfe1cf0a0f1f027000c7f1a2e93179b49b88 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Thu, 11 Jan 2018 17:25:26 +0100 Subject: [PATCH] Bug fixes & code improvements - simplified access to MainActivity - fixed bug where the 'unread' tag wasn't updated - aboutlibraries version bump --- app/build.gradle | 2 +- .../dissem/apps/abit/AddressDetailFragment.kt | 29 +++++++---- .../apps/abit/ImportIdentitiesFragment.kt | 5 +- .../java/ch/dissem/apps/abit/MainActivity.kt | 15 ++++-- .../dissem/apps/abit/MessageListFragment.kt | 51 ++++++++++--------- .../abit/dialog/AddIdentityDialogFragment.kt | 7 +-- .../DeterministicIdentityDialogFragment.kt | 4 +- .../apps/abit/listener/MessageListener.kt | 2 +- .../ch/dissem/apps/abit/service/Singleton.kt | 3 +- 9 files changed, 67 insertions(+), 51 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7d4133e..4b08511 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -79,7 +79,7 @@ dependencies { implementation('com.mikepenz:materialdrawer:6.0.2@aar') { transitive = true } - implementation('com.mikepenz:aboutlibraries:6.0.1@aar') { + implementation('com.mikepenz:aboutlibraries:6.0.2@aar') { transitive = true } implementation "com.mikepenz:iconics-core:3.0.0@aar" diff --git a/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.kt b/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.kt index ab7fea0..9a4ea03 100644 --- a/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.kt +++ b/app/src/main/java/ch/dissem/apps/abit/AddressDetailFragment.kt @@ -94,9 +94,10 @@ class AddressDetailFragment : Fragment() { .setMessage(warning) .setPositiveButton(android.R.string.yes) { _, _ -> Singleton.getAddressRepository(ctx).remove(item) - val mainActivity = MainActivity.getInstance() - if (item.privateKey != null && mainActivity != null) { - mainActivity.removeIdentityEntry(item) + MainActivity.apply { + if (item.privateKey != null) { + removeIdentityEntry(item) + } } this.item = null ctx.onBackPressed() @@ -109,13 +110,19 @@ class AddressDetailFragment : Fragment() { AlertDialog.Builder(ctx) .setMessage(R.string.confirm_export) .setPositiveButton(android.R.string.yes) { _, _ -> - val shareIntent = Intent(Intent.ACTION_SEND) - shareIntent.type = "text/plain" - shareIntent.putExtra(Intent.EXTRA_TITLE, item.toString() + EXPORT_POSTFIX) - val exporter = WifExporter(Singleton - .getBitmessageContext(ctx)) - exporter.addIdentity(item) - shareIntent.putExtra(Intent.EXTRA_TEXT, exporter.toString()) + val shareIntent = Intent(Intent.ACTION_SEND).apply { + type = "text/plain" + putExtra( + Intent.EXTRA_TITLE, + "$item$EXPORT_POSTFIX" + ) + putExtra( + Intent.EXTRA_TEXT, + WifExporter(Singleton.getBitmessageContext(ctx)).apply { + addIdentity(item) + }.toString() + ) + } startActivity(Intent.createChooser(shareIntent, null)) } .setNegativeButton(android.R.string.no, null) @@ -186,7 +193,7 @@ class AddressDetailFragment : Fragment() { item?.let { item -> Singleton.getAddressRepository(context!!).save(item) if (item.privateKey != null) { - MainActivity.getInstance()?.updateIdentityEntry(item) + MainActivity.apply { updateIdentityEntry(item) } } } super.onPause() diff --git a/app/src/main/java/ch/dissem/apps/abit/ImportIdentitiesFragment.kt b/app/src/main/java/ch/dissem/apps/abit/ImportIdentitiesFragment.kt index 91088c9..c65b3ed 100644 --- a/app/src/main/java/ch/dissem/apps/abit/ImportIdentitiesFragment.kt +++ b/app/src/main/java/ch/dissem/apps/abit/ImportIdentitiesFragment.kt @@ -62,10 +62,9 @@ class ImportIdentitiesFragment : Fragment() { view.findViewById