优化猜测下载文件名

This commit is contained in:
sonichy 2020-10-01 19:25:00 +08:00
parent 8162313777
commit 847b9462b6
8 changed files with 42 additions and 25 deletions

BIN
app.apk

Binary file not shown.

View File

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hty.browser" package="com.hty.browser"
android:versionCode="4" android:versionCode="4"
android:versionName="4.14"> android:versionName="4.15">
<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"

View File

@ -9,7 +9,7 @@ p { text-indent:2em; }
</style> </style>
</head> </head>
<body> <body>
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.14</h2> <h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.15</h2>
<p>内置扩展的浏览器。</p> <p>内置扩展的浏览器。</p>
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p> <p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
<p>作者:海天鹰</p> <p>作者:海天鹰</p>
@ -23,6 +23,7 @@ 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://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> <p><a href="https://www.jianshu.com/p/c9a18050a249" target="_blank">字符串转Bitmap</a></p>
<h3>更新日志:</h3> <h3>更新日志:</h3>
<h3>V4.15 (2020-10-01)</h3><ol><li>优化猜测下载文件名。</li></ol>
<h3>V4.14 (2020-09-20)</h3><ol><li>优化下载对话框百度网页图片文件名填充,支持修改下载文件名。</li></ol> <h3>V4.14 (2020-09-20)</h3><ol><li>优化下载对话框百度网页图片文件名填充,支持修改下载文件名。</li></ol>
<h3>V4.13 (2020-08-30)</h3><ol><li>图片查看改为在新窗口中打开。</li><li>修复修改、删除收藏不能记忆位置问题。</li></ol> <h3>V4.13 (2020-08-30)</h3><ol><li>图片查看改为在新窗口中打开。</li><li>修复修改、删除收藏不能记忆位置问题。</li></ol>
<h3>V4.12 (2020-07-17)</h3><ol><li>适配全面屏导航栏背景色。</li><li>收藏夹无标题栏自定义菜单改成标题栏菜单。</li></ol> <h3>V4.12 (2020-07-17)</h3><ol><li>适配全面屏导航栏背景色。</li><li>收藏夹无标题栏自定义菜单改成标题栏菜单。</li></ol>

View File

@ -77,6 +77,7 @@ import android.webkit.ConsoleMessage;
import android.webkit.DownloadListener; import android.webkit.DownloadListener;
import android.webkit.GeolocationPermissions; import android.webkit.GeolocationPermissions;
import android.webkit.JsResult; import android.webkit.JsResult;
import android.webkit.URLUtil;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebChromeClient.CustomViewCallback; import android.webkit.WebChromeClient.CustomViewCallback;
@ -105,7 +106,7 @@ public class MainActivity extends Activity {
ImageButton button_back, button_forward, button_menu, button_go, button_search_prev, button_search_next, button_search_close, button_info, button_play; ImageButton button_back, button_forward, button_menu, button_go, button_search_prev, button_search_next, button_search_close, button_info, button_play;
// RelativeLayout RelativeLayout1; // RelativeLayout RelativeLayout1;
LinearLayout LinearLayout1, LinearLayout2; LinearLayout LinearLayout1, LinearLayout2;
FrameLayout webViewLayout, video, searchBar; FrameLayout webViewLayout, videoLayout, searchBar;
InputMethodManager IMM; InputMethodManager IMM;
ProgressBar pgb1; ProgressBar pgb1;
String urlo = "", HTRE = "", ptitle = "", urln = ""; String urlo = "", HTRE = "", ptitle = "", urln = "";
@ -139,7 +140,7 @@ public class MainActivity extends Activity {
LinearLayout2 = (LinearLayout) findViewById(R.id.LinearLayout2); LinearLayout2 = (LinearLayout) findViewById(R.id.LinearLayout2);
// RelativeLayout1 = (RelativeLayout) findViewById(R.id.RelativeLayout1); // RelativeLayout1 = (RelativeLayout) findViewById(R.id.RelativeLayout1);
webViewLayout = (FrameLayout) findViewById(R.id.webViewLayout); webViewLayout = (FrameLayout) findViewById(R.id.webViewLayout);
video = (FrameLayout) findViewById(R.id.video); videoLayout = (FrameLayout) findViewById(R.id.videoLayout);
searchBar = (FrameLayout) findViewById(R.id.searchBar); searchBar = (FrameLayout) findViewById(R.id.searchBar);
searchBar.setVisibility(View.GONE); searchBar.setVisibility(View.GONE);
pgb1 = (ProgressBar) findViewById(R.id.progressBar1); pgb1 = (ProgressBar) findViewById(R.id.progressBar1);
@ -252,7 +253,7 @@ public class MainActivity extends Activity {
private void setFullScreen() { private void setFullScreen() {
// RelativeLayout1.setVisibility(View.GONE); // RelativeLayout1.setVisibility(View.GONE);
LinearLayout1.setVisibility(View.GONE); LinearLayout1.setVisibility(View.GONE);
video.setVisibility(View.VISIBLE); videoLayout.setVisibility(View.VISIBLE);
// imageView1.setVisibility(View.VISIBLE); // imageView1.setVisibility(View.VISIBLE);
// 横屏显示 // 横屏显示
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
@ -272,7 +273,7 @@ public class MainActivity extends Activity {
LinearLayout1.setVisibility(View.VISIBLE); LinearLayout1.setVisibility(View.VISIBLE);
LinearLayout2.setVisibility(View.VISIBLE); LinearLayout2.setVisibility(View.VISIBLE);
pgb1.setVisibility(View.VISIBLE); pgb1.setVisibility(View.VISIBLE);
video.setVisibility(View.GONE); videoLayout.setVisibility(View.GONE);
// imageView1.setVisibility(View.GONE); // imageView1.setVisibility(View.GONE);
// 用户当前的首选方向 // 用户当前的首选方向
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
@ -391,7 +392,7 @@ public class MainActivity extends Activity {
WebView w = (WebView) v; WebView w = (WebView) v;
HitTestResult result = w.getHitTestResult(); HitTestResult result = w.getHitTestResult();
HTRE = result.getExtra(); HTRE = result.getExtra();
Log.e(Thread.currentThread().getStackTrace()[2] + ": ", HTRE); Log.e(Thread.currentThread().getStackTrace()[2] + " ", HTRE + "");
menu.setHeaderTitle(HTRE); menu.setHeaderTitle(HTRE);
if (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) { if (result.getType() == HitTestResult.IMAGE_TYPE || result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
menu.setHeaderIcon(android.R.drawable.ic_menu_gallery); menu.setHeaderIcon(android.R.drawable.ic_menu_gallery);
@ -427,7 +428,7 @@ public class MainActivity extends Activity {
break; break;
case 2: case 2:
String mime = URLConnection.getFileNameMap().getContentTypeFor(HTRE); String mime = URLConnection.getFileNameMap().getContentTypeFor(HTRE);
Log.e(Thread.currentThread().getStackTrace()[2] + ": ", "" + mime); Log.e(Thread.currentThread().getStackTrace()[2] + " ", "" + mime);
if (mime == null) mime = ""; if (mime == null) mime = "";
dialog_download(HTRE, "", mime, 0); dialog_download(HTRE, "", mime, 0);
break; break;
@ -613,8 +614,13 @@ public class MainActivity extends Activity {
@Override @Override
protected void onPause() { protected void onPause() {
//Log.e(Thread.currentThread().getStackTrace()[2] + "", "onPause"); Log.e(Thread.currentThread().getStackTrace()[2] + "", "onPause");
pauseVideo(); // Log.e(Thread.currentThread().getStackTrace()[2] + "", "pauseVideo = " + sharedPreferences.getBoolean("switch_pasueVideoOnPause", true));
// if (sharedPreferences.getBoolean("switch_pasueVideoOnPause", true)) {
// pauseVideo();
// } else {
// playVideo();
// }
if (isFullScreen) { if (isFullScreen) {
button_play.setVisibility(View.VISIBLE); button_play.setVisibility(View.VISIBLE);
} }
@ -1391,7 +1397,7 @@ public class MainActivity extends Activity {
//Toast.makeText(getApplicationContext(), "onShowCustomView", Toast.LENGTH_SHORT).show(); //Toast.makeText(getApplicationContext(), "onShowCustomView", Toast.LENGTH_SHORT).show();
customViewCallback = callback; customViewCallback = callback;
// 将video放到当前视图中 // 将video放到当前视图中
video.addView(view); videoLayout.addView(view);
// 设置全屏 // 设置全屏
setFullScreen(); setFullScreen();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@ -1474,6 +1480,8 @@ public class MainActivity extends Activity {
Date date = new Date(); Date date = new Date();
String stime = SDF.format(date); String stime = SDF.format(date);
filename = stime + ".jpg"; filename = stime + ".jpg";
} else {
filename = URLUtil.guessFileName(surl, null, null);
} }
editText_download_filename.setText(filename); editText_download_filename.setText(filename);
editText_download_path = (EditText) view.findViewById(R.id.editText_download_path); editText_download_path = (EditText) view.findViewById(R.id.editText_download_path);
@ -1527,7 +1535,6 @@ public class MainActivity extends Activity {
public void handleMessage(android.os.Message msg) { public void handleMessage(android.os.Message msg) {
switch (msg.what){ switch (msg.what){
case 0: case 0:
//textView_filesize.setText(formatFileSize(msg.arg1));
textView_filesize.setText(Formatter.formatFileSize(MainActivity.this, msg.arg1)); textView_filesize.setText(Formatter.formatFileSize(MainActivity.this, msg.arg1));
break; break;
} }

View File

@ -5,6 +5,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.util.Log;
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{ public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
@ -34,6 +35,7 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
@Override @Override
// 修改后显示 // 修改后显示
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.e(Thread.currentThread().getStackTrace()[2] + "", key);
if (key.equals("homepage")) { if (key.equals("homepage")) {
ETP_homepage.setSummary(sharedPreferences.getString(key, "")); ETP_homepage.setSummary(sharedPreferences.getString(key, ""));
} else if(key.equals("filter")) { } else if(key.equals("filter")) {

View File

@ -4,7 +4,7 @@
android:layout_height="match_parent" > android:layout_height="match_parent" >
<FrameLayout <FrameLayout
android:id="@+id/video" android:id="@+id/videoLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="#000000" android:background="#000000"

View File

@ -60,4 +60,11 @@
</PreferenceCategory> </PreferenceCategory>
<!--
<SwitchPreference
android:key="switch_pasueVideoOnPause"
android:defaultValue="true"
android:title="后台暂停播放视频"/>
-->
</PreferenceScreen> </PreferenceScreen>

View File

@ -1 +1 @@
4.14 4.15