Skip to content

Commit

Permalink
Update minSdkVersion to 25 = Android 7.1 (Nougat)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikespub committed Mar 3, 2022
1 parent 909cde1 commit b42759b
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 137 deletions.
22 changes: 22 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,24 @@ android {
}

dependencies {
//def appCompatVersion = "1.4.0"
def lifeCycleVersion = '2.4.0'
//def appCompatVersion = "1.4.1"
def lifeCycleVersion = '2.4.1'
//def arch_version = '2.1.0'

// https://developer.android.com/studio/projects/android-library
implementation project(":myutils")

implementation fileTree(dir: 'libs', include: ['*.jar'])
// https://developer.android.com/jetpack/androidx/releases/appcompat
implementation "androidx.appcompat:appcompat:${appCompatVersion}"
// For loading and tinting drawables on older versions of the platform
// implementation "androidx.appcompat:appcompat-resources:${appCompatVersion}"
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
// https://developer.android.com/jetpack/androidx/releases/constraintlayout
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
// To use constraintlayout in compose
//implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0"
implementation "androidx.webkit:webkit:1.4.0"
// https://developer.android.com/jetpack/androidx/releases/lifecycle
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel:${lifeCycleVersion}"
// LiveData
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 22,
"versionName": "1.21",
"versionCode": 23,
"versionName": "1.22",
"outputFile": "app-release.apk"
}
],
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/assets/web/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<div id="main">
<h1><a href="index.html">My WebView</a></h1>
<h2>About My WebView</h2>
<h3>What's New in Version 1.21</h3>
<p>Update min API level to 24 = Android 7 (Nougat)</p>
<h3>What's New in Version 1.22</h3>
<p>Update min API level to 25 = Android 7.1 (Nougat)</p>
<h3>Product Description</h3>
<p>Test your websites with Android WebView, using a configurable list of sites and matches to allow or skip.
Other links will not be handled by the app and will simply ask you to open the standard browser or not.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void showMessage(final String message) {
public void run() {
Uri uri = Uri.parse(myWebView.getUrl());
if(!uri.getHost().equals(myActivity.getString(R.string.app_host))){
Log.d("WebView", "No Javascript Interface for " + uri.toString());
Log.d("WebView", "No Javascript Interface for " + uri);
return;
}

Expand Down
19 changes: 10 additions & 9 deletions app/src/main/java/net/mikespub/mywebview/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.mikespub.mywebview;

import android.annotation.SuppressLint;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract;
Expand Down Expand Up @@ -142,6 +142,7 @@ public void onActivityResult(Uri returnUri) {
/**
* @param savedInstanceState saved instance state
*/
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -347,9 +348,9 @@ public void onBackPressed() {
// https://stackoverflow.com/questions/41025200/android-view-inflateexception-error-inflating-class-android-webkit-webview
@Override
public void applyOverrideConfiguration(final Configuration overrideConfiguration) {
if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 25) {
overrideConfiguration.uiMode &= ~Configuration.UI_MODE_NIGHT_MASK;
}
//if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT < 25) {
// overrideConfiguration.uiMode &= ~Configuration.UI_MODE_NIGHT_MASK;
//}
super.applyOverrideConfiguration(overrideConfiguration);
}

Expand Down Expand Up @@ -445,16 +446,16 @@ private Uri getActivityResultUri(int requestCode, int resultCode, Intent returnI
if (returnUri == null) {
// Pick text - Samsung Notes
if (returnExtras != null) {
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent.toString() + " No Uri: " + returnIntent.toUri(0) + " Extras: " + returnExtras.toString());
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent + " No Uri: " + returnIntent.toUri(0) + " Extras: " + returnExtras);
} else {
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent.toString() + " No Uri: " + returnIntent.toUri(0) + " Extras: " + returnExtras);
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent + " No Uri: " + returnIntent.toUri(0) + " Extras: " + returnExtras);
}
return null;
}
if (returnExtras != null) {
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent.toString() + " Uri: " + returnUri + " Extras: " + returnExtras.toString());
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent + " Uri: " + returnUri + " Extras: " + returnExtras);
} else {
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent.toString() + " Uri: " + returnUri + " Extras: " + returnExtras);
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Intent: " + returnIntent + " Uri: " + returnUri + " Extras: " + returnExtras);
}
return returnUri;
}
Expand All @@ -464,7 +465,7 @@ private boolean checkActivityResult(int requestCode, int resultCode, Intent retu
if (resultCode != RESULT_OK) {
// Exit without doing anything else
if (returnIntent != null) {
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Not OK: " + returnIntent.toString());
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Not OK: " + returnIntent);
} else {
Log.d("Activity Result", "Request: " + requestCode + " Result: " + resultCode + " Not OK: " + returnIntent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private boolean testOverrideUrlLoading(WebView view, String url) {
if (isMatch && isSkip) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// Create intent to show chooser
String title = uri.toString() + "\n\nOpen with";
String title = uri + "\n\nOpen with";
Intent chooser = Intent.createChooser(intent, title);
view.getContext().startActivity(chooser);
return true;
Expand All @@ -444,11 +444,11 @@ private boolean testOverrideUrlLoading(WebView view, String url) {
if (hasNotMatching()) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
// Create intent to show chooser
String title = uri.toString() + "\n\nOpen with";
String title = uri + "\n\nOpen with";
Intent chooser = Intent.createChooser(intent, title);
view.getContext().startActivity(chooser);
} else {
String message = uri.toString() + "\n\nLink not matching. You can allow opening via regular browser in Advanced Options.";
String message = uri + "\n\nLink not matching. You can allow opening via regular browser in Advanced Options.";
Toast toast = Toast.makeText(
view.getContext().getApplicationContext(),
message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static void saveIconToMedia(AppCompatActivity activity) {
}
//Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher);
if (bitmap != null) {
Log.d(TAG, "Bitmap: " + bitmap.toString());
Log.d(TAG, "Bitmap: " + bitmap);
File extDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
if (!extDir.exists() && !extDir.mkdirs()) {
Log.e(TAG, "Dir Create: FAIL " + extDir.getAbsolutePath());
Expand Down Expand Up @@ -198,7 +198,7 @@ public static void insertImage(ContentResolver cr, File file) {

static boolean updateLocalSites(AppCompatActivity activity, HashMap<String, String> localSites) {
HashMap<String, String> siteMap = findLocalSites(activity);
Log.d(TAG, "Sites: " + siteMap.toString());
Log.d(TAG, "Sites: " + siteMap);
boolean hasAdded = false;
for (String url: siteMap.keySet()) {
if (!localSites.containsKey(url)) {
Expand Down
Loading

0 comments on commit b42759b

Please sign in to comment.