added free space text below file picker

pull/50/head
deniscerri 3 years ago
parent 94562dfe8d
commit 78cdaf5642
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -35,6 +35,7 @@ import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
class DownloadAudioFragment(private var resultItem: ResultItem, private var currentDownloadItem: DownloadItem?) : Fragment() {
@ -48,6 +49,7 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
private lateinit var title : TextInputLayout
private lateinit var author : TextInputLayout
private lateinit var saveDir : TextInputLayout
private lateinit var freeSpace : TextView
lateinit var downloadItem : DownloadItem
override fun onCreateView(
@ -111,6 +113,11 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
audioPathResultLauncher.launch(intent)
}
freeSpace = view.findViewById(R.id.freespace)
freeSpace.text = getString(R.string.freespace) + ": " + fileUtil.convertFileSize(
File(fileUtil.formatPath(downloadItem.downloadPath)).freeSpace
)
var formats = resultItem.formats.filter { it.format_note.contains("audio", ignoreCase = true) }
@ -208,6 +215,10 @@ class DownloadAudioFragment(private var resultItem: ResultItem, private var curr
downloadItem.downloadPath = result.data?.data.toString()
//downloadViewModel.updateDownload(downloadItem)
saveDir.editText?.setText(fileUtil.formatPath(result.data?.data.toString()), TextView.BufferType.EDITABLE)
freeSpace.text = getString(R.string.freespace) + ": " + fileUtil.convertFileSize(
File(fileUtil.formatPath(downloadItem.downloadPath)).freeSpace
)
}
}

@ -35,6 +35,7 @@ import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
class DownloadCommandFragment(private val resultItem: ResultItem, private var currentDownloadItem: DownloadItem?) : Fragment() {
private var _binding : FragmentHomeBinding? = null
@ -45,6 +46,7 @@ class DownloadCommandFragment(private val resultItem: ResultItem, private var cu
private lateinit var fileUtil : FileUtil
private lateinit var uiUtil : UiUtil
private lateinit var saveDir : TextInputLayout
private lateinit var freeSpace : TextView
lateinit var downloadItem: DownloadItem
@ -76,22 +78,10 @@ class DownloadCommandFragment(private val resultItem: ResultItem, private var cu
}
}
val sharedPreferences = requireContext().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
try {
val templates : MutableList<CommandTemplate> = withContext(Dispatchers.IO){
commandTemplateViewModel.getAll().toMutableList()
}
// val id = sharedPreferences.getLong("commandTemplate", templates[0].id)
// val chosenCommand = templates.find { it.id == id }
// downloadItem.format = Format(
// chosenCommand!!.title,
// "",
// "",
// "",
// "",
// 0,
// chosenCommand.content
// )
val chosenCommandView = view.findViewById<TextInputLayout>(R.id.content)
chosenCommandView.editText!!.setText(downloadItem.format.format_note)
@ -160,6 +150,11 @@ class DownloadCommandFragment(private val resultItem: ResultItem, private var cu
commandPathResultLauncher.launch(intent)
}
freeSpace = view.findViewById(R.id.freespace)
freeSpace.text = getString(R.string.freespace) + ": " + fileUtil.convertFileSize(
File(fileUtil.formatPath(downloadItem.downloadPath)).freeSpace
)
val newTemplate : Chip = view.findViewById(R.id.newTemplate)
newTemplate.setOnClickListener {
uiUtil.showCommandTemplateCreationOrUpdatingSheet(null, requireActivity(), viewLifecycleOwner, commandTemplateViewModel) {
@ -240,6 +235,10 @@ class DownloadCommandFragment(private val resultItem: ResultItem, private var cu
downloadItem.downloadPath = result.data?.data.toString()
//downloadviewmodel.updateDownload(downloadItem)
saveDir.editText?.setText(fileUtil.formatPath(result.data?.data.toString()), TextView.BufferType.EDITABLE)
freeSpace.text = getString(R.string.freespace) + ": " + fileUtil.convertFileSize(
File(fileUtil.formatPath(downloadItem.downloadPath)).freeSpace
)
}
}
}

@ -35,6 +35,7 @@ import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
class DownloadVideoFragment(private val resultItem: ResultItem, private var currentDownloadItem: DownloadItem?) : Fragment() {
@ -49,6 +50,7 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
private lateinit var title : TextInputLayout
private lateinit var author : TextInputLayout
private lateinit var saveDir : TextInputLayout
private lateinit var freeSpace : TextView
lateinit var downloadItem: DownloadItem
@ -117,6 +119,11 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
videoPathResultLauncher.launch(intent)
}
freeSpace = view.findViewById(R.id.freespace)
freeSpace.text = getString(R.string.freespace) + ": " + fileUtil.convertFileSize(
File(fileUtil.formatPath(downloadItem.downloadPath)).freeSpace
)
var formats = mutableListOf<Format>()
formats.addAll(resultItem.formats.filter { !it.format_note.contains("audio", ignoreCase = true) })
val videoFormats = resources.getStringArray(R.array.video_formats)
@ -236,6 +243,10 @@ class DownloadVideoFragment(private val resultItem: ResultItem, private var curr
downloadItem.downloadPath = result.data?.data.toString()
//downloadviewmodel.updateDownload(downloadItem)
saveDir.editText?.setText(fileUtil.formatPath(result.data?.data.toString()), TextView.BufferType.EDITABLE)
freeSpace.text = getString(R.string.freespace) + ": " + fileUtil.convertFileSize(
File(fileUtil.formatPath(downloadItem.downloadPath)).freeSpace
)
}
}

@ -149,6 +149,14 @@
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/freespace"
android:paddingHorizontal="10dp"
android:paddingVertical="5dp"
android:textSize="13sp"
android:textColor="@android:color/tab_indicator_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/adjust_audio"

@ -60,6 +60,16 @@
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/freespace"
android:paddingHorizontal="10dp"
android:paddingVertical="5dp"
android:textSize="13sp"
android:textColor="@android:color/tab_indicator_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/adjust_commands"
android:layout_width="wrap_content"

@ -144,6 +144,16 @@
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/freespace"
android:paddingHorizontal="10dp"
android:paddingVertical="5dp"
android:textSize="13sp"
android:textColor="@android:color/tab_indicator_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/adjust_video"
android:layout_width="match_parent"

@ -226,4 +226,5 @@
<string name="cache_cleared">Temporary files cleared</string>
<string name="downloads_running_try_later">Download worker is running. Try again later</string>
<string name="ytdl_version">yt-dlp Version</string>
<string name="freespace">Free space</string>
</resources>
Loading…
Cancel
Save