Browse Source

Avoid constant condition by changing full_version declaration

master
anthony restaino 8 years ago
parent
commit
50b0ad2512
  1. 4
      app/build.gradle
  2. 3
      app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java
  3. 2
      app/src/main/java/acr/browser/lightning/constant/Constants.java
  4. 5
      app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java
  5. 3
      app/src/main/java/acr/browser/lightning/utils/AdBlock.java

4
app/build.gradle

@ -33,13 +33,13 @@ android { @@ -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
}

3
app/src/main/java/acr/browser/lightning/browser/BrowserPresenter.java

@ -12,6 +12,7 @@ import com.anthonycr.bonsai.Schedulers; @@ -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 { @@ -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;
}

2
app/src/main/java/acr/browser/lightning/constant/Constants.java

@ -15,8 +15,6 @@ public final class Constants { @@ -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";

5
app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java

@ -22,6 +22,7 @@ import android.view.ViewGroup; @@ -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 @@ -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());
}

3
app/src/main/java/acr/browser/lightning/utils/AdBlock.java

@ -22,6 +22,7 @@ import java.util.Set; @@ -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 { @@ -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();

Loading…
Cancel
Save