Commit 2fd14064 authored by Administrator's avatar Administrator

init commit

parents
Pipeline #1389 failed with stages
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.idea
This diff is collapsed.
### Xposed-Rimet
这是一个钉钉的Xposed插件
ratel迁移仓库,迁移自: https://github.com/sky-wei/xposed-rimet
#### Xposed Module Repository
[http://repo.xposed.info/module/com.sky.xposed.rimet](http://repo.xposed.info/module/com.sky.xposed.rimet)
QQ交流群:
1. __731081056__
![](./screenshot/WechatIMG219.jpeg)
## License
Copyright 2019 The sky Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
\ No newline at end of file
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sky.xposed.rimet"
minSdkVersion 21
targetSdkVersion 27
versionCode 7
versionName "1.1.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a"//, "arm64-v8a", "x86","arm64-v8a","x86_64"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
release {
storeFile rootProject.file('script/hermes_key')
storePassword "hermes"
keyAlias "hermes"
keyPassword "hermes"
}
}
buildTypes {
release {
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${project.name}_${variant.flavorName}_v${variant.versionName}.apk"
}
}
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
signingConfig signingConfigs.release
}
}
flavorDimensions "default"
productFlavors {
all { flavor ->
resValue 'string', 'flavor', flavor.name
}
demo {
// 测试渠道
}
plugin {
// 正式发布渠道
dimension "default"
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.sky-wei:xposed-common:1.0.5'
implementation 'com.github.sky-wei:xposed-javax:1.1.6'
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'com.rover12421.AndroidHideApi:android:1.17'
demoImplementation 'org.apache.commons:commons-lang3:3.7'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# Serializable
-keepclasseswithmembernames class * implements java.io.Serializable {*;}
-keep class com.sky.xposed.rimet.Main {*;}
-keep class com.sky.xposed.rimet.StringFog
-keep class rx.** {*;}
-keep class okhttp3.** {*;}
-keep class okio.** {*;}
-keep class com.squareup.** {*;}
-keep class org.apache.** {*;}
-keep class com.google.gson.** {*;}
-keep class android.support.** {*;}
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn com.amap.**
-keep class com.amap.api.maps.**{*;}
-keep class com.autonavi.**{*;}
-keep class com.amap.api.trace.**{*;}
-keep class com.amap.api.location.**{*;}
-keep class com.amap.api.fence.**{*;}
-keep class com.autonavi.aps.amapapi.model.**{*;}
-keep class com.amap.api.services.**{*;}
-keep class com.amap.api.maps2d.**{*;}
-keep class com.amap.api.mapcore2d.**{*;}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sky.xposed.rimet">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name=".App">
<activity android:name=".ui.activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter>
</activity>
<activity android:name=".ui.activity.MapActivity"
android:label="选择位置">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="949931e653928fc485a30726ed6d7063"/>
<service android:name="com.amap.api.location.APSService" />
<meta-data
android:name="xposedmodule"
android:value="true"/>
<meta-data
android:name="xposeddescription"
android:value="钉钉工具"/>
<meta-data
android:name="xposedminversion"
android:value="54"/>
</application>
</manifest>
\ No newline at end of file
com.sky.xposed.rimet.Main
\ No newline at end of file
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet;
import android.app.Application;
import com.sky.xposed.common.util.Alog;
import com.sky.xposed.common.util.ToastUtil;
/**
* Created by sky on 2019/3/26.
*/
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Alog.setDebug(BuildConfig.DEBUG);
// 初始化
ToastUtil.getInstance().init(getApplicationContext());
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet;
/**
* Created by sky on 2019/3/14.
*/
public interface Constant {
interface Rimet {
String PACKAGE_NAME = "com.alibaba.android.rimet";
}
interface Event {
int CLICK = 0x01;
}
interface Color {
int BLUE = 0xFF393A3F;
int TOOLBAR = 0xff303030;
int TITLE = 0xff004198;
int DESC = 0xff303030;
}
interface GroupId {
int GROUP = 999;
}
interface Name {
String TITLE = "钉钉助手";
String RIMET = "rimet";
}
interface XFlag {
int MAIN_MENU = 0x000001;
int ENABLE_LUCKY = 0x000002;
int LUCKY_DELAYED = 0x000003;
int ENABLE_FAST_LUCKY = 0x000004;
int ENABLE_RECALL = 0x000005;
int ENABLE_LOCATION = 0x000006;
int ADDRESS = 0x000007;
int LATITUDE = 0x000008;
int LONGITUDE = 0x000009;
}
interface Preference {
String MAIN_MENU = "main.menu";
String AUTO_LOGIN = "other.autoLogin";
String ACTIVITY_CYCLE = "develop.activityCycle";
String ACTIVITY_START = "develop.activityStart";
String ACTIVITY_RESULT = "develop.activityResult";
String WECHAT_LOG = "develop.wechatLog";
}
interface Flag {
int MAIN = 0xFF000000;
}
interface Plugin {
int MAIN_SETTINGS = 0x00000000;
int DEBUG = 0x01000000;
int DING_DING = 0x02000000;
int LUCKY_MONEY = 0x03000000;
int REMITTANCE = 0x04000000;
}
interface ItemId {
int MAIN_SETTINGS = 60001;
}
interface Key {
String DATA = "data";
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet;
import android.app.ActivityThread;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import com.sky.xposed.common.util.Alog;
import com.sky.xposed.javax.MethodHook;
import com.sky.xposed.javax.XposedPlus;
import com.sky.xposed.javax.XposedUtil;
import com.sky.xposed.rimet.data.M;
import com.sky.xposed.rimet.data.VersionManager;
import com.sky.xposed.rimet.plugin.PluginManager;
import com.sky.xposed.rimet.plugin.interfaces.XConfig;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import com.sky.xposed.rimet.plugin.interfaces.XVersionManager;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
/**
* Created by sky on 2019/3/14.
*/
public class Main implements IXposedHookLoadPackage, MethodHook.ThrowableCallback {
@Override
public void onThrowable(Throwable tr) {
Alog.e("Throwable", tr);
}
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpParam) throws Throwable {
final String packageName = lpParam.packageName;
if (!Constant.Rimet.PACKAGE_NAME.equals(packageName)) return;
// 获取版本管理对象
XVersionManager versionManager = new VersionManager
.Build(ActivityThread.currentActivityThread().getSystemContext())
.build();
if (!versionManager.isSupportVersion()) return;
// 设置默认的参数
XposedPlus.setDefaultInstance(new XposedPlus.Builder(lpParam)
.throwableCallback(this)
.build());
// 获取支持的版本配置
XConfig config = versionManager.getSupportConfig();
XposedUtil
.findMethod(
config.get(M.classz.class_dingtalkbase_multidexsupport_DDApplication),
config.get(M.method.method_dingtalkbase_multidexsupport_DDApplication_onCreate))
.before(param -> {
Application application = (Application) param.thisObject;
Context context = application.getApplicationContext();
if (TextUtils.equals(
config.get(M.classz.class_rimet_LauncherApplication),
application.getClass().getName())) {
XPluginManager pluginManager = new PluginManager
.Build(context)
.setLoadPackageParam(lpParam)
.setVersionManager(versionManager)
.build();
// 开始处理加载的包
pluginManager.handleLoadPackage();
}
});
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data;
import android.content.Context;
import android.content.SharedPreferences;
import com.sky.xposed.rimet.plugin.interfaces.XConfigManager;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Created by sky on 2018/12/24.
*/
public class ConfigManager implements XConfigManager {
private Context mContext;
private SimplePreferences mSimplePreferences;
private Map<String, XConfigManager> mManagerMap = new HashMap<>();
private ConfigManager(Build build) {
mContext = build.mXPluginManager.getContext();
mSimplePreferences = new SimplePreferences(mContext, build.mName);
}
@Override
public String getString(int flag, String defValue) {
return mSimplePreferences.getString(flag, defValue);
}
@Override
public boolean getBoolean(int flag, boolean defValue) {
return mSimplePreferences.getBoolean(flag, defValue);
}
@Override
public int getInt(int flag, int defValue) {
return mSimplePreferences.getInt(flag, defValue);
}
@Override
public Set<String> getStringSet(int flag, Set<String> defValue) {
return mSimplePreferences.getStringSet(flag, defValue);
}
@Override
public void putString(int flag, String value) {
mSimplePreferences.putString(flag, value);
}
@Override
public void putBoolean(int flag, boolean value) {
mSimplePreferences.putBoolean(flag, value);
}
@Override
public void putInt(int flag, int value) {
mSimplePreferences.putInt(flag, value);
}
@Override
public void putStringSet(int flag, Set<String> value) {
mSimplePreferences.putStringSet(flag, value);
}
@Override
public XConfigManager getConfigManager(String name) {
if (mManagerMap.containsKey(name)) {
// 存在了直接返回
return mManagerMap.get(name);
}
// 创建对象
SimplePreferences preferences = new SimplePreferences(mContext, name);
mManagerMap.put(name, preferences);
return preferences;
}
@Override
public void release() {
mManagerMap.clear();
}
/**
* 一个简单属性配置管理类
*/
private final class SimplePreferences implements XConfigManager {
private SharedPreferences mSharedPreferences;
public SimplePreferences(Context context, String name) {
mSharedPreferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
}
@Override
public String getString(int flag, String defValue) {
return mSharedPreferences.getString(Integer.toString(flag), defValue);
}
@Override
public boolean getBoolean(int flag, boolean defValue) {
return mSharedPreferences.getBoolean(Integer.toString(flag), defValue);
}
@Override
public int getInt(int flag, int defValue) {
return mSharedPreferences.getInt(Integer.toString(flag), defValue);
}
@Override
public Set<String> getStringSet(int flag, Set<String> defValue) {
return mSharedPreferences.getStringSet(Integer.toString(flag), defValue);
}
@Override
public void putString(int flag, String value) {
mSharedPreferences.edit().putString(Integer.toString(flag), value).apply();
}
@Override
public void putBoolean(int flag, boolean value) {
mSharedPreferences.edit().putBoolean(Integer.toString(flag), value).apply();
}
@Override
public void putInt(int flag, int value) {
mSharedPreferences.edit().putInt(Integer.toString(flag), value).apply();
}
@Override
public void putStringSet(int flag, Set<String> value) {
mSharedPreferences.edit().putStringSet(Integer.toString(flag), value).apply();
}
@Override
public XConfigManager getConfigManager(String name) {
throw new IllegalArgumentException("不支持当前操作");
}
@Override
public void release() {
throw new IllegalArgumentException("不支持当前操作");
}
}
public static class Build {
private XPluginManager mXPluginManager;
private String mName;
public Build(XPluginManager xPluginManager) {
mXPluginManager = xPluginManager;
}
public Build setConfigName(String name) {
mName = name;
return this;
}
public XConfigManager build() {
return new ConfigManager(this);
}
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data;
/**
* Created by sky on 2019/3/12.
*/
public final class M {
private M() {
}
public static final class classz {
public static final int class_rimet_LauncherApplication = 0x1f000001;
public static final int class_dingtalkbase_multidexsupport_DDApplication = 0x1f000002;
public static final int class_defpackage_MessageDs = 0x1f000003;
public static final int class_plugin_webwx_ui_ExtDeviceWXLoginUI = 0x1f000004;
public static final int class_defpackage_ServiceFactory = 0x1f000005;
public static final int class_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService = 0x1f000006;
public static final int class_defpackage_RedPacketsRpc = 0x1f000007;
public static final int class_defpackage_RedPacketsRpc_9 = 0x1f000008;
public static final int class_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl = 0x1f000009;
public static final int class_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity = 0x1f00000A;
public static final int class_android_dingtalk_redpackets_activities_PickRedPacketsActivity = 0x1f00000B;
public static final int class_android_user_settings_activity_NewSettingActivity = 0x1f00000C;
public static final int class_wukong_im_base_IMDatabase = 0x1f00000D;
}
public static final class method {
public static final int method_dingtalkbase_multidexsupport_DDApplication_onCreate = 0x2f000001;
public static final int method_defpackage_MessageDs_handler = 0x2f000002;
public static final int method_android_dingtalkim_base_model_typeValue = 0x2f000003;
public static final int method_wukong_im_message_MessageImpl_messageContent = 0x2f000004;
public static final int method_wukong_im_message_MessageContentImpl_contents = 0x2f000005;
public static final int method_defpackage_RedPacketsRpc_newInstance = 0x2f000006;
public static final int method_defpackage_ServiceFactory_getService = 0x2f000007;
public static final int method_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService_pickRedEnvelopCluster = 0x2f000008;
public static final int method_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl_initSecurityGuard = 0x2f000009;
public static final int method_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity_initView = 0x2f00000A;
public static final int method_android_dingtalk_redpackets_activities_PickRedPacketsActivity_initView = 0x2f00000B;
public static final int method_android_user_settings_activity_NewSettingActivity_onCreate = 0x2f00000C;
public static final int method_defpackage_MessageDs_recall = 0x2f00000D;
public static final int method_wukong_im_conversation_ConversationImpl_latestMessage = 0x2f00000E;
public static final int method_wukong_im_base_IMDatabase_getWritableDatabase = 0x2f00000F;
public static final int method_defpackage_MessageDs_update = 0x2f000010;
public static final int method_wukong_im_message_MessageContentImpl_TextContentImpl_text = 0x2f000011;
public static final int method_wukong_im_message_MessageContentImpl_TextContentImpl_setText = 0x2f000012;
}
public static final class field {
public static final int field_android_dingtalkim_base_model_DingtalkMessage_msgDisplayType = 0x3f000001;
public static final int field_wukong_im_message_MessageContentImpl_CustomMessageContentImpl_mExtension = 0x3f000002;
public static final int field_android_dingtalkim_base_model_DingtalkMessage_mConversation = 0x3f000003;
}
public static final class key {
public static final int key_sid = 0x4f000001;
public static final int key_clusterid = 0x4f000002;
}
public static final class res {
public static final int res_iv_pick = 0x5f000001;
public static final int res_btn_pick = 0x5f000002;
public static final int res_setting_msg_notice = 0x5f000003;
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data;
import android.content.Context;
import android.content.res.Resources;
import android.util.SparseArray;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import com.sky.xposed.rimet.plugin.interfaces.XResourceManager;
import com.sky.xposed.rimet.plugin.interfaces.XVersionManager;
/**
* Created by sky on 2018/12/25.
*
* 主要针对访问插件资源的管理类
*/
public class ResourceManager implements XResourceManager {
private Context mHookContext;
private Context mPluginContext;
private XVersionManager mVersionManager;
private Theme mTheme;
private ResourceManager(Build build) {
mHookContext = build.mXPluginManager.getContext();
mVersionManager = build.mXPluginManager.getVersionManager();
initResourceManager();
}
/**
* 初始化
*/
private void initResourceManager() {
// 暂时不处理
// try {
// mPluginContext = mWechatContext.createPackageContext(BuildConfig.APPLICATION_ID,
// Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
// } catch (Throwable tr) {
// Alog.e("加载插件资源异常", tr);
// }
}
@Override
public Context getHookContext() {
return mHookContext;
}
@Override
public Context getPluginContext() {
return mPluginContext;
}
@Override
public Resources getHookResources() {
return mHookContext.getResources();
}
@Override
public Resources getPluginResources() {
return mPluginContext.getResources();
}
@Override
public String getString(int resId) {
return mPluginContext.getString(resId);
}
@Override
public String getString(int resId, Object... formatArgs) {
return mPluginContext.getString(resId, formatArgs);
}
@Override
public Theme getTheme() {
return mTheme;
}
public abstract class WeTheme implements Theme {
private SparseArray<Object> mConfig = new SparseArray<>();
public WeTheme() {
// 加载配置
loadConfig();
}
public abstract void loadConfig();
void add(int key, int value) {
mConfig.append(key, value);
}
@Override
public int getColor(int id) {
return (int) mConfig.get(id);
}
@Override
public int getImage(int id) {
return (int) mConfig.get(id);
}
}
public static class Build {
private XPluginManager mXPluginManager;
public Build(XPluginManager xPluginManager) {
mXPluginManager = xPluginManager;
}
public XResourceManager build() {
return new ResourceManager(this);
}
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data;
import android.content.Context;
import android.content.pm.PackageInfo;
import com.sky.xposed.common.util.Alog;
import com.sky.xposed.common.util.PackageUtil;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.data.config.RimetConfig4617;
import com.sky.xposed.rimet.data.config.RimetConfig4618;
import com.sky.xposed.rimet.data.config.RimetConfig4621;
import com.sky.xposed.rimet.data.config.RimetConfig4625;
import com.sky.xposed.rimet.plugin.interfaces.XConfig;
import com.sky.xposed.rimet.plugin.interfaces.XVersionManager;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Created by sky on 2018/9/24.
*
* Hook应用相关版本变量管理类
*/
public class VersionManager implements XVersionManager {
private final static Map<String, Class<? extends XConfig>> CONFIG_MAP = new LinkedHashMap<>();
static {
// 微信版本配置
CONFIG_MAP.put("4.6.17", RimetConfig4617.class);
CONFIG_MAP.put("4.6.18", RimetConfig4618.class);
CONFIG_MAP.put("4.6.20", RimetConfig4618.class);
CONFIG_MAP.put("4.6.21", RimetConfig4621.class);
CONFIG_MAP.put("4.6.25", RimetConfig4625.class);
}
private XConfig mVersionConfig;
private VersionInfo mVersionInfo;
private VersionManager(Build build) {
PackageInfo packageInfo = PackageUtil
.getPackageInfo(build.mContext, Constant.Rimet.PACKAGE_NAME, 0);
if (packageInfo != null) {
// 保存包版本信息
mVersionInfo = new VersionInfo();
mVersionInfo.versionName = packageInfo.versionName;
mVersionInfo.versionCode = packageInfo.versionCode;
}
}
/**
* 获取当前版本名
* @return
*/
@Override
public String getVersionName() {
return mVersionInfo != null ? mVersionInfo.versionName : "";
}
/**
* 获取当前版本号
* @return
*/
@Override
public int getVersionCode() {
return mVersionInfo != null ? mVersionInfo.versionCode : 0;
}
/**
* 判断Hook是否支持当前版本
* @return
*/
@Override
public boolean isSupportVersion() {
return isSupportVersion(getVersionName());
}
/**
* 获取支持版本的配置信息,如果没有适配到返回Null
* @return
*/
@Override
public XConfig getSupportConfig() {
if (mVersionConfig == null) {
mVersionConfig = getSupportConfig(CONFIG_MAP.get(getVersionName()));
}
return mVersionConfig;
}
@Override
public List<String> getSupportVersion() {
return new ArrayList<>(CONFIG_MAP.keySet());
}
/**
* 判断Hook是否支持当前版本
* @return
*/
public boolean isSupportVersion(String versionName) {
return CONFIG_MAP.containsKey(versionName);
}
/**
* 创建指定的配置类
* @param vClass
* @return
*/
private XConfig getSupportConfig(Class<? extends XConfig> vClass) {
if (vClass == null) return null;
try {
// 创建实例
return vClass.newInstance();
} catch (Throwable tr) {
Alog.e("创建版本配置异常", tr);
}
return null;
}
/**
* 版本信息
*/
private final class VersionInfo {
protected String versionName;
protected int versionCode;
}
public static final class Build {
private Context mContext;
public Build(Context context) {
mContext = context;
}
public XVersionManager build() {
return new VersionManager(this);
}
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data.config;
import android.text.TextUtils;
import android.util.SparseArray;
import com.sky.xposed.rimet.plugin.interfaces.XConfig;
/**
* Created by sky on 2019/1/14.
*/
public abstract class RimetConfig implements XConfig {
private SparseArray<Object> mConfig = new SparseArray<>();
public RimetConfig() {
// 加载配置
loadConfig();
}
/**
* 加载配置
*/
protected abstract void loadConfig();
protected void add(int key, String value) {
mConfig.append(key, value);
}
protected void add(int key, boolean value) {
mConfig.append(key, value);
}
protected void add(int key, int value) {
mConfig.append(key, value);
}
@Override
public String get(int key) {
return (String) mConfig.get(key);
}
@Override
public boolean getBoolean(int key) {
return (boolean) mConfig.get(key);
}
@Override
public int getInt(int key) {
return (int) mConfig.get(key);
}
@Override
public boolean has(int key) {
return !TextUtils.isEmpty(get(key));
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data.config;
import com.sky.xposed.rimet.data.M;
/**
* Created by sky on 2019/1/14.
*/
public class RimetConfig4617 extends RimetConfig {
@Override
public void loadConfig() {
/** Class */
add(M.classz.class_rimet_LauncherApplication, "com.alibaba.android.rimet.LauncherApplication");
add(M.classz.class_dingtalkbase_multidexsupport_DDApplication, "com.alibaba.android.dingtalkbase.multidexsupport.DDApplication");
add(M.classz.class_defpackage_MessageDs, "iqd"); // MessageDs
add(M.classz.class_plugin_webwx_ui_ExtDeviceWXLoginUI, "com.tencent.mm.plugin.webwx.ui.ExtDeviceWXLoginUI");
add(M.classz.class_defpackage_ServiceFactory, "jpn"); // ServiceFactory
add(M.classz.class_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService, "com.alibaba.android.dingtalk.redpackets.idl.service.RedEnvelopPickIService");
add(M.classz.class_defpackage_RedPacketsRpc, "ces"); // RedPacketsRpc
add(M.classz.class_defpackage_RedPacketsRpc_9, "ces$9");
add(M.classz.class_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl, "com.alibaba.lightapp.runtime.LightAppRuntimeReverseInterfaceImpl");
add(M.classz.class_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity, "com.alibaba.android.dingtalk.redpackets.activities.FestivalRedPacketsPickActivity");
add(M.classz.class_android_dingtalk_redpackets_activities_PickRedPacketsActivity, "com.alibaba.android.dingtalk.redpackets.activities.PickRedPacketsActivity");
add(M.classz.class_android_user_settings_activity_NewSettingActivity, "com.alibaba.android.user.settings.activity.NewSettingActivity");
add(M.classz.class_wukong_im_base_IMDatabase, "com.alibaba.wukong.im.base.IMDatabase");
/** Method */
add(M.method.method_dingtalkbase_multidexsupport_DDApplication_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_handler, "a"); // INSERT,IGNORE,INSERT_FAIL
add(M.method.method_android_dingtalkim_base_model_typeValue, "typeValue");
add(M.method.method_wukong_im_message_MessageImpl_messageContent, "messageContent");
add(M.method.method_wukong_im_message_MessageContentImpl_contents, "contents");
add(M.method.method_defpackage_RedPacketsRpc_newInstance, "a");
add(M.method.method_defpackage_ServiceFactory_getService, "a");
add(M.method.method_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService_pickRedEnvelopCluster, "pickRedEnvelopCluster");
add(M.method.method_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl_initSecurityGuard, "initSecurityGuard");
add(M.method.method_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity_initView, "a");
add(M.method.method_android_dingtalk_redpackets_activities_PickRedPacketsActivity_initView, "a");
add(M.method.method_android_user_settings_activity_NewSettingActivity_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_recall, "a");
add(M.method.method_wukong_im_conversation_ConversationImpl_latestMessage, "latestMessage");
add(M.method.method_wukong_im_base_IMDatabase_getWritableDatabase, "getWritableDatabase");
add(M.method.method_defpackage_MessageDs_update, "a");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_text, "text");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_setText, "setText");
/** Field */
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_msgDisplayType, "msgDisplayType");
add(M.field.field_wukong_im_message_MessageContentImpl_CustomMessageContentImpl_mExtension, "mExtension");
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_mConversation, "mConversation");
/** Key */
add(M.key.key_sid, "sid");
add(M.key.key_clusterid, "clusterid");
/** Res */
add(M.res.res_iv_pick, "iv_pick");
add(M.res.res_btn_pick, "btn_pick");
add(M.res.res_setting_msg_notice, "setting_msg_notice");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data.config;
import com.sky.xposed.rimet.data.M;
/**
* Created by sky on 2019/1/14.
*/
public class RimetConfig4618 extends RimetConfig {
@Override
public void loadConfig() {
/** Class */
add(M.classz.class_rimet_LauncherApplication, "com.alibaba.android.rimet.LauncherApplication");
add(M.classz.class_dingtalkbase_multidexsupport_DDApplication, "com.alibaba.android.dingtalkbase.multidexsupport.DDApplication");
add(M.classz.class_defpackage_MessageDs, "isl"); // MessageDs
add(M.classz.class_plugin_webwx_ui_ExtDeviceWXLoginUI, "com.tencent.mm.plugin.webwx.ui.ExtDeviceWXLoginUI");
add(M.classz.class_defpackage_ServiceFactory, "jru"); // ServiceFactory
add(M.classz.class_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService, "com.alibaba.android.dingtalk.redpackets.idl.service.RedEnvelopPickIService");
add(M.classz.class_defpackage_RedPacketsRpc, "cez"); // RedPacketsRpc
add(M.classz.class_defpackage_RedPacketsRpc_9, "cez$9");
add(M.classz.class_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl, "com.alibaba.lightapp.runtime.LightAppRuntimeReverseInterfaceImpl");
add(M.classz.class_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity, "com.alibaba.android.dingtalk.redpackets.activities.FestivalRedPacketsPickActivity");
add(M.classz.class_android_dingtalk_redpackets_activities_PickRedPacketsActivity, "com.alibaba.android.dingtalk.redpackets.activities.PickRedPacketsActivity");
add(M.classz.class_android_user_settings_activity_NewSettingActivity, "com.alibaba.android.user.settings.activity.NewSettingActivity");
add(M.classz.class_wukong_im_base_IMDatabase, "com.alibaba.wukong.im.base.IMDatabase");
/** Method */
add(M.method.method_dingtalkbase_multidexsupport_DDApplication_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_handler, "a"); // INSERT,IGNORE,INSERT_FAIL
add(M.method.method_android_dingtalkim_base_model_typeValue, "typeValue");
add(M.method.method_wukong_im_message_MessageImpl_messageContent, "messageContent");
add(M.method.method_wukong_im_message_MessageContentImpl_contents, "contents");
add(M.method.method_defpackage_RedPacketsRpc_newInstance, "a");
add(M.method.method_defpackage_ServiceFactory_getService, "a");
add(M.method.method_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService_pickRedEnvelopCluster, "pickRedEnvelopCluster");
add(M.method.method_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl_initSecurityGuard, "initSecurityGuard");
add(M.method.method_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity_initView, "a");
add(M.method.method_android_dingtalk_redpackets_activities_PickRedPacketsActivity_initView, "a");
add(M.method.method_android_user_settings_activity_NewSettingActivity_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_recall, "a");
add(M.method.method_wukong_im_conversation_ConversationImpl_latestMessage, "latestMessage");
add(M.method.method_wukong_im_base_IMDatabase_getWritableDatabase, "getWritableDatabase");
add(M.method.method_defpackage_MessageDs_update, "a");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_text, "text");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_setText, "setText");
/** Field */
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_msgDisplayType, "msgDisplayType");
add(M.field.field_wukong_im_message_MessageContentImpl_CustomMessageContentImpl_mExtension, "mExtension");
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_mConversation, "mConversation");
/** Key */
add(M.key.key_sid, "sid");
add(M.key.key_clusterid, "clusterid");
/** Res */
add(M.res.res_iv_pick, "iv_pick");
add(M.res.res_btn_pick, "btn_pick");
add(M.res.res_setting_msg_notice, "setting_msg_notice");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data.config;
import com.sky.xposed.rimet.data.M;
/**
* Created by sky on 2019/1/14.
*/
public class RimetConfig4621 extends RimetConfig {
@Override
public void loadConfig() {
/** Class */
add(M.classz.class_rimet_LauncherApplication, "com.alibaba.android.rimet.LauncherApplication");
add(M.classz.class_dingtalkbase_multidexsupport_DDApplication, "com.alibaba.android.dingtalkbase.multidexsupport.DDApplication");
add(M.classz.class_defpackage_MessageDs, "ivh"); // MessageDs
add(M.classz.class_plugin_webwx_ui_ExtDeviceWXLoginUI, "com.tencent.mm.plugin.webwx.ui.ExtDeviceWXLoginUI");
add(M.classz.class_defpackage_ServiceFactory, "jut"); // ServiceFactory
add(M.classz.class_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService, "com.alibaba.android.dingtalk.redpackets.idl.service.RedEnvelopPickIService");
add(M.classz.class_defpackage_RedPacketsRpc, "cfe"); // RedPacketsRpc
add(M.classz.class_defpackage_RedPacketsRpc_9, "cfe$9");
add(M.classz.class_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl, "com.alibaba.lightapp.runtime.LightAppRuntimeReverseInterfaceImpl");
add(M.classz.class_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity, "com.alibaba.android.dingtalk.redpackets.activities.FestivalRedPacketsPickActivity");
add(M.classz.class_android_dingtalk_redpackets_activities_PickRedPacketsActivity, "com.alibaba.android.dingtalk.redpackets.activities.PickRedPacketsActivity");
add(M.classz.class_android_user_settings_activity_NewSettingActivity, "com.alibaba.android.user.settings.activity.NewSettingActivity");
add(M.classz.class_wukong_im_base_IMDatabase, "com.alibaba.wukong.im.base.IMDatabase");
/** Method */
add(M.method.method_dingtalkbase_multidexsupport_DDApplication_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_handler, "a"); // INSERT,IGNORE,INSERT_FAIL
add(M.method.method_android_dingtalkim_base_model_typeValue, "typeValue");
add(M.method.method_wukong_im_message_MessageImpl_messageContent, "messageContent");
add(M.method.method_wukong_im_message_MessageContentImpl_contents, "contents");
add(M.method.method_defpackage_RedPacketsRpc_newInstance, "a");
add(M.method.method_defpackage_ServiceFactory_getService, "a");
add(M.method.method_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService_pickRedEnvelopCluster, "pickRedEnvelopCluster");
add(M.method.method_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl_initSecurityGuard, "initSecurityGuard");
add(M.method.method_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity_initView, "a");
add(M.method.method_android_dingtalk_redpackets_activities_PickRedPacketsActivity_initView, "a");
add(M.method.method_android_user_settings_activity_NewSettingActivity_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_recall, "a");
add(M.method.method_wukong_im_conversation_ConversationImpl_latestMessage, "latestMessage");
add(M.method.method_wukong_im_base_IMDatabase_getWritableDatabase, "getWritableDatabase");
add(M.method.method_defpackage_MessageDs_update, "a");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_text, "text");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_setText, "setText");
/** Field */
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_msgDisplayType, "msgDisplayType");
add(M.field.field_wukong_im_message_MessageContentImpl_CustomMessageContentImpl_mExtension, "mExtension");
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_mConversation, "mConversation");
/** Key */
add(M.key.key_sid, "sid");
add(M.key.key_clusterid, "clusterid");
/** Res */
add(M.res.res_iv_pick, "iv_pick");
add(M.res.res_btn_pick, "btn_pick");
add(M.res.res_setting_msg_notice, "setting_msg_notice");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data.config;
import com.sky.xposed.rimet.data.M;
/**
* Created by sky on 2019/1/14.
*/
public class RimetConfig4625 extends RimetConfig {
@Override
public void loadConfig() {
/** Class */
add(M.classz.class_rimet_LauncherApplication, "com.alibaba.android.rimet.LauncherApplication");
add(M.classz.class_dingtalkbase_multidexsupport_DDApplication, "com.alibaba.android.dingtalkbase.multidexsupport.DDApplication");
add(M.classz.class_defpackage_MessageDs, "ivh,jbk"); // MessageDs
add(M.classz.class_plugin_webwx_ui_ExtDeviceWXLoginUI, "com.tencent.mm.plugin.webwx.ui.ExtDeviceWXLoginUI");
add(M.classz.class_defpackage_ServiceFactory, "jut,kaw"); // ServiceFactory
add(M.classz.class_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService, "com.alibaba.android.dingtalk.redpackets.idl.service.RedEnvelopPickIService");
add(M.classz.class_defpackage_RedPacketsRpc, "cfe"); // RedPacketsRpc
add(M.classz.class_defpackage_RedPacketsRpc_9, "cfe$9");
add(M.classz.class_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl, "com.alibaba.lightapp.runtime.LightAppRuntimeReverseInterfaceImpl");
add(M.classz.class_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity, "com.alibaba.android.dingtalk.redpackets.activities.FestivalRedPacketsPickActivity");
add(M.classz.class_android_dingtalk_redpackets_activities_PickRedPacketsActivity, "com.alibaba.android.dingtalk.redpackets.activities.PickRedPacketsActivity");
add(M.classz.class_android_user_settings_activity_NewSettingActivity, "com.alibaba.android.user.settings.activity.NewSettingActivity");
add(M.classz.class_wukong_im_base_IMDatabase, "com.alibaba.wukong.im.base.IMDatabase");
/** Method */
add(M.method.method_dingtalkbase_multidexsupport_DDApplication_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_handler, "a,a"); // INSERT,IGNORE,INSERT_FAIL
add(M.method.method_android_dingtalkim_base_model_typeValue, "typeValue");
add(M.method.method_wukong_im_message_MessageImpl_messageContent, "messageContent");
add(M.method.method_wukong_im_message_MessageContentImpl_contents, "contents");
add(M.method.method_defpackage_RedPacketsRpc_newInstance, "a");
add(M.method.method_defpackage_ServiceFactory_getService, "a,a");
add(M.method.method_android_dingtalk_redpackets_idl_service_RedEnvelopPickIService_pickRedEnvelopCluster, "pickRedEnvelopCluster");
add(M.method.method_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl_initSecurityGuard, "initSecurityGuard");
add(M.method.method_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity_initView, "a");
add(M.method.method_android_dingtalk_redpackets_activities_PickRedPacketsActivity_initView, "a");
add(M.method.method_android_user_settings_activity_NewSettingActivity_onCreate, "onCreate");
add(M.method.method_defpackage_MessageDs_recall, "a,a");
add(M.method.method_wukong_im_conversation_ConversationImpl_latestMessage, "latestMessage");
add(M.method.method_wukong_im_base_IMDatabase_getWritableDatabase, "getWritableDatabase");
add(M.method.method_defpackage_MessageDs_update, "a,a");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_text, "text");
add(M.method.method_wukong_im_message_MessageContentImpl_TextContentImpl_setText, "setText");
/** Field */
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_msgDisplayType, "msgDisplayType");
add(M.field.field_wukong_im_message_MessageContentImpl_CustomMessageContentImpl_mExtension, "mExtension");
add(M.field.field_android_dingtalkim_base_model_DingtalkMessage_mConversation, "mConversation");
/** Key */
add(M.key.key_sid, "sid");
add(M.key.key_clusterid, "clusterid");
/** Res */
add(M.res.res_iv_pick, "iv_pick");
add(M.res.res_btn_pick, "btn_pick");
add(M.res.res_setting_msg_notice, "setting_msg_notice");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.data.model;
import com.sky.xposed.rimet.plugin.interfaces.XPlugin;
/**
* Created by sky on 2018/12/30.
*/
public class PluginInfo implements XPlugin.Info {
private int id;
private String name;
private String desc;
public PluginInfo(int id, String name) {
this(id, name, "这是一个牛逼的功能");
}
public PluginInfo(int id, String name, String desc) {
this.id = id;
this.name = name;
this.desc = desc;
}
@Override
public int getId() {
return id;
}
@Override
public String getName() {
return name;
}
@Override
public String getDesc() {
return desc;
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.SparseArray;
import com.sky.xposed.common.util.Alog;
import com.sky.xposed.common.util.ToastUtil;
import com.sky.xposed.rimet.BuildConfig;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.data.ConfigManager;
import com.sky.xposed.rimet.data.ResourceManager;
import com.sky.xposed.rimet.plugin.develop.DevelopPlugin;
import com.sky.xposed.rimet.plugin.dingding.DingDingHandler;
import com.sky.xposed.rimet.plugin.dingding.DingDingPlugin;
import com.sky.xposed.rimet.plugin.interfaces.XConfigManager;
import com.sky.xposed.rimet.plugin.interfaces.XPlugin;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import com.sky.xposed.rimet.plugin.interfaces.XResourceManager;
import com.sky.xposed.rimet.plugin.interfaces.XVersionManager;
import com.sky.xposed.rimet.plugin.main.SettingsPlugin;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
/**
* Created by sky on 2018/9/24.
*/
public class PluginManager implements XPluginManager {
private static XPluginManager sXPluginManager;
private Context mContext;
private Handler mHandler;
private XC_LoadPackage.LoadPackageParam mLoadPackageParam;
private XVersionManager mVersionManager;
private XResourceManager mResourceManager;
private XConfigManager mConfigManager;
private Map<Class, Object> mObjectMap = new HashMap<>();
private SparseArray<XPlugin> mXPlugins = new SparseArray<>();
private PluginManager(Build build) {
mContext = build.mContext;
mLoadPackageParam = build.mLoadPackageParam;
mVersionManager = build.mXVersionManager;
// 调试开关
Alog.setDebug(BuildConfig.DEBUG);
mHandler = new PluginHandler();
ToastUtil.getInstance().init(mContext);
Picasso.setSingletonInstance(new Picasso.Builder(mContext).build());
// 个别需要静态引用
sXPluginManager = this;
}
public static XPluginManager getInstance() {
return sXPluginManager;
}
/**
* 开始处理需要Hook的插件
*/
@Override
public void handleLoadPackage() {
if (mXPlugins.size() != 0
|| !getVersionManager().isSupportVersion()) {
Alog.d("暂时不需要处理加载的包!");
return;
}
// 加载插件
loadPlugin();
for (int i = 0; i < mXPlugins.size(); i++) {
// 开始处理
handleLoadPackage(mXPlugins.get(mXPlugins.keyAt(i)));
}
}
@Override
public void release() {
mXPlugins.clear();
}
@Override
public Context getContext() {
return mContext;
}
@Override
public Handler getHandler() {
return mHandler;
}
@Override
public XC_LoadPackage.LoadPackageParam getLoadPackageParam() {
return mLoadPackageParam;
}
@Override
public XVersionManager getVersionManager() {
return mVersionManager;
}
@Override
public XConfigManager getConfigManager() {
if (mConfigManager == null) {
mConfigManager = new ConfigManager
.Build(this)
.setConfigName(Constant.Name.RIMET)
.build();
}
return mConfigManager;
}
@Override
public XResourceManager getResourceManager() {
if (mResourceManager == null) {
mResourceManager = new ResourceManager
.Build(this)
.build();
}
return mResourceManager;
}
/**
* 获取所有插件
* @return
*/
@Override
public List<XPlugin> getXPlugins(int flag) {
List<XPlugin> xPlugins = new ArrayList<>();
for (int i = 0; i < mXPlugins.size(); i++) {
XPlugin xPlugin = mXPlugins.get(mXPlugins.keyAt(i));
if ((xPlugin.getInfo().getId() & flag) > 0) {
// 添加到列表中
xPlugins.add(xPlugin);
}
}
return xPlugins;
}
@Override
public XPlugin getXPlugin(XPlugin.Info info) {
return getXPluginById(info.getId());
}
@Override
public XPlugin getXPluginById(int id) {
return mXPlugins.get(id);
}
@Override
public <T> T getObject(Class<T> tClass) {
if (mObjectMap.containsKey(tClass)) {
return (T) mObjectMap.get(tClass);
}
try {
// 创建实例
T result = tClass.getConstructor(
XPluginManager.class).newInstance(this);
// 保存实例
mObjectMap.put(tClass, result);
return result;
} catch (Throwable tr) {
Alog.e("创建版本配置异常", tr);
}
return null;
}
/**
* 开始处理需要Hook的插件
* @param xPlugin
*/
private void handleLoadPackage(XPlugin xPlugin) {
if (!xPlugin.isHandler()) return;
try {
// 初始化
xPlugin.initialization();
// 处理
xPlugin.onHandleLoadPackage();
} catch (Throwable tr) {
Alog.e("handleLoadPackage异常", tr);
}
}
/**
* 加载需要处理的插件
*/
private void loadPlugin() {
addPlugin(new SettingsPlugin(this));
addPlugin(new DingDingPlugin
.Build(this)
.setHandler(new DingDingHandler(this))
.build());
if (BuildConfig.DEBUG) {
addPlugin(new DevelopPlugin(this));
}
}
/**
* 添加到插件到列表中
* @param xPlugin
*/
private void addPlugin(XPlugin xPlugin) {
mXPlugins.append(xPlugin.getInfo().getId(), xPlugin);
}
private final class PluginHandler extends Handler {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
}
}
public static class Build {
private Context mContext;
private XC_LoadPackage.LoadPackageParam mLoadPackageParam;
private XVersionManager mXVersionManager;
public Build(Context context) {
mContext = context;
}
public Build setLoadPackageParam(XC_LoadPackage.LoadPackageParam loadPackageParam) {
mLoadPackageParam = loadPackageParam;
return this;
}
public Build setVersionManager(XVersionManager xVersionManager) {
mXVersionManager = xVersionManager;
return this;
}
public XPluginManager build() {
return new PluginManager(this);
}
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.base;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import com.sky.xposed.common.util.ResourceUtil;
import com.sky.xposed.javax.XposedUtil;
import com.sky.xposed.rimet.plugin.interfaces.XConfig;
import com.sky.xposed.rimet.plugin.interfaces.XHandler;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import java.lang.reflect.Method;
import de.robv.android.xposed.XposedHelpers;
/**
* Created by sky on 2018/9/24.
*/
public abstract class BaseHandler implements XHandler {
private final XPluginManager mPluginManager;
private final Context mContext;
private final Handler mHandler;
private final XConfig mXConfig;
public BaseHandler(XPluginManager pluginManager) {
mPluginManager = pluginManager;
mContext = mPluginManager.getContext();
mHandler = mPluginManager.getHandler();
mXConfig = mPluginManager.getVersionManager().getSupportConfig();
}
public Context getContext() {
return mContext;
}
public XPluginManager getPluginManager() {
return mPluginManager;
}
public View findViewById(View view, String id) {
if (view == null) return null;
return view.findViewById(ResourceUtil.getId(mContext, id));
}
public void mainPerformClick(final View viewGroup, final String id) {
mHandler.post(() -> performClick(viewGroup, id));
}
public void mainPerformClick(final View view) {
mHandler.post(() -> performClick(view));
}
public void performClick(View viewGroup, String id) {
if (viewGroup == null) return;
Context context = viewGroup.getContext();
performClick(viewGroup.findViewById(ResourceUtil.getId(context, id)));
}
public void performClick(View view) {
if (view != null && view.isShown()) {
// 点击
view.performClick();
}
}
public void postDelayed(Runnable runnable, long delayMillis) {
mHandler.postDelayed(runnable, delayMillis);
}
public XConfig getXConfig() {
return mXConfig;
}
public String getXString(int key) {
return getXConfig().get(key);
}
public Object getObjectField(Object obj, String fieldName) {
return XposedHelpers.getObjectField(obj, fieldName);
}
public Object getObjectField(Object obj, int fieldName) {
return getObjectField(obj, getXString(fieldName));
}
public Class findClass(String className) {
return XposedUtil.findClass(className);
}
public Class findClass(int className) {
return findClass(getXString(className));
}
public Method findMatcherMethod(int className, int methodName, Object... parameterTypes) {
return findMatcherMethod(getXString(className), getXString(methodName), parameterTypes);
}
public Method findMatcherMethod(String classNameList, String methodNameList, Object... parameterTypes) {
if (TextUtils.isEmpty(classNameList)) return null;
// 多个类名
String[] classNames = classNameList.split(",");
String[] methodNames = methodNameList.split(",");
for (int i = 0; i < classNameList.length(); i++) {
Method method = findMethodExactIfExists(
classNames[i], methodNames[i], parameterTypes);
if (method != null) return method;
}
return null;
}
public Method findMethodExactIfExists(String className, String methodName, Object... parameterTypes) {
return XposedHelpers.findMethodExactIfExists(className,
mPluginManager.getLoadPackageParam().classLoader, methodName, parameterTypes);
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.base;
import android.app.ActivityThread;
import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;
import com.sky.xposed.common.util.Alog;
import com.sky.xposed.javax.MethodHook;
import com.sky.xposed.javax.XposedUtil;
import com.sky.xposed.rimet.plugin.interfaces.XConfig;
import com.sky.xposed.rimet.plugin.interfaces.XConfigManager;
import com.sky.xposed.rimet.plugin.interfaces.XPlugin;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import java.lang.reflect.Method;
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;
/**
* Created by sky on 2018/9/24.
*/
public abstract class BasePlugin implements XPlugin {
private final XPluginManager mPluginManager;
private final Context mContext;
private final XC_LoadPackage.LoadPackageParam mParam;
private final XConfig mXConfig;
private final XConfigManager mConfigManager;
public BasePlugin(XPluginManager pluginManager) {
mPluginManager = pluginManager;
mContext = pluginManager.getContext();
mParam = pluginManager.getLoadPackageParam();
mXConfig = mPluginManager.getVersionManager().getSupportConfig();
mConfigManager = pluginManager.getConfigManager();
}
@Override
public boolean isHandler() {
return true;
}
@Override
public void initialization() {
}
@Override
public void release() {
}
@Override
public boolean isEnable(int flag, boolean defValue) {
return mConfigManager.getBoolean(flag, defValue);
}
@Override
public void setEnable(int flag, boolean enable) {
mConfigManager.putBoolean(flag, enable);
}
public Context getSystemContext() {
return ActivityThread.currentActivityThread().getSystemContext();
}
public Context getContext() {
return mContext;
}
public XPluginManager getPluginManager() {
return mPluginManager;
}
public XConfig getXConfig() {
return mXConfig;
}
public XConfigManager getConfigManager() {
return mConfigManager;
}
public XC_LoadPackage.LoadPackageParam getLoadPackageParam() {
return mParam;
}
public String getProcessName() {
return mParam.processName;
}
public String getXString(int key) {
return getXConfig().get(key);
}
public boolean hasXString(int key) {
return getXConfig().has(key);
}
public Class findClass(String className) {
return XposedUtil.findClass(className);
}
public Class findClass(int className) {
return findClass(getXString(className));
}
public Method findMatcherMethod(int className, int methodName, Object... parameterTypes) {
return findMatcherMethod(getXString(className), getXString(methodName), parameterTypes);
}
public Class findClass(String className, ClassLoader classLoader) {
return XposedHelpers.findClass(className, classLoader);
}
public Method findMatcherMethod(String classNameList, String methodNameList, Object... parameterTypes) {
if (TextUtils.isEmpty(classNameList)) return null;
// 多个类名
String[] classNames = classNameList.split(",");
String[] methodNames = methodNameList.split(",");
for (int i = 0; i < classNameList.length(); i++) {
Method method = findMethodExactIfExists(
classNames[i], methodNames[i], parameterTypes);
if (method != null) return method;
}
return null;
}
public Method findMethodExactIfExists(String className, String methodName, Object... parameterTypes) {
return XposedHelpers.findMethodExactIfExists(className, mParam.classLoader, methodName, parameterTypes);
}
public MethodHook findMethod(String className, String methodName, Object... parameterTypes) {
return XposedUtil.findMethod(className, methodName, parameterTypes);
}
public MethodHook findMethod(int className, int methodName, Object... parameterTypes) {
return findMethod(getXString(className), getXString(methodName), parameterTypes);
}
public MethodHook findMethod(Class clazz, String methodName, Object... parameterTypes) {
return XposedUtil.findMethod(clazz, methodName, parameterTypes);
}
public MethodHook findMethod(Class clazz, int methodName, Object... parameterTypes) {
return findMethod(clazz, getXString(methodName), parameterTypes);
}
public MethodHook findConstructor(String className, Object... parameterTypes) {
return XposedUtil.findConstructor(className, parameterTypes);
}
public MethodHook findConstructor(int className, Object... parameterTypes) {
return findConstructor(getXString(className), parameterTypes);
}
public MethodHook findConstructor(Class clazz, Object... parameterTypes) {
return XposedUtil.findConstructor(clazz, parameterTypes);
}
public Object getObjectField(Object obj, String fieldName) {
return XposedHelpers.getObjectField(obj, fieldName);
}
public Object getObjectField(Object obj, int fieldName) {
return getObjectField(obj, getXString(fieldName));
}
public Object invokeOriginalMethod(XC_MethodHook.MethodHookParam param) {
try {
return XposedBridge.invokeOriginalMethod(
param.method, param.thisObject, param.args);
} catch (Throwable e) {
Alog.e("异常了", e);
}
return null;
}
public void showMessage(final String msg) {
mPluginManager.getHandler().post(() -> Toast.makeText(getContext(), msg, Toast.LENGTH_SHORT).show());
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.develop;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import com.sky.xposed.common.util.Alog;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.data.model.PluginInfo;
import com.sky.xposed.rimet.plugin.base.BasePlugin;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import com.sky.xposed.rimet.ui.dialog.DevelopDialog;
import com.sky.xposed.rimet.util.DebugUtil;
import com.sky.xposed.rimet.util.ToStringUtil;
import java.util.Arrays;
/**
* Created by sky on 2018/12/19.
*/
public class DevelopPlugin extends BasePlugin {
public DevelopPlugin(XPluginManager pluginManager) {
super(pluginManager);
}
@Override
public Info getInfo() {
return new PluginInfo(Constant.Plugin.DEBUG, "微信调试");
}
@Override
public void onHandleLoadPackage() {
findMethod("android.app.Activity", "setResult",
int.class, Intent.class)
.before(param -> {
Intent intent = (Intent) param.args[1];
ToStringUtil.toString("Activity#setResult: " + intent.getComponent(), intent);
});
findMethod("android.app.Instrumentation", "execStartActivity",
Context.class, IBinder.class, IBinder.class,
Activity.class, Intent.class, int.class, Bundle.class)
.before(param -> {
Intent intent = (Intent) param.args[4];
ToStringUtil.toString("Instrumentation#execStartActivity: " + intent.getComponent(), intent);
});
// findMethod("android.app.Instrumentation", "execStartActivity",
// Context.class, IBinder.class, IBinder.class,
// Activity.class, Intent.class, int.class,
// Bundle.class, UserHandle.class)
// .before(param -> {
//
// Intent intent = (Intent) param.args[4];
// ToStringUtil.toString("Instrumentation#execStartActivity: " + intent.getComponent(), intent);
// });
//
// findMethod(
// "android.app.Dialog", "show")
// .before(param -> Alog.d(">>>>>>>>>>>>>> dialog " + param.thisObject));
//
// findMethod(
// "android.support.v4.app.Fragment",
// "onCreate", Bundle.class)
// .before(param -> Alog.d(">>>>>>>>>>>>>> Fragment " + param.thisObject.getClass()));
// findMethod("cxw", "getView", int.class, View.class, ViewGroup.class)
// .before(param -> {
//
// int position = (int) param.args[0];
// Adapter adapter = (Adapter) param.thisObject;
//
// Alog.d(">>>>>>>>>>>>>>>>>> " + adapter.getCount());
//
//
// Object message = XposedHelpers.callMethod(param.thisObject, "getItem", position);
// ToStringUtil.toString(message);
//
// });
findMethod("com.alibaba.bee.DBManager", "insert", String.class, Class.class, String.class, ContentValues.class)
.before(param -> {
Alog.d(">>>>>>>>>> insert " + Arrays.toString(param.args));
});
findMethod("com.alibaba.bee.DBManager", "insertWithOnConflict", String.class, Class.class, String.class, ContentValues.class, int.class)
.before(param -> {
Alog.d(">>>>>>>>>> insertWithOnConflict " + Arrays.toString(param.args));
});
findMethod("com.alibaba.bee.DBManager", "update", String.class, Class.class, String.class, ContentValues.class, String.class, String[].class)
.before(param -> {
Alog.d(">>>>>>>>>> update " + Arrays.toString(param.args));
// ContentValues contentValues = (ContentValues) param.args[3];
// Class tClass = (Class) param.args[1];
// String[] strings = (String[]) param.args[5];
//
//// Alog.d(">>>>>>>>>>>>>>>>>> tClass " + tClass);
//
// if ("com.alibaba.wukong.im.message.MessageEntry".equals(tClass.getName())) {
//
// Integer integer = contentValues.getAsInteger("recall");
//
// Alog.d(">>>>>>>>>>>>>> " + Arrays.toString(strings));
//
// if (integer != null && integer.intValue() == 1) {
// DebugUtil.printStackTrace();
// param.setResult(null);
// return;
// }
// }
});
// findMethod("com.alibaba.bee.DBManager", "updateWithOnConflict", String.class, Class.class, String.class, ContentValues.class, String.class, String[].class, int.class)
// .before(param -> {
//
// Alog.d(">>>>>>>>>> updateWithOnConflict " + Arrays.toString(param.args));
// });
//
// findMethod("com.alibaba.bee.DBManager", "delete", String.class, Class.class, String.class, String.class, String[].class)
// .before(param -> {
//
// Alog.d(">>>>>>>>>> delete " + Arrays.toString(param.args));
// });
//
// findMethod("com.alibaba.bee.DBManager", "execRaw", String.class, String.class)
// .before(param -> {
//
// Alog.d(">>>>>>>>>> execRaw " + Arrays.toString(param.args));
// });
//
// findMethod("com.alibaba.bee.DBManager", "execRaw", String.class, String.class, Object[].class)
// .before(param -> {
//
// Alog.d(">>>>>>>>>> execRaw " + Arrays.toString(param.args));
// });
//
// findMethod("com.alibaba.bee.DBManager", "executeWriteTask", String.class, "com.alibaba.sqlcrypto.sqlite.DatabaseTask")
// .before(param -> {
//
// Alog.d(">>>>>>>>>> executeWriteTask " + Arrays.toString(param.args));
// });
//
// findMethod("com.alibaba.bee.DBManager", "execInTransaction", String.class, Runnable.class, "com.alibaba.bee.SQLiteTransactionListener")
// .before(param -> {
//
// Alog.d(">>>>>>>>>> execInTransaction " + Arrays.toString(param.args));
// });
//
// findMethod("com.alibaba.bee.DBManager", "compileStatement", String.class, Class.class, String.class)
// .before(param -> {
//
// Alog.d(">>>>>>>>>> compileStatement " + Arrays.toString(param.args));
//
// Class tClass = (Class) param.args[1];
//
// if ("com.alibaba.wukong.im.message.MessageEntry".equals(tClass.getName())) {
//
// DebugUtil.printStackTrace();
// }
// });
}
@Override
public void openSettings(Activity activity) {
DevelopDialog developDialog = new DevelopDialog();
developDialog.show(activity.getFragmentManager(), "develop");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.dingding;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.data.M;
import com.sky.xposed.rimet.data.model.PluginInfo;
import com.sky.xposed.rimet.plugin.base.BasePlugin;
import com.sky.xposed.rimet.plugin.interfaces.XPlugin;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import com.sky.xposed.rimet.ui.dialog.DingDingDialog;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.List;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
/**
* Created by sky on 2019/3/14.
*/
public class DingDingPlugin extends BasePlugin {
private Handler mHandler;
public DingDingPlugin(Build build) {
super(build.mPluginManager);
mHandler = build.mHandler;
}
@Override
public void setEnable(int flag, boolean enable) {
// super.setEnable(flag, enable); // 不需要处理
mHandler.setEnable(flag, enable);
}
@Override
public Info getInfo() {
return new PluginInfo(Constant.Plugin.DING_DING, Constant.Name.TITLE);
}
@Override
public void onHandleLoadPackage() {
findMethod(
M.classz.class_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl,
M.method.method_lightapp_runtime_LightAppRuntimeReverseInterfaceImpl_initSecurityGuard,
Context.class)
.before(param -> param.setResult(null));
Method methodMessage = findMatcherMethod(
M.classz.class_defpackage_MessageDs,
M.method.method_defpackage_MessageDs_handler,
String.class, Collection.class, boolean.class);
XposedBridge.hookMethod(methodMessage, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
// 处理消息
mHandler.onHandlerMessage((String) param.args[0], (Collection) param.args[1]);
}
});
findMethod(
M.classz.class_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity,
M.method.method_android_dingtalk_redpackets_activities_FestivalRedPacketsPickActivity_initView)
.after(param -> {
// 处理快速打开红包
mHandler.onHandlerFestivalRedPacketsPick((Activity) param.thisObject);
});
findMethod(
M.classz.class_android_dingtalk_redpackets_activities_PickRedPacketsActivity,
M.method.method_android_dingtalk_redpackets_activities_PickRedPacketsActivity_initView)
.after(param -> {
// 处理快速打开红包
mHandler.onHandlerPickRedPackets((Activity) param.thisObject);
});
Method methodRecall = findMatcherMethod(
M.classz.class_defpackage_MessageDs,
M.method.method_defpackage_MessageDs_recall,
String.class, List.class, ContentValues.class);
XposedBridge.hookMethod(methodRecall, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
super.beforeHookedMethod(param);
// 处理撤回消息
if (mHandler.onRecallMessage((ContentValues) param.args[2])) {
// 直接返回0
param.setResult(0);
}
}
});
/**************** 位置信息处理 ******************/
findMethod(
"com.amap.api.location.AMapLocationClient",
"getLastKnownLocation")
.after(param -> param.setResult(mHandler.getLastKnownLocation(param.getResult())));
findMethod(
"com.amap.api.location.AMapLocationClient",
"setLocationListener",
"com.amap.api.location.AMapLocationListener")
.before(param -> param.args[0] = mHandler.onHandlerLocationListener(param.args[0]));
}
@Override
public void openSettings(Activity activity) {
DingDingDialog dialog = new DingDingDialog();
dialog.show(activity.getFragmentManager(), "dingDing");
}
public interface Handler {
void setEnable(int flag, boolean enable);
void onHandlerMessage(String cid, Collection messages);
void onHandlerFestivalRedPacketsPick(Activity activity);
void onHandlerPickRedPackets(Activity activity);
boolean onRecallMessage(ContentValues contentValues);
Object getLastKnownLocation(Object location);
Object onHandlerLocationListener(Object listener);
}
public static class Build {
private XPluginManager mPluginManager;
private Handler mHandler;
public Build(XPluginManager pluginManager) {
mPluginManager = pluginManager;
}
public Build setHandler(Handler handler) {
mHandler = handler;
return this;
}
public XPlugin build() {
return new DingDingPlugin(this);
}
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
import android.view.View;
/**
* Created by starrysky on 16-8-2.
*/
public interface OnItemEventListener {
void onItemEvent(int event, View view, int position, Object... args);
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
/**
* Created by sky on 2019/3/12.
*/
public interface XConfig {
/**
* 获取相应key的值
* @param key
* @return
*/
String get(int key);
/**
* 获取相应key的值
* @param key
* @return
*/
boolean getBoolean(int key);
/**
* 获取相应key的值
* @param key
* @return
*/
int getInt(int key);
/**
* 判断相应key的值是否存在
* @param key
* @return
*/
boolean has(int key);
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
import java.util.Set;
/**
* Created by sky on 2019/3/12.
*/
public interface XConfigManager {
/**
* 获取字符串
* @param flag
* @param defValue
* @return
*/
String getString(int flag, String defValue);
boolean getBoolean(int flag, boolean defValue);
int getInt(int flag, int defValue);
Set<String> getStringSet(int flag, Set<String> defValue);
void putString(int flag, String value);
void putBoolean(int flag, boolean value);
void putInt(int flag, int value);
void putStringSet(int flag, Set<String> value);
/**
* 获取指定名称的配置管理对象
* @param name
* @return
*/
XConfigManager getConfigManager(String name);
void release();
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
/**
* Created by sky on 2018/12/21.
*/
public interface XHandler {
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
import android.app.Activity;
/**
* Created by sky on 2018/12/21.
*/
public interface XPlugin {
/**
* 获取插件信息
* @return
*/
Info getInfo();
/**
* 是否需要处理
* @return
*/
boolean isHandler();
/**
* 初始化
*/
void initialization();
/**
* 处理加载的包
*/
void onHandleLoadPackage();
/**
* 释放
*/
void release();
/**
* 打开设置
*/
void openSettings(Activity activity);
/**
* 是否启用
* @param flag
* @param defValue
*/
boolean isEnable(int flag, boolean defValue);
/**
* 设置是否启用
* @param flag
* @param enable
*/
void setEnable(int flag, boolean enable);
/**
* 插件信息
*/
interface Info {
int getId();
String getName();
String getDesc();
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
import android.content.Context;
import android.os.Handler;
import java.util.List;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
/**
* Created by sky on 2019/3/11.
*/
public interface XPluginManager {
/**
* 返回当前Hook应用的Context
* @return
*/
Context getContext();
/**
* 返回程序创建的Handler
* @return
*/
Handler getHandler();
/**
* 获取加载的包信息
* @return
*/
XC_LoadPackage.LoadPackageParam getLoadPackageParam();
/**
* 获取版本管理对象
* @return
*/
XVersionManager getVersionManager();
/**
* 获取配置管理对象
* @return
*/
XConfigManager getConfigManager();
/**
* 获取资源管理对象
* @return
*/
XResourceManager getResourceManager();
/**
* 获取相应flag的插件
* @param flag
* @return
*/
List<XPlugin> getXPlugins(int flag);
/**
* 获取插件信息获取指定插件
* @param info
* @return
*/
XPlugin getXPlugin(XPlugin.Info info);
/**
* 获取相应id获取相应插件
* @param id
* @return
*/
XPlugin getXPluginById(int id);
/**
* 根据相应的Class获取相应的对象
* @param tClass
* @param <T>
* @return
*/
<T> T getObject(Class<T> tClass);
/**
* 开始处理加载的包
*/
void handleLoadPackage();
/**
* 释放
*/
void release();
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
import android.content.Context;
import android.content.res.Resources;
/**
* Created by sky on 2019/3/12.
*/
public interface XResourceManager {
/**
* 获取相应Hook的Context
* @return
*/
Context getHookContext();
/**
* 获取插件的Context
* @return
*/
Context getPluginContext();
/**
* 获取相应Hook的资源对象
* @return
*/
Resources getHookResources();
/**
* 获取插件的资源对象
* @return
*/
Resources getPluginResources();
/**
* 获取插件的字符串信息
* @param resId
* @return
*/
String getString(int resId);
/**
* 获取插件的字符串信息
* @param resId
* @param formatArgs
* @return
*/
String getString(int resId, Object... formatArgs);
/**
* 获取主题
* @return
*/
Theme getTheme();
/**
* 主题资源接口
*/
interface Theme {
/**
* 获取颜色值
* @param id
* @return
*/
int getColor(int id);
/**
* 获取图片值
* @param id
* @return
*/
int getImage(int id);
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.interfaces;
import java.util.List;
/**
* Created by sky on 2019/3/12.
*/
public interface XVersionManager {
/**
* 获取当前版本名
* @return
*/
String getVersionName();
/**
* 获取当前版本号
* @return
*/
int getVersionCode();
/**
* 判断Hook是否支持当前版本
* @return
*/
boolean isSupportVersion();
/**
* 获取支持版本的配置信息,如果没有适配到返回Null
* @return
*/
XConfig getSupportConfig();
/**
* 获取插件支持的版本
* @return
*/
List<String> getSupportVersion();
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.plugin.main;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import com.sky.xposed.common.ui.view.SimpleItemView;
import com.sky.xposed.common.util.ResourceUtil;
import com.sky.xposed.rimet.BuildConfig;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.data.M;
import com.sky.xposed.rimet.data.model.PluginInfo;
import com.sky.xposed.rimet.plugin.base.BasePlugin;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
/**
* Created by sky on 2018/12/30.
*/
public class SettingsPlugin extends BasePlugin {
public SettingsPlugin(XPluginManager pluginManager) {
super(pluginManager);
}
@Override
public Info getInfo() {
return new PluginInfo(Constant.Plugin.MAIN_SETTINGS, "设置");
}
@Override
public void onHandleLoadPackage() {
findMethod(
M.classz.class_android_user_settings_activity_NewSettingActivity,
M.method.method_android_user_settings_activity_NewSettingActivity_onCreate,
Bundle.class)
.after(param -> {
final Activity activity = (Activity) param.thisObject;
View view = activity.findViewById(ResourceUtil.getId(activity, getXString(M.res.res_setting_msg_notice)));
ViewGroup viewGroup = (ViewGroup) view.getParent();
final int index = viewGroup.indexOfChild(view);
SimpleItemView viewDing = new SimpleItemView(activity);
viewDing.getNameView().setTextSize(17);
viewDing.setName(Constant.Name.TITLE);
viewDing.setExtend("v" + BuildConfig.VERSION_NAME);
viewDing.setOnClickListener(v -> {
// 打开设置
openSettings(activity);
});
viewGroup.addView(viewDing, index);
});
}
@Override
public void openSettings(Activity activity) {
// 打开插件设置
getPluginManager().getXPluginById(Constant.Plugin.DING_DING).openSettings(activity);
// PluginSettingsDialog dialog = new PluginSettingsDialog();
// dialog.show(activity.getFragmentManager(), "settings");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import com.sky.xposed.common.ui.view.ItemMenu;
import com.sky.xposed.common.util.PackageUtil;
import com.sky.xposed.common.util.ToastUtil;
import com.sky.xposed.rimet.BuildConfig;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.R;
import com.sky.xposed.rimet.data.VersionManager;
import com.sky.xposed.rimet.plugin.interfaces.XVersionManager;
import com.sky.xposed.rimet.ui.dialog.DingDingDialog;
import com.sky.xposed.rimet.ui.dialog.LoveDialog;
import com.sky.xposed.rimet.ui.util.ActivityUtil;
import com.sky.xposed.rimet.ui.util.DialogUtil;
public class MainActivity extends Activity {
private ItemMenu imVersion;
private ItemMenu imDingVersion;
private TextView tvSupportVersion;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 初始化
ToastUtil.getInstance().init(getApplicationContext());
XVersionManager versionManager = new VersionManager
.Build(getApplicationContext())
.build();
imVersion = findViewById(R.id.im_version);
imDingVersion = findViewById(R.id.im_ding_version);
tvSupportVersion = findViewById(R.id.tv_support_version);
imVersion.setDesc("v" + BuildConfig.VERSION_NAME);
imDingVersion.setDesc(getDingVersionName());
StringBuilder builder = new StringBuilder();
builder.append(versionManager.isSupportVersion() ? "支持当前版本" : "不支持当前版本");
builder.append("\n支持的版本: " + versionManager.getSupportVersion());
tvSupportVersion.setText(builder.toString());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (BuildConfig.DEBUG) {
getMenuInflater().inflate(R.menu.activity_main_menu, menu);
return true;
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_settings) {
// 显示
DingDingDialog dialog = new DingDingDialog();
dialog.show(getFragmentManager(), "setting");
return true;
}
return super.onOptionsItemSelected(item);
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.im_download:
// 下载
ActivityUtil.openUrl(this, "http://repo.xposed.info/module/com.sky.xposed.rimet");
break;
case R.id.im_source:
// 源地址
ActivityUtil.openUrl(this, "https://github.com/sky-wei/xposed-rimet");
break;
case R.id.im_love:
// 公益
LoveDialog loveDialog = new LoveDialog();
loveDialog.show(getFragmentManager(), "love");
break;
case R.id.im_about:
// 关于
DialogUtil.showAboutDialog(this);
break;
}
}
private String getDingVersionName() {
// 获取版本名
PackageUtil.SimplePackageInfo info = PackageUtil
.getSimplePackageInfo(this, Constant.Rimet.PACKAGE_NAME);
return info == null ? "Unknown" : "v" + info.getVersionName();
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.sky.xposed.common.ui.base.BaseListAdapter;
import com.sky.xposed.common.ui.view.CommentItemView;
import com.sky.xposed.common.util.DisplayUtil;
import com.sky.xposed.rimet.plugin.interfaces.XPlugin;
/**
* Created by sky on 2018/12/30.
*/
public class PluginSettingsAdapter extends BaseListAdapter<XPlugin.Info> {
public PluginSettingsAdapter(Context context) {
super(context);
}
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
CommentItemView commentItemView = new CommentItemView(getContext());
TextView textView = commentItemView.getContentView();
textView.setTextSize(16);
textView.setMinLines(1);
textView.setMaxLines(1);
textView.setHeight(DisplayUtil.dip2px(getContext(), 32));
return commentItemView;
}
public ViewHolder<XPlugin.Info> onCreateViewHolder(View view, int viewType) {
return new PluginListHolder(view, this);
}
private final class PluginListHolder extends ViewHolder<XPlugin.Info> {
private CommentItemView mCommentItemView;
public PluginListHolder(View itemView, BaseListAdapter<XPlugin.Info> baseListAdapter) {
super(itemView, baseListAdapter);
}
public void onInitialize() {
super.onInitialize();
mCommentItemView = (CommentItemView) mItemView;
}
public void onBind(int position, int viewType) {
XPlugin.Info item = getItem(position);
mCommentItemView.setContent(item.getName());
}
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.adapter;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.amap.api.services.core.PoiItem;
import com.sky.xposed.common.ui.base.BaseListAdapter;
import com.sky.xposed.common.ui.util.ViewUtil;
import com.sky.xposed.rimet.R;
/**
* Created by sky on 2019/4/3.
*/
public class SearchResultAdapter extends BaseListAdapter<PoiItem> {
private int selectedPosition = 0;
private String beginAddress;
public SearchResultAdapter(Context context) {
super(context);
}
public String getBeginAddress() {
return beginAddress;
}
public void setBeginAddress(String beginAddress) {
this.beginAddress = beginAddress;
}
public void setSelectedPosition(int selectedPosition) {
this.selectedPosition = selectedPosition;
}
public int getSelectedPosition() {
return selectedPosition;
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
return layoutInflater.inflate(R.layout.item_search_result, parent, false);
}
@Override
public ViewHolder<PoiItem> onCreateViewHolder(View view, int viewType) {
return new SearchResultHolder(view, this);
}
private class SearchResultHolder extends ViewHolder<PoiItem> {
TextView tvTitle;
TextView tvSubTitle;
ImageView ivCheck;
public SearchResultHolder(View view, BaseListAdapter<PoiItem> itemView) {
super(view, itemView);
}
@Override
public void onInitialize() {
super.onInitialize();
tvTitle = mItemView.findViewById(R.id.tv_title);
tvSubTitle = mItemView.findViewById(R.id.tv_title_sub);
ivCheck = mItemView.findViewById(R.id.iv_check);
}
@Override
public void onBind(int position, int viewType) {
PoiItem poiItem = getItem(position);
tvTitle.setText(poiItem.getTitle());
tvSubTitle.setText(poiItemToString(poiItem));
ViewUtil.setVisibility(ivCheck, position == selectedPosition ? View.VISIBLE : View.INVISIBLE);
ViewUtil.setVisibility(tvSubTitle, (position == 0 && poiItem.getPoiId().equals("regeo") ? View.GONE : View.VISIBLE));
}
}
public String poiItemToString(PoiItem poiItem) {
if ("regeo".equals(poiItem.getPoiId())) {
return poiItem.getSnippet();
}
if (beginAddress != null) {
return beginAddress + poiItem.getSnippet();
}
StringBuilder builder = new StringBuilder(poiItem.getProvinceName());
if (!TextUtils.equals(poiItem.getProvinceName(), poiItem.getCityName())) {
builder.append(poiItem.getCityName());
}
builder.append(poiItem.getAdName());
if (!TextUtils.equals(poiItem.getAdName(), poiItem.getSnippet())) {
builder.append(poiItem.getSnippet());
}
return builder.toString();
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.base;
import android.content.SharedPreferences;
import com.sky.xposed.common.ui.base.BaseDialogFragment;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.data.ResourceManager;
import com.sky.xposed.rimet.plugin.PluginManager;
import com.sky.xposed.rimet.plugin.interfaces.XPluginManager;
import com.sky.xposed.rimet.plugin.interfaces.XResourceManager;
/**
* Created by sky on 2018/12/18.
*/
public abstract class BaseDialog extends BaseDialogFragment {
@Override
public SharedPreferences getDefaultSharedPreferences() {
return getSharedPreferences(Constant.Name.RIMET);
}
public XPluginManager getPluginManager() {
return PluginManager.getInstance();
}
public XResourceManager getResourceManager() {
return getPluginManager().getResourceManager();
}
public ResourceManager.Theme getMTheme() {
return getResourceManager().getTheme();
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import com.sky.xposed.common.ui.view.CommonFrameLayout;
import com.sky.xposed.common.ui.view.TitleView;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.R;
import com.sky.xposed.rimet.ui.base.BaseDialog;
import com.sky.xposed.rimet.ui.util.UriUtil;
import com.squareup.picasso.Picasso;
/**
* Created by sky on 2019/3/13.
*/
public abstract class CommonDialog extends BaseDialog {
private TitleView mToolbar;
private CommonFrameLayout mCommonFrameLayout;
@Override
protected View createView(LayoutInflater inflater, ViewGroup container) {
// 不显示默认标题
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
// 初始化View
mCommonFrameLayout = new CommonFrameLayout(getContext());
mToolbar = mCommonFrameLayout.getTitleView();
mToolbar.setBackgroundColor(Constant.Color.TOOLBAR);
// 创建相关的View
createView(mCommonFrameLayout);
return mCommonFrameLayout;
}
public TitleView getTitleView() {
return mToolbar;
}
public CommonFrameLayout getCommonFrameLayout() {
return mCommonFrameLayout;
}
public abstract void createView(CommonFrameLayout frameView);
@Override
protected void initView(View view, Bundle args) {
mToolbar.showBack();
// 设置监听
mToolbar.setOnBackEventListener(view1 -> onCloseDialog());
// 设置图标
Picasso.get()
.load(UriUtil.getResource(R.drawable.ic_action_clear))
.into(getTitleView().getBackView());
}
public void setTitle(String title) {
mToolbar.setTitle(title);
}
/**
* 关闭Dialog
*/
public void onCloseDialog() {
// 关闭界面
dismiss();
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.dialog;
import android.os.Bundle;
import android.view.View;
import com.sky.xposed.common.ui.util.ViewUtil;
import com.sky.xposed.common.ui.view.CommonFrameLayout;
import com.sky.xposed.common.ui.view.SwitchItemView;
/**
* Created by sky on 2019/3/13.
*/
public class DevelopDialog extends CommonDialog {
private SwitchItemView sivDevelopEnable;
@Override
public void createView(CommonFrameLayout frameView) {
sivDevelopEnable = ViewUtil.newSwitchItemView(getContext(), "微信调试");
frameView.addContent(sivDevelopEnable);
}
@Override
protected void initView(View view, Bundle args) {
super.initView(view, args);
setTitle("调试设置");
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.dialog;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.sky.xposed.common.ui.util.ViewUtil;
import com.sky.xposed.common.ui.view.CommonFrameLayout;
import com.sky.xposed.common.ui.view.EditTextItemView;
import com.sky.xposed.common.ui.view.SimpleItemView;
import com.sky.xposed.common.ui.view.SwitchItemView;
import com.sky.xposed.common.util.DisplayUtil;
import com.sky.xposed.rimet.BuildConfig;
import com.sky.xposed.rimet.Constant;
import com.sky.xposed.rimet.plugin.interfaces.XPlugin;
import com.sky.xposed.rimet.ui.activity.MapActivity;
import com.sky.xposed.rimet.ui.util.DialogUtil;
/**
* Created by sky on 2019/3/13.
*/
public class DingDingDialog extends CommonDialog {
private SwitchItemView sivLuckyEnable;
private EditTextItemView sivLuckyDelayed;
private SwitchItemView sivFastLuckyEnable;
private SwitchItemView sivRecallEnable;
private SwitchItemView sivLocationEnable;
private SimpleItemView sivSettingsLocation;
private SimpleItemView sivLove;
private SimpleItemView sivAbout;
@Override
public void createView(CommonFrameLayout frameView) {
sivLuckyEnable = ViewUtil.newSwitchItemView(getContext(), "自动接收红包");
sivLuckyEnable.setDesc("开启时自动接收红包");
sivLuckyDelayed = new EditTextItemView(getContext());
sivLuckyDelayed.setInputType(com.sky.xposed.common.Constant.InputType.NUMBER_SIGNED);
sivLuckyDelayed.setMaxLength(2);
sivLuckyDelayed.setUnit("秒");
sivLuckyDelayed.setName("红包延迟时间");
sivLuckyDelayed.setExtendHint("单位(秒)");
sivFastLuckyEnable = ViewUtil.newSwitchItemView(getContext(), "快速打开红包");
sivFastLuckyEnable.setDesc("开启时快速打开红包");
sivRecallEnable = ViewUtil.newSwitchItemView(getContext(), "消息防撤回");
sivRecallEnable.setDesc("开启时消息不会被撤回");
sivLocationEnable = ViewUtil.newSwitchItemView(getContext(), "虚拟定位(Beta)");
sivLocationEnable.setDesc("开启时会修改当前位置信息");
sivSettingsLocation = ViewUtil.newSimpleItemView(getContext(), "位置信息");
sivSettingsLocation.setExtendHint("设置位置信息");
sivLove = ViewUtil.newSimpleItemView(getContext(), "爱心公益");
sivAbout = ViewUtil.newSimpleItemView(getContext(), "关于");
frameView.addContent(sivLuckyEnable);
frameView.addContent(sivLuckyDelayed);
frameView.addContent(sivFastLuckyEnable);
frameView.addContent(sivRecallEnable);
frameView.addContent(sivLocationEnable);
frameView.addContent(sivSettingsLocation);
frameView.addContent(sivLove);
frameView.addContent(sivAbout);
}
@Override
protected void initView(View view, Bundle args) {
super.initView(view, args);
setTitle(Constant.Name.TITLE);
TextView tvExt = sivSettingsLocation.getExtendView();
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) tvExt.getLayoutParams();
params.leftMargin = DisplayUtil.dip2px(getContext(), 100);
tvExt.setMaxLines(2);
tvExt.setEllipsize(TextUtils.TruncateAt.END);
tvExt.setTextSize(12);
SharedPreferences preferences = getDefaultSharedPreferences();
XPlugin xPlugin = getPluginManager().getXPluginById(Constant.Plugin.DING_DING);
sivLuckyEnable.bind(getDefaultSharedPreferences(),
Integer.toString(Constant.XFlag.ENABLE_LUCKY), true,
(view1, key, value) -> {
xPlugin.setEnable(Constant.XFlag.ENABLE_LUCKY, value);
return true;
});
sivLuckyDelayed.bind(getDefaultSharedPreferences(),
Integer.toString(Constant.XFlag.LUCKY_DELAYED), "",
(view12, key, value) -> true);
sivFastLuckyEnable.bind(getDefaultSharedPreferences(),
Integer.toString(Constant.XFlag.ENABLE_FAST_LUCKY), true,
(view1, key, value) -> {
xPlugin.setEnable(Constant.XFlag.ENABLE_FAST_LUCKY, value);
return true;
});
sivRecallEnable.bind(getDefaultSharedPreferences(),
Integer.toString(Constant.XFlag.ENABLE_RECALL), true,
(view1, key, value) -> {
xPlugin.setEnable(Constant.XFlag.ENABLE_RECALL, value);
return true;
});
sivLocationEnable.bind(getDefaultSharedPreferences(),
Integer.toString(Constant.XFlag.ENABLE_LOCATION), false,
(view1, key, value) -> {
xPlugin.setEnable(Constant.XFlag.ENABLE_LOCATION, value);
return true;
});
// 设置初始信息
sivSettingsLocation.setExtend(preferences.getString(
Integer.toString(Constant.XFlag.ADDRESS), ""));
sivSettingsLocation.setOnClickListener(v -> {
// 跳转到地图界面
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(BuildConfig.APPLICATION_ID, MapActivity.class.getName());
startActivityForResult(intent, 99);
});
sivLove.setOnClickListener(v -> {
// 打开捐赠界面
LoveDialog loveDialog = new LoveDialog();
loveDialog.show(getFragmentManager(), "love");
});
sivAbout.setOnClickListener(v -> {
// 打开关于界面
DialogUtil.showAboutDialog(getContext());
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 99 && resultCode == Activity.RESULT_OK) {
// 保存位置信息
saveLocationInfo(
data.getStringExtra("address"),
data.getDoubleExtra("latitude", 0),
data.getDoubleExtra("longitude", 0));
}
}
/**
* 保存位置信息
* @param address
* @param latitude
* @param longitude
*/
private void saveLocationInfo(String address, double latitude, double longitude) {
getDefaultSharedPreferences()
.edit()
.putString(Integer.toString(Constant.XFlag.ADDRESS), address)
.putString(Integer.toString(Constant.XFlag.LATITUDE), Double.toString(latitude))
.putString(Integer.toString(Constant.XFlag.LONGITUDE), Double.toString(longitude))
.apply();
// 设置UI信息
sivSettingsLocation.setExtend(address);
}
}
This diff is collapsed.
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.util;
import android.location.Location;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.services.core.LatLonPoint;
/**
* Created by sky on 2019/3/26.
*/
public class MapUtil {
private MapUtil() {
}
public static LatLng newLatLng(Location location) {
if (location == null) return null;
return newLatLng(location.getLatitude(), location.getLongitude());
}
public static LatLng newLatLng(LatLonPoint location) {
if (location == null) return null;
return newLatLng(location.getLatitude(), location.getLongitude());
}
public static LatLng newLatLng(double latitude, double longitude) {
return new LatLng(latitude, longitude);
}
public static LatLonPoint newLocation(LatLng latLng) {
return new LatLonPoint(latLng.latitude, latLng.longitude);
}
}
/*
* Copyright (c) 2019 The sky Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sky.xposed.rimet.ui.util;
import android.net.Uri;
import com.sky.xposed.common.util.ResourceUtil;
import com.sky.xposed.rimet.BuildConfig;
/**
* Created by sky on 2018/12/14.
*/
public class UriUtil {
public static Uri getResource(int resId) {
return ResourceUtil.resourceIdToUri(BuildConfig.APPLICATION_ID, resId);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<resources>
<string name="app_name">钉钉助手</string>
</resources>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment