Merge branch 'infoGrabs' into test-merge
Manual merge, still need to add compressing recycler view stuff
This commit is contained in:
commit
e45cab082d
@ -7,7 +7,7 @@
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="11" />
|
||||
<option name="gradleJvm" value="Embedded JDK" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
|
@ -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
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/setting_radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@ -23,6 +24,7 @@
|
||||
android:id="@+id/setting_default_size_video"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/settings_default_size" />
|
||||
|
||||
<RadioButton
|
||||
|
@ -6,5 +6,15 @@
|
||||
android:id="@+id/add"
|
||||
android:title="Add"
|
||||
android:icon="@drawable/ic_add"
|
||||
app:showAsAction="ifRoom" />
|
||||
app:showAsAction="ifRoom" >
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/addFile"
|
||||
android:title="@string/files" />
|
||||
<item
|
||||
android:id="@+id/addYoutube"
|
||||
android:title="@string/youtube" />
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
</menu>
|
@ -10,4 +10,6 @@
|
||||
<string name="settings_huge_size">500mb</string>
|
||||
<string name="settings_custom_size">Custom</string>
|
||||
<string name="settings_custom_size_hint">Enter Size in MB</string>
|
||||
<string name="files">Files</string>
|
||||
<string name="youtube">Youtube</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user