Skip to content

Commit cd7ad98

Browse files
tobiasKaminskyalperozturk96
authored andcommitted
crash
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 3345422 commit cd7ad98

File tree

1 file changed

+12
-66
lines changed

1 file changed

+12
-66
lines changed

app/src/main/java/com/owncloud/android/ui/dialog/TermsOfServiceDialog.kt

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import android.os.Bundle
1212
import android.view.View
1313
import android.widget.AdapterView
1414
import android.widget.ArrayAdapter
15+
import androidx.core.app.ActivityCompat.finishAffinity
1516
import androidx.fragment.app.DialogFragment
1617
import com.google.android.material.dialog.MaterialAlertDialogBuilder
1718
import com.nextcloud.android.lib.resources.tos.GetTermsRemoteOperation
@@ -25,6 +26,7 @@ import com.nextcloud.utils.extensions.setHtmlContent
2526
import com.owncloud.android.R
2627
import com.owncloud.android.databinding.DialogShowTosBinding
2728
import com.owncloud.android.lib.common.operations.RemoteOperationResult
29+
import com.owncloud.android.lib.common.utils.Log_OC
2830
import com.owncloud.android.utils.DisplayUtils
2931
import com.owncloud.android.utils.theme.ViewThemeUtils
3032
import kotlinx.coroutines.CoroutineScope
@@ -61,11 +63,6 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
6163
}
6264

6365
private fun updateDialog() {
64-
// viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
65-
// binding.root.context,
66-
// builder
67-
// )
68-
6966
binding.message.setHtmlContent(terms[0].renderedBody)
7067

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

89-
override fun onNothingSelected(adapterView: AdapterView<*>?) {
90-
// nothing to do
91-
}
86+
override fun onNothingSelected(adapterView: AdapterView<*>?) = Unit
9287
}
9388

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

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

112108
CoroutineScope(Dispatchers.Main).launch {
109+
// withContext(Dispatchers.Main) {
113110
updateDialog()
114111
}
115112
}
116113
} catch (exception: ClientFactory.CreationException) {
117-
TODO("Add error handling here")
114+
Log_OC.e(TAG, "Error creating client!")
118115
}
119116
}
120117
}
@@ -123,10 +120,10 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
123120
return MaterialAlertDialogBuilder(binding.root.context)
124121
.setView(binding.root)
125122
.setTitle(R.string.terms_of_service_title)
126-
.setNegativeButton(R.string.dialog_close) { dialog, which ->
127-
// TODO finishAffinity()
123+
.setNegativeButton(R.string.dialog_close) { _, _ ->
124+
activity?.let { finishAffinity(it) }
128125
}
129-
.setPositiveButton(R.string.terms_of_services_agree) { dialog, which ->
126+
.setPositiveButton(R.string.terms_of_services_agree) { dialog, _ ->
130127
dialog.dismiss()
131128
Thread {
132129
val id = binding.languageDropdown.selectedItemPosition
@@ -139,58 +136,7 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
139136
}
140137
}
141138

142-
// private void showTermsOfServiceDialog1()
143-
// {
144-
145-
// runOnUiThread(Runnable {
146-
// viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
147-
// binding.root.context,
148-
// builder
149-
// )
150-
// builder.create()
151-
//
152-
// binding.message.setHtmlContent(terms[0].renderedBody)
153-
//
154-
// val arrayAdapter: ArrayAdapter<String> = ArrayAdapter(
155-
// binding.root.context,
156-
// android.R.layout.simple_spinner_item
157-
// )
158-
//
159-
// for ((_, _, languageCode) in terms) {
160-
// arrayAdapter.add(languages[languageCode])
161-
// }
162-
//
163-
// arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
164-
//
165-
//
166-
// binding.languageDropdown.adapter = arrayAdapter
167-
// binding.languageDropdown.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
168-
// override fun onItemSelected(
169-
// adapterView: AdapterView<*>?,
170-
// view: View,
171-
// position: Int,
172-
// l: Long
173-
// ) {
174-
// binding.message
175-
// .setHtmlContent(terms[position].renderedBody)
176-
// }
177-
//
178-
// override fun onNothingSelected(adapterView: AdapterView<*>?) {
179-
// // nothing to do
180-
// }
181-
// }
182-
//
183-
// if (terms.size == 1) {
184-
// binding.languageDropdown.visibility = View.GONE
185-
// }
186-
// if (!tosIsShown) {
187-
// tosIsShown = true
188-
// builder.create().show()
189-
// }
190-
// })
191-
// }
192-
// } catch (e: CreationException) {
193-
// showInfoBox(R.string.sign_tos_failed)
194-
// }
195-
// }.start()
139+
companion object {
140+
private const val TAG = "TermsOfServiceDialog"
141+
}
196142
}

0 commit comments

Comments
 (0)