diff --git a/app/build.gradle b/app/build.gradle
index 4378d6879..6732075bc 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -15,10 +15,19 @@ def getVersionName = { ->
def isCi = "true".equals(System.getenv("CI"))
def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
+def fullApplicationId = "org.fdroid.fdroid"
+def basicApplicationId = "org.fdroid.basic"
+
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
+ defaultConfig {
+ versionCode 1003001
+ versionName getVersionName()
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+
buildTypes {
// use proguard on debug too since we have unknowingly broken
// release builds before.
@@ -29,6 +38,26 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'src/androidTest/proguard-rules.pro'
}
+ debug {
+ applicationIdSuffix ".debug"
+ resValue "string", "applicationId", fullApplicationId + applicationIdSuffix
+ versionNameSuffix "-debug"
+ println 'buildTypes.debug defaultConfig.versionCode ' + defaultConfig.versionCode
+ }
+ }
+
+ flavorDimensions "base"
+ productFlavors {
+ full {
+ dimension "base"
+ applicationId fullApplicationId
+ resValue "string", "applicationId", fullApplicationId
+ }
+ basic {
+ dimension "base"
+ applicationId basicApplicationId
+ resValue "string", "applicationId", basicApplicationId
+ }
}
compileOptions {
@@ -46,23 +75,6 @@ android {
preDexLibraries = preDexEnabled && !isCi
}
- defaultConfig {
- versionCode 1003001
- versionName getVersionName()
- applicationId 'org.fdroid.fdroid'
- resValue "string", "applicationId", applicationId
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
- }
-
- buildTypes {
- debug {
- applicationIdSuffix ".debug"
- resValue "string", "applicationId", defaultConfig.applicationId + applicationIdSuffix
- versionNameSuffix "-debug"
- println 'buildTypes.debug defaultConfig.versionCode ' + defaultConfig.versionCode
- }
- }
-
testOptions {
unitTests {
includeAndroidResources = true
@@ -125,13 +137,10 @@ dependencies {
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.google.zxing:core:3.3.2'
implementation 'eu.chainfire:libsuperuser:1.0.0.201602271131'
- implementation 'cc.mvdan.accesspoint:library:0.2.0'
implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1'
implementation 'info.guardianproject.panic:panic:0.5'
implementation 'commons-io:commons-io:2.5'
implementation 'commons-net:commons-net:3.5'
- implementation 'org.jmdns:jmdns:3.5.3'
- implementation 'org.nanohttpd:nanohttpd:2.3.1'
implementation 'ch.acra:acra:4.9.1'
implementation 'io.reactivex:rxjava:1.1.0'
implementation 'io.reactivex:rxandroid:0.23.0'
@@ -142,10 +151,14 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.7'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.7'
- implementation 'org.bouncycastle:bcpkix-jdk15on:1.59'
implementation 'org.bouncycastle:bcprov-jdk15on:1.59'
+ fullImplementation 'org.bouncycastle:bcpkix-jdk15on:1.59'
+ fullImplementation 'cc.mvdan.accesspoint:library:0.2.0'
+ fullImplementation 'org.jmdns:jmdns:3.5.3'
+ fullImplementation 'org.nanohttpd:nanohttpd:2.3.1'
testImplementation 'org.robolectric:robolectric:3.8'
+ testImplementation 'org.bouncycastle:bcprov-jdk15on:1.59'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.7.22'
@@ -154,6 +167,12 @@ dependencies {
androidTestImplementation 'com.android.support.test:rules:0.5'
}
+tasks.whenTaskAdded { task ->
+ if (task.name.startsWith("lintBasic")) {
+ android.lintOptions.abortOnError = false
+ }
+}
+
checkstyle {
toolVersion = '7.2'
}
diff --git a/app/lint.xml b/app/lint.xml
index a2eed735d..277c6dcb1 100644
--- a/app/lint.xml
+++ b/app/lint.xml
@@ -36,7 +36,7 @@
+ * Note: It is tricky to attach a {@link Fragment} to a view from this view holder. This is due + * to the way in which the {@link RecyclerView} will reuse existing views and ask us to + * put a settings fragment in there at arbitrary times. Usually it wont be the same view we + * attached the fragment to last time, which causes weirdness. The solution is to use code from + * the com.lsjwzh.widget.recyclerviewpager.FragmentStatePagerAdapter which manages this. + * The code has been ported to {@link SettingsView}. + * + * @see SettingsView + */ + public void bindSettingsView() { + activity.getLayoutInflater().inflate(R.layout.main_tab_settings, frame, true); + } +} diff --git a/app/src/basic/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java b/app/src/basic/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java new file mode 100644 index 000000000..4e86467a5 --- /dev/null +++ b/app/src/basic/java/org/fdroid/fdroid/views/swap/SwapWorkflowActivity.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Senecto Limited + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.fdroid.fdroid.views.swap; + +/** + * Dummy version for basic app flavor. + */ +public class SwapWorkflowActivity { + public static final String EXTRA_PREVENT_FURTHER_SWAP_REQUESTS = "preventFurtherSwap"; + public static final String EXTRA_CONFIRM = "EXTRA_CONFIRM"; +} diff --git a/app/src/basic/res/menu/main_activity_screens.xml b/app/src/basic/res/menu/main_activity_screens.xml new file mode 100644 index 000000000..4785bd5c0 --- /dev/null +++ b/app/src/basic/res/menu/main_activity_screens.xml @@ -0,0 +1,14 @@ + +
\ No newline at end of file diff --git a/app/src/basic/res/xml/preferences.xml b/app/src/basic/res/xml/preferences.xml new file mode 100644 index 000000000..c1e62f5ca --- /dev/null +++ b/app/src/basic/res/xml/preferences.xml @@ -0,0 +1,166 @@ + +
+ * All defaults should be set in {@code res/xml/preferences.xml}. The one
+ * exception is {@link Preferences#PREF_LOCAL_REPO_NAME} since it needs to be
+ * generated per install. The preferences are only written out explicitly when
+ * the user changes the preferences. So the default values need to be reloaded
+ * every time F-Droid starts. The various {@link SharedPreferences} getters are
+ * using {@code false} and {@code -1} as fallback default values to help catch
+ * problems with the proper default loading as quickly as possible.
*/
public final class Preferences implements SharedPreferences.OnSharedPreferenceChangeListener {
@@ -34,6 +64,7 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
private final SharedPreferences preferences;
private Preferences(Context context) {
+ PreferenceManager.setDefaultValues(context, R.xml.preferences, true);
preferences = PreferenceManager.getDefaultSharedPreferences(context);
preferences.registerOnSharedPreferenceChangeListener(this);
if (preferences.getString(PREF_LOCAL_REPO_NAME, null) == null) {
@@ -79,31 +110,22 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
public static final int OVER_NETWORK_ON_DEMAND = 1;
public static final int OVER_NETWORK_ALWAYS = 2;
- private static final boolean DEFAULT_SHOW_INCOMPAT_VERSIONS = false;
- private static final boolean DEFAULT_SHOW_ROOT_APPS = true;
- private static final boolean DEFAULT_SHOW_ANTI_FEATURE_APPS = true;
- public static final int DEFAULT_OVER_WIFI = OVER_NETWORK_ALWAYS;
- public static final int DEFAULT_OVER_DATA = OVER_NETWORK_ON_DEMAND;
- public static final int DEFAULT_UPDATE_INTERVAL = 3;
- private static final boolean DEFAULT_PRIVILEGED_INSTALLER = true;
- //private static final boolean DEFAULT_LOCAL_REPO_BONJOUR = true;
- private static final long DEFAULT_KEEP_CACHE_TIME = TimeUnit.DAYS.toMillis(1);
- private static final boolean DEFAULT_UNSTABLE_UPDATES = false;
- private static final boolean DEFAULT_KEEP_INSTALL_HISTORY = false;
- //private static final boolean DEFAULT_LOCAL_REPO_HTTPS = false;
- private static final boolean DEFAULT_EXPERT = false;
- private static final boolean DEFAULT_ENABLE_PROXY = false;
- public static final String DEFAULT_THEME = "light";
+ // these preferences are not listed in preferences.xml so the defaults are set here
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
- public static final String DEFAULT_PROXY_HOST = "127.0.0.1";
- public static final int DEFAULT_PROXY_PORT = 8118;
+ public static final String DEFAULT_PROXY_HOST = "127.0.0.1"; // TODO move to preferences.xml
+ public static final int DEFAULT_PROXY_PORT = 8118; // TODO move to preferences.xml
private static final boolean DEFAULT_SHOW_NFC_DURING_SWAP = true;
- private static final boolean DEFAULT_FORCE_OLD_INDEX = false;
private static final boolean DEFAULT_POST_PRIVILEGED_INSTALL = false;
- private static final boolean DEFAULT_PREVENT_SCREENSHOTS = false;
private static final boolean DEFAULT_PANIC_EXIT = true;
- private static final boolean DEFAULT_HIDE_ON_LONG_PRESS_SEARCH = false;
+ private static final boolean IGNORED_B = false;
+ private static final int IGNORED_I = -1;
+
+ /**
+ * Old preference replaced by {@link #PREF_KEEP_CACHE_TIME}
+ */
+ @Deprecated
+ private static final String OLD_PREF_CACHE_APK = "cacheDownloaded";
@Deprecated
private static final String OLD_PREF_UPDATE_INTERVAL = "updateInterval";
@Deprecated
@@ -126,8 +148,8 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
DateUtils.HOUR_IN_MILLIS,
};
- private boolean showAppsRequiringRoot = DEFAULT_SHOW_ROOT_APPS;
- private boolean showAppsWithAntiFeatures = DEFAULT_SHOW_ANTI_FEATURE_APPS;
+ private boolean showAppsRequiringRoot;
+ private boolean showAppsWithAntiFeatures;
private final Map
+ * It doesn't need to do very much other than redirect requests from the {@link MainActivity}s
+ * {@link RecyclerView} to the relevant "bind*()" method
+ * of the {@link MainViewController}.
+ *
+ * {@link PopupMenu} is used as a hack to get a disposable {@link Menu} instance
+ * for parsing and reading the menu XML.
*/
class MainViewAdapter extends RecyclerView.Adapter