made changelog a separate fragment
This commit is contained in:
parent
54314fcee1
commit
c705f7e831
13 changed files with 158 additions and 68 deletions
|
|
@ -80,7 +80,7 @@ class ChangelogAdapter(activity: Activity) : ListAdapter<GithubRelease?, Changel
|
|||
val assetGroup = card.findViewById<ChipGroup>(R.id.assets)
|
||||
assetGroup.removeAllViews()
|
||||
it.assets.forEachIndexed { idx, c ->
|
||||
val tmp = activity.layoutInflater.inflate(R.layout.filter_chip, assetGroup, false) as Chip
|
||||
val tmp = activity.layoutInflater.inflate(R.layout.suggestion_chip, assetGroup, false) as Chip
|
||||
tmp.isCheckable = false
|
||||
tmp.layoutParams = layoutParams
|
||||
tmp.text = c.name
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import android.provider.Settings
|
|||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.interaction.DragInteraction
|
||||
import androidx.core.content.edit
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
|
|
@ -268,6 +269,9 @@ class DownloadSettingsFragment : BaseSettingsFragment() {
|
|||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(preferences.edit(), R.xml.downloading_preferences)
|
||||
requireActivity().recreate()
|
||||
val fragmentId = findNavController().currentDestination?.id
|
||||
findNavController().popBackStack(fragmentId!!,true)
|
||||
findNavController().navigate(fragmentId)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import android.provider.Settings
|
|||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceCategory
|
||||
import androidx.preference.PreferenceGroup
|
||||
|
|
@ -240,6 +241,9 @@ class FolderSettingsFragment : BaseSettingsFragment() {
|
|||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(editor, R.xml.folders_preference)
|
||||
requireActivity().recreate()
|
||||
val fragmentId = findNavController().currentDestination?.id
|
||||
findNavController().popBackStack(fragmentId!!,true)
|
||||
findNavController().navigate(fragmentId)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,6 +373,9 @@ class GeneralSettingsFragment : BaseSettingsFragment() {
|
|||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(editor, R.xml.general_preferences)
|
||||
ThemeUtil.updateThemes()
|
||||
val fragmentId = findNavController().currentDestination?.id
|
||||
findNavController().popBackStack(fragmentId!!,true)
|
||||
findNavController().navigate(fragmentId)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.deniscerri.ytdl.ui.more.settings
|
|||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.EditTextPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceManager
|
||||
|
|
@ -77,6 +78,9 @@ class ProcessingSettingsFragment : BaseSettingsFragment() {
|
|||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(editor, R.xml.processing_preferences)
|
||||
requireActivity().recreate()
|
||||
val fragmentId = findNavController().currentDestination?.id
|
||||
findNavController().popBackStack(fragmentId!!,true)
|
||||
findNavController().navigate(fragmentId)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ class AdvancedSettingsFragment : BaseSettingsFragment() {
|
|||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(editor, R.xml.downloading_preferences)
|
||||
requireActivity().recreate()
|
||||
val fragmentId = findNavController().currentDestination?.id
|
||||
findNavController().popBackStack(fragmentId!!,true)
|
||||
findNavController().navigate(fragmentId)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package com.deniscerri.ytdl.ui.more.settings.updating
|
||||
|
||||
import android.animation.AnimatorSet
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.deniscerri.ytdl.R
|
||||
import com.deniscerri.ytdl.database.models.YoutubePlayerClientItem
|
||||
import com.deniscerri.ytdl.ui.adapter.ChangelogAdapter
|
||||
import com.deniscerri.ytdl.ui.adapter.YoutubePlayerClientAdapter
|
||||
import com.deniscerri.ytdl.ui.more.settings.SettingsActivity
|
||||
import com.deniscerri.ytdl.util.Extensions.enableFastScroll
|
||||
import com.deniscerri.ytdl.util.UiUtil
|
||||
import com.deniscerri.ytdl.util.UpdateUtil
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
class ChangeLogFragment : Fragment() {
|
||||
private lateinit var recyclerView: RecyclerView
|
||||
private lateinit var listAdapter: ChangelogAdapter
|
||||
private lateinit var noResults : RelativeLayout
|
||||
private lateinit var settingsActivity: SettingsActivity
|
||||
private lateinit var preferences: SharedPreferences
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopAppbarTitle(getString(R.string.changelog))
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
return inflater.inflate(R.layout.fragment_changelog, container, false)
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
noResults = view.findViewById(R.id.no_results)
|
||||
|
||||
listAdapter = ChangelogAdapter(settingsActivity)
|
||||
recyclerView = view.findViewById(R.id.recycler_view)
|
||||
recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
recyclerView.adapter = listAdapter
|
||||
recyclerView.enableFastScroll()
|
||||
|
||||
val updateUtil = UpdateUtil(requireContext())
|
||||
lifecycleScope.launch {
|
||||
val releases = withContext(Dispatchers.IO) {
|
||||
updateUtil.getGithubReleases()
|
||||
}
|
||||
listAdapter.submitList(releases)
|
||||
noResults.isVisible = releases.isEmpty()
|
||||
recyclerView.isVisible = releases.isNotEmpty()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +1,25 @@
|
|||
package com.deniscerri.ytdl.ui.more.settings
|
||||
package com.deniscerri.ytdl.ui.more.settings.updating
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.DownloadManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Button
|
||||
import android.widget.CheckBox
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.ListView
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.get
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.afollestad.materialdialogs.utils.MDUtil.getStringArray
|
||||
import com.deniscerri.ytdl.BuildConfig
|
||||
import com.deniscerri.ytdl.R
|
||||
import com.deniscerri.ytdl.database.models.CommandTemplate
|
||||
import com.deniscerri.ytdl.database.viewmodel.DownloadViewModel
|
||||
import com.deniscerri.ytdl.database.viewmodel.SettingsViewModel
|
||||
import com.deniscerri.ytdl.database.viewmodel.YTDLPViewModel
|
||||
import com.deniscerri.ytdl.util.FileUtil
|
||||
import com.deniscerri.ytdl.ui.more.settings.BaseSettingsFragment
|
||||
import com.deniscerri.ytdl.util.UiUtil
|
||||
import com.deniscerri.ytdl.util.UiUtil.showShortcutsSheet
|
||||
import com.deniscerri.ytdl.util.UpdateUtil
|
||||
import com.deniscerri.ytdl.util.extractors.YTDLPUtil
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.chip.ChipGroup
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.materialswitch.MaterialSwitch
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.yausername.youtubedl_android.YoutubeDL
|
||||
import io.noties.markwon.AbstractMarkwonPlugin
|
||||
import io.noties.markwon.Markwon
|
||||
import io.noties.markwon.MarkwonConfiguration
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
class UpdateSettingsFragment : BaseSettingsFragment() {
|
||||
|
|
@ -130,10 +77,8 @@ class UpdateSettingsFragment : BaseSettingsFragment() {
|
|||
|
||||
|
||||
findPreference<Preference>("changelog")?.setOnPreferenceClickListener {
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
updateUtil?.showChangeLog(requireActivity())
|
||||
}
|
||||
true
|
||||
findNavController().navigate(R.id.changeLogFragment)
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -165,6 +110,9 @@ class UpdateSettingsFragment : BaseSettingsFragment() {
|
|||
UiUtil.showGenericConfirmDialog(requireContext(), getString(R.string.reset), getString(R.string.reset_preferences_in_screen)) {
|
||||
resetPreferences(preferences.edit(), R.xml.updating_preferences)
|
||||
requireActivity().recreate()
|
||||
val fragmentId = findNavController().currentDestination?.id
|
||||
findNavController().popBackStack(fragmentId!!,true)
|
||||
findNavController().navigate(fragmentId)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ class UpdateUtil(var context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getGithubReleases(): List<GithubRelease> {
|
||||
fun getGithubReleases(): List<GithubRelease> {
|
||||
val url = "https://api.github.com/repos/deniscerri/ytdlnis/releases"
|
||||
val conn: HttpURLConnection
|
||||
var json = listOf<GithubRelease>()
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_margin="5dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
|
|
@ -61,4 +63,10 @@
|
|||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:backgroundTint="?android:colorAccent"
|
||||
style="@style/Divider.Horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
33
app/src/main/res/layout/fragment_changelog.xml
Normal file
33
app/src/main/res/layout/fragment_changelog.xml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.deniscerri.ytdl.ui.more.terminal.TerminalActivity">
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/recycler_view"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="200dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<include layout="@layout/no_results"
|
||||
android:visibility="gone"/>
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
|
@ -137,7 +137,7 @@
|
|||
android:label="DownloadSettingsFragment" />
|
||||
<fragment
|
||||
android:id="@+id/updateSettingsFragment"
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.UpdateSettingsFragment"
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.updating.UpdateSettingsFragment"
|
||||
android:label="UpdateSettingsFragment" />
|
||||
<fragment
|
||||
android:id="@+id/mainSettingsFragment"
|
||||
|
|
|
|||
|
|
@ -16,8 +16,12 @@
|
|||
android:label="FolderSettingsFragment" />
|
||||
<fragment
|
||||
android:id="@+id/updateSettingsFragment"
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.UpdateSettingsFragment"
|
||||
android:label="UpdateSettingsFragment" />
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.updating.UpdateSettingsFragment"
|
||||
android:label="UpdateSettingsFragment" >
|
||||
<action
|
||||
android:id="@+id/action_updateSettingsFragment_to_changeLogFragment"
|
||||
app:destination="@id/changeLogFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/downloadSettingsFragment"
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.DownloadSettingsFragment"
|
||||
|
|
@ -57,4 +61,8 @@
|
|||
android:id="@+id/youtubePlayerClientFragment"
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.advanced.YoutubePlayerClientFragment"
|
||||
android:label="YoutubePlayerClientFragment" />
|
||||
<fragment
|
||||
android:id="@+id/changeLogFragment"
|
||||
android:name="com.deniscerri.ytdl.ui.more.settings.updating.ChangeLogFragment"
|
||||
android:label="ChangeLogFragment" />
|
||||
</navigation>
|
||||
Loading…
Reference in a new issue