Something

This commit is contained in:
Isaac Shoebottom 2022-12-06 07:00:52 -04:00
parent 07e0a5422e
commit 9b60e78c1f
3 changed files with 42 additions and 6 deletions

View File

@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
minSdk 24
targetSdk 32
versionCode 1
versionName "1.0"
@ -35,8 +35,7 @@ android {
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
@ -44,7 +43,8 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
implementation 'com.arthenica:ffmpeg-kit-full:5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
}

View File

@ -0,0 +1,10 @@
package com.example.myapplication
import java.io.FileDescriptor
class Compressor {
public fun compressFile(fileDescriptor: FileDescriptor) {
}
}

View File

@ -1,9 +1,11 @@
package com.example.myapplication
import android.app.Activity
import android.content.ContentResolver
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.MediaStore
import android.view.Menu
import android.view.MenuItem
import android.view.View
@ -20,6 +22,7 @@ import com.example.myapplication.databinding.ActivityMainBinding
import com.example.myapplication.ui.compressing.CompressingAdapter
import com.example.myapplication.ui.compressing.CompressingItem
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.io.FileInputStream
import java.util.*
class MainActivity : AppCompatActivity() {
@ -71,6 +74,10 @@ class MainActivity : AppCompatActivity() {
Toast.makeText(applicationContext, "Files", Toast.LENGTH_LONG).show()
if (fileName != null && fileDate != null) {
compressingItems.add(CompressingItem(fileName!!, 0.0, fileDate!!))
}
compressingItems.add(CompressingItem("Testing", 0.5, Date(1)))
return true
@ -83,11 +90,30 @@ class MainActivity : AppCompatActivity() {
}
}
private var fileName: String? = null
private var fileDate: Date? = null
private var fileStream: FileInputStream? = null
//grabs output from pressing files, used for grabbing URI
var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
private var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
// There are no request codes
val data: Uri? = result.data?.data
val contentResolver: ContentResolver = contentResolver
val fileDescriptor = contentResolver.openFileDescriptor(data!!, "r")
val fd = fileDescriptor?.fileDescriptor
val inputStream = FileInputStream(fd)
val cursor = contentResolver.query(data, null, null, null, null)
val dateIndex = cursor?.getColumnIndex(MediaStore.MediaColumns.DATE_ADDED)
fileDate = Date(dateIndex?.toLong()!!)
val nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME)
fileName = cursor.getString(nameIndex)
this.fileStream = inputStream
Toast.makeText(applicationContext, data.toString(), Toast.LENGTH_LONG).show()
}
}