v1.0.7 - 카테고리 On/Off 설정, REQUEST_INSTALL_PACKAGES 권한

This commit is contained in:
tvmon-dev
2026-04-16 21:07:35 +09:00
parent 08406166a6
commit b02e3cb07a
7 changed files with 130 additions and 8 deletions

View File

@@ -13,8 +13,8 @@ android {
applicationId "com.example.tvmon"
minSdk 28
targetSdk 34
versionCode 7
versionName "1.0.6"
versionCode 8
versionName "1.0.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

View File

@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-feature
android:name="android.hardware.type.tv"

View File

@@ -13,6 +13,7 @@ import com.example.tvmon.data.model.Content
import com.example.tvmon.data.repository.CategoryCacheRepository
import com.example.tvmon.data.repository.WatchHistoryRepository
import com.example.tvmon.data.scraper.TvmonScraper
import com.example.tvmon.util.CategoryPreferences
import com.example.tvmon.ui.detail.DetailsActivity
import com.example.tvmon.ui.presenter.ContentCardPresenter
import com.example.tvmon.ui.settings.SettingsActivity
@@ -100,14 +101,19 @@ private fun setupUI() {
var successCount = 0
var failCount = 0
val context = requireContext()
val enabledCategories = CategoryPreferences.getEnabledCategories(context)
val deferredRows = coroutineScope {
TvmonScraper.CATEGORIES.values.map { category ->
Log.w(TAG, "Loading category: ${category.key} - ${category.name}")
async {
val row = loadCategoryRow(category)
category.key to row
TvmonScraper.CATEGORIES.values
.filter { enabledCategories.contains(it.key) }
.map { category ->
Log.w(TAG, "Loading category: ${category.key} - ${category.name}")
async {
val row = loadCategoryRow(category)
category.key to row
}
}
}
}
for (deferred in deferredRows) {

View File

@@ -4,12 +4,15 @@ import android.app.AlertDialog
import android.os.Bundle
import android.view.WindowManager
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Switch
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.example.tvmon.R
import com.example.tvmon.util.ApkDownloader
import com.example.tvmon.util.CategoryPreferences
import com.example.tvmon.util.UpdateChecker
import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject
@@ -28,9 +31,25 @@ class SettingsActivity : AppCompatActivity() {
private lateinit var btnClearCache: Button
private lateinit var btnCheckUpdate: Button
private lateinit var btnBack: Button
private lateinit var categoryTogglesContainer: LinearLayout
private var latestVersionInfo: com.example.tvmon.util.VersionInfo? = null
private val categories = listOf(
"popular" to "인기영상",
"movie" to "영화",
"kor_movie" to "한국영화",
"drama" to "드라마",
"ent" to "예능프로그램",
"sisa" to "시사/다큐",
"world" to "해외드라마",
"ott_ent" to "해외 (예능/다큐)",
"ani_movie" to "[극장판] 애니메이션",
"animation" to "일반 애니메이션",
"old_ent" to "추억의 예능",
"old_drama" to "추억의 드라마"
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -43,6 +62,7 @@ class SettingsActivity : AppCompatActivity() {
setContentView(R.layout.activity_settings)
initViews()
setupCategoryToggles()
loadSettings()
setupListeners()
}
@@ -53,6 +73,23 @@ class SettingsActivity : AppCompatActivity() {
btnClearCache = findViewById(R.id.btn_clear_cache)
btnCheckUpdate = findViewById(R.id.btn_check_update)
btnBack = findViewById(R.id.btn_back)
categoryTogglesContainer = findViewById(R.id.category_toggles_container)
}
private fun setupCategoryToggles() {
for ((key, name) in categories) {
val toggleView = layoutInflater.inflate(R.layout.item_category_toggle, categoryTogglesContainer, false)
val toggle = toggleView.findViewById<Switch>(R.id.switch_category)
val label = toggleView.findViewById<TextView>(R.id.tv_category_name)
label.text = name
toggle.isChecked = CategoryPreferences.isCategoryEnabled(this, key)
toggle.setOnCheckedChangeListener { _, isChecked ->
CategoryPreferences.setCategoryEnabled(this, key, isChecked)
}
categoryTogglesContainer.addView(toggleView)
}
}
private fun loadSettings() {

View File

@@ -0,0 +1,36 @@
package com.example.tvmon.util
import android.content.Context
import android.content.SharedPreferences
object CategoryPreferences {
private const val PREFS_NAME = "category_prefs"
private const val KEY_PREFIX = "category_enabled_"
private fun getPrefs(context: Context): SharedPreferences {
return context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
}
fun isCategoryEnabled(context: Context, categoryKey: String): Boolean {
return getPrefs(context).getBoolean(KEY_PREFIX + categoryKey, true)
}
fun setCategoryEnabled(context: Context, categoryKey: String, enabled: Boolean) {
getPrefs(context).edit().putBoolean(KEY_PREFIX + categoryKey, enabled).apply()
}
fun getEnabledCategories(context: Context): Set<String> {
val prefs = getPrefs(context)
val enabled = mutableSetOf<String>()
val categories = listOf("popular", "movie", "kor_movie", "drama", "ent", "sisa",
"world", "ott_ent", "ani_movie", "animation", "old_ent", "old_drama")
for (key in categories) {
if (prefs.getBoolean(KEY_PREFIX + key, true)) {
enabled.add(key)
}
}
return enabled
}
}

View File

@@ -67,6 +67,24 @@
</LinearLayout>
</LinearLayout>
<!-- Category Toggle Header -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="카테고리 표시"
android:textColor="@color/netflix_light_gray"
android:textSize="18sp"
android:padding="16dp"
android:layout_marginTop="16dp" />
<!-- Category Toggles Container -->
<LinearLayout
android:id="@+id/category_toggles_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp" />
<!-- Cache Delete Buttons -->
<LinearLayout
android:layout_width="match_parent"

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="12dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_category_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@android:color/white"
android:textSize="16sp" />
<Switch
android:id="@+id/switch_category"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumbTint="@color/accent"
android:trackTint="@color/netflix_medium_gray" />
</LinearLayout>