收藏夹测试ExpandableListView控件
This commit is contained in:
parent
489f00f4a3
commit
c962451642
|
@ -1,8 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hty.browser"
|
||||
android:versionCode="4"
|
||||
android:versionName="4.29">
|
||||
package="com.hty.browser"
|
||||
android:versionCode="4"
|
||||
android:versionName="4.30">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<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" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<!-- GPS权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_GPS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
|
@ -10,58 +25,52 @@
|
|||
android:theme="@android:style/Theme.Holo.Light">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.Holo.Light.NoActionBar"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:launchMode="singleInstance">
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleInstance"
|
||||
android:theme="@android:style/Theme.Holo.Light.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<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="file"/>
|
||||
<data android:scheme="content"/>
|
||||
<data android:scheme="https"/>
|
||||
<data android:scheme="http"/>
|
||||
<data android:mimeType="*/*"/>
|
||||
<data android:host="*"/>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<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="*/*" />
|
||||
<data android:host="*" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.WEB_SEARCH"/>
|
||||
<action android:name="android.intent.action.WEB_SEARCH" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<data android:mimeType="*/*"/>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".FavoriteActivity"
|
||||
android:icon="@android:drawable/btn_star_big_on"
|
||||
android:label="收藏夹"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:name=".FavoriteActivity1"
|
||||
android:icon="@android:drawable/btn_star_big_on"
|
||||
android:label="收藏夹"
|
||||
android:parentActivityName=".MainActivity" />
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:label="设置"
|
||||
android:parentActivityName=".MainActivity"/>
|
||||
android:parentActivityName=".MainActivity" />
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<!-- 查询网络状态权限 -->
|
||||
<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"/>
|
||||
<!-- GPS权限 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_GPS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
|
||||
</manifest>
|
|
@ -9,7 +9,7 @@ p { text-indent:2em; }
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.29</h2>
|
||||
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.30</h2>
|
||||
<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://www.jianshu.com/p/c9a18050a249" target="_blank">字符串转Bitmap</a></p>
|
||||
<h3>更新日志:</h3>
|
||||
<h3>V4.30 (2023-03-23)</h3><ol><li>收藏夹测试 ExpandableListView 控件</li></ol>
|
||||
<h3>V4.29 (2023-03-01)</h3><ol><li>收藏夹增加分类。</li><li>收藏夹分类的修改和删除。</li><li>修改导出HTML和CSV方法。</li><li>新建收藏和修改收藏编辑框设置最大行数,避免窗口撑大不完整。</li></ol>
|
||||
<h3>V4.28 (2022-11-07)</h3><ol><li>资源探查脚本支持返回多个对象。<br>分类标题增加数量。<br>使用 <details> 代替 <div>,分类可折叠。</li></ol>
|
||||
<h3>V4.27 (2022-10-22)</h3><ol><li>修改收藏夹数据库目录。</li><li>收藏夹增加分享数据库功能。</li></ol>
|
||||
|
|
|
@ -11,7 +11,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
public class DBHelper extends SQLiteOpenHelper {
|
||||
public static final String filename = "webfav.db";
|
||||
public static final String DATABASE_NAME = MainActivity.dir + File.separator + filename;
|
||||
private final static int VERSION = 3;
|
||||
private final static int VERSION = 4;
|
||||
static String TableName = "webfav";
|
||||
private SQLiteDatabase db;
|
||||
private static DBHelper mInstance = null;
|
||||
|
@ -32,23 +32,32 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
this.db = db;
|
||||
db.execSQL("CREATE TABLE webfav (_id INTEGER PRIMARY KEY , website TEXT, title TEXT, category TEXT)");
|
||||
db.execSQL("CREATE TABLE category (_id INTEGER PRIMARY KEY , category TEXT)");
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("category", "");
|
||||
db.insert("category", null, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
switch (newVersion) {
|
||||
case 3:
|
||||
db.execSQL("CREATE TABLE category (_id INTEGER PRIMARY KEY , category TEXT)");
|
||||
String sql = "ALTER TABLE " + TableName + " ADD COLUMN category TEXT default ''";
|
||||
db.execSQL(sql);
|
||||
break;
|
||||
case 3:
|
||||
db.execSQL("CREATE TABLE category (_id INTEGER PRIMARY KEY , category TEXT)");
|
||||
String sql = "ALTER TABLE " + TableName + " ADD COLUMN category TEXT default ''";
|
||||
db.execSQL(sql);
|
||||
break;
|
||||
case 4:
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("category", "");
|
||||
db.insert("category", null, values);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void insert(String tableName, ContentValues values) {
|
||||
public long insert(String tableName, ContentValues values) {
|
||||
db = getWritableDatabase();
|
||||
db.insert(tableName, null, values);
|
||||
long i = db.insert(tableName, null, values);
|
||||
db.close();
|
||||
return i;
|
||||
}
|
||||
|
||||
public Cursor query(String s) {
|
||||
|
@ -62,34 +71,29 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
return c;
|
||||
}
|
||||
|
||||
public Cursor queryCategoty(String s) {
|
||||
public Cursor queryCategory(String s) {
|
||||
db = getWritableDatabase();
|
||||
Cursor c;
|
||||
if (s.equals("无分类")) {
|
||||
c = db.query(TableName, null, "category = ''", null, null, null, "_id desc");
|
||||
} else {
|
||||
c = db.query(TableName, null, "category = '" + s + "'", null, null, null, "_id desc");
|
||||
}
|
||||
Cursor c = db.query(TableName, null, "category = '" + s + "'", null, null, null, "_id desc");
|
||||
return c;
|
||||
}
|
||||
|
||||
public Cursor category() {
|
||||
db = getWritableDatabase();
|
||||
Cursor c = db.query("category", null, null, null, null, null, "category asc");
|
||||
return c;
|
||||
}
|
||||
|
||||
public Cursor category(String s) {
|
||||
db = getWritableDatabase();
|
||||
Cursor c;
|
||||
if (s.equals("")) {
|
||||
c = db.query("category", null, null, null, null, null, "category asc");
|
||||
} else {
|
||||
c = db.query("category", null, "category = '" + s + "'", null, null, null, null);
|
||||
}
|
||||
Cursor c = db.query("category", null, "category = '" + s + "'", null, null, null, null);
|
||||
return c;
|
||||
}
|
||||
|
||||
public void del(int id) {
|
||||
public int 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");
|
||||
int i = db.delete(TableName, "_id=?", new String[] { String.valueOf(id) });
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -159,7 +159,7 @@ public class FavoriteActivity extends Activity {
|
|||
if (radioButton == null)
|
||||
break;
|
||||
final String title = radioButton.getText().toString();
|
||||
if (title.equals("无分类"))
|
||||
if (title.equals(""))
|
||||
break;
|
||||
builder.setTitle(title);
|
||||
final EditText editText_rename = new EditText(FavoriteActivity.this);
|
||||
|
@ -291,9 +291,8 @@ public class FavoriteActivity extends Activity {
|
|||
layout.addView(editText_url);
|
||||
final Spinner spinner = new Spinner(this);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("");
|
||||
DBHelper helper = new DBHelper(this);
|
||||
Cursor cursor = helper.category("");
|
||||
Cursor cursor = helper.category();
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String s = cursor.getString(cursor.getColumnIndex("category"));
|
||||
|
@ -327,19 +326,21 @@ public class FavoriteActivity extends Activity {
|
|||
values.put("website", surl);
|
||||
values.put("title", stitle);
|
||||
values.put("category", spinner.getSelectedItem().toString());
|
||||
db.update(DBHelper.TableName, values, "_id = " + sid, null);
|
||||
IMM.hideSoftInputFromWindow(editText_title.getWindowToken(), 0);
|
||||
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
|
||||
if (radioButton == null)
|
||||
search(0, editText.getText().toString());
|
||||
else
|
||||
search(1, radioButton.getText().toString());
|
||||
try {
|
||||
//关闭
|
||||
field.set(dialog, true);
|
||||
dialog.dismiss();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
int i = db.update(DBHelper.TableName, values, "_id = " + sid, null);
|
||||
if (i != -1) {
|
||||
IMM.hideSoftInputFromWindow(editText_title.getWindowToken(), 0);
|
||||
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
|
||||
if (radioButton == null)
|
||||
search(0, editText.getText().toString());
|
||||
else
|
||||
search(1, radioButton.getText().toString());
|
||||
try { //关闭
|
||||
field.set(dialog, true);
|
||||
dialog.dismiss();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
} else
|
||||
Toast.makeText(getApplicationContext(), "修改失败", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
if (stitle.equals("")){
|
||||
editText_title.setError("标题不能为空!");
|
||||
|
@ -380,8 +381,11 @@ public class FavoriteActivity extends Activity {
|
|||
position = listView.getFirstVisiblePosition();
|
||||
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
|
||||
helper = new DBHelper(getApplicationContext());
|
||||
helper.del(id);
|
||||
search(0, editText.getText().toString());
|
||||
int i = helper.del(id);
|
||||
if (i != -1)
|
||||
search(0, editText.getText().toString());
|
||||
else
|
||||
Toast.makeText(getApplicationContext(), "删除失败", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
@ -414,7 +418,7 @@ public class FavoriteActivity extends Activity {
|
|||
if (type == 0) {
|
||||
cursor1 = helper.query(s);
|
||||
} else if (type == 1) {
|
||||
cursor1 = helper.queryCategoty(s);
|
||||
cursor1 = helper.queryCategory(s);
|
||||
}
|
||||
int count = cursor1.getCount();
|
||||
setTitle("收藏夹 - " + s + " " + count);
|
||||
|
@ -449,15 +453,11 @@ public class FavoriteActivity extends Activity {
|
|||
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
radioGroup.removeAllViews();
|
||||
DBHelper helper = new DBHelper(this);
|
||||
Cursor cursor = helper.category("");
|
||||
Cursor cursor = helper.category();
|
||||
if (cursor != null) {
|
||||
RadioButton radioButton = new RadioButton(this);
|
||||
radioButton.setText("无分类");
|
||||
radioButton.setOnClickListener(new RadioButtonOnClickListener());
|
||||
radioGroup.addView(radioButton);
|
||||
while (cursor.moveToNext()) {
|
||||
String s = cursor.getString(cursor.getColumnIndex("category"));
|
||||
radioButton = new RadioButton(this);
|
||||
RadioButton radioButton = new RadioButton(this);
|
||||
radioButton.setText(s);
|
||||
radioButton.setOnClickListener(new RadioButtonOnClickListener());
|
||||
radioGroup.addView(radioButton);
|
||||
|
@ -496,7 +496,7 @@ public class FavoriteActivity extends Activity {
|
|||
}
|
||||
BW.write(s);
|
||||
BW.flush();
|
||||
Toast.makeText(FavoriteActivity.this, "写文件 " + MainActivity.dir + File.separator + filename + " 成功", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), "写文件 " + MainActivity.dir + File.separator + filename + " 成功", Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
Log.e(Thread.currentThread().getStackTrace()[2] + "", e.toString());
|
||||
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
|
||||
|
|
|
@ -673,7 +673,7 @@ public class MainActivity extends Activity {
|
|||
}
|
||||
|
||||
private void MenuDialog() {
|
||||
String[] items = { "新建窗口", "关闭当前窗口", "收藏当前页", "收藏夹", "查找", "分享", "网页信息", "视频独立播放", "视频截图", "视频在播放器中打开", "资源探查", "查看源码", "保存", "全屏", "广告过滤规则", "清除当前页面缓存", "设置", "检查更新", "关于", "退出" };
|
||||
String[] items = { "新建窗口", "关闭当前窗口", "收藏当前页", "收藏夹", "查找", "分享", "网页信息", "视频独立播放", "视频截图", "视频在播放器中打开", "资源探查", "查看源码", "保存", "全屏", "广告过滤规则", "清除当前页面缓存", "设置", "检查更新", "关于", "退出", "ExpandableListView" };
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("菜单");
|
||||
//builder.setIcon(android.R.drawable.ic_menu_preferences);
|
||||
|
@ -719,7 +719,7 @@ public class MainActivity extends Activity {
|
|||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("");
|
||||
DBHelper helper = new DBHelper(MainActivity.this);
|
||||
Cursor cursor = helper.category("");
|
||||
Cursor cursor = helper.category();
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String s = cursor.getString(cursor.getColumnIndex("category"));
|
||||
|
@ -959,6 +959,10 @@ public class MainActivity extends Activity {
|
|||
unregisterReceiver(receiver);
|
||||
MainActivity.this.finish();
|
||||
break;
|
||||
case 20:
|
||||
intent = new Intent(MainActivity.this, FavoriteActivity1.class);
|
||||
startActivityForResult(intent, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">海天鹰浏览器</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
</resources>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">海天鹰浏览器</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue