Compare commits
20 Commits
appbase
...
webpagesou
Author | SHA1 | Date | |
---|---|---|---|
f53b222b7f | |||
0c0cde8406 | |||
46967065c0 | |||
8edbff5ac1 | |||
434f8a8549 | |||
c04be60b13 | |||
641098f8fb | |||
dba54ac4b2 | |||
c6cd779889 | |||
dfb1692a04 | |||
c83c8f66b3 | |||
cd7b5f38bf | |||
0c2e73b82e | |||
7b1838ff8e | |||
73ff3d1726 | |||
a69572e216 | |||
fa79c3f807 | |||
fde4b275f7 | |||
d66d9373ff | |||
f32ed94e4e |
@ -56,3 +56,7 @@
|
||||
// NumTable 项目编译设置
|
||||
//include ':numtable'
|
||||
//rootProject.name = "numtable"
|
||||
|
||||
// WebPageSources 项目编译设置
|
||||
//include ':webpagesources'
|
||||
//rootProject.name = "webpagesources"
|
||||
|
1
webpagesources/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
34
webpagesources/README.md
Normal file
@ -0,0 +1,34 @@
|
||||
# webpagesources
|
||||
|
||||
#### 介绍
|
||||
WinBoLl 网站专用网页浏览器,用于开发调试 WinBoLL 网站。
|
||||
|
||||
#### 软件架构
|
||||
适配安卓应用 [AIDE Pro] 的 Gradle 编译结构。
|
||||
也适配安卓应用 [AndroidIDE] 的 Gradle 编译结构。
|
||||
|
||||
|
||||
#### Gradle 编译说明
|
||||
调试版编译命令 :gradle assembleBetaDebug
|
||||
阶段版编译命令 :bash .winboll/bashPublishAPKAddTag.sh webpagesources
|
||||
|
||||
#### 使用说明
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码 : ZhanGSKen(ZhanGSKen<zhangsken@188.com>)
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
||||
|
||||
#### 参考文档
|
1
webpagesources/app_update_description.txt
Normal file
@ -0,0 +1 @@
|
||||
|
76
webpagesources/build.gradle
Normal file
@ -0,0 +1,76 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply from: '../.winboll/winboll_app_build.gradle'
|
||||
apply from: '../.winboll/winboll_lint_build.gradle'
|
||||
|
||||
def genVersionName(def versionName){
|
||||
// 检查编译标志位配置
|
||||
assert (winbollBuildProps['stageCount'] != null)
|
||||
assert (winbollBuildProps['baseVersion'] != null)
|
||||
// 保存基础版本号
|
||||
winbollBuildProps.setProperty("baseVersion", "${versionName}");
|
||||
//保存编译标志配置
|
||||
FileOutputStream fos = new FileOutputStream(winbollBuildPropsFile)
|
||||
winbollBuildProps.store(fos, "${winbollBuildPropsDesc}");
|
||||
fos.close();
|
||||
|
||||
// 返回编译版本号
|
||||
return "${versionName}." + winbollBuildProps['stageCount']
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 32
|
||||
buildToolsVersion "32.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cc.winboll.studio.webpagesources"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.0"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 视图布局下拉控件
|
||||
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
|
||||
// SSH
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
// AndroidX 类库
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
api 'androidx.fragment:fragment:1.1.0'
|
||||
|
||||
api 'cc.winboll.studio:libaes:15.8.0'
|
||||
api 'cc.winboll.studio:libapputils:15.8.2'
|
||||
api 'cc.winboll.studio:libappbase:15.8.2'
|
||||
}
|
8
webpagesources/build.properties
Normal file
@ -0,0 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Fri Jun 13 10:04:49 HKT 2025
|
||||
stageCount=7
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.6
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.7
|
21
webpagesources/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
25
webpagesources/src/beta/AndroidManifest.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application
|
||||
|
||||
tools:replace="android:icon"
|
||||
android:icon="@drawable/ic_winbollbeta">
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="cc.winboll.studio.webpagesources.beta.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_provider"/>
|
||||
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
6
webpagesources/src/beta/res/values/strings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">WebPageSources +</string>
|
||||
|
||||
</resources>
|
109
webpagesources/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.webpagesources">
|
||||
|
||||
<!-- 拥有完全的网络访问权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<!-- 读取您共享存储空间中的内容 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
|
||||
<!-- 修改或删除您共享存储空间中的内容 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<!-- 只能在前台获取精确的位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_winboll"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/WebPageSourceTheme"
|
||||
android:supportsRtl="true"
|
||||
android:resizeableActivity="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="standard"
|
||||
android:exported="true">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:scheme="http"/>
|
||||
|
||||
<data android:scheme="https"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:mimeType="text/html"/>
|
||||
|
||||
<data android:mimeType="application/xhtml+xml"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:scheme="about"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
|
||||
<data android:scheme="javascript"/>
|
||||
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activities.AboutActivity"
|
||||
android:label="AboutActivity"/>
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<activity android:name=".GlobalApplication$CrashActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,345 @@
|
||||
package cc.winboll.studio.webpagesources;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.hjq.toast.style.WhiteToastStyle;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
//CrashHandler.getInstance().registerGlobal(this);
|
||||
//CrashHandler.getInstance().registerPart(this);
|
||||
}
|
||||
|
||||
public static void write(InputStream input, OutputStream output) throws IOException {
|
||||
byte[] buf = new byte[1024 * 8];
|
||||
int len;
|
||||
while ((len = input.read(buf)) != -1) {
|
||||
output.write(buf, 0, len);
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(File file, byte[] data) throws IOException {
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null && !parent.exists()) parent.mkdirs();
|
||||
|
||||
ByteArrayInputStream input = new ByteArrayInputStream(data);
|
||||
FileOutputStream output = new FileOutputStream(file);
|
||||
try {
|
||||
write(input, output);
|
||||
} finally {
|
||||
closeIO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static String toString(InputStream input) throws IOException {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
write(input, output);
|
||||
try {
|
||||
return output.toString("UTF-8");
|
||||
} finally {
|
||||
closeIO(input, output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeIO(Closeable... closeables) {
|
||||
for (Closeable closeable : closeables) {
|
||||
try {
|
||||
if (closeable != null) closeable.close();
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CrashHandler {
|
||||
|
||||
public static final UncaughtExceptionHandler DEFAULT_UNCAUGHT_EXCEPTION_HANDLER = Thread.getDefaultUncaughtExceptionHandler();
|
||||
|
||||
private static CrashHandler sInstance;
|
||||
|
||||
private PartCrashHandler mPartCrashHandler;
|
||||
|
||||
public static CrashHandler getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new CrashHandler();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void registerGlobal(Context context) {
|
||||
registerGlobal(context, null);
|
||||
}
|
||||
|
||||
public void registerGlobal(Context context, String crashDir) {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandlerImpl(context.getApplicationContext(), crashDir));
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(DEFAULT_UNCAUGHT_EXCEPTION_HANDLER);
|
||||
}
|
||||
|
||||
public void registerPart(Context context) {
|
||||
unregisterPart(context);
|
||||
mPartCrashHandler = new PartCrashHandler(context.getApplicationContext());
|
||||
MAIN_HANDLER.postAtFrontOfQueue(mPartCrashHandler);
|
||||
}
|
||||
|
||||
public void unregisterPart(Context context) {
|
||||
if (mPartCrashHandler != null) {
|
||||
mPartCrashHandler.isRunning.set(false);
|
||||
mPartCrashHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PartCrashHandler implements Runnable {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public AtomicBoolean isRunning = new AtomicBoolean(true);
|
||||
|
||||
public PartCrashHandler(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRunning.get()) {
|
||||
try {
|
||||
Looper.loop();
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
if (isRunning.get()) {
|
||||
MAIN_HANDLER.post(new Runnable(){
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(mContext, e.toString(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException)e;
|
||||
} else {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class UncaughtExceptionHandlerImpl implements UncaughtExceptionHandler {
|
||||
|
||||
private static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss");
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private final File mCrashDir;
|
||||
|
||||
public UncaughtExceptionHandlerImpl(Context context, String crashDir) {
|
||||
this.mContext = context;
|
||||
this.mCrashDir = TextUtils.isEmpty(crashDir) ? new File(mContext.getExternalCacheDir(), "crash") : new File(crashDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
try {
|
||||
|
||||
String log = buildLog(throwable);
|
||||
writeLog(log);
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(mContext, CrashActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, log);
|
||||
mContext.startActivity(intent);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
writeLog(e.toString());
|
||||
}
|
||||
|
||||
throwable.printStackTrace();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
|
||||
} catch (Throwable e) {
|
||||
if (DEFAULT_UNCAUGHT_EXCEPTION_HANDLER != null) DEFAULT_UNCAUGHT_EXCEPTION_HANDLER.uncaughtException(thread, throwable);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildLog(Throwable throwable) {
|
||||
String time = DATE_FORMAT.format(new Date());
|
||||
|
||||
String versionName = "unknown";
|
||||
long versionCode = 0;
|
||||
try {
|
||||
PackageInfo packageInfo = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0);
|
||||
versionName = packageInfo.versionName;
|
||||
versionCode = Build.VERSION.SDK_INT >= 28 ? packageInfo.getLongVersionCode() : packageInfo.versionCode;
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
LinkedHashMap<String, String> head = new LinkedHashMap<String, String>();
|
||||
head.put("Time Of Crash", time);
|
||||
head.put("Device", String.format("%s, %s", Build.MANUFACTURER, Build.MODEL));
|
||||
head.put("Android Version", String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
|
||||
head.put("App Version", String.format("%s (%d)", versionName, versionCode));
|
||||
head.put("Kernel", getKernel());
|
||||
head.put("Support Abis", Build.VERSION.SDK_INT >= 21 && Build.SUPPORTED_ABIS != null ? Arrays.toString(Build.SUPPORTED_ABIS): "unknown");
|
||||
head.put("Fingerprint", Build.FINGERPRINT);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String key : head.keySet()) {
|
||||
if (builder.length() != 0) builder.append("\n");
|
||||
builder.append(key);
|
||||
builder.append(" : ");
|
||||
builder.append(head.get(key));
|
||||
}
|
||||
|
||||
builder.append("\n\n");
|
||||
builder.append(Log.getStackTraceString(throwable));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private void writeLog(String log) {
|
||||
String time = DATE_FORMAT.format(new Date());
|
||||
File file = new File(mCrashDir, "crash_" + time + ".txt");
|
||||
try {
|
||||
write(file, log.getBytes("UTF-8"));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getKernel() {
|
||||
try {
|
||||
return App.toString(new FileInputStream("/proc/version")).trim();
|
||||
} catch (Throwable e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class CrashActivity extends Activity {
|
||||
|
||||
private String mLog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setTheme(android.R.style.Theme_DeviceDefault);
|
||||
setTitle("App Crash");
|
||||
|
||||
mLog = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||
|
||||
ScrollView contentView = new ScrollView(this);
|
||||
contentView.setFillViewport(true);
|
||||
|
||||
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
|
||||
|
||||
TextView textView = new TextView(this);
|
||||
int padding = dp2px(16);
|
||||
textView.setPadding(padding, padding, padding, padding);
|
||||
textView.setText(mLog);
|
||||
textView.setTextIsSelectable(true);
|
||||
textView.setTypeface(Typeface.DEFAULT);
|
||||
textView.setLinksClickable(true);
|
||||
|
||||
horizontalScrollView.addView(textView);
|
||||
contentView.addView(horizontalScrollView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
|
||||
setContentView(contentView);
|
||||
}
|
||||
|
||||
private void restart() {
|
||||
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
|
||||
if (intent != null) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static int dp2px(float dpValue) {
|
||||
final float scale = Resources.getSystem().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(0, android.R.id.copy, 0, android.R.string.copy)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.copy:
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setPrimaryClip(ClipData.newPlainText(getPackageName(), mLog));
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
restart();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,214 @@
|
||||
package cc.winboll.studio.webpagesources;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/07/02 17:10:46
|
||||
* @Describe 主要启动窗口类
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.ValueCallback;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.activities.AboutActivity;
|
||||
import cc.winboll.studio.webpagesources.fragment.SourcesFragment;
|
||||
import cc.winboll.studio.webpagesources.fragment.WebFragment;
|
||||
import cc.winboll.studio.webpagesources.view.StatusBarView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
public static final int REQUEST_ABOUT_ACTIVITY = 0;
|
||||
public static final int REQUEST_FILE_CHOOSER = 1;
|
||||
|
||||
public static final String MSG_UPDATE_URL = "MSG_UPDATE_URL";
|
||||
|
||||
static MainActivity _MainActivity;
|
||||
StatusBarView mStatusBarView;
|
||||
WebFragment mWebFragment;
|
||||
SourcesFragment mSourcesFragment;
|
||||
static boolean _mIsLoadedHomePage;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
FragmentTransaction ft = ((FragmentManager)getSupportFragmentManager()).beginTransaction();
|
||||
mSourcesFragment = new SourcesFragment();
|
||||
ft.add(R.id.activitymainFrameLayout1, mSourcesFragment, SourcesFragment.TAG);
|
||||
ft.hide(mSourcesFragment);
|
||||
mWebFragment = new WebFragment();
|
||||
//mWebFragment.setJSOnShowSourceListener(this);
|
||||
ft.add(R.id.activitymainFrameLayout1, mWebFragment, WebFragment.TAG);
|
||||
ft.show(mWebFragment);
|
||||
ft.commit();
|
||||
|
||||
mStatusBarView = findViewById(R.id.activitymainStatusBarView1);
|
||||
_MainActivity = this;
|
||||
postStatusBarMessage("主窗口加载完成。");
|
||||
//ToastUtils.show("Start");
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected void onNewIntent(Intent intent) {
|
||||
// super.onNewIntent(intent);
|
||||
// // 处理 onNewIntent 时的 Intent(Activity 已存在时调用)
|
||||
// handleIntent(intent);
|
||||
// }
|
||||
|
||||
private String getIntentUrl(Intent intent) {
|
||||
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
//ToastUtils.show("ACTION_VIEW");
|
||||
Uri data = intent.getData();
|
||||
if (data != null) {
|
||||
String url = data.toString(); // 获取完整 URL
|
||||
String host = data.getHost(); // 获取主机名(如 "www.example.com")
|
||||
String path = data.getPath(); // 获取路径(如 "/page")
|
||||
|
||||
// 在界面显示 URL
|
||||
//tvUrl.setText("接收到的 URL:\n" + url);
|
||||
//ToastUtils.show(String.format("url %s", url));
|
||||
return url;
|
||||
|
||||
// 示例:打开系统浏览器访问该 URL
|
||||
// Intent browserIntent = new Intent(Intent.ACTION_VIEW, data);
|
||||
// startActivity(browserIntent);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void postStatusBarMessage(String msg) {
|
||||
if (_MainActivity != null) {
|
||||
_MainActivity.mStatusBarView.postMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
String intentUrl = getIntentUrl(getIntent());
|
||||
if (intentUrl != null && !intentUrl.trim().equals("")) {
|
||||
mWebFragment.loadUrl(intentUrl);
|
||||
} else {
|
||||
if (_mIsLoadedHomePage) {
|
||||
//ToastUtils.show("重新加载当前页面");
|
||||
mWebFragment.reloadLastUrl();
|
||||
} else {
|
||||
//ToastUtils.show("加载默认主页");
|
||||
mWebFragment.loadUrl(getApplicationContext().getString(R.string.app_homepage));
|
||||
_mIsLoadedHomePage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_main, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
//return super.onOptionsItemSelected(item);
|
||||
switch (item.getItemId()) {
|
||||
case R.id.item_sources : {
|
||||
LogUtils.d(TAG, "item_web");
|
||||
FragmentTransaction ft = ((FragmentManager)getSupportFragmentManager()).beginTransaction();
|
||||
ft.hide(mWebFragment);
|
||||
ft.show(mSourcesFragment);
|
||||
ft.commit();
|
||||
break;
|
||||
}
|
||||
case R.id.item_web : {
|
||||
LogUtils.d(TAG, "item_sources");
|
||||
FragmentTransaction ft = ((FragmentManager)getSupportFragmentManager()).beginTransaction();
|
||||
ft.hide(mSourcesFragment);
|
||||
ft.show(mWebFragment);
|
||||
ft.commit();
|
||||
break;
|
||||
}
|
||||
case R.id.item_editor : {
|
||||
mSourcesFragment.shareHtml();
|
||||
break;
|
||||
}
|
||||
case R.id.item_log : {
|
||||
GlobalApplication.getWinBoLLActivityManager().startLogActivity(this);
|
||||
break;
|
||||
}
|
||||
case R.id.item_about : {
|
||||
GlobalApplication.getWinBoLLActivityManager().startWinBoLLActivity(this, AboutActivity.class);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
//ToastUtils.show("onActivityResult Main");
|
||||
switch (requestCode) {
|
||||
case REQUEST_ABOUT_ACTIVITY : {
|
||||
LogUtils.d(TAG, "REQUEST_ABOUT_ACTIVITY");
|
||||
break;
|
||||
}
|
||||
case REQUEST_FILE_CHOOSER : {
|
||||
//ToastUtils.show("MainActivity.REQUEST_FILE_CHOOSER");
|
||||
ValueCallback<Uri[]> filePathCallback = mWebFragment.getWebView().getFilePathCallback();
|
||||
|
||||
if (filePathCallback == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Uri[] results = null;
|
||||
// 检查选择的文件是否为空
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
String dataString = data.getDataString();
|
||||
if (dataString != null) {
|
||||
results = new Uri[]{Uri.parse(dataString)};
|
||||
}
|
||||
}
|
||||
|
||||
// 传递选择的文件给WebView
|
||||
filePathCallback.onReceiveValue(results);
|
||||
filePathCallback = null;
|
||||
|
||||
break;
|
||||
}
|
||||
default : {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cc.winboll.studio.webpagesources.activities;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/07/14 13:20:33
|
||||
* @Describe AboutFragment Test
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
final public class AboutActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "AboutActivity";
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.toolbar_about, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.item_help) {
|
||||
ToastUtils.show("R.id.item_help");
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
GlobalApplication.getWinBoLLActivityManager().getInstance().finish(this);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -0,0 +1,197 @@
|
||||
package cc.winboll.studio.webpagesources.common;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/26 20:48:46
|
||||
* @Describe 登录验证对话框
|
||||
*/
|
||||
import android.content.DialogInterface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.models.AuthenticationBean;
|
||||
import cc.winboll.studio.webpagesources.common.AuthenticationUtils;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AuthLoginDialog {
|
||||
|
||||
public static final String TAG = "AuthLoginDialog";
|
||||
|
||||
WebView mWebView;
|
||||
static AuthenticationBean _mLastAuthenticationBean;
|
||||
EditText metUserName;
|
||||
EditText metPassword;
|
||||
AlertDialog mLoginAlertDialog;
|
||||
HttpAuthHandler mHttpAuthHandler;
|
||||
|
||||
public AuthLoginDialog(WebView view, HttpAuthHandler httpAuthHandler, String host, String realm) {
|
||||
mWebView = view;
|
||||
mHttpAuthHandler = httpAuthHandler;
|
||||
_mLastAuthenticationBean = new AuthenticationBean();
|
||||
_mLastAuthenticationBean.setHost(host);
|
||||
_mLastAuthenticationBean.setRealm(realm);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
// 获取要登录的URL和已知的身份验证信息
|
||||
String authUrl = "[ " + _mLastAuthenticationBean.getHost() + " ] " + _mLastAuthenticationBean.getRealm();
|
||||
final AuthenticationUtils authenticationUtils = AuthenticationUtils.getInstance(mWebView.getContext());
|
||||
final ArrayList<AuthenticationBean> listInfo = authenticationUtils.getHostAuthenticationList(_mLastAuthenticationBean.getHost(), _mLastAuthenticationBean.getRealm());
|
||||
|
||||
final View llMain = mWebView.inflate(mWebView.getContext(), R.layout.dialog_login_auth, null);
|
||||
metUserName = llMain.findViewById(R.id.viewloginhttpEditText1);
|
||||
metPassword = llMain.findViewById(R.id.viewloginhttpEditText2);
|
||||
RecyclerView recyclerView = llMain.findViewById(R.id.dialogloginauthRecyclerView1);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mWebView.getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
AuthenticationBeanListAdapter adapter = new AuthenticationBeanListAdapter(listInfo);
|
||||
// 设置 RecyclerView 的适配器
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
if (listInfo.size() > 0) {
|
||||
metUserName.setText(listInfo.get(0).getUserName());
|
||||
metPassword.setText(listInfo.get(0).getPassword());
|
||||
LogUtils.d(TAG, "listInfo setText");
|
||||
}
|
||||
// 弹窗提示用户输入账号密码
|
||||
mLoginAlertDialog = new AlertDialog.Builder(mWebView.getContext())
|
||||
.setTitle("Login Required")
|
||||
.setMessage(authUrl + "\nPlease enter your credentials:")
|
||||
.setView(llMain)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int p) {
|
||||
_mLastAuthenticationBean.setUserName(metUserName.getText().toString());
|
||||
_mLastAuthenticationBean.setPassword(metPassword.getText().toString());
|
||||
//LogUtils.d(TAG, "getUserName : " + _mLastAuthenticationBean.getUserName());
|
||||
//LogUtils.d(TAG, "getPassword : " + _mLastAuthenticationBean.getPassword());
|
||||
//LogUtils.d(TAG, "mHttpAuthHandler : " + mHttpAuthHandler);
|
||||
// 进入网站
|
||||
mHttpAuthHandler.proceed(_mLastAuthenticationBean.getUserName(), _mLastAuthenticationBean.getPassword());
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public void checkAndSaveLastAuthenticationBean() {
|
||||
if (_mLastAuthenticationBean != null) {
|
||||
// 更新身份验证信息
|
||||
if (!_mLastAuthenticationBean.getHost().isEmpty()
|
||||
&& !_mLastAuthenticationBean.getRealm().isEmpty()
|
||||
&& !_mLastAuthenticationBean.getUserName().isEmpty()
|
||||
&& !_mLastAuthenticationBean.getPassword().isEmpty()) {
|
||||
final AuthenticationUtils authenticationUtils = AuthenticationUtils.getInstance(mWebView.getContext());
|
||||
authenticationUtils.saveAuthenticationInfo(_mLastAuthenticationBean);
|
||||
// 清理已保存,或者不需要保存的登录信息
|
||||
_mLastAuthenticationBean = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AuthenticationBeanListAdapter extends RecyclerView.Adapter {
|
||||
|
||||
ArrayList<AuthenticationBean> mDataList;
|
||||
public AuthenticationBeanListAdapter(ArrayList<AuthenticationBean> listInfo) {
|
||||
mDataList = listInfo;
|
||||
}
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mDataList.size();
|
||||
}
|
||||
|
||||
void deleteSMSRecycleItem(final int position) {
|
||||
YesNoAlertDialog.show(mWebView.getContext(),
|
||||
"密码删除提示",
|
||||
"请确认删除(" + mDataList.get(position).getUserName() + ")密码!"
|
||||
, (new YesNoAlertDialog.OnDialogResultListener(){
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
AuthenticationUtils authenticationUtils = AuthenticationUtils.getInstance(mWebView.getContext());
|
||||
authenticationUtils.deleteAuthenticationInfo(mDataList.get(position));
|
||||
mDataList.remove(position);
|
||||
notifyDataSetChanged();
|
||||
ToastUtils.show("密码已删除!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNo() {
|
||||
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||
final AuthenticationBean item = mDataList.get(position);
|
||||
if (holder.getItemViewType() == 0) {
|
||||
final SimpleViewHolder viewHolder = (SimpleViewHolder) holder;
|
||||
viewHolder.mtvUserName.setText(item.getUserName());
|
||||
viewHolder.mCardView.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
metUserName.setText(item.getUserName());
|
||||
metPassword.setText(item.getPassword());
|
||||
}
|
||||
});
|
||||
viewHolder.mCardView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View p1) {
|
||||
// 弹出复制菜单
|
||||
PopupMenu menu = new PopupMenu(mWebView.getContext(), viewHolder.mCardView);
|
||||
//加载菜单资源
|
||||
menu.getMenuInflater().inflate(R.menu.toolbar_authinfo, menu.getMenu());
|
||||
//设置点击事件的响应
|
||||
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
int nItemId = menuItem.getItemId();
|
||||
if (nItemId == R.id.item_delete_authinfo) {
|
||||
deleteSMSRecycleItem(position);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
//一定要调用show()来显示弹出式菜单
|
||||
menu.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (viewType == 0) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listview_authinfo, parent, false);
|
||||
return new SimpleViewHolder(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class SimpleViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView mtvUserName;
|
||||
CardView mCardView;
|
||||
SimpleViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mtvUserName = itemView.findViewById(R.id.viewitemauthinfoTextView1);
|
||||
mCardView = itemView.findViewById(R.id.listviewauthinfoCardView1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package cc.winboll.studio.webpagesources.common;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/26 16:16:00
|
||||
* @Describe 网站登录验证工具类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.webpagesources.models.AuthenticationBean;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AuthenticationUtils {
|
||||
|
||||
public static final String TAG = "AuthenticationUtils";
|
||||
|
||||
static AuthenticationUtils _mAuthenticationUtils;
|
||||
static String _mBeanPath;
|
||||
Context mContext;
|
||||
ArrayList<AuthenticationBean> mData;
|
||||
|
||||
AuthenticationUtils(Context context) {
|
||||
mContext = context;
|
||||
File beanDir = new File(context.getFilesDir(), "home" + File.separator + TAG);
|
||||
if (!beanDir.exists()) {
|
||||
beanDir.mkdirs();
|
||||
}
|
||||
LogUtils.d(TAG, String.format("beanDir %s", beanDir.toString()));
|
||||
_mBeanPath = beanDir.getPath() + "/" + AuthenticationBean.class.getName() + ".json";
|
||||
mData = new ArrayList<AuthenticationBean>();
|
||||
AuthenticationBean.loadBeanListFromFile(_mBeanPath, mData, AuthenticationBean.class);
|
||||
}
|
||||
|
||||
public static AuthenticationUtils getInstance(Context context) {
|
||||
if (_mAuthenticationUtils == null) {
|
||||
_mAuthenticationUtils = new AuthenticationUtils(context);
|
||||
}
|
||||
return _mAuthenticationUtils;
|
||||
}
|
||||
|
||||
ArrayList<AuthenticationBean> loadAuthenticationData(String szHost, String szRealm) {
|
||||
ArrayList<AuthenticationBean> listReturn = new ArrayList<AuthenticationBean>();
|
||||
for (AuthenticationBean item : getInstance(mContext).mData) {
|
||||
if (szHost.equals(item.getHost())
|
||||
&& szRealm.equals(item.getRealm())) {
|
||||
listReturn.add(item);
|
||||
}
|
||||
}
|
||||
return listReturn;
|
||||
}
|
||||
|
||||
public ArrayList<AuthenticationBean> getHostAuthenticationList(String szHost, String szRealm) {
|
||||
ArrayList<AuthenticationBean> listReturn = new ArrayList<AuthenticationBean>();
|
||||
for (final AuthenticationBean item : mData) {
|
||||
if (szHost.equals(item.getHost())
|
||||
&& szRealm.equals(item.getRealm())) {
|
||||
listReturn.add(item);
|
||||
}
|
||||
}
|
||||
return listReturn;
|
||||
}
|
||||
|
||||
public void deleteAuthenticationInfo(AuthenticationBean bean) {
|
||||
for (final AuthenticationBean item : mData) {
|
||||
if (bean.getHost().equals(item.getHost())
|
||||
&& bean.getRealm().equals(item.getRealm())
|
||||
&& bean.getUserName().equals(item.getUserName())) {
|
||||
mData.remove(item);
|
||||
AuthenticationBean.saveBeanListToFile(_mBeanPath, mData);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void putAuthenticationBeanToTheFirstPosition(AuthenticationBean bean) {
|
||||
for (AuthenticationBean item : mData) {
|
||||
if (bean.getHost().equals(item.getHost())
|
||||
&& bean.getRealm().equals(item.getRealm())
|
||||
&& bean.getUserName().equals(item.getUserName())) {
|
||||
mData.add(0, new AuthenticationBean(item));
|
||||
mData.remove(item);
|
||||
AuthenticationBean.saveBeanListToFile(_mBeanPath, mData);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAuthenticationInfo(AuthenticationBean bean) {
|
||||
saveAuthenticationInfo(bean.getHost(), bean.getRealm(), bean.getUserName(), bean.getPassword());
|
||||
}
|
||||
|
||||
public void saveAuthenticationInfo(String szHost, String szRealm, String szUserName, final String szPassword) {
|
||||
boolean isFindUserName = false;
|
||||
AuthenticationBean.loadBeanListFromFile(_mBeanPath, mData, AuthenticationBean.class);
|
||||
for (final AuthenticationBean item : mData) {
|
||||
if (szHost.equals(item.getHost())
|
||||
&& szRealm.equals(item.getRealm())
|
||||
&& szUserName.equals(item.getUserName())) {
|
||||
isFindUserName = true;
|
||||
if (!szPassword.equals(item.getPassword())) {
|
||||
// 如果找到同名信息,就提示是否更新
|
||||
YesNoAlertDialog.show(mContext, "Ask Update Password", "Is update " + item.getUserName() + " Password?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
@Override
|
||||
public void onNo() {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
item.setPassword(szPassword);
|
||||
AuthenticationBean.saveBeanListToFile(_mBeanPath, mData);
|
||||
putAuthenticationBeanToTheFirstPosition(item);
|
||||
return;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
putAuthenticationBeanToTheFirstPosition(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找不到同名信息,就新建一个
|
||||
if (!isFindUserName) {
|
||||
AuthenticationBean bean = new AuthenticationBean(szHost, szRealm, szUserName, szPassword);
|
||||
mData.add(bean);
|
||||
AuthenticationBean.saveBeanListToFile(_mBeanPath, mData);
|
||||
putAuthenticationBeanToTheFirstPosition(bean);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
package cc.winboll.studio.webpagesources.common;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/06/22 15:01:43
|
||||
* @Describe 下载线程基类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
abstract public class BaseDownLoadThread implements Runnable {
|
||||
|
||||
public static final String TAG = "BaseDownLoadThread";
|
||||
|
||||
Context mContext;
|
||||
//UserLogonUtil mUserLogonUtil;
|
||||
String mszUrl;
|
||||
String mszDowndloadName;
|
||||
protected File mfDownloadDir;
|
||||
protected File mfDownloadFile;
|
||||
|
||||
//
|
||||
// 构造函数
|
||||
//
|
||||
public BaseDownLoadThread(Context context) {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// 构造函数
|
||||
//
|
||||
public BaseDownLoadThread(Context context, String szUrl) {
|
||||
mContext = context;
|
||||
File fDownloadDir = new File(context.getExternalCacheDir(), "Download");
|
||||
initDownLoadEnvironment(fDownloadDir, szUrl);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 构造函数
|
||||
//
|
||||
public BaseDownLoadThread(Context context, String szUrl, String szDowndloadName) {
|
||||
mContext = context;
|
||||
mszDowndloadName = szDowndloadName;
|
||||
File fDownloadDir = new File(context.getExternalCacheDir(), "Download");
|
||||
initDownLoadEnvironment(fDownloadDir, szUrl);
|
||||
}
|
||||
|
||||
//
|
||||
// 构造函数
|
||||
//
|
||||
public BaseDownLoadThread(File fDownloadDir, String szUrl) {
|
||||
initDownLoadEnvironment(fDownloadDir, szUrl);
|
||||
}
|
||||
|
||||
//
|
||||
// 初始化下载环境参数
|
||||
//
|
||||
void initDownLoadEnvironment(File fDownloadDir, String szUrl) {
|
||||
mfDownloadDir = fDownloadDir;
|
||||
//LogUtils.d(TAG, "mfDownloadDir is : " + mfDownloadDir);
|
||||
if (!mfDownloadDir.exists()) {
|
||||
mfDownloadDir.mkdir();
|
||||
}
|
||||
this.mszUrl = szUrl;
|
||||
//LogUtils.d(TAG, "mszUrl is : " + mszUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//LogUtils.d(TAG, "DownLoad Start : " + mszUrl);
|
||||
InputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try {
|
||||
//LogUtils.d(TAG, "mszUrl is " + mszUrl);
|
||||
URL httpUrl = new URL(mszUrl);
|
||||
HttpURLConnection conn = (HttpURLConnection) httpUrl.openConnection();
|
||||
//conn.setRequestProperty(UserLogonUtil.getInstance(mContext).getWinBollAppHeaderKey(),
|
||||
// UserLogonUtil.getInstance(mContext).getWinBollAppHeaderValue());
|
||||
conn.setDoInput(true);
|
||||
conn.setDoOutput(false);
|
||||
in = conn.getInputStream();
|
||||
|
||||
// 打印 Header Fields
|
||||
/*Map<String, List<String>> map = conn.getHeaderFields();
|
||||
for (String str : map.keySet()) {
|
||||
if (str != null) {
|
||||
LogUtils.d(TAG, str + map.get(str));
|
||||
}
|
||||
}*/
|
||||
|
||||
// 设置文件名
|
||||
//URL absUrl = conn.getURL();
|
||||
String filename = "";
|
||||
|
||||
// 文件名生成方法 1
|
||||
// 读取 Content-Disposition
|
||||
try {
|
||||
//LogUtils.d(TAG, "文件名生成方法 1");
|
||||
// 通过Content-Disposition获取文件名,这点跟服务器有关,需要灵活变通
|
||||
String szTemp = conn.getHeaderField("Content-Disposition");
|
||||
if (szTemp != null) {
|
||||
String szSearch = "filename=\"";
|
||||
int nSearchStart = szTemp.indexOf(szSearch);
|
||||
int nFileNameStart = nSearchStart + szSearch.length();
|
||||
//LogUtils.d(TAG, "nFileNameStart : " + Integer.toString(nFileNameStart));
|
||||
int nFileNameEnd = szTemp.indexOf("\"", nFileNameStart);
|
||||
//LogUtils.d(TAG, "nFileNameEnd : " + Integer.toString(nFileNameEnd));
|
||||
filename = szTemp.substring(nFileNameStart, nFileNameEnd);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
}
|
||||
//LogUtils.d(TAG, "filename is : " + filename);
|
||||
|
||||
// 文件名生成方法 2
|
||||
// 读取 mszUrl
|
||||
// 如果文件名包含"/"字符
|
||||
// (例如 https://studio.zhangsken.cc/gitweb/libapputils.git/blob_plain/2aa898149aa7f0e34fe5bc11b2e70187f9f206bc:/libapputils/src/main/java/cc/winboll/studio/libapputils/LogView.java
|
||||
// 的文件名方法1就得到"filename is : libapputils/src/main/java/cc/winboll/studio/libapputils/LogView.java")
|
||||
// 或者为空就执行以下函数段
|
||||
if ((filename.lastIndexOf("/") > 0)
|
||||
|| filename.trim().equals("")) {
|
||||
//LogUtils.d(TAG, "文件名生成方法 2");
|
||||
// 示例 https://studio.zhangsken.cc/gitweb/libaes.git/rss
|
||||
// 截取最后的名称"rss"。
|
||||
// 示例 https://studio.zhangsken.cc/gitweb/libaes.git/
|
||||
// 最后是反斜杆结尾。就截取最后两个斜杆之间的名称"libaes.git"。
|
||||
Pattern pattern = Pattern.compile(".*[/]([^/]+)[/]?$", Pattern.MULTILINE);
|
||||
Matcher matcher = pattern.matcher(mszUrl);
|
||||
if (matcher.find()) {
|
||||
filename = matcher.replaceAll("$1");
|
||||
}
|
||||
|
||||
//LogUtils.d(TAG, "转化文件名为可操作易读写格式");
|
||||
//LogUtils.d(TAG, "filename is : " + filename);
|
||||
// 转化文件名为可操作易读写格式
|
||||
String filenameTemp = URLDecoder.decode(filename, "UTF-8");
|
||||
//filenameTemp = filenameTemp.replace("/", "_");
|
||||
//filename = filenameTemp.replace(".", "-");
|
||||
filename = filenameTemp;
|
||||
|
||||
// 如果文件名没有".*"后缀,就加上".dat"后缀
|
||||
if (filename.lastIndexOf(".") < 0) {
|
||||
filename += ".dat";
|
||||
}
|
||||
}
|
||||
//LogUtils.d(TAG, "filename is : " + filename);
|
||||
|
||||
// 如果指定了保存名称就用指定的名称
|
||||
if (mszDowndloadName != null && !mszDowndloadName.equals("")) {
|
||||
filename = mszDowndloadName;
|
||||
}
|
||||
|
||||
mfDownloadFile = createSavedFile(filename);
|
||||
// 如果文件存在就退出,没有就创建一个并下载
|
||||
if (mfDownloadFile.exists()) {
|
||||
LogUtils.d(TAG, "mfDownloadFile : " + mfDownloadFile.getPath());
|
||||
fout = new FileOutputStream(mfDownloadFile);
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buffer)) != -1) {
|
||||
fout.write(buffer, 0, len);
|
||||
}
|
||||
LogUtils.i(TAG, "DownLoad is well done : " + mfDownloadFile.getPath());
|
||||
// 处理接收到的项目列表文件
|
||||
handleDownloadFile();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
if (fout != null) {
|
||||
try {
|
||||
fout.close();
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e.getMessage(), Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
File createSavedFile(String szOriginDownloadName) {
|
||||
File fOriginDownload = new File(mfDownloadDir, szOriginDownloadName);
|
||||
if (!fOriginDownload.exists()) {
|
||||
// 如果该文件名的文件不存在,就表示可以保存为该文件名
|
||||
// 预先创建新文件
|
||||
try {
|
||||
fOriginDownload.createNewFile();
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return fOriginDownload;
|
||||
}
|
||||
|
||||
// 校验文件是否已存在,若存在就重命名新文件名
|
||||
File fCheck = fOriginDownload;
|
||||
int nAddName = 1;
|
||||
while (fCheck.exists()) {
|
||||
int nPoint = szOriginDownloadName.lastIndexOf(".");
|
||||
if (nPoint > -1) {
|
||||
LogUtils.d(TAG, "nPoint > -1");
|
||||
fCheck = new File(mfDownloadDir, File.separator + szOriginDownloadName.substring(0, nPoint) + "(" + Integer.toString(nAddName) + ")." + szOriginDownloadName.substring(nPoint + 1));
|
||||
} else {
|
||||
LogUtils.d(TAG, "nPoint > -1 else");
|
||||
fCheck = new File(mfDownloadDir, File.separator + szOriginDownloadName + "(" + Integer.toString(nAddName) + ")");
|
||||
}
|
||||
LogUtils.d(TAG, "nAddName++");
|
||||
nAddName++;
|
||||
}
|
||||
// 预先创建新文件
|
||||
try {
|
||||
fCheck.createNewFile();
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return fCheck;
|
||||
}
|
||||
|
||||
//
|
||||
// 文件下载后的文件处理函数
|
||||
//
|
||||
abstract protected void handleDownloadFile();
|
||||
|
||||
}
|
@ -0,0 +1,392 @@
|
||||
package cc.winboll.studio.webpagesources.common;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.ValueCallback;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.GestureDetectorCompat;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.webpagesources.MainActivity;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.thread.LinkDownLoadThread;
|
||||
import cc.winboll.studio.webpagesources.util.UIUtil;
|
||||
import cc.winboll.studio.webpagesources.view.ItemLongClickedPopWindow;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class BaseWebView extends WebView {
|
||||
|
||||
public static final String TAG = "BaseWebView";
|
||||
|
||||
public static final int WEB_CopyLink = 0;
|
||||
public static final int WEB_DownLoadLink = 1;
|
||||
|
||||
protected Context mContext;
|
||||
static String _mszLastUrl = "";
|
||||
IOnPageFinished mIOnPageFinished;
|
||||
protected MyWebChromeClient mMyWebChromeClient;
|
||||
protected BaseWebViewClient mBaseWebViewClient;
|
||||
protected BaseWebViewHandler mBaseWebViewHandler;
|
||||
private int downX, downY;
|
||||
private GestureDetectorCompat mGestureDetector;
|
||||
ValueCallback<Uri[]> mFilePathCallback;
|
||||
WebChromeClient.FileChooserParams mFileChooserParams;
|
||||
|
||||
AuthLoginDialog mAuthLoginDialog;
|
||||
|
||||
public BaseWebView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public BaseWebView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
|
||||
mBaseWebViewHandler = new BaseWebViewHandler();
|
||||
MyWebChromeClient mMyWebChromeClient = new MyWebChromeClient();
|
||||
setWebChromeClient(mMyWebChromeClient);
|
||||
mBaseWebViewClient = new BaseWebViewClient();
|
||||
setWebViewClient(mBaseWebViewClient);
|
||||
|
||||
WebSettings mWebSettings = getSettings();
|
||||
|
||||
// ------------------- 优化后的 WebSettings 配置 -------------------
|
||||
// 基础功能配置
|
||||
mWebSettings.setJavaScriptEnabled(true); // 启用JavaScript
|
||||
mWebSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 允许JS打开新窗口
|
||||
mWebSettings.setDomStorageEnabled(true); // 启用DOM存储
|
||||
mWebSettings.setDatabaseEnabled(true); // 启用数据库存储
|
||||
//mWebSettings.setAppCacheEnabled(true); // 启用应用缓存
|
||||
String appCachePath = context.getCacheDir().getAbsolutePath();
|
||||
//mWebSettings.setAppCachePath(appCachePath);
|
||||
mWebSettings.setCacheMode(WebSettings.LOAD_DEFAULT); // 缓存模式
|
||||
|
||||
// 页面渲染与缩放
|
||||
mWebSettings.setUseWideViewPort(true); // 支持viewport标签
|
||||
mWebSettings.setLoadWithOverviewMode(true); // 自动加载时适应屏幕
|
||||
mWebSettings.setSupportZoom(true); // 支持缩放
|
||||
mWebSettings.setBuiltInZoomControls(true); // 显示缩放控件
|
||||
mWebSettings.setDisplayZoomControls(false); // 隐藏默认缩放控件
|
||||
mWebSettings.setDefaultTextEncodingName("utf-8"); // 默认编码
|
||||
mWebSettings.setMinimumFontSize(12); // 最小字体大小
|
||||
|
||||
// 性能优化
|
||||
mWebSettings.setLoadsImagesAutomatically(true); // 自动加载图片
|
||||
mWebSettings.setBlockNetworkImage(false); // 不阻止图片加载
|
||||
mWebSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); // 高渲染优先级
|
||||
|
||||
// 混合内容配置(Android 5.0+)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mWebSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
}
|
||||
|
||||
// 安全配置
|
||||
mWebSettings.setSafeBrowsingEnabled(true); // 启用安全浏览
|
||||
mWebSettings.setAllowFileAccess(true); // 允许访问文件URL
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
mWebSettings.setAllowFileAccessFromFileURLs(false); // 禁止文件URL访问其他文件
|
||||
mWebSettings.setAllowUniversalAccessFromFileURLs(false); // 禁止文件URL执行JS
|
||||
}
|
||||
|
||||
// 高级功能(可选)
|
||||
mWebSettings.setGeolocationEnabled(true); // 启用地理位置
|
||||
mWebSettings.setNeedInitialFocus(true); // 获取初始焦点
|
||||
mWebSettings.setSaveFormData(true); // 保存表单数据
|
||||
mWebSettings.setEnableSmoothTransition(true); // 平滑过渡动画
|
||||
|
||||
// 硬件加速(Android 3.0+)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
|
||||
// 字体缩放(100%为默认)
|
||||
mWebSettings.setTextZoom(100);
|
||||
// ------------------- WebSettings 配置结束 -------------------
|
||||
|
||||
mWebSettings.setSafeBrowsingEnabled(true);
|
||||
addJavascriptInterface(new JSConsole(mContext), "console");
|
||||
addJavascriptInterface(new JS(mContext), "local_obj");
|
||||
|
||||
setInitialScale(60);
|
||||
|
||||
mGestureDetector = new GestureDetectorCompat(mContext, new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public void onLongPress(MotionEvent e) {
|
||||
downX = (int) e.getX();
|
||||
downY = (int) e.getY();
|
||||
}
|
||||
});
|
||||
|
||||
setOnLongClickListener(new View.OnLongClickListener() {
|
||||
String szUrl = "";
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
|
||||
WebView.HitTestResult result = ((WebView)v).getHitTestResult();
|
||||
if (null == result)
|
||||
return false;
|
||||
int type = result.getType();
|
||||
if (type == WebView.HitTestResult.UNKNOWN_TYPE)
|
||||
return false;
|
||||
if (type == WebView.HitTestResult.EDIT_TEXT_TYPE) {
|
||||
}
|
||||
final ItemLongClickedPopWindow itemLongClickedPopWindow = new ItemLongClickedPopWindow(mContext, ItemLongClickedPopWindow.IMAGE_VIEW_POPUPWINDOW, UIUtil.dip2px(mContext, 180), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
szUrl = result.getExtra();
|
||||
|
||||
itemLongClickedPopWindow.showAtLocation(v, Gravity.TOP | Gravity.LEFT, downX, downY + 10);
|
||||
|
||||
itemLongClickedPopWindow.getView(R.id.item_longclicked_copylink)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("simple text", szUrl);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(mContext, "Copy to clipboard.", Toast.LENGTH_SHORT).show();
|
||||
itemLongClickedPopWindow.dismiss();
|
||||
}
|
||||
});
|
||||
itemLongClickedPopWindow.getView(R.id.item_longclicked_downloadlink)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
itemLongClickedPopWindow.dismiss();
|
||||
new Thread(new LinkDownLoadThread(szUrl)).start();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public BaseWebView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public String getLastUrl() {
|
||||
return _mszLastUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadUrl(String url) {
|
||||
MainActivity.postStatusBarMessage(String.format("正在加载:%s", url));
|
||||
Pattern patternHttp = Pattern.compile("(?i)^http[s]{0,1}://", Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcherHttp = patternHttp.matcher(url);
|
||||
if (matcherHttp.matches()) {
|
||||
stopLoading();
|
||||
loadUrl(url);
|
||||
return;
|
||||
} else {
|
||||
Pattern pattern = Pattern.compile("^[a-z]+:.*", Pattern.MULTILINE);
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
if (matcher.find()) {
|
||||
super.loadUrl(url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setFilePathCallback(ValueCallback<Uri[]> mFilePathCallback) {
|
||||
this.mFilePathCallback = mFilePathCallback;
|
||||
}
|
||||
|
||||
public ValueCallback<Uri[]> getFilePathCallback() {
|
||||
return mFilePathCallback;
|
||||
}
|
||||
|
||||
public void setFileChooserParams(WebChromeClient.FileChooserParams mFileChooserParams) {
|
||||
this.mFileChooserParams = mFileChooserParams;
|
||||
}
|
||||
|
||||
public WebChromeClient.FileChooserParams getFileChooserParams() {
|
||||
return mFileChooserParams;
|
||||
}
|
||||
|
||||
private class MyWebChromeClient extends WebChromeClient {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
|
||||
setFilePathCallback(filePathCallback);
|
||||
setFileChooserParams(fileChooserParams);
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("*/*");
|
||||
((AppCompatActivity)mContext).startActivityForResult(intent, MainActivity.REQUEST_FILE_CHOOSER);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean ret = mGestureDetector.onTouchEvent(event);
|
||||
LogUtils.d(TAG, String.format("onTouchEvent ret : %s", ret));
|
||||
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
class BaseWebViewHandler extends Handler {
|
||||
|
||||
public static final String TAG = "BaseWebViewHandler";
|
||||
|
||||
public static final int MSG_RELOAD_LOG = 0X100;
|
||||
public static final int MSG_SHOW_DATA = 0X123;
|
||||
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_SHOW_DATA:{
|
||||
loadDataWithBaseURL("", (String)msg.obj, "text/html", "UTF-8", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
final class InJavaScriptLocalObj {
|
||||
@JavascriptInterface
|
||||
public void getSource(String html) {
|
||||
}
|
||||
}
|
||||
|
||||
public class MyDownLoadListener implements DownloadListener {
|
||||
private Context mContext;
|
||||
|
||||
public MyDownLoadListener(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
|
||||
Uri uri = Uri.parse(url);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
class BaseWebViewClient extends WebViewClient {
|
||||
|
||||
public static final String TAG = "BaseWebViewClient";
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
view.loadUrl("javascript:window.local_obj.showSource('<head>'+" +
|
||||
"document.getElementsByTagName('html')[0].innerHTML+'</head>');");
|
||||
super.onPageFinished(view, url);
|
||||
mIOnPageFinished.onPageFinished(url);
|
||||
LogUtils.d(TAG, "Page load finished : " + url);
|
||||
_mszLastUrl = url;
|
||||
MainActivity.postStatusBarMessage(String.format("加载完成:%s", url));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||
//SSL证书错误修复方法:
|
||||
//网站证书下载网站是https://www.ssleye.com/ssltool/certs_down.html
|
||||
//使用该网站访问要获取证书的主机
|
||||
//获取证书后导出证书到 res/raw/<标识名称>.cer
|
||||
//再在res/xml/network_security_config.xml配置网站证书设置。
|
||||
ToastUtils.show("SSL证书错误!");
|
||||
LogUtils.d(TAG, "SSL证书错误! onReceivedSslError 0\nerror : " + error.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||
int statusCode = errorResponse.getStatusCode();
|
||||
LogUtils.d(TAG, "onReceivedHttpError statusCode " + Integer.toString(statusCode));
|
||||
super.onReceivedHttpError(view, request, errorResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, int errorCode,
|
||||
String description, String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
LogUtils.d(TAG, "onReceivedError 1\nerrorCode : " + errorCode
|
||||
+ "\ndescription :" + description + "\nfailingUrl : " + failingUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||
super.onReceivedError(view, request, error);
|
||||
LogUtils.d(TAG, "onReceivedError 2\nUrl : " + request.getUrl()
|
||||
+ "\nErrorCode : " + error.getErrorCode()
|
||||
+ "\nDescription : " + error.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedLoginRequest(WebView view, String realm, String account, String args) {
|
||||
super.onReceivedLoginRequest(view, realm, account, args);
|
||||
LogUtils.d(TAG, "onReceivedLoginRequest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadResource(WebView view, String url) {
|
||||
super.onLoadResource(view, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpAuthRequest(WebView view,
|
||||
HttpAuthHandler handler, String host, String realm) {
|
||||
mAuthLoginDialog = new AuthLoginDialog(view, handler, host, realm);
|
||||
mAuthLoginDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
LogUtils.d(TAG, "Page load started : " + url);
|
||||
_mszLastUrl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||
// 修复Android 5.0点击无反应的问题
|
||||
view.loadUrl(request.getUrl().toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IOnPageFinished {
|
||||
void onPageFinished(String url);
|
||||
}
|
||||
|
||||
public void setOnPageFinished(IOnPageFinished iOnPageFinished) {
|
||||
mIOnPageFinished = iOnPageFinished;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package cc.winboll.studio.webpagesources.common;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/07/13 13:54:13
|
||||
* @Describe 获取网页内容的接口类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import cc.winboll.studio.webpagesources.fragment.SourcesFragment;
|
||||
|
||||
public final class JS {
|
||||
|
||||
public static final String TAG = "JS";
|
||||
|
||||
Context mContext;
|
||||
|
||||
public JS(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@SuppressWarnings("unused")
|
||||
public void showSource(String html) {
|
||||
//LogUtils.d(TAG, "showSource");
|
||||
SourcesFragment.sendSourcesUpdateMessage(html);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cc.winboll.studio.webpagesources.common;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/23 02:15:03
|
||||
* @Describe Javascript Console Log 接收类。
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
public class JSConsole {
|
||||
|
||||
public static final String TAG = "JSConsole";
|
||||
|
||||
Context mContext;
|
||||
|
||||
public JSConsole(Context context) {
|
||||
//LogUtils.d(TAG, "JSConsole(Context context)");
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@SuppressWarnings("unused")
|
||||
public void log(String tag, String message) {
|
||||
LogUtils.i(TAG, "console.log(...)\n" + tag + " : " + message);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@SuppressWarnings("unused")
|
||||
public void log(String message) {
|
||||
LogUtils.i(TAG, "console.log(...)\n" + message);
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package cc.winboll.studio.webpagesources.fragment;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/07/04 13:45:57
|
||||
* @Describe 网页源码视图 Fragment
|
||||
*/
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.handler.SourcesFragmentHandler;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
public class SourcesFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "SourcesFragment";
|
||||
|
||||
View mView;
|
||||
EditText mEditText;
|
||||
String mszHtmlPath;
|
||||
String mszHtmlFileName;
|
||||
static SourcesFragmentHandler _mSourcesFragmentHandler;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//return super.onCreateView(inflater, container, savedInstanceState);
|
||||
mView = inflater.inflate(R.layout.fragment_sources, container, false);
|
||||
mEditText = mView.findViewById(R.id.fragmentsourcesEditText1);
|
||||
|
||||
_mSourcesFragmentHandler = new SourcesFragmentHandler(this);
|
||||
mszHtmlFileName = getString(R.string.app_name) + ".html";
|
||||
mszHtmlPath = getActivity().getExternalFilesDir(TAG) + "/" + mszHtmlFileName;
|
||||
|
||||
return mView;
|
||||
}
|
||||
|
||||
public void showCurrentWebPageHtml(String szHtml) {
|
||||
/*File fHtml = new File(App._fTempHtmlPath);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
BufferedReader in = null;
|
||||
in = new BufferedReader(new InputStreamReader(new FileInputStream(fHtml), "UTF-8"));
|
||||
String line = "";
|
||||
while ((line = in.readLine()) != null) {
|
||||
sb.append(line);
|
||||
sb.append("\n");
|
||||
}
|
||||
mEditText.setText(sb.toString());
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, "IOException : " + e.getMessage());
|
||||
}*/
|
||||
mEditText.setText(szHtml);
|
||||
}
|
||||
|
||||
public void shareHtml() {
|
||||
saveHtml(mEditText.getText().toString());
|
||||
|
||||
Uri uri;
|
||||
File file = new File(mszHtmlPath);
|
||||
if (Build.VERSION.SDK_INT >= 24) {//android 7.0以上
|
||||
uri = FileProvider.getUriForFile(getActivity().getApplicationContext(), getActivity().getApplicationContext().getPackageName() + ".fileprovider", file);
|
||||
} else {
|
||||
uri = Uri.fromFile(file);
|
||||
}
|
||||
Intent shareIntent = new Intent("android.intent.action.VIEW");
|
||||
shareIntent.setDataAndType(uri, "text/html");
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
startActivity(Intent.createChooser(shareIntent, mszHtmlFileName));
|
||||
}
|
||||
|
||||
public static void sendSourcesUpdateMessage(String szHtml) {
|
||||
if (_mSourcesFragmentHandler != null) {
|
||||
Message message = _mSourcesFragmentHandler.obtainMessage(SourcesFragmentHandler.MSG_UPDATE);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SourcesFragmentHandler.BUNDLE_KEY_HTML, szHtml);
|
||||
message.setData(bundle);
|
||||
_mSourcesFragmentHandler.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
void saveHtml(String szHtml) {
|
||||
try {
|
||||
File fTempHtml = new File(mszHtmlPath);
|
||||
if (fTempHtml.exists()) {
|
||||
fTempHtml.delete();
|
||||
}
|
||||
BufferedWriter out = null;
|
||||
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fTempHtml, false), "UTF-8"));
|
||||
out.write(szHtml);
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, "IOException : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package cc.winboll.studio.webpagesources.fragment;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/07/04 13:45:32
|
||||
* @Describe 网页浏览视图 Fragment
|
||||
*/
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.libaes.views.AButton;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import cc.winboll.studio.webpagesources.common.BaseWebView;
|
||||
import cc.winboll.studio.webpagesources.view.URLAddressView;
|
||||
import com.baoyz.widget.PullRefreshLayout;
|
||||
|
||||
public class WebFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "WebFragment";
|
||||
|
||||
View mView;
|
||||
BaseWebView mBaseWebView;
|
||||
URLAddressView mURLAddressView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//return super.onCreateView(inflater, container, savedInstanceState);
|
||||
mView = inflater.inflate(R.layout.fragment_web, container, false);
|
||||
|
||||
mURLAddressView = mView.findViewById(R.id.fragmentwebURLAddressView1);
|
||||
mURLAddressView.initAnchorView((LinearLayout)mView.findViewById(R.id.fragmentwebLinearLayout1));
|
||||
|
||||
AButton btnGoback = mView.findViewById(R.id.fragmentwebAButton1);
|
||||
btnGoback.setOnClickListener(new AButton.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mBaseWebView.goBack();
|
||||
}
|
||||
});
|
||||
AButton btnGoForward = mView.findViewById(R.id.fragmentwebAButton2);
|
||||
btnGoForward.setOnClickListener(new AButton.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mURLAddressView.getURLAddressText().equals(mBaseWebView.getUrl())) {
|
||||
mBaseWebView.goForward();
|
||||
} else {
|
||||
mBaseWebView.stopLoading();
|
||||
mBaseWebView.loadUrl(mURLAddressView.getURLAddressText());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
AButton btnReload = mView.findViewById(R.id.fragmentwebAButton3);
|
||||
btnReload.setOnClickListener(new AButton.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mBaseWebView.stopLoading();
|
||||
mBaseWebView.clearCache(true);
|
||||
mBaseWebView.reload();
|
||||
}
|
||||
});
|
||||
AButton btnStopLoading = mView.findViewById(R.id.fragmentwebAButton4);
|
||||
btnStopLoading.setOnClickListener(new AButton.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mBaseWebView.stopLoading();
|
||||
}
|
||||
});
|
||||
|
||||
mBaseWebView = mView.findViewById(R.id.fragmentwebBaseWebView1);
|
||||
mBaseWebView.setOnPageFinished(new BaseWebView.IOnPageFinished(){
|
||||
@Override
|
||||
public void onPageFinished(String url) {
|
||||
mURLAddressView.setURLAddressText(url);
|
||||
}
|
||||
});
|
||||
|
||||
final PullRefreshLayout layout = mView.findViewById(R.id.fragmentwebPullRefreshLayout1);
|
||||
// listen refresh event
|
||||
layout.setOnRefreshListener(new PullRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
// start refresh
|
||||
mBaseWebView.stopLoading();
|
||||
mBaseWebView.clearCache(true);
|
||||
mBaseWebView.reload();
|
||||
layout.setRefreshing(false);
|
||||
}
|
||||
});
|
||||
return mView;
|
||||
}
|
||||
|
||||
public BaseWebView getWebView() {
|
||||
return mBaseWebView;
|
||||
}
|
||||
|
||||
public void loadUrl(String szUrl) {
|
||||
if(mBaseWebView != null) {
|
||||
mBaseWebView.loadUrl(szUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadLastUrl() {
|
||||
mBaseWebView.stopLoading();
|
||||
mBaseWebView.loadUrl(mBaseWebView.getLastUrl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (mBaseWebView != null) {
|
||||
mBaseWebView.destroy();
|
||||
|
||||
ViewParent parent = mBaseWebView.getParent();
|
||||
if (parent != null) {
|
||||
((ViewGroup) parent).removeView(mBaseWebView);
|
||||
}
|
||||
mBaseWebView.stopLoading();
|
||||
// 退出时调用此方法,移除绑定的服务,否则某些特定系统会报错
|
||||
mBaseWebView.getSettings().setJavaScriptEnabled(false);
|
||||
mBaseWebView.clearHistory();
|
||||
mBaseWebView.clearView();
|
||||
mBaseWebView.removeAllViews();
|
||||
mBaseWebView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cc.winboll.studio.webpagesources.handler;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/07/13 15:43:48
|
||||
* @Describe 源码视图窗口事务处理类
|
||||
*/
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import cc.winboll.studio.webpagesources.fragment.SourcesFragment;
|
||||
|
||||
public class SourcesFragmentHandler extends Handler {
|
||||
|
||||
public static final String TAG = "SourcesFragmentHandler";
|
||||
|
||||
public static final int MSG_UPDATE = 0;
|
||||
public static final String BUNDLE_KEY_HTML = "BUNDLE_KEY_HTML";
|
||||
|
||||
SourcesFragment mSourcesFragment;
|
||||
public SourcesFragmentHandler(SourcesFragment fragment) {
|
||||
mSourcesFragment = fragment;
|
||||
}
|
||||
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case MSG_UPDATE:{
|
||||
Bundle bundle = msg.getData();
|
||||
String szHtml = (String)bundle.getSerializable(BUNDLE_KEY_HTML);
|
||||
mSourcesFragment.showCurrentWebPageHtml(szHtml);
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package cc.winboll.studio.webpagesources.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2024/08/26 15:43:22
|
||||
* @Describe 验证信息数据类
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AuthenticationBean extends BaseBean {
|
||||
|
||||
public static final String TAG = "AuthenticationBean";
|
||||
|
||||
// 主机名
|
||||
String host;
|
||||
// 认证区域
|
||||
String realm;
|
||||
// 用户名
|
||||
String userName;
|
||||
// 密码
|
||||
String password;
|
||||
|
||||
public AuthenticationBean(String host, String realm, String userName, String password) {
|
||||
this.host = host;
|
||||
this.realm = realm;
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public AuthenticationBean(AuthenticationBean bean) {
|
||||
this.host = bean.getHost();
|
||||
this.realm = bean.getRealm();
|
||||
this.userName = bean.getUserName();
|
||||
this.password = bean.getPassword();
|
||||
}
|
||||
|
||||
public AuthenticationBean() {
|
||||
this.host = "";
|
||||
this.realm = "";
|
||||
this.userName = "";
|
||||
this.password = "";
|
||||
}
|
||||
|
||||
public void setRealm(String realm) {
|
||||
this.realm = realm;
|
||||
}
|
||||
|
||||
public String getRealm() {
|
||||
return realm;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AuthenticationBean.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
AuthenticationBean bean = this;
|
||||
jsonWriter.name("host").value(bean.getHost());
|
||||
jsonWriter.name("realm").value(bean.getRealm());
|
||||
jsonWriter.name("userName").value(bean.getUserName());
|
||||
jsonWriter.name("password").value(bean.getPassword());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("host")) {
|
||||
setHost(jsonReader.nextString());
|
||||
} else if (name.equals("realm")) {
|
||||
setRealm(jsonReader.nextString());
|
||||
} else if (name.equals("userName")) {
|
||||
setUserName(jsonReader.nextString());
|
||||
} else if (name.equals("password")) {
|
||||
setPassword(jsonReader.nextString());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cc.winboll.studio.webpagesources.thread;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/06/22 21:19:59
|
||||
* @Describe 链接下载进程类
|
||||
*/
|
||||
import android.os.Environment;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.webpagesources.common.BaseDownLoadThread;
|
||||
import java.io.File;
|
||||
|
||||
public class LinkDownLoadThread extends BaseDownLoadThread {
|
||||
|
||||
public static final String TAG = "LinkDownLoadThread";
|
||||
|
||||
public LinkDownLoadThread(String szUrl) {
|
||||
super(new File(Environment.getExternalStorageDirectory(), "Download"), szUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleDownloadFile() {
|
||||
LogUtils.d(TAG, "handleDownloadFile");
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cc.winboll.studio.webpagesources.util;
|
||||
|
||||
/*
|
||||
* 网站证书校验工具类
|
||||
* Power By :
|
||||
* ZhanGSKen@QQ.COM
|
||||
* https://blog.csdn.net/
|
||||
* https://blog.csdn.net/lsyz0021/article/details/54669914
|
||||
*
|
||||
*/
|
||||
import android.net.http.SslCertificate;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SSLUtil {
|
||||
public static final String TAG = "SSLUtil";
|
||||
|
||||
/**
|
||||
* SSL证书错误,手动校验https证书
|
||||
*
|
||||
* @param cert https证书
|
||||
* @param sha256Str sha256值
|
||||
* @return true通过,false失败
|
||||
*/
|
||||
public static boolean isSSLCertOk(SslCertificate cert, String sha256Str) {
|
||||
byte[] SSLSHA256 = hexToBytes(sha256Str.toLowerCase());
|
||||
Bundle bundle = SslCertificate.saveState(cert);
|
||||
if (bundle != null) {
|
||||
byte[] bytes = bundle.getByteArray("x509-certificate");
|
||||
if (bytes != null) {
|
||||
try {
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
Certificate ca = cf.generateCertificate(new ByteArrayInputStream(bytes));
|
||||
MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
|
||||
byte[] key = sha256.digest(((X509Certificate) ca).getEncoded());
|
||||
return Arrays.equals(key, SSLSHA256);
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "Exception : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* hexString转byteArr
|
||||
* <p>例如:</p>
|
||||
* hexString2Bytes("00A8") returns { 0, (byte) 0xA8 }
|
||||
*
|
||||
* @param hexString
|
||||
* @return 字节数组
|
||||
*/
|
||||
public static byte[] hexToBytes(String hexString) {
|
||||
|
||||
if (hexString == null || hexString.trim().length() == 0)
|
||||
return null;
|
||||
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] bytes = new byte[length];
|
||||
String hexDigits = "0123456789abcdef";
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2; // 两个字符对应一个byte
|
||||
int h = hexDigits.indexOf(hexChars[pos]) << 4; // 注1
|
||||
int l = hexDigits.indexOf(hexChars[pos + 1]); // 注2
|
||||
if (h == -1 || l == -1) { // 非16进制字符
|
||||
return null;
|
||||
}
|
||||
bytes[i] = (byte) (h | l);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cc.winboll.studio.webpagesources.util;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/06/23 03:57:30
|
||||
* @Describe 视图辅助工具类
|
||||
*/
|
||||
import android.content.Context;
|
||||
|
||||
public class UIUtil {
|
||||
|
||||
public static final String TAG = "UIUtil";
|
||||
|
||||
public static int dip2px(Context context, float dpValue) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package cc.winboll.studio.webpagesources.view;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/06/23 03:45:50
|
||||
* @Describe 网页浏览长按弹出菜单类
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.PopupWindow;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
|
||||
public class ItemLongClickedPopWindow extends PopupWindow {
|
||||
/**
|
||||
* 书签条目弹出菜单 * @value * {@value} *
|
||||
*/
|
||||
public static final int FAVORITES_ITEM_POPUPWINDOW = 0;
|
||||
/**
|
||||
* 书签页面弹出菜单 * @value * {@value} *
|
||||
*/
|
||||
public static final int FAVORITES_VIEW_POPUPWINDOW = 1;
|
||||
/**
|
||||
* 历史条目弹出菜单 * @value * {@value} *
|
||||
*/
|
||||
public static final int HISTORY_ITEM_POPUPWINDOW = 3;
|
||||
/**
|
||||
* 历史页面弹出菜单 * @value * {@value} *
|
||||
*/
|
||||
public static final int HISTORY_VIEW_POPUPWINDOW = 4;
|
||||
/**
|
||||
* 图片项目弹出菜单 * @value * {@value} *
|
||||
*/
|
||||
public static final int IMAGE_VIEW_POPUPWINDOW = 5;
|
||||
/**
|
||||
* 超链接项目弹出菜单 * @value * {@value} *
|
||||
*/
|
||||
public static final int ACHOR_VIEW_POPUPWINDOW = 6;
|
||||
private LayoutInflater itemLongClickedPopWindowInflater;
|
||||
private View itemLongClickedPopWindowView;
|
||||
private Context context;
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 构造函数 * @param context 上下文 * @param width 宽度 * @param height 高度 *
|
||||
*/
|
||||
public ItemLongClickedPopWindow(Context context, int type, int width, int height) {
|
||||
super(context);
|
||||
this.context = context;
|
||||
this.type = type;
|
||||
//创建
|
||||
this.initTab();
|
||||
//设置默认选项
|
||||
setWidth(width);
|
||||
setHeight(height);
|
||||
setContentView(this.itemLongClickedPopWindowView);
|
||||
setOutsideTouchable(true);
|
||||
setFocusable(true);
|
||||
}
|
||||
|
||||
//实例化
|
||||
private void initTab() {
|
||||
this.itemLongClickedPopWindowInflater = LayoutInflater.from(this.context);
|
||||
switch (type) {
|
||||
// case FAVORITES_ITEM_POPUPWINDOW:
|
||||
// this.itemLongClickedPopWindowView = this.itemLongClickedPopWindowInflater.inflate(R.layout.list_item_longclicked_favorites, null);
|
||||
// break;
|
||||
// case FAVORITES_VIEW_POPUPWINDOW: //对于书签内容弹出菜单,未作处理
|
||||
// break;
|
||||
// case HISTORY_ITEM_POPUPWINDOW:
|
||||
// this.itemLongClickedPopWindowView = this.itemLongClickedPopWindowInflater.inflate(R.layout.list_item_longclicked_history, null);
|
||||
// break;
|
||||
// case HISTORY_VIEW_POPUPWINDOW: //对于历史内容弹出菜单,未作处理
|
||||
// break;
|
||||
// case ACHOR_VIEW_POPUPWINDOW: //超链接
|
||||
// break;
|
||||
case IMAGE_VIEW_POPUPWINDOW: //图片
|
||||
this.itemLongClickedPopWindowView = this.itemLongClickedPopWindowInflater.inflate(R.layout.list_item_longclicked_img, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public View getView(int id) {
|
||||
return this.itemLongClickedPopWindowView.findViewById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cc.winboll.studio.webpagesources.view;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen<zhangsken@188.com>
|
||||
* @Date 2025/06/11 04:11
|
||||
* @Describe 网页状态信息栏
|
||||
*/
|
||||
public class StatusBarView extends LinearLayout {
|
||||
|
||||
public static final String TAG = "StatusBar";
|
||||
|
||||
public static final int MESSAGE_NEWS = 0;
|
||||
|
||||
Context mContext;
|
||||
TextView mtvMessage;
|
||||
|
||||
public StatusBarView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
void initView(Context context) {
|
||||
mContext = context;
|
||||
View viewMain = inflate(context, R.layout.view_statusbar, null);
|
||||
mtvMessage = viewMain.findViewById(R.id.tv_message);
|
||||
|
||||
// 设置布局参数为MATCH_PARENT,并确保最大尺寸显示
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
addView(viewMain, params);
|
||||
}
|
||||
|
||||
public void postMessage(String msg) {
|
||||
if (mContext != null) {
|
||||
Message message = new Message();
|
||||
message.what = MESSAGE_NEWS;
|
||||
message.obj = msg;
|
||||
mHandler.dispatchMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler(){
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == MESSAGE_NEWS) {
|
||||
mtvMessage.setText((String)msg.obj);
|
||||
}
|
||||
//super.handleMessage(msg);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
@ -0,0 +1,481 @@
|
||||
package cc.winboll.studio.webpagesources.view;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@QQ.COM
|
||||
* @Date 2023/07/16 17:52:43
|
||||
* @Describe 网页地址栏
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import androidx.appcompat.widget.ListPopupWindow;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.webpagesources.R;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class URLAddressView extends LinearLayout {
|
||||
|
||||
public static final String TAG = "URLEditText";
|
||||
|
||||
Context mContext;
|
||||
EditText mURLAddressEditText;
|
||||
ImageView mRightImageView;
|
||||
ImageView mLeftImageView;
|
||||
ListPopupWindow mListPopupWindow;
|
||||
boolean mIsListPopupWindow_OnShow = false;
|
||||
long mnRightImageViewTouchCount = 0;
|
||||
String mszConfigPath;
|
||||
ArrayList<URLInfo> mlistURLInfo;
|
||||
//Drawable drawable_r;
|
||||
//Drawable drawable_l_no;
|
||||
//Drawable drawable_l_yes;
|
||||
LinearLayout mllAnchorView;
|
||||
|
||||
/**
|
||||
* 在java代码里new的时候会用到
|
||||
* @param context
|
||||
*/
|
||||
public URLAddressView(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在xml布局文件中使用时自动调用
|
||||
* @param context
|
||||
*/
|
||||
public URLAddressView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不会自动调用,如果有默认style时,在第二个构造函数中调用
|
||||
* @param context
|
||||
* @param attrs
|
||||
* @param defStyleAttr
|
||||
*/
|
||||
public URLAddressView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只有在API版本>21时才会用到
|
||||
* 不会自动调用,如果有默认style时,在第二个构造函数中调用
|
||||
* @param context
|
||||
* @param attrs
|
||||
* @param defStyleAttr
|
||||
* @param defStyleRes
|
||||
*/
|
||||
//@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public URLAddressView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void initAnchorView(LinearLayout llAnchorView) {
|
||||
mllAnchorView = llAnchorView;
|
||||
}
|
||||
|
||||
void init(Context context) {
|
||||
mContext = context;
|
||||
View viewMain = inflate(mContext, R.layout.view_urladdress, null);
|
||||
mURLAddressEditText = viewMain.findViewById(R.id.viewurladdressEditText1);
|
||||
mLeftImageView = viewMain.findViewById(R.id.viewurladdressImageView1);
|
||||
mRightImageView = viewMain.findViewById(R.id.viewurladdressImageView2);
|
||||
addView(viewMain);
|
||||
|
||||
mszConfigPath = context.getExternalFilesDir(TAG) + File.separator + "_mszConfigPath.json";
|
||||
mlistURLInfo = new ArrayList<URLInfo>();
|
||||
mlistURLInfo = loadListURLInfo();
|
||||
|
||||
mURLAddressEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// 当文本发生改变时,这个方法会被调用
|
||||
//LogUtils.d(TAG, "Text changed to: " + s.toString());
|
||||
for (int i = 0; i < 0; i++) {
|
||||
if (mURLAddressEditText.equals(mlistURLInfo.get(i).getUrl())) {
|
||||
updateFavoriteButtonStatus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
updateFavoriteButtonStatus();
|
||||
/*if (mIOnTextChanged != null) {
|
||||
if (text != null) {
|
||||
mIOnTextChanged.onTextChanged(text.toString());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
});
|
||||
|
||||
mURLAddressEditText.setOnTouchListener(new View.OnTouchListener(){
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
//ToastUtils.show("mURLAddressEditText ACTION_DOWN");
|
||||
if(!mIsListPopupWindow_OnShow) {
|
||||
mnRightImageViewTouchCount = 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mLeftImageView.setOnTouchListener(new View.OnTouchListener(){
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
changeURLFavoriteStatus(mURLAddressEditText.getText().toString());
|
||||
} else {
|
||||
LogUtils.d(TAG, "MotionEvent : " + Integer.toString(motionEvent.getAction()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mRightImageView.setOnTouchListener(new View.OnTouchListener(){
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (mnRightImageViewTouchCount % 2 == 0) {
|
||||
// 弹出网址列表
|
||||
showListPopulWindow();
|
||||
}
|
||||
mnRightImageViewTouchCount++;
|
||||
} else {
|
||||
LogUtils.d(TAG, "MotionEvent : " + Integer.toString(motionEvent.getAction()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/*TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.test);
|
||||
String text = ta.getString(R.styleable.test_text);
|
||||
setText(text + " ZhanGSKen.CN");
|
||||
ta.recycle();*/
|
||||
//drawable_r = getResources().getDrawable(R.drawable.ic_form_dropdown);
|
||||
//drawable_n.setBounds(0, 0, drawable_n.getMinimumWidth(),drawable_n.getMinimumHeight()); //此为必须写的
|
||||
//drawable_r.setBounds(0, 0, 80, 80); //此为必须写的
|
||||
|
||||
//drawable_l_no = getResources().getDrawable(R.drawable.ic_favorite_outline);
|
||||
//drawable_n.setBounds(0, 0, drawable_n.getMinimumWidth(),drawable_n.getMinimumHeight()); //此为必须写的
|
||||
//drawable_l_no.setBounds(0, 0, 80, 80); //此为必须写的
|
||||
|
||||
//drawable_l_yes = getResources().getDrawable(R.drawable.ic_favorite);
|
||||
//drawable_n.setBounds(0, 0, drawable_n.getMinimumWidth(),drawable_n.getMinimumHeight()); //此为必须写的
|
||||
//drawable_l_yes.setBounds(0, 0, 80, 80); //此为必须写的
|
||||
|
||||
//setFavoriteNo();
|
||||
//setOnTouchListener(mOnTouchListener);
|
||||
//setMinWidth(100);
|
||||
//setPadding(10,0,10,0);
|
||||
//setPaddingRelative(0,0,0,0);
|
||||
|
||||
}
|
||||
|
||||
public String getURLAddressText() {
|
||||
return mURLAddressEditText.getText().toString();
|
||||
}
|
||||
|
||||
public void setURLAddressText(String szUrl) {
|
||||
mURLAddressEditText.setText(szUrl);
|
||||
}
|
||||
|
||||
//
|
||||
// 更新收藏按钮显示状态
|
||||
//
|
||||
void updateFavoriteButtonStatus() {
|
||||
if (isFavoritedURL(mURLAddressEditText.getText().toString())) {
|
||||
mLeftImageView.setBackgroundResource(R.drawable.ic_favorite);
|
||||
//setCompoundDrawables(drawable_l_yes, null, drawable_r, null);
|
||||
} else {
|
||||
mLeftImageView.setBackgroundResource(R.drawable.ic_favorite_outline);
|
||||
//setCompoundDrawables(drawable_l_no, null, drawable_r, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void setOnTouchListener(View.OnTouchListener l) {
|
||||
super.setOnTouchListener(l);
|
||||
}*/
|
||||
|
||||
/*View.OnTouchListener mOnTouchListener = new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent event) {
|
||||
final int DRAWABLE_LEFT = 0;
|
||||
//final int DRAWABLE_TOP = 1;
|
||||
final int DRAWABLE_RIGHT = 2;
|
||||
//final int DRAWABLE_BOTTOM = 3;
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if (event.getX() >= (getWidth() - getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
|
||||
// 弹出网址列表
|
||||
LogUtils.d(TAG, "mOnTouchListener 1");
|
||||
showListPopulWindow();
|
||||
return false;
|
||||
} else if (event.getX() <= (getCompoundDrawables()[DRAWABLE_LEFT].getBounds().width())) {
|
||||
// 修改输入框网址收藏状态
|
||||
LogUtils.d(TAG, "mOnTouchListener 2");
|
||||
changeURLFavoriteStatus(getText().toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};*/
|
||||
|
||||
//
|
||||
// 改变网址的收藏状态:
|
||||
// @返回值:收藏状态
|
||||
// 如果没收藏就设置收藏,收藏状态返回true;
|
||||
// 如果收藏了就取消收藏,收藏状态返回false;
|
||||
//
|
||||
public boolean changeURLFavoriteStatus(String szUrl) {
|
||||
if (szUrl == null || szUrl.equals("")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (URLInfo item : mlistURLInfo) {
|
||||
if (item.getUrl().equals(szUrl)) {
|
||||
mlistURLInfo.remove(item);
|
||||
saveListURLInfo();
|
||||
updateFavoriteButtonStatus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
URLInfo newItem = new URLInfo(szUrl);
|
||||
mlistURLInfo.add(newItem);
|
||||
saveListURLInfo();
|
||||
updateFavoriteButtonStatus();
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// 读取网址的收藏状态
|
||||
//
|
||||
public boolean isFavoritedURL(String szUrl) {
|
||||
if ((mlistURLInfo == null) || (szUrl == null) || szUrl.equals("")) {return false;}
|
||||
|
||||
for (URLInfo item : mlistURLInfo) {
|
||||
if (item.getUrl().equals(szUrl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// 前置网址在收藏列表里的位置
|
||||
//
|
||||
public boolean postposesURL(String szUrl) {
|
||||
for (URLInfo item : mlistURLInfo) {
|
||||
if (item.getUrl().equals(szUrl)) {
|
||||
mlistURLInfo.add(0, new URLInfo(szUrl));
|
||||
mlistURLInfo.remove(item);
|
||||
saveListURLInfo();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// 加载收藏的网址列表
|
||||
//
|
||||
public ArrayList<URLInfo> loadListURLInfo() {
|
||||
File fJson = new File(mszConfigPath);
|
||||
try {
|
||||
ArrayList<URLInfo> listTemp = readJsonStream(new FileInputStream(fJson));
|
||||
if (listTemp != null && listTemp.size() > 0) {
|
||||
mlistURLInfo.clear();
|
||||
mlistURLInfo.addAll(listTemp);
|
||||
} else {
|
||||
mlistURLInfo.clear();
|
||||
saveListURLInfo();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, "IOException : " + e.getMessage());
|
||||
mlistURLInfo = new ArrayList<URLInfo>();
|
||||
saveListURLInfo();
|
||||
}
|
||||
return mlistURLInfo;
|
||||
}
|
||||
|
||||
//
|
||||
// 读取 Json 文件
|
||||
//
|
||||
ArrayList<URLInfo> readJsonStream(InputStream in) throws IOException {
|
||||
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
|
||||
return readURLInfoArrayList(reader);
|
||||
}
|
||||
|
||||
//
|
||||
// 读取 Json 文件的每一 Json 项
|
||||
//
|
||||
ArrayList<URLInfo> readURLInfoArrayList(JsonReader reader) throws IOException {
|
||||
ArrayList<URLInfo> list = new ArrayList<URLInfo>();
|
||||
reader.beginArray();
|
||||
while (reader.hasNext()) {
|
||||
list.add(readURLInfo(reader));
|
||||
}
|
||||
reader.endArray();
|
||||
return list;
|
||||
}
|
||||
|
||||
//
|
||||
// 读取 Json 文件的某一 Json 项
|
||||
//
|
||||
URLInfo readURLInfo(JsonReader reader) throws IOException {
|
||||
URLInfo urlInfo = new URLInfo();
|
||||
reader.beginObject();
|
||||
while (reader.hasNext()) {
|
||||
String name = reader.nextName();
|
||||
if (name.equals("url")) {
|
||||
urlInfo.setUrl(reader.nextString());
|
||||
} else {
|
||||
reader.skipValue();
|
||||
}
|
||||
}
|
||||
reader.endObject();
|
||||
return urlInfo;
|
||||
}
|
||||
|
||||
//
|
||||
// 写入 Json 文件的某一 Json 项
|
||||
//
|
||||
static void writeConfigs(JsonWriter writer, URLInfo urlInfo) throws IOException {
|
||||
writer.beginObject();
|
||||
writer.name("url").value(urlInfo.getUrl());
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
//
|
||||
// 保存收藏的网址列表
|
||||
//
|
||||
void saveListURLInfo() {
|
||||
try {
|
||||
File fJson = new File(mszConfigPath);
|
||||
writeJsonStream(new FileOutputStream(fJson, false), mlistURLInfo);
|
||||
} catch (IOException e) {
|
||||
LogUtils.d(TAG, "IOException : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 写入 Json 文件
|
||||
//
|
||||
void writeJsonStream(OutputStream out, ArrayList<URLInfo> listURLInfo) throws IOException {
|
||||
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, "UTF-8"));
|
||||
writer.setIndent(" ");
|
||||
writeConfigsArray(writer, listURLInfo);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
//
|
||||
// 记录 Json 文件的某一 Json 项
|
||||
//
|
||||
void writeConfigsArray(JsonWriter writer, ArrayList<URLInfo> listURLInfo) throws IOException {
|
||||
writer.beginArray();
|
||||
for (URLInfo urlInfo : listURLInfo) {
|
||||
writeConfigs(writer, urlInfo);
|
||||
}
|
||||
writer.endArray();
|
||||
}
|
||||
|
||||
public class URLInfo {
|
||||
String url;
|
||||
|
||||
public URLInfo() {}
|
||||
public URLInfo(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 弹出网址下拉框
|
||||
// @ llAnchorView : 设置下拉列表基准控件
|
||||
//
|
||||
void showListPopulWindow() {
|
||||
//final String[] list = {"asg","hshsh"};
|
||||
int nListSize = mlistURLInfo.size();
|
||||
final String[] list = new String[nListSize];
|
||||
for (int i = 0; i < nListSize; i++) {
|
||||
list[i] = mlistURLInfo.get(i).getUrl();
|
||||
}
|
||||
//final String[] list = (String[])mSetStringFavorite.toArray(new String[0]);
|
||||
|
||||
|
||||
mListPopupWindow = new ListPopupWindow(mContext);
|
||||
mListPopupWindow.setWidth(LayoutParams.WRAP_CONTENT);
|
||||
mListPopupWindow.setHeight(LayoutParams.WRAP_CONTENT);
|
||||
//listPopupWindow.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list));//用android内置布局,或设计自己的样式
|
||||
mListPopupWindow.setAdapter(new ArrayAdapter<String>(mContext, R.layout.view_popurllist, R.id.viewpopurllistTextView1, list));//用android内置布局,或设计自己的样式
|
||||
//设置下拉列表基准控件
|
||||
//LinearLayout llAnchorView = findViewById(R.id.activitytesturlLinearLayout2);
|
||||
mListPopupWindow.setAnchorView(mllAnchorView);
|
||||
mListPopupWindow.setModal(false);
|
||||
// 透明度
|
||||
//listPopupWindow.setBackgroundDrawable(new ColorDrawable(0xEEAAAAAA));
|
||||
mListPopupWindow.setBackgroundDrawable(mContext.getDrawable(R.drawable.bg_shadow));
|
||||
|
||||
mListPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {//设置项点击监听
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
mURLAddressEditText.setText(list[i]);//展示选择的内容
|
||||
postposesURL(list[i]);
|
||||
updateFavoriteButtonStatus();
|
||||
//setWebViewURL(list[i]);
|
||||
mListPopupWindow.dismiss();//如果已经选择了,隐藏起来
|
||||
mnRightImageViewTouchCount = 0;
|
||||
}
|
||||
});
|
||||
mListPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener(){
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
mIsListPopupWindow_OnShow = false;
|
||||
}
|
||||
});
|
||||
mIsListPopupWindow_OnShow = true;
|
||||
mListPopupWindow.show();//下拉列表展示出来
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1" />
|
||||
</vector>
|
41
webpagesources/src/main/res/drawable/bg_shadow.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<!-- 阴影部分 -->
|
||||
<!-- 个人觉得更形象的表达:top代表下边的阴影高度,left代表右边的阴影宽度。其实也就是相对应的offset,solid中的颜色是阴影的颜色,也可以设置角度等等 -->
|
||||
<item
|
||||
android:left="2dp"
|
||||
android:top="2dp"
|
||||
android:right="2dp"
|
||||
android:bottom="2dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="#0F000000"
|
||||
android:startColor="#0F000000" />
|
||||
<corners
|
||||
android:bottomLeftRadius="6dip"
|
||||
android:bottomRightRadius="6dip"
|
||||
android:topLeftRadius="6dip"
|
||||
android:topRightRadius="6dip" />
|
||||
</shape>
|
||||
</item>
|
||||
<!-- 背景部分 -->
|
||||
<!-- 形象的表达:bottom代表背景部分在上边缘超出阴影的高度,right代表背景部分在左边超出阴影的宽度(相对应的offset) -->
|
||||
<item
|
||||
android:left="3dp"
|
||||
android:top="3dp"
|
||||
android:right="3dp"
|
||||
android:bottom="5dp">
|
||||
<shape android:shape="rectangle" >
|
||||
<gradient
|
||||
android:angle="270"
|
||||
android:endColor="@color/colorAccent"
|
||||
android:startColor="@color/colorAccent" />
|
||||
<corners
|
||||
android:bottomLeftRadius="6dip"
|
||||
android:bottomRightRadius="6dip"
|
||||
android:topLeftRadius="6dip"
|
||||
android:topRightRadius="6dip" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
11
webpagesources/src/main/res/drawable/ic_code_block_html.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="?attr/colorAppTextColor"
|
||||
android:pathData="M5.59,3.41L7,4.82L3.82,8L7,11.18L5.59,12.6L1,8L5.59,3.41M11.41,3.41L16,8L11.41,12.6L10,11.18L13.18,8L10,4.82L11.41,3.41M22,6V18C22,19.11 21.11,20 20,20H4C2.9,20 2,19.11 2,18V14H4V18H20V6H17.03V4H20C21.11,4 22,4.89 22,6Z"/>
|
||||
|
||||
</vector>
|
11
webpagesources/src/main/res/drawable/ic_favorite.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="@color/colorAppTextColor"
|
||||
android:pathData="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"/>
|
||||
|
||||
</vector>
|
11
webpagesources/src/main/res/drawable/ic_favorite_outline.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="@color/colorAppTextColor"
|
||||
android:pathData="M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z"/>
|
||||
|
||||
</vector>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="?attr/colorAppTextColor"
|
||||
android:pathData="M10,20H6V4H13V9H18V12.1L20,10.1V8L14,2H6C4.9,2 4,2.9 4,4V20C4,21.1 4.9,22 6,22H10V20M20.2,13C20.3,13 20.5,13.1 20.6,13.2L21.9,14.5C22.1,14.7 22.1,15.1 21.9,15.3L20.9,16.3L18.8,14.2L19.8,13.2C19.9,13.1 20,13 20.2,13M20.2,16.9L14.1,23H12V20.9L18.1,14.8L20.2,16.9Z"/>
|
||||
|
||||
</vector>
|
11
webpagesources/src/main/res/drawable/ic_form_dropdown.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="@color/colorAppTextColor"
|
||||
android:pathData="M17,5H20L18.5,7L17,5M3,2H21C22.11,2 23,2.9 23,4V8C23,9.11 22.11,10 21,10H16V20C16,21.11 15.11,22 14,22H3C1.9,22 1,21.11 1,20V4C1,2.9 1.9,2 3,2M3,4V8H14V4H3M21,8V4H16V8H21M3,20H14V10H3V20M5,12H12V14H5V12M5,16H12V18H5V16Z"/>
|
||||
|
||||
</vector>
|
11
webpagesources/src/main/res/drawable/ic_launcher.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clickable="true">
|
||||
<item android:drawable="@drawable/ic_launcher_background"/>
|
||||
<item
|
||||
android:left="15dp"
|
||||
android:top="15dp"
|
||||
android:right="15dp"
|
||||
android:bottom="15dp"
|
||||
android:drawable="@drawable/ic_launcher_foreground"/>
|
||||
</layer-list>
|
170
webpagesources/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillColor="@color/colorPrimary"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF"
|
||||
android:strokeWidth="0.8" />
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M16.61,15.15C16.15,15.15 15.77,14.78 15.77,14.32S16.15,13.5 16.61,13.5H16.61C17.07,13.5 17.45,13.86 17.45,14.32C17.45,14.78 17.07,15.15 16.61,15.15M7.41,15.15C6.95,15.15 6.57,14.78 6.57,14.32C6.57,13.86 6.95,13.5 7.41,13.5H7.41C7.87,13.5 8.24,13.86 8.24,14.32C8.24,14.78 7.87,15.15 7.41,15.15M16.91,10.14L18.58,7.26C18.67,7.09 18.61,6.88 18.45,6.79C18.28,6.69 18.07,6.75 18,6.92L16.29,9.83C14.95,9.22 13.5,8.9 12,8.91C10.47,8.91 9,9.24 7.73,9.82L6.04,6.91C5.95,6.74 5.74,6.68 5.57,6.78C5.4,6.87 5.35,7.08 5.44,7.25L7.1,10.13C4.25,11.69 2.29,14.58 2,18H22C21.72,14.59 19.77,11.7 16.91,10.14H16.91Z"/>
|
||||
</vector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M16.36,14C16.44,13.34 16.5,12.68 16.5,12C16.5,11.32 16.44,10.66 16.36,10H19.74C19.9,10.64 20,11.31 20,12C20,12.69 19.9,13.36 19.74,14M14.59,19.56C15.19,18.45 15.65,17.25 15.97,16H18.92C17.96,17.65 16.43,18.93 14.59,19.56M14.34,14H9.66C9.56,13.34 9.5,12.68 9.5,12C9.5,11.32 9.56,10.65 9.66,10H14.34C14.43,10.65 14.5,11.32 14.5,12C14.5,12.68 14.43,13.34 14.34,14M12,19.96C11.17,18.76 10.5,17.43 10.09,16H13.91C13.5,17.43 12.83,18.76 12,19.96M8,8H5.08C6.03,6.34 7.57,5.06 9.4,4.44C8.8,5.55 8.35,6.75 8,8M5.08,16H8C8.35,17.25 8.8,18.45 9.4,19.56C7.57,18.93 6.03,17.65 5.08,16M4.26,14C4.1,13.36 4,12.69 4,12C4,11.31 4.1,10.64 4.26,10H7.64C7.56,10.66 7.5,11.32 7.5,12C7.5,12.68 7.56,13.34 7.64,14M12,4.03C12.83,5.23 13.5,6.57 13.91,8H10.09C10.5,6.57 11.17,5.23 12,4.03M18.92,8H15.97C15.65,6.75 15.19,5.55 14.59,4.44C16.43,5.07 17.96,6.34 18.92,8M12,2C6.47,2 2,6.5 2,12A10,10 0,0 0,12 22A10,10 0,0 0,22 12A10,10 0,0 0,12 2Z"/>
|
||||
</vector>
|
11
webpagesources/src/main/res/drawable/ic_web.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="?attr/colorAppTextColor"
|
||||
android:pathData="M16.36,14C16.44,13.34 16.5,12.68 16.5,12C16.5,11.32 16.44,10.66 16.36,10H19.74C19.9,10.64 20,11.31 20,12C20,12.69 19.9,13.36 19.74,14M14.59,19.56C15.19,18.45 15.65,17.25 15.97,16H18.92C17.96,17.65 16.43,18.93 14.59,19.56M14.34,14H9.66C9.56,13.34 9.5,12.68 9.5,12C9.5,11.32 9.56,10.65 9.66,10H14.34C14.43,10.65 14.5,11.32 14.5,12C14.5,12.68 14.43,13.34 14.34,14M12,19.96C11.17,18.76 10.5,17.43 10.09,16H13.91C13.5,17.43 12.83,18.76 12,19.96M8,8H5.08C6.03,6.34 7.57,5.06 9.4,4.44C8.8,5.55 8.35,6.75 8,8M5.08,16H8C8.35,17.25 8.8,18.45 9.4,19.56C7.57,18.93 6.03,17.65 5.08,16M4.26,14C4.1,13.36 4,12.69 4,12C4,11.31 4.1,10.64 4.26,10H7.64C7.56,10.66 7.5,11.32 7.5,12C7.5,12.68 7.56,13.34 7.64,14M12,4.03C12.83,5.23 13.5,6.57 13.91,8H10.09C10.5,6.57 11.17,5.23 12,4.03M18.92,8H15.97C15.65,6.75 15.19,5.55 14.59,4.44C16.43,5.07 17.96,6.34 18.92,8M12,2C6.47,2 2,6.5 2,12A10,10 0,0 0,12 22A10,10 0,0 0,22 12A10,10 0,0 0,12 2Z"/>
|
||||
|
||||
</vector>
|
10
webpagesources/src/main/res/drawable/ic_web_white.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:clickable="true">
|
||||
<item
|
||||
android:left="24dp"
|
||||
android:top="24dp"
|
||||
android:right="24dp"
|
||||
android:bottom="24dp"
|
||||
android:drawable="@drawable/ic_launcher_foreground_web_white"/>
|
||||
</layer-list>
|
10
webpagesources/src/main/res/drawable/shape_gradient.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="180"
|
||||
android:endColor="#FFFFFFFF"
|
||||
android:startColor="#FFFFFFFF"
|
||||
android:type="linear" />
|
||||
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
31
webpagesources/src/main/res/layout/activity_about.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activityaboutToolbar1"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<!--<cc.winboll.studio.shared.view.AboutView
|
||||
app:appname="WebPageSource"
|
||||
app:appprojectname="WebPageSource"
|
||||
app:appdescription="一个简单的网站浏览器。"
|
||||
app:appicon="@drawable/ic_winboll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activityaboutAboutView1"/>-->
|
||||
|
||||
</LinearLayout>
|
||||
|
40
webpagesources/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activitymainFrameLayout1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.webpagesources.view.StatusBarView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:id="@+id/activitymainStatusBarView1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
42
webpagesources/src/main/res/layout/dialog_login_auth.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="User Name :"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:ems="10"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/viewloginhttpEditText1"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Password :"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:ems="10"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/viewloginhttpEditText2"
|
||||
android:inputType="textPassword"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/dialogloginauthRecyclerView1"
|
||||
android:background="@drawable/bg_shadow"
|
||||
android:padding="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
21
webpagesources/src/main/res/layout/fragment_sources.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:inputType="textMultiLine"
|
||||
android:layout_height="0dp"
|
||||
android:ems="10"
|
||||
android:layout_weight="1.0"
|
||||
android:background="#FFEBEBEB"
|
||||
android:id="@+id/fragmentsourcesEditText1"
|
||||
android:gravity="top"
|
||||
android:padding="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
58
webpagesources/src/main/res/layout/fragment_web.xml
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/fragmentwebLinearLayout1">
|
||||
|
||||
<cc.winboll.studio.webpagesources.view.URLAddressView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/fragmentwebURLAddressView1"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
style="@style/NormalButtonStyle"
|
||||
android:text="⇦"
|
||||
android:id="@+id/fragmentwebAButton1"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
style="@style/NormalButtonStyle"
|
||||
android:text="⇨"
|
||||
android:id="@+id/fragmentwebAButton2"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
style="@style/NormalButtonStyle"
|
||||
android:text="↺"
|
||||
android:id="@+id/fragmentwebAButton3"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.AButton
|
||||
style="@style/NormalButtonStyle"
|
||||
android:text="×"
|
||||
android:id="@+id/fragmentwebAButton4"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.baoyz.widget.PullRefreshLayout
|
||||
android:id="@+id/fragmentwebPullRefreshLayout1"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<cc.winboll.studio.webpagesources.common.BaseWebView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/fragmentwebBaseWebView1"/>
|
||||
|
||||
</com.baoyz.widget.PullRefreshLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="?attr/colorAccent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_longclicked_copylink"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Copy Link"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:background="#55555555"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_longclicked_downloadlink"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Download Link"
|
||||
android:gravity="center_vertical"
|
||||
android:singleLine="true"
|
||||
android:padding="15dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
22
webpagesources/src/main/res/layout/listview_authinfo.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="#F5F5F5"
|
||||
app:cardElevation="4dp"
|
||||
app:cardCornerRadius="4dp"
|
||||
android:id="@+id/listviewauthinfoCardView1"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:id="@+id/viewitemauthinfoTextView1"
|
||||
android:padding="5dp"/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
20
webpagesources/src/main/res/layout/view_popurllist.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:background="@drawable/bg_shadow">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:id="@+id/viewpopurllistTextView1"
|
||||
android:textSize="20sp"
|
||||
android:padding="6dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
24
webpagesources/src/main/res/layout/view_statusbar.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFCCCCCC">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:id="@+id/tv_message"
|
||||
android:textIsSelectable="true"/>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
32
webpagesources/src/main/res/layout/view_toast.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_gradient"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="10dp">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:src="@drawable/ic_launcher"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/message"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:textColor="#FF000000"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
31
webpagesources/src/main/res/layout/view_urladdress.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/viewurladdressLinearLayout1">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:background="@drawable/ic_favorite_outline"
|
||||
android:id="@+id/viewurladdressImageView1"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:ems="10"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/viewurladdressEditText1"
|
||||
android:singleLine="true"
|
||||
android:layout_weight="1.0"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:background="@drawable/ic_form_dropdown"
|
||||
android:id="@+id/viewurladdressImageView2"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
11
webpagesources/src/main/res/menu/toolbar_about.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/item_help"
|
||||
android:title="HELP"
|
||||
android:icon="@drawable/ic_winboll"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
9
webpagesources/src/main/res/menu/toolbar_authinfo.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/item_delete_authinfo"
|
||||
android:title="删除密码"/>
|
||||
|
||||
</menu>
|
30
webpagesources/src/main/res/menu/toolbar_main.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/item_web"
|
||||
android:title="Web"
|
||||
android:icon="@drawable/ic_web"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/item_sources"
|
||||
android:title="Sources"
|
||||
android:icon="@drawable/ic_code_block_html"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/item_editor"
|
||||
android:title="Editor"
|
||||
android:icon="@drawable/ic_file_edit_outline"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/item_log"
|
||||
android:title="Log"
|
||||
android:icon="@drawable/ic_winboll"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/item_about"
|
||||
android:title="About"
|
||||
android:icon="@drawable/ic_winboll"
|
||||
app:showAsAction="ifRoom"/>
|
||||
</menu>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
BIN
webpagesources/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
webpagesources/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
webpagesources/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
webpagesources/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
webpagesources/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
webpagesources/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
webpagesources/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
webpagesources/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
webpagesources/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
webpagesources/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 15 KiB |
37
webpagesources/src/main/res/raw/globalsign_ca.cer
Normal file
@ -0,0 +1,37 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIGZDCCBUygAwIBAgIMOwCrRmG0Wi0jBsKXMA0GCSqGSIb3DQEBCwUAMFUxCzAJ
|
||||
BgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMSswKQYDVQQDEyJH
|
||||
bG9iYWxTaWduIEdDQyBSNiBBbHBoYVNTTCBDQSAyMDIzMB4XDTI0MDkxNTA2NTY1
|
||||
NVoXDTI1MTAxNzA2NTY1NFowGzEZMBcGA1UEAwwQKi5zdGF0aWNmaWxlLm9yZzCC
|
||||
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALydYBhogMuljWzzVydKnNXd
|
||||
1QgbSsTM72cf+bhEZT8achjVkiPgrekfXQEMaVcdSeicDjFpC/PmNQnJStWnCr4a
|
||||
nybDu65PV2uk0eDpcGDDBeExf7O4I8i9C/yzm5nvhFQQrlr9iWK2pW+ytiUefsSA
|
||||
Yq8r+e63UNafv2ShaeKx/APiD5CfD4e2fQJzQkodbPiReaZaG3tTj+gZw1iME1wF
|
||||
3Fd1WFgn3E7d93iy4LR45073pt+W/qD899iOc+o6kic+xFG+UjsBsfwKmzYZO75A
|
||||
qad3TxtNkwHM3LWxttyQbckOQRlLjEMN0hZ2GpJ36sHeC/WyVGsDogitvllJ+KUC
|
||||
AwEAAaOCA2wwggNoMA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMIGZBggr
|
||||
BgEFBQcBAQSBjDCBiTBJBggrBgEFBQcwAoY9aHR0cDovL3NlY3VyZS5nbG9iYWxz
|
||||
aWduLmNvbS9jYWNlcnQvZ3NnY2NyNmFscGhhc3NsY2EyMDIzLmNydDA8BggrBgEF
|
||||
BQcwAYYwaHR0cDovL29jc3AuZ2xvYmFsc2lnbi5jb20vZ3NnY2NyNmFscGhhc3Ns
|
||||
Y2EyMDIzMFcGA1UdIARQME4wCAYGZ4EMAQIBMEIGCisGAQQBoDIKAQMwNDAyBggr
|
||||
BgEFBQcCARYmaHR0cHM6Ly93d3cuZ2xvYmFsc2lnbi5jb20vcmVwb3NpdG9yeS8w
|
||||
RAYDVR0fBD0wOzA5oDegNYYzaHR0cDovL2NybC5nbG9iYWxzaWduLmNvbS9nc2dj
|
||||
Y3I2YWxwaGFzc2xjYTIwMjMuY3JsMCsGA1UdEQQkMCKCECouc3RhdGljZmlsZS5v
|
||||
cmeCDnN0YXRpY2ZpbGUub3JnMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcD
|
||||
AjAfBgNVHSMEGDAWgBS9BbfzipM8c8t5+g+FEqF3lhiRdDAdBgNVHQ4EFgQUduaF
|
||||
/hF7hb1ofiF58NiodcpFJjgwggF/BgorBgEEAdZ5AgQCBIIBbwSCAWsBaQB3AK8Y
|
||||
GijWjKPgqYpMnGerCfi7vCK6rryxOKOhndP5tgMNAAABkfR4Z+gAAAQDAEgwRgIh
|
||||
AOpyIQTSOF1422Dn64GHE59XsbVeeThUgCqpiE60BjKQAiEA0FJlalS44WJg82+P
|
||||
4PuZijKkTY99/YG8Ut79TjHafGMAdgAaBP9J0FQdQK/2oMO/8djEZy9O7O4jQGiY
|
||||
axdALtyJfQAAAZH0eGidAAAEAwBHMEUCIFkh8nff1OVMNzA/by8c3ERjHgwdo7jm
|
||||
6DYJUaY2EJ78AiEAwJFOCANEUNl6nGNSTxzkQGUEAcfDNayztyhqFwJ4TUYAdgAS
|
||||
8U40vVNyTIQGGcOPP3oT+Oe1YoeInG0wBYTr5YYmOgAAAZH0eGjLAAAEAwBHMEUC
|
||||
IGDdjzgfLgdHzXYEWKfEEvNmiLPS1I/3N6IQF9SwVQ7pAiEAp+6BQtg8OUgwWwWh
|
||||
CBZh2Bnna5/RMOU8avlVXn/besgwDQYJKoZIhvcNAQELBQADggEBAJaNrbJ5ArwZ
|
||||
9oI2mu9I0pfZGhCFB3v6T8YTDNMnEq4JR0tngbrbrP5zbpbhNJwwvEA8uzbYClan
|
||||
axEOf4f3besEyPwKAq8yZUqYDLSTNjT+f0xnVNxOBElA5r5zo18Pw0nqATdfrezC
|
||||
U+CoejR8lk4RRvg0zPda8f+OhYP3ERbZ0Cm2YDJtVT59+Idyp2BbzCpsRJPLvjlt
|
||||
yWKkfcx/41tbcdKhNZFM3xszCz8vfy23yLv8zotY00rCT3F+NwMh2Kuqg9p+htCE
|
||||
/9SLNPLlBgkHK6wzQBTJoWWXKWTk3A1iPP/+MeBcN1OlKt/Zurbrka4DoEqRAyBn
|
||||
v0FDEHbg0oU=
|
||||
-----END CERTIFICATE-----
|
5
webpagesources/src/main/res/values/attrs.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<attr name="colorAppTextColor" format="color"/>
|
||||
<attr name="colorAppBackgroundColor" format="color"/>
|
||||
</resources>
|
15
webpagesources/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!--<color name="colorPrimary">#FF009688</color>
|
||||
<color name="colorPrimaryDark">#FF00796B</color>
|
||||
<color name="colorAccent">#FF9DFFF6</color>-->
|
||||
<color name="colorAppTextColor">#FF000000</color>
|
||||
<color name="colorAppBackgroundColor">#FF000000</color>
|
||||
<!-- WinBoll 默认方案 -->
|
||||
<color name="colorPrimary">#FF196ABC</color>
|
||||
<color name="colorPrimaryDark">#FF002B57</color>
|
||||
<color name="colorAccent">#FF80BFFF</color>
|
||||
<color name="colorToastFrame">#FFA9A9A9</color>
|
||||
<color name="colorToastShadow">#FF000000</color>
|
||||
<color name="colorToastBackgroung">#FFFFFFFF</color>
|
||||
</resources>
|
5
webpagesources/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">WebPageSources</string>
|
||||
<string name="app_homepage">https://winboll.cc/</string>
|
||||
|
||||
</resources>
|
35
webpagesources/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,35 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="WebPageSourceTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="colorAppTextColor">@color/colorAppTextColor</item>
|
||||
<item name="colorAppBackgroundColor">@color/colorAppBackgroundColor</item>
|
||||
</style>
|
||||
|
||||
<!-- 普通按钮的样式 -->
|
||||
<style name="NormalButtonStyle">
|
||||
<item name="android:paddingStart">15dp</item>
|
||||
<item name="android:paddingEnd">15dp</item>
|
||||
<item name="android:paddingTop">10dp</item>
|
||||
<item name="android:paddingBottom">10dp</item>
|
||||
<item name="android:minWidth">0dp</item>
|
||||
<item name="android:minHeight">0dp</item>
|
||||
<item name="android:textAllCaps">false</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">35dp</item>
|
||||
<item name="android:textColor">?attr/colorAppTextColor</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
25
webpagesources/src/main/res/xml/file_provider.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths>
|
||||
<external-path
|
||||
name="external_storage_root"
|
||||
path="." />
|
||||
<files-path
|
||||
name="files-path"
|
||||
path="." />
|
||||
<cache-path
|
||||
name="cache-path"
|
||||
path="." />
|
||||
<!--/storage/emulated/0/Android/data/...-->
|
||||
<external-files-path
|
||||
name="external_file_path"
|
||||
path="." />
|
||||
<!--代表app 外部存储区域根目录下的文件 Context.getExternalCacheDir目录下的目录-->
|
||||
<external-cache-path
|
||||
name="external_cache_path"
|
||||
path="." />
|
||||
<!--配置root-path。这样子可以读取到sd卡和一些应用分身的目录,否则微信分身保存的图片,就会导致 java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/999/tencent/MicroMsg/WeiXin/export1544062754693.jpg,在小米6的手机上微信分身有这个crash,华为没有
|
||||
-->
|
||||
<root-path
|
||||
name="root-path"
|
||||
path="" />
|
||||
</paths>
|
21
webpagesources/src/main/res/xml/network_security_config.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<!-- 允许 winboll.cc 及其子域名的明文流量 -->
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">winboll.cc</domain>
|
||||
</domain-config>
|
||||
<!-- 允许 http://10.8.0.250 的明文流量 -->
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="false">10.8.0.250</domain>
|
||||
</domain-config>
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="false">8.217.250.205</domain>
|
||||
</domain-config>
|
||||
<domain-config>
|
||||
<domain includeSubdomains="true">staticfile.org</domain>
|
||||
<trust-anchors>
|
||||
<certificates src="@raw/globalsign_ca" />
|
||||
</trust-anchors>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
|
22
webpagesources/src/stage/AndroidManifest.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application>
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="cc.winboll.studio.webpagesources.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_provider"/>
|
||||
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
6
webpagesources/src/stage/res/values/strings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Put flavor specific strings here -->
|
||||
|
||||
</resources>
|