diff --git a/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/PlotView.kt b/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/PlotView.kt index 23821bfc5..263eb7783 100644 --- a/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/PlotView.kt +++ b/application/live-plot-graph/src/main/java/org/videolan/liveplotgraph/PlotView.kt @@ -101,7 +101,7 @@ class PlotView : FrameLayout { listeners.remove(listener) } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) maxsY.clear() diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt index 7601a93e3..a221f7789 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt @@ -230,7 +230,8 @@ class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnShared return super.onPreferenceTreeClick(preference) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { "network_caching" -> { sharedPreferences.edit { diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt index a41b2f746..6b1000c49 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt @@ -29,7 +29,6 @@ import android.os.Bundle import android.text.InputFilter import android.text.InputType import android.util.Log -import androidx.core.content.ContextCompat import androidx.core.content.edit import androidx.preference.CheckBoxPreference import androidx.preference.EditTextPreference @@ -133,7 +132,8 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { "aout" -> { launch { restartLibVLC() } diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesOptional.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesOptional.kt index af09539dd..c353f0d67 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesOptional.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesOptional.kt @@ -74,7 +74,8 @@ class PreferencesOptional : BasePreferenceFragment(), SharedPreferences.OnShared } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return val enabled = findPreference(key)!!.isChecked FeatureFlagManager.getByKey(key)?.let { FeatureFlagManager.enable(activity,it, enabled) } } diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesParentalControl.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesParentalControl.kt index f9f0e1bee..7aa075741 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesParentalControl.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesParentalControl.kt @@ -84,7 +84,8 @@ class PreferencesParentalControl : BasePreferenceFragment(), SharedPreferences.O } } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { KEY_SAFE_MODE -> { Settings.safeMode = sharedPreferences.getBoolean(key, false) && activity.isPinCodeSet() diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesSubtitles.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesSubtitles.kt index 81cd5dfb4..cb97ef6f7 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesSubtitles.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesSubtitles.kt @@ -220,7 +220,7 @@ class PreferencesSubtitles : BasePreferenceFragment(), SharedPreferences.OnShare preferenceScreen.sharedPreferences.registerOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { "subtitles_size", "subtitles_bold", "subtitle_text_encoding", "subtitles_color", "subtitles_color_opacity", diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt index 6ecef98fd..c18ca55de 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesUi.kt @@ -89,7 +89,8 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer .unregisterOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { PREF_TV_UI -> { Settings.tvUI = sharedPreferences.getBoolean(PREF_TV_UI, false) diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt index f3e116520..d07b86a05 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesVideo.kt @@ -66,7 +66,7 @@ class PreferencesVideo : BasePreferenceFragment(), SharedPreferences.OnSharedPre .unregisterOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { "preferred_resolution" -> { launch { diff --git a/application/television/src/main/java/org/videolan/television/ui/views/ColorPickerItem.kt b/application/television/src/main/java/org/videolan/television/ui/views/ColorPickerItem.kt index 53d04c5d9..3c5242fbc 100644 --- a/application/television/src/main/java/org/videolan/television/ui/views/ColorPickerItem.kt +++ b/application/television/src/main/java/org/videolan/television/ui/views/ColorPickerItem.kt @@ -94,10 +94,10 @@ class ColorPickerItem @JvmOverloads constructor( * * @param canvas the view's [Canvas] */ - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) - canvas?.drawCircle(width.toFloat() / 2, height.toFloat() / 2, (width.toFloat() / 2) - 4.dp, outerPaint) - canvas?.drawCircle(width.toFloat() / 2, height.toFloat() / 2, (width.toFloat() / 2) - 5.dp, paint) + canvas.drawCircle(width.toFloat() / 2, height.toFloat() / 2, (width.toFloat() / 2) - 4.dp, outerPaint) + canvas.drawCircle(width.toFloat() / 2, height.toFloat() / 2, (width.toFloat() / 2) - 5.dp, paint) } diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt index 23a0f8cbd..100a21a47 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt @@ -44,7 +44,19 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.videolan.medialibrary.interfaces.Medialibrary -import org.videolan.resources.* +import org.videolan.resources.AndroidDevices +import org.videolan.resources.KEY_AUDIO_LAST_PLAYLIST +import org.videolan.resources.KEY_CURRENT_AUDIO +import org.videolan.resources.KEY_CURRENT_AUDIO_RESUME_ARTIST +import org.videolan.resources.KEY_CURRENT_AUDIO_RESUME_THUMB +import org.videolan.resources.KEY_CURRENT_AUDIO_RESUME_TITLE +import org.videolan.resources.KEY_CURRENT_MEDIA +import org.videolan.resources.KEY_CURRENT_MEDIA_RESUME +import org.videolan.resources.KEY_MEDIA_LAST_PLAYLIST +import org.videolan.resources.KEY_MEDIA_LAST_PLAYLIST_RESUME +import org.videolan.resources.ROOM_DATABASE +import org.videolan.resources.SCHEME_PACKAGE +import org.videolan.resources.VLCInstance import org.videolan.tools.BitmapCache import org.videolan.tools.Settings import org.videolan.tools.putSingle @@ -235,7 +247,8 @@ class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnShared return super.onPreferenceTreeClick(preference) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { "network_caching" -> { sharedPreferences.edit { diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt index ac9274452..5abf1fa9d 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt @@ -32,7 +32,11 @@ import android.text.InputType import android.util.Log import androidx.core.content.edit import androidx.lifecycle.lifecycleScope -import androidx.preference.* +import androidx.preference.CheckBoxPreference +import androidx.preference.EditTextPreference +import androidx.preference.ListPreference +import androidx.preference.Preference +import androidx.preference.TwoStatePreference import kotlinx.coroutines.launch import org.videolan.libvlc.util.AndroidUtil import org.videolan.libvlc.util.HWDecoderUtil @@ -55,7 +59,7 @@ import org.videolan.vlc.providers.PickerType import org.videolan.vlc.util.LocaleUtil import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import java.util.* +import java.util.Locale private const val TAG = "VLC/PreferencesAudio" private const val FILE_PICKER_RESULT_CODE = 10000 @@ -151,8 +155,9 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre } } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { - if (activity == null) return + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null || activity == null) return + when (key) { "aout" -> { lifecycleScope.launch { restartLibVLC() } @@ -173,7 +178,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre Log.w(TAG, "Could not parse value: $newValue. Setting $key to $fmtValue", e) } finally { if (fmtValue != newValue) { - sharedPreferences.edit { + sharedPreferences?.edit { // putString will trigger another preference change event. Restart libVLC when it settles. putString(key, fmtValue) findPreference(key)?.let { it.text = fmtValue } diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudioControls.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudioControls.kt index 468e22e78..98bd6b0fb 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudioControls.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudioControls.kt @@ -46,7 +46,8 @@ class PreferencesAudioControls : BasePreferenceFragment(), SharedPreferences.OnS .unregisterOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return (activity as? VideoPlayerActivity)?.onChangedControlSetting(key) when (key) { KEY_AUDIO_JUMP_DELAY -> { diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt index fc55933e4..513dbb81a 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt @@ -185,8 +185,10 @@ class PreferencesFragment : BasePreferenceFragment(), SharedPreferences.OnShared return true } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { val activity = activity ?: return + if (sharedPreferences == null || key == null) return + when (key) { "video_action_switch" -> if (!AndroidUtil.isOOrLater && findPreference(key)?.value == "2" && !Permissions.canDrawOverlays(activity)) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesOptional.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesOptional.kt index 1b96fc5e0..f69b637ad 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesOptional.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesOptional.kt @@ -32,7 +32,6 @@ import androidx.preference.PreferenceScreen import org.videolan.vlc.R import org.videolan.vlc.gui.dialogs.FeatureFlagWarningDialog import org.videolan.vlc.gui.dialogs.RenameDialog -import org.videolan.vlc.gui.helpers.UiTools import org.videolan.vlc.util.FeatureFlag import org.videolan.vlc.util.FeatureFlagManager @@ -69,7 +68,8 @@ class PreferencesOptional : BasePreferenceFragment(), SharedPreferences.OnShared } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return val enabled = findPreference(key)!!.isChecked FeatureFlagManager.getByKey(key)?.let { FeatureFlagManager.enable(requireActivity(), it, enabled) } // if (enabled) UiTools.snacker(requireActivity(), getString(R.string.optional_features_warning)) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesParentalControl.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesParentalControl.kt index 733ab9607..894de79f1 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesParentalControl.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesParentalControl.kt @@ -74,7 +74,8 @@ class PreferencesParentalControl : BasePreferenceFragment(), SharedPreferences.O return super.onPreferenceTreeClick(preference) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { KEY_SAFE_MODE -> { Settings.safeMode = sharedPreferences.getBoolean(key, false) && requireActivity().isPinCodeSet() diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesSubtitles.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesSubtitles.kt index 10b7e261d..32d915335 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesSubtitles.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesSubtitles.kt @@ -168,7 +168,7 @@ class PreferencesSubtitles : BasePreferenceFragment(), SharedPreferences.OnShare preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { "subtitles_size", "subtitles_bold", "subtitle_text_encoding", "subtitles_color", "subtitles_color_opacity", diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt index b30dd452b..532e9fd54 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt @@ -130,7 +130,8 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer return super.onPreferenceTreeClick(preference) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { "set_locale" -> { (activity as PreferencesActivity).setRestart() diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt index 5f1a6eeec..7f8890d0f 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideo.kt @@ -56,7 +56,8 @@ class PreferencesVideo : BasePreferenceFragment(), SharedPreferences.OnSharedPre .unregisterOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { "preferred_resolution" -> { lifecycleScope.launch { diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt index 129e97a9b..da4a5a9ed 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesVideoControls.kt @@ -27,7 +27,21 @@ import android.os.Bundle import androidx.preference.Preference import org.videolan.libvlc.util.AndroidUtil import org.videolan.resources.AndroidDevices -import org.videolan.tools.* +import org.videolan.tools.AUDIO_BOOST +import org.videolan.tools.ENABLE_BRIGHTNESS_GESTURE +import org.videolan.tools.ENABLE_DOUBLE_TAP_PLAY +import org.videolan.tools.ENABLE_DOUBLE_TAP_SEEK +import org.videolan.tools.ENABLE_SCALE_GESTURE +import org.videolan.tools.ENABLE_SWIPE_SEEK +import org.videolan.tools.ENABLE_VOLUME_GESTURE +import org.videolan.tools.KEY_VIDEO_DOUBLE_TAP_JUMP_DELAY +import org.videolan.tools.KEY_VIDEO_JUMP_DELAY +import org.videolan.tools.KEY_VIDEO_LONG_JUMP_DELAY +import org.videolan.tools.POPUP_KEEPSCREEN +import org.videolan.tools.SCREENSHOT_MODE +import org.videolan.tools.Settings +import org.videolan.tools.VIDEO_HUD_TIMEOUT +import org.videolan.tools.coerceInOrDefault import org.videolan.vlc.R import org.videolan.vlc.gui.video.VideoPlayerActivity @@ -72,7 +86,8 @@ class PreferencesVideoControls : BasePreferenceFragment(), SharedPreferences.OnS .unregisterOnSharedPreferenceChangeListener(this) } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return (activity as? VideoPlayerActivity)?.onChangedControlSetting(key) when (key) { VIDEO_HUD_TIMEOUT -> { diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/widgets/PreferencesWidgets.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/widgets/PreferencesWidgets.kt index eebd1c4bc..3d9fd5ac5 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/widgets/PreferencesWidgets.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/widgets/PreferencesWidgets.kt @@ -142,7 +142,8 @@ class PreferencesWidgets : BasePreferenceFragment(), SharedPreferences.OnSharedP } - override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { + override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { + if (sharedPreferences == null || key == null) return when (key) { "opacity" -> { model.widget.value?.opacity = sharedPreferences.getInt(key, 100) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt index f7d828a99..44be8dd6b 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/PopupManager.kt @@ -137,13 +137,14 @@ class PopupManager constructor(private val service: PlaybackService) : PlaybackS return false } - override fun onScroll(p0: MotionEvent, p1: MotionEvent, p2: Float, p3: Float): Boolean { + + override fun onScroll(p0: MotionEvent?, p1: MotionEvent, p2: Float, p3: Float): Boolean { return false } override fun onLongPress(e: MotionEvent) {} - override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { + override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean { if (abs(velocityX) > FLING_STOP_VELOCITY || velocityY > FLING_STOP_VELOCITY) { stopPlayback() return true diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/AutofitButton.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/AutofitButton.kt index 5a1842137..5624632d0 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/view/AutofitButton.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/view/AutofitButton.kt @@ -51,7 +51,7 @@ class AutofitButton : MaterialButton { super.onSizeChanged(w, h, oldw, oldh) } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { super.onDraw(canvas) computeTextSize() } diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/HalfCircleView.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/HalfCircleView.kt index 51180044e..4fb96f33c 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/view/HalfCircleView.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/view/HalfCircleView.kt @@ -6,8 +6,8 @@ import android.graphics.Paint import android.util.AttributeSet import android.view.View import androidx.core.content.ContextCompat -import org.videolan.vlc.R import org.videolan.tools.Settings +import org.videolan.vlc.R class HalfCircleView : View { private var isLeft: Boolean = true @@ -49,11 +49,11 @@ class HalfCircleView : View { } } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { if (!Settings.showTvUi) { val cx = if (isLeft) -width else width * 2 val cy = height / 2 - canvas?.drawCircle(cx.toFloat(), cy.toFloat(), width.toFloat()*2, paint) + canvas.drawCircle(cx.toFloat(), cy.toFloat(), width.toFloat()*2, paint) } super.onDraw(canvas) } diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/PlayerProgress.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/PlayerProgress.kt index 421c75415..e6fb2680b 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/view/PlayerProgress.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/view/PlayerProgress.kt @@ -25,7 +25,11 @@ package org.videolan.vlc.gui.view import android.content.Context -import android.graphics.* +import android.graphics.Canvas +import android.graphics.Paint +import android.graphics.Path +import android.graphics.RectF +import android.graphics.Region import android.util.AttributeSet import android.view.View import androidx.core.content.ContextCompat @@ -73,7 +77,7 @@ class PlayerProgress : View { paintProgress.isAntiAlias = true } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { val left = (width.toFloat() - progressWidth.toFloat()) / 2 val right = width - left val top = yOffset.toFloat() @@ -83,18 +87,18 @@ class PlayerProgress : View { //draw background roundedRectanglePath(left, top, right, bottom, radius, radius) paintBackground.setShadowLayer(6F,0F,0F, shadowColor) - canvas?.drawPath(path, paintBackground) + canvas.drawPath(path, paintBackground) paintBackground.clearShadowLayer() paintBackground.color = 0x00000000 - canvas?.drawPath(path, paintBackground) + canvas.drawPath(path, paintBackground) paintBackground.color = backgroundColor - canvas?.drawPath(path, paintBackground) + canvas.drawPath(path, paintBackground) //draw progress val clipTop = yOffset + (bottom - top) * (1 - progressPercent) rectProgress.set(left, clipTop, right, bottom) - canvas?.withClip(rectProgress) { + canvas.withClip(rectProgress) { clipRect(rectProgress) } @@ -112,7 +116,7 @@ class PlayerProgress : View { firstClippingRegion.op(secondClippingRegion, Region.Op.INTERSECT) paintProgress.color = progressColor - canvas?.drawPath(firstClippingRegion.boundaryPath, paintProgress) + canvas.drawPath(firstClippingRegion.boundaryPath, paintProgress) //draw boost if (isDouble && progressPercent > 0.5) { @@ -133,7 +137,7 @@ class PlayerProgress : View { firstClippingRegion.op(secondClippingRegion, Region.Op.INTERSECT) paintProgress.color = boostColor - canvas?.drawPath(firstClippingRegion.boundaryPath, paintProgress) + canvas.drawPath(firstClippingRegion.boundaryPath, paintProgress) } super.onDraw(canvas) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/WidgetHandleView.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/WidgetHandleView.kt index 9daf6d617..236a97d6b 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/view/WidgetHandleView.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/view/WidgetHandleView.kt @@ -59,7 +59,7 @@ class WidgetHandleView : View { paint.isAntiAlias = true } - override fun onDraw(canvas: Canvas?) { + override fun onDraw(canvas: Canvas) { val padding = 8.dp.toFloat() val viewWidth = width //3.56 is the known ratio of the [R.drawable.vlc_widget_mini] image. 6.dp is two times the stroke size @@ -68,12 +68,12 @@ class WidgetHandleView : View { val height = height - padding paint.strokeWidth = 3.dp.toFloat() paint.style = Paint.Style.STROKE - canvas?.drawRoundRect(hPadding, padding, viewWidth - hPadding, height, 12.dp.toFloat(), 12.dp.toFloat(), paint) + canvas.drawRoundRect(hPadding, padding, viewWidth - hPadding, height, 12.dp.toFloat(), 12.dp.toFloat(), paint) paint.style = Paint.Style.FILL - canvas?.drawCircle(hPadding, padding + (height / 2), 6.dp.toFloat(), paint) - canvas?.drawCircle(hPadding + (width.toFloat() / 2), padding, 6.dp.toFloat(), paint) - canvas?.drawCircle(hPadding + width.toFloat(), padding + (height / 2), 6.dp.toFloat(), paint) - canvas?.drawCircle(hPadding + (width.toFloat() / 2), height, 6.dp.toFloat(), paint) + canvas.drawCircle(hPadding, padding + (height / 2), 6.dp.toFloat(), paint) + canvas.drawCircle(hPadding + (width.toFloat() / 2), padding, 6.dp.toFloat(), paint) + canvas.drawCircle(hPadding + width.toFloat(), padding + (height / 2), 6.dp.toFloat(), paint) + canvas.drawCircle(hPadding + (width.toFloat() / 2), height, 6.dp.toFloat(), paint) super.onDraw(canvas) } } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2aa890912..25df4be2c 100644 --- a/build.gradle +++ b/build.gradle @@ -46,7 +46,7 @@ ext { medialibraryVersion = vlcMajorVersion == 3 ? '0.13.13-rc10' : '0.13.13-vlc4-rc10' minSdkVersion = 17 targetSdkVersion = 34 - compileSdkVersion = 33 + compileSdkVersion = 34 buildToolsVersion = '33.0.1' androidxLegacyVersion = '1.0.0' androidxCoreVersion = '1.7.0'