Bug fixes & code improvements
- simplified access to MainActivity - fixed bug where the 'unread' tag wasn't updated - aboutlibraries version bump
This commit is contained in:
parent
d88d3c900e
commit
4c89bfe1cf
@ -79,7 +79,7 @@ dependencies {
|
|||||||
implementation('com.mikepenz:materialdrawer:6.0.2@aar') {
|
implementation('com.mikepenz:materialdrawer:6.0.2@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
implementation('com.mikepenz:aboutlibraries:6.0.1@aar') {
|
implementation('com.mikepenz:aboutlibraries:6.0.2@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
implementation "com.mikepenz:iconics-core:3.0.0@aar"
|
implementation "com.mikepenz:iconics-core:3.0.0@aar"
|
||||||
|
@ -94,9 +94,10 @@ class AddressDetailFragment : Fragment() {
|
|||||||
.setMessage(warning)
|
.setMessage(warning)
|
||||||
.setPositiveButton(android.R.string.yes) { _, _ ->
|
.setPositiveButton(android.R.string.yes) { _, _ ->
|
||||||
Singleton.getAddressRepository(ctx).remove(item)
|
Singleton.getAddressRepository(ctx).remove(item)
|
||||||
val mainActivity = MainActivity.getInstance()
|
MainActivity.apply {
|
||||||
if (item.privateKey != null && mainActivity != null) {
|
if (item.privateKey != null) {
|
||||||
mainActivity.removeIdentityEntry(item)
|
removeIdentityEntry(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.item = null
|
this.item = null
|
||||||
ctx.onBackPressed()
|
ctx.onBackPressed()
|
||||||
@ -109,13 +110,19 @@ class AddressDetailFragment : Fragment() {
|
|||||||
AlertDialog.Builder(ctx)
|
AlertDialog.Builder(ctx)
|
||||||
.setMessage(R.string.confirm_export)
|
.setMessage(R.string.confirm_export)
|
||||||
.setPositiveButton(android.R.string.yes) { _, _ ->
|
.setPositiveButton(android.R.string.yes) { _, _ ->
|
||||||
val shareIntent = Intent(Intent.ACTION_SEND)
|
val shareIntent = Intent(Intent.ACTION_SEND).apply {
|
||||||
shareIntent.type = "text/plain"
|
type = "text/plain"
|
||||||
shareIntent.putExtra(Intent.EXTRA_TITLE, item.toString() + EXPORT_POSTFIX)
|
putExtra(
|
||||||
val exporter = WifExporter(Singleton
|
Intent.EXTRA_TITLE,
|
||||||
.getBitmessageContext(ctx))
|
"$item$EXPORT_POSTFIX"
|
||||||
exporter.addIdentity(item)
|
)
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, exporter.toString())
|
putExtra(
|
||||||
|
Intent.EXTRA_TEXT,
|
||||||
|
WifExporter(Singleton.getBitmessageContext(ctx)).apply {
|
||||||
|
addIdentity(item)
|
||||||
|
}.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
startActivity(Intent.createChooser(shareIntent, null))
|
startActivity(Intent.createChooser(shareIntent, null))
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.no, null)
|
.setNegativeButton(android.R.string.no, null)
|
||||||
@ -186,7 +193,7 @@ class AddressDetailFragment : Fragment() {
|
|||||||
item?.let { item ->
|
item?.let { item ->
|
||||||
Singleton.getAddressRepository(context!!).save(item)
|
Singleton.getAddressRepository(context!!).save(item)
|
||||||
if (item.privateKey != null) {
|
if (item.privateKey != null) {
|
||||||
MainActivity.getInstance()?.updateIdentityEntry(item)
|
MainActivity.apply { updateIdentityEntry(item) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onPause()
|
super.onPause()
|
||||||
|
@ -62,10 +62,9 @@ class ImportIdentitiesFragment : Fragment() {
|
|||||||
|
|
||||||
view.findViewById<Button>(R.id.finish).setOnClickListener {
|
view.findViewById<Button>(R.id.finish).setOnClickListener {
|
||||||
importer.importAll(adapter.selected)
|
importer.importAll(adapter.selected)
|
||||||
val mainActivity = MainActivity.getInstance()
|
MainActivity.apply {
|
||||||
if (mainActivity != null) {
|
|
||||||
for (selected in adapter.selected) {
|
for (selected in adapter.selected) {
|
||||||
mainActivity.addIdentityEntry(selected)
|
addIdentityEntry(selected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activity.finish()
|
activity.finish()
|
||||||
|
@ -298,9 +298,8 @@ class MainActivity : AppCompatActivity(), ListSelectionListener<Serializable> {
|
|||||||
if (listFragment is ListHolder<*>) {
|
if (listFragment is ListHolder<*>) {
|
||||||
val listHolder = listFragment as ListHolder<*>
|
val listHolder = listFragment as ListHolder<*>
|
||||||
if (listHolder.showPreviousList()) {
|
if (listHolder.showPreviousList()) {
|
||||||
val drawerItem = drawer.getDrawerItem(listHolder.currentLabel)
|
drawer.getDrawerItem(listHolder.currentLabel)?.let {
|
||||||
if (drawerItem != null) {
|
drawer.setSelection(it)
|
||||||
drawer.setSelection(drawerItem)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -510,7 +509,7 @@ class MainActivity : AppCompatActivity(), ListSelectionListener<Serializable> {
|
|||||||
private var instance: WeakReference<MainActivity>? = null
|
private var instance: WeakReference<MainActivity>? = null
|
||||||
|
|
||||||
fun updateNodeSwitch() {
|
fun updateNodeSwitch() {
|
||||||
getInstance()?.apply {
|
apply {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
nodeSwitch.withChecked(Preferences.isFullNodeActive(this))
|
nodeSwitch.withChecked(Preferences.isFullNodeActive(this))
|
||||||
drawer.updateStickyFooterItem(nodeSwitch)
|
drawer.updateStickyFooterItem(nodeSwitch)
|
||||||
@ -518,6 +517,12 @@ class MainActivity : AppCompatActivity(), ListSelectionListener<Serializable> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getInstance() = instance?.get()
|
/**
|
||||||
|
* Runs the given code in the main activity context, if it currently exists. Otherwise,
|
||||||
|
* it's ignored.
|
||||||
|
*/
|
||||||
|
fun apply(run: MainActivity.() -> Unit){
|
||||||
|
instance?.get()?.let { run.invoke(it) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,6 +262,11 @@ class MessageListFragment : Fragment(), ListHolder<Label> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (removed.any { it.type == Label.Type.UNREAD } || added.any { it.type == Label.Type.UNREAD }) {
|
||||||
|
MainActivity.apply {
|
||||||
|
updateUnread()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,9 @@ class AddIdentityDialogFragment : AppCompatDialogFragment() {
|
|||||||
Toast.makeText(ctx,
|
Toast.makeText(ctx,
|
||||||
R.string.toast_identity_created,
|
R.string.toast_identity_created,
|
||||||
Toast.LENGTH_SHORT).show()
|
Toast.LENGTH_SHORT).show()
|
||||||
val mainActivity = MainActivity.getInstance()
|
MainActivity.apply {
|
||||||
mainActivity?.addIdentityEntry(identity)
|
addIdentityEntry(identity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,7 +107,7 @@ class AddIdentityDialogFragment : AppCompatDialogFragment() {
|
|||||||
Toast.makeText(ctx,
|
Toast.makeText(ctx,
|
||||||
R.string.toast_chan_created,
|
R.string.toast_chan_created,
|
||||||
Toast.LENGTH_SHORT).show()
|
Toast.LENGTH_SHORT).show()
|
||||||
MainActivity.getInstance()?.addIdentityEntry(chan)
|
MainActivity.apply { addIdentityEntry(chan) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ class DeterministicIdentityDialogFragment : AppCompatDialogFragment() {
|
|||||||
Toast.makeText(context,
|
Toast.makeText(context,
|
||||||
messageRes,
|
messageRes,
|
||||||
Toast.LENGTH_SHORT).show()
|
Toast.LENGTH_SHORT).show()
|
||||||
MainActivity.getInstance()?.let { mainActivity ->
|
MainActivity.apply {
|
||||||
identities.forEach { identity ->
|
identities.forEach { identity ->
|
||||||
mainActivity.addIdentityEntry(identity)
|
addIdentityEntry(identity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class MessageListener(ctx: Context) : BitmessageContext.Listener {
|
|||||||
notification.show()
|
notification.show()
|
||||||
|
|
||||||
// If MainActivity is shown, update the sidebar badges
|
// If MainActivity is shown, update the sidebar badges
|
||||||
MainActivity.getInstance()?.updateUnread()
|
MainActivity.apply { updateUnread() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,7 @@ object Singleton {
|
|||||||
Toast.makeText(ctx,
|
Toast.makeText(ctx,
|
||||||
R.string.toast_identity_created,
|
R.string.toast_identity_created,
|
||||||
Toast.LENGTH_SHORT).show()
|
Toast.LENGTH_SHORT).show()
|
||||||
val mainActivity = MainActivity.getInstance()
|
MainActivity.apply { addIdentityEntry(identity) }
|
||||||
mainActivity?.addIdentityEntry(identity)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user