diff --git a/app/src/main/java/com/qsboy/antirecall/access/MainService.java b/app/src/main/java/com/qsboy/antirecall/access/MainService.java index dce901a..a0900e1 100644 --- a/app/src/main/java/com/qsboy/antirecall/access/MainService.java +++ b/app/src/main/java/com/qsboy/antirecall/access/MainService.java @@ -7,7 +7,6 @@ package com.qsboy.antirecall.access; import android.accessibilityservice.AccessibilityService; -import android.graphics.Rect; import android.util.Log; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; @@ -159,7 +158,8 @@ private class WXAutoLogin { private int time = 0; public void flagEnable() { - time = 10; + if (App.isWeChatAutoLogin) + time = 10; } private void autoLoginWX() { diff --git a/app/src/main/java/com/qsboy/antirecall/ui/QQFragment.java b/app/src/main/java/com/qsboy/antirecall/ui/QQFragment.java index b7196e4..0238e76 100644 --- a/app/src/main/java/com/qsboy/antirecall/ui/QQFragment.java +++ b/app/src/main/java/com/qsboy/antirecall/ui/QQFragment.java @@ -20,7 +20,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.view.WindowManager; import android.widget.ImageView; import android.widget.RelativeLayout; @@ -58,15 +57,28 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa max = dao.getMaxID(Table_Recalled_Messages); handler = new Handler(); - adjuster = view.findViewById(R.id.adjuster); recyclerViewRecalled = view.findViewById(R.id.main_recycler_view_recall); recyclerViewAll = view.findViewById(R.id.main_recycler_view_all); adapterRecalled = new MessageAdapter(dao, null, getActivity(), App.THEME_BLUE); adapterAll = new MessageAdapter(dao, null, getActivity(), App.THEME_RED); + adjuster = view.findViewById(R.id.adjuster); initList(recyclerViewRecalled, adapterRecalled, prepareRecalledData()); - initList(recyclerViewAll, adapterAll, prepareAllData()); + if (App.isShowAllQQMessages) { + initList(recyclerViewAll, adapterAll, prepareAllData()); + initAdjuster(view); + } else { + setRecyclerViewRecalledHeight(App.layoutHeight); + App.layoutHeight = -1; + adjuster.setVisibility(View.GONE); + } + + + return view; + } + private void initAdjuster(View view) { + adjuster.setVisibility(View.VISIBLE); relativeLayout = view.findViewById(R.id.relative_layout_lists); relativeLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override @@ -116,8 +128,6 @@ public boolean onTouch(View v, MotionEvent event) { return true; } }); - - return view; } private void onMeasured() { @@ -131,22 +141,20 @@ private void onMeasured() { private void setRecyclerViewAllHeight(int height) { ViewGroup.LayoutParams params = recyclerViewAll.getLayoutParams(); - params.height = App.recyclerViewAllHeight = height; + params.height = height; + App.recyclerViewAllHeight = height; +// App.recyclerViewRecalledHeight = App.layoutHeight - height; recyclerViewAll.setLayoutParams(params); } private void setRecyclerViewRecalledHeight(int height) { ViewGroup.LayoutParams params = recyclerViewRecalled.getLayoutParams(); - params.height = App.recyclerViewRecalledHeight = height; + params.height = height; + App.recyclerViewRecalledHeight = height; +// App.recyclerViewAllHeight = App.layoutHeight - height; recyclerViewRecalled.setLayoutParams(params); } -// private void setAdjusterY(int y) { -// RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) adjuster.getLayoutParams(); -// params.topMargin = App.adjusterY = y; -// adjuster.setLayoutParams(params); -// } - private void initList(RecyclerView recyclerView, MessageAdapter adapter, List messages) { if (messages != null && messages.size() != 0) adapter.addData(messages); diff --git a/app/src/main/java/com/qsboy/antirecall/ui/WeChatFragment.java b/app/src/main/java/com/qsboy/antirecall/ui/WeChatFragment.java index 79efc58..5fc048d 100644 --- a/app/src/main/java/com/qsboy/antirecall/ui/WeChatFragment.java +++ b/app/src/main/java/com/qsboy/antirecall/ui/WeChatFragment.java @@ -36,8 +36,8 @@ public class WeChatFragment extends Fragment { String TAG = "WeChatFragment"; // RecyclerView recyclerView; - RecyclerView recyclerViewAll; - MessageAdapter adapterAll; + RecyclerView recyclerView; + MessageAdapter adapter; ImageView adjuster; Dao dao; @@ -49,25 +49,31 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View view = inflater.inflate(R.layout.list_messages, container, false); dao = Dao.getInstance(getContext(), Dao.DB_NAME_WE_CHAT); - adapterAll = new MessageAdapter(dao, null, getActivity(), App.THEME_GREEN); - recyclerViewAll = view.findViewById(R.id.main_recycler_view_all); max = dao.getMaxID(Table_Recalled_Messages); + + recyclerView = view.findViewById(R.id.main_recycler_view_all); + adapter = new MessageAdapter(dao, null, getActivity(), App.THEME_GREEN); adjuster = view.findViewById(R.id.adjuster); adjuster.setVisibility(View.GONE); List messages = prepareAllData(); if (messages != null && messages.size() != 0) - adapterAll.addData(messages); - - recyclerViewAll.setLayoutManager(new LinearLayoutManager(getActivity())); - recyclerViewAll.setAdapter(adapterAll); + adapter.addData(messages); - ItemDragAndSwipeCallback itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(adapterAll); + ItemDragAndSwipeCallback itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(adapter); ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemDragAndSwipeCallback); - itemTouchHelper.attachToRecyclerView(recyclerViewAll); + itemTouchHelper.attachToRecyclerView(recyclerView); + + recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + recyclerView.setAdapter(adapter); + + if (App.isSwipeRemoveOn) + adapter.enableSwipeItem(); + else + adapter.disableSwipeItem(); - adapterAll.enableSwipeItem(); - adapterAll.setOnItemSwipeListener(onItemSwipeListener); + adapter.enableSwipeItem(); + adapter.setOnItemSwipeListener(onItemSwipeListener); return view; } @@ -84,7 +90,7 @@ public void clearView(RecyclerView.ViewHolder viewHolder, int pos) { @Override public void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos) { - List data = adapterAll.getData(); + List data = adapter.getData(); if (data.size() <= pos) { Log.i(TAG, "onItemSwiped: size is too small: " + pos); return; @@ -105,35 +111,21 @@ public List prepareAllData() { List list = dao.queryAllTheLastMessage(dao.queryAllTables()); Log.i(TAG, "prepareAllData: list: " + list); return list; -// List list = new ArrayList<>(); -// Messages messages; -// cursor[0] = max + 1 - adapter.getData().size(); -// for (int i = 0; i < 10; i++) { -// while (true) { -// cursor[0]--; -// if (cursor[0] == 0) -// return list; -// if ((messages = dao.queryRecallById(cursor[0])) != null) -// break; -// } -// adapter.addData(messages); -// } -// return list; } // TODO: 24/04/2018 refresh public void refresh() { - if (adapterAll == null) + if (adapter == null) return; - if (recyclerViewAll == null) + if (recyclerView == null) return; - List messages = adapterAll.prepareData(); + List messages = adapter.prepareData(); if (messages != null && messages.size() != 0) - if (adapterAll.getData().size() != messages.size()) { - adapterAll.getData().clear(); - adapterAll.addData(messages); + if (adapter.getData().size() != messages.size()) { + adapter.getData().clear(); + adapter.addData(messages); } - adapterAll.notifyDataSetChanged(); - recyclerViewAll.setAdapter(adapterAll); + adapter.notifyDataSetChanged(); + recyclerView.setAdapter(adapter); } }