This commit is contained in:
sonichy 2018-03-29 23:36:28 +08:00
commit 02a8b24f9f
23 changed files with 1613 additions and 0 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# Android海天鹰浏览器
基本电量信息,数据列表,电量电流电压折线图。
### 主界面
![alt](preview.png)

BIN
app-debug.apk Normal file

Binary file not shown.

48
main/AndroidManifest.xml Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hty.browser"
android:versionCode="3"
android:versionName="3.4">
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16"/>
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo.Light.NoActionBar">
<activity
android:name="com.hty.browser.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name">
<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"/>
<data android:mimeType="text/html"/>
</intent-filter>
</activity>
<activity android:name="com.hty.browser.FavoriteActivity"/>
<activity
android:name="com.hty.browser.SettingsActivity"
android:label="设置"
android:theme="@android:style/Theme.Holo">
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<!-- 查询网络状态权限 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="andorid.permission.CHANGE_CONFIGURATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>

47
main/assets/about.htm Normal file
View File

@ -0,0 +1,47 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>海天鹰浏览器</title>
<style>
body{}
p{text-indent:2em;}
</style>
</head>
<body>
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V3.4</h2>
<p>内置扩展的浏览器。</p>
<p>扩展:[查看图片]文字链接转图片,广告图片自定义过滤。</p>
<p>作者:黄颖</p>
<p>E-mailsonichy@163.com</p>
<p>QQ84429027</p>
<h3>更新日志:</h3>
<h3>V3.4 (2018-03-13)</h3><ol><li>增加视频独立播放。</li><li>使用系统下载取代浏览器跳转下载、图片下载,并增加链接下载</li></ol>
<h3>V3.3 (2018-01)</h3><ol><li>增加分享菜单。</li><li>增加:视频全屏禁用屏幕休眠。</li><li>解决网页跳转APP协议问题。</li></ol>
<h3>V3.2 (2017-12-17)</h3><ol><li>修复:关闭查找框,高亮不消失的问题。</li><li>增加过滤iframe。</li><li>修复EditTextPreference没有设置defaultValue引起第一次运行点击主页菜单崩溃。</li></ol>
<h3>V3.1 (2017-09-16)</h3><ol><li>修复:增加设置主页后,从打开方式打开仍然打开主页而不是打开文件的问题。</li><li>增加全屏菜单。</li></ol>
<h3>V3.0 (2017-08-31)</h3><ol><li>增加广告图片自定义过滤。</li></ol>
<h3>V2.15 (2017-08-27)</h3><ol><li>增加设置页面,增加主页设置。</li></ol>
<h3>V2.14 (2017-03-05)</h3><ol><li>按钮设置空背景去除边框,使按钮更小,从而使导航栏高度更小,下面的网页更大;更换主菜单图标。</li></ol>
<h3>V2.13 (2016-10-07)</h3><ol><li>下载图片后自动添加到图库中。</li></ol>
<h3>V2.12 (2016-08-17)</h3><ol><li>优化移动端关于页面。</li></ol>
<h3>V2.11 (2016-05-08)</h3><ol><li>增加显示网页源码。</li><li>增加查找功能。</li><li>自定义搜索栏,代替搜索对话框,支持搜索上一个、下一个。</li><li>适配无虚拟键盘的 Android X86。</li><li>网址收藏数据库存储到扩展存储上,以免重装应用时数据库被删除。</li></ol>
<h3>V2.10 (2016-04-28)</h3><ol><li>设置前进、后退按钮可用、禁用逻辑。</li><li>点击返回键无历史网页可退时,无动作而不是退到后台。</li></ol>
<h3>V2.9 (2016-04-13)</h3><ol><li>浏览器添加到HTML文件打开方式选择列表。</li></ol>
<h3>V2.8 (2016-03-11)</h3><ol><li>文字按钮改为图片按钮。</li><li>适配平板,取消沉浸模式,增加前进、后退、菜单按钮,点击菜单按钮弹出菜单,适配无物理按键。</li><li>修复图片无扩展名无法保存的问题。</li></ol>
<h3>V2.7 (2016-02-25)</h3><ol><li>网址收藏排除[about:blank]。</li><li>取消恢复前台自动播放视频,因为会引起解锁时新浪微博视频自动播放。</li><li>全屏暂停时显示播放按钮。</li></ol>
<h3>V2.6 (2016-02-21)</h3><ol><li>浏览器退到后台暂停视频播放。</li></ol>
<h3>V2.5 (2016-02-14)</h3><ol><li>增加onConsoleMessage。</li><li>测试视频全屏MIUI显示控件LEUI不显示控件是手机系统问题因为回退键已做好退出退出全屏功能取消显示退出全屏按钮。</li></ol>
<h3>V2.4 (2016-02-12)</h3><ol><li>视频全屏适用iqiyi.com。</li><li>点击返回键优先退出全屏返回上一页次之最后moveTaskToback。</li></ol>
<h3>V2.3 (2016-02-09)</h3><ol><li>修复网络未连接,反复请求百度搜索的问题。</li></ol>
<h3>V2.2 (2016-02-03)</h3><ol><li>触摸WebView隐藏地址栏输入法。</li><li>自定义进度条。</li></ol>
<h3>V2.1 (2016-02-01)</h3><ol><li>增加保存图片功能。</li></ol>
<h3>V2.0 (2016-01-31)</h3><ol><li>改用SQLite数据库收藏网址。</li><li>完善收藏夹的显示、添加、删除、点击跳转菜单。</li></ol>
<h3>V1.5 (2016-01-28)</h3><ol><li>增加使用localStorage技术的收藏夹。</li></ol>
<h3>V1.4 (2016-01-26)</h3><ol><li>修复中文网址打不开时,跳转百度搜索乱码。</li><li>增加图片长按菜单。</li></ol>
<h3>V1.3 (2016-01-25)</h3><ol><li>菜单键增加前进菜单项。</li><li>增加输入法回车打开网址。</li><li>改用Holo主题。</li><li>增加网址补齐[http://]。</li><li>找不到网站时到百度网搜索。</li><li>增加进度条。</li></ol>
<h3>V1.2 (2016-01-23)</h3><ol><li>支持自适应屏幕,支持缩放。</li></ol>
<h3>V1.1 (2016-01-22)</h3><ol><li>增加支持网页input.file转安卓文件选择器。</li><li>点击加载按钮隐藏输入法。</li><li>增加支持使用内部浏览器下载文件。</li></ol>
<h3>V1.0 (2016-01-21)</h3><ol><li>实现基本的浏览器界面。</li><li>实现第一个扩展[链接转图片]。</li><li>网页JS.alert转安卓Toast。</li></ol>
</body>
</html>

BIN
main/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,80 @@
package com.hty.browser;
import java.io.File;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = MainActivity.dir + File.separator + "webfav.db";
private final static int VERSION = 1;
String TableName = "webfav";
private SQLiteDatabase db;
private static DBHelper mInstance = null;
public DBHelper(Context context) {
super(context, DATABASE_NAME, null, VERSION);
}
public static synchronized DBHelper getInstance(Context context) {
if (mInstance == null) {
mInstance = new DBHelper(context);
}
return mInstance;
}
@Override
public void onCreate(SQLiteDatabase db) {
this.db = db;
db.execSQL("CREATE TABLE webfav (_id INTEGER PRIMARY KEY ,website TEXT,title TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// db.execSQL("DROP TABLE IF EXISTS battery");
// onCreate(db);
switch (newVersion) {
case 6:
db.execSQL("alter table battery rename to battery_temp");
db.execSQL("CREATE TABLE battery (_id INTEGER PRIMARY KEY ,time TEXT,level INTEGER, voltage INTEGER, current INTEGER , temperature INTEGER, cpu INTEGER)");
db.execSQL("insert into battery select *,'' from battery_temp");
db.execSQL("drop table battery_temp");
break;
}
}
public void insert(ContentValues values) {
db = getWritableDatabase();
db.insert(TableName, null, values);
db.close();
}
public Cursor query(String url) {
db = getWritableDatabase();
Cursor c = null;
if (url.equalsIgnoreCase("")) {
c = db.query(TableName, null, null, null, null, null, "_id desc");
} else {
c = db.query(TableName, null, "website=?", new String[] { url }, null, null, "_id desc");
}
return c;
}
public void del(int id) {
if (db == null)
db = getWritableDatabase();
db.delete(TableName, "_id=?", new String[] { String.valueOf(id) });
// Log.e("id", id + "");
// db.ExecuteNonQuery(CommandType.Text, "VACUUM");
}
@Override
public void close() {
if (db != null)
db.close();
}
}

View File

@ -0,0 +1,93 @@
package com.hty.browser;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnCreateContextMenuListener;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class FavoriteActivity extends Activity {
SimpleCursorAdapter adapter;
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_favorite);
DBHelper helper = new DBHelper(this);
Cursor c = helper.query("");
String[] from = { "_id", "title", "website" };
int[] to = { R.id.id, R.id.title, R.id.website };
adapter = new SimpleCursorAdapter(this, R.layout.favorite_row, c, from, to, 0);
listView = (ListView) this.findViewById(R.id.listView1);
listView.setAdapter(adapter);
listView.setDivider(new ColorDrawable(Color.GREEN));
listView.setDividerHeight(2);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
String url = ((TextView) arg1.findViewById(R.id.website)).getText().toString();
Intent intent = new Intent(FavoriteActivity.this, MainActivity.class);
intent.putExtra("url", url);
setResult(RESULT_OK, intent);
finish();
}
});
listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
String title = ((TextView) info.targetView.findViewById(R.id.title)).getText().toString();
menu.setHeaderTitle(title);
menu.add(0, 0, 0, "复制链接");
menu.add(0, 1, 1, "删除");
}
});
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
case 0:
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String url = ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString();
cm.setPrimaryClip(ClipData.newPlainText("link", url));
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
break;
case 1:
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText()
.toString());
DBHelper helper = new DBHelper(getApplicationContext());
helper.del(id);
Cursor c = helper.query("");
String[] from = { "_id", "title", "website" };
int[] to = { R.id.id, R.id.title, R.id.website };
adapter = new SimpleCursorAdapter(this, R.layout.favorite_row, c, from, to, 0);
listView.setAdapter(adapter);
break;
}
return true;
}
public void favback(View v) {
finish();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
package com.hty.browser;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.PreferenceActivity;
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener{
private EditTextPreference ETP_homepage;
SharedPreferences sharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
ETP_homepage = (EditTextPreference) findPreference("homepage");
sharedPreferences = getPreferenceScreen().getSharedPreferences();
sharedPreferences.registerOnSharedPreferenceChangeListener(this);
}
@Override
// Activity启动时修改列表项目值
protected void onResume() {
super.onResume();
ETP_homepage.setSummary(sharedPreferences.getString("homepage","http://www.baidu.com"));
}
@Override
// 编辑后确定修改列表项目值
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equals("homepage")){
ETP_homepage.setSummary(sharedPreferences.getString(key,""));
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 背景 gradient是渐变,corners定义的是圆角 -->
<item android:id="@android:id/background">
<shape>
<solid android:color="#CBCED6" />
</shape>
</item>
<!-- 第二条进度条颜色 -->
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="#B5DFF4" />
</shape>
</clip>
</item>
<!-- 进度条 -->
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#47BCE8" />
</shape>
</clip>
</item>
</layer-list>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".FavoriteActivity" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="收藏夹"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:clickable="true"
android:onClick="favback"
android:text=" × "
android:textSize="30sp" />
</RelativeLayout>
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>

View File

@ -0,0 +1,145 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hty.browser.MainActivity" >
<FrameLayout
android:id="@+id/video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:visibility="gone" >
</FrameLayout>
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ImageButtonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_media_rew" />
<ImageButton
android:id="@+id/ImageButtonForward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_media_ff" />
<EditText
android:id="@+id/EditText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="输入网址"
android:imeOptions="actionGo"
android:inputType="textUri"
android:singleLine="true"
/>
<ImageButton
android:id="@+id/ImageButtonGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_media_play" />
<ImageButton
android:id="@+id/ImageButtonMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_menu_sort_by_size" />
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar1" style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:progressDrawable="@drawable/progressbar_color"
android:visibility="invisible" />
<WebView
android:id="@+id/WebView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/play"
android:visibility="gone" />
<FrameLayout
android:id="@+id/findbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/LinearLayout1"
android:background="#ffffff"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/findText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="查找"
android:imeOptions="actionSearch"
android:inputType="textUri"
android:singleLine="true" />
<TextView
android:id="@+id/findCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0/0" />
<ImageButton
android:id="@+id/findPrev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_media_rew" />
<ImageButton
android:id="@+id/findNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_media_ff" />
<ImageButton
android:id="@+id/findClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@android:drawable/ic_menu_close_clear_cancel" />
</LinearLayout>
</FrameLayout>
</RelativeLayout>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="id"
android:visibility="gone" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:singleLine="true"
android:text="title" />
<TextView
android:id="@+id/website"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:singleLine="true"
android:text="website" />
</LinearLayout>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">海天鹰浏览器</string>
<string name="title_activity_settings">Settings</string>
</resources>

View File

@ -0,0 +1,21 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="设置">
<EditTextPreference
android:key="homepage"
android:defaultValue="http://www.baidu.com"
android:summary="http://www.baidu.com"
android:title="主页"
android:background="#282828"/>
<SwitchPreference
android:key="switch_adBlock"
android:defaultValue="true"
android:title="广告过滤"/>
<SwitchPreference
android:key="switch_iframeBlock"
android:defaultValue="false"
android:title="iframe过滤"/>
</PreferenceScreen>

BIN
preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 KiB