diff options
Diffstat (limited to 'app/src/main/java/moe/yuuta/workmode/suspend/data')
-rw-r--r-- | app/src/main/java/moe/yuuta/workmode/suspend/data/SuspendedStorage.kt | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/src/main/java/moe/yuuta/workmode/suspend/data/SuspendedStorage.kt b/app/src/main/java/moe/yuuta/workmode/suspend/data/SuspendedStorage.kt index a6c6cdd..d8cfee7 100644 --- a/app/src/main/java/moe/yuuta/workmode/suspend/data/SuspendedStorage.kt +++ b/app/src/main/java/moe/yuuta/workmode/suspend/data/SuspendedStorage.kt @@ -2,7 +2,11 @@ package moe.yuuta.workmode.suspend.data import android.content.Context import android.content.SharedPreferences +import com.crashlytics.android.Crashlytics +import com.crashlytics.android.answers.Answers +import com.crashlytics.android.answers.CustomEvent import com.elvishew.xlog.XLog +import moe.yuuta.workmode.Setup import moe.yuuta.workmode.utils.Utils import java.util.stream.Collectors @@ -65,4 +69,38 @@ class SuspendedStorage(private val mContext: Context) { } .collect(Collectors.toSet())) } + + // #Anti-Crack + fun reportCrack(id: String, reason: String) { + val reportTimes = getStorage().getInt("c_$id", 0) + getStorage().edit() + .putInt("c_$id", reportTimes + 1) + .apply() + if (reportTimes <= 0) { + Runnable { + Runnable { + if (Setup.FABRIC_ENABLE) + Runnable { + Answers.getInstance().logCustom(CustomEvent("St.rf.pa.") + .putCustomAttribute("rn", reason) + .putCustomAttribute("ic", id)) + Crashlytics.log("Sf. $reason $id") + }.run() + }.run() + }.run() + } + } + + // #Anti-Crack + fun removeCrack(id: String) { + getStorage().edit() + .remove("c_$id") + .apply() + if (Setup.FABRIC_ENABLE) + Runnable { + Answers.getInstance().logCustom(CustomEvent("St.rf.rm.") + .putCustomAttribute("ic", id)) + Crashlytics.log("Sf.rm. $id") + }.run() + } }
\ No newline at end of file |