From 510dd9c358a83278f008359dc41ab1b8cac10c7f Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Sat, 30 Jul 2022 03:24:07 +0200 Subject: [PATCH] Added setup screen :) --- .../lagradost/cloudstream3/MainActivity.kt | 14 + .../cloudstream3/ui/settings/SettingsLang.kt | 90 +-- .../ui/settings/SettingsUpdates.kt | 13 +- .../ui/setup/SetupFragmentLanguage.kt | 90 +++ .../ui/setup/SetupFragmentLayout.kt | 89 +++ .../ui/setup/SetupFragmentMedia.kt | 69 ++ .../ui/setup/SetupFragmentProviderLanguage.kt | 80 ++ .../drawable/ic_baseline_construction_24.xml | 6 + .../res/layout/fragment_setup_language.xml | 66 ++ .../main/res/layout/fragment_setup_layout.xml | 102 +++ .../main/res/layout/fragment_setup_media.xml | 60 ++ .../fragment_setup_provider_languages.xml | 63 ++ .../main/res/navigation/mobile_navigation.xml | 702 ++++++++++-------- app/src/main/res/values/strings.xml | 33 +- app/src/main/res/xml/settings_updates.xml | 74 +- 15 files changed, 1141 insertions(+), 410 deletions(-) create mode 100644 app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLanguage.kt create mode 100644 app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLayout.kt create mode 100644 app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentMedia.kt create mode 100644 app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt create mode 100644 app/src/main/res/drawable/ic_baseline_construction_24.xml create mode 100644 app/src/main/res/layout/fragment_setup_language.xml create mode 100644 app/src/main/res/layout/fragment_setup_layout.xml create mode 100644 app/src/main/res/layout/fragment_setup_media.xml create mode 100644 app/src/main/res/layout/fragment_setup_provider_languages.xml diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index daab7016..73c346d0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -36,6 +36,7 @@ import com.lagradost.cloudstream3.CommonActivity.onUserLeaveHint import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.CommonActivity.updateLocale import com.lagradost.cloudstream3.mvvm.logError +import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.network.initClient import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.OAuth2Apis @@ -49,6 +50,7 @@ import com.lagradost.cloudstream3.ui.search.SearchResultBuilder import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsGeneral +import com.lagradost.cloudstream3.ui.setup.HAS_DONE_SETUP_KEY import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable import com.lagradost.cloudstream3.utils.AppUtils.loadCache import com.lagradost.cloudstream3.utils.AppUtils.loadResult @@ -56,6 +58,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.BackupUtils.setUpBackup import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.main +import com.lagradost.cloudstream3.utils.DataStore import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.removeKey import com.lagradost.cloudstream3.utils.DataStore.setKey @@ -743,7 +746,18 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { ioSafe { migrateResumeWatching() } + + try { + if (getKey(HAS_DONE_SETUP_KEY, false) != true) { + navController.navigate(R.id.navigation_setup_language) + } + } catch (e: Exception) { + logError(e) + } finally { + setKey(HAS_DONE_SETUP_KEY, true) + } /* + val relativePath = (Environment.DIRECTORY_DOWNLOADS) + File.separatorChar val displayName = "output.dex" //""output.dex" val file = getExternalFilesDir(null)?.absolutePath + File.separatorChar + displayName//"${Environment.getExternalStorageDirectory()}${File.separatorChar}$relativePath$displayName" diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsLang.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsLang.kt index 84b40444..4693d066 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsLang.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsLang.kt @@ -1,5 +1,6 @@ package com.lagradost.cloudstream3.ui.settings +import android.content.Context import android.os.Bundle import android.view.View import androidx.preference.PreferenceFragmentCompat @@ -7,6 +8,7 @@ import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings +import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.network.initClient import com.lagradost.cloudstream3.ui.APIRepository @@ -19,45 +21,45 @@ import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog import com.lagradost.cloudstream3.utils.SubtitleHelper import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard +fun getCurrentLocale(context: Context): String { + val res = context.resources + // Change locale settings in the app. + // val dm = res.displayMetrics + val conf = res.configuration + return conf?.locale?.language ?: "en" +} + +// idk, if you find a way of automating this it would be great +// https://www.iemoji.com/view/emoji/1794/flags/antarctica +// Emoji Character Encoding Data --> C/C++/Java Src +// https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes leave blank for auto +val appLanguages = arrayListOf( + Triple("", "Spanish", "es"), + Triple("", "English", "en"), + Triple("", "Viet Nam", "vi"), + Triple("", "Dutch", "nl"), + Triple("", "French", "fr"), + Triple("", "Greek", "el"), + Triple("", "Swedish", "sv"), + Triple("", "Tagalog", "tl"), + Triple("", "Polish", "pl"), + Triple("", "Hindi", "hi"), + Triple("", "Malayalam", "ml"), + Triple("", "Norsk", "no"), + Triple("", "German", "de"), + Triple("", "Arabic", "ar"), + Triple("", "Turkish", "tr"), + Triple("", "Macedonian", "mk"), + Triple("\uD83C\uDDF5\uD83C\uDDF9", "Portuguese", "pt"), + Triple("\uD83C\uDDE7\uD83C\uDDF7", "Brazilian Portuguese", "bp"), + Triple("", "Romanian", "ro"), + Triple("", "Italian", "it"), + Triple("", "Chinese", "zh"), + Triple("", "Indonesian", "id"), + Triple("", "Czech", "cs"), +).sortedBy { it.second } //ye, we go alphabetical, so ppl don't put their lang on top + class SettingsLang : PreferenceFragmentCompat() { - // idk, if you find a way of automating this it would be great - // https://www.iemoji.com/view/emoji/1794/flags/antarctica - // Emoji Character Encoding Data --> C/C++/Java Src - // https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes leave blank for auto - private val languages = arrayListOf( - Triple("", "Spanish", "es"), - Triple("", "English", "en"), - Triple("", "Viet Nam", "vi"), - Triple("", "Dutch", "nl"), - Triple("", "French", "fr"), - Triple("", "Greek", "el"), - Triple("", "Swedish", "sv"), - Triple("", "Tagalog", "tl"), - Triple("", "Polish", "pl"), - Triple("", "Hindi", "hi"), - Triple("", "Malayalam", "ml"), - Triple("", "Norsk", "no"), - Triple("", "German", "de"), - Triple("", "Arabic", "ar"), - Triple("", "Turkish", "tr"), - Triple("", "Macedonian", "mk"), - Triple("\uD83C\uDDF5\uD83C\uDDF9", "Portuguese", "pt"), - Triple("\uD83C\uDDE7\uD83C\uDDF7", "Brazilian Portuguese", "bp"), - Triple("", "Romanian", "ro"), - Triple("", "Italian", "it"), - Triple("", "Chinese", "zh"), - Triple("", "Indonesian", "id"), - Triple("", "Czech", "cs"), - ).sortedBy { it.second } //ye, we go alphabetical, so ppl don't put their lang on top - - private fun getCurrentLocale(): String { - val res = requireContext().resources - // Change locale settings in the app. - // val dm = res.displayMetrics - val conf = res.configuration - return conf?.locale?.language ?: "en" - } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setUpToolbar(R.string.category_preferred_media_and_lang) @@ -112,22 +114,21 @@ class SettingsLang : PreferenceFragmentCompat() { .putInt(getString(R.string.prefer_media_type_key), prefValues[it]) .apply() - AcraApplication.removeKey(HOMEPAGE_API) - (context ?: AcraApplication.context)?.let { ctx -> app.initClient(ctx) } + removeKey(HOMEPAGE_API) +// (context ?: AcraApplication.context)?.let { ctx -> app.initClient(ctx) } } return@setOnPreferenceClickListener true } getPref(R.string.locale_key)?.setOnPreferenceClickListener { - val tempLangs = languages.toMutableList() + val tempLangs = appLanguages.toMutableList() //if (beneneCount > 100) { // tempLangs.add(Triple("\uD83E\uDD8D", "mmmm... monke", "mo")) //} - val current = getCurrentLocale() + val current = getCurrentLocale(requireContext()) val languageCodes = tempLangs.map { it.third } val languageNames = tempLangs.map { (emoji, name, iso) -> val flag = emoji.ifBlank { SubtitleHelper.getFlagFromIso(iso) ?: "ERROR" } - "$flag $name" } val index = languageCodes.indexOf(current) @@ -149,7 +150,8 @@ class SettingsLang : PreferenceFragmentCompat() { getPref(R.string.provider_lang_key)?.setOnPreferenceClickListener { activity?.getApiProviderLangSettings()?.let { current -> - val langs = APIHolder.apis.map { it.lang }.toSet().sortedBy { SubtitleHelper.fromTwoLettersToLanguage(it) } + val langs = APIHolder.apis.map { it.lang }.toSet() + .sortedBy { SubtitleHelper.fromTwoLettersToLanguage(it) } val currentList = ArrayList() for (i in current) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsUpdates.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsUpdates.kt index 04c7af92..ddf4c5c1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsUpdates.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsUpdates.kt @@ -7,6 +7,7 @@ import android.os.Bundle import android.view.View import android.widget.Toast import androidx.appcompat.app.AlertDialog +import androidx.navigation.fragment.findNavController import androidx.preference.PreferenceFragmentCompat import com.lagradost.cloudstream3.CommonActivity import com.lagradost.cloudstream3.R @@ -31,6 +32,7 @@ class SettingsUpdates : PreferenceFragmentCompat() { super.onViewCreated(view, savedInstanceState) setUpToolbar(R.string.category_updates) } + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { hideKeyboard() setPreferencesFromResource(R.xml.settings_updates, rootKey) @@ -41,6 +43,11 @@ class SettingsUpdates : PreferenceFragmentCompat() { return@setOnPreferenceClickListener true } + getPref(R.string.redo_setup_key)?.setOnPreferenceClickListener { + findNavController().navigate(R.id.navigation_setup_language) + return@setOnPreferenceClickListener true + } + getPref(R.string.restore_key)?.setOnPreferenceClickListener { activity?.restorePrompt() return@setOnPreferenceClickListener true @@ -112,7 +119,11 @@ class SettingsUpdates : PreferenceFragmentCompat() { thread { if (!requireActivity().runAutoUpdate(false)) { activity?.runOnUiThread { - CommonActivity.showToast(activity, R.string.no_update_found, Toast.LENGTH_SHORT) + CommonActivity.showToast( + activity, + R.string.no_update_found, + Toast.LENGTH_SHORT + ) } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLanguage.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLanguage.kt new file mode 100644 index 00000000..bc047a06 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLanguage.kt @@ -0,0 +1,90 @@ +package com.lagradost.cloudstream3.ui.setup + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AbsListView +import android.widget.ArrayAdapter +import androidx.core.content.ContextCompat +import androidx.fragment.app.Fragment +import androidx.navigation.fragment.findNavController +import androidx.preference.PreferenceManager +import com.lagradost.cloudstream3.BuildConfig +import com.lagradost.cloudstream3.CommonActivity +import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.mvvm.normalSafeApiCall +import com.lagradost.cloudstream3.ui.settings.appLanguages +import com.lagradost.cloudstream3.ui.settings.getCurrentLocale +import com.lagradost.cloudstream3.utils.SubtitleHelper +import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar +import kotlinx.android.synthetic.main.fragment_setup_language.* +import kotlinx.android.synthetic.main.fragment_setup_media.listview1 +import kotlinx.android.synthetic.main.fragment_setup_media.next_btt + +const val HAS_DONE_SETUP_KEY = "HAS_DONE_SETUP" +class SetupFragmentLanguage : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_setup_language, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + context?.fixPaddingStatusbar(setup_root) + + // We don't want a crash for all users + normalSafeApiCall { + with(context) { + if (this == null) return@normalSafeApiCall + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + + val arrayAdapter = + ArrayAdapter(this, R.layout.sort_bottom_single_choice) + + // Icons may crash on some weird android versions? + normalSafeApiCall { + val drawable = when { + BuildConfig.DEBUG -> R.drawable.cloud_2_gradient_debug + BuildConfig.BUILD_TYPE == "prerelease" -> R.drawable.cloud_2_gradient_beta + else -> R.drawable.cloud_2_gradient + } + app_icon_image?.setImageDrawable(ContextCompat.getDrawable(this, drawable)) + } + + val current = getCurrentLocale(this) + val languageCodes = appLanguages.map { it.third } + val languageNames = appLanguages.map { (emoji, name, iso) -> + val flag = emoji.ifBlank { SubtitleHelper.getFlagFromIso(iso) ?: "ERROR" } + "$flag $name" + } + val index = languageCodes.indexOf(current) + + arrayAdapter.addAll(languageNames) + listview1?.adapter = arrayAdapter + listview1?.choiceMode = AbsListView.CHOICE_MODE_SINGLE + listview1?.setItemChecked(index, true) + + listview1?.setOnItemClickListener { _, _, position, _ -> + val code = languageCodes[position] + CommonActivity.setLocale(activity, code) + settingsManager.edit().putString(getString(R.string.locale_key), code).apply() + activity?.recreate() + } + + next_btt?.setOnClickListener { + findNavController().navigate(R.id.action_navigation_setup_language_to_navigation_setup_provider_languages) + } + + skip_btt?.setOnClickListener { + findNavController().navigate(R.id.navigation_home) + } + } + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLayout.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLayout.kt new file mode 100644 index 00000000..bc9bfb1f --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentLayout.kt @@ -0,0 +1,89 @@ +package com.lagradost.cloudstream3.ui.setup + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AbsListView +import android.widget.ArrayAdapter +import androidx.fragment.app.Fragment +import androidx.navigation.fragment.findNavController +import androidx.preference.PreferenceManager +import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar +import kotlinx.android.synthetic.main.fragment_setup_layout.* +import kotlinx.android.synthetic.main.fragment_setup_media.listview1 +import kotlinx.android.synthetic.main.fragment_setup_media.next_btt +import kotlinx.android.synthetic.main.fragment_setup_media.prev_btt +import kotlinx.android.synthetic.main.fragment_setup_media.setup_root +import org.acra.ACRA + + +class SetupFragmentLayout : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_setup_layout, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + context?.fixPaddingStatusbar(setup_root) + + with(context) { + if (this == null) return + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + + val prefNames = resources.getStringArray(R.array.app_layout) + val prefValues = resources.getIntArray(R.array.app_layout_values) + + val currentLayout = + settingsManager.getInt(getString(R.string.app_layout_key), -1) + + val arrayAdapter = + ArrayAdapter(this, R.layout.sort_bottom_single_choice) + + arrayAdapter.addAll(prefNames.toList()) + listview1?.adapter = arrayAdapter + listview1?.choiceMode = AbsListView.CHOICE_MODE_SINGLE + listview1?.setItemChecked( + prefValues.indexOf(currentLayout), true + ) + + listview1?.setOnItemClickListener { _, _, position, _ -> + settingsManager.edit() + .putInt(getString(R.string.app_layout_key), prefValues[position]) + .apply() + activity?.recreate() + } + + acra_switch?.setOnCheckedChangeListener { _, enableCrashReporting -> + // Use same pref as in settings + settingsManager.edit().putBoolean(ACRA.PREF_DISABLE_ACRA, !enableCrashReporting) + .apply() + val text = + if (enableCrashReporting) R.string.bug_report_settings_off else R.string.bug_report_settings_on + crash_reporting_text?.text = getText(text) + } + + val enableCrashReporting = !settingsManager.getBoolean(ACRA.PREF_DISABLE_ACRA, false) + acra_switch.isChecked = enableCrashReporting + crash_reporting_text.text = + getText( + if (enableCrashReporting) R.string.bug_report_settings_off else R.string.bug_report_settings_on + ) + + + next_btt?.setOnClickListener { + findNavController().navigate(R.id.navigation_home) + } + + prev_btt?.setOnClickListener { + findNavController().popBackStack() + } + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentMedia.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentMedia.kt new file mode 100644 index 00000000..cd0c76f5 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentMedia.kt @@ -0,0 +1,69 @@ +package com.lagradost.cloudstream3.ui.setup + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AbsListView +import android.widget.ArrayAdapter +import androidx.fragment.app.Fragment +import androidx.navigation.fragment.findNavController +import androidx.preference.PreferenceManager +import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.utils.DataStore.removeKey +import com.lagradost.cloudstream3.utils.HOMEPAGE_API +import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar +import kotlinx.android.synthetic.main.fragment_setup_media.* + + +class SetupFragmentMedia : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_setup_media, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + context?.fixPaddingStatusbar(setup_root) + + with(context) { + if (this == null) return + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + + val arrayAdapter = + ArrayAdapter(this, R.layout.sort_bottom_single_choice) + + val currentPrefMedia = + settingsManager.getInt(getString(R.string.prefer_media_type_key), 0) + + val prefNames = resources.getStringArray(R.array.media_type_pref) + val prefValues = resources.getIntArray(R.array.media_type_pref_values) + + arrayAdapter.addAll(prefNames.toList()) + listview1?.adapter = arrayAdapter + listview1?.choiceMode = AbsListView.CHOICE_MODE_SINGLE + listview1?.setItemChecked(currentPrefMedia, true) + + listview1?.setOnItemClickListener { _, _, position, _ -> + settingsManager.edit() + .putInt(getString(R.string.prefer_media_type_key), prefValues[position]) + .apply() + + // Regenerate set homepage + removeKey(HOMEPAGE_API) + } + + next_btt?.setOnClickListener { + findNavController().navigate(R.id.navigation_setup_media_to_navigation_setup_layout) + } + + prev_btt?.setOnClickListener { + findNavController().popBackStack() + } + } + } + + +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt new file mode 100644 index 00000000..157a7ac2 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt @@ -0,0 +1,80 @@ +package com.lagradost.cloudstream3.ui.setup + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AbsListView +import android.widget.ArrayAdapter +import androidx.core.util.forEach +import androidx.fragment.app.Fragment +import androidx.navigation.fragment.findNavController +import androidx.preference.PreferenceManager +import com.lagradost.cloudstream3.APIHolder +import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings +import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.utils.SubtitleHelper +import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar +import kotlinx.android.synthetic.main.fragment_setup_media.* + +class SetupFragmentProviderLanguage : Fragment() { + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_setup_provider_languages, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + context?.fixPaddingStatusbar(setup_root) + + with(context) { + if (this == null) return + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + + val arrayAdapter = + ArrayAdapter(this, R.layout.sort_bottom_single_choice) + + val current = this.getApiProviderLangSettings() + val langs = APIHolder.apis.map { it.lang }.toSet() + .sortedBy { SubtitleHelper.fromTwoLettersToLanguage(it) } + + val currentList = current.map { langs.indexOf(it) } + val languageNames = langs.map { + val emoji = SubtitleHelper.getFlagFromIso(it) + val name = SubtitleHelper.fromTwoLettersToLanguage(it) + "$emoji $name" + } + arrayAdapter.addAll(languageNames) + + listview1?.adapter = arrayAdapter + listview1?.choiceMode = AbsListView.CHOICE_MODE_MULTIPLE + currentList.forEach { + listview1.setItemChecked(it, true) + } + + listview1?.setOnItemClickListener { _, _, _, _ -> + val currentLanguages = mutableListOf() + listview1?.checkedItemPositions?.forEach { key, value -> + if (value) currentLanguages.add(langs[key]) + } + settingsManager.edit().putStringSet( + this.getString(R.string.provider_lang_key), + currentLanguages.toSet() + ).apply() + } + + next_btt?.setOnClickListener { + findNavController().navigate(R.id.navigation_setup_provider_languages_to_navigation_setup_media) + } + + prev_btt?.setOnClickListener { + findNavController().popBackStack() + } + } + } + + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_baseline_construction_24.xml b/app/src/main/res/drawable/ic_baseline_construction_24.xml new file mode 100644 index 00000000..5a2a7a54 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_construction_24.xml @@ -0,0 +1,6 @@ + + + + diff --git a/app/src/main/res/layout/fragment_setup_language.xml b/app/src/main/res/layout/fragment_setup_language.xml new file mode 100644 index 00000000..93afe823 --- /dev/null +++ b/app/src/main/res/layout/fragment_setup_language.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_setup_layout.xml b/app/src/main/res/layout/fragment_setup_layout.xml new file mode 100644 index 00000000..e14170e3 --- /dev/null +++ b/app/src/main/res/layout/fragment_setup_layout.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_setup_media.xml b/app/src/main/res/layout/fragment_setup_media.xml new file mode 100644 index 00000000..154db338 --- /dev/null +++ b/app/src/main/res/layout/fragment_setup_media.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_setup_provider_languages.xml b/app/src/main/res/layout/fragment_setup_provider_languages.xml new file mode 100644 index 00000000..8dc88917 --- /dev/null +++ b/app/src/main/res/layout/fragment_setup_provider_languages.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml index 606ff34d..b3e64c1b 100644 --- a/app/src/main/res/navigation/mobile_navigation.xml +++ b/app/src/main/res/navigation/mobile_navigation.xml @@ -1,396 +1,460 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/mobile_navigation" + app:startDestination="@+id/navigation_home"> + android:id="@+id/global_to_navigation_results" + app:destination="@id/navigation_results" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim"> + android:name="url" + app:argType="string" /> + android:name="apiName" + app:argType="string" /> + android:name="startAction" + android:defaultValue="0" + app:argType="integer" /> + android:name="startValue" + android:defaultValue="0" + app:argType="integer" /> + android:name="restart" + android:defaultValue="false" + app:argType="boolean" /> + android:id="@+id/global_to_navigation_player" + app:destination="@id/navigation_player" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim"> + android:name="data" + android:defaultValue="@null" + app:argType="string" /> + android:name="uriData" + android:defaultValue="@null" + app:argType="string" /> + android:name="resumePosition" + android:defaultValue="0L" + app:argType="long" /> + android:id="@+id/global_to_navigation_home" + app:destination="@id/navigation_home" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + + + + + + + + + - - - - + - - - - - - + app:popExitAnim="@anim/exit_anim" /> + android:id="@+id/navigation_settings_ui" + android:name="com.lagradost.cloudstream3.ui.settings.SettingsUI" + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:id="@+id/navigation_settings_general" + android:name="com.lagradost.cloudstream3.ui.settings.SettingsGeneral" + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:id="@+id/navigation_settings_lang" + android:name="com.lagradost.cloudstream3.ui.settings.SettingsLang" + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:id="@+id/navigation_settings_updates" + android:name="com.lagradost.cloudstream3.ui.settings.SettingsUpdates" + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + android:id="@+id/navigation_settings_account" + android:name="com.lagradost.cloudstream3.ui.settings.SettingsAccount" + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" /> + + + + + + + - - - - - - - + app:popExitAnim="@anim/exit_anim" /> + - + app:popExitAnim="@anim/exit_anim" /> + + - - + android:name="name" + app:argType="string" /> + android:name="folder" + app:argType="string" /> - - - - - - - - - - - - - - - - - - - - + android:id="@+id/navigation_settings" + android:name="com.lagradost.cloudstream3.ui.settings.SettingsFragment" + android:layout_height="match_parent" + android:label="@string/title_settings" + app:enterAnim="@anim/enter_anim" + app:exitAnim="@anim/exit_anim" + app:popEnterAnim="@anim/enter_anim" + app:popExitAnim="@anim/exit_anim" + tools:layout="@layout/main_settings"> - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c55d6836..7172b7b4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -52,19 +52,20 @@ poster_ui_key subtitles_encoding_key override_site_key + redo_setup_key - %d %s | %sMB - %s • %sGB - %sMB / %sMB - %dMB - %s %s - +%d - -%d - %d - %d - %.1f/10.0 - %d + %d %s | %sMB + %s • %sGB + %sMB / %sMB + %dMB + %s %s + +%d + -%d + %d + %d + %.1f/10.0 + %d %s Ep %d Cast: %s Episode %d will be released in @@ -558,4 +559,14 @@ Trailer Link to stream Referer + Next + Watch videos in these languages + Previous + Skip setup + + Hello blank fragment + Change the look of the app to suit your device + Crash reporting + What do you want to see + Done diff --git a/app/src/main/res/xml/settings_updates.xml b/app/src/main/res/xml/settings_updates.xml index db453c0c..d62605ac 100644 --- a/app/src/main/res/xml/settings_updates.xml +++ b/app/src/main/res/xml/settings_updates.xml @@ -1,49 +1,53 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:title="@string/check_for_update" + app:icon="@drawable/ic_baseline_system_update_24" + app:key="@string/manual_check_update_key" + app:summary="@string/app_version" /> + android:icon="@drawable/baseline_save_as_24" + android:key="@string/backup_key" + android:title="@string/backup_settings" /> + android:icon="@drawable/baseline_restore_page_24" + android:key="@string/restore_key" + android:title="@string/restore_settings" /> + android:icon="@drawable/baseline_description_24" + android:key="@string/show_logcat_key" + android:title="@string/show_log_cat" /> + android:defaultValue="false" + android:icon="@drawable/ic_baseline_bug_report_24" + android:key="acra.disable" + android:summaryOff="@string/bug_report_settings_off" + android:summaryOn="@string/bug_report_settings_on" + android:title="@string/pref_disable_acra" /> + android:icon="@drawable/ic_baseline_notifications_active_24" + android:summary="@string/updates_settings_des" + android:title="@string/updates_settings" + app:defaultValue="true" + app:key="@string/auto_update_key" /> + android:icon="@drawable/ic_baseline_developer_mode_24" + android:summary="@string/uprereleases_settings_des" + android:title="@string/uprereleases_settings" + app:defaultValue="false" + app:key="@string/prerelease_update_key" /> + android:defaultValue="true" + android:icon="@drawable/netflix_download" + android:key="@string/killswitch_key" + android:summary="@string/killswitch_settings_des" + android:title="@string/killswitch_settings" /> + \ No newline at end of file