add preference to disable text color highlight
This commit is contained in:
parent
85352bad91
commit
5697d1b4f4
17 changed files with 46 additions and 14 deletions
|
|
@ -93,8 +93,12 @@ class AddExtraCommandsDialog(private val item: DownloadItem? = null, private val
|
|||
view.findViewById<View>(R.id.current).visibility = View.GONE
|
||||
}
|
||||
|
||||
text.enableTextHighlight()
|
||||
currentText.enableTextHighlight()
|
||||
if (sharedPreferences.getBoolean("use_code_color_highlighter", true)) {
|
||||
text.enableTextHighlight()
|
||||
currentText.enableTextHighlight()
|
||||
}
|
||||
|
||||
|
||||
|
||||
text?.setText(item?.extraCommands)
|
||||
val imm = activity?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@ class DownloadCommandFragment(private val resultItem: ResultItem? = null, privat
|
|||
|
||||
val chosenCommandView = view.findViewById<TextInputLayout>(R.id.content)
|
||||
chosenCommandView.editText?.setText(downloadItem.format.format_note)
|
||||
chosenCommandView.editText?.enableTextHighlight()
|
||||
if (preferences.getBoolean("use_code_color_highlighter", true)) {
|
||||
chosenCommandView.editText?.enableTextHighlight()
|
||||
}
|
||||
chosenCommandView.endIconDrawable = AppCompatResources.getDrawable(requireContext(), R.drawable.ic_delete_all)
|
||||
chosenCommandView.editText!!.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class DownloadsAlreadyExistDialog : BottomSheetDialogFragment(), AlreadyExistsAd
|
|||
val historyItem = withContext(Dispatchers.IO){
|
||||
downloadViewModel.getHistoryItemById(historyItemID)
|
||||
}
|
||||
UiUtil.showHistoryItemDetailsCard(historyItem, requireActivity(), isPresent = true,
|
||||
UiUtil.showHistoryItemDetailsCard(historyItem, requireActivity(), isPresent = true, preferences,
|
||||
removeItem = { item, deleteFile ->
|
||||
historyViewModel.delete(item, deleteFile)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -450,6 +450,7 @@ class ResultCardDetailsDialog : BottomSheetDialogFragment(), GenericDownloadAdap
|
|||
requireActivity(),
|
||||
DownloadRepository.Status.valueOf(item.status),
|
||||
ytdlpViewModel,
|
||||
sharedPreferences,
|
||||
removeItem = { it: DownloadItem, sheet: BottomSheetDialog ->
|
||||
sheet.hide()
|
||||
removeQueuedItem(itemID)
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
|
|||
requireActivity(),
|
||||
DownloadRepository.Status.valueOf(item.status),
|
||||
ytdlpViewModel,
|
||||
preferences,
|
||||
removeItem = { it: DownloadItem, sheet: BottomSheetDialog ->
|
||||
removeItem(it, sheet)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
|
|||
requireActivity(),
|
||||
DownloadRepository.Status.valueOf(item.status),
|
||||
ytdlpViewModel,
|
||||
preferences,
|
||||
removeItem = { it: DownloadItem, sheet: BottomSheetDialog ->
|
||||
removeItem(it, sheet)
|
||||
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ class HistoryFragment : Fragment(), HistoryPaginatedAdapter.OnItemClickListener{
|
|||
historyViewModel.getByID(itemID)
|
||||
}
|
||||
|
||||
UiUtil.showHistoryItemDetailsCard(item, requireActivity(), filePresent,
|
||||
UiUtil.showHistoryItemDetailsCard(item, requireActivity(), filePresent, sharedPreferences,
|
||||
removeItem = { it, deleteFile ->
|
||||
historyViewModel.delete(it, deleteFile)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -454,6 +454,7 @@ class QueuedDownloadsFragment : Fragment(), QueuedDownloadAdapter.OnItemClickLis
|
|||
requireActivity(),
|
||||
DownloadRepository.Status.valueOf(item.status),
|
||||
ytdlpViewModel,
|
||||
sharedPreferences,
|
||||
removeItem = { it: DownloadItem, sheet: BottomSheetDialog ->
|
||||
sheet.hide()
|
||||
removeItem(it.id)
|
||||
|
|
|
|||
|
|
@ -187,6 +187,7 @@ class SavedDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickLis
|
|||
requireActivity(),
|
||||
DownloadRepository.Status.valueOf(item.status),
|
||||
ytdlpViewModel,
|
||||
preferences,
|
||||
removeItem = { it: DownloadItem, sheet: BottomSheetDialog ->
|
||||
removeItem(it, sheet)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ class ScheduledDownloadsFragment : Fragment(), ScheduledDownloadAdapter.OnItemCl
|
|||
requireActivity(),
|
||||
DownloadRepository.Status.valueOf(item.status),
|
||||
ytdlpViewModel,
|
||||
preferences,
|
||||
removeItem = { it: DownloadItem, sheet: BottomSheetDialog ->
|
||||
sheet.hide()
|
||||
removeItem(it, sheet)
|
||||
|
|
|
|||
|
|
@ -190,7 +190,9 @@ class CookiesFragment : Fragment(), CookieAdapter.OnItemClickListener {
|
|||
item?.apply {
|
||||
current.findViewById<TextView>(R.id.currentText).apply {
|
||||
setText(item.content)
|
||||
enableTextHighlight()
|
||||
if (preferences.getBoolean("use_code_color_highlighter", true)) {
|
||||
enableTextHighlight()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,9 @@ class DownloadLogFragment : Fragment() {
|
|||
|
||||
lifecycleScope.launch(Dispatchers.IO){
|
||||
content.isFocusable = true
|
||||
content.enableTextHighlight()
|
||||
if (sharedPreferences.getBoolean("use_code_color_highlighter", true)) {
|
||||
content.enableTextHighlight()
|
||||
}
|
||||
}
|
||||
|
||||
contentScrollView.enableFastScroll()
|
||||
|
|
|
|||
|
|
@ -227,7 +227,11 @@ class TerminalFragment : Fragment() {
|
|||
notificationUtil = NotificationUtil(requireContext())
|
||||
initMenu()
|
||||
|
||||
input?.enableTextHighlight()
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
if (sharedPreferences.getBoolean("use_code_color_highlighter", true)) {
|
||||
input?.enableTextHighlight()
|
||||
}
|
||||
}
|
||||
|
||||
input?.append(bundle?.getString("input") ?: "")
|
||||
input!!.requestFocus()
|
||||
|
|
|
|||
|
|
@ -66,14 +66,14 @@ class FormatUtil(private var context: Context) {
|
|||
val orderPreferences = sharedPreferences.getString("format_importance_video", itemValues.joinToString(","))!!.split(",").toMutableList()
|
||||
if (preferSmallerFormats) {
|
||||
orderPreferences.remove("file_size")
|
||||
orderPreferences.add(0, "smallsize")
|
||||
orderPreferences.add("smallsize")
|
||||
}
|
||||
|
||||
return orderPreferences
|
||||
}else {
|
||||
val formatImportance = mutableListOf("resolution", "codec", "container")
|
||||
if (sharedPreferences.getBoolean("prefer_smaller_formats", false)) {
|
||||
formatImportance.add(0, "smallsize")
|
||||
formatImportance.add("smallsize")
|
||||
}
|
||||
|
||||
return formatImportance
|
||||
|
|
|
|||
|
|
@ -533,6 +533,7 @@ object UiUtil {
|
|||
context: Activity,
|
||||
status: DownloadRepository.Status,
|
||||
ytdlpViewModel: YTDLPViewModel,
|
||||
preferences: SharedPreferences,
|
||||
removeItem : (DownloadItem, BottomSheetDialog) -> Unit,
|
||||
downloadItem: (DownloadItem) -> Unit,
|
||||
longClickDownloadButton: (DownloadItem) -> Unit,
|
||||
|
|
@ -642,7 +643,7 @@ object UiUtil {
|
|||
else fileSize!!.text = fileSizeReadable
|
||||
|
||||
command?.setOnClickListener {
|
||||
showGeneratedCommand(context, ytdlpViewModel.parseYTDLRequestString(item))
|
||||
showGeneratedCommand(context, preferences, ytdlpViewModel.parseYTDLRequestString(item))
|
||||
}
|
||||
|
||||
val link = bottomSheet.findViewById<Button>(R.id.bottom_sheet_link)
|
||||
|
|
@ -736,6 +737,7 @@ object UiUtil {
|
|||
item: HistoryItem?,
|
||||
context: Activity,
|
||||
isPresent: Boolean,
|
||||
preferences: SharedPreferences,
|
||||
removeItem: (item:HistoryItem, removeFiles: Boolean) -> Unit,
|
||||
redownloadItem: (HistoryItem) -> Unit,
|
||||
redownloadShowDownloadCard: (HistoryItem) -> Unit,
|
||||
|
|
@ -861,7 +863,7 @@ object UiUtil {
|
|||
else fileSize!!.text = fileSizeReadable
|
||||
|
||||
command?.setOnClickListener {
|
||||
showGeneratedCommand(context, item.command)
|
||||
showGeneratedCommand(context, preferences, item.command)
|
||||
}
|
||||
|
||||
val availableFiles = item.downloadPath.filter { FileUtil.exists(it) }
|
||||
|
|
@ -2094,7 +2096,7 @@ object UiUtil {
|
|||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL).gravity = Gravity.START
|
||||
}
|
||||
|
||||
private fun showGeneratedCommand(context: Activity, command: String){
|
||||
private fun showGeneratedCommand(context: Activity, preferences: SharedPreferences, command: String) {
|
||||
val builder = MaterialAlertDialogBuilder(context)
|
||||
builder.setTitle(context.getString(R.string.command))
|
||||
val view = context.layoutInflater.inflate(R.layout.command_dialog, null)
|
||||
|
|
@ -2102,7 +2104,9 @@ object UiUtil {
|
|||
text = command
|
||||
isLongClickable = true
|
||||
setTextIsSelectable(true)
|
||||
enableTextHighlight()
|
||||
if (preferences.getBoolean("use_code_color_highlighter", true)) {
|
||||
enableTextHighlight()
|
||||
}
|
||||
setPadding(20, 0, 20, 0)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -465,4 +465,5 @@
|
|||
<string name="cache_directory_warning">Changing the Cache Folder might cause unexpected issues. If the app cannot write to the configured path, it will resort to the default internal cache directory</string>
|
||||
<string name="app_icon_change">Icon could change and Application will close</string>
|
||||
<string name="use_format_sorting">Use Format Importance Ordering</string>
|
||||
<string name="use_code_highlighter">Use Code Color Highlighter</string>
|
||||
</resources>
|
||||
|
|
@ -190,6 +190,13 @@
|
|||
android:key="swipe_gestures_download_card"
|
||||
app:title="@string/swipe_gestures_download_card" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preferece_material_switch"
|
||||
app:defaultValue="true"
|
||||
android:icon="@drawable/baseline_color_lens_24"
|
||||
android:key="use_code_color_highlighter"
|
||||
app:title="@string/use_code_highlighter" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preferece_material_switch"
|
||||
app:defaultValue="false"
|
||||
|
|
|
|||
Loading…
Reference in a new issue