Avoid constant condition by changing full_version declaration

This commit is contained in:
anthony restaino 2017-05-09 23:40:22 -04:00
parent 5ca24e7d11
commit 50b0ad2512
5 changed files with 9 additions and 8 deletions

View File

@ -33,13 +33,13 @@ android {
productFlavors {
lightningPlus {
buildConfigField "boolean", "FULL_VERSION", "true"
buildConfigField "boolean", "FULL_VERSION", "Boolean.parseBoolean(\"true\")"
applicationId "acr.browser.lightning"
versionCode 91
}
lightningLite {
buildConfigField "boolean", "FULL_VERSION", "false"
buildConfigField "boolean", "FULL_VERSION", "Boolean.parseBoolean(\"false\")"
applicationId "acr.browser.barebones"
versionCode 93
}

View File

@ -12,6 +12,7 @@ import com.anthonycr.bonsai.Schedulers;
import javax.inject.Inject;
import acr.browser.lightning.BuildConfig;
import acr.browser.lightning.R;
import acr.browser.lightning.activity.TabsManager;
import acr.browser.lightning.app.BrowserApp;
@ -317,7 +318,7 @@ public class BrowserPresenter {
*/
public synchronized boolean newTab(@Nullable String url, boolean show) {
// Limit number of tabs for limited version of app
if (!Constants.FULL_VERSION && mTabsModel.size() >= 10) {
if (!BuildConfig.FULL_VERSION && mTabsModel.size() >= 10) {
mView.showSnackbar(R.string.max_tabs);
return false;
}

View File

@ -15,8 +15,6 @@ public final class Constants {
private Constants() {
}
public static final boolean FULL_VERSION = BuildConfig.FULL_VERSION;
// Hardcoded user agents
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36";
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.4; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";

View File

@ -22,6 +22,7 @@ import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import acr.browser.lightning.BuildConfig;
import acr.browser.lightning.R;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.dialog.BrowserDialog;
@ -151,13 +152,13 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
boolean imagesBool = mPreferenceManager.getBlockImagesEnabled();
boolean enableJSBool = mPreferenceManager.getJavaScriptEnabled();
cbAds.setEnabled(Constants.FULL_VERSION);
cbAds.setEnabled(BuildConfig.FULL_VERSION);
cbFlash.setEnabled(API < Build.VERSION_CODES.KITKAT);
cbImages.setChecked(imagesBool);
cbJsScript.setChecked(enableJSBool);
cbFlash.setChecked(flashNum > 0);
cbAds.setChecked(Constants.FULL_VERSION && mPreferenceManager.getAdBlockEnabled());
cbAds.setChecked(BuildConfig.FULL_VERSION && mPreferenceManager.getAdBlockEnabled());
cbColorMode.setChecked(mPreferenceManager.getColorModeEnabled());
}

View File

@ -22,6 +22,7 @@ import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import acr.browser.lightning.BuildConfig;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager;
@ -48,7 +49,7 @@ public class AdBlock {
AdBlock(@NonNull Application application, @NonNull PreferenceManager preferenceManager) {
mApplication = application;
mPreferenceManager = preferenceManager;
if (mBlockedDomainsList.isEmpty() && Constants.FULL_VERSION) {
if (mBlockedDomainsList.isEmpty() && BuildConfig.FULL_VERSION) {
loadHostsFile().subscribeOn(Schedulers.io()).subscribe();
}
mBlockAds = mPreferenceManager.getAdBlockEnabled();