Skip to content

Commit b81c8c1

Browse files
Update Android Gradle plugin and sdk
- Gradle plugin 3.6.1 - Gradle Wrapper 5.6.4 - Update min and target sdk - Migrate to androidx
1 parent c2b61b6 commit b81c8c1

File tree

12 files changed

+205
-169
lines changed

12 files changed

+205
-169
lines changed

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
VideoEnabledWebView
22
===================
33

4-
Android's WebView and WebChromeClient class extensions that enable fully working, cross-device, HTML5 video support in Android 2.2 (API level 8) onwards. Actively maintained and tested up to Android 4.4 (API level 19) with its new Chromium webview.
4+
Android's WebView and WebChromeClient class extensions that enable fully working, cross-device, HTML5 video support in Android 4.0.3 (API level 15) onwards. Actively maintained and tested up to Android 10 (API level 29) with its new Chromium webview.
55

6-
Motivation
7-
----------
6+
## Motivation
87

98
Android's default WebView doesn't work well with HTML5 videos (i.e. the _<video>_ tag). Unlike iOS's UIWebView, which is similar to a Safari tab with respect to video handling, Android's implementation is far from how a Chrome tab behaves. API level fragmentation and manufacturer customizations, which usually include video player related UI changes, only add up to the mess. Things that don't work consistently across devices include:
109
- Videos not even playing.
@@ -16,8 +15,7 @@ Android's default WebView doesn't work well with HTML5 videos (i.e. the _<vid
1615

1716
VideoEnabledWebView and VideoEnabledWebChromeClient are two handy extension classes that come to help deal with these issues. I originally wrote them for my personal use, but they got a lot of attention in [StackOverflow](http://stackoverflow.com/a/16179544/423171), and that's the reason they are now here. Contributions are appreciated.
1817

19-
How to use it
20-
-------------
18+
## How to use it
2119

2220
For a working example, download the whole repository and open it with __Android Studio__. Do not use the Open Project option, use __Import Project__.
2321

@@ -27,12 +25,11 @@ VideoEnabledWebChromeClient can be used alone if you do not require the function
2725

2826
Finally, you need to define all the views that you will be using in your layout files, and provide the relevant references in the classes' constructors.
2927

30-
Common issues check-list
31-
------------------------
28+
## Common issues check-list
3229

3330
1. Remember to declare the __internet permission__ in AndroidManifest.xml if you are using the WebView to access remote content: `<uses-permission android:name="android.permission.INTERNET" />`
3431
2. Remember to enable __hardware acceleration__ in AndroidManifest.xml for in-line videos to work in API level 11. The field will have no effect in earlier API levels: `android:hardwareAccelerated="true"`
3532
3. Remember to __initialize the VideoEnabledWebChromeClient__ and link it with the VideoEnabledWebView. Follow the example in ExampleActivity.java.
36-
4. Remember to override your Activity's __onBackPressed()__ and pass the event to the VideoEnabledWebChromeClient. Follow the example in ExampleActivity.java.
33+
4. Remember to override your Activity's __onBackPressed()__ and pass the event to the VideoEnabledWebChromeClient. Follow the example in ExampleActivity.java.
3734
5. Remember to specify and/or programmatically inflate the __videoLayout__, __nonVideoLayout__, and, optionally, __loadingView__. Follow the example in ExampleActivity.java and the xml layout files in res/layout.
3835
6. If you are using __ProGuard__, remember to add the fully qualified name of the Javascript interface to the rules file: `-keepclassmembers class name.cpr.VideoEnabledWebView$JavascriptInterface { public *; }`

app/build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 22
5-
buildToolsVersion '25.0.0'
6-
4+
compileSdkVersion 29
5+
buildToolsVersion '29.0.2'
76
defaultConfig {
87
applicationId "cpr.name.videoenabledwebview"
9-
minSdkVersion 8
10-
targetSdkVersion 22
8+
minSdkVersion 15
9+
targetSdkVersion 29
1110
versionCode 2
1211
versionName "1.0.1"
1312
}
@@ -20,6 +19,6 @@ android {
2019
}
2120

2221
dependencies {
23-
compile fileTree(dir: 'libs', include: ['*.jar'])
24-
compile 'com.android.support:appcompat-v7:22.0.0'
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'androidx.appcompat:appcompat:1.1.0'
2524
}

app/proguard-rules.pro

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Add project specific ProGuard rules here.
2-
# By default, the flags in this file are appended to flags specified
3-
# in C:\Program Files\Android Studio\sdk/tools/proguard/proguard-android.txt
4-
# You can edit the include path and order by changing the proguardFiles
5-
# directive in build.gradle.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
64
#
75
# For more details, see
86
# http://developer.android.com/guide/developing/tools/proguard.html
97

10-
# Add any project specific keep options here:
11-
128
# If your project uses WebView with JS, uncomment the following
139
# and specify the fully qualified class name to the JavaScript interface
1410
# class:
15-
-keepclassmembers class name.cpr.VideoEnabledWebView$JavascriptInterface {
16-
public *;
17-
}
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

app/src/main/java/name/cpr/ExampleActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package name.cpr;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.ActionBarActivity;
54
import android.view.View;
65
import android.view.ViewGroup;
76
import android.view.WindowManager;
87
import android.webkit.WebView;
98
import android.webkit.WebViewClient;
109

10+
import androidx.appcompat.app.AppCompatActivity;
1111
import cpr.name.videoenabledwebview.R;
1212

13-
public class ExampleActivity extends ActionBarActivity
13+
public class ExampleActivity extends AppCompatActivity
1414
{
1515
private VideoEnabledWebView webView;
1616
private VideoEnabledWebChromeClient webChromeClient;
@@ -74,9 +74,9 @@ public void toggledFullscreen(boolean fullscreen)
7474
webView.setWebChromeClient(webChromeClient);
7575
// Call private class InsideWebViewClient
7676
webView.setWebViewClient(new InsideWebViewClient());
77-
77+
7878
// Navigate anywhere you want, but consider that this classes have only been tested on YouTube's mobile site
79-
webView.loadUrl("http://m.youtube.com");
79+
webView.loadUrl("https://www.youtube.com/watch?v=HGZYtDZhOEQ");
8080

8181
}
8282

@@ -89,7 +89,7 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
8989
return true;
9090
}
9191
}
92-
92+
9393
@Override
9494
public void onBackPressed()
9595
{

build.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
31
buildscript {
42
repositories {
3+
google()
54
jcenter()
65
}
76
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.3.3'
9-
10-
// NOTE: Do not place your application dependencies here; they belong
11-
// in the individual module build.gradle files
7+
classpath 'com.android.tools.build:gradle:3.6.1'
128
}
139
}
1410

1511
allprojects {
1612
repositories {
13+
google()
1714
jcenter()
1815
}
1916
}

gradle.properties

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
# Project-wide Gradle settings.
22

33
# IDE (e.g. Android Studio) users:
4-
# Settings specified in this file will override any Gradle settings
5-
# configured through the IDE.
4+
# Gradle settings configured through the IDE *will override*
5+
# any settings specified in this file.
66

77
# For more details on how to configure your build environment visit
88
# http://www.gradle.org/docs/current/userguide/build_environment.html
99

1010
# Specifies the JVM arguments used for the daemon process.
1111
# The setting is particularly useful for tweaking memory settings.
12-
# Default value: -Xmx10248m -XX:MaxPermSize=256m
13-
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
12+
org.gradle.jvmargs=-Xmx1536m
1413

1514
# When configured, Gradle will run in incubating parallel mode.
1615
# This option should only be used with decoupled projects. More details, visit
1716
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1817
# org.gradle.parallel=true
18+
19+
# AndroidX package structure to make it clearer which packages are bundled with the
20+
# Android operating system, and which are packaged with your app's APK
21+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
22+
android.useAndroidX=true
23+
# Automatically convert third-party libraries to use AndroidX
24+
android.enableJetifier=true

gradle/wrapper/gradle-wrapper.jar

5.59 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Mon Oct 16 21:46:15 PDT 2017
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

gradlew

100644100755
Lines changed: 61 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)