增加请求电脑版网页

This commit is contained in:
sonichy 2021-06-27 11:07:31 +08:00
parent f3287f3ac7
commit df3f62afed
7 changed files with 39 additions and 42 deletions

BIN
app.apk

Binary file not shown.

View File

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hty.browser"
android:versionCode="4"
android:versionName="4.17">
android:versionName="4.19">
<application
android:icon="@drawable/ic_launcher"
@ -21,18 +21,15 @@
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"/>
<data android:scheme="http"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="android.intent.action.SEARCH"/>
<action android:name="android.intent.action.WEB_SEARCH"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="file"/>
<data android:scheme="content"/>
<data android:scheme="https"/>
<data android:scheme="http"/>
<data android:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:host="*"/>
</intent-filter>
</activity>
<activity

View File

@ -9,7 +9,7 @@ p { text-indent:2em; }
</style>
</head>
<body>
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.17</h2>
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.18</h2>
<p>内置扩展的浏览器。</p>
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
<p>作者:海天鹰</p>
@ -23,6 +23,8 @@ p { text-indent:2em; }
<p><a href="https://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon" target="_blank">获取网页图标</a></p>
<p><a href="https://www.jianshu.com/p/c9a18050a249" target="_blank">字符串转Bitmap</a></p>
<h3>更新日志:</h3>
<h3>V4.19 (2021-06-27)</h3><ol><li>增加请求电脑版网页。</li></ol>
<h3>V4.18 (2021-06-01)</h3><ol><li>增加动态权限请求。</li></ol>
<h3>V4.17 (2021-03-02)</h3><ol><li>允许HTTPS、HTTP混合内容解决微信网页视频无法播放的问题。</li></ol>
<h3>V4.16 (2020-10-14)</h3><ol><li>取消引起崩溃的复制图片。</li></ol>
<h3>V4.15 (2020-10-01)</h3><ol><li>优化猜测下载文件名。</li></ol>

View File

@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
@ -103,7 +104,6 @@ public class MainActivity extends Activity {
TextView textView_searchCount, textView_filesize;
EditText editText_url, editText_search, editText_download_path;
ImageButton button_back, button_forward, button_menu, button_go, button_search_prev, button_search_next, button_search_close, button_info, button_play;
// RelativeLayout RelativeLayout1;
LinearLayout LinearLayout1, LinearLayout2;
FrameLayout webViewLayout, videoLayout, searchBar;
InputMethodManager IMM;
@ -121,10 +121,21 @@ public class MainActivity extends Activity {
int currentPage;
int FILECHOOSER_DOWNLOAD_PATH = 3;
DownloadCompleteReceiver receiver;
private static String[] PERMISSIONS = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE };
private static int REQUEST_PERMISSION_CODE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//Log.e(Thread.currentThread().getStackTrace()[2] + "", "checkSelfPermission: " + checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE));
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(PERMISSIONS, REQUEST_PERMISSION_CODE);
}
}
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
IMM = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
String path = Environment.getExternalStorageDirectory().getPath() + File.separator + "HTYBrowser";
@ -132,33 +143,17 @@ public class MainActivity extends Activity {
if (!dir.exists()) {
dir.mkdirs();
}
setContentView(R.layout.activity_main);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
LinearLayout1 = (LinearLayout) findViewById(R.id.LinearLayout1);
LinearLayout2 = (LinearLayout) findViewById(R.id.LinearLayout2);
// RelativeLayout1 = (RelativeLayout) findViewById(R.id.RelativeLayout1);
webViewLayout = (FrameLayout) findViewById(R.id.webViewLayout);
videoLayout = (FrameLayout) findViewById(R.id.videoLayout);
searchBar = (FrameLayout) findViewById(R.id.searchBar);
searchBar.setVisibility(View.GONE);
pgb1 = (ProgressBar) findViewById(R.id.progressBar1);
// if (VERSION.SDK_INT > 18) {
// getWindow().addFlags(
// WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// getWindow().addFlags(
// WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
// LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
// LinearLayout1
// .getLayoutParams();
// lp.topMargin = 45;
// LinearLayout1.setLayoutParams(lp);
// // RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams)
// // RelativeLayout1
// // .getLayoutParams();
// // lp.topMargin = 45;
// // RelativeLayout1.setLayoutParams(lp);
// }
button_go = (ImageButton) findViewById(R.id.button_go);
button_back = (ImageButton) findViewById(R.id.button_back);
button_forward = (ImageButton) findViewById(R.id.button_forward);
@ -1177,12 +1172,12 @@ public class MainActivity extends Activity {
long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
Log.e(Thread.currentThread().getStackTrace()[2] + "", downloadId + "");
DownloadManager downloadManager = (DownloadManager) context.getSystemService(DOWNLOAD_SERVICE);
if(downloadId == downloadIdUpdate){
if (downloadId == downloadIdUpdate) {
Uri uri = downloadManager.getUriForDownloadedFile(downloadId);
Log.e(Thread.currentThread().getStackTrace()[2] + "", uri.toString());
Intent intentn = new Intent(Intent.ACTION_VIEW);
intentn.setDataAndType(uri, "application/vnd.android.package-archive");
startActivity(intentn);
Intent intent1 = new Intent(Intent.ACTION_VIEW);
intent1.setDataAndType(uri, "application/vnd.android.package-archive");
startActivity(intent1);
}
}
}
@ -1203,7 +1198,9 @@ public class MainActivity extends Activity {
void settingWebView(WebView webView) {
registerForContextMenu(webView); // 注册菜单
webView.requestFocusFromTouch(); // 请求触摸焦点
webView.setWebContentsDebuggingEnabled(true); // 允许调试
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setWebContentsDebuggingEnabled(true); // 允许调试
}
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true); // 开启JS
@ -1224,6 +1221,9 @@ public class MainActivity extends Activity {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); // 允许HTTPSHTTP混合内容
}
if (sharedPreferences.getBoolean("switch_pcmode", false)) {
webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36");
}
webView.setWebViewClient(new WebViewClient() {
@Override

View File

@ -23,8 +23,8 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
SP.registerOnSharedPreferenceChangeListener(this);
}
@Override
// 启动时显示
@Override
protected void onResume() {
super.onResume();
ETP_homepage.setSummary(SP.getString("homepage", "http://www.baidu.com"));
@ -32,8 +32,8 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
ETP_highlight.setSummary(SP.getString("highlight", ""));
}
@Override
// 修改后显示
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.e(Thread.currentThread().getStackTrace()[2] + "", key);
if (key.equals("homepage")) {

View File

@ -8,6 +8,11 @@
android:title="主页"
android:textColor="@android:color/holo_blue_dark"/>
<SwitchPreference
android:key="switch_pcmode"
android:defaultValue="false"
android:title="电脑模式"/>
<SwitchPreference
android:key="switch_adBlock"
android:defaultValue="true"
@ -60,11 +65,4 @@
</PreferenceCategory>
<!--
<SwitchPreference
android:key="switch_pasueVideoOnPause"
android:defaultValue="true"
android:title="后台暂停播放视频"/>
-->
</PreferenceScreen>

View File

@ -1 +1 @@
4.17
4.19