Skip to content
Snippets Groups Projects
Commit b12917ec authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

Add a PIN lock item to the TV main screen

Fixes #2966
parent 14935027
No related branches found
No related tags found
1 merge request!1753Parental control
......@@ -154,6 +154,7 @@ const val ID_REFRESH = 13L
const val ID_ALL_MOVIES = 14L
const val ID_ALL_TVSHOWS = 15L
const val ID_SPONSOR = 16L
const val ID_PIN_LOCK = 17L
const val CATEGORY_NOW_PLAYING = 20L
const val CATEGORY_ARTISTS = 21L
const val CATEGORY_ALBUMS = 22L
......
<!--
~ *************************************************************************
~ pin_lock.xml
~ **************************************************************************
~ Copyright © 2023 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="90dp"
android:height="90dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/white"
android:pathData="M12,2L4,5v6.09c0,5.05 3.41,9.76 8,10.91c4.59,-1.15 8,-5.86 8,-10.91V5L12,2zM18,11.09c0,4 -2.55,7.7 -6,8.83c-3.45,-1.13 -6,-4.82 -6,-8.83V6.31l6,-2.12l6,2.12V11.09zM8.82,10.59L7.4,12l3.54,3.54l5.66,-5.66l-1.41,-1.41l-4.24,4.24L8.82,10.59z" />
</vector>
......@@ -978,6 +978,7 @@
<string name="restricted_access">Access restricted</string>
<string name="unlock">Unlock</string>
<string name="lock_with_pin">Re-enable PIN lock</string>
<string name="lock_with_pin_short">PIN lock</string>
<string name="restrict_settings">Restrict settings access</string>
<string name="search_prefs">Search settings</string>
<string name="video_match_frame_rate_title">Match Display Frame Rate</string>
......
......@@ -22,6 +22,8 @@
package org.videolan.television.ui
//import org.videolan.vlc.donations.BillingStatus
//import org.videolan.vlc.donations.VLCBilling
import android.content.Intent
import android.os.Bundle
import android.view.View
......@@ -45,9 +47,8 @@ import org.videolan.television.viewmodel.MainTvModel.Companion.getMainTvModel
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.RecommendationsService
//import org.videolan.vlc.donations.BillingStatus
//import org.videolan.vlc.donations.VLCBilling
import org.videolan.vlc.gui.helpers.UiTools.showDonations
import org.videolan.vlc.gui.helpers.hf.PinCodeDelegate
import org.videolan.vlc.gui.video.VideoPlayerActivity
import org.videolan.vlc.reloadLibrary
import org.videolan.vlc.util.Permissions
......@@ -156,6 +157,8 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
otherAdapter = ArrayObjectAdapter(GenericCardPresenter(ctx))
val miscHeader = HeaderItem(HEADER_MISC, getString(R.string.other))
val lockItem = GenericCardItem(ID_PIN_LOCK, getString(R.string.lock_with_pin_short), "", R.drawable.ic_menu_pin_lock_big, R.color.tv_card_content_dark)
if (PinCodeDelegate.pinUnlocked.value == true) otherAdapter.add(lockItem)
otherAdapter.add(GenericCardItem(ID_SETTINGS, getString(R.string.preferences), "", R.drawable.ic_menu_preferences_big, R.color.tv_card_content_dark))
if (Permissions.canReadStorage(requireActivity())) otherAdapter.add(GenericCardItem(ID_REFRESH, getString(R.string.refresh), "", R.drawable.ic_menu_tv_scan, R.color.tv_card_content_dark))
otherAdapter.add(GenericCardItem(ID_ABOUT_TV, getString(R.string.about), "${getString(R.string.app_name_full)} ${BuildConfig.VLC_VERSION_NAME}", R.drawable.ic_menu_info_big, R.color.tv_card_content_dark))
......@@ -163,6 +166,18 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
// VLCBilling.getInstance(requireActivity().application).addStatusListener {
// manageDonationVisibility(donateCard)
// }
PinCodeDelegate.pinUnlocked.observe(requireActivity()) {
if (it) {
if ((otherAdapter.get(0) as GenericCardItem).id != ID_PIN_LOCK) {
otherAdapter.add(0, lockItem)
}
} else {
if ((otherAdapter.get(0) as GenericCardItem).id == ID_PIN_LOCK) {
otherAdapter.removeItems(0, 1)
}
}
}
manageDonationVisibility(donateCard)
miscRow = ListRow(miscHeader, otherAdapter)
rowsAdapter.add(miscRow)
......@@ -311,6 +326,7 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
}
ID_ABOUT_TV -> activity.startActivity(Intent(activity, AboutActivity::class.java))
ID_SPONSOR -> activity.showDonations()
ID_PIN_LOCK -> PinCodeDelegate.pinUnlocked.postValue(false)
}
}
HEADER_NOW_PLAYING -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment