From 249c97d4bacb844f9238b3c0c09755a1140fedcd Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Fri, 16 Dec 2016 07:44:01 +0100 Subject: [PATCH] Added function to cleanup inventory (mine grew to 1.5GB) but no automatism yet --- app/build.gradle | 8 ++--- .../apps/abit/ComposeMessageFragment.java | 6 ++-- .../ch/dissem/apps/abit/SettingsFragment.java | 34 +++++++++++++++++++ .../apps/abit/service/BitmessageService.java | 4 +-- 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 +++ build.gradle | 2 +- 8 files changed, 57 insertions(+), 10 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 20fa736..f96adba 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ if (project.hasProperty("project.configs") //noinspection GroovyMissingReturnStatement android { compileSdkVersion 25 - buildToolsVersion "25.0.0" + buildToolsVersion "25.0.1" defaultConfig { applicationId "ch.dissem.apps." + appName.toLowerCase() @@ -40,9 +40,9 @@ android { ext.jabitVersion = 'feature-extended-encoding-SNAPSHOT' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.0.1' - compile 'com.android.support:support-v4:25.0.1' - compile 'com.android.support:design:25.0.1' + compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:support-v4:25.1.0' + compile 'com.android.support:design:25.1.0' compile "ch.dissem.jabit:jabit-core:$jabitVersion" compile "ch.dissem.jabit:jabit-networking:$jabitVersion" diff --git a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java index 3a357b6..4413933 100644 --- a/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/ComposeMessageFragment.java @@ -38,7 +38,7 @@ import ch.dissem.apps.abit.service.Singleton; import ch.dissem.bitmessage.BitmessageContext; import ch.dissem.bitmessage.entity.BitmessageAddress; import ch.dissem.bitmessage.entity.Plaintext; -import ch.dissem.bitmessage.entity.valueobject.ExtendedEncoding; +import ch.dissem.bitmessage.entity.valueobject.extended.Message; import static android.app.Activity.RESULT_OK; import static ch.dissem.apps.abit.ComposeMessageActivity.EXTRA_BROADCAST; @@ -223,10 +223,10 @@ public class ComposeMessageFragment extends Fragment { break; case EXTENDED: builder.message( - new ExtendedEncoding.Builder() - .message() + new Message.Builder() .subject(subjectInput.getText().toString()) .body(bodyInput.getText().toString()) + .addParent(parent) .build() ); break; 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 223e8de..15fc6b0 100644 --- a/app/src/main/java/ch/dissem/apps/abit/SettingsFragment.java +++ b/app/src/main/java/ch/dissem/apps/abit/SettingsFragment.java @@ -19,14 +19,17 @@ package ch.dissem.apps.abit; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.AsyncTask; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; +import android.widget.Toast; import com.mikepenz.aboutlibraries.Libs; import com.mikepenz.aboutlibraries.LibsBuilder; +import ch.dissem.apps.abit.service.Singleton; import ch.dissem.apps.abit.synchronization.SyncAdapter; import static ch.dissem.apps.abit.util.Constants.PREFERENCE_SERVER_POW; @@ -59,6 +62,37 @@ public class SettingsFragment return true; } }); + final Preference cleanup = findPreference("cleanup"); + cleanup.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + new AsyncTask() { + @Override + protected void onPreExecute() { + cleanup.setEnabled(false); + Toast.makeText(getActivity(), R.string.cleanup_notification_start, Toast + .LENGTH_SHORT).show(); + } + + @Override + protected Void doInBackground(Void... voids) { + Singleton.getBitmessageContext(getActivity()).cleanup(); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + Toast.makeText( + getActivity(), + R.string.cleanup_notification_end, + Toast.LENGTH_LONG + ).show(); + cleanup.setEnabled(true); + } + }.execute(); + return true; + } + }); Preference status = findPreference("status"); status.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { 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 1b8c645..5c8a528 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 @@ -33,11 +33,11 @@ import static ch.dissem.apps.abit.notification.NetworkNotification.NETWORK_NOTIF * onPerformSync(). */ public class BitmessageService extends Service { - private NetworkNotification notification = null; private static BitmessageContext bmc = null; - private static volatile boolean running = false; + private NetworkNotification notification = null; + public static boolean isRunning() { return running && bmc.isRunning(); } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ce4217b..4d03c23 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -113,4 +113,8 @@ Als Alternative kann in den Einstellungen ein vertrauenswürdiger Knoten konfigu Codierung ‘%s’ wird nicht unterstützt, es wird ‘SIMPLE’ verwendet. Kodierung auswählen ‘EXTENDED’ ist ein neues Datenformat welches noch nicht überall funktioniert, es hat jedoch einige interessante Vorteile. Wähle ‘SIMPLE’ um sicher zu gehen. + Aufräumen + Aufräumarbeiten gestartet + Aufräumarbeiten beendet + Veraltete Inventareinträge werden entfernt diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 397ad27..96037f6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -112,4 +112,8 @@ As an alternative you could configure a trusted node in the settings, but as of Unsupported encoding ‘%s’, using ‘SIMPLE’ instead. ‘EXTENDED’ is a new message format that\'s not widely supported yet but has some interesting features. To stay on the save side, select ‘SIMPLE’. Select Message Encoding + Cleanup + Remove outdated inventory entries + Cleanup started + Cleanup finished diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 85568c0..fd31078 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -44,6 +44,11 @@ android:action="android.intent.action.VIEW" android:data="@string/help_out_link"/> +