You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2022/09/09 16:31:46 UTC

[cordova-plugin-splashscreen] branch master updated: feat(android)!: remove platform from plugin (#337)

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-splashscreen.git


The following commit(s) were added to refs/heads/master by this push:
     new 78e8fa0  feat(android)!: remove platform from plugin (#337)
78e8fa0 is described below

commit 78e8fa07ae4db6a3293ab4a648e8c0a22092dda9
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Sat Sep 10 01:31:39 2022 +0900

    feat(android)!: remove platform from plugin (#337)
    
    * feat(android): drop source code
    * feat(android): remove from docs
    * feat(android): remove ci
    * feat(android): remove dependency requirements
    * feat(android): remove from config.xml
    * feat(android): revert removal of android version requirements
    * feat(anroid): do not install on 7.0.0 or above
---
 .github/workflows/android.yml | 137 -------------
 README.md                     | 136 +------------
 package-lock.json             |   3 +
 package.json                  |   5 +-
 plugin.xml                    |  17 --
 src/android/SplashScreen.java | 447 ------------------------------------------
 6 files changed, 8 insertions(+), 737 deletions(-)

diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
deleted file mode 100644
index 1f914ca..0000000
--- a/.github/workflows/android.yml
+++ /dev/null
@@ -1,137 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#  KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-name: Android Testsuite
-
-on:
-  push:
-    paths-ignore:
-      - '**.md'
-      - 'LICENSE'
-      - '.eslint*'
-  pull_request:
-    paths-ignore:
-      - '**.md'
-      - 'LICENSE'
-      - '.eslint*'
-
-jobs:
-  test:
-    name: Android ${{ matrix.versions.android }} Test
-    runs-on: macos-latest
-    continue-on-error: true
-
-    # hoist configurations to top that are expected to be updated
-    env:
-      # Storing a copy of the repo
-      repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
-
-      node-version: 16
-
-      # These are the default Java configurations used by most tests.
-      # To customize these options, add "java-distro" or "java-version" to the strategy matrix with its overriding value.
-      default_java-distro: temurin
-      default_java-version: 11
-
-      # These are the default Android System Image configurations used by most tests.
-      # To customize these options, add "system-image-arch" or "system-image-target" to the strategy matrix with its overriding value.
-      default_system-image-arch: x86_64
-      default_system-image-target: google_apis # Most system images have a google_api option. Set this as default.
-
-    # configurations for each testing strategy (test matrix)
-    strategy:
-      matrix:
-        versions:
-          # Test the lowest minimum supported APIs
-          - android: 5.1
-            android-api: 22
-
-          # Test the last 3-4 supported APIs
-          - android: 10
-            android-api: 29
-
-          - android: 11
-            android-api: 30
-
-          - android: 12
-            android-api: 31
-
-          - android: 12L
-            android-api: 32
-
-    timeout-minutes: 60
-
-    steps:
-      - uses: actions/checkout@v3
-      - uses: actions/setup-node@v3
-        with:
-          node-version: ${{ env.node-version }}
-      - uses: actions/setup-java@v3
-        env:
-          java-version: ${{ matrix.versions.java-version == '' && env.default_java-version || matrix.versions.java-version }}
-          java-distro: ${{ matrix.versions.java-distro == '' && env.default_java-distro || matrix.versions.java-distro }}
-        with:
-          distribution: ${{ env.java-distro }}
-          java-version: ${{ env.java-version }}
-
-      - name: Run Environment Information
-        run: |
-          node --version
-          npm --version
-          java -version
-
-      - name: Run npm install
-        run: |
-          export PATH="/usr/local/lib/android/sdk/platform-tools":$PATH
-          export JAVA_HOME=$JAVA_HOME_11_X64
-          npm i -g cordova@latest
-          npm ci
-
-      - name: Run paramedic install
-        if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
-        run: npm i -g github:apache/cordova-paramedic
-
-      - uses: reactivecircus/android-emulator-runner@5de26e4bd23bf523e8a4b7f077df8bfb8e52b50e
-        env:
-          system-image-arch: ${{ matrix.versions.system-image-arch == '' && env.default_system-image-arch || matrix.versions.system-image-arch }}
-          system-image-target: ${{ matrix.versions.system-image-target == '' && env.default_system-image-target || matrix.versions.system-image-target }}
-        with:
-          api-level: ${{ matrix.versions.android-api }}
-          target: ${{ env.system-image-target }}
-          arch: ${{ env.system-image-arch }}
-          force-avd-creation: false
-          disable-animations: false
-          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
-          script: echo "Pregenerate the AVD before running Paramedic"
-
-      - name: Run paramedic tests
-        uses: reactivecircus/android-emulator-runner@5de26e4bd23bf523e8a4b7f077df8bfb8e52b50e
-        env:
-          system-image-arch: ${{ matrix.versions.system-image-arch == '' && env.default_system-image-arch || matrix.versions.system-image-arch }}
-          system-image-target: ${{ matrix.versions.system-image-target == '' && env.default_system-image-target || matrix.versions.system-image-target }}
-          test_config: 'android-${{ matrix.versions.android }}.config.json'
-          # Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
-          test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
-          paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
-        with:
-          api-level: ${{ matrix.versions.android-api }}
-          target: ${{ env.system-image-target }}
-          arch: ${{ env.system-image-arch }}
-          force-avd-creation: false
-          disable-animations: false
-          emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
-          script: ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}
diff --git a/README.md b/README.md
index 345132e..54d6b10 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ description: Control the splash screen for your app.
 
 # cordova-plugin-splashscreen
 
-[![Android Testsuite](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/chrome.yml) [![Lint Test](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/lin [...]
+[![Chrome Testsuite](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/chrome.yml) [![Lint Test](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-splashscreen/actions/workflows/lint.yml)
 
 This plugin displays and hides a splash screen while your web application is launching. Using its methods you can also show and hide the splash screen manually.
 
@@ -32,17 +32,10 @@ This plugin displays and hides a splash screen while your web application is lau
   - [Supported Platforms](#supported-platforms)
   - [Platform Splash Screen Image Configuration](#platform-splash-screen-image-configuration)
     - [Example Configuration](#example-configuration)
-    - [Android-specific Information](#android-specific-information)
-      - [Image Layout](#image-layout)
-      - [`density`](#density)
-      - [Image Sizing Table](#image-sizing-table)
-      - [Dark Mode (API 28+)](#dark-mode-api-28)
-      - [Example Android Configuration](#example-android-configuration)
     - [Windows-specific Information](#windows-specific-information)
   - [Preferences](#preferences)
     - [config.xml](#configxml)
     - [Quirks](#quirks)
-      - [Android Quirks](#android-quirks)
       - [Browser Quirks](#browser-quirks)
       - [Windows Quirks](#windows-quirks)
   - [Methods](#methods)
@@ -59,12 +52,8 @@ This plugin displays and hides a splash screen while your web application is lau
 
 ## Supported Platforms
 
-- Android
-  __Note__: Android implementation has been moved to the core framework.
-    If using `cordova-android@10.x` or earlier, use `cordova-plugin-splashscreen@6.x`
-    If using `cordova-android@11.x` or later and exclusively developing for Android, this plugin can be uninstalled.
 - Windows (`cordova-windows` version >= 4.4.0 is required)  
-  __Note__: Extended splashscreen does not require the plugin on Windows (as opposed to Android) in case you don't use the plugin API, i.e. programmatic hide/show.
+  __Note__: Extended splashscreen does not require the plugin on Windows in case you don't use the plugin API, i.e. programmatic hide/show.
 - Browser
 
 ## Platform Splash Screen Image Configuration
@@ -88,27 +77,10 @@ projectRoot
         js
     res
         screen
-            android
             windows
 ```
 
 ```xml
-<platform name="android">
-    <splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi" />
-    <splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi" />
-    <splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi" />
-    <splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi" />
-    <splash src="res/screen/android/splash-land-xxhdpi.png" density="land-xxhdpi" />
-    <splash src="res/screen/android/splash-land-xxxhdpi.png" density="land-xxxhdpi" />
-
-    <splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi" />
-    <splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi" />
-    <splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi" />
-    <splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi" />
-    <splash src="res/screen/android/splash-port-xxhdpi.png" density="port-xxhdpi" />
-    <splash src="res/screen/android/splash-port-xxxhdpi.png" density="port-xxxhdpi" /> 
-</platform>
-
 <!-- Configuration using MRT concept (Recommended, see "Windows-specific information" section for details): -->
 <platform name="windows">
     <splash src="res/screen/windows/splashscreen.png" target="SplashScreen"/>
@@ -124,92 +96,6 @@ projectRoot
 <preference name="SplashScreenDelay" value="10000" />
 ```
 
-### Android-specific Information
-
-To effectively create your Android SplashScreen assets, it is important to understand the idiom and sizes used for the assets.
-
-Android defined its assets by the image's layout and `density`.
-
-#### Image Layout
-
-- `land` short for landscape mode
-- `port` short for portrait mode
-
-#### `density`
-
-The image's density refers to the number of pixels per square inch. Android, interchangeably refers to this as DPI.
-
-Not all devices have the same pixel size so it is important to create images for all DPI to ensure that the quality of the image for each device is great.
-
-If not all DPI images are considered, some devices might not show a SplashScreen or will use an incorrect DPI image that can result in a blurry scaled image.
-
-#### Image Sizing Table
-
-|  size   | portrait  | landscape |
-| :-----: | :-------: | :-------: |
-|  ldpi   |  200x320  |  320x200  |
-|  mdpi   |  320x480  |  480x320  |
-|  hdpi   |  480x800  |  800x480  |
-|  xhdpi  | 720x1280  | 1280x720  |
-| xxhdpi  | 960x1600  | 1600x960  |
-| xxxhdpi | 1280x1920 | 1920x1280 |
-
-#### Dark Mode (API 28+)
-
-You can optionally provide an extra SplashScreen image to be used in dark/night mode when enabled on supported devices.
-To do this, add the `-night` keyword in between the **layout** and **size** keywords of the image's `density` attribute value. E.g.: `land-night-hdpi`
-
-For more examples, please see [the Example Configuration](#example-android-configuration) section.
-
-#### Example Android Configuration
-
-```xml
-<platform name="android">
-    <!-- Default 
-    Note: You should specify default resources for each density.
-      -- For instance, if the device(hdpi) is in landscape orientation and [density="land-hdpi"] 
-      -- does not exists, [density="hdpi"] will be selected 
-      If you do not declare this you will get MissingDefaultResource lint check errors.
-      -->
-    <splash src="res/screen/android/splash-port-hdpi.png" density="hdpi"/>
-    <splash src="res/screen/android/splash-port-ldpi.png" density="ldpi"/>
-    <splash src="res/screen/android/splash-port-mdpi.png" density="mdpi"/>
-    <splash src="res/screen/android/splash-port-xhdpi.png" density="xhdpi"/>
-    <splash src="res/screen/android/splash-port-xxhdpi.png" density="xxhdpi"/>
-
-    <!-- Landscape -->
-    <splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi" />
-    <splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi" />
-    <splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi" />
-    <splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi" />
-    <splash src="res/screen/android/splash-land-xxhdpi.png" density="land-xxhdpi" />
-    <splash src="res/screen/android/splash-land-xxxhdpi.png" density="land-xxxhdpi" />
-
-    <!-- Portrait -->
-    <splash src="res/screen/android/splash-port-hdpi.png" density="port-hdpi" />
-    <splash src="res/screen/android/splash-port-ldpi.png" density="port-ldpi" />
-    <splash src="res/screen/android/splash-port-mdpi.png" density="port-mdpi" />
-    <splash src="res/screen/android/splash-port-xhdpi.png" density="port-xhdpi" />
-    <splash src="res/screen/android/splash-port-xxhdpi.png" density="port-xxhdpi" />
-    <splash src="res/screen/android/splash-port-xxxhdpi.png" density="port-xxxhdpi" />
-  
-    <!-- Dark Mode -->
-    <splash src="res/screen/android/splash-land-night-hdpi.png" density="land-night-hdpi" />
-    <splash src="res/screen/android/splash-land-night-ldpi.png" density="land-night-ldpi" />
-    <splash src="res/screen/android/splash-land-night-mdpi.png" density="land-night-mdpi" />
-    <splash src="res/screen/android/splash-land-night-xhdpi.png" density="land-night-xhdpi" />
-    <splash src="res/screen/android/splash-land-night-xxhdpi.png" density="land-night-xxhdpi" />
-    <splash src="res/screen/android/splash-land-night-xxxhdpi.png" density="land-night-xxxhdpi" />
-
-    <splash src="res/screen/android/splash-port-night-hdpi.png" density="port-night-hdpi" />
-    <splash src="res/screen/android/splash-port-night-ldpi.png" density="port-night-ldpi" />
-    <splash src="res/screen/android/splash-port-night-mdpi.png" density="port-night-mdpi" />
-    <splash src="res/screen/android/splash-port-night-xhdpi.png" density="port-night-xhdpi" />
-    <splash src="res/screen/android/splash-port-night-xxhdpi.png" density="port-night-xxhdpi" />
-    <splash src="res/screen/android/splash-port-night-xxxhdpi.png" density="port-night-xxxhdpi" />
-</platform>
-```
-
 ### Windows-specific Information
 
 Splash screen images can be defined using the [MRT](https://cordova.apache.org/docs/en/dev/config_ref/images.html#windows) concept.  
@@ -304,24 +190,6 @@ __Note__: You may need to reopen Visual Studio solution after changing the image
 
 ### Quirks
 
-#### Android Quirks
-
-In your `config.xml`, you can add the following preferences:
-
-```xml
-<preference name="SplashMaintainAspectRatio" value="true|false" />
-<preference name="SplashShowOnlyFirstTime" value="true|false" />
-<preference name="SplashScreenSpinnerColor" value="white" />
-```
-
-`SplashMaintainAspectRatio` preference is optional. If set to `true`, the splash screen drawable is not stretched to fit the full screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios.
-
-The splash screen plugin reloads the splash screen whenever the orientation changes so that you can specify different splash screen images for portrait and landscape orientations.
-
-`SplashShowOnlyFirstTime` preference is  optional and defaults to `true`. When set to `true` the splash screen will only appear on application launch. However, if you plan to use `navigator.app.exitApp()` to close the application and force the splash screen appear on the application's next launch, you should set this property to `false` (this also applies to closing the application with the Back button).
-
-`SplashScreenSpinnerColor` preference is also optional and is ignored when not set. Setting it to a valid color name or HEX color code will change the color of the spinner on Android 5.0+ devices.
-
 #### Browser Quirks
 
 You can use the following preferences in your `config.xml`:
diff --git a/package-lock.json b/package-lock.json
index e9d3410..59c6b2e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,6 +16,9 @@
           "<6.0.0": {
             "cordova-ios": "<6.0.0"
           },
+          "<7.0.0": {
+            "cordova-android": ">=3.6.0 <11.0.0"
+          },
           ">=4.0.0": {
             "cordova-android": ">=3.6.0",
             "cordova-windows": ">=4.4.0"
diff --git a/package.json b/package.json
index bd112b7..c107e2d 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,6 @@
   "cordova": {
     "id": "cordova-plugin-splashscreen",
     "platforms": [
-      "android",
       "windows",
       "browser"
     ]
@@ -17,7 +16,6 @@
     "cordova",
     "splashscreen",
     "ecosystem:cordova",
-    "cordova-android",
     "cordova-windows",
     "cordova-browser"
   ],
@@ -41,6 +39,9 @@
         "cordova-android": ">=3.6.0 <11.0.0",
         "cordova-windows": ">=4.4.0"
       },
+      "<7.0.0": {
+        "cordova-android": ">=3.6.0 <11.0.0"
+      },
       "8.0.0": {
         "cordova": ">100"
       }
diff --git a/plugin.xml b/plugin.xml
index f418056..6dc202d 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -29,26 +29,9 @@
     <issue>https://github.com/apache/cordova-plugin-splashscreen/issues</issue>
 
     <engines>
-        <engine name="cordova-android" version=">=3.6.0 <11.0.0" /><!-- Requires CordovaPlugin.preferences -->
         <engine name="cordova-windows" version=">=4.4.0" />
     </engines>
 
-    <!-- android -->
-    <platform name="android">
-        <config-file target="res/xml/config.xml" parent="/*">
-            <feature name="SplashScreen">
-                <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
-                <param name="onload" value="true"/>
-            </feature>
-        </config-file>
-
-        <source-file src="src/android/SplashScreen.java" target-dir="src/org/apache/cordova/splashscreen" />
-
-        <js-module src="www/splashscreen.js" name="SplashScreen">
-            <clobbers target="navigator.splashscreen" />
-        </js-module>
-    </platform>
-
     <!-- windows -->
     <platform name="windows">
         <js-module src="src/windows/SplashScreenProxy.js" name="SplashScreenProxy">
diff --git a/src/android/SplashScreen.java b/src/android/SplashScreen.java
deleted file mode 100644
index ea9e38d..0000000
--- a/src/android/SplashScreen.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
-       Licensed to the Apache Software Foundation (ASF) under one
-       or more contributor license agreements.  See the NOTICE file
-       distributed with this work for additional information
-       regarding copyright ownership.  The ASF licenses this file
-       to you under the Apache License, Version 2.0 (the
-       "License"); you may not use this file except in compliance
-       with the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing,
-       software distributed under the License is distributed on an
-       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-       KIND, either express or implied.  See the License for the
-       specific language governing permissions and limitations
-       under the License.
-*/
-
-package org.apache.cordova.splashscreen;
-
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.res.Configuration;
-import android.content.res.ColorStateList;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.os.Handler;
-import android.view.Display;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup.LayoutParams;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.DecelerateInterpolator;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.RelativeLayout;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.CordovaWebView;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-public class SplashScreen extends CordovaPlugin {
-    private static final String LOG_TAG = "SplashScreen";
-    // Cordova 3.x.x has a copy of this plugin bundled with it (SplashScreenInternal.java).
-    // Enable functionality only if running on 4.x.x.
-    private static final boolean HAS_BUILT_IN_SPLASH_SCREEN = Integer.valueOf(CordovaWebView.CORDOVA_VERSION.split("\\.")[0]) < 4;
-    private static final int DEFAULT_SPLASHSCREEN_DURATION = 3000;
-    private static final int DEFAULT_FADE_DURATION = 500;
-    private static Dialog splashDialog;
-    private static ProgressDialog spinnerDialog;
-    private static boolean firstShow = true;
-    private static boolean lastHideAfterDelay; // https://issues.apache.org/jira/browse/CB-9094
-
-    /**
-     * Displays the splash drawable.
-     */
-    private ImageView splashImageView;
-
-    /**
-     * Remember last device orientation to detect orientation changes.
-     */
-    private int orientation;
-
-    // Helper to be compile-time compatible with both Cordova 3.x and 4.x.
-    private View getView() {
-        try {
-            return (View)webView.getClass().getMethod("getView").invoke(webView);
-        } catch (Exception e) {
-            return (View)webView;
-        }
-    }
-
-    private int getSplashId() {
-        int drawableId = 0;
-        String splashResource = preferences.getString("SplashScreen", "screen");
-        if (splashResource != null) {
-            drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName());
-            if (drawableId == 0) {
-                drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName());
-            }
-        }
-        return drawableId;
-    }
-
-    @Override
-    protected void pluginInitialize() {
-        if (HAS_BUILT_IN_SPLASH_SCREEN) {
-            return;
-        }
-        // Make WebView invisible while loading URL
-        // CB-11326 Ensure we're calling this on UI thread
-        cordova.getActivity().runOnUiThread(new Runnable() {
-            @Override
-            public void run() {
-                getView().setVisibility(View.INVISIBLE);
-            }
-        });
-        int drawableId = getSplashId();
-
-        // Save initial orientation.
-        orientation = cordova.getActivity().getResources().getConfiguration().orientation;
-
-        if (firstShow) {
-            boolean autoHide = preferences.getBoolean("AutoHideSplashScreen", true);
-            showSplashScreen(autoHide);
-        }
-
-        if (preferences.getBoolean("SplashShowOnlyFirstTime", true)) {
-            firstShow = false;
-        }
-    }
-
-    /**
-     * Shorter way to check value of "SplashMaintainAspectRatio" preference.
-     */
-    private boolean isMaintainAspectRatio () {
-        return preferences.getBoolean("SplashMaintainAspectRatio", false);
-    }
-
-    private int getFadeDuration () {
-        int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ?
-            preferences.getInteger("FadeSplashScreenDuration", DEFAULT_FADE_DURATION) : 0;
-
-        if (fadeSplashScreenDuration < 30) {
-            // [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10
-            // they mean 10 seconds, and not the meaningless 10ms
-            fadeSplashScreenDuration *= 1000;
-        }
-
-        return fadeSplashScreenDuration;
-    }
-
-    @Override
-    public void onPause(boolean multitasking) {
-        if (HAS_BUILT_IN_SPLASH_SCREEN) {
-            return;
-        }
-        // hide the splash screen to avoid leaking a window
-        this.removeSplashScreen(true);
-    }
-
-    @Override
-    public void onDestroy() {
-        if (HAS_BUILT_IN_SPLASH_SCREEN) {
-            return;
-        }
-        // hide the splash screen to avoid leaking a window
-        this.removeSplashScreen(true);
-        // If we set this to true onDestroy, we lose track when we go from page to page!
-        //firstShow = true;
-    }
-
-    @Override
-    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
-        if (action.equals("hide")) {
-            cordova.getActivity().runOnUiThread(new Runnable() {
-                public void run() {
-                    webView.postMessage("splashscreen", "hide");
-                }
-            });
-        } else if (action.equals("show")) {
-            cordova.getActivity().runOnUiThread(new Runnable() {
-                public void run() {
-                    webView.postMessage("splashscreen", "show");
-                }
-            });
-        } else {
-            return false;
-        }
-
-        callbackContext.success();
-        return true;
-    }
-
-    @Override
-    public Object onMessage(String id, Object data) {
-        if (HAS_BUILT_IN_SPLASH_SCREEN) {
-            return null;
-        }
-        if ("splashscreen".equals(id)) {
-            if ("hide".equals(data.toString())) {
-                this.removeSplashScreen(false);
-            } else {
-                this.showSplashScreen(false);
-            }
-        } else if ("spinner".equals(id)) {
-            if ("stop".equals(data.toString())) {
-                getView().setVisibility(View.VISIBLE);
-                getView().requestFocus();
-            }
-        } else if ("onReceivedError".equals(id)) {
-            this.spinnerStop();
-        }
-        return null;
-    }
-
-    // Don't add @Override so that plugin still compiles on 3.x.x for a while
-    public void onConfigurationChanged(Configuration newConfig) {
-        if (newConfig.orientation != orientation) {
-            orientation = newConfig.orientation;
-
-            // Splash drawable may change with orientation, so reload it.
-            if (splashImageView != null) {
-                int drawableId = getSplashId();
-                if (drawableId != 0) {
-                    splashImageView.setImageDrawable(cordova.getActivity().getResources().getDrawable(drawableId));
-                }
-            }
-        }
-    }
-
-    private void removeSplashScreen(final boolean forceHideImmediately) {
-        cordova.getActivity().runOnUiThread(new Runnable() {
-            public void run() {
-        if (splashDialog != null && splashImageView != null && splashDialog.isShowing()) {//check for non-null splashImageView, see https://issues.apache.org/jira/browse/CB-12277
-                    final int fadeSplashScreenDuration = getFadeDuration();
-                    // CB-10692 If the plugin is being paused/destroyed, skip the fading and hide it immediately
-                    if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) {
-                        AlphaAnimation fadeOut = new AlphaAnimation(1, 0);
-                        fadeOut.setInterpolator(new DecelerateInterpolator());
-                        fadeOut.setDuration(fadeSplashScreenDuration);
-
-                        splashImageView.setAnimation(fadeOut);
-                        splashImageView.startAnimation(fadeOut);
-
-                        fadeOut.setAnimationListener(new Animation.AnimationListener() {
-                            @Override
-                            public void onAnimationStart(Animation animation) {
-                                spinnerStop();
-                            }
-
-                            @Override
-                            public void onAnimationEnd(Animation animation) {
-                                if (splashDialog != null && splashImageView != null && splashDialog.isShowing()) {//check for non-null splashImageView, see https://issues.apache.org/jira/browse/CB-12277
-                                    splashDialog.dismiss();
-                                    splashDialog = null;
-                                    splashImageView = null;
-                                }
-                            }
-
-                            @Override
-                            public void onAnimationRepeat(Animation animation) {
-                            }
-                        });
-                    } else {
-                        spinnerStop();
-                        splashDialog.dismiss();
-                        splashDialog = null;
-                        splashImageView = null;
-                    }
-                }
-            }
-        });
-    }
-
-    /**
-     * Shows the splash screen over the full Activity
-     */
-    @SuppressWarnings("deprecation")
-    private void showSplashScreen(final boolean hideAfterDelay) {
-        final int splashscreenTime = preferences.getInteger("SplashScreenDelay", DEFAULT_SPLASHSCREEN_DURATION);
-        final int drawableId = getSplashId();
-
-        final int fadeSplashScreenDuration = getFadeDuration();
-        final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration);
-
-        lastHideAfterDelay = hideAfterDelay;
-
-        // Prevent to show the splash dialog if the activity is in the process of finishing
-        if (cordova.getActivity().isFinishing()) {
-            return;
-        }
-        // If the splash dialog is showing don't try to show it again
-        if (splashDialog != null && splashDialog.isShowing()) {
-            return;
-        }
-        if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) {
-            return;
-        }
-
-        cordova.getActivity().runOnUiThread(new Runnable() {
-            public void run() {
-                // Get reference to display
-                Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
-                Context context = webView.getContext();
-
-                // Use an ImageView to render the image because of its flexible scaling options.
-                splashImageView = new ImageView(context);
-                splashImageView.setImageResource(drawableId);
-                LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-                splashImageView.setLayoutParams(layoutParams);
-
-                splashImageView.setMinimumHeight(display.getHeight());
-                splashImageView.setMinimumWidth(display.getWidth());
-
-                // TODO: Use the background color of the webView's parent instead of using the preference.
-                splashImageView.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
-
-                if (isMaintainAspectRatio()) {
-                    // CENTER_CROP scale mode is equivalent to CSS "background-size:cover"
-                    splashImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
-                }
-                else {
-                    // FIT_XY scales image non-uniformly to fit into image view.
-                    splashImageView.setScaleType(ImageView.ScaleType.FIT_XY);
-                }
-
-                // Create and show the dialog
-                splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
-
-                // Check to see if the splash screen should be full screen.
-                // On first run, currently cordova hasn't set the window flags yet because it does it in
-                //  onWindowFocusChanged instead of onCreate. If that's the case, we'll fall back to the
-                //  Fullscreen preference. Hopefully it will get fixed so that cordova sets them in onCreate,
-                //  so that this fallback can be removed.
-                boolean isFullscreen = false;
-                int mainWindowFlags = cordova.getActivity().getWindow().getAttributes().flags;
-                boolean flagFullscreen = (mainWindowFlags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
-                        == WindowManager.LayoutParams.FLAG_FULLSCREEN;
-                boolean flagForceNotFullscreen = (mainWindowFlags & WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
-                        == WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN;
-
-                // If cordova has set flags, one of these must be true.
-                if (flagFullscreen || flagForceNotFullscreen) {
-                    isFullscreen = flagFullscreen;
-                } else {
-                    // Cordova hasn't set flags, fall back to reading preference.
-                    isFullscreen = preferences.getBoolean("Fullscreen", false);
-                }
-
-                Window dialogWindow = splashDialog.getWindow();
-                if (isFullscreen) {
-                    dialogWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
-                }
-                splashDialog.setContentView(splashImageView);
-                splashDialog.setCancelable(false);
-                splashDialog.show();
-
-                if (isFullscreen) {
-                    // These must be set after .show() is called because they only work on visible views.
-                    // When the splashscreen hides, the app will revert to whatever was set in CordovaActivity
-                    dialogWindow.getDecorView().setSystemUiVisibility(
-                        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
-                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
-                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
-                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
-                        | View.SYSTEM_UI_FLAG_FULLSCREEN
-                        | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
-                }
-
-                if (preferences.getBoolean("ShowSplashScreenSpinner", true)) {
-                    spinnerStart();
-                }
-
-                // Set Runnable to remove splash screen just in case
-                if (hideAfterDelay) {
-                    final Handler handler = new Handler();
-                    handler.postDelayed(new Runnable() {
-                        public void run() {
-                            if (lastHideAfterDelay) {
-                                removeSplashScreen(false);
-                            }
-                        }
-                    }, effectiveSplashDuration);
-                }
-            }
-        });
-    }
-
-    // Show only spinner in the center of the screen
-    private void spinnerStart() {
-        cordova.getActivity().runOnUiThread(new Runnable() {
-            public void run() {
-                spinnerStop();
-
-                spinnerDialog = new ProgressDialog(webView.getContext());
-                spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
-                    public void onCancel(DialogInterface dialog) {
-                        spinnerDialog = null;
-                    }
-                });
-
-                spinnerDialog.setCancelable(false);
-                spinnerDialog.setIndeterminate(true);
-
-                RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity());
-                centeredLayout.setGravity(Gravity.CENTER);
-                centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
-
-                ProgressBar progressBar = new ProgressBar(webView.getContext());
-                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
-                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
-                progressBar.setLayoutParams(layoutParams);
-
-                if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
-                    String colorName = preferences.getString("SplashScreenSpinnerColor", null);
-                    if(colorName != null){
-                        int[][] states = new int[][] {
-                            new int[] { android.R.attr.state_enabled}, // enabled
-                            new int[] {-android.R.attr.state_enabled}, // disabled
-                            new int[] {-android.R.attr.state_checked}, // unchecked
-                            new int[] { android.R.attr.state_pressed}  // pressed
-                        };
-                        int progressBarColor = Color.parseColor(colorName);
-                        int[] colors = new int[] {
-                            progressBarColor,
-                            progressBarColor,
-                            progressBarColor,
-                            progressBarColor
-                        };
-                        ColorStateList colorStateList = new ColorStateList(states, colors);
-                        progressBar.setIndeterminateTintList(colorStateList);
-                    }
-                }
-
-                centeredLayout.addView(progressBar);
-
-                spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
-                spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
-
-                spinnerDialog.show();
-                spinnerDialog.setContentView(centeredLayout);
-            }
-        });
-    }
-
-    private void spinnerStop() {
-        cordova.getActivity().runOnUiThread(new Runnable() {
-            public void run() {
-                if (spinnerDialog != null && spinnerDialog.isShowing()) {
-                    spinnerDialog.dismiss();
-                    spinnerDialog = null;
-                }
-            }
-        });
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org