mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-07 19:18:52 +00:00
PreferencesActivity: Migrate to usage of PreferenceFragment for all settings.
This commit is contained in:
parent
924de06cb1
commit
d06373c608
19 changed files with 424 additions and 291 deletions
|
@ -60,8 +60,6 @@
|
|||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:theme="@style/My.Theme.Light" >
|
||||
<activity android:name=".PreferencesActivity" />
|
||||
<activity android:name=".AboutActivity" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
|
@ -73,6 +71,10 @@
|
|||
android:resource="@xml/file_provider" />
|
||||
</provider>
|
||||
|
||||
<activity
|
||||
android:name=".preference.PreferenceActivity"
|
||||
android:theme="@style/My.Theme.Preference"
|
||||
android:label="@string/global_options_preferences_title" />
|
||||
<activity
|
||||
android:name=".network.NetworkPickerActivity"
|
||||
android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/donate_menu_bitcoin"
|
||||
android:title="@string/about_donate_bitcoin_title"
|
||||
android:titleCondensed="@string/about_donate_bitcoin_summary"/>
|
||||
<item
|
||||
android:id="@+id/donate_menu_euro"
|
||||
android:title="@string/about_donate_euro_title"
|
||||
android:titleCondensed="@string/about_donate_euro_summary"/>
|
||||
|
||||
</menu>
|
|
@ -24,6 +24,10 @@
|
|||
<item name="android:textViewStyle">@style/My.Widget.TextView</item>
|
||||
</style>
|
||||
|
||||
<style name="My.Theme.Preference" parent="@android:style/Theme.Material.Light.DarkActionBar">
|
||||
<item name="android:actionBarStyle">@style/My.Widget.ActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="My.Widget.AutoCompleteTextView" parent="@android:style/Widget.Material.Light.AutoCompleteTextView">
|
||||
<item name="android:textColor">@color/text</item>
|
||||
<item name="android:background">@null</item>
|
||||
|
@ -53,4 +57,15 @@
|
|||
|
||||
<style name="My.Widget.PopupMenu" parent="@android:style/Widget.Material.Light.PopupMenu" />
|
||||
|
||||
<style name="My.Widget.ActionBar" parent="@android:style/Widget.Material.ActionBar.Solid">
|
||||
<item name="android:background">@color/action_bar_background</item>
|
||||
<item name="android:titleTextStyle">@style/My.TextAppearance.Widget.ActionBar.Title</item>
|
||||
<item name="android:displayOptions">homeAsUp|showTitle</item>
|
||||
</style>
|
||||
|
||||
<style name="My.TextAppearance.Widget.ActionBar.Title" parent="@android:style/TextAppearance.Material.Widget.ActionBar.Title">
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
<item name="android:textViewStyle">@style/My.Widget.TextView</item>
|
||||
</style>
|
||||
|
||||
<style name="My.Theme.Preference" parent="@android:style/Theme.Holo.Light.DarkActionBar">
|
||||
<item name="android:actionBarStyle">@style/My.Widget.ActionBar</item>
|
||||
</style>
|
||||
|
||||
<style name="My.Theme.Translucent" parent="@style/My.Theme.Light">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
@ -73,4 +77,15 @@
|
|||
|
||||
<style name="My.Widget.PopupMenu" parent="@android:style/Widget.Holo.Light.PopupMenu" />
|
||||
|
||||
<style name="My.Widget.ActionBar" parent="@android:style/Widget.Holo.ActionBar.Solid">
|
||||
<item name="android:background">@color/action_bar_background</item>
|
||||
<item name="android:titleTextStyle">@style/My.TextAppearance.Widget.ActionBar.Title</item>
|
||||
<item name="android:displayOptions">homeAsUp|showTitle</item>
|
||||
</style>
|
||||
|
||||
<style name="My.TextAppearance.Widget.ActionBar.Title" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
|
||||
<item name="android:textColor">@android:color/white</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="about" >
|
||||
|
||||
<PreferenceCategory android:title="@string/about_title" >
|
||||
<Preference
|
||||
android:key="about_version"
|
||||
android:title="Version" />
|
||||
<Preference
|
||||
android:summary="@string/about_copyright_summary"
|
||||
android:title="@string/about_copyright_title" />
|
||||
<Preference
|
||||
android:key="about_license"
|
||||
android:summary="https://www.gnu.org/licenses/gpl-3.0.txt"
|
||||
android:title="@string/about_license_title" >
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://www.gnu.org/licenses/gpl-3.0.txt" />
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="about_changelog"
|
||||
android:summary="@string/about_changelog_summary"
|
||||
android:title="@string/about_changelog_title" />
|
||||
<Preference
|
||||
android:key="about_faq"
|
||||
android:summary="@string/about_faq_summary"
|
||||
android:title="@string/about_faq_title" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/about_participate_title" >
|
||||
<Preference
|
||||
android:key="about_market_app"
|
||||
android:title="@string/about_market_app_title" />
|
||||
<Preference
|
||||
android:key="about_source"
|
||||
android:summary="https://gitlab.com/oeffi/oeffi"
|
||||
android:title="@string/about_source_title" >
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://gitlab.com/oeffi/oeffi" />
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="about_twitter"
|
||||
android:summary="\@oeffi"
|
||||
android:title="Twitter">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://twitter.com/oeffi" />
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="about_donate"
|
||||
android:title="@string/about_donate_title" >
|
||||
<Preference
|
||||
android:key="about_donate_bitcoin"
|
||||
android:summary="@string/about_donate_bitcoin_summary"
|
||||
android:title="@string/about_donate_bitcoin_title" />
|
||||
<Preference
|
||||
android:key="about_donate_euro"
|
||||
android:summary="@string/about_donate_euro_summary"
|
||||
android:title="@string/about_donate_euro_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
52
oeffi/res/xml/preference_about.xml
Normal file
52
oeffi/res/xml/preference_about.xml
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="about_version"
|
||||
android:title="Version"/>
|
||||
<Preference
|
||||
android:summary="@string/about_copyright_summary"
|
||||
android:title="@string/about_copyright_title"/>
|
||||
<Preference
|
||||
android:key="about_license"
|
||||
android:summary="https://www.gnu.org/licenses/gpl-3.0.txt"
|
||||
android:title="@string/about_license_title">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://www.gnu.org/licenses/gpl-3.0.txt"/>
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="about_changelog"
|
||||
android:summary="@string/about_changelog_summary"
|
||||
android:title="@string/about_changelog_title"/>
|
||||
<Preference
|
||||
android:key="about_faq"
|
||||
android:summary="@string/about_faq_summary"
|
||||
android:title="@string/about_faq_title">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="@string/about_faq_summary"/>
|
||||
</Preference>
|
||||
|
||||
<PreferenceCategory android:title="@string/about_participate_title">
|
||||
<Preference
|
||||
android:key="about_market_app"
|
||||
android:title="@string/about_market_app_title"/>
|
||||
<Preference
|
||||
android:key="about_source"
|
||||
android:summary="https://gitlab.com/oeffi/oeffi"
|
||||
android:title="@string/about_source_title">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://gitlab.com/oeffi/oeffi"/>
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="about_twitter"
|
||||
android:summary="\@oeffi"
|
||||
android:title="Twitter">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://twitter.com/oeffi"/>
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
35
oeffi/res/xml/preference_common.xml
Normal file
35
oeffi/res/xml/preference_common.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="network_provider"
|
||||
android:summary="@string/global_preferences_network_provider_summary"
|
||||
android:title="@string/global_preferences_network_provider_title">
|
||||
<intent
|
||||
android:targetPackage="de.schildbach.oeffi"
|
||||
android:targetClass="de.schildbach.oeffi.network.NetworkPickerActivity"/>
|
||||
</Preference>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="show_changelog"
|
||||
android:summary="@string/global_preferences_show_changelog_summary"
|
||||
android:title="@string/global_preferences_show_changelog_title"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="show_hints"
|
||||
android:summary="@string/global_preferences_show_hints_summary"
|
||||
android:title="@string/global_preferences_show_hints_title"/>
|
||||
<Preference
|
||||
android:key="location_settings"
|
||||
android:summary="@string/global_preferences_location_settings_summary"
|
||||
android:title="@string/global_preferences_location_settings_title">
|
||||
<intent android:action="android.settings.LOCATION_SOURCE_SETTINGS"/>
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="battery_optimizations"
|
||||
android:summary="@string/global_preferences_battery_optimizations_summary"
|
||||
android:title="@string/global_preferences_battery_optimizations_title">
|
||||
<intent android:action="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS"/>
|
||||
</Preference>
|
||||
|
||||
</PreferenceScreen>
|
25
oeffi/res/xml/preference_directions.xml
Normal file
25
oeffi/res/xml/preference_directions.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ListPreference
|
||||
android:entries="@array/directions_optimize_trip"
|
||||
android:entryValues="@array/directions_optimize_trip_values"
|
||||
android:key="optimize_trip"
|
||||
android:summary="@string/directions_preferences_optimize_trip_summary"
|
||||
android:title="@string/directions_preferences_optimize_trip_title"/>
|
||||
<ListPreference
|
||||
android:defaultValue="NORMAL"
|
||||
android:entries="@array/directions_walk_speed"
|
||||
android:entryValues="@array/directions_walk_speed_values"
|
||||
android:key="walk_speed"
|
||||
android:summary="@string/directions_preferences_walk_speed_summary"
|
||||
android:title="@string/directions_preferences_walk_speed_title"/>
|
||||
<ListPreference
|
||||
android:defaultValue="NEUTRAL"
|
||||
android:entries="@array/directions_accessibility"
|
||||
android:entryValues="@array/directions_accessibility_values"
|
||||
android:key="accessibility"
|
||||
android:summary="@string/directions_preferences_accessibility_summary"
|
||||
android:title="@string/directions_preferences_accessibility_title"/>
|
||||
|
||||
</PreferenceScreen>
|
17
oeffi/res/xml/preference_donate.xml
Normal file
17
oeffi/res/xml/preference_donate.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<Preference
|
||||
android:key="about_donate_bitcoin"
|
||||
android:summary="@string/about_donate_bitcoin_summary"
|
||||
android:title="@string/about_donate_bitcoin_title"/>
|
||||
<Preference
|
||||
android:key="about_donate_euro"
|
||||
android:summary="@string/about_donate_euro_summary"
|
||||
android:title="@string/about_donate_euro_title">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="@string/about_donate_euro_summary"/>
|
||||
</Preference>
|
||||
|
||||
</PreferenceScreen>
|
17
oeffi/res/xml/preference_headers.xml
Normal file
17
oeffi/res/xml/preference_headers.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<header
|
||||
android:fragment="de.schildbach.oeffi.preference.CommonFragment"
|
||||
android:title="@string/global_preferences_title"/>
|
||||
<header
|
||||
android:fragment="de.schildbach.oeffi.preference.DirectionsFragment"
|
||||
android:title="@string/directions_preferences_title"/>
|
||||
<header
|
||||
android:fragment="de.schildbach.oeffi.preference.AboutFragment"
|
||||
android:title="@string/about_title"/>
|
||||
<header
|
||||
android:fragment="de.schildbach.oeffi.preference.DonateFragment"
|
||||
android:title="@string/about_donate_title"/>
|
||||
|
||||
</preference-headers>
|
|
@ -1,53 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory android:title="@string/global_preferences_title" >
|
||||
<Preference
|
||||
android:key="network_provider"
|
||||
android:summary="@string/global_preferences_network_provider_summary"
|
||||
android:title="@string/global_preferences_network_provider_title" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="show_changelog"
|
||||
android:summary="@string/global_preferences_show_changelog_summary"
|
||||
android:title="@string/global_preferences_show_changelog_title" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="show_hints"
|
||||
android:summary="@string/global_preferences_show_hints_summary"
|
||||
android:title="@string/global_preferences_show_hints_title" />
|
||||
|
||||
<Preference
|
||||
android:key="location_settings"
|
||||
android:summary="@string/global_preferences_location_settings_summary"
|
||||
android:title="@string/global_preferences_location_settings_title" />
|
||||
<Preference
|
||||
android:key="battery_optimizations"
|
||||
android:summary="@string/global_preferences_battery_optimizations_summary"
|
||||
android:title="@string/global_preferences_battery_optimizations_title" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/directions_preferences_title" >
|
||||
<ListPreference
|
||||
android:entries="@array/directions_optimize_trip"
|
||||
android:entryValues="@array/directions_optimize_trip_values"
|
||||
android:key="optimize_trip"
|
||||
android:summary="@string/directions_preferences_optimize_trip_summary"
|
||||
android:title="@string/directions_preferences_optimize_trip_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="NORMAL"
|
||||
android:entries="@array/directions_walk_speed"
|
||||
android:entryValues="@array/directions_walk_speed_values"
|
||||
android:key="walk_speed"
|
||||
android:summary="@string/directions_preferences_walk_speed_summary"
|
||||
android:title="@string/directions_preferences_walk_speed_title" />
|
||||
<ListPreference
|
||||
android:defaultValue="NEUTRAL"
|
||||
android:entries="@array/directions_accessibility"
|
||||
android:entryValues="@array/directions_accessibility_values"
|
||||
android:key="accessibility"
|
||||
android:summary="@string/directions_preferences_accessibility_summary"
|
||||
android:title="@string/directions_preferences_accessibility_title" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
63
oeffi/src/de/schildbach/oeffi/preference/AboutFragment.java
Normal file
63
oeffi/src/de/schildbach/oeffi/preference/AboutFragment.java
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
39
oeffi/src/de/schildbach/oeffi/preference/CommonFragment.java
Normal file
39
oeffi/src/de/schildbach/oeffi/preference/CommonFragment.java
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
44
oeffi/src/de/schildbach/oeffi/preference/DonateFragment.java
Normal file
44
oeffi/src/de/schildbach/oeffi/preference/DonateFragment.java
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Header> 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue