From e41533a63e3c7a8a29b752f08e6ed55f8942e065 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 6 Sep 2019 16:11:05 +0200 Subject: [PATCH] Use 'aosp' and 'google' flavors to separate the two variants. This is a replacement for the constantly rebased 'google' git branch. --- oeffi/AndroidManifest.xml | 2 +- oeffi/build.gradle | 15 +++++++++++++ oeffi/res/xml/preference_headers.xml | 3 --- oeffi/res/xml/preference_headers_donate.xml | 8 +++++++ .../de/schildbach/oeffi/Variants.java | 22 +++++++++++++++++++ .../de/schildbach/oeffi/Variants.java | 22 +++++++++++++++++++ .../schildbach/oeffi/OeffiMainActivity.java | 6 ++++- .../oeffi/preference/PreferenceActivity.java | 5 ++++- 8 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 oeffi/res/xml/preference_headers_donate.xml create mode 100644 oeffi/src-aosp/de/schildbach/oeffi/Variants.java create mode 100644 oeffi/src-google/de/schildbach/oeffi/Variants.java diff --git a/oeffi/AndroidManifest.xml b/oeffi/AndroidManifest.xml index 41ee599..6fa7150 100644 --- a/oeffi/AndroidManifest.xml +++ b/oeffi/AndroidManifest.xml @@ -20,7 +20,7 @@ xmlns:tools="http://schemas.android.com/tools" package="de.schildbach.oeffi" android:versionCode="653" - android:versionName="10.5.9-aosp" > + android:versionName="10.5.9" > -
diff --git a/oeffi/res/xml/preference_headers_donate.xml b/oeffi/res/xml/preference_headers_donate.xml new file mode 100644 index 0000000..1b0b600 --- /dev/null +++ b/oeffi/res/xml/preference_headers_donate.xml @@ -0,0 +1,8 @@ + + + +
+ + diff --git a/oeffi/src-aosp/de/schildbach/oeffi/Variants.java b/oeffi/src-aosp/de/schildbach/oeffi/Variants.java new file mode 100644 index 0000000..8f26f91 --- /dev/null +++ b/oeffi/src-aosp/de/schildbach/oeffi/Variants.java @@ -0,0 +1,22 @@ +/* + * 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; + +public class Variants { + public static final boolean ENABLE_DONATE = true; +} diff --git a/oeffi/src-google/de/schildbach/oeffi/Variants.java b/oeffi/src-google/de/schildbach/oeffi/Variants.java new file mode 100644 index 0000000..3fe9f90 --- /dev/null +++ b/oeffi/src-google/de/schildbach/oeffi/Variants.java @@ -0,0 +1,22 @@ +/* + * 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; + +public class Variants { + public static final boolean ENABLE_DONATE = false; +} diff --git a/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java b/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java index 9f4c80c..9ba245e 100644 --- a/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java +++ b/oeffi/src/de/schildbach/oeffi/OeffiMainActivity.java @@ -277,6 +277,9 @@ public abstract class OeffiMainActivity extends OeffiActivity { final MenuItem plansItem = menu.findItem(R.id.global_options_plans); plansItem.setChecked(this instanceof PlansPickerActivity); + final MenuItem donateItem = menu.findItem(R.id.global_options_donate); + donateItem.setVisible(Variants.ENABLE_DONATE); + return super.onPrepareOptionsMenu(menu); } @@ -326,7 +329,8 @@ public abstract class OeffiMainActivity extends OeffiActivity { } case R.id.global_options_donate: { - PreferenceActivity.start(this, DonateFragment.class.getName()); + if (Variants.ENABLE_DONATE) + PreferenceActivity.start(this, DonateFragment.class.getName()); return true; } diff --git a/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java b/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java index 10ab988..ff08703 100644 --- a/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java +++ b/oeffi/src/de/schildbach/oeffi/preference/PreferenceActivity.java @@ -21,6 +21,7 @@ import android.app.Activity; import android.content.Intent; import android.view.MenuItem; import de.schildbach.oeffi.R; +import de.schildbach.oeffi.Variants; import java.util.List; @@ -38,6 +39,8 @@ public class PreferenceActivity extends android.preference.PreferenceActivity { @Override public void onBuildHeaders(final List
target) { loadHeadersFromResource(R.xml.preference_headers, target); + if (Variants.ENABLE_DONATE) + loadHeadersFromResource(R.xml.preference_headers_donate, target); } @Override @@ -56,6 +59,6 @@ public class PreferenceActivity extends android.preference.PreferenceActivity { return CommonFragment.class.getName().equals(fragmentName) || DirectionsFragment.class.getName().equals(fragmentName) || AboutFragment.class.getName().equals(fragmentName) - || DonateFragment.class.getName().equals(fragmentName); + || (Variants.ENABLE_DONATE && DonateFragment.class.getName().equals(fragmentName)); } }