Skip to content

Commit 3345422

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

File tree

1 file changed

+67
-13
lines changed

1 file changed

+67
-13
lines changed

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

+67-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ 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
1615
import androidx.fragment.app.DialogFragment
1716
import com.google.android.material.dialog.MaterialAlertDialogBuilder
1817
import com.nextcloud.android.lib.resources.tos.GetTermsRemoteOperation
@@ -26,13 +25,11 @@ import com.nextcloud.utils.extensions.setHtmlContent
2625
import com.owncloud.android.R
2726
import com.owncloud.android.databinding.DialogShowTosBinding
2827
import com.owncloud.android.lib.common.operations.RemoteOperationResult
29-
import com.owncloud.android.lib.common.utils.Log_OC
3028
import com.owncloud.android.utils.DisplayUtils
3129
import com.owncloud.android.utils.theme.ViewThemeUtils
3230
import kotlinx.coroutines.CoroutineScope
3331
import kotlinx.coroutines.Dispatchers
3432
import kotlinx.coroutines.launch
35-
import kotlinx.coroutines.withContext
3633
import javax.inject.Inject
3734

3835
class TermsOfServiceDialog : DialogFragment(), Injectable {
@@ -64,6 +61,11 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
6461
}
6562

6663
private fun updateDialog() {
64+
// viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
65+
// binding.root.context,
66+
// builder
67+
// )
68+
6769
binding.message.setHtmlContent(terms[0].renderedBody)
6870

6971
val arrayAdapter: ArrayAdapter<String> = ArrayAdapter(
@@ -84,7 +86,9 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
8486
.setHtmlContent(terms[position].renderedBody)
8587
}
8688

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

9094
if (terms.size == 1) {
@@ -93,7 +97,6 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
9397
}
9498

9599
private fun fetchTerms() {
96-
// TODO use viewLifecycleOwner instead
97100
CoroutineScope(Dispatchers.IO).launch {
98101
try {
99102
client = clientFactory.createNextcloudClient(accountManager.getUser())
@@ -106,12 +109,12 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
106109
languages = result.resultData.languages
107110
terms = result.resultData.terms
108111

109-
withContext(Dispatchers.Main) {
112+
CoroutineScope(Dispatchers.Main).launch {
110113
updateDialog()
111114
}
112115
}
113116
} catch (exception: ClientFactory.CreationException) {
114-
Log_OC.e(TAG, "Error creating client!")
117+
TODO("Add error handling here")
115118
}
116119
}
117120
}
@@ -120,10 +123,10 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
120123
return MaterialAlertDialogBuilder(binding.root.context)
121124
.setView(binding.root)
122125
.setTitle(R.string.terms_of_service_title)
123-
.setNegativeButton(R.string.dialog_close) { _, _ ->
124-
activity?.let { finishAffinity(it) }
126+
.setNegativeButton(R.string.dialog_close) { dialog, which ->
127+
// TODO finishAffinity()
125128
}
126-
.setPositiveButton(R.string.terms_of_services_agree) { dialog, _ ->
129+
.setPositiveButton(R.string.terms_of_services_agree) { dialog, which ->
127130
dialog.dismiss()
128131
Thread {
129132
val id = binding.languageDropdown.selectedItemPosition
@@ -136,7 +139,58 @@ class TermsOfServiceDialog : DialogFragment(), Injectable {
136139
}
137140
}
138141

139-
companion object {
140-
private const val TAG = "TermsOfServiceDialog"
141-
}
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()
142196
}

0 commit comments

Comments
 (0)