收藏夹分类单选改成下拉列表

This commit is contained in:
sonichy 2024-01-19 18:32:37 +08:00
parent 9361ad849d
commit 6c46f679ff
6 changed files with 36 additions and 55 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.32"> android:versionName="4.33">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 查询网络状态权限 --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 查询网络状态权限 -->

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.32</h2> <h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.33</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.33 (2024-01-19)</h3><ol><li>收藏夹分类:使用下拉列表代替单选组。</li></ol>
<h3>V4.32 (2023-11-19)</h3><ol><li>增加GIF屏蔽。</li><li>在Activity中处理广告屏蔽规则。</li></ol> <h3>V4.32 (2023-11-19)</h3><ol><li>增加GIF屏蔽。</li><li>在Activity中处理广告屏蔽规则。</li></ol>
<h3>V4.31 (2023-04-17)</h3><ol><li>取消自动升级,以免因升级错误引起崩溃。</li></ol> <h3>V4.31 (2023-04-17)</h3><ol><li>取消自动升级,以免因升级错误引起崩溃。</li></ol>
<h3>V4.30 (2023-03-23)</h3><ol><li>收藏夹测试 ExpandableListView 控件</li></ol> <h3>V4.30 (2023-03-23)</h3><ol><li>收藏夹测试 ExpandableListView 控件</li></ol>

View File

@ -41,6 +41,8 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.w3c.dom.Text;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
@ -50,10 +52,10 @@ import java.util.ArrayList;
public class FavoriteActivity extends Activity { public class FavoriteActivity extends Activity {
EditText editText; EditText editText;
ImageButton imageButton_clear; ImageButton imageButton_clear;
RadioGroup radioGroup;
InputMethodManager IMM; InputMethodManager IMM;
ListView listView; ListView listView;
SimpleCursorAdapter adapter; SimpleCursorAdapter adapter;
Spinner spinner;
int position = 0; int position = 0;
@Override @Override
@ -67,12 +69,23 @@ public class FavoriteActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
editText.setText(""); editText.setText("");
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
} }
}); });
imageButton_clear.setVisibility(View.GONE); imageButton_clear.setVisibility(View.GONE);
editText = (EditText) findViewById(R.id.editText); editText = (EditText) findViewById(R.id.editText);
editText.addTextChangedListener(new EditChangedListener()); editText.addTextChangedListener(new EditChangedListener());
radioGroup = (RadioGroup) findViewById(R.id.radioGroup); spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Log.e(Thread.currentThread().getStackTrace()[2] + "", "spinner: " + arg2);
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
String s = arg0.getItemAtPosition(arg2).toString();
search(1, s);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
genCategory(); genCategory();
listView = (ListView) findViewById(R.id.listView1); listView = (ListView) findViewById(R.id.listView1);
@ -110,9 +123,6 @@ public class FavoriteActivity extends Activity {
return false; return false;
} }
}); });
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
radioButton.performClick();
} }
@Override @Override
@ -146,8 +156,6 @@ public class FavoriteActivity extends Activity {
helper.insert("category", values); helper.insert("category", values);
IMM.hideSoftInputFromWindow(editText1.getWindowToken(), 0); IMM.hideSoftInputFromWindow(editText1.getWindowToken(), 0);
genCategory(); genCategory();
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
radioButton.performClick();
} else { } else {
Toast.makeText(getApplicationContext(), "分类已存在", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), "分类已存在", Toast.LENGTH_SHORT).show();
} }
@ -159,10 +167,7 @@ public class FavoriteActivity extends Activity {
case 1: case 1:
builder = new AlertDialog.Builder(FavoriteActivity.this); builder = new AlertDialog.Builder(FavoriteActivity.this);
builder.setIcon(android.R.drawable.ic_menu_edit); builder.setIcon(android.R.drawable.ic_menu_edit);
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId()); final String title = spinner.getSelectedItem().toString();
if (radioButton == null)
break;
final String title = radioButton.getText().toString();
if (title.equals("")) if (title.equals(""))
break; break;
builder.setTitle(title); builder.setTitle(title);
@ -181,8 +186,6 @@ public class FavoriteActivity extends Activity {
db.update("category", values, "category = '" + title + "'", null); db.update("category", values, "category = '" + title + "'", null);
db.update(helper.TableName, values, "category = '" + title + "'", null); db.update(helper.TableName, values, "category = '" + title + "'", null);
genCategory(); genCategory();
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
radioButton.performClick();
IMM.hideSoftInputFromWindow(editText_rename.getWindowToken(), 0); IMM.hideSoftInputFromWindow(editText_rename.getWindowToken(), 0);
} }
}); });
@ -196,8 +199,6 @@ public class FavoriteActivity extends Activity {
values.put("category", ""); values.put("category", "");
db.update(helper.TableName, values, "category = '" + title + "'", null); db.update(helper.TableName, values, "category = '" + title + "'", null);
genCategory(); genCategory();
RadioButton radioButton = (RadioButton) radioGroup.getChildAt(0);
radioButton.performClick();
} }
}); });
builder.setNegativeButton("取消", null); builder.setNegativeButton("取消", null);
@ -334,11 +335,11 @@ public class FavoriteActivity extends Activity {
int i = db.update(DBHelper.TableName, values, "_id = " + sid, null); int i = db.update(DBHelper.TableName, values, "_id = " + sid, null);
if (i != -1) { if (i != -1) {
IMM.hideSoftInputFromWindow(editText_title.getWindowToken(), 0); IMM.hideSoftInputFromWindow(editText_title.getWindowToken(), 0);
RadioButton radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId()); String s = spinner.getSelectedItem().toString();
if (radioButton == null) if (s.equals(""))
search(0, editText.getText().toString()); search(0, editText.getText().toString());
else else
search(1, radioButton.getText().toString()); search(1, s);
try { //关闭 try { //关闭
field.set(dialog, true); field.set(dialog, true);
dialog.dismiss(); dialog.dismiss();
@ -396,16 +397,6 @@ public class FavoriteActivity extends Activity {
return true; return true;
} }
class RadioButtonOnClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
RadioButton radioButton = (RadioButton) v;
String s = radioButton.getText().toString();
search(1, s);
}
}
void search(int type, String s) { void search(int type, String s) {
DBHelper helper = new DBHelper(this); DBHelper helper = new DBHelper(this);
Cursor cursor1 = null; Cursor cursor1 = null;
@ -445,17 +436,16 @@ public class FavoriteActivity extends Activity {
void genCategory() { void genCategory() {
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0); IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
radioGroup.removeAllViews(); ArrayList<String> list = new ArrayList<>();
DBHelper helper = new DBHelper(this); DBHelper helper = new DBHelper(this);
Cursor cursor = helper.category(); Cursor cursor = helper.category();
if (cursor != null) { if (cursor != null) {
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
String s = cursor.getString(cursor.getColumnIndex("category")); String s = cursor.getString(cursor.getColumnIndex("category"));
RadioButton radioButton = new RadioButton(this); list.add(s);
radioButton.setText(s);
radioButton.setOnClickListener(new RadioButtonOnClickListener());
radioGroup.addView(radioButton);
} }
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_spinner_item, list);
spinner.setAdapter(adapter);
} }
} }
@ -476,7 +466,6 @@ public class FavoriteActivity extends Activity {
imageButton_clear.setVisibility(View.VISIBLE); imageButton_clear.setVisibility(View.VISIBLE);
} }
search(0, s.toString()); search(0, s.toString());
radioGroup.clearCheck();
} }
} }

View File

@ -9,9 +9,13 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:orientation="horizontal" android:orientation="horizontal">
android:paddingLeft="10dp"
android:paddingRight="10dp"> <Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#888" />
<EditText <EditText
android:id="@+id/editText" android:id="@+id/editText"
@ -33,24 +37,11 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:background="#ffffff" android:background="#ffffff"
android:paddingLeft="-15dp" android:paddingLeft="-5dp"
android:paddingRight="-15dp" android:paddingRight="-5dp"
android:src="@android:drawable/ic_menu_close_clear_cancel" /> android:src="@android:drawable/ic_menu_close_clear_cancel" />
</LinearLayout> </LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
<ListView <ListView
android:id="@+id/listView1" android:id="@+id/listView1"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@ -1 +1 @@
{4.32} {4.33}