@@ -31,10 +31,12 @@ import com.google.android.gms.common.GooglePlayServicesNotAvailableException
|
|||||||
import com.google.android.gms.common.GooglePlayServicesRepairableException
|
import com.google.android.gms.common.GooglePlayServicesRepairableException
|
||||||
import com.google.android.gms.security.ProviderInstaller
|
import com.google.android.gms.security.ProviderInstaller
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import xyz.quaver.proxy
|
import xyz.quaver.proxy
|
||||||
import xyz.quaver.pupil.util.Histories
|
import xyz.quaver.pupil.util.Histories
|
||||||
import xyz.quaver.pupil.util.getProxy
|
import xyz.quaver.pupil.util.getProxy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class Pupil : MultiDexApplication() {
|
class Pupil : MultiDexApplication() {
|
||||||
|
|
||||||
@@ -48,6 +50,16 @@ class Pupil : MultiDexApplication() {
|
|||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
val preference = PreferenceManager.getDefaultSharedPreferences(this)
|
val preference = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
|
||||||
|
val userID =
|
||||||
|
if (preference.getString("user_id", "").isNullOrEmpty()) {
|
||||||
|
UUID.randomUUID().toString().also {
|
||||||
|
preference.edit().putString("user_id", it).apply()
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
preference.getString("user_id", "") ?: ""
|
||||||
|
|
||||||
|
FirebaseCrashlytics.getInstance().setUserId(userID)
|
||||||
|
|
||||||
proxy = getProxy(this)
|
proxy = getProxy(this)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
package xyz.quaver.pupil.ui.fragment
|
package xyz.quaver.pupil.ui.fragment
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Intent
|
import android.content.*
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
@@ -53,11 +53,7 @@ class SettingsFragment :
|
|||||||
Preference.OnPreferenceChangeListener,
|
Preference.OnPreferenceChangeListener,
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
lateinit var sharedPreference: SharedPreferences
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(requireContext()).registerOnSharedPreferenceChangeListener(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
@@ -202,6 +198,12 @@ class SettingsFragment :
|
|||||||
activity?.startActivityForResult(intent, REQUEST_IMPORT_OLD_GALLERIES_OLD)
|
activity?.startActivityForResult(intent, REQUEST_IMPORT_OLD_GALLERIES_OLD)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"user_id" -> {
|
||||||
|
(context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).setPrimaryClip(
|
||||||
|
ClipData.newPlainText("user_id", sharedPreference.getString("user_id", ""))
|
||||||
|
)
|
||||||
|
Toast.makeText(context, R.string.settings_user_id_toast, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,6 +249,9 @@ class SettingsFragment :
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
||||||
|
|
||||||
|
sharedPreference = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
sharedPreference.registerOnSharedPreferenceChangeListener(this)
|
||||||
|
|
||||||
initPreferences()
|
initPreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +298,7 @@ class SettingsFragment :
|
|||||||
onPreferenceClickListener = this@SettingsFragment
|
onPreferenceClickListener = this@SettingsFragment
|
||||||
}
|
}
|
||||||
"default_query" -> {
|
"default_query" -> {
|
||||||
summary = PreferenceManager.getDefaultSharedPreferences(requireContext()).getString("default_query", "") ?: ""
|
summary = sharedPreference.getString("default_query", "") ?: ""
|
||||||
|
|
||||||
onPreferenceClickListener = this@SettingsFragment
|
onPreferenceClickListener = this@SettingsFragment
|
||||||
}
|
}
|
||||||
@@ -337,6 +342,10 @@ class SettingsFragment :
|
|||||||
"old_import_galleries" -> {
|
"old_import_galleries" -> {
|
||||||
onPreferenceClickListener = this@SettingsFragment
|
onPreferenceClickListener = this@SettingsFragment
|
||||||
}
|
}
|
||||||
|
"user_id" -> {
|
||||||
|
summary = sharedPreference.getString("user_id", "")
|
||||||
|
onPreferenceClickListener = this@SettingsFragment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,8 +259,12 @@ class Cache(context: Context) : ContextWrapper(context) {
|
|||||||
it.createNewFile()
|
it.createNewFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOutputStream(cache).use {
|
try {
|
||||||
it.write(data)
|
FileOutputStream(cache).use {
|
||||||
|
it.write(data)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
cache.delete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,13 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
|||||||
|
|
||||||
val interceptor = Interceptor { chain ->
|
val interceptor = Interceptor { chain ->
|
||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
val response = chain.proceed(request)
|
var response = chain.proceed(request)
|
||||||
|
|
||||||
|
var retry = 5
|
||||||
|
while (!response.isSuccessful && retry > 0) {
|
||||||
|
response = chain.proceed(request)
|
||||||
|
retry--
|
||||||
|
}
|
||||||
|
|
||||||
response.newBuilder()
|
response.newBuilder()
|
||||||
.body(response.body()?.let {
|
.body(response.body()?.let {
|
||||||
@@ -296,7 +302,7 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
|||||||
val callback = object : Callback {
|
val callback = object : Callback {
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
Log.i("PUPILD", "FAIL ${call.request().tag()} (${e.message})")
|
Log.i("PUPILD", "FAIL ${call.request().tag()} (${e.message})")
|
||||||
if (e.message != "Canceled")
|
if (e.message?.contains("cancel", true) != true)
|
||||||
FirebaseCrashlytics.getInstance().recordException(e)
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
|
|
||||||
progress[galleryID]?.set(i, Float.NaN)
|
progress[galleryID]?.set(i, Float.NaN)
|
||||||
|
|||||||
@@ -148,4 +148,6 @@
|
|||||||
<string name="settings_download_when_cache_disable_warning">キャッシュを使用しないため、ダウンロードできません</string>
|
<string name="settings_download_when_cache_disable_warning">キャッシュを使用しないため、ダウンロードできません</string>
|
||||||
<string name="apcjsa_option_title">(Korean only)</string>
|
<string name="apcjsa_option_title">(Korean only)</string>
|
||||||
<string name="apcjsa_option_message">(Korean only)</string>
|
<string name="apcjsa_option_message">(Korean only)</string>
|
||||||
|
<string name="settings_user_id">ユーザーID</string>
|
||||||
|
<string name="settings_user_id_toast">ユーザーIDをクリップボードにコピーしました</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -148,4 +148,6 @@
|
|||||||
<string name="settings_download_when_cache_disable_warning">캐시를 활성화 해야 다운로드를 진행할 수 있습니다</string>
|
<string name="settings_download_when_cache_disable_warning">캐시를 활성화 해야 다운로드를 진행할 수 있습니다</string>
|
||||||
<string name="apcjsa_option_title">아청법 대응 옵션 추가</string>
|
<string name="apcjsa_option_title">아청법 대응 옵션 추가</string>
|
||||||
<string name="apcjsa_option_message">경찰서 정모 확률을 줄여보고자 캐시 비활성화/태그 필터를 추가하였습니다. 적용하시겠습니까?</string>
|
<string name="apcjsa_option_message">경찰서 정모 확률을 줄여보고자 캐시 비활성화/태그 필터를 추가하였습니다. 적용하시겠습니까?</string>
|
||||||
|
<string name="settings_user_id">유저 ID</string>
|
||||||
|
<string name="settings_user_id_toast">유저 ID를 클립보드에 복사했습니다</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -183,6 +183,8 @@
|
|||||||
<string name="settings_restore_failed">Restore failed</string>
|
<string name="settings_restore_failed">Restore failed</string>
|
||||||
<string name="settings_restore_successful">%1$d entries restored</string>
|
<string name="settings_restore_successful">%1$d entries restored</string>
|
||||||
<string name="settings_import_old_galleries">Import old galleries</string>
|
<string name="settings_import_old_galleries">Import old galleries</string>
|
||||||
|
<string name="settings_user_id">User ID</string>
|
||||||
|
<string name="settings_user_id_toast">User ID is copied to clipboard</string>
|
||||||
|
|
||||||
<!-- SETTINGS/APP LOCK ACTIVITY -->
|
<!-- SETTINGS/APP LOCK ACTIVITY -->
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,10 @@
|
|||||||
app:key="old_import_galleries"
|
app:key="old_import_galleries"
|
||||||
app:title="@string/settings_import_old_galleries"/>
|
app:title="@string/settings_import_old_galleries"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:key="user_id"
|
||||||
|
app:title="@string/settings_user_id"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
Reference in New Issue
Block a user