From 2d2916f4984ae5888aa3318184839009ff283f7c Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Thu, 14 Jan 2016 16:41:10 +0100 Subject: [PATCH] Added some quick & dirty activity to show addresses and the network state --- app/src/main/AndroidManifest.xml | 102 ++++++++++-------- .../ch/dissem/apps/abit/SettingsFragment.java | 10 ++ .../ch/dissem/apps/abit/StatusActivity.java | 36 +++++++ .../apps/abit/service/BitmessageService.java | 3 + app/src/main/res/layout/activity_status.xml | 40 +++++++ app/src/main/res/values-de/strings.xml | 4 + app/src/main/res/values/strings.xml | 4 + app/src/main/res/xml/preferences.xml | 5 + 8 files changed, 160 insertions(+), 44 deletions(-) create mode 100644 app/src/main/java/ch/dissem/apps/abit/StatusActivity.java create mode 100644 app/src/main/res/layout/activity_status.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4f64223..5738a48 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,17 +1,18 @@ - + - - - - - - - - + + + + + + + + - + - + + android:value=".MainActivity"/> + android:value=".MainActivity"/> + android:value=".MainActivity"/> - + - - - + + + - + - + - + - + - + - + - + - + - + - - + - - - + + + - - + + - - + + + + android:syncable="true"/> + - + + + android:resource="@xml/authenticator"/> - + + - + + + + + diff --git a/app/src/main/java/ch/dissem/apps/abit/SettingsFragment.java b/app/src/main/java/ch/dissem/apps/abit/SettingsFragment.java index 38ad512..dc638e7 100644 --- a/app/src/main/java/ch/dissem/apps/abit/SettingsFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/SettingsFragment.java @@ -1,6 +1,7 @@ package ch.dissem.apps.abit; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; @@ -42,6 +43,15 @@ public class SettingsFragment return true; } }); + + Preference status = findPreference("status"); + status.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + startActivity(new Intent(getActivity(), StatusActivity.class)); + return true; + } + }); } @Override diff --git a/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java b/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java new file mode 100644 index 0000000..60886b2 --- /dev/null +++ b/app/src/main/java/ch/dissem/apps/abit/StatusActivity.java @@ -0,0 +1,36 @@ +package ch.dissem.apps.abit; + +import android.os.Bundle; +import android.app.Activity; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.widget.TextView; + +import ch.dissem.apps.abit.service.Singleton; +import ch.dissem.bitmessage.BitmessageContext; +import ch.dissem.bitmessage.entity.BitmessageAddress; + +public class StatusActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_status); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(false); + + BitmessageContext bmc = Singleton.getBitmessageContext(this); + StringBuilder status = new StringBuilder(); + for (BitmessageAddress address : bmc.addresses().getIdentities()) { + status.append(address.getAddress()).append('\n'); + } + status.append('\n'); + status.append(bmc.status()); + ((TextView) findViewById(R.id.content)).setText(status); + } + +} diff --git a/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java b/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java index 5c81472..b5c18f6 100644 --- a/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java +++ b/app/src/main/java/ch/dissem/apps/abit/service/BitmessageService.java @@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory; import java.io.Serializable; import java.lang.ref.WeakReference; +import ch.dissem.apps.abit.R; import ch.dissem.apps.abit.notification.NetworkNotification; import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.entity.BitmessageAddress; @@ -101,6 +102,8 @@ public class BitmessageService extends Service { switch (msg.what) { case MSG_CREATE_IDENTITY: { BitmessageAddress identity = bmc.createIdentity(false); + identity.setAlias(service.get().getString(R.string.alias_default_identity)); + bmc.addresses().save(identity); if (msg.replyTo != null) { try { Message message = Message.obtain(this, MSG_CREATE_IDENTITY); diff --git a/app/src/main/res/layout/activity_status.xml b/app/src/main/res/layout/activity_status.xml new file mode 100644 index 0000000..2e8d317 --- /dev/null +++ b/app/src/main/res/layout/activity_status.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 694b211..279491a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -52,4 +52,8 @@ Server POW Der vertrauenswürdige Knoten macht den Proof of Work Ein aktiver Bitmessage-Knoten muss viel hoch- und herunterladen, was auf einem mobilen Netzwerk teuer sein kann. Soll tatsächlich ein aktiver Knoten gestartet werden? + Debugging + Ich + Debugging + Technische Infos \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fa2c9df..83c5d60 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -55,4 +55,8 @@ Running a full Bitmessage node uses a lot of traffic, which could be expensive on a mobile network. Are you sure you want to start a full node? About Abit Open source dependencies. + Debugging + Debugging + Technical information + Me diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 696d443..b04f110 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -36,4 +36,9 @@ android:title="@string/about" android:summary="@string/about_summary" /> + \ No newline at end of file