diff --git a/README.md b/README.md
index d021375..5cd9ced 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ https://play.google.com/store/apps/details?id=com.daigorian.epcltvapp
## 今後やりたいこと
- ~~動画リストの一番右に「さらに読み込む」ボタンの追加~~ DONE!
- ~~検索履歴を残して再検索を楽にする~~ DONE !
- - 設定画面をLeanbackSettingsFragmentに変えてかっこよくする
+ - ~~設定画面をLeanbackSettingsFragmentに変えてかっこよくする~~ DONE !
- 検索画面をメイン画面とシームレスに接続する
- 割と入手性の良い端末であるAmazon FireTVシリーズへの対応、Amazonのストアでの公開
- 初回起動時のOnboarding画面の追加
diff --git a/app/build.gradle b/app/build.gradle
index f9059ec..4f5a2d7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -11,8 +11,8 @@ android {
applicationId "com.daigorian.epcltvapp"
minSdkVersion 22
targetSdkVersion 30
- versionCode 13
- versionName "1.13"
+ versionCode 14
+ versionName "1.14"
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c9272e1..d081415 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -42,8 +42,10 @@
diff --git a/app/src/main/java/com/daigorian/epcltvapp/SettingsActivity.kt b/app/src/main/java/com/daigorian/epcltvapp/SettingsActivity.kt
index 571ba77..bfbb1bd 100644
--- a/app/src/main/java/com/daigorian/epcltvapp/SettingsActivity.kt
+++ b/app/src/main/java/com/daigorian/epcltvapp/SettingsActivity.kt
@@ -1,10 +1,10 @@
package com.daigorian.epcltvapp
+import android.app.Activity
import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-class SettingsActivity : FragmentActivity() {
+class SettingsActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
diff --git a/app/src/main/java/com/daigorian/epcltvapp/SettingsFragment.kt b/app/src/main/java/com/daigorian/epcltvapp/SettingsFragment.kt
index 55f1708..a57560c 100644
--- a/app/src/main/java/com/daigorian/epcltvapp/SettingsFragment.kt
+++ b/app/src/main/java/com/daigorian/epcltvapp/SettingsFragment.kt
@@ -4,43 +4,108 @@ import android.content.Context
import android.os.Bundle
import android.widget.Toast
import androidx.leanback.preference.LeanbackPreferenceFragment
+import androidx.leanback.preference.LeanbackSettingsFragment
import androidx.preference.*
+import androidx.preference.DialogPreference.TargetFragment
-class SettingsFragment : LeanbackPreferenceFragment() {
- override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
- setPreferencesFromResource(R.xml.preferences, rootKey)
+class SettingsFragment : LeanbackSettingsFragment(), TargetFragment {
+ private var mPreferenceFragment: PreferenceFragment? = null
+ override fun onPreferenceStartInitialScreen() {
+ mPreferenceFragment = buildPreferenceFragment(R.xml.preferences, null)
+ startPreferenceFragment(mPreferenceFragment!!)
+ }
+
+ override fun onPreferenceStartFragment(
+ preferenceFragment: PreferenceFragment,
+ preference: Preference
+ ): Boolean {
+ return false
+ }
+
+ override fun onPreferenceStartScreen(
+ preferenceFragment: PreferenceFragment,
+ preferenceScreen: PreferenceScreen
+ ): Boolean {
+ val frag = buildPreferenceFragment(
+ R.xml.preferences,
+ preferenceScreen.key
+ )
+ startPreferenceFragment(frag)
+ return true
+ }
+
- //IPアドレスの入力時バリデーション
- val ipAddressPref = preferenceScreen.findPreference(getText(R.string.pref_key_ip_addr)) as EditTextPreference?
- ipAddressPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
- val regex = Regex(pattern =IP_REGEX_PATTERN)
- if (value.toString().matches(regex)){
- true
- }else{
- Toast.makeText(activity, getString(R.string.not_a_valid_ipv4_addr,value.toString()), Toast.LENGTH_LONG).show()
- false
+ private fun buildPreferenceFragment(preferenceResId: Int, root: String?): PreferenceFragment {
+ val fragment: PreferenceFragment =
+ PrefFragment()
+ val args = Bundle()
+ args.putInt(
+ PREFERENCE_RESOURCE_ID,
+ preferenceResId
+ )
+ args.putString(
+ PREFERENCE_ROOT,
+ root
+ )
+ fragment.arguments = args
+ return fragment
+ }
+
+ override fun findPreference(key: CharSequence): T? {
+ return mPreferenceFragment!!.findPreference(key)
+ }
+
+ class PrefFragment : LeanbackPreferenceFragment() {
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ val root = arguments.getString(PREFERENCE_ROOT, null)
+ val prefResId = arguments.getInt(PREFERENCE_RESOURCE_ID)
+ if (root == null) {
+ addPreferencesFromResource(prefResId)
+ } else {
+ setPreferencesFromResource(prefResId, root)
}
- }
- //PORT番号の入力時バリデーション
- val portNumPref = preferenceScreen.findPreference(getText(R.string.pref_key_port_num)) as EditTextPreference?
- portNumPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
- val regex = Regex(pattern =PORT_REGEX_PATTERN)
- if (value.toString().matches(regex)){
- true
- }else{
- Toast.makeText(activity, getString(R.string.not_a_valid_port_num,value.toString()), Toast.LENGTH_LONG).show()
- false
+ //IPアドレスの入力時バリデーション
+ val ipAddressPref = preferenceScreen.findPreference(getText(R.string.pref_key_ip_addr)) as EditTextPreference?
+ ipAddressPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
+ val regex = Regex(pattern =IP_REGEX_PATTERN)
+ if (value.toString().matches(regex)){
+ true
+ }else{
+ Toast.makeText(activity, getString(R.string.not_a_valid_ipv4_addr,value.toString()), Toast.LENGTH_LONG).show()
+ false
+ }
+
}
+ //PORT番号の入力時バリデーション
+ val portNumPref = preferenceScreen.findPreference(getText(R.string.pref_key_port_num)) as EditTextPreference?
+ portNumPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
+ val regex = Regex(pattern =PORT_REGEX_PATTERN)
+ if (value.toString().matches(regex)){
+ true
+ }else{
+ Toast.makeText(activity, getString(R.string.not_a_valid_port_num,value.toString()), Toast.LENGTH_LONG).show()
+ false
+ }
+
+ }
+
+ }
+
+
+ companion object{
}
}
- companion object{
+ companion object {
+ private const val PREFERENCE_RESOURCE_ID = "preferenceResource"
+ private const val PREFERENCE_ROOT = "root"
+
private const val IP_REGEX_PATTERN = """^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$"""
private const val PORT_REGEX_PATTERN = """^([1-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$"""
@@ -60,11 +125,13 @@ class SettingsFragment : LeanbackPreferenceFragment() {
}
//ほかのパラメータの存在チェック
return (
- pref.contains(context.getString(R.string.pref_key_fetch_limit)) &&
- pref.contains(context.getString(R.string.pref_key_player)) &&
- pref.contains(context.getString(R.string.pref_key_num_of_history))
- )
+ pref.contains(context.getString(R.string.pref_key_fetch_limit)) &&
+ pref.contains(context.getString(R.string.pref_key_player)) &&
+ pref.contains(context.getString(R.string.pref_key_num_of_history))
+ )
}
+
}
+
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index d111188..95365f8 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -7,8 +7,4 @@
android:name="com.daigorian.epcltvapp.SettingsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
-
-
-
-
-
+
\ No newline at end of file
diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml
index 4781316..d5b1b16 100644
--- a/app/src/main/res/values-ja-rJP/strings.xml
+++ b/app/src/main/res/values-ja-rJP/strings.xml
@@ -22,7 +22,7 @@
MX Player (デフォルト)
VLC
内蔵 (非推奨)
- \"EPGStationの録画を見る\" の設定
+ 設定
%1$s は有効なIPv4アドレスではありません
%1$s は有効なポート番号ではありません
EPGStationのバージョン
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5214ca0..a63c2ff 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4,7 +4,7 @@
EPGStation
Settings
- Settings of EPGStation Player
+ Settings
Now On Recording
Recent videos
Rule ID %1$s
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 4a27926..fab9deb 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -1,8 +1,18 @@
+
+
+
+
\ No newline at end of file