add feedback id (use Build.ID & PackageArchive.lastUpdateTime)
This commit is contained in:
5 files changed
+61
-2
No files matched your search
@@ -1,15 +1,37 @@
|
||||
package com.github.kr328.clash
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.Keep
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import kotlinx.android.synthetic.main.activity_feedback.*
|
||||
|
||||
class FeedbackActivity : BaseActivity() {
|
||||
companion object {
|
||||
const val KEY_FEEDBACK_ID = "feedback_id"
|
||||
}
|
||||
|
||||
@Keep
|
||||
class Fragment : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.feedback, rootKey)
|
||||
|
||||
findPreference<Preference>(KEY_FEEDBACK_ID)?.apply {
|
||||
summary = MainApplication.userIdentifier
|
||||
|
||||
onPreferenceClickListener = Preference.OnPreferenceClickListener { p ->
|
||||
val data = ClipData.newPlainText("userIdentifier", summary)
|
||||
|
||||
requireContext().getSystemService(ClipboardManager::class.java)?.setPrimaryClip(data)
|
||||
|
||||
Toast.makeText(requireContext(), R.string.feedback_feedback_id_copied, Toast.LENGTH_LONG).show()
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.github.kr328.clash
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import com.github.kr328.clash.core.Constants
|
||||
import com.github.kr328.clash.core.utils.Log
|
||||
import com.google.firebase.FirebaseApp
|
||||
import io.fabric.sdk.android.Fabric
|
||||
import java.security.MessageDigest
|
||||
import kotlin.experimental.and
|
||||
|
||||
|
||||
class MainApplication : Application() {
|
||||
@@ -16,10 +19,28 @@ class MainApplication : Application() {
|
||||
const val PROXY_MODE_PROXY_ONLY = "proxy_only"
|
||||
|
||||
val GOOGLE_PLAY_INSTALLER = listOf("com.android.vending", "com.google.android.feedback")
|
||||
const val CRASHLYTICS_GOOGLE_PLAY_KEY = "install_from_google"
|
||||
const val CRASHLYTICS_FROM_PLAY_KEY = "install_from_google"
|
||||
const val CRASHLYTICS_SPLIT_APK_KEY = "split_apk"
|
||||
|
||||
val userIdentifier: String by lazy {
|
||||
val archive = instance.packageManager.getPackageInfo(instance.packageName, 0)
|
||||
val encoder = MessageDigest.getInstance("md5")
|
||||
|
||||
encoder.digest((Build.ID + archive.lastUpdateTime).toByteArray()).toHexString()
|
||||
}
|
||||
|
||||
lateinit var instance: MainApplication
|
||||
|
||||
private fun ByteArray.toHexString(): String {
|
||||
return this.map {
|
||||
Integer.toHexString(it.toInt() and 0xff)
|
||||
}.map {
|
||||
if ( it.length < 2 )
|
||||
"0$it"
|
||||
else
|
||||
it
|
||||
}.joinToString(separator = "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun attachBaseContext(base: Context?) {
|
||||
@@ -38,8 +59,9 @@ class MainApplication : Application() {
|
||||
Fabric.with(this, Crashlytics())
|
||||
}
|
||||
|
||||
Crashlytics.setBool(CRASHLYTICS_GOOGLE_PLAY_KEY, detectFromPlay())
|
||||
Crashlytics.setBool(CRASHLYTICS_FROM_PLAY_KEY, detectFromPlay())
|
||||
Crashlytics.setBool(CRASHLYTICS_SPLIT_APK_KEY, detectSplitArchive())
|
||||
Crashlytics.setUserIdentifier(userIdentifier)
|
||||
|
||||
Log.handler = object: Log.LogHandler {
|
||||
override fun info(message: String, throwable: Throwable?) {
|
||||
|
||||
@@ -94,6 +94,11 @@
|
||||
|
||||
<string name="not_implemented">Not Implemented</string>
|
||||
|
||||
<string name="feedback_id">ID</string>
|
||||
<string name="feedback_feedback_id">Feedback ID</string>
|
||||
<string name="feedback_feedback_id_summary">Unknown</string>
|
||||
<string name="feedback_feedback_id_copied">Copied</string>
|
||||
|
||||
<string name="feedback_source">Source & Issues</string>
|
||||
<string name="feedback_upstream">Upstream</string>
|
||||
<string name="feedback_github_repo">Github</string>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/feedback_id">
|
||||
<Preference android:title="@string/feedback_feedback_id"
|
||||
android:key="feedback_id"
|
||||
android:summary="@string/feedback_feedback_id_summary" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/feedback_source">
|
||||
<Preference android:title="@string/feedback_upstream"
|
||||
android:summary="@string/feedback_upstream_url">
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory android:title="@string/feedback_id">
|
||||
<Preference android:title="@string/feedback_feedback_id"
|
||||
android:key="feedback_id"
|
||||
android:summary="@string/feedback_feedback_id_summary" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/feedback_source">
|
||||
<Preference android:title="@string/feedback_upstream"
|
||||
android:summary="@string/feedback_upstream_url">
|
||||
|
||||
Reference in new issue
Block a user