diff --git a/oeffi/AndroidManifest.xml b/oeffi/AndroidManifest.xml
index 439af1f..c799bc4 100644
--- a/oeffi/AndroidManifest.xml
+++ b/oeffi/AndroidManifest.xml
@@ -60,8 +60,6 @@
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/My.Theme.Light" >
-
-
+
-
diff --git a/oeffi/res/values-v21/styles.xml b/oeffi/res/values-v21/styles.xml
index 15e2414..afc7c8e 100644
--- a/oeffi/res/values-v21/styles.xml
+++ b/oeffi/res/values-v21/styles.xml
@@ -24,6 +24,10 @@
- @style/My.Widget.TextView
+
+
+
+
+
diff --git a/oeffi/res/values/styles.xml b/oeffi/res/values/styles.xml
index 6753673..1a8798f 100644
--- a/oeffi/res/values/styles.xml
+++ b/oeffi/res/values/styles.xml
@@ -24,6 +24,10 @@
- @style/My.Widget.TextView
+
+
+
+
+
diff --git a/oeffi/res/xml/about.xml b/oeffi/res/xml/about.xml
deleted file mode 100644
index 03fb901..0000000
--- a/oeffi/res/xml/about.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/oeffi/res/xml/preference_about.xml b/oeffi/res/xml/preference_about.xml
new file mode 100644
index 0000000..726096e
--- /dev/null
+++ b/oeffi/res/xml/preference_about.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/oeffi/res/xml/preference_common.xml b/oeffi/res/xml/preference_common.xml
new file mode 100644
index 0000000..63e7059
--- /dev/null
+++ b/oeffi/res/xml/preference_common.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/oeffi/res/xml/preference_directions.xml b/oeffi/res/xml/preference_directions.xml
new file mode 100644
index 0000000..0efac78
--- /dev/null
+++ b/oeffi/res/xml/preference_directions.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
diff --git a/oeffi/res/xml/preference_donate.xml b/oeffi/res/xml/preference_donate.xml
new file mode 100644
index 0000000..71ce8a3
--- /dev/null
+++ b/oeffi/res/xml/preference_donate.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/oeffi/res/xml/preference_headers.xml b/oeffi/res/xml/preference_headers.xml
new file mode 100644
index 0000000..7270b3b
--- /dev/null
+++ b/oeffi/res/xml/preference_headers.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/oeffi/res/xml/preferences.xml b/oeffi/res/xml/preferences.xml
deleted file mode 100644
index 4ee707c..0000000
--- a/oeffi/res/xml/preferences.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/oeffi/src/de/schildbach/oeffi/AboutActivity.java b/oeffi/src/de/schildbach/oeffi/AboutActivity.java
deleted file mode 100644
index 6c6bd89..0000000
--- a/oeffi/src/de/schildbach/oeffi/AboutActivity.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package de.schildbach.oeffi;
-
-import de.schildbach.oeffi.util.ChangelogDialogBuilder;
-import de.schildbach.wallet.integration.android.BitcoinIntegration;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceScreen;
-
-public class AboutActivity extends PreferenceActivity {
- private static final String KEY_ABOUT_VERSION = "about_version";
- private static final String KEY_ABOUT_CHANGELOG = "about_changelog";
- private static final String KEY_ABOUT_FAQ = "about_faq";
- private static final String KEY_ABOUT_DONATE_BITCOIN = "about_donate_bitcoin";
- private static final String KEY_ABOUT_DONATE_EURO = "about_donate_euro";
- private static final String KEY_ABOUT_MARKET_APP = "about_market_app";
-
- @Override
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- getListView().setFitsSystemWindows(true);
- getListView().setClipToPadding(false);
-
- addPreferencesFromResource(R.xml.about);
-
- findPreference(KEY_ABOUT_VERSION).setSummary(((Application) getApplication()).packageInfo().versionName);
- findPreference(KEY_ABOUT_MARKET_APP).setSummary(String.format(Constants.MARKET_APP_URL, getPackageName()));
- }
-
- @Override
- public boolean onPreferenceTreeClick(final PreferenceScreen preferenceScreen, final Preference preference) {
- final String key = preference.getKey();
-
- if (KEY_ABOUT_CHANGELOG.equals(key)) {
- final Application application = (Application) getApplication();
- ChangelogDialogBuilder.get(this, Application.versionCode(application), null,
- Application.versionFlavor(application), 0, null).show();
- } else if (KEY_ABOUT_FAQ.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_faq_summary))));
- finish();
- } else if (KEY_ABOUT_DONATE_BITCOIN.equals(key)) {
- BitcoinIntegration.request(this, Constants.BITCOIN_ADDRESS);
- finish();
- } else if (KEY_ABOUT_DONATE_EURO.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.about_donate_euro_summary))));
- finish();
- } else if (KEY_ABOUT_MARKET_APP.equals(key)) {
- startActivity(new Intent(Intent.ACTION_VIEW,
- Uri.parse(String.format(Constants.MARKET_APP_URL, getPackageName()))));
- finish();
- }
-
- return false;
- }
-}
diff --git a/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java b/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java
index 97eb05f..9f4c80c 100644
--- a/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java
+++ b/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java
@@ -32,6 +32,9 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import de.schildbach.oeffi.preference.AboutFragment;
+import de.schildbach.oeffi.preference.DonateFragment;
+import de.schildbach.oeffi.preference.PreferenceActivity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +59,6 @@ import de.schildbach.oeffi.util.Installer;
import de.schildbach.oeffi.util.NavigationMenuAdapter;
import de.schildbach.oeffi.util.UiThreadExecutor;
import de.schildbach.pte.NetworkId;
-import de.schildbach.wallet.integration.android.BitcoinIntegration;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
@@ -78,7 +80,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
-import android.widget.PopupMenu;
import androidx.annotation.Nullable;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -325,23 +326,7 @@ public abstract class OeffiMainActivity extends OeffiActivity {
}
case R.id.global_options_donate: {
- final PopupMenu popup = new PopupMenu(this, getMyActionBar());
- popup.inflate(R.menu.donate_menu);
- popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
- public boolean onMenuItemClick(final MenuItem item) {
- if (item.getItemId() == R.id.donate_menu_bitcoin) {
- BitcoinIntegration.request(OeffiMainActivity.this, Constants.BITCOIN_ADDRESS);
- return true;
- } else if (item.getItemId() == R.id.donate_menu_euro) {
- startActivity(new Intent(Intent.ACTION_VIEW,
- Uri.parse(getString(R.string.about_donate_euro_summary))));
- return true;
- } else {
- return false;
- }
- }
- });
- popup.show();
+ PreferenceActivity.start(this, DonateFragment.class.getName());
return true;
}
@@ -351,12 +336,12 @@ public abstract class OeffiMainActivity extends OeffiActivity {
}
case R.id.global_options_preferences: {
- startActivity(new Intent(this, PreferencesActivity.class));
+ PreferenceActivity.start(this);
return true;
}
case R.id.global_options_about: {
- startActivity(new Intent(this, AboutActivity.class));
+ PreferenceActivity.start(this, AboutFragment.class.getName());
return true;
}
}
diff --git a/oeffi/src/de/schildbach/oeffi/PreferencesActivity.java b/oeffi/src/de/schildbach/oeffi/PreferencesActivity.java
deleted file mode 100644
index db729d2..0000000
--- a/oeffi/src/de/schildbach/oeffi/PreferencesActivity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright the original author or authors.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package de.schildbach.oeffi;
-
-import de.schildbach.oeffi.network.NetworkPickerActivity;
-
-import android.content.Intent;
-import android.os.Build;
-import android.os.Bundle;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceScreen;
-import android.provider.Settings;
-
-public class PreferencesActivity extends PreferenceActivity {
- private static final String KEY_NETWORK_PROVIDER = "network_provider";
- private static final String KEY_LOCATION_SETTINGS = "location_settings";
- private static final String KEY_BATTERY_OPTIMIZATIONS = "battery_optimizations";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- getListView().setFitsSystemWindows(true);
- getListView().setClipToPadding(false);
-
- addPreferencesFromResource(R.xml.preferences);
- findPreference(KEY_BATTERY_OPTIMIZATIONS).setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
- }
-
- @Override
- public boolean onPreferenceTreeClick(final PreferenceScreen preferenceScreen, final Preference preference) {
- final String key = preference.getKey();
-
- if (KEY_NETWORK_PROVIDER.equals(key)) {
- startActivity(new Intent(this, NetworkPickerActivity.class));
- return true;
- } else if (KEY_LOCATION_SETTINGS.equals(key)) {
- startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
- return true;
- } else if (KEY_BATTERY_OPTIMIZATIONS.equals(key)) {
- startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS));
- return true;
- }
-
- return false;
- }
-}
diff --git a/oeffi/src/de/schildbach/oeffi/preference/AboutFragment.java b/oeffi/src/de/schildbach/oeffi/preference/AboutFragment.java
new file mode 100644
index 0000000..789ef7b
--- /dev/null
+++ b/oeffi/src/de/schildbach/oeffi/preference/AboutFragment.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright the original author or authors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package de.schildbach.oeffi.preference;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import androidx.annotation.Nullable;
+import de.schildbach.oeffi.Application;
+import de.schildbach.oeffi.Constants;
+import de.schildbach.oeffi.R;
+import de.schildbach.oeffi.util.ChangelogDialogBuilder;
+
+public class AboutFragment extends PreferenceFragment {
+ private static final String KEY_ABOUT_VERSION = "about_version";
+ private static final String KEY_ABOUT_MARKET_APP = "about_market_app";
+ private static final String KEY_ABOUT_CHANGELOG = "about_changelog";
+
+ private Application application;
+
+ @Override
+ public void onAttach(final Activity activity) {
+ super.onAttach(activity);
+ this.application = (Application) activity.getApplication();
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preference_about);
+ findPreference(KEY_ABOUT_VERSION).setSummary(application.packageInfo().versionName);
+ final Uri marketUri = Uri.parse(String.format(Constants.MARKET_APP_URL, application.getPackageName()));
+ findPreference(KEY_ABOUT_MARKET_APP).setSummary(marketUri.toString());
+ findPreference(KEY_ABOUT_MARKET_APP).setIntent(new Intent(Intent.ACTION_VIEW, marketUri));
+ findPreference(KEY_ABOUT_CHANGELOG).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ ChangelogDialogBuilder.get(application, Application.versionCode(application), null,
+ Application.versionFlavor(application), 0, null).show();
+ return true;
+ }
+ });
+ }
+}
diff --git a/oeffi/src/de/schildbach/oeffi/preference/CommonFragment.java b/oeffi/src/de/schildbach/oeffi/preference/CommonFragment.java
new file mode 100644
index 0000000..e015564
--- /dev/null
+++ b/oeffi/src/de/schildbach/oeffi/preference/CommonFragment.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright the original author or authors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package de.schildbach.oeffi.preference;
+
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+import android.provider.Settings;
+import androidx.annotation.Nullable;
+import de.schildbach.oeffi.R;
+import de.schildbach.oeffi.network.NetworkPickerActivity;
+
+public class CommonFragment extends PreferenceFragment {
+ private static final String KEY_BATTERY_OPTIMIZATIONS = "battery_optimizations";
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preference_common);
+ findPreference(KEY_BATTERY_OPTIMIZATIONS).setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
+ }
+}
diff --git a/oeffi/src/de/schildbach/oeffi/preference/DirectionsFragment.java b/oeffi/src/de/schildbach/oeffi/preference/DirectionsFragment.java
new file mode 100644
index 0000000..cdb06ac
--- /dev/null
+++ b/oeffi/src/de/schildbach/oeffi/preference/DirectionsFragment.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright the original author or authors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package de.schildbach.oeffi.preference;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+import androidx.annotation.Nullable;
+import de.schildbach.oeffi.R;
+
+public class DirectionsFragment extends PreferenceFragment {
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.preference_directions);
+ }
+}
diff --git a/oeffi/src/de/schildbach/oeffi/preference/DonateFragment.java b/oeffi/src/de/schildbach/oeffi/preference/DonateFragment.java
new file mode 100644
index 0000000..93b88b6
--- /dev/null
+++ b/oeffi/src/de/schildbach/oeffi/preference/DonateFragment.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright the original author or authors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package de.schildbach.oeffi.preference;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import androidx.annotation.Nullable;
+import de.schildbach.oeffi.Constants;
+import de.schildbach.oeffi.R;
+import de.schildbach.wallet.integration.android.BitcoinIntegration;
+
+public class DonateFragment extends PreferenceFragment {
+ private static final String KEY_ABOUT_DONATE_BITCOIN = "about_donate_bitcoin";
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preference_donate);
+ findPreference(KEY_ABOUT_DONATE_BITCOIN).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ BitcoinIntegration.request(getActivity(), Constants.BITCOIN_ADDRESS);
+ return true;
+ }
+ });
+ }
+}
diff --git a/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java b/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java
new file mode 100644
index 0000000..10ab988
--- /dev/null
+++ b/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright the original author or authors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package de.schildbach.oeffi.preference;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.view.MenuItem;
+import de.schildbach.oeffi.R;
+
+import java.util.List;
+
+public class PreferenceActivity extends android.preference.PreferenceActivity {
+ public static void start(final Activity activity) {
+ activity.startActivity(new Intent(activity, PreferenceActivity.class));
+ }
+
+ public static void start(final Activity activity, final String fragmentName) {
+ final Intent intent = new Intent(activity, PreferenceActivity.class);
+ intent.putExtra(EXTRA_SHOW_FRAGMENT, fragmentName);
+ activity.startActivity(intent);
+ }
+
+ @Override
+ public void onBuildHeaders(final List target) {
+ loadHeadersFromResource(R.xml.preference_headers, target);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(final MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ protected boolean isValidFragment(final String fragmentName) {
+ return CommonFragment.class.getName().equals(fragmentName)
+ || DirectionsFragment.class.getName().equals(fragmentName)
+ || AboutFragment.class.getName().equals(fragmentName)
+ || DonateFragment.class.getName().equals(fragmentName);
+ }
+}