Added label for Settings

This commit is contained in:
Hemanth S 2020-10-12 01:56:14 +05:30
parent acd55f249a
commit fa819284d0
2 changed files with 19 additions and 2 deletions

View file

@ -17,6 +17,7 @@ package code.name.monkey.retromusic.activities
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.NavDestination
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -43,10 +44,26 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
applyToolbar(toolbar) applyToolbar(toolbar)
val navController: NavController = findNavController(R.id.contentFrame) val navController: NavController = findNavController(R.id.contentFrame)
navController.addOnDestinationChangedListener { _, _, _ -> navController.addOnDestinationChangedListener { _, _, _ ->
toolbar.title = navController.currentDestination?.label toolbar.title = navController.currentDestination?.let { getStringFromDestination(it) }
} }
} }
private fun getStringFromDestination(currentDestination: NavDestination): String {
val idRes = when (currentDestination.id) {
R.id.mainSettingsFragment -> R.string.action_settings
R.id.audioSettings -> R.string.pref_header_audio
R.id.imageSettingFragment -> R.string.pref_header_images
R.id.notificationSettingsFragment -> R.string.notification
R.id.nowPlayingSettingsFragment -> R.string.now_playing
R.id.otherSettingsFragment -> R.string.others
R.id.personalizeSettingsFragment -> R.string.personalize
R.id.themeSettingsFragment -> R.string.general_settings_title
R.id.aboutActivity -> R.string.action_about
else -> R.id.action_settings
}
return getString(idRes)
}
override fun onSupportNavigateUp(): Boolean { override fun onSupportNavigateUp(): Boolean {
return findNavController(R.id.contentFrame).navigateUp() || super.onSupportNavigateUp() return findNavController(R.id.contentFrame).navigateUp() || super.onSupportNavigateUp()
} }

View file

@ -37,7 +37,7 @@
<string name="action_set">Запустить</string> <string name="action_set">Запустить</string>
<string name="action_set_as_ringtone">Задать в качества рингтона</string> <string name="action_set_as_ringtone">Задать в качества рингтона</string>
<string name="action_set_as_start_directory">Установить как стартовый каталог</string> <string name="action_set_as_start_directory">Установить как стартовый каталог</string>
<string name="action_settings">"Настройки"</string> <string name="action_settings">Настройки</string>
<string name="action_share">Поделиться</string> <string name="action_share">Поделиться</string>
<string name="action_shuffle_all">Перемешать всё</string> <string name="action_shuffle_all">Перемешать всё</string>
<string name="action_shuffle_playlist">Перемешать плейлист</string> <string name="action_shuffle_playlist">Перемешать плейлист</string>