Skip to content

Commit

Permalink
migrating from material preferences to native, squashed commit
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Linus julius.linus@nextcloud.com
  • Loading branch information
rapterjet2004 authored and mahibi committed Jun 27, 2023
1 parent 1b43d18 commit 943286d
Show file tree
Hide file tree
Showing 18 changed files with 1,269 additions and 1,393 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ configurations.all {
}

dependencies {
implementation 'androidx.preference:preference-ktx:1.2.0'
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.0")

implementation fileTree(include: ['*'], dir: 'libs')
Expand Down Expand Up @@ -236,7 +237,6 @@ dependencies {
implementation 'net.orange-box.storebox:storebox-lib:1.4.0'
implementation 'eu.davidea:flexible-adapter:5.1.0'
implementation 'eu.davidea:flexible-adapter-ui:1.0.0'
implementation 'com.yarolegovich:mp:1.1.6'
implementation 'me.zhanghai.android.effortlesspermissions:library:1.1.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.github.wooplr:Spotlight:1.3'
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.nextcloud.talk.conversationinfo

import android.annotation.SuppressLint
import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.SwitchCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.nextcloud.talk.R
import com.nextcloud.talk.data.user.model.User
Expand All @@ -34,45 +32,41 @@ class GuestAccessHelper(
private val context = activity.context

fun setupGuestAccess() {
val guestAccessAllowSwitch = (
binding.guestAccessView.allowGuestsSwitch
as SwitchCompat
)
val guestAccessPasswordSwitch = (
binding.guestAccessView.passwordProtectionSwitch
as SwitchCompat
)

if (conversation.canModerate(conversationUser)) {
binding.guestAccessView.guestAccessSettings.visibility = View.VISIBLE
} else {
binding.guestAccessView.guestAccessSettings.visibility = View.GONE
}

if (conversation.type == Conversation.ConversationType.ROOM_PUBLIC_CALL) {
guestAccessAllowSwitch.isChecked = true
binding.guestAccessView.allowGuestsSwitch.isChecked = true
showAllOptions()
if (conversation.hasPassword) {
guestAccessPasswordSwitch.isChecked = true
binding.guestAccessView.passwordProtectionSwitch.isChecked = true
}
} else {
guestAccessAllowSwitch.isChecked = false
binding.guestAccessView.allowGuestsSwitch.isChecked = false
hideAllOptions()
}

binding.guestAccessView.allowGuestsSwitch.setOnClickListener {
binding.guestAccessView.guestAccessSettingsAllowGuest.setOnClickListener {
val isChecked = binding.guestAccessView.allowGuestsSwitch.isChecked
binding.guestAccessView.allowGuestsSwitch.isChecked = !isChecked
conversationsRepository.allowGuests(
conversation.token!!,
!guestAccessAllowSwitch.isChecked
!isChecked
).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(AllowGuestsResultObserver())
}

binding.guestAccessView.passwordProtectionSwitch.setOnClickListener {
if (guestAccessPasswordSwitch.isChecked) {
binding.guestAccessView.guestAccessSettingsPasswordProtection.setOnClickListener {
val isChecked = binding.guestAccessView.passwordProtectionSwitch.isChecked
binding.guestAccessView.passwordProtectionSwitch.isChecked = !isChecked
if (isChecked) {
conversationsRepository.password("", conversation.token!!).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(PasswordResultObserver(false))
} else {
showPasswordDialog(guestAccessPasswordSwitch)
showPasswordDialog()
}
}

Expand All @@ -86,8 +80,7 @@ class GuestAccessHelper(
}
}

@SuppressLint("InflateParams")
private fun showPasswordDialog(guestAccessPasswordSwitch: SwitchCompat) {
private fun showPasswordDialog() {
val builder = MaterialAlertDialogBuilder(activity)
builder.apply {
val dialogPassword = DialogPasswordBinding.inflate(LayoutInflater.from(context))
Expand All @@ -102,7 +95,7 @@ class GuestAccessHelper(
.subscribe(PasswordResultObserver(true))
}
setNegativeButton(R.string.nc_cancel) { _, _ ->
guestAccessPasswordSwitch.isChecked = false
binding.guestAccessView.passwordProtectionSwitch.isChecked = false
}
}
createDialog(builder)
Expand Down Expand Up @@ -179,10 +172,7 @@ class GuestAccessHelper(
}

override fun onComplete() {
(
binding.guestAccessView.allowGuestsSwitch
as SwitchCompat
).isChecked = allowGuestsResult.allow
binding.guestAccessView.allowGuestsSwitch.isChecked = allowGuestsResult.allow
if (allowGuestsResult.allow) {
showAllOptions()
} else {
Expand Down Expand Up @@ -225,12 +215,7 @@ class GuestAccessHelper(
}

override fun onComplete() {
val guestAccessPasswordSwitch = (
binding.guestAccessView.passwordProtectionSwitch
as SwitchCompat
)
guestAccessPasswordSwitch.isChecked = passwordResult.passwordSet && setPassword

binding.guestAccessView.passwordProtectionSwitch.isChecked = passwordResult.passwordSet && setPassword
if (passwordResult.passwordIsWeak) {
val builder = MaterialAlertDialogBuilder(activity)
builder.apply {
Expand Down
Loading

0 comments on commit 943286d

Please sign in to comment.