diff --git a/app/build.gradle b/app/build.gradle index 005c3d34..ccd79c6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "com.tsng.hidemyapplist" minSdkVersion 24 targetSdkVersion 30 - versionCode 44 - versionName "1.7.-0.8 Prebuild" + versionCode 45 + versionName "1.7 Beta" buildConfigField "int", "SERVICE_VERSION", "43" buildConfigField "int", "MIN_RIRU_VERSION", "15" } diff --git a/app/src/main/java/com/tsng/hidemyapplist/MainActivity.kt b/app/src/main/java/com/tsng/hidemyapplist/MainActivity.kt index 31664a04..bc1efa9c 100644 --- a/app/src/main/java/com/tsng/hidemyapplist/MainActivity.kt +++ b/app/src/main/java/com/tsng/hidemyapplist/MainActivity.kt @@ -111,16 +111,16 @@ class MainActivity : AppCompatActivity(), View.OnClickListener { try { val client = OkHttpClient() val responseData = client.newCall(Request.Builder() - .url("https://cdn.jsdelivr.net/gh/Dr-TSNG/Hide-My-Applist@master/updates/latest_version.json") + .url("https://cdn.jsdelivr.net/gh/Dr-TSNG/Hide-My-Applist@updates/updates/latest_version.json") .build()).execute().body?.string() if (responseData != null) { val json = JSONObject(responseData) var data = json["Stable"] as JSONObject - var updateLogURL = "https://cdn.jsdelivr.net/gh/Dr-TSNG/Hide-My-Applist@master/updates/stable-" + var updateLogURL = "https://cdn.jsdelivr.net/gh/Dr-TSNG/Hide-My-Applist@updates/updates/stable-" if (getSharedPreferences("Settings", MODE_PRIVATE).getBoolean("ReceiveBetaUpdate", false)) if (json["Beta"] != false) { data = json["Beta"] as JSONObject - updateLogURL = "https://cdn.jsdelivr.net/gh/Dr-TSNG/Hide-My-Applist@master/updates/beta-" + updateLogURL = "https://cdn.jsdelivr.net/gh/Dr-TSNG/Hide-My-Applist@updates/updates/beta-" } updateLogURL += if (Locale.getDefault().language.contains("zh")) "zh" else "en" updateLogURL += ".html" diff --git a/app/src/main/java/com/tsng/hidemyapplist/ui/TemplateSettingsActivity.kt b/app/src/main/java/com/tsng/hidemyapplist/ui/TemplateSettingsActivity.kt index 600b9796..557c0596 100644 --- a/app/src/main/java/com/tsng/hidemyapplist/ui/TemplateSettingsActivity.kt +++ b/app/src/main/java/com/tsng/hidemyapplist/ui/TemplateSettingsActivity.kt @@ -6,12 +6,15 @@ import android.os.Bundle import android.view.Menu import android.view.MenuInflater import android.view.MenuItem +import android.view.View +import android.widget.* import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SearchView import androidx.preference.CheckBoxPreference import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.preference.iterator +import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.tsng.hidemyapplist.R import kotlinx.android.synthetic.main.appselect.* import kotlinx.android.synthetic.main.toolbar.* @@ -59,6 +62,39 @@ class TemplateSettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.O override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { preferenceManager.sharedPreferencesName = "tpl_" + arguments?.getString("template") setPreferencesFromResource(R.xml.template_preferences, rootKey) + preferenceScreen.findPreference("MapsRules")?.setOnPreferenceClickListener { + val rules = preferenceManager.sharedPreferences.getStringSet("MapsRules", setOf()).toMutableList() + val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_list_item_1, rules) + MaterialAlertDialogBuilder(requireContext()) + .setTitle(R.string.template_add_maps_rules) + .setView(View.inflate(requireContext(), R.layout.alert_customize_maps_rules, null).apply { + findViewById(R.id.template_lv_maps_rules).apply { + this.adapter = adapter + setOnItemLongClickListener { _, _, position, _ -> + MaterialAlertDialogBuilder(requireContext()) + .setTitle(R.string.template_delete_maps_rule) + .setMessage(rules[position]) + .setNegativeButton(android.R.string.cancel, null) + .setPositiveButton(android.R.string.ok) { _, _ -> + activity?.runOnUiThread { adapter.remove(rules[position]) } + preferenceManager.sharedPreferences.edit().putStringSet("MapsRules", rules.toSet()).apply() + }.show() + true + } + } + findViewById