summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--org.fox.epube/build.gradle5
-rw-r--r--org.fox.epube/src/main/java/org/fox/epube/MainActivity.java10
-rw-r--r--org.fox.epube/src/main/java/org/fox/epube/NetworkStateReceiver.java234
3 files changed, 121 insertions, 128 deletions
diff --git a/org.fox.epube/build.gradle b/org.fox.epube/build.gradle
index bd630c0..3bd4a70 100644
--- a/org.fox.epube/build.gradle
+++ b/org.fox.epube/build.gradle
@@ -7,8 +7,8 @@ android {
         applicationId "org.fox.epube"

         minSdkVersion 23

         targetSdkVersion 29

-        versionCode 5

-        versionName "1.4"

+        versionCode 6

+        versionName "1.5"

         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

     }

 

@@ -46,7 +46,6 @@ dependencies {
     testImplementation 'junit:junit:4.12'

     androidTestImplementation 'androidx.test.ext:junit:1.1.1'

     androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

-    implementation 'androidx.webkit:webkit:1.3.0'

     implementation 'frankiesardo:icepick:3.2.0'

     compileOnly 'frankiesardo:icepick-processor:3.2.0'

     annotationProcessor 'frankiesardo:icepick-processor:3.2.0'

diff --git a/org.fox.epube/src/main/java/org/fox/epube/MainActivity.java b/org.fox.epube/src/main/java/org/fox/epube/MainActivity.java
index dfd7086..05c9c92 100644
--- a/org.fox.epube/src/main/java/org/fox/epube/MainActivity.java
+++ b/org.fox.epube/src/main/java/org/fox/epube/MainActivity.java
@@ -71,14 +71,8 @@ public class MainActivity extends AppCompatActivity implements NetworkStateRecei
         settings.setAppCachePath(getCacheDir().getAbsolutePath());

         settings.setAppCacheEnabled(true);

 

-        if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {

-            WebSettingsCompat.setForceDark(m_web.getSettings(),

-                    isNightMode() ? WebSettingsCompat.FORCE_DARK_ON : WebSettingsCompat.FORCE_DARK_OFF);

-        }

-

-        if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {

-            WebSettingsCompat.setForceDarkStrategy(m_web.getSettings(),

-                    WebSettingsCompat.DARK_STRATEGY_USER_AGENT_DARKENING_ONLY);

+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {

+            settings.setForceDark(WebSettings.FORCE_DARK_OFF);

         }

 

         m_loadingBar = findViewById(R.id.loading_progress);

diff --git a/org.fox.epube/src/main/java/org/fox/epube/NetworkStateReceiver.java b/org.fox.epube/src/main/java/org/fox/epube/NetworkStateReceiver.java
index 4afb7d9..2987525 100644
--- a/org.fox.epube/src/main/java/org/fox/epube/NetworkStateReceiver.java
+++ b/org.fox.epube/src/main/java/org/fox/epube/NetworkStateReceiver.java
@@ -1,118 +1,118 @@
-package org.fox.epube;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * NetworkStateReceiver defines a BroadcastReceiver which allows us to register for system (i.e. network status) or application events.
- * All registered receivers for an event are notified by the Android runtime once this event happens.
- * Source: http://stackoverflow.com/questions/6169059/android-event-for-internet-connectivity-state-change
- */
-public class NetworkStateReceiver extends BroadcastReceiver {
-
-    protected List<NetworkStateReceiverListener> listeners;
-    protected Boolean connected;
-    private String TAG = "NetworkStateReceiver";
-
-    public NetworkStateReceiver() {
-        listeners = new ArrayList<>();
-        connected = null;
-    }
-
-    /**
-     * Called when the BroadcastReceiver is receiving an Intent broadcast (event for which the broadcast receiver has registered occurs).
-     * During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.
-     * NOTE: When it runs on the main thread you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed).
-     * NOTE: You cannot launch a popup dialog in your implementation of onReceive().
-     * @param context   Object to access additional information or to start services or activities
-     * @param intent    Object with action used to register your receiver. This object contains additional information (e.g. extras)
-     */
-    public void onReceive(Context context, Intent intent) {
-        Log.i(TAG, "Intent broadcast received");
-        if(intent == null || intent.getExtras() == null)
-            return;
-
-        // Retrieve a ConnectivityManager for handling management of network connections
-        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-        // Details about the currently active default data network. When connected, this network is the default route for outgoing connections
-        NetworkInfo networkInfo = manager.getActiveNetworkInfo();
-
-        /**
-         * NOTE: getActiveNetworkInfo() may return null when there is no default network e.g. Airplane Mode
-         */
-        if(networkInfo != null && networkInfo.getState() == NetworkInfo.State.CONNECTED) {
-            connected = true;
-        } else if(intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, Boolean.FALSE)) {    //Boolean that indicates whether there is a complete lack of connectivity
-            connected = false;
-        }
-
-        notifyStateToAll();
-    }   //After the onReceive() of the receiver class has finished, the Android system is allowed to recycle the receiver
-
-    /**
-     * Notify the state to all needed methods
-     */
-    private void notifyStateToAll() {
-        Log.i(TAG, "Notifying state to " + listeners.size() + " listener(s)");
-        for(NetworkStateReceiverListener eachNetworkStateReceiverListener : listeners)
-            notifyState(eachNetworkStateReceiverListener);
-    }
-
-    /**
-     * Notify the network state, triggering interface functions based on the current state
-     * @param networkStateReceiverListener  Object which implements the NetworkStateReceiverListener interface
-     */
-    private void notifyState(NetworkStateReceiverListener networkStateReceiverListener) {
-        if(connected == null || networkStateReceiverListener == null)
-            return;
-
-        if(connected == true) {
-            // Triggering function on the interface towards network availability
-            networkStateReceiverListener.networkAvailable();
-        } else {
-            // Triggering function on the interface towards network being unavailable
-            networkStateReceiverListener.networkUnavailable();
-        }
-    }
-
-    /**
-     * Adds a listener to the list so that it will receive connection state change updates
-     * @param networkStateReceiverListener     Object which implements the NetworkStateReceiverListener interface
-     */
-    public void addListener(NetworkStateReceiverListener networkStateReceiverListener) {
-        Log.i(TAG, "addListener() - listeners.add(networkStateReceiverListener) + notifyState(networkStateReceiverListener);");
-        listeners.add(networkStateReceiverListener);
-        notifyState(networkStateReceiverListener);
-    }
-
-    /**
-     * Removes listener (when no longer necessary) from the list so that it will no longer receive connection state change updates
-     * @param networkStateReceiverListener     Object which implements the NetworkStateReceiverListener interface
-     */
-    public void removeListener(NetworkStateReceiverListener networkStateReceiverListener) {
-        listeners.remove(networkStateReceiverListener);
-    }
-
-    /**
-     * Inner Interface (i.e. to encapsulate behavior in a generic and re-usable way) which handles connection state changes for classes which registered this receiver (Outer class NetworkStateReceiver)
-     * This interface implements the 'Strategy Pattern', where an execution strategy is evaluated and applied internally at runtime
-     */
-    public interface NetworkStateReceiverListener {
-        /**
-         * When the connection state is changed and there is a connection, this method is called
-         */
-        void networkAvailable();
-
-        /**
-         * Connection state is changed and there is not a connection, this method is called
-         */
-        void networkUnavailable();
-    }
+package org.fox.epube;

+

+import android.content.BroadcastReceiver;

+import android.content.Context;

+import android.content.Intent;

+import android.net.ConnectivityManager;

+import android.net.NetworkInfo;

+import android.util.Log;

+

+import java.util.ArrayList;

+import java.util.List;

+

+/**

+ * NetworkStateReceiver defines a BroadcastReceiver which allows us to register for system (i.e. network status) or application events.

+ * All registered receivers for an event are notified by the Android runtime once this event happens.

+ * Source: http://stackoverflow.com/questions/6169059/android-event-for-internet-connectivity-state-change

+ */

+public class NetworkStateReceiver extends BroadcastReceiver {

+

+    protected List<NetworkStateReceiverListener> listeners;

+    protected Boolean connected;

+    private String TAG = "NetworkStateReceiver";

+

+    public NetworkStateReceiver() {

+        listeners = new ArrayList<>();

+        connected = null;

+    }

+

+    /**

+     * Called when the BroadcastReceiver is receiving an Intent broadcast (event for which the broadcast receiver has registered occurs).

+     * During this time you can use the other methods on BroadcastReceiver to view/modify the current result values.

+     * NOTE: When it runs on the main thread you should never perform long-running operations in it (there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed).

+     * NOTE: You cannot launch a popup dialog in your implementation of onReceive().

+     * @param context   Object to access additional information or to start services or activities

+     * @param intent    Object with action used to register your receiver. This object contains additional information (e.g. extras)

+     */

+    public void onReceive(Context context, Intent intent) {

+        Log.i(TAG, "Intent broadcast received");

+        if(intent == null || intent.getExtras() == null)

+            return;

+

+        // Retrieve a ConnectivityManager for handling management of network connections

+        ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

+        // Details about the currently active default data network. When connected, this network is the default route for outgoing connections

+        NetworkInfo networkInfo = manager.getActiveNetworkInfo();

+

+        /**

+         * NOTE: getActiveNetworkInfo() may return null when there is no default network e.g. Airplane Mode

+         */

+        if(networkInfo != null && networkInfo.getState() == NetworkInfo.State.CONNECTED) {

+            connected = true;

+        } else if(intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, Boolean.FALSE)) {    //Boolean that indicates whether there is a complete lack of connectivity

+            connected = false;

+        }

+

+        notifyStateToAll();

+    }   //After the onReceive() of the receiver class has finished, the Android system is allowed to recycle the receiver

+

+    /**

+     * Notify the state to all needed methods

+     */

+    private void notifyStateToAll() {

+        Log.i(TAG, "Notifying state to " + listeners.size() + " listener(s)");

+        for(NetworkStateReceiverListener eachNetworkStateReceiverListener : listeners)

+            notifyState(eachNetworkStateReceiverListener);

+    }

+

+    /**

+     * Notify the network state, triggering interface functions based on the current state

+     * @param networkStateReceiverListener  Object which implements the NetworkStateReceiverListener interface

+     */

+    private void notifyState(NetworkStateReceiverListener networkStateReceiverListener) {

+        if(connected == null || networkStateReceiverListener == null)

+            return;

+

+        if(connected == true) {

+            // Triggering function on the interface towards network availability

+            networkStateReceiverListener.networkAvailable();

+        } else {

+            // Triggering function on the interface towards network being unavailable

+            networkStateReceiverListener.networkUnavailable();

+        }

+    }

+

+    /**

+     * Adds a listener to the list so that it will receive connection state change updates

+     * @param networkStateReceiverListener     Object which implements the NetworkStateReceiverListener interface

+     */

+    public void addListener(NetworkStateReceiverListener networkStateReceiverListener) {

+        Log.i(TAG, "addListener() - listeners.add(networkStateReceiverListener) + notifyState(networkStateReceiverListener);");

+        listeners.add(networkStateReceiverListener);

+        notifyState(networkStateReceiverListener);

+    }

+

+    /**

+     * Removes listener (when no longer necessary) from the list so that it will no longer receive connection state change updates

+     * @param networkStateReceiverListener     Object which implements the NetworkStateReceiverListener interface

+     */

+    public void removeListener(NetworkStateReceiverListener networkStateReceiverListener) {

+        listeners.remove(networkStateReceiverListener);

+    }

+

+    /**

+     * Inner Interface (i.e. to encapsulate behavior in a generic and re-usable way) which handles connection state changes for classes which registered this receiver (Outer class NetworkStateReceiver)

+     * This interface implements the 'Strategy Pattern', where an execution strategy is evaluated and applied internally at runtime

+     */

+    public interface NetworkStateReceiverListener {

+        /**

+         * When the connection state is changed and there is a connection, this method is called

+         */

+        void networkAvailable();

+

+        /**

+         * Connection state is changed and there is not a connection, this method is called

+         */

+        void networkUnavailable();

+    }

 }
\ No newline at end of file