Merge branch 'infoGrabs' into test-merge
Manual merge, still need to add compressing recycler view stuff
This commit is contained in:
@ -1,9 +1,15 @@
|
||||
package com.example.myapplication
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
@ -46,14 +52,34 @@ class MainActivity : AppCompatActivity() {
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
//adds actions for when you press buttons
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.add) {
|
||||
val compressingRecycler = findViewById<View>(R.id.compressing_recycler_view) as? RecyclerView
|
||||
compressingRecycler?.adapter = CompressingAdapter(compressingItems)
|
||||
compressingRecycler?.layoutManager = LinearLayoutManager(this)
|
||||
val compressingItem = CompressingItem("Testing", 0.5, Date(1))
|
||||
compressingItems.add(compressingItem)
|
||||
return when (item.itemId) {
|
||||
//runs when pressing "Files"
|
||||
R.id.addFile -> {
|
||||
val intent = Intent()
|
||||
.setType("*/*")
|
||||
.setAction(Intent.ACTION_GET_CONTENT)
|
||||
|
||||
resultLauncher.launch(intent)
|
||||
|
||||
Toast.makeText(applicationContext, "Files", Toast.LENGTH_LONG).show()
|
||||
return true
|
||||
}
|
||||
R.id.addYoutube ->{
|
||||
Toast.makeText(applicationContext, "Youtube downloading is currently not available", Toast.LENGTH_LONG).show()
|
||||
return true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
//grabs output from pressing files, used for grabbing URI
|
||||
var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
// There are no request codes
|
||||
val data: Uri? = result.data?.data
|
||||
Toast.makeText(applicationContext, data.toString(), Toast.LENGTH_LONG).show()
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
package com.example.myapplication.ui.settings
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RadioButton
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.example.myapplication.databinding.FragmentSettingsBinding
|
||||
@ -25,7 +31,71 @@ class SettingsFragment : Fragment() {
|
||||
ViewModelProvider(this)[SettingsViewModel::class.java]
|
||||
|
||||
_binding = FragmentSettingsBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
val root: View = binding.root
|
||||
|
||||
|
||||
|
||||
|
||||
//sets the textbox visibility on startup
|
||||
binding.settingCustomSizeVideoText.visibility = View.INVISIBLE
|
||||
|
||||
|
||||
//updates size when size selection changes
|
||||
binding.settingRadioGroup.setOnCheckedChangeListener{ group,checkedID ->
|
||||
|
||||
if(checkedID == binding.settingDefaultSizeVideo.id){
|
||||
homeViewModel.size.value = 8.0
|
||||
}else if(checkedID == binding.settingBigSizeVideo.id){
|
||||
homeViewModel.size.value = 50.0
|
||||
}else if(checkedID == binding.settingHugeSize.id){
|
||||
homeViewModel.size.value = 500.0
|
||||
}else{
|
||||
try{
|
||||
homeViewModel.size.value = binding.settingCustomSizeVideoText.text.toString().toDouble()
|
||||
}catch (e: NumberFormatException){
|
||||
homeViewModel.size.value = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
Toast.makeText(root.context,"" + homeViewModel.size.value,Toast.LENGTH_SHORT).show()
|
||||
|
||||
}
|
||||
|
||||
//updates size when the custom value changes
|
||||
binding.settingCustomSizeVideoText.addTextChangedListener ( object: TextWatcher {
|
||||
|
||||
override fun afterTextChanged(s: Editable) {}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int,
|
||||
count: Int, after: Int) {
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence, start: Int,
|
||||
before: Int, count: Int) {
|
||||
try{
|
||||
homeViewModel.size.value = s.toString().toDouble()
|
||||
}catch (e: NumberFormatException){
|
||||
homeViewModel.size.value = 0.0
|
||||
}
|
||||
Toast.makeText(root.context,"" + homeViewModel.size.value,Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
//listens for changes in the custom radiobutton and hides or shows the textbox
|
||||
binding.settingCustomSizeVideo.setOnCheckedChangeListener{ _, isChecked ->
|
||||
if (isChecked){
|
||||
binding.settingCustomSizeVideoText.visibility = View.VISIBLE
|
||||
}else{
|
||||
binding.settingCustomSizeVideoText.visibility = View.INVISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
// val textView: TextView = binding.textSettings
|
||||
// homeViewModel.text.observe(viewLifecycleOwner) {
|
||||
// textView.text = it
|
||||
// }
|
||||
return root
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -10,4 +10,10 @@ class SettingsViewModel : ViewModel() {
|
||||
value = "This is settings Fragment"
|
||||
}
|
||||
val text: LiveData<String> = _text
|
||||
|
||||
//size of the file, grab this for use
|
||||
private val _size = MutableLiveData<Double>().apply {
|
||||
value = 8.0
|
||||
}
|
||||
val size: MutableLiveData<Double> = _size
|
||||
}
|
Reference in New Issue
Block a user