Use 'aosp' and 'google' flavors to separate the two variants.

This is a replacement for the constantly rebased 'google' git branch.
This commit is contained in:
Andreas Schildbach 2019-09-06 16:11:05 +02:00
parent 3f11df7be6
commit e41533a63e
8 changed files with 77 additions and 6 deletions

View file

@ -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" >
<uses-sdk
android:minSdkVersion="19"

View file

@ -49,6 +49,15 @@ android {
}
}
productFlavors {
aosp {
versionNameSuffix '-aosp'
}
google {
versionNameSuffix '-google'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
@ -59,6 +68,12 @@ android {
test {
java.srcDirs = ['test']
}
aosp {
java.srcDirs = ['src-aosp']
}
google {
java.srcDirs = ['src-google']
}
}
packagingOptions {

View file

@ -10,8 +10,5 @@
<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>

View file

@ -0,0 +1,8 @@
<?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.DonateFragment"
android:title="@string/about_donate_title"/>
</preference-headers>

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.schildbach.oeffi;
public class Variants {
public static final boolean ENABLE_DONATE = true;
}

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.schildbach.oeffi;
public class Variants {
public static final boolean ENABLE_DONATE = false;
}

View file

@ -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,6 +329,7 @@ public abstract class OeffiMainActivity extends OeffiActivity {
}
case R.id.global_options_donate: {
if (Variants.ENABLE_DONATE)
PreferenceActivity.start(this, DonateFragment.class.getName());
return true;
}

View file

@ -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<Header> 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));
}
}