-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KeepUnreadボタンをLsPatch用に作成することにより、rootしている端末は、保存するように
- Loading branch information
1 parent
1304e28
commit 8e978ff
Showing
6 changed files
with
172 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
app/src/main/java/io/github/chipppppppppp/lime/hooks/KeepUnreadLSpatch.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package io.github.chipppppppppp.lime.hooks; | ||
|
||
import android.content.Context; | ||
import android.graphics.Color; | ||
import android.graphics.drawable.GradientDrawable; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ListView; | ||
import android.widget.RelativeLayout; | ||
import android.widget.Switch; | ||
import android.widget.TextView; | ||
|
||
import de.robv.android.xposed.XC_MethodHook; | ||
import de.robv.android.xposed.XposedBridge; | ||
import de.robv.android.xposed.XposedHelpers; | ||
import de.robv.android.xposed.callbacks.XC_LoadPackage; | ||
import io.github.chipppppppppp.lime.LimeOptions; | ||
import io.github.chipppppppppp.lime.R; | ||
|
||
public class KeepUnreadLSpatch implements IHook { | ||
static boolean keepUnread = false; | ||
|
||
@Override | ||
public void hook(LimeOptions limeOptions, XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { | ||
if (!limeOptions.KeepUnreadLSpatch.checked) return; | ||
|
||
XposedBridge.hookAllConstructors( | ||
loadPackageParam.classLoader.loadClass("jp.naver.line.android.common.view.listview.PopupListView"), | ||
new XC_MethodHook() { | ||
@Override | ||
protected void afterHookedMethod(MethodHookParam param) throws Throwable { | ||
ViewGroup viewGroup = (ViewGroup) param.thisObject; | ||
Context context = viewGroup.getContext(); | ||
|
||
Context moduleContext = context.getApplicationContext().createPackageContext(Constants.MODULE_NAME, Context.CONTEXT_IGNORE_SECURITY); | ||
String textKeepUnread = moduleContext.getResources().getString(R.string.switch_keep_unread); | ||
|
||
RelativeLayout container = new RelativeLayout(context); | ||
RelativeLayout.LayoutParams containerParams = new RelativeLayout.LayoutParams( | ||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); | ||
container.setLayoutParams(containerParams); | ||
|
||
GradientDrawable background = new GradientDrawable(); | ||
background.setShape(GradientDrawable.RECTANGLE); | ||
background.setColor(Color.parseColor("#06C755")); | ||
background.setCornerRadii(new float[]{100, 100, 80, 30, 100, 100, 80, 30}); | ||
|
||
container.setBackground(background); | ||
|
||
TextView label = new TextView(context); | ||
label.setText(textKeepUnread); | ||
label.setTextSize(18); | ||
label.setTextColor(Color.WHITE); | ||
label.setId(View.generateViewId()); | ||
RelativeLayout.LayoutParams labelParams = new RelativeLayout.LayoutParams( | ||
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); | ||
labelParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); | ||
labelParams.setMargins(40, 0, 0, 0); | ||
container.addView(label, labelParams); | ||
|
||
Switch switchView = new Switch(context); | ||
RelativeLayout.LayoutParams switchParams = new RelativeLayout.LayoutParams( | ||
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); | ||
switchParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); | ||
switchParams.setMargins(0, 0, 40, 0); | ||
switchView.setChecked(false); | ||
switchView.setOnCheckedChangeListener((buttonView, isChecked) -> { | ||
keepUnread = isChecked; | ||
}); | ||
|
||
container.addView(switchView, switchParams); | ||
|
||
((ListView) viewGroup.getChildAt(0)).addFooterView(container); | ||
} | ||
} | ||
); | ||
|
||
XposedHelpers.findAndHookMethod( | ||
loadPackageParam.classLoader.loadClass(Constants.MARK_AS_READ_HOOK.className), | ||
Constants.MARK_AS_READ_HOOK.methodName, | ||
new XC_MethodHook() { | ||
@Override | ||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { | ||
if (keepUnread) { | ||
param.setResult(null); | ||
} | ||
} | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters