fixed terminal glitch
This commit is contained in:
parent
fa7bb62320
commit
57f8520e03
5 changed files with 58 additions and 45 deletions
|
|
@ -77,7 +77,7 @@ class CutVideoBottomSheetDialog(private val item: DownloadItem, private val list
|
|||
val timeSeconds = convertStringToTimestamp(item.duration)
|
||||
|
||||
if (item.downloadSections.isEmpty()){
|
||||
fromTextInput.editText!!.setText("00:00")
|
||||
fromTextInput.editText!!.setText("0:00")
|
||||
toTextInput.editText!!.setText(item.duration)
|
||||
}else{
|
||||
val stamps = item.downloadSections.split("-")
|
||||
|
|
|
|||
|
|
@ -258,6 +258,9 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
|
|||
}
|
||||
|
||||
override fun onChangeCut(from: String, to: String) {
|
||||
if (from == "0:00" && to == downloadItem.duration){
|
||||
return
|
||||
}
|
||||
val value = "${from}-${to}"
|
||||
downloadItem.downloadSections = value
|
||||
cut.text = value
|
||||
|
|
|
|||
|
|
@ -283,6 +283,9 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
|
|||
}
|
||||
|
||||
override fun onChangeCut(from: String, to: String) {
|
||||
if (from == "0:00" && to == downloadItem.duration){
|
||||
return
|
||||
}
|
||||
val value = "${from}-${to}"
|
||||
downloadItem.downloadSections = value
|
||||
cut.text = value
|
||||
|
|
@ -290,6 +293,7 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
|
|||
splitByChapters.isEnabled = false
|
||||
splitByChapters.isChecked = false
|
||||
addChapters.isEnabled = true
|
||||
|
||||
}
|
||||
}
|
||||
cut.setOnClickListener {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.deniscerri.ytdlnis.ui.more
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.app.Notification
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
|
|
@ -21,10 +23,7 @@ import androidx.core.app.NotificationManagerCompat
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.work.Data
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import androidx.work.*
|
||||
import com.deniscerri.ytdlnis.App
|
||||
import com.deniscerri.ytdlnis.R
|
||||
import com.deniscerri.ytdlnis.database.repository.DownloadRepository
|
||||
|
|
@ -67,6 +66,7 @@ class TerminalActivity : AppCompatActivity() {
|
|||
private var scrollView: ScrollView? = null
|
||||
private lateinit var bottomAppBar: BottomAppBar
|
||||
private lateinit var commandTemplateViewModel: CommandTemplateViewModel
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
var context: Context? = null
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -78,6 +78,7 @@ class TerminalActivity : AppCompatActivity() {
|
|||
topAppBar!!.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() }
|
||||
|
||||
commandTemplateViewModel = ViewModelProvider(this)[CommandTemplateViewModel::class.java]
|
||||
sharedPreferences = getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
|
||||
|
||||
|
||||
bottomAppBar = findViewById(R.id.bottomAppBar)
|
||||
|
|
@ -157,6 +158,7 @@ class TerminalActivity : AppCompatActivity() {
|
|||
item.findViewById<TextView>(R.id.content).text = template.content
|
||||
item.setOnClickListener {
|
||||
input!!.text.insert(input!!.selectionStart, template.content + " ")
|
||||
bottomSheet.cancel()
|
||||
}
|
||||
linearLayout.addView(item)
|
||||
}
|
||||
|
|
@ -246,7 +248,7 @@ class TerminalActivity : AppCompatActivity() {
|
|||
YoutubeDL.getInstance().execute(request, downloadID.toString()){ progress, _, line ->
|
||||
Log.e(TAG, line)
|
||||
runOnUiThread {
|
||||
output!!.append("\n" + line)
|
||||
output!!.text = "${output!!.text}\n$line"
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
|
|
@ -261,11 +263,12 @@ class TerminalActivity : AppCompatActivity() {
|
|||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
runOnUiThread {
|
||||
output!!.append("\n" + e.message)
|
||||
output!!.text = "${output!!.text}\n${e.message}"
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
|
||||
input!!.visibility = View.VISIBLE
|
||||
input!!.requestFocus()
|
||||
|
||||
hideCancelFab()
|
||||
}
|
||||
|
|
@ -275,15 +278,24 @@ class TerminalActivity : AppCompatActivity() {
|
|||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
input!!.setText("yt-dlp ")
|
||||
input!!.visibility = View.VISIBLE
|
||||
input!!.requestFocus()
|
||||
|
||||
try{
|
||||
val fileUtil = FileUtil()
|
||||
fileUtil.moveFile(tempFileDir.absoluteFile, this, sharedPreferences.getString("command_path", getString(R.string.command))!!) {}
|
||||
}catch (e: Exception){
|
||||
output!!.text = "${output!!.text}\n${e.message}"
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
|
||||
hideCancelFab()
|
||||
notificationUtil.cancelDownloadNotification(downloadID)
|
||||
}) { e ->
|
||||
e.printStackTrace()
|
||||
output!!.text = "${output!!.text}\n${e.message}"
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
input!!.setText("yt-dlp ")
|
||||
|
|
|
|||
|
|
@ -30,53 +30,47 @@
|
|||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/custom_command_frame_layout"
|
||||
<ScrollView
|
||||
android:layout_margin="10dp"
|
||||
android:id="@+id/custom_command_scrollview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="100dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/coordinatorLayout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/custom_command_scrollview"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="100dp">
|
||||
android:layout_height="wrap_content"
|
||||
android:focusableInTouchMode="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
<TextView
|
||||
android:id="@+id/custom_command_output"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:fontFamily="monospace"
|
||||
android:gravity="bottom"
|
||||
android:textIsSelectable="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/custom_command_output"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="monospace"
|
||||
android:gravity="bottom"
|
||||
android:textIsSelectable="true" />
|
||||
<EditText
|
||||
android:id="@+id/command_edittext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:fontFamily="monospace"
|
||||
android:gravity="start"
|
||||
android:inputType="textMultiLine"
|
||||
android:paddingBottom="100dp"
|
||||
android:maxLines="100"
|
||||
android:text="yt-dlp "
|
||||
android:textSize="15sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/command_edittext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:fontFamily="monospace"
|
||||
android:gravity="start"
|
||||
android:inputType="textMultiLine"
|
||||
android:maxLines="100"
|
||||
android:text="yt-dlp "
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
|
|
|||
Loading…
Reference in a new issue