Skip to content

Commit

Permalink
feat: StickerPanelEntryHooker LastSelect
Browse files Browse the repository at this point in the history
Closes #1016
  • Loading branch information
HdShare committed Jun 16, 2024
1 parent 58070d4 commit 3a3c2f3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/src/main/java/cc/hicore/hook/stickerPanel/ICreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import androidx.annotation.NonNull;
import cc.hicore.Env;
import cc.hicore.Utils.Async;
import cc.hicore.Utils.FunConf;
import cc.hicore.hook.stickerPanel.MainItemImpl.InputFromLocalImpl;
import cc.hicore.hook.stickerPanel.MainItemImpl.LocalStickerImpl;
import cc.hicore.hook.stickerPanel.MainItemImpl.PanelSetImpl;
Expand All @@ -41,6 +42,7 @@ public class ICreator extends BottomPopupView{

ArrayList<ViewGroup> mItems = new ArrayList<>();

private boolean open_last_select;
private static long savedSelectID;
private static long lastSelectTime;
private static int savedScrollTo;
Expand Down Expand Up @@ -256,9 +258,9 @@ protected void onCreate() {

initDefItemsLast();

if (System.currentTimeMillis() - lastSelectTime > 60 * 1000){
switchToItem(recentUse);
}else if (savedSelectID != 0){
open_last_select = FunConf.getBoolean("global", "sticker_panel_set_open_last_select", false);
if (open_last_select) savedSelectID = Long.parseLong(FunConf.getString("global", "sticker_panel_set_last_select", String.valueOf(savedSelectID)));
if (savedSelectID != 0){
for (ViewGroup item : mItems){
IMainPanelItem iMainPanelItem = (IMainPanelItem) item.getTag();
if (iMainPanelItem.getID() == savedSelectID){
Expand Down Expand Up @@ -293,6 +295,7 @@ protected void beforeDismiss() {
if (currentTab != null){
savedScrollTo = itemContainer.getScrollY();
savedSelectID = currentTab.getID();
if (open_last_select) FunConf.setString("global", "sticker_panel_set_last_select",String.valueOf(savedSelectID));
lastSelectTime = System.currentTimeMillis();
}
super.beforeDismiss();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public void afterTextChanged(Editable s) {
});
dont_auto_close.setChecked(FunConf.getBoolean("global", "sticker_panel_set_dont_close_panel", false));

CheckBox open_last_select = cacheView.findViewById(R.id.sticker_panel_set_open_last_select);
open_last_select.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()){
FunConf.setBoolean("global", "sticker_panel_set_open_last_select", isChecked);
}
});
open_last_select.setChecked(FunConf.getBoolean("global", "sticker_panel_set_open_last_select", false));

RadioButton show_anim_always = cacheView.findViewById(R.id.sticker_panel_set_rb_show_anim_always);
show_anim_always.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()){
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/sticker_panel_set.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
android:id="@+id/sticker_panel_set_dont_close_panel"
android:text="发送图片后不关闭面板"/>

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:id="@+id/sticker_panel_set_open_last_select"
android:text="关闭面板后保存上次导航栏选择位置"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 3a3c2f3

Please sign in to comment.