]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Create standard and free flavors. Add AdMob advertisements to the free flavor.
authorSoren Stoutner <soren@stoutner.com>
Tue, 23 Feb 2016 05:10:01 +0000 (22:10 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 23 Feb 2016 05:10:01 +0000 (22:10 -0700)
.idea/dictionaries/soren.xml
app/app.iml
app/build.gradle
app/src/free/res/layout/ad_view.xml [new file with mode: 0644]
app/src/free/res/values/strings.xml [new file with mode: 0644]
app/src/main/AndroidManifest.xml
app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
app/src/main/java/com/stoutner/privacybrowser/SettingsActivity.java
app/src/main/res/layout/activity_webview.xml
app/src/main/res/values/strings.xml
app/src/standard/res/layout/ad_view.xml [new file with mode: 0644]

index db1251c78a21a42106df1f81bc153f7d6d081d22..75d1eb6496ae9299447d576774c9abf3714353f4 100644 (file)
@@ -3,6 +3,7 @@
     <words>
       <w>duckduckgo</w>
       <w>privacybrowser</w>
     <words>
       <w>duckduckgo</w>
       <w>privacybrowser</w>
+      <w>recents</w>
       <w>rehide</w>
       <w>rehides</w>
       <w>soren</w>
       <w>rehide</w>
       <w>rehides</w>
       <w>soren</w>
index 41cbfa77da6e42f35f77ed30285f8161595b18de..3fa1af5aaa9dcdef977c1aa2db79c117f1c2467f 100644 (file)
@@ -8,48 +8,60 @@
     </facet>
     <facet type="android" name="Android">
       <configuration>
     </facet>
     <facet type="android" name="Android">
       <configuration>
-        <option name="SELECTED_BUILD_VARIANT" value="debug" />
+        <option name="SELECTED_BUILD_VARIANT" value="freeRelease" />
         <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
         <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
-        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
-        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
-        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
-        <option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
+        <option name="ASSEMBLE_TASK_NAME" value="assembleFreeRelease" />
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileFreeReleaseSources" />
         <afterSyncTasks>
         <afterSyncTasks>
-          <task>generateDebugAndroidTestSources</task>
-          <task>generateDebugSources</task>
+          <task>generateFreeReleaseSources</task>
         </afterSyncTasks>
         <option name="ALLOW_USER_CONFIGURATION" value="false" />
         <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
         <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
         </afterSyncTasks>
         <option name="ALLOW_USER_CONFIGURATION" value="false" />
         <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
         <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
-        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/free/res" />
         <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
       </configuration>
     </facet>
   </component>
   <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
         <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
       </configuration>
     </facet>
   </component>
   <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
-    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
-    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/free/release" />
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/free/debug" />
     <exclude-output />
     <content url="file://$MODULE_DIR$">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/free/release" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/free/release" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/free/release" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/free/release" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/free/release" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/free/release" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/freeRelease/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/free/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/jni" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestFree/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/release/rs" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
@@ -74,6 +86,8 @@
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/8.4.0/jars" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/jars" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
     <orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
+    <orderEntry type="library" exported="" name="play-services-basement-8.4.0" level="project" />
     <orderEntry type="library" exported="" name="design-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="design-23.1.1" level="project" />
     <orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
+    <orderEntry type="library" exported="" name="play-services-ads-8.4.0" level="project" />
   </component>
 </module>
\ No newline at end of file
   </component>
 </module>
\ No newline at end of file
index f741400ba6a7ef18876bcd319141f5fea6db7fdb..9cb5c59c962f4ce78cd755f2c59f6eab2deed02f 100644 (file)
@@ -1,9 +1,29 @@
+/**
+ * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser.
+ *
+ * Privacy Browser 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.
+ *
+ * Privacy Browser 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 Privacy Browser.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 apply plugin: 'com.android.application'
 
 android {
 apply plugin: 'com.android.application'
 
 android {
+    signingConfigs {
+    }
     compileSdkVersion 23
     buildToolsVersion "23.0.2"
     compileSdkVersion 23
     buildToolsVersion "23.0.2"
-
     defaultConfig {
         applicationId "com.stoutner.privacybrowser"
         minSdkVersion 10
     defaultConfig {
         applicationId "com.stoutner.privacybrowser"
         minSdkVersion 10
@@ -11,13 +31,23 @@ android {
         versionCode 1
         versionName "1.0"
     }
         versionCode 1
         versionName "1.0"
     }
-
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
+    productFlavors {
+        standard {
+            applicationId "com.stoutner.privacybrowser.standard"
+            versionName "1.0-standard"
+        }
+
+        free {
+            applicationId "com.stoutner.privacybrowser.free"
+            versionName "1.0-free"
+        }
+    }
 }
 
 dependencies {
 }
 
 dependencies {
@@ -25,4 +55,5 @@ dependencies {
     compile 'com.android.support:appcompat-v7:23.1.1'
     compile 'com.android.support:design:23.1.1'
     compile 'com.android.support:support-v4:23.1.1'
     compile 'com.android.support:appcompat-v7:23.1.1'
     compile 'com.android.support:design:23.1.1'
     compile 'com.android.support:support-v4:23.1.1'
+    compile 'com.google.android.gms:play-services-ads:8.4.0'
 }
 }
diff --git a/app/src/free/res/layout/ad_view.xml b/app/src/free/res/layout/ad_view.xml
new file mode 100644 (file)
index 0000000..13adbae
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
+
+  Privacy Browser 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.
+
+  Privacy Browser 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 Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<!-- android:layout_martinTop="?attr/actionBarSize" moves adRelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView. -->
+<RelativeLayout
+    android:id="@+id/adRelativeLayout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    xmlns:ads="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_marginTop="?attr/actionBarSize"
+    tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
+    tools:showIn="@layout/activity_webview">
+
+    <!-- Set to visibility="gone" in the standard flavor. -->
+    <com.google.android.gms.ads.AdView
+        android:id="@+id/adView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_alignParentBottom="true"
+        ads:adSize="BANNER"
+        ads:adUnitId="@string/ad_id">
+    </com.google.android.gms.ads.AdView>
+
+    <android.support.v4.widget.SwipeRefreshLayout
+        android:id="@+id/swipeRefreshLayout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_above="@id/adView">
+
+        <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar.  https://code.google.com/p/android/issues/detail?id=200394 -->
+        <WebView
+            android:id="@+id/mainWebView"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:focusable="true"
+            android:focusableInTouchMode="true"/>
+    </android.support.v4.widget.SwipeRefreshLayout>
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/free/res/values/strings.xml b/app/src/free/res/values/strings.xml
new file mode 100644 (file)
index 0000000..db5ac09
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
+
+  Privacy Browser 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.
+
+  Privacy Browser 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 Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<resources>
+    <!-- Activities. -->
+    <string name="privacy_browser">Privacy Browser Free</string>
+
+    <!-- Ad control strings. -->
+    <string name="free_flavor">true</string>
+    <string name="ad_id">ca-app-pub-5962503714887045/2738552414</string>
+</resources>
\ No newline at end of file
index febfeaf636afaf302b900819a2ca3959159eefd9..773f0a88a1c8ad151d6f63c790d66b0082735dc5 100644 (file)
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.stoutner.privacybrowser" >
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.stoutner.privacybrowser" >
 
+    <!-- Required to load websites. -->
     <uses-permission android:name="android.permission.INTERNET" />
 
     <!-- Required to create homescreen shortcuts. -->
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
 
     <uses-permission android:name="android.permission.INTERNET" />
 
     <!-- Required to create homescreen shortcuts. -->
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
 
+    <!-- Required to upload files to websites. -->
+    <!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> -->
+
     <!-- on API >= 23, app data is automatically backed up to Google cloud servers unless android:allowBackup="false" and android:fullBackupContent="false" is set. -->
     <application
     <!-- on API >= 23, app data is automatically backed up to Google cloud servers unless android:allowBackup="false" and android:fullBackupContent="false" is set. -->
     <application
-        android:allowBackup="false"
-        android:fullBackupContent="false"
-        android:icon="@mipmap/ic_launcher"
         android:label="@string/privacy_browser"
         android:label="@string/privacy_browser"
-        android:theme="@style/AppTheme" >
+        android:icon="@mipmap/ic_launcher"
+        android:theme="@style/AppTheme"
+        android:allowBackup="false"
+        android:fullBackupContent="false" >
 
         <!-- android:configChanges="orientation|screenSize" makes the app not reload when the orientation changes, which preserves scroll location in the WebView. -->
         <!-- android:launchMode="singleTask" makes the app launch in a new task instead of inside the task of the program that sends it an intent.
             It also makes it reuse an existing Privacy Browser activity if available instead of launching a new one. -->
 
         <!-- android:configChanges="orientation|screenSize" makes the app not reload when the orientation changes, which preserves scroll location in the WebView. -->
         <!-- android:launchMode="singleTask" makes the app launch in a new task instead of inside the task of the program that sends it an intent.
             It also makes it reuse an existing Privacy Browser activity if available instead of launching a new one. -->
+        <!-- android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".MainWebViewActivity"
         <activity
             android:name=".MainWebViewActivity"
-            android:configChanges="orientation|screenSize"
             android:label="@string/privacy_browser"
             android:label="@string/privacy_browser"
+            android:theme="@style/AppTheme.NoActionBar"
+            android:configChanges="orientation|screenSize"
             android:launchMode="singleTask"
             android:launchMode="singleTask"
-            android:theme="@style/AppTheme.NoActionBar">
+            android:persistableMode="persistNever" >
 
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
             </intent-filter>
         </activity>
 
             </intent-filter>
         </activity>
 
+        <!-- android:persistableMode="persistNever" removes Privacy Browser from the recents screen on a device reboot. -->
         <activity
             android:name=".SettingsActivity"
             android:label="@string/privacy_browser_settings"
         <activity
             android:name=".SettingsActivity"
             android:label="@string/privacy_browser_settings"
-            android:parentActivityName=".MainWebViewActivity" >
+            android:parentActivityName=".MainWebViewActivity"
+            android:persistableMode="persistNever" >
 
             <!-- android.support.PARENT_ACTIVITY is necessary for API <= 15. -->
             <meta-data
 
             <!-- android.support.PARENT_ACTIVITY is necessary for API <= 15. -->
             <meta-data
index 7f49a6cd9083047d6a09a446d76a16a67c3a4789..757b2c87895b21b935d5c9f4b2e786b3881b01bb 100644 (file)
@@ -53,6 +53,10 @@ import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
 import android.widget.Toast;
 import android.widget.ImageView;
 import android.widget.ProgressBar;
 import android.widget.Toast;
+
+import com.google.android.gms.ads.AdRequest;
+import com.google.android.gms.ads.AdView;
+
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -105,6 +109,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
         // We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
         final ActionBar appBar = getSupportActionBar();
 
         // We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
         final ActionBar appBar = getSupportActionBar();
 
+        // Setup the AdView for the free flavor.
+        final AdView adView = (AdView) findViewById(R.id.adView);
+
         // Implement swipe to refresh
         final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
         swipeToRefresh.setColorSchemeResources(R.color.blue);
         // Implement swipe to refresh
         final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
         swipeToRefresh.setColorSchemeResources(R.color.blue);
@@ -211,11 +218,18 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
                     appBar.hide();
                 }
 
                     appBar.hide();
                 }
 
+                // Show the fullScreenVideoFrameLayout.
                 fullScreenVideoFrameLayout.addView(view);
                 fullScreenVideoFrameLayout.setVisibility(View.VISIBLE);
 
                 fullScreenVideoFrameLayout.addView(view);
                 fullScreenVideoFrameLayout.setVisibility(View.VISIBLE);
 
+                // Hide the mainWebView.
                 mainWebView.setVisibility(View.GONE);
 
                 mainWebView.setVisibility(View.GONE);
 
+                // Hide the add if this is the free flavor.
+                if (getString(R.string.free_flavor).equals("true")) {
+                    adView.setVisibility(View.GONE);
+                }
+
                 /* SYSTEM_UI_FLAG_HIDE_NAVIGATION hides the navigation bars on the bottom or right of the screen.
                 ** SYSTEM_UI_FLAG_FULLSCREEN hides the status bar across the top of the screen.
                 ** SYSTEM_UI_FLAG_IMMERSIVE_STICKY makes the navigation and status bars ghosted overlays and automatically rehides them.
                 /* SYSTEM_UI_FLAG_HIDE_NAVIGATION hides the navigation bars on the bottom or right of the screen.
                 ** SYSTEM_UI_FLAG_FULLSCREEN hides the status bar across the top of the screen.
                 ** SYSTEM_UI_FLAG_IMMERSIVE_STICKY makes the navigation and status bars ghosted overlays and automatically rehides them.
@@ -243,8 +257,15 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
                     appBar.show();
                 }
 
                     appBar.show();
                 }
 
+                // Show the mainWebView.
                 mainWebView.setVisibility(View.VISIBLE);
 
                 mainWebView.setVisibility(View.VISIBLE);
 
+                // Show the adView if this is the free flavor.
+                if (getString(R.string.free_flavor).equals("true")) {
+                    adView.setVisibility(View.VISIBLE);
+                }
+
+                // Hide the fullScreenVideoFrameLayout.
                 fullScreenVideoFrameLayout.removeAllViews();
                 fullScreenVideoFrameLayout.setVisibility(View.GONE);
             }
                 fullScreenVideoFrameLayout.removeAllViews();
                 fullScreenVideoFrameLayout.setVisibility(View.GONE);
             }
@@ -323,6 +344,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
 
         // Load the initial website.
         mainWebView.loadUrl(formattedUrlString);
 
         // Load the initial website.
         mainWebView.loadUrl(formattedUrlString);
+
+        // Load the ad if this is the free flavor.
+        if (getString(R.string.free_flavor).equals("true")) {
+            AdRequest adRequest = new AdRequest.Builder().build();
+            adView.loadAd(adRequest);
+        }
     }
 
     @Override
     }
 
     @Override
@@ -436,7 +463,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
                         }
                     } else {
                         menuItem.setIcon(R.drawable.privacy_mode);
                         }
                     } else {
                         menuItem.setIcon(R.drawable.privacy_mode);
-                        Toast.makeText(getApplicationContext(), "Privacy Mode", Toast.LENGTH_SHORT).show();
+                        Toast.makeText(getApplicationContext(), R.string.privacy_mode, Toast.LENGTH_SHORT).show();
                     }
                 } else {
                     javaScriptEnabled = true;
                     }
                 } else {
                     javaScriptEnabled = true;
@@ -457,7 +484,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
                     // Update the toggleJavaScript icon and display a toast message if appropriate.
                     if (!javaScriptEnabled && !cookiesEnabled) {
                         toggleJavaScript.setIcon(R.drawable.privacy_mode);
                     // Update the toggleJavaScript icon and display a toast message if appropriate.
                     if (!javaScriptEnabled && !cookiesEnabled) {
                         toggleJavaScript.setIcon(R.drawable.privacy_mode);
-                        Toast.makeText(getApplicationContext(), "Privacy Mode", Toast.LENGTH_SHORT).show();
+                        Toast.makeText(getApplicationContext(), R.string.privacy_mode, Toast.LENGTH_SHORT).show();
                     } else {
                         if (cookiesEnabled) {
                             toggleJavaScript.setIcon(R.drawable.warning);
                     } else {
                         if (cookiesEnabled) {
                             toggleJavaScript.setIcon(R.drawable.warning);
@@ -505,7 +532,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
                     // Update the toggleJavaScript icon and display a toast message if appropriate.
                     if (!javaScriptEnabled && !domStorageEnabled) {
                         toggleJavaScript.setIcon(R.drawable.privacy_mode);
                     // Update the toggleJavaScript icon and display a toast message if appropriate.
                     if (!javaScriptEnabled && !domStorageEnabled) {
                         toggleJavaScript.setIcon(R.drawable.privacy_mode);
-                        Toast.makeText(getApplicationContext(), "Privacy Mode", Toast.LENGTH_SHORT).show();
+                        Toast.makeText(getApplicationContext(), R.string.privacy_mode, Toast.LENGTH_SHORT).show();
                     } else {
                         if (domStorageEnabled) {
                             toggleJavaScript.setIcon(R.drawable.warning);
                     } else {
                         if (domStorageEnabled) {
                             toggleJavaScript.setIcon(R.drawable.warning);
index 287237bea587a7ab7f8358778cd94c5712e98e84..0a0357b6580ab6f24465a79c422f8db93e8ee02b 100644 (file)
@@ -21,7 +21,6 @@ package com.stoutner.privacybrowser;
 
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
 
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
-import android.support.v7.widget.Toolbar;
 
 // Once the minimum API is >= 11 we can switch from the deprecated PreferenceActivity to using a PreferenceFragment.
 public class SettingsActivity extends PreferenceActivity {
 
 // Once the minimum API is >= 11 we can switch from the deprecated PreferenceActivity to using a PreferenceFragment.
 public class SettingsActivity extends PreferenceActivity {
index d90adc7c4ceba0b679f350adee7a4b68a2c2fa00..0efd90f684470dd0d7347dc4271b5812e0b7c1af 100644 (file)
             app:popupTheme="@style/AppTheme.PopupOverlay" />
     </android.support.design.widget.AppBarLayout>
 
             app:popupTheme="@style/AppTheme.PopupOverlay" />
     </android.support.design.widget.AppBarLayout>
 
-    <!-- android:layout_martinTop="?attr/actionBarSize" moves the SwipeRefreshLayout below the AppBarLayout, which otherwise would cover the top of the WebView. -->
-    <android.support.v4.widget.SwipeRefreshLayout
-        android:id="@+id/swipeRefreshLayout"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_marginTop="?attr/actionBarSize">
-
-        <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar.  https://code.google.com/p/android/issues/detail?id=200394 -->
-        <WebView
-            android:id="@+id/mainWebView"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:focusable="true"
-            android:focusableInTouchMode="true"/>
-
-    </android.support.v4.widget.SwipeRefreshLayout>
+    <include layout="@layout/ad_view" />
 
     <!-- fullScreenVideoFrameLayout is used to display full screen videos.  It is initially android:visibility="gone" to hide it from view. -->
     <FrameLayout
 
     <!-- fullScreenVideoFrameLayout is used to display full screen videos.  It is initially android:visibility="gone" to hide it from view. -->
     <FrameLayout
index ea122f1e05c7ee9f84dbf8e429247637be696ea6..720731f06e3c5ffafa64671fcb6ed6a66e660f36 100644 (file)
     <string name="privacy_browser">Privacy Browser</string>
     <string name="privacy_browser_settings">Privacy Browser Settings</string>
 
     <string name="privacy_browser">Privacy Browser</string>
     <string name="privacy_browser_settings">Privacy Browser Settings</string>
 
+    <!-- Ad control strings. -->
+    <string name="free_flavor">false</string>
+
+    <!-- MainWebViewActivity. -->
+    <string name="privacy_mode">Privacy Mode</string>
+
     <!-- Custom App Bar. -->
     <string name="favorite_icon">Favorite Icon</string>
 
     <!-- Custom App Bar. -->
     <string name="favorite_icon">Favorite Icon</string>
 
diff --git a/app/src/standard/res/layout/ad_view.xml b/app/src/standard/res/layout/ad_view.xml
new file mode 100644 (file)
index 0000000..e4d6784
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+  Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+  This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
+
+  Privacy Browser 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.
+
+  Privacy Browser 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 Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
+
+<!-- android:layout_martinTop="?attr/actionBarSize" moves adRelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView. -->
+<RelativeLayout
+    android:id="@+id/adRelativeLayout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_marginTop="?attr/actionBarSize"
+    tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
+    tools:showIn="@layout/activity_webview" >
+
+    <!-- Set to visibility="gone" in the standard flavor. -->
+    <com.google.android.gms.ads.AdView
+        android:id="@+id/adView"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerHorizontal="true"
+        android:layout_alignParentBottom="true"
+        android:visibility="gone">
+    </com.google.android.gms.ads.AdView>
+
+    <android.support.v4.widget.SwipeRefreshLayout
+        android:id="@+id/swipeRefreshLayout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_above="@id/adView">
+
+        <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar.  https://code.google.com/p/android/issues/detail?id=200394 -->
+        <WebView
+            android:id="@+id/mainWebView"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:focusable="true"
+            android:focusableInTouchMode="true"/>
+    </android.support.v4.widget.SwipeRefreshLayout>
+</RelativeLayout>
\ No newline at end of file