Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
内置curl&增加AppCenter开关
Browse files Browse the repository at this point in the history
  • Loading branch information
liuran001 committed Jun 8, 2022
1 parent 66e6a00 commit 42f401a
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 106 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 28
versionCode(Common.getversionCode())
versionName "4.7" + (Common.getGitHeadRefsSuffix(rootProject))
versionName "4.9" + (Common.getGitHeadRefsSuffix(rootProject))
}
buildTypes {
release {
Expand Down
41 changes: 0 additions & 41 deletions app/src/main/assets/kr-script/Install_Command.sh

This file was deleted.

16 changes: 0 additions & 16 deletions app/src/main/assets/kr-script/Start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,9 @@ abort() {
}

Inject() {
[[ ! -x "`curl -where`" ]] && Install_Curl
curl -L -s -o "$2" "$CODING/$1"
}

Install_Curl() {
echo "- $curl_not_found"
Curl_URL='http://159.27.81.21/curl'
wget -O $ELF1_Path/curl3 "$Curl_URL/`getprop ro.product.cpu.abi`"
wget -O $ELF1_Path/curl3 "$Curl_URL/armeabi-v7a"
wget -O ~/cacert.pem "$Curl_URL/cacert.pem"
if $Have_ROOT; then
. $Core
[[ ! -f "$ELF1_Path/curl3" ]] && downloader "$ELF1_Path/curl3" "$Curl_URL/`getprop ro.product.cpu.abi`"
[[ ! -f "$ELF1_Path/curl3" ]] && downloader "$ELF1_Path/curl3" "$Curl_URL/armeabi-v7a"
[[ ! -f ~/cacert.pem ]] && downloader ~/cacert.pem "$Curl_URL/cacert.pem"
fi
chmod +x $ELF1_Path/curl3
}

SCRIPT() {
if [[ ! -f $2 ]]; then
Inject $1 $2
Expand Down
Binary file added app/src/main/assets/usr/xbin/arm64-v8a/curl
Binary file not shown.
Binary file added app/src/main/assets/usr/xbin/armeabi-v7a/curl
Binary file not shown.
29 changes: 2 additions & 27 deletions app/src/main/assets/usr/xbin/curl
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,8 @@ CURL() {
fi
}

CURL2() {
if [[ "$1" = -where ]]; then
exec echo "$C"
elif [[ "$1" = -V ]]; then
exec "$C" "$@"
elif [[ "$1" = --version ]]; then
exec "$C" "$@"
elif [[ "$1" = --help ]]; then
exec "$C" "$@"
elif [[ "$1" = -h ]]; then
exec "$C" "$@"
else
ping -w 1 223.5.5.5 > /dev/null && DoH_Ser='223.5.5.5'
[[ ! -n $DoH_Ser ]] && ping -w 1 223.6.6.6 > /dev/null && DoH_Ser='223.6.6.6'
[[ ! -n $DoH_Ser ]] && ping -w 1 120.53.80.136 > /dev/null && DoH_Ser='120.53.80.136'
[[ ! -n $DoH_Ser ]] && ping -w 1 175.24.219.66 > /dev/null && DoH_Ser='175.24.219.66'
[[ ! -n $DoH_Ser ]] && ping -w 1 8.8.8.8 > /dev/null && DoH_Ser='8.8.8.8'
[[ ! -n $DoH_Ser ]] && ping -w 1 9.9.9.9 > /dev/null && DoH_Ser='9.9.9.9'
[[ ! -n $DoH_Ser ]] && DoH_Ser='223.5.5.5'
"$C" --doh-url "https://$DoH_Ser/dns-query" --doh-insecure --cacert ~/cacert.pem "$@"
fi
}

C="$ELF1_Path/curl3"
[[ -x "$C" ]] && CURL2 "$@"

C="$ELF1_Path/curl2"
Arch=$(getprop ro.product.cpu.abi)
C="$ELF3_Path/$Arch/curl"
[[ -x "$C" ]] && CURL "$@"

C="$DATA_DIR/com.termux/files/usr/bin/curl"
Expand Down
Binary file added app/src/main/assets/usr/xbin/x86/curl
Binary file not shown.
Binary file added app/src/main/assets/usr/xbin/x86_64/curl
Binary file not shown.
57 changes: 39 additions & 18 deletions app/src/main/java/gjzs/online/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,57 @@ class AboutActivity : AbsAboutActivity() {
items.add(License("appcenter-sdk-android", "microsoft", License.MIT, "https://github.com/microsoft/appcenter-sdk-android"))
items.add(License("AndroidHiddenApiBypass", "LSPosed", License.APACHE_2, "https://github.com/LSPosed/AndroidHiddenApiBypass"))
items.add(License("StringFog", "MegatronKing", License.APACHE_2, "https://github.com/MegatronKing/StringFog"))
items.add(License("curl-android", "vvb2060", "No License", "https://github.com/vvb2060/curl-android"))
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_about, menu)
// TransparentUI
val transparent = menu.findItem(R.id.transparent_ui)
val themeConfig = ThemeConfig(this)
transparent.isChecked = themeConfig.getAllowTransparentUI()
// App Center Status
val appcenter = menu.findItem(R.id.appcenter_switch)
val appcenterStatus = AppCenterStatus(this)
appcenter.isChecked = appcenterStatus.getAppCenterStatus()
return super.onCreateOptionsMenu(menu)
}

override fun onOptionsItemSelected(menuItem: MenuItem): Boolean {
val themeConfig = ThemeConfig(this)
if (menuItem.isChecked) {
themeConfig.setAllowTransparentUI(false)
val intent = Intent()
intent.setClass(this,MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
} else {
fun checkPermission(permission: String): Boolean = PermissionChecker.checkSelfPermission(this, permission) == PermissionChecker.PERMISSION_GRANTED
if (menuItem.isChecked && !checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
themeConfig.setAllowTransparentUI(false)
Toast.makeText(this@AboutActivity, R.string.kr_write_external_storage, Toast.LENGTH_SHORT).show()
} else {
themeConfig.setAllowTransparentUI(true)
val intent = Intent()
intent.setClass(this,MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
return when (menuItem.itemId) {
R.id.transparent_ui -> {
val themeConfig = ThemeConfig(this)
if (menuItem.isChecked) {
themeConfig.setAllowTransparentUI(false)
val intent = Intent()
intent.setClass(this, MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
} else {
fun checkPermission(permission: String): Boolean = PermissionChecker.checkSelfPermission(this, permission) == PermissionChecker.PERMISSION_GRANTED
if (menuItem.isChecked && !checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) {
themeConfig.setAllowTransparentUI(false)
Toast.makeText(this@AboutActivity, R.string.kr_write_external_storage, Toast.LENGTH_SHORT).show()
} else {
themeConfig.setAllowTransparentUI(true)
val intent = Intent()
intent.setClass(this, MainActivity::class.java).flags = Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(intent)
}
}
return true
}
R.id.appcenter_switch -> {
val appcenterStatus = AppCenterStatus(this)
if (menuItem.isChecked) {
appcenterStatus.setAppCenterStatus(false)
invalidateOptionsMenu()
} else {
appcenterStatus.setAppCenterStatus(true)
invalidateOptionsMenu()
}
return true
}
else -> super.onOptionsItemSelected(menuItem)
}
return true
}

}
16 changes: 16 additions & 0 deletions app/src/main/java/gjzs/online/AppCenterStatus.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gjzs.online

import android.app.Activity
import android.content.Context

class AppCenterStatus (private val activity: Activity) {
private val config = activity.getSharedPreferences("AppCenter_status", Context.MODE_PRIVATE)

fun getAppCenterStatus(): Boolean {
return config.getBoolean("Status", true)
}

fun setAppCenterStatus(allow: Boolean) {
config.edit().putBoolean("Status", allow).apply()
}
}
13 changes: 10 additions & 3 deletions app/src/main/java/gjzs/online/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.util.Base64
import android.util.DisplayMetrics
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.view.View
Expand Down Expand Up @@ -40,9 +42,14 @@ class MainActivity : AppCompatActivity() {
private fun checkPermission(permission: String): Boolean = PermissionChecker.checkSelfPermission(this, permission) == PermissionChecker.PERMISSION_GRANTED

override fun onCreate(savedInstanceState: Bundle?) {
//二改的麻烦把AppCenter密钥改了
AppCenter.start(application, "16d4ef12-f4e7-4955-964c-42c0e84e8446", Analytics::class.java, Crashes::class.java)

val appcenterStatus = AppCenterStatus(this)
val signCode = String(Base64.decode("RUQ6RjE6REE6QkU6Mzc6OTA6RDM6MTY6RTg6Qzc6NTI6Qzg6OUQ6QUQ6M0U6MTM6MEE6RkM6NjE6Mzk=", Base64.DEFAULT))
val signCheck = SignCheck(this, signCode)
if (appcenterStatus.getAppCenterStatus() && signCheck.check()) {
AppCenter.start(application, "16d4ef12-f4e7-4955-964c-42c0e84e8446", Analytics::class.java, Crashes::class.java)
} else {
Log.d("AppCenter", "AppCenter is disabled")
}
super.onCreate(savedInstanceState)
ThemeModeState.switchTheme(this)
setContentView(R.layout.activity_main)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/gjzs/online/SplashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Base64
import android.util.Log
import android.util.TypedValue
import android.view.View
import android.widget.TextView
Expand All @@ -34,6 +35,7 @@ class SplashActivity : Activity() {
val signCheck = SignCheck(this, signCode)
val webCode = String(Base64.decode("aHR0cHM6Ly9nanpzci5jb20vU2lnbkNoZWNrRmFpbGVkLmh0bWw=", Base64.DEFAULT))
if (!signCheck.check()) {
Log.e("SplashActivity", "SignCheck failed")
Toast.makeText(this, "警告:您安装的是非官方应用,请立即卸载,并前往 gjzsr.com 下载官方正版!", Toast.LENGTH_LONG).show()
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(webCode))
startActivity(intent)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/menu_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
android:title="@string/transparent_ui"
app:showAsAction="never"
tools:ignore="HardcodedText"/>
<item
android:id="@+id/appcenter_switch"
android:checkable="true"
android:title="@string/appcenter_switch"
app:showAsAction="never"
tools:ignore="HardcodedText"/>

</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
<string name="title_activity_folder_selector">请长按选择目录</string>
<string name="card_content">搞机助手·R 是一款提供给Android玩机爱好者的实用工具应用。\n\n此APP最早由 情非得已c 开发,后由 笨蛋ovo 继续维护,并更名为 搞机助手·R。\n\n搞机千万条,安全第一条。\n搞机不规范,亲人两行泪。</string>
<string name="title_activity_about_page">关于</string>
<string name="appcenter_switch">App Center 统计开关</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
<string name="title_activity_folder_selector">Please select a folder by long press...</string>
<string name="card_content">"GJZS·R" is a utility application for Android enthusiasts. \n\nThis app was first developed by 情非得已c, and later maintained by BDovo (@liuran001), and renamed as GJZS·R.</string>
<string name="title_activity_about_page">About</string>
<string name="appcenter_switch">App Center Analytics Switch</string>
</resources>

0 comments on commit 42f401a

Please sign in to comment.