Skip to content

Commit

Permalink
i18n support & in-app activation check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikotwa committed Dec 11, 2021
1 parent 435935d commit 16bf6ef
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "com.dualguard"
minSdk 25
targetSdk 31
versionCode 42
versionName "1.0"
versionCode 52
versionName "1.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
19 changes: 4 additions & 15 deletions app/src/main/java/com/dualguard/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,15 @@ import com.dualguard.BuildConfig.VERSION_NAME
class AboutActivity : AbsAboutActivity() {
override fun onCreateHeader(icon: ImageView, slogan: TextView, version: TextView) {
icon.setImageResource(R.drawable.ic_launcher_foreground);
slogan.text = "关于 DualGuard";
slogan.text = getString(R.string.about_slogan);
version.text = "v" + VERSION_NAME;
}

override fun onItemsCreated(items: MutableList<Any>) {
items.add(Category("介绍与帮助"))
items.add(Card("该模块旨在帮助那些购买了 AdGuard 个人版授权,却又拥有刚好大于三台设备的人使用高级特性。"
+ "\n\n"
+ "默认情况下,AdGuard 的个人版授权仅允许激活三台设备。该模块可以让 Android 设备上的 AdGuard 无视该授权限制。"
+ "\n\n"
+ "首先,该模块 *不能,也不会* 免费帮你获得高级版授权。如果你只是想要破解 AdGuard,那么你来错地方了。"
+ "\n\n"
+ "如果你已经拥有合法的 AdGuard 授权,那么请继续阅读使用方法:\n"
+ "1. 下载,安装 AdGuard 本体,并使用你的授权许可激活应用\n"
+ "2. 在 LSPosed 里激活该模块\n"
+ "3. 强行停止 + 重开 AdGuard"
+ "\n\n"
+ "在所有设备上享受高级版权限吧!"))
items.add(Category(getString(R.string.about_module_intro_and_help_title)))
items.add(Card(getString(R.string.about_module_intro_and_help_text)))

items.add(Category("开发者"))
items.add(Category(getString(R.string.about_module_developer_title)))
items.add(
Contributor(
R.drawable.avatar_mogu,
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/com/dualguard/HookLicense.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dualguard
import android.util.Log
import com.github.kyuubiran.ezxhelper.init.EzXHelperInit
import com.github.kyuubiran.ezxhelper.utils.*

import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.IXposedHookZygoteInit
import de.robv.android.xposed.XC_MethodHook
Expand Down Expand Up @@ -43,6 +44,19 @@ class HookLicense : IXposedHookZygoteInit, IXposedHookLoadPackage {
}
}
}

"com.dualguard" -> {
val clazz = lpparam.classLoader.loadClass("com.dualguard.MainActivity")

findAllMethods(clazz) {
name == "isModuleActivated"
}.hookMethod {
after { param ->
Log.d("DualGuard", "Now hooking method: " + param.method.name);
param.result = true
}
}
}
}
}

Expand Down
19 changes: 12 additions & 7 deletions app/src/main/java/com/dualguard/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import android.view.Menu
import android.view.MenuItem
import android.widget.TextView
import android.widget.Toast
import com.afollestad.materialdialogs.MaterialDialog
import com.dualguard.databinding.ActivityMainBinding
Expand All @@ -20,6 +21,10 @@ class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var binding: ActivityMainBinding

private fun isModuleActivated(): Boolean {
return false
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -28,18 +33,18 @@ class MainActivity : AppCompatActivity() {

setSupportActionBar(binding.toolbar)

var text = findViewById<TextView>(R.id.textview_first)
if (isModuleActivated()) text.setText(R.string.first_fragment_enabled)
else text.setText(R.string.first_fragment_disabled)

val navController = findNavController(R.id.nav_host_fragment_content_main)
appBarConfiguration = AppBarConfiguration(navController.graph)
setupActionBarWithNavController(navController, appBarConfiguration)

MaterialDialog(this).show {
title(text = "该应用不是对 AdGuard 现有授权机制的“绕过”")
message(text = "该应用的目的旨在让个人授权用户在拥有多于三台设备的情况下仍能享受到高级版 AdGuard 的授权待遇"
+ "\n\n"
+ "该应用 *不会* 让你免费获得 AdGuard 的高级授权。您原则上仍然需要购买正版授权后才能使用高级权益"
+ "\n\n"
+ "您同意仅将该应用作为上述且个人非营利的用途")
positiveButton(text = "我明白")
title(R.string.main_first_use_notice_title)
message(R.string.main_first_use_notice_text)
positiveButton(R.string.main_first_use_notice_agree)
}

binding.fab.setOnClickListener { view ->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_first.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:id="@+id/textview_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="模块未生效"
android:text=" "
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="action_settings">关于</string>
<string name="main_first_use_notice_title">该应用不是对 AdGuard 现有授权机制的“绕过”</string>
<string name="main_first_use_notice_text">该应用的目的旨在让个人授权用户在拥有多于三台设备的情况下仍能享受到高级版 AdGuard 的授权待遇\n\n该应用 *不会* 让你免费获得 AdGuard 的高级授权。您原则上仍然需要购买正版授权后才能使用高级权益\n\n您同意仅将该应用作为上述且个人非营利的用途</string>
<string name="main_first_use_notice_agree">我同意</string>
<string name="about_slogan">关于 DualGuard</string>
<string name="about_module_intro_and_help_title">简介与帮助</string>
<string name="about_module_developer_title">开发者</string>
<string name="about_module_intro_and_help_text">该模块旨在帮助那些购买了 AdGuard 个人版授权,却又拥有刚好大于三台设备的人使用高级特性。\n\n默认情况下,AdGuard 的个人版授权仅允许激活三台设备。该模块可以让 Android 设备上的 AdGuard 无视该授权限制。\n\n首先,该模块 *不能,也不会* 免费帮你获得高级版授权。如果你只是想要破解 AdGuard,那么你来错地方了。\n\n如果你已经拥有合法的 AdGuard 授权,那么请继续阅读使用方法:\n1. 下载,安装 AdGuard 本体,并使用你的授权许可激活应用\n2. 在 LSPosed 里激活该模块\n3. 强行停止 + 重开 AdGuard\n\n在所有设备上享受高级版权限吧!</string>
<string name="first_fragment_enabled">模块已生效</string>
<string name="first_fragment_disabled">模块未生效</string>
</resources>
26 changes: 20 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<resources>
<string name="app_name">DualGuard</string>
<string name="action_settings">关于</string>
<string name="app_name" translatable="false">DualGuard</string>
<string name="action_settings">About</string>
<!-- Strings used for fragments for navigation -->
<string name="first_fragment_label">DualGuard</string>
<string name="second_fragment_label">Second Fragment</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
<string name="first_fragment_label" translatable="false">DualGuard</string>
<string name="first_fragment_enabled">Module is enabled</string>
<string name="first_fragment_disabled">Module is disabled</string>

<string name="main_first_use_notice_title">This is NOT a bypass for AdGuard subscription</string>
<string name="main_first_use_notice_text">This module is intended for those who have more than three devices. It *won\'t* let you get AdGuard Premium for free. You are required to purchase a valid subscription before using this module. By using this module, you agree that you use it only for personal and non-commercial usage.</string>
<string name="main_first_use_notice_agree">I agree</string>

<string name="about_slogan">About DualGuard</string>

<string name="about_module_intro_and_help_title">Introduction and Assistance</string>
<string name="about_module_intro_and_help_text">This module is designed to help those who have purchased an AdGuard Personal license but have just greater than three devices to use the advanced features. \n\nBy default, the Personal license of AdGuard allows only three devices to be activated. This module allows AdGuard on Android devices to ignore that limit. \n\nFirst of all, the module *can\'t and won\'t* help you get a Premium license for free. If you just want to hack AdGuard, then you\'ve come to the wrong place. If you already have a legitimate AdGuard license, then read on for instructions: \n1. Download, install AdGuard properly and activate the app with your license. \n2. Activate this module in LSPosed. \n3. Force stop + reopen AdGuard. \n\nEnjoy Premium access on all your devices!</string>

<string name="about_module_developer_title">Developers</string>
<!-- Strings below are intended for remove -->
<string name="hello_first_fragment">Hello first fragment</string>
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>

<string name="second_fragment_label">Second Fragment</string>
<string name="next">Next</string>
<string name="previous">Previous</string>
</resources>

0 comments on commit 16bf6ef

Please sign in to comment.