From 0ec5d166df3295c3c465cf653095ac3b8cc46268 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Fri, 6 Aug 2021 22:55:11 +0200 Subject: [PATCH] subs settings not working :( --- app/build.gradle | 3 + .../lagradost/cloudstream3/MainActivity.kt | 20 +- .../cloudstream3/ui/player/PlayerFragment.kt | 84 ++---- .../cloudstream3/ui/result/ResultFragment.kt | 4 +- .../cloudstream3/ui/search/SearchFragment.kt | 6 +- .../ui/subtitles/SubtitlesFragment.kt | 263 ++++++++++++++++++ .../utils/SingleSelectionHelper.kt | 98 +++++++ .../subtitles_background_gradient.xml | 7 + app/src/main/res/layout/activity_main.xml | 2 +- .../res/layout/bottom_selection_dialog.xml | 58 ++++ app/src/main/res/layout/fragment_home.xml | 61 +--- app/src/main/res/layout/fragment_result.xml | 28 +- .../layout/player_select_source_and_subs.xml | 84 +++--- app/src/main/res/layout/subtitle_settings.xml | 92 ++++++ app/src/main/res/values/strings.xml | 8 + app/src/main/res/values/styles.xml | 47 +++- 16 files changed, 665 insertions(+), 200 deletions(-) create mode 100644 app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt create mode 100644 app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt create mode 100644 app/src/main/res/drawable/subtitles_background_gradient.xml create mode 100644 app/src/main/res/layout/bottom_selection_dialog.xml create mode 100644 app/src/main/res/layout/subtitle_settings.xml diff --git a/app/build.gradle b/app/build.gradle index 97638d39..b8551e64 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -91,4 +91,7 @@ dependencies { annotationProcessor "com.google.auto.service:auto-service:1.0" //or for kotlin sources (requires kapt gradle plugin): kapt "com.google.auto.service:auto-service:1.0" + + // subtitle color picker + implementation 'com.jaredrummler:colorpicker:1.1.0' } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index 6b85eddf..e41aee49 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -13,6 +13,7 @@ import androidx.navigation.NavOptions import androidx.navigation.findNavController import androidx.navigation.fragment.NavHostFragment import com.google.android.gms.cast.framework.CastButtonFactory +import com.jaredrummler.android.colorpicker.ColorPickerDialogListener import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.utils.UIHelper.checkWrite import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor @@ -46,21 +47,23 @@ const val VLC_EXTRA_POSITION_OUT = "extra_position" const val VLC_EXTRA_DURATION_OUT = "extra_duration" const val VLC_LAST_ID_KEY = "vlc_last_open_id" -class MainActivity : AppCompatActivity() { - /*, ViewModelStoreOwner { - private val appViewModelStore: ViewModelStore by lazy { - ViewModelStore() - } +class MainActivity : AppCompatActivity(), ColorPickerDialogListener { + override fun onColorSelected(dialogId: Int, color: Int) { + onColorSelectedEvent.invoke(Pair(dialogId, color)) + } + + override fun onDialogDismissed(dialogId: Int) { + onDialogDismissedEvent.invoke(dialogId) + } - override fun getViewModelStore(): ViewModelStore { - return appViewModelStore - }*/ companion object { var canEnterPipMode: Boolean = false var canShowPipMode: Boolean = false var isInPIPMode: Boolean = false val backEvent = Event() + val onColorSelectedEvent = Event>() + val onDialogDismissedEvent = Event() lateinit var navOptions: NavOptions } @@ -288,4 +291,5 @@ class MainActivity : AppCompatActivity() { }*/ handleAppIntent(intent) } + } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index 54ed49e8..c7b12316 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -65,6 +65,10 @@ import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.mvvm.observeDirectly import com.lagradost.cloudstream3.ui.result.ResultEpisode import com.lagradost.cloudstream3.ui.result.ResultViewModel +import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle +import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment +import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.fromSaveToStyle +import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getCurrentSavedStyle import com.lagradost.cloudstream3.utils.AppUtils.getFocusRequest import com.lagradost.cloudstream3.utils.AppUtils.getVideoContentUri import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable @@ -75,6 +79,7 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog import com.lagradost.cloudstream3.utils.UIHelper.getNavigationBarHeight import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard @@ -145,6 +150,9 @@ data class UriData( // YE, I KNOW, THIS COULD BE HANDLED A LOT BETTER class PlayerFragment : Fragment() { + private lateinit var subStyle: SaveCaptionStyle + private var subView: SubtitleView? = null + private var isCurrentlyPlaying: Boolean = false private val mapper = JsonMapper.builder().addModule(KotlinModule()) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build() @@ -788,18 +796,19 @@ class PlayerFragment : Fragment() { } //endregion + private fun onSubStyleChanged(style : SaveCaptionStyle) { + subView?.setStyle(fromSaveToStyle(subStyle)) + subView?.translationY = -subStyle.elevation.toPx.toFloat() + } + @SuppressLint("SetTextI18n") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val subs = player_view.findViewById(R.id.exo_subtitles) - subs.setStyle( - CaptionStyleCompat( - Color.WHITE, Color.TRANSPARENT, Color.TRANSPARENT, CaptionStyleCompat.EDGE_TYPE_OUTLINE, Color.BLACK, - Typeface.SANS_SERIF - ) - ) - subs.translationY = -10.toPx.toFloat() + subView = player_view.findViewById(R.id.exo_subtitles) + subStyle = context?.getCurrentSavedStyle()!! + onSubStyleChanged(subStyle) + SubtitlesFragment.applyStyleEvent += ::onSubStyleChanged settingsManager = PreferenceManager.getDefaultSharedPreferences(activity) swipeEnabled = settingsManager.getBoolean("swipe_enabled", true) @@ -1115,64 +1124,19 @@ class PlayerFragment : Fragment() { playback_speed_btt.visibility = if (playBackSpeedEnabled) VISIBLE else GONE playback_speed_btt.setOnClickListener { - lateinit var dialog: AlertDialog - // Lmao kind bad val speedsText = listOf("0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x") val speedsNumbers = listOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 1.75f, 2f) - val builder = - AlertDialog.Builder(requireContext(), R.style.AlertDialogCustom).setView(R.layout.player_select_speed) - - val speedDialog = builder.create() - speedDialog.show() - - val speedList = speedDialog.findViewById(R.id.sort_speed)!! - // val applyButton = speedDialog.findViewById(R.id.pick_source_apply)!! - // val cancelButton = speedDialog.findViewById(R.id.pick_source_cancel)!! - - val arrayAdapter = ArrayAdapter(view.context, R.layout.sort_bottom_single_choice) - arrayAdapter.addAll(speedsText) - - speedList.adapter = arrayAdapter - speedList.choiceMode = AbsListView.CHOICE_MODE_SINGLE - val speedIndex = speedsNumbers.indexOf(playbackSpeed) - speedList.setSelection(speedIndex) - speedList.setItemChecked(speedIndex, true) - - speedList.setOnItemClickListener { _, _, which, _ -> - playbackSpeed = speedsNumbers[which] + context?.showDialog(speedsText,speedIndex,"Player Speed", false) { index -> + playbackSpeed = speedsNumbers[index] requireContext().setKey(PLAYBACK_SPEED_KEY, playbackSpeed) val param = PlaybackParameters(playbackSpeed) exoPlayer.playbackParameters = param player_speed_text.text = "Speed (${playbackSpeed}x)".replace(".0x", "x") - speedDialog.dismiss() activity?.hideSystemUI() } - - /* - builder.setTitle("Pick playback speed") - builder.setOnDismissListener { - activity?.hideSystemUI() - } - builder.setSingleChoiceItems(speedsText, speedsNumbers.indexOf(playbackSpeed)) { _, which -> - - //val speed = speedsText[which] - //Toast.makeText(requireContext(), "$speed selected.", Toast.LENGTH_SHORT).show() - - playbackSpeed = speedsNumbers[which] - requireContext().setKey(PLAYBACK_SPEED_KEY, playbackSpeed) - val param = PlaybackParameters(playbackSpeed) - exoPlayer.playbackParameters = param - player_speed_text.text = "Speed (${playbackSpeed}x)".replace(".0x", "x") - - dialog.dismiss() - activity?.hideSystemUI() - } - - dialog = builder.create() - dialog.show()*/ } sources_btt.setOnClickListener { @@ -1191,8 +1155,13 @@ class PlayerFragment : Fragment() { // bottomSheetDialog.setContentView(R.layout.sort_bottom_sheet) val providerList = sourceDialog.findViewById(R.id.sort_providers)!! val subtitleList = sourceDialog.findViewById(R.id.sort_subtitles)!! - val applyButton = sourceDialog.findViewById(R.id.pick_source_apply)!! - val cancelButton = sourceDialog.findViewById(R.id.pick_source_cancel)!! + val applyButton = sourceDialog.findViewById(R.id.apply_btt)!! + val cancelButton = sourceDialog.findViewById(R.id.cancel_btt)!! + val subsSettings = sourceDialog.findViewById(R.id.subs_settings)!! + + subsSettings.setOnClickListener { + SubtitlesFragment.push(activity) + } val startSource = sources.indexOf(getCurrentUrl()) var sourceIndex = startSource @@ -1450,6 +1419,7 @@ class PlayerFragment : Fragment() { override fun onDestroy() { savePos() + SubtitlesFragment.applyStyleEvent -= ::onSubStyleChanged super.onDestroy() canEnterPipMode = false diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index 707df029..10b41b1a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -330,9 +330,7 @@ class ResultFragment : Fragment() { return true } - val skipLoading = if (apiName != null) { - getApiFromName(apiName).instantLinkLoading - } else false + val skipLoading = getApiFromName(apiName).instantLinkLoading var loadingDialog: AlertDialog? = null val currentLoad = currentLoadingCount diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt index f8c20b84..656c2bcb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt @@ -23,6 +23,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.observe +import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import kotlinx.android.synthetic.main.fragment_search.* @@ -171,8 +172,8 @@ class SearchFragment : Fragment() { }, 200) } } - main_search.onActionViewExpanded() - + // main_search.onActionViewExpanded() + SubtitlesFragment.push(activity) //searchViewModel.search("iron man") //(activity as AppCompatActivity).loadResult("https://shiro.is/overlord-dubbed", "overlord-dubbed", "Shiro") /* @@ -184,4 +185,5 @@ class SearchFragment : Fragment() { .add(R.id.homeRoot, PlayerFragment.newInstance(PlayerData(0, null,0))) .commit()*/ } + } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt new file mode 100644 index 00000000..ce684344 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt @@ -0,0 +1,263 @@ +package com.lagradost.cloudstream3.ui.subtitles + +import android.app.Activity +import android.content.Context +import android.content.res.Resources +import android.graphics.Color +import android.graphics.Typeface +import android.os.Bundle +import android.util.DisplayMetrics +import android.util.TypedValue +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import android.widget.Toast +import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity +import com.google.android.exoplayer2.text.Cue +import com.google.android.exoplayer2.ui.CaptionStyleCompat +import com.jaredrummler.android.colorpicker.ColorPickerDialog +import com.lagradost.cloudstream3.MainActivity +import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.utils.DataStore.getKey +import com.lagradost.cloudstream3.utils.DataStore.setKey +import com.lagradost.cloudstream3.utils.Event +import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog +import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar +import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage +import kotlinx.android.synthetic.main.subtitle_settings.* + +const val SUBTITLE_KEY = "subtitle_settings" + +data class SaveCaptionStyle( + var foregroundColor: Int, + var backgroundColor: Int, + var windowColor: Int, + @CaptionStyleCompat.EdgeType + var edgeType: Int, + var edgeColor: Int, + var typeface: String?, + /**in dp**/ + var elevation: Int, +) + +class SubtitlesFragment : Fragment() { + companion object { + val applyStyleEvent = Event() + + fun fromSaveToStyle(data: SaveCaptionStyle): CaptionStyleCompat { + return CaptionStyleCompat( + data.foregroundColor, data.backgroundColor, data.windowColor, data.edgeType, data.edgeColor, + Typeface.SANS_SERIF + ) + } + + fun push(activity: Activity?) { + (activity as FragmentActivity?)?.supportFragmentManager?.beginTransaction() + ?.setCustomAnimations( + R.anim.enter_anim, + R.anim.exit_anim, + R.anim.pop_enter, + R.anim.pop_exit + ) + ?.add( + R.id.homeRoot, + SubtitlesFragment() + ) + ?.commit() + } + + private fun getDefColor(id: Int): Int { + return when (id) { + 0 -> Color.WHITE + 1 -> Color.BLACK + 2 -> Color.TRANSPARENT + 3 -> Color.TRANSPARENT + else -> Color.TRANSPARENT + } + } + + fun Context.saveStyle(style: SaveCaptionStyle) { + this.setKey(SUBTITLE_KEY, style) + } + + fun Context.getCurrentSavedStyle(): SaveCaptionStyle { + return this.getKey(SUBTITLE_KEY) ?: SaveCaptionStyle( + getDefColor(0), + getDefColor(2), + getDefColor(3), + CaptionStyleCompat.EDGE_TYPE_OUTLINE, + getDefColor(1), + null, + 0, + ) + } + + private fun Context.getCurrentStyle(): CaptionStyleCompat { + return fromSaveToStyle(getCurrentSavedStyle()) + } + + private fun getPixels(unit: Int, size: Float): Int { + val metrics: DisplayMetrics = Resources.getSystem().displayMetrics + return TypedValue.applyDimension(unit, size, metrics).toInt() + } + } + + private fun onColorSelected(stuff: Pair) { + setColor(stuff.first, stuff.second) + } + + private fun setColor(id: Int, color: Int?) { + val realColor = color ?: getDefColor(id) + when (id) { + 0 -> state.foregroundColor = realColor + 1 -> state.edgeColor = realColor + 2 -> state.backgroundColor = realColor + 3 -> state.windowColor = realColor + + else -> { + } + } + updateState() + } + + fun updateState() { + subtitle_text?.setStyle(fromSaveToStyle(state)) + } + + private fun getColor(id: Int): Int { + val color = when (id) { + 0 -> state.foregroundColor + 1 -> state.edgeColor + 2 -> state.backgroundColor + 3 -> state.windowColor + + else -> Color.TRANSPARENT + } + + return if (color == Color.TRANSPARENT) Color.BLACK else color + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle?, + ): View? { + return inflater.inflate(R.layout.subtitle_settings, container, false) + } + + lateinit var state: SaveCaptionStyle + + override fun onDestroy() { + super.onDestroy() + MainActivity.onColorSelectedEvent -= ::onColorSelected + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + MainActivity.onColorSelectedEvent += ::onColorSelected + + context?.fixPaddingStatusbar(subs_root) + + state = requireContext().getCurrentSavedStyle() + updateState() + + fun View.setup(id: Int) { + this.setOnClickListener { + activity?.let { + ColorPickerDialog.newBuilder() + .setDialogId(id) + .setColor(getColor(id)) + .show(it) + } + } + + this.setOnLongClickListener { + setColor(id, null) + Toast.makeText(it.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show() + return@setOnLongClickListener true + } + } + + subs_text_color.setup(0) + subs_outline_color.setup(1) + subs_background_color.setup(2) + subs_window_color.setup(3) + + subs_subtitle_elevation.setOnClickListener { textView -> + val elevationTypes = listOf( + Pair(0, "None"), + Pair(10, "10"), + Pair(20, "20"), + Pair(30, "30"), + Pair(40, "40"), + ) + + textView.context.showBottomDialog( + elevationTypes.map { it.second }, + elevationTypes.map { it.first }.indexOf(state.elevation), + (textView as TextView).text.toString(), + false + ) { index -> + state.elevation = elevationTypes.map { it.first }[index] + updateState() + } + } + + subs_subtitle_elevation.setOnLongClickListener { + state.elevation = 0 + updateState() + Toast.makeText(it.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show() + return@setOnLongClickListener true + } + + subs_edge_type.setOnClickListener { textView -> + val edgeTypes = listOf( + Pair(CaptionStyleCompat.EDGE_TYPE_NONE, "None"), + Pair(CaptionStyleCompat.EDGE_TYPE_OUTLINE, "Outline"), + Pair(CaptionStyleCompat.EDGE_TYPE_DEPRESSED, "Depressed"), + Pair(CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW, "Shadow"), + Pair(CaptionStyleCompat.EDGE_TYPE_RAISED, "Raised"), + ) + + textView.context.showBottomDialog( + edgeTypes.map { it.second }, + edgeTypes.map { it.first }.indexOf(state.edgeType), + (textView as TextView).text.toString(), + false + ) { index -> + state.edgeType = edgeTypes.map { it.first }[index] + updateState() + } + } + + subs_edge_type.setOnLongClickListener { + state.edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE + updateState() + Toast.makeText(it.context, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT).show() + return@setOnLongClickListener true + } + + cancel_btt.setOnClickListener { + activity?.popCurrentPage() + } + + apply_btt.setOnClickListener { + applyStyleEvent.invoke(state) + fromSaveToStyle(state) + activity?.popCurrentPage() + } + + subtitle_text.setCues( + listOf( + Cue.Builder() + .setTextSize( + getPixels(TypedValue.COMPLEX_UNIT_SP, 25.0f).toFloat(), + Cue.TEXT_SIZE_TYPE_ABSOLUTE + ) + .setText("The quick brown fox jumps over the lazy dog").build() + ) + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt new file mode 100644 index 00000000..2e7b0ddc --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/SingleSelectionHelper.kt @@ -0,0 +1,98 @@ +package com.lagradost.cloudstream3.utils + +import android.app.Dialog +import android.content.Context +import android.view.View +import android.widget.* +import androidx.appcompat.app.AlertDialog +import androidx.core.view.marginLeft +import androidx.core.view.marginRight +import androidx.core.view.marginTop +import com.google.android.material.bottomsheet.BottomSheetDialog +import com.lagradost.cloudstream3.R + +object SingleSelectionHelper { + fun Context.showDialog( + dialog: Dialog, + items: List, + selectedIndex: Int, + name: String, + showApply: Boolean, + callback: (Int) -> Unit + ) { + val listView = dialog.findViewById(R.id.listview1)!! + val textView = dialog.findViewById(R.id.text1)!! + val applyButton = dialog.findViewById(R.id.apply_btt)!! + val cancelButton = dialog.findViewById(R.id.cancel_btt)!! + val applyHolder = dialog.findViewById(R.id.apply_btt_holder)!! + + applyHolder.visibility = if (showApply) View.VISIBLE else View.GONE + if (!showApply) { + val params = listView.layoutParams as LinearLayout.LayoutParams + params.setMargins(listView.marginLeft, listView.marginTop, listView.marginRight, 0) + listView.layoutParams = params + } + + textView.text = name + + val arrayAdapter = ArrayAdapter(this, R.layout.sort_bottom_single_choice) + arrayAdapter.addAll(items) + + listView.adapter = arrayAdapter + listView.choiceMode = AbsListView.CHOICE_MODE_SINGLE + + listView.setSelection(selectedIndex) + listView.setItemChecked(selectedIndex, true) + + var currentIndex = selectedIndex + + listView.setOnItemClickListener { _, _, which, _ -> + if (showApply) { + currentIndex = which + listView.setItemChecked(which, true) + } else { + callback.invoke(which) + dialog.dismiss() + } + } + if (showApply) { + applyButton.setOnClickListener { + callback.invoke(currentIndex) + dialog.dismiss() + } + cancelButton.setOnClickListener { + dialog.dismiss() + } + } + } + + fun Context.showDialog( + items: List, + selectedIndex: Int, + name: String, + showApply: Boolean, + callback: (Int) -> Unit + ) { + val builder = + AlertDialog.Builder(this, R.style.AlertDialogCustom).setView(R.layout.bottom_selection_dialog) + + val dialog = builder.create() + dialog.show() + showDialog(dialog, items, selectedIndex, name, showApply, callback) + } + + fun Context.showBottomDialog( + items: List, + selectedIndex: Int, + name: String, + showApply: Boolean, + callback: (Int) -> Unit + ) { + val builder = + BottomSheetDialog(this) + builder.setContentView(R.layout.bottom_selection_dialog) + + builder.show() + showDialog(builder, items, selectedIndex, name, showApply, callback) + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/subtitles_background_gradient.xml b/app/src/main/res/drawable/subtitles_background_gradient.xml new file mode 100644 index 00000000..76aa548e --- /dev/null +++ b/app/src/main/res/drawable/subtitles_background_gradient.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 587a524b..26ac8daa 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -15,7 +15,7 @@ android:id="@+id/nav_view" android:layout_width="0dp" android:layout_height="wrap_content" - android:background="@color/darkBackground" + android:background="?attr/darkBackground" app:itemRippleColor="@color/colorRipple" app:labelVisibilityMode="labeled" diff --git a/app/src/main/res/layout/bottom_selection_dialog.xml b/app/src/main/res/layout/bottom_selection_dialog.xml new file mode 100644 index 00000000..38327e7d --- /dev/null +++ b/app/src/main/res/layout/bottom_selection_dialog.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index ed2cdbe9..3651b2c1 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -26,49 +26,22 @@ android:layout_height="wrap_content"> @@ -147,48 +120,26 @@ android:contentDescription="@string/home_next_random"> + android:layout_width="120dp"> + android:layout_width="120dp"> + android:layout_width="match_parent"> + android:layout_width="match_parent"> - - + + + + + + + - + /> - + /> diff --git a/app/src/main/res/layout/subtitle_settings.xml b/app/src/main/res/layout/subtitle_settings.xml new file mode 100644 index 00000000..8dd8f798 --- /dev/null +++ b/app/src/main/res/layout/subtitle_settings.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + \ 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 70358787..04e81c00 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -70,4 +70,12 @@ Apply Cancel Player Speed + Subtitle Settings + Text Color + Outline Color + Background Color + Window Color + Edge Type + Subtitle Elevation + Reset to default value \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c23bbad9..6b657821 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,7 +5,7 @@ @color/colorPrimary @color/colorPrimaryDark @color/colorAccent - + @color/darkBackground @color/grayBackground @@ -132,6 +132,48 @@ ?attr/bitDarkerGrayBackground + + + + + + + +