diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index c0f68ed..a10cf88 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,27 +5,41 @@ - + diff --git a/app/build.gradle b/app/build.gradle index b9e19f3..09b973b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,7 +98,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.core:core:1.1.0-rc02' implementation 'androidx.core:core-ktx:1.1.0-rc02' - implementation 'androidx.drawerlayout:drawerlayout:1.1.0-alpha02' + implementation 'androidx.drawerlayout:drawerlayout:1.1.0-alpha03' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.preference:preference:1.1.0-rc01' implementation 'androidx.preference:preference-ktx:1.1.0-rc01' @@ -111,14 +111,14 @@ dependencies { implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' // Firebase - implementation 'com.google.firebase:firebase-core:17.0.1' - implementation 'com.google.firebase:firebase-config:18.0.0' - implementation 'com.google.firebase:firebase-perf:18.0.1' + implementation 'com.google.firebase:firebase-core:17.1.0' + implementation 'com.google.firebase:firebase-config:19.0.0' + implementation 'com.google.firebase:firebase-perf:19.0.0' implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' // ViewModel + LiveData + Room + Paging implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' - kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0' + implementation "androidx.lifecycle:lifecycle-common-java8:2.0.0" implementation 'androidx.room:room-runtime:2.1.0' kapt 'androidx.room:room-compiler:2.1.0' implementation 'androidx.paging:paging-runtime:2.1.0' @@ -146,8 +146,8 @@ dependencies { //implementation 'com.squareup.okhttp3:okhttp:3.12.1' // Location Picker - //implementation ('com.schibstedspain.android:leku:6.2.1') { - implementation ('com.github.huikaihoo:leku:6.2.1-lite') { + //implementation('com.schibstedspain.android:leku:6.2.1') { + implementation('com.github.huikaihoo:leku:6.2.1-lite') { exclude group: 'com.google.android.gms' exclude group: 'androidx.appcompat' } @@ -156,12 +156,12 @@ dependencies { implementation 'com.facebook.stetho:stetho:1.5.1' implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1' debugImplementation 'com.facebook.flipper:flipper:0.23.4' - debugImplementation 'com.facebook.soloader:soloader:0.6.1' + debugImplementation 'com.facebook.soloader:soloader:0.7.0' //releaseImplementation 'com.facebook.flipper:flipper-noop:0.23.4' - releaseImplementation ('com.github.huikaihoo:flipper-android-no-op:0.1.1') { + releaseImplementation('com.github.theGlenn:flipper-android-no-op:0.2.0') { exclude group: 'com.squareup.okhttp3' } - //debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' + //debugImplementation 'com.amitshekhar.android:debug-db:1.0.6' // Unit Test testImplementation 'androidx.arch.core:core-testing:2.1.0-rc01' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f45b7c..348301b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,8 +12,12 @@ - - + + - preference?.setSummary(newValue) - true - } - } - fun findPreference(@StringRes resId: Int): Preference { return super.findPreference(getString(resId))!! } - - fun bindPreferenceSummary(@StringRes resId: Int, onPreferenceChangeListener: Preference.OnPreferenceChangeListener = bindSummaryOnPreferenceChangeListener) { - val preference = findPreference(resId) - preference.onPreferenceChangeListener = onPreferenceChangeListener - - // Trigger the listener immediately with the preference's - // current value. - if ( preference is SwitchPreference || preference is CheckBoxPreference ) { - preference.setSummary(SharedPrefsHelper.get(resId)) - } else { - preference.setSummary(SharedPrefsHelper.get(resId) as Any?) - } - } } \ No newline at end of file diff --git a/app/src/main/java/hoo/etahk/view/settings/ParametersPrefFragment.kt b/app/src/main/java/hoo/etahk/view/settings/ParametersPrefFragment.kt index 51b202d..2bbbce8 100644 --- a/app/src/main/java/hoo/etahk/view/settings/ParametersPrefFragment.kt +++ b/app/src/main/java/hoo/etahk/view/settings/ParametersPrefFragment.kt @@ -19,31 +19,6 @@ class ParametersPrefFragment : BasePrefFragment() { */ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.pref_parameters) - setHasOptionsMenu(true) - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. - - // Firebase - bindPreferenceSummary(R.string.param_user_uuid) - bindPreferenceSummary(R.string.param_enable_remote_config) - // App - bindPreferenceSummary(R.string.param_app_mode) - bindPreferenceSummary(R.string.param_accepted_terms) - bindPreferenceSummary(R.string.param_paged_list_page_size) - // Feature - bindPreferenceSummary(R.string.param_enable_bus_list) - bindPreferenceSummary(R.string.param_enable_gmb_list) - bindPreferenceSummary(R.string.param_enable_tram_list) - bindPreferenceSummary(R.string.param_enable_mtr_list) - // Gist - bindPreferenceSummary(R.string.param_gist_id_kmb) - bindPreferenceSummary(R.string.param_gist_id_nwfb) - bindPreferenceSummary(R.string.param_gist_id_mtrb) - // OkHttp - bindPreferenceSummary(R.string.param_user_agent) } override fun onResume() { diff --git a/app/src/main/java/hoo/etahk/view/settings/GeneralPrefFragment.kt b/app/src/main/java/hoo/etahk/view/settings/RootPrefFragment.kt similarity index 78% rename from app/src/main/java/hoo/etahk/view/settings/GeneralPrefFragment.kt rename to app/src/main/java/hoo/etahk/view/settings/RootPrefFragment.kt index f4d13c3..77f3dbd 100644 --- a/app/src/main/java/hoo/etahk/view/settings/GeneralPrefFragment.kt +++ b/app/src/main/java/hoo/etahk/view/settings/RootPrefFragment.kt @@ -8,7 +8,6 @@ import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.core.net.toUri import androidx.lifecycle.ViewModelProviders -import androidx.preference.Preference import com.google.android.gms.oss.licenses.OssLicensesMenuActivity import com.mcxiaoke.koi.ext.newIntent import com.mcxiaoke.koi.ext.restart @@ -27,9 +26,8 @@ import hoo.etahk.view.follow.FollowActivity import hoo.etahk.view.service.UpdateRoutesService import org.jetbrains.anko.startActivity -class GeneralPrefFragment : BasePrefFragment() { +class RootPrefFragment : BasePrefFragment() { - private lateinit var testing: Preference private lateinit var viewModel: SettingsViewModel /** @@ -45,35 +43,25 @@ class GeneralPrefFragment : BasePrefFragment() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { viewModel = ViewModelProviders.of(this).get(SettingsViewModel::class.java) - addPreferencesFromResource(R.xml.pref_general) - setHasOptionsMenu(true) - - // Bind the summaries of EditText/List/Dialog/Ringtone preferences - // to their values. When their values change, their summaries are - // updated to reflect the new value, per the Android Design - // guidelines. + setPreferencesFromResource(R.xml.pref_root, rootKey) // General - bindPreferenceSummary(R.string.pref_language, Preference.OnPreferenceChangeListener { preference, newValue -> + val language = findPreference(R.string.pref_language) + language.setOnPreferenceChangeListener { _, newValue -> AppHelper.applyAppLocale(newValue.toString()) activity?.restart() true - }) + } val updateRoutes = findPreference(R.string.pref_update_routes) - - updateRoutes.onPreferenceClickListener = Preference.OnPreferenceClickListener { + updateRoutes.setOnPreferenceClickListener { App.instance.startServiceCompat(activity!!.newIntent()) true } - // Bus - bindPreferenceSummary(R.string.pref_bus_jointly) - // Backup and Restore val backup = findPreference(R.string.pref_backup) - - backup.onPreferenceClickListener = Preference.OnPreferenceClickListener { + backup.setOnPreferenceClickListener { val exporter = Exporter() AlertDialogBuilder(context!!) .setTitle(R.string.title_backup_save_success_to) @@ -84,8 +72,7 @@ class GeneralPrefFragment : BasePrefFragment() { } val restore = findPreference(R.string.pref_restore) - - restore.onPreferenceClickListener = Preference.OnPreferenceClickListener { + restore.setOnPreferenceClickListener { val importer = Importer() val displayList = importer.getBackupList() var selectedIndex = -1 @@ -123,7 +110,7 @@ class GeneralPrefFragment : BasePrefFragment() { // About val appName = findPreference(R.string.pref_app_name) - appName.onPreferenceClickListener = Preference.OnPreferenceClickListener { + appName.setOnPreferenceClickListener { startActivity(Intent(Intent.ACTION_VIEW, getString(R.string.play_store_developer_url).toUri())) true } @@ -132,20 +119,19 @@ class GeneralPrefFragment : BasePrefFragment() { appVersion.summary = App.instance.getVersionName() val privacyPolicy = findPreference(R.string.pref_privacy_policy) - privacyPolicy.onPreferenceClickListener = Preference.OnPreferenceClickListener { + privacyPolicy.setOnPreferenceClickListener { (activity as AppCompatActivity).startCustomTabs(getString(R.string.privacy_policy_url)) true } val disclaimer = findPreference(R.string.pref_disclaimer) - disclaimer.onPreferenceClickListener = Preference.OnPreferenceClickListener { + disclaimer.setOnPreferenceClickListener { (activity as AppCompatActivity).startCustomTabs(getString(R.string.disclaimer_url)) true } val licenses= findPreference(R.string.pref_licenses) - - licenses.onPreferenceClickListener = Preference.OnPreferenceClickListener { + licenses.setOnPreferenceClickListener { activity?.startActivity( Argument.ARG_TITLE to getString(R.string.pref_title_licenses) ) @@ -155,14 +141,8 @@ class GeneralPrefFragment : BasePrefFragment() { // Testing val parameters = findPreference(R.string.pref_parameters) - parameters.onPreferenceClickListener = Preference.OnPreferenceClickListener { - activity!!.supportFragmentManager.beginTransaction().replace(R.id.container, ParametersPrefFragment()).addToBackStack(null).commit() - true - } - - testing = findPreference(R.string.pref_testing) if (!viewModel.showTesting) { - preferenceScreen.removePreference(testing) + preferenceScreen.removePreference(findPreference(R.string.pref_testing)) } // Disable preference if permission is not granted diff --git a/app/src/main/java/hoo/etahk/view/settings/SettingsActivity.kt b/app/src/main/java/hoo/etahk/view/settings/SettingsActivity.kt index e923980..cd88c53 100644 --- a/app/src/main/java/hoo/etahk/view/settings/SettingsActivity.kt +++ b/app/src/main/java/hoo/etahk/view/settings/SettingsActivity.kt @@ -3,7 +3,6 @@ package hoo.etahk.view.settings import android.Manifest import android.content.Intent import android.os.Bundle -import android.preference.PreferenceActivity import android.view.Menu import android.view.MenuItem import androidx.core.net.toUri @@ -12,19 +11,8 @@ import hoo.etahk.BuildConfig import hoo.etahk.R import hoo.etahk.common.extensions.startCustomTabs import hoo.etahk.view.base.BaseActivity -import kotlinx.android.synthetic.main.activity_follow.* +import kotlinx.android.synthetic.main.activity_follow.toolbar - -/** - * A [PreferenceActivity] that presents a set of application settings. On - * handset devices, settings are presented as a single list. On tablets, - * settings are split by category, with category headers shown to the left of - * the list of settings. - * - * See [Android Design: Settings](http://developer.android.com/design/patterns/settings.html) - * for design guidelines and the [Settings API Guide](http://developer.android.com/guide/topics/ui/settings.html) - * for more information on developing a Settings UI. - */ class SettingsActivity : BaseActivity() { private lateinit var viewModel: SettingsViewModel @@ -52,7 +40,7 @@ class SettingsActivity : BaseActivity() { viewModel.isInit = true // load General Preference fragment - supportFragmentManager.beginTransaction().replace(R.id.container, GeneralPrefFragment()).commitAllowingStateLoss() + supportFragmentManager.beginTransaction().replace(R.id.container, RootPrefFragment()).commitAllowingStateLoss() } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -77,4 +65,4 @@ class SettingsActivity : BaseActivity() { else -> super.onOptionsItemSelected(item) } } -} +} \ No newline at end of file diff --git a/app/src/main/res/menu/nav_drawer.xml b/app/src/main/res/menu/nav_drawer.xml index a81f508..e776bf8 100644 --- a/app/src/main/res/menu/nav_drawer.xml +++ b/app/src/main/res/menu/nav_drawer.xml @@ -47,6 +47,7 @@ 已從最愛路線中移除 已從路線歷史中移除 - + 一般 語言 (Language) 自動更新路線資料頻率 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 788491c..2a7cd56 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -215,7 +215,7 @@ https://github.com/huikaihoo/EtaAtHK/blob/master/app/src/main/res/raw/privacy_policy.md https://github.com/huikaihoo/EtaAtHK/blob/master/app/src/main/res/raw/disclaimer.md - + General Language (語言) Automatic updates routes data frequency @@ -243,7 +243,7 @@ Parameters View and edit parameters - + @string/system_default @string/tc diff --git a/app/src/main/res/xml/pref_parameters.xml b/app/src/main/res/xml/pref_parameters.xml index d474c4b..83f2ca3 100644 --- a/app/src/main/res/xml/pref_parameters.xml +++ b/app/src/main/res/xml/pref_parameters.xml @@ -1,40 +1,38 @@ - + + android:title="@string/param_category_firebase"> + app:useSimpleSummaryProvider="true" /> + android:defaultValue="true" /> + android:title="@string/param_category_app"> + app:useSimpleSummaryProvider="true" /> + android:defaultValue="false" /> + app:useSimpleSummaryProvider="true" /> + android:title="@string/param_category_feature"> + app:defaultValue="true" /> + app:key="@string/param_enable_gmb_list" + app:title="@string/param_enable_gmb_list" + app:defaultValue="false" /> + android:defaultValue="false" /> + android:defaultValue="false" /> + android:title="@string/param_category_gist"> + app:useSimpleSummaryProvider="true" /> + app:useSimpleSummaryProvider="true" /> + app:useSimpleSummaryProvider="true" /> + android:title="@string/param_category_ok_http"> + app:useSimpleSummaryProvider="true" /> diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_root.xml similarity index 59% rename from app/src/main/res/xml/pref_general.xml rename to app/src/main/res/xml/pref_root.xml index b9d789c..75ded4f 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_root.xml @@ -1,30 +1,29 @@ - - + android:title="@string/pref_category_title_general"> - + android:defaultValue="" + app:useSimpleSummaryProvider="true" /> + app:updatesContinuously="true" + app:useSimpleSummaryProvider="true" /> + android:title="@string/pref_category_title_bus"> + android:defaultValue="2" + app:useSimpleSummaryProvider="true" /> + android:title="@string/pref_category_title_backup_restore"> + android:title="@string/pref_category_title_about"> - - - - - - - - - - + + + + + + + + + + @@ -119,15 +116,46 @@ + android:title="@string/pref_category_title_testing"> + app:fragment="hoo.etahk.view.settings.ParametersSettingsFragment" /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.gradle b/build.gradle index d72ea08..d838df5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.41' + ext.kotlin_version = '1.3.50' ext.kotlin_coroutines_version = '1.1.1' ext.anko_version = '0.10.8' ext.markwon_version = '2.0.2' @@ -13,7 +13,7 @@ buildscript { dependencies { // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5' classpath 'com.google.firebase:perf-plugin:1.3.1' classpath 'com.google.gms:google-services:4.3.0' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b2e0d72..82cbbe7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Apr 24 01:01:16 HKT 2019 +#Thu Aug 22 22:44:08 HKT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip