Skip to content

Commit

Permalink
crash
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky authored and alperozturk96 committed Feb 5, 2025
1 parent 3345422 commit cd7ad98
Showing 1 changed file with 12 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.os.Bundle
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.core.app.ActivityCompat.finishAffinity
import androidx.fragment.app.DialogFragment
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.android.lib.resources.tos.GetTermsRemoteOperation
Expand All @@ -25,6 +26,7 @@ import com.nextcloud.utils.extensions.setHtmlContent
import com.owncloud.android.R
import com.owncloud.android.databinding.DialogShowTosBinding
import com.owncloud.android.lib.common.operations.RemoteOperationResult
import com.owncloud.android.lib.common.utils.Log_OC
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.theme.ViewThemeUtils
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -61,11 +63,6 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
}

private fun updateDialog() {
// viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
// binding.root.context,
// builder
// )

binding.message.setHtmlContent(terms[0].renderedBody)

val arrayAdapter: ArrayAdapter<String> = ArrayAdapter(
Expand All @@ -86,9 +83,7 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
.setHtmlContent(terms[position].renderedBody)
}

override fun onNothingSelected(adapterView: AdapterView<*>?) {
// nothing to do
}
override fun onNothingSelected(adapterView: AdapterView<*>?) = Unit
}

if (terms.size == 1) {
Expand All @@ -98,6 +93,7 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {

private fun fetchTerms() {
CoroutineScope(Dispatchers.IO).launch {
//viewLifecycleOwner.lifecycleScope.launch {
try {
client = clientFactory.createNextcloudClient(accountManager.getUser())
val result = GetTermsRemoteOperation().execute(client)
Expand All @@ -110,11 +106,12 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
terms = result.resultData.terms

CoroutineScope(Dispatchers.Main).launch {
// withContext(Dispatchers.Main) {
updateDialog()
}
}
} catch (exception: ClientFactory.CreationException) {
TODO("Add error handling here")
Log_OC.e(TAG, "Error creating client!")
}
}
}
Expand All @@ -123,10 +120,10 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
return MaterialAlertDialogBuilder(binding.root.context)
.setView(binding.root)
.setTitle(R.string.terms_of_service_title)
.setNegativeButton(R.string.dialog_close) { dialog, which ->
// TODO finishAffinity()
.setNegativeButton(R.string.dialog_close) { _, _ ->
activity?.let { finishAffinity(it) }
}
.setPositiveButton(R.string.terms_of_services_agree) { dialog, which ->
.setPositiveButton(R.string.terms_of_services_agree) { dialog, _ ->
dialog.dismiss()
Thread {
val id = binding.languageDropdown.selectedItemPosition
Expand All @@ -139,58 +136,7 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
}
}

// private void showTermsOfServiceDialog1()
// {

// runOnUiThread(Runnable {
// viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
// binding.root.context,
// builder
// )
// builder.create()
//
// binding.message.setHtmlContent(terms[0].renderedBody)
//
// val arrayAdapter: ArrayAdapter<String> = ArrayAdapter(
// binding.root.context,
// android.R.layout.simple_spinner_item
// )
//
// for ((_, _, languageCode) in terms) {
// arrayAdapter.add(languages[languageCode])
// }
//
// arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
//
//
// binding.languageDropdown.adapter = arrayAdapter
// binding.languageDropdown.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
// override fun onItemSelected(
// adapterView: AdapterView<*>?,
// view: View,
// position: Int,
// l: Long
// ) {
// binding.message
// .setHtmlContent(terms[position].renderedBody)
// }
//
// override fun onNothingSelected(adapterView: AdapterView<*>?) {
// // nothing to do
// }
// }
//
// if (terms.size == 1) {
// binding.languageDropdown.visibility = View.GONE
// }
// if (!tosIsShown) {
// tosIsShown = true
// builder.create().show()
// }
// })
// }
// } catch (e: CreationException) {
// showInfoBox(R.string.sign_tos_failed)
// }
// }.start()
companion object {
private const val TAG = "TermsOfServiceDialog"
}
}

0 comments on commit cd7ad98

Please sign in to comment.