diff --git a/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceChildFragment.kt b/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceChildFragment.kt index 4038b7b..a793f5a 100644 --- a/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceChildFragment.kt +++ b/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceChildFragment.kt @@ -1,14 +1,18 @@ package io.github.takusan23.searchpreferencefragment +import android.graphics.Color +import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.util.Log import android.view.View +import androidx.core.view.postDelayed import androidx.fragment.app.viewModels import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleObserver import androidx.lifecycle.OnLifecycleEvent import androidx.preference.* import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView /** * [SearchPreferenceFragment]に置くFragment。設定項目一覧はこのFragmentで表示している @@ -18,6 +22,9 @@ class SearchPreferenceChildFragment : PreferenceFragmentCompat() { /** 最初に表示されるPreferenceのID */ private val defaultPreferenceResId by lazy { arguments?.getInt(PREFERENCE_XML_RESOURCE_ID) } + /** 検索結果を押したときに設定項目をハイライトさせる色 */ + var SEARCH_SCROLL_HIGH_LIGHT_COLOR = Color.parseColor("#80ffff00") + companion object { /** 最初に表示するPreferenceのリソースID */ const val PREFERENCE_XML_RESOURCE_ID = "preference_xml_resource_id" @@ -59,31 +66,9 @@ class SearchPreferenceChildFragment : PreferenceFragmentCompat() { (fragment as? PreferenceFragmentCompat)?.apply { val scrollTitle = arguments?.getString("scroll_title") val scrollKey = arguments?.getString("scroll_key") - - val pos = getAllPreference(preferenceScreen).indexOfFirst { preference -> - if (scrollKey != null) { - preference.key == scrollKey - } else { - Log.e(javaClass.simpleName, "Preferenceにkeyが設定されていなかったため、同じタイトルの設定項目へスクロールします。") - preference.title == scrollTitle - } - } - // なんか遅延させると動く - view?.postDelayed({ - if (isAdded) { - /** - * LayoutManager経由でスクロールする。RecyclerViewにもスクロール関数が生えてるけど、なんか実装空っぽだった - * - * なので、[PreferenceFragmentCompat.scrollToPreference]も、RecyclerViewの実装空っぽスクロール関数を呼んでいるため動かない。 - * */ - (listView.layoutManager as LinearLayoutManager).apply { - scrollToPositionWithOffset(pos, 0) - } - } - }, 500) - + // スクロール + scroll(getAllPreference(preferenceScreen), listView, scrollKey, scrollTitle) } - } }) return true @@ -115,41 +100,64 @@ class SearchPreferenceChildFragment : PreferenceFragmentCompat() { } } + // 表示中のPreferenceを配列にして持っておく + val preferenceList = getAllPreference(preferenceScreen) + // 検索結果Preferenceを押したときのコールバック的なLiveData viewModel.changePreferenceScreen.observe(viewLifecycleOwner) { result -> // 同じリソースIDなら if (result.resId == defaultPreferenceResId) { - // スクロール - val pos = getAllPreference(preferenceScreen).indexOfFirst { preference -> - if (result.preference.key != null) { - preference.key == result.preference.key - } else { - Log.e(javaClass.simpleName, "Preferenceにkeyが設定されていなかったため、同じタイトルの設定項目へスクロールします。") - preference.title == result.preferenceTitle - } - } - // なんか遅延させると動く - view.postDelayed({ - if (isAdded) { - /** - * LayoutManager経由でスクロールする。RecyclerViewにもスクロール関数が生えてるけど、なんか実装空っぽだった - * - * なので、[PreferenceFragmentCompat.scrollToPreference]も、RecyclerViewの実装空っぽスクロール関数を呼んでいるため動かない。 - * */ - (listView.layoutManager as LinearLayoutManager).apply { - scrollToPositionWithOffset(pos, 0) + scroll(preferenceList, listView, result.preference.key, result.preferenceTitle) + } + } + + } + + private fun scroll(preferenceList: ArrayList, listView: RecyclerView, preferenceKey: String?, preferenceTitle: String?) { + // スクロール + val pos = preferenceList.indexOfFirst { preference -> + if (preferenceKey != null) { + preference.key == preferenceKey + } else { + Log.e(javaClass.simpleName, "Preferenceにkeyが設定されていなかったため、同じタイトルの設定項目へスクロールします。") + preference.title == preferenceTitle + } + } + // なんか遅延させると動く + listView.postDelayed(500) { + /** + * LayoutManager経由でスクロールする。RecyclerViewにもスクロール関数が生えてるけど、なんか実装空っぽだった + * + * なので、[PreferenceFragmentCompat.scrollToPreference]も、RecyclerViewの実装空っぽスクロール関数を呼んでいるため動かない。 + * */ + val visibleItem = (listView.layoutManager as LinearLayoutManager).let { + // 真ん中へスクロールさせたいので + (it.findLastCompletelyVisibleItemPosition() - it.findFirstVisibleItemPosition()) / 2 + } + listView.smoothScrollToPosition(pos + visibleItem) + // リピートさせる + var delayTime = 200L + repeat(9) { // 奇数回だと色ついて終わる + // コルーチンだともっときれいにかけそう + listView.postDelayed(delayTime) { + // RecyclerViewの指定した位置のViewを取得して背景色を変更 + (listView.layoutManager as LinearLayoutManager).findViewByPosition(pos)?.apply { + background = if (background == null) { + ColorDrawable(SEARCH_SCROLL_HIGH_LIGHT_COLOR) + } else { + null } } - }, 500) + } + delayTime += 500 } } - } /** Preferenceをすべて見つけて配列にして返す関数 */ private fun getAllPreference(preferenceScreen: PreferenceScreen): ArrayList { // 設定項目を配列にしまう - val preferenceList = arrayListOf().apply { + return arrayListOf().apply { // 再帰的に呼び出す fun getChildPreference(group: PreferenceGroup) { val preferenceCount = group.preferenceCount @@ -163,7 +171,6 @@ class SearchPreferenceChildFragment : PreferenceFragmentCompat() { } getChildPreference(preferenceScreen) } - return preferenceList } } \ No newline at end of file diff --git a/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceViewModel.kt b/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceViewModel.kt index 69f1224..eae59da 100644 --- a/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceViewModel.kt +++ b/SearchPreferenceFragment/src/main/java/io/github/takusan23/searchpreferencefragment/SearchPreferenceViewModel.kt @@ -72,8 +72,10 @@ class SearchPreferenceViewModel(application: Application, private val preference // PreferenceCategoryなら名前を控える。 if (parser.name == "PreferenceCategory" && isCategoryShow) { + val attrs = Xml.asAttributeSet(parser) + val categoryPreference = Preference(context, attrs) // ローカライズに対応させるため if (eventType == XmlPullParser.START_TAG) { - categoryName = title // 囲いはじめ + categoryName = categoryPreference.title.toString() // 囲いはじめ } if (eventType == XmlPullParser.END_TAG) { categoryName = null // 終了タグ @@ -94,8 +96,10 @@ class SearchPreferenceViewModel(application: Application, private val preference } else { pref.summary } - // 属性の方を優先して登録する。なければ遷移先Fragment - pref.fragment = fragmentAttr ?: fragmentName + // もしdependencyが設定されている場合は剥がす(表示できないエラーを回避) + pref.dependency = null + // 階層Fragmentが指定されていればそれを、なければnull + pref.fragment = fragmentName val data = SearchPreferenceParseData( preference = pref, resId = xmlResId, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a3536b8..2265377 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,535 @@ SearchPreferenceFragmentExample Android Codename + Login + MailAddress + Password + There was a problem. + LiveID + Connection + Successful + Please set your email address and password. + Loading + Connected + The seat number and current room could not be obtained because getPlayerStatus could not be obtained. + Gift History + Gift Ranking + Contribution ranking + Ad history + Arena + Post a comment + Post + Settings + Play live broadcast + Watch live broadcast + Play live broadcast + Open in browser + Use viewing mode + If enabled, comments can be posted.\nHowever, you will not be able to play the same broadcast on other devices. + The ID could not be found. + Live broadcast / video ID input + Followed programs + Please wait until the start time. + You have successfully posted a comment. + Failed to post a comment. + Post with 184 (anonymous). + Posted comments will flow to the arena regardless of the room. + Use comment-to-speech. + Display comments in Toast + TTS ready + mode selection + CommentViewer Mode + You can get comments, gifts, and nicoini ads for all rooms. + I cannot post comments. + Comment posting mode + It is not disconnected even if you watch it simultaneously on a computer.\nComments can be posted. You can get comments, gifts, and nicoini ads for all rooms. + If you launch this app on another device and select this mode, you will be disconnected. (You can choose another mode.) + Nicocas expression comment posting mode + Even if you view on the computer at the same time, it will not be disconnected. \nComments can be posted. \nYou can get comments, gifts, and nicoini ads for all rooms. + The posted comments will be comments on the arena room regardless of the room. + watchCount + CommentCount + Email address and password are not saved. + Comment + View by room + Gift + niconi ads + Program Info + Broadcaster + Community + Community Level + Nicorepo + Link + About this app + Licence + If you have anything, please go here. The browser will start. + Version + Other + Reservation frame automatic entrance function + Reservation frame automatic entrance function + Exit the automatic reservation slot admission function + Reservation slot automatic admission service is running. + Open with NicoNico Live Broadcast App + Open with TatimiDroid (Cannot start due to changes in Android 10 and later specifications) + When the reservation frame start time is reached, it can be started automatically with this app or the NicoNico Live Broadcast app. + Added + Nico Nico Live Broadcasting + Delete + Do you want to delete it? + source code + Since the ID was found in the copied content, it was automatically pasted. + Open Comment Viewer + Reservation frame automatic admission start notification + About 1 minute later, you will automatically enter the reserved space. + Hide eviction comments + Hide eviction comment (hb ifseetno) + The program is not registered. + I registered for KOTEHAN. + KOTEHAN + Kotehan added + Added to NG comments. + Added to NG users. + Long press to register + NG user + NG comment + It has been deleted + NG list + Since the auto-start function is not available in your version, please start the app. + Launch app + Program background playback + Pop-up playback + Background playback + Finish + pause + Regeneration + Program Pop-up Playback + The program is playing in a pop-up. + finish + Pop-up playback has ended because the app has started. + Background playback has ended because the app has started. + When away from the app + Play background when you leave the app. + Pop-up playback when leaving the app. + One person + person + Add comment NG + Add user NG + Copy comment + Copied comment. + Open URL + 1 minute + Number of active people (number of comments per minute) + elapsed time + Hide comments + Color the room + Follow the NCV and color the arena and standing characters. (Supports up to 10). \nIn the ID non-display mode, color the comment. + Add + Comment posting list + questionnaire + Questionnaire results + Share + Program search + Recommended programs for you + Ranking + Use the new comment posting screen. + New comment posts are always displayed at the bottom so you can post comments. + privacy policy + Pop-up playback automatically when watching live broadcasts + it changed. + Added. + If you add the same reading, it will be overwritten. + Comment Collection + This program has ended. + End + Do you want to exit? + Otsutsu + Comment collection replenishment function + This function is displayed when there is a reading while inputting a comment. + Automatic next frame move + Set to dark mode + If you want to use dark mode on Android 8 or earlier devices, please enable. For Android 9 or later, set the dark mode from the main unit settings. + Forcibly change vertical / horizontal screen + Copy program ID + Hide info comments and management comments + mute + The next frame automatic movement function is effective. Check the frame at 1 minute intervals. + Conversion failed + Share with image attachment + Hide ID + Display in one line + Setting the comment viewer + volume + Volume control + Change image quality + Automatic + Audio only + The image quality has changed. + The program is over. + Minimum quality for mobile data + When using mobile data, it automatically switches to the lowest image quality. + Log in again + Getting program ID from community ID + Program ID, community ID, or video ID + Enable comment collection + You can register comments that you enter frequently. + Floating comment viewer + You can use the comment viewer while starting other apps. + To use this function, Android version must be 10 or later. + Exit flooring comment viewer + Menu + Copy community ID + Forced screen rotation using sensor + The screen is rotated using the sensor even when the screen rotation is disabled. + 2-window comment view + Movement size of comment + The default is 3 + I confirmed the extension. + End time + Hide 184 (anonymous) comments + Smooth background playback + In order to be able to play immediately when switching apps, prepare for playback in the back in advance and start playback at the same time when you leave the app. (The communication volume will increase.) + Failed to get user session. Please review your email address and password. + "Video ID (sm9, sm157, etc.)   " + Nico douga comment acquisition + History + Posted videos + Views + Mylist + Post date + Watching + Play video in browser + Video information + Dictionary + Low latency mode + Disable low latency mode + Hide 3DS comments + Registration date + Toriaezu Mylist + Nicoru + Parent work + Number of comments acquired + Total parent work + series + Sort comments + Play time (from the beginning) + Play time (from the end) + Posting date (new → old) + Posting date (old → new) + There was a problem playing the live broadcast. Prepare for playback again. + Retry + Frame remaining time + How to display comment posting time + Change the display from absolute time (example: 07:14:22) to relative time (example: 25:25) + Show NG score + Post a comment with the enter key (line feed) + History + Add comment colors by room + Arena comments are colored by room, such as blue. If enabled, the command\'s colored comments will be disabled. + Follower-only program. + Cast + Logged in again because user session expired. + Reload + font + Choose a font + Delete selected font + If you want to use a font file that cannot be selected in font selection, please go to the following location. \n /sdcard/Android/data/io.github.takusan23.tatimidroid/font + Nico live game + Play Nico live game (experimental) + For engineers: In order to use the Nico Live game, it is realized by displaying the PC version of Nico Live on WebView. + Make sure you ’re not watching on another device when activating. Also, do not open programs on other terminals. (Disconnected) + Program during Nico live game play + Programs for recruiting Nico live game viewers + No shows found + font size + Edit font size (comment) + Edit font size (user ID) + Reset font size + Font settings + You can use the font size and font file of the comment viewer. + Exit comment viewer when program ends + Even if you fall asleep, you can avoid running out of battery. + Edit tags + Follow the community + User follow + Tag + Show start + End of program + Level + Followed + It is a program that can not edit tags + Time shift reservation + Register / cancel time shift + Time shift reservation successful + Timeshift reservation canceled + Booking list (browser) + Cancel reservation + Time shift reserved + Command + Post with User ID + Big + Medium + Small + Time shift is disabled + Official program + Reserved program + Add event to calendar + others + Already added + Removed from the reservation frame automatic admission list. + Always display program name, broadcast time, visitors, etc. + Ad total points + Points during the advertising period + Notch invades cutout area + Hide the status bar and navigation bar to increase the display area. It will be counterproductive on some devices. (Terminals with large notches, etc.) + Re-login to Nico Nico + View + Post + Cas + Auto Admission + Calendar + TS + Automatic admission (opens at Tachimidorido) + Automatic admission (open with Nico Nico) + Nico Live Top + Upcoming programs + Popular reservation programs + Open recommendations, rankings, official programs, etc. + Advertise + Serch + Comment search + Following + Don\'t scroll the comment field according to the playback time + Views + Mylists + Previous page + Following page + page + Cache + Click here to expand rankings, my lists, etc. + Get cache + Getting video cache + Video comment obtained + Got video thumbnail + Video information obtained + Video cache obtained + Clear cache + The cache list is displayed because there is no Internet connection. + Updated program information and comments + Updating program information and comments + Encrypted videos cannot be saved. + My list registration + Reacquire video information and comments + Added to my list + Removed from My List + Remove from My List + Video + Live + Convert XML format comments to JSON format + Conversion to JSON format is complete. + Convert comments in XML format before playback. Select \"Convert XML format comments to JSON format\" from the video in the cache list and convert it before playing. + Wait a moment + Encrypted videos cannot be played. + Can I delete the cache? + Video + If you are connected to the Internet with mobile data, display the cache list + Comment drawing settings + Change the update frequency of comment drawing + Default is 10 + I couldn\'t find the video + Show only comments + Display only the comment screen without playing the video + Play video + Copy video ID + Video ID copy + Cache playback saves playback position + Play from the position you last saw + Play + Hide program information on landscape screen + Deprecated + Video pop-up playback + Video background playback + Video popup / background playback + About cache playback + Click here for information on playing your own videos and comment files with this app + Nico Nico Live Commentary + Video ID found. + Hide comment search and comment sort buttons + Cash acquisition (economy mode) + Cash acquisition service + Getting cache + Reserved for cash acquisition + Number of remaining cache reservations + Already added to the cache acquisition reservation list + All cash acquisition completed + Acquisition service end + Related Videos + If the cache has already been acquired, it will be used preferentially even when the cache is not being played. + Use cache preferentially + Playback using cache + Use without login + You need to be logged in to watch the video. You need to log in for live broadcasting and live commentary, so you can log in regardless of this setting. + Clear cache + Cancel + Can I delete it from my list? + Play in forced economy + Setting of screen displayed at startup + You can use it when you want to open a live broadcast as soon as it starts + Startup settings + App Shortcuts are not affected by this value + Normal playback (default) + Change playback method + It can be used when you want it to always be played in a popup. + This is the last ;; + Set the order of the list of My List to the most registered videos + Cache continuous playback notification + Remove filter + Is it really okay to reset sort and sort conditions? + Delete + I have been logged out. Would you like to log in again? + Login or set \"Use without login\" in settings... + Nikotta Nicoru + I\'m already nicoru + Open in browser (other application) + Secure 10 comment lines regardless of size + If enabled, 10 lines of comment can be displayed. + Enable comment line settings + Use it when you have too many comments and can\'t see them or want to display more than 10 lines. + Set comment line + With this, the comment line is reserved for the set value. + Total cache capacity + Only today + The cache is empty + When you get the cache, it will be displayed here. + To watch Nico Nico Douga, you need to enable \"Login\" or \"Use without login\". + Use without logging in (live broadcasting and live viewing cannot be used)\n You can always return from the settings. + Login to NicoNico (recommended) + (Premium only) Make you nico + The second term Nikoru-kun is still in beta stage, so I have disabled it by default. + Open in pop-up playback + Open in bagground play + Added to home screen (test introduction) + Video, live broadcast common settings + If disabled, comments can be posted in multiple lines. + Economy mode: Low image quality mode. + Watch in forced economy mode + Always watch in low quality + Please when Internet is slow + Cash acquisition progress notification + Getting cash + Reset + TV + Radio + BS + Video contributors have hidden the list of posted videos. + User name acquisition + Open user page + Canceled Nicoru + cancel + Change skip seconds + Change skip time (seconds).(By the way, skip can be used by double tapping the left and right of the playback screen.) + Change skip time when pressing and holding (second) + You can change the skip seconds. + Hide the comment visualization (graph above the seek bar) + Match the color of the comment list frame to the room color + Outline CardView and match the frame color with the room color. Disable if the previous specifications are good. + NG score + One minute statistics + Number of premium accounts + Number of raw IDs + Average NG score + Average number of comment characters + See the first used day + "Press here to get the oldest value from the history database. " + Play Nico Live Game (experimental. Live broadcast and comments are also displayed on WebView.) + Already acquired + Change the color according to the number of smiles + Outline the CardView and change the frame color. + Apply selected font file to flowing comments + Replace the forward button with the back button. + Replaces the next song button with the previous song button for continuous background playback (cache only). Since the seek bar is available on Android 10 or later, the following songs can be replaced by operating the seek bar. + Setting comment transparency + You can set the transparency of the comment. Enter within the range of 0.1 to 1.0 (no transparency). + Set comment update frequency in fps + When enabled, \"Change comment drawing update frequency\" is not applied. + Set comment update frequency in fps + You can set the change of update frequency with fps. Let\'s change the \"moving size\" together. + Following + Don\'t use the chase button + If you don\'t want to use the button that moves the playback time for videos and the top button for live broadcasting, enable it. Enable it even if the previous specifications are good. + Myris registration, popup playback, etc. + TS registration, schedule addition, etc. + Don\'t send the same comment in succession + I was kicked out. + Turn off low latency + Play from here + Follow device settings + "Dark mode " + Light mode + Theme (dark mode) setting + You can enable dark mode as in the terminal settings, or you can always set it to dark mode.The change will be reflected after rebooting. + End full screen + rookie + You can adjust the size with pinch in and pinch out. + Fixed handle name list + Change the app language + You can choose between Japanese and English.It will be applied after reboot. + Follow terminal settings + Japanese + English + Show + Hide + ALL + Limit + See later + Number of comments per second + Maximum value + Color + Position + Size + Close + Like! + Liked! + Can I cancel the likes? + cancel + I like it! + Already registered + See later (for now, add to my list) + Added to see later + Do not show duplicates + Is me! + I couldn\'t find the posted rice even 5 seconds ago. + Fix size + This applies to live broadcasts only. + This applies to videos only. Probably too early, please adjust. + This applies only to videos + Command (position, color) is retained even after posting. + Delete in-device history + Total playback time + Number of videos + Reverse order + shuffle + Continuous playback + Continuous background playback + Transition of Nico Nico Douga + Normal playback + Play with the lowest image quality + Play audio only + Playback of audio only + Play using the internet + Two factor auth + Two-step verification is required to log in. + If you are set to receive the verification code by email, please check your inbox. To get the verification code with the smartphone app, open the app and get the code. + authentication code + Trust this device. If you check it, you can skip two-step verification from the next time. + Authentication started + Could not log in + Filter / Sort + Don\'t hide tabs + If you scroll the comment list etc., the tab will be hidden automatically, but if you do not like this, you can enable it to always display it. + Image quality during mobile data communication + During mobile data communication, you will be able to select normal playback, voice only, and minimum image quality. + Enable the minimum row setting + It is a setting to secure at least a comment line even if the player becomes small. For mini players + Minimum line setting + The priority of the setting is 10 lines reserved-> comment line settings-> minimum reserved lines. \ No newline at end of file diff --git a/app/src/main/res/xml/preference.xml b/app/src/main/res/xml/preference.xml index d59729d..402b051 100644 --- a/app/src/main/res/xml/preference.xml +++ b/app/src/main/res/xml/preference.xml @@ -51,9 +51,435 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file