Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update project to androidx #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 1 addition & 17 deletions .idea/compiler.xml

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

6 changes: 4 additions & 2 deletions .idea/gradle.xml

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

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

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

40 changes: 25 additions & 15 deletions .idea/misc.xml

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

6 changes: 3 additions & 3 deletions .idea/modules.xml

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

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

17 changes: 9 additions & 8 deletions adblockwebview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
compileSdk 31
buildToolsVersion "30.0.3"

defaultConfig {
minSdkVersion 14
targetSdkVersion 24
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0.0"
vectorDrawables.useSupportLibrary = true
Expand All @@ -21,8 +21,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
3 changes: 2 additions & 1 deletion adblockwebview/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<activity
android:name=".ui.AdBlocksWebViewActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:configChanges="orientation|screenSize" />
android:configChanges="orientation|screenSize"
android:exported="true"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.amnix.adblockwebview.presenter;

import android.support.v4.widget.SwipeRefreshLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.webkit.WebView;
import android.widget.PopupWindow;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Vibrator;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.URLUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatImageButton;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.snackbar.Snackbar;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageButton;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -114,8 +114,7 @@ public static void startWebViewForResult(Activity context, @NonNull final String

@Override
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_COLOR, Color.BLACK));
getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_COLOR, Color.BLACK));
super.onCreate(savedInstanceState);

//noinspection ConstantConditions
Expand Down Expand Up @@ -185,9 +184,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (filePathCallbackLollipop == null) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
filePathCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
}
filePathCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, data));
filePathCallbackLollipop = null;
break;
}
Expand Down Expand Up @@ -222,9 +219,7 @@ private void bindView() {
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
webSettings.setDisplayZoomControls(false);
}
webSettings.setDisplayZoomControls(false);
webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
webSettings.setDomStorageEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.os.AsyncTask;
import android.support.annotation.WorkerThread;
import androidx.annotation.WorkerThread;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebResourceResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,29 @@ private ClipboardUtils() {
public static void copyText(Context context, String text) {
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ClipData clip = ClipData.newPlainText("", text);
cm.setPrimaryClip(clip);
} else {
//noinspection deprecation
cm.setText(text);
}
ClipData clip = ClipData.newPlainText("", text);
cm.setPrimaryClip(clip);
}

public static boolean hasText(Context context) {
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ClipDescription description = cm.getPrimaryClipDescription();
ClipData clipData = cm.getPrimaryClip();
return clipData != null
&& description != null
&& (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN));
} else {
//noinspection deprecation
return cm.hasText();
}
ClipDescription description = cm.getPrimaryClipDescription();
ClipData clipData = cm.getPrimaryClip();
return clipData != null
&& description != null
&& (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN));
}

public static CharSequence getText(Context context) {
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ClipDescription description = cm.getPrimaryClipDescription();
ClipData clipData = cm.getPrimaryClip();
if (clipData != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
return clipData.getItemAt(0).getText();
} else {
return "";
}
ClipDescription description = cm.getPrimaryClipDescription();
ClipData clipData = cm.getPrimaryClip();
if (clipData != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
return clipData.getItemAt(0).getText();
} else {
//noinspection deprecation
return cm.getText();
return "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.app.Activity;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

public class PermissionUtils {

Expand Down
8 changes: 4 additions & 4 deletions adblockwebview/src/main/res/layout/a_web_viewer.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/a_web_viewer_coordinatorlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -19,7 +19,7 @@
android:indeterminate="false"
android:progressDrawable="@drawable/progress_drawable" />

<android.support.v4.widget.SwipeRefreshLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/a_web_viewer_srl"
android:layout_width="match_parent"
android:layout_height="match_parent">
Expand All @@ -29,6 +29,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
</android.support.v4.widget.SwipeRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>