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="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="11" />
|
<option name="gradleJvm" value="Embedded JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
package com.example.myapplication
|
package com.example.myapplication
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
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.appcompat.app.AppCompatActivity
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.ui.AppBarConfiguration
|
import androidx.navigation.ui.AppBarConfiguration
|
||||||
@ -46,14 +52,34 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return super.onCreateOptionsMenu(menu)
|
return super.onCreateOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//adds actions for when you press buttons
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
if (item.itemId == R.id.add) {
|
return when (item.itemId) {
|
||||||
val compressingRecycler = findViewById<View>(R.id.compressing_recycler_view) as? RecyclerView
|
//runs when pressing "Files"
|
||||||
compressingRecycler?.adapter = CompressingAdapter(compressingItems)
|
R.id.addFile -> {
|
||||||
compressingRecycler?.layoutManager = LinearLayoutManager(this)
|
val intent = Intent()
|
||||||
val compressingItem = CompressingItem("Testing", 0.5, Date(1))
|
.setType("*/*")
|
||||||
compressingItems.add(compressingItem)
|
.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
|
package com.example.myapplication.ui.settings
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.Editable
|
||||||
|
import android.text.TextWatcher
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
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.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import com.example.myapplication.databinding.FragmentSettingsBinding
|
import com.example.myapplication.databinding.FragmentSettingsBinding
|
||||||
@ -25,7 +31,71 @@ class SettingsFragment : Fragment() {
|
|||||||
ViewModelProvider(this)[SettingsViewModel::class.java]
|
ViewModelProvider(this)[SettingsViewModel::class.java]
|
||||||
|
|
||||||
_binding = FragmentSettingsBinding.inflate(inflater, container, false)
|
_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() {
|
override fun onDestroyView() {
|
||||||
|
@ -10,4 +10,10 @@ class SettingsViewModel : ViewModel() {
|
|||||||
value = "This is settings Fragment"
|
value = "This is settings Fragment"
|
||||||
}
|
}
|
||||||
val text: LiveData<String> = _text
|
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">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
|
android:id="@+id/setting_radio_group"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
@ -23,6 +24,7 @@
|
|||||||
android:id="@+id/setting_default_size_video"
|
android:id="@+id/setting_default_size_video"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
android:text="@string/settings_default_size" />
|
android:text="@string/settings_default_size" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
|
@ -6,5 +6,15 @@
|
|||||||
android:id="@+id/add"
|
android:id="@+id/add"
|
||||||
android:title="Add"
|
android:title="Add"
|
||||||
android:icon="@drawable/ic_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>
|
</menu>
|
@ -10,4 +10,6 @@
|
|||||||
<string name="settings_huge_size">500mb</string>
|
<string name="settings_huge_size">500mb</string>
|
||||||
<string name="settings_custom_size">Custom</string>
|
<string name="settings_custom_size">Custom</string>
|
||||||
<string name="settings_custom_size_hint">Enter Size in MB</string>
|
<string name="settings_custom_size_hint">Enter Size in MB</string>
|
||||||
|
<string name="files">Files</string>
|
||||||
|
<string name="youtube">Youtube</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user