Skip to content

Commit

Permalink
Merge pull request #3940 from nextcloud/backport/3939/stable-19.0
Browse files Browse the repository at this point in the history
[stable-19.0] hide logos for conversation list and lockscreen if app is not nextcloud
  • Loading branch information
mahibi authored May 24, 2024
2 parents c9f23f9 + 9e7d52c commit fc79dc8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import com.nextcloud.talk.ui.dialog.ConversationsListBottomDialog
import com.nextcloud.talk.ui.dialog.FilterConversationFragment
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.BrandingUtils
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
import com.nextcloud.talk.utils.CapabilitiesUtil.isServerEOL
import com.nextcloud.talk.utils.CapabilitiesUtil.isUnifiedSearchAvailable
Expand Down Expand Up @@ -959,6 +960,8 @@ class ConversationsListActivity :

@SuppressLint("ClickableViewAccessibility")
private fun prepareViews() {
hideLogoForBrandedClients()

layoutManager = SmoothScrollLinearLayoutManager(this)
binding.recyclerView.layoutManager = layoutManager
binding.recyclerView.setHasFixedSize(true)
Expand Down Expand Up @@ -1019,6 +1022,12 @@ class ConversationsListActivity :
binding?.newMentionPopupBubble?.let { viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it) }
}

private fun hideLogoForBrandedClients() {
if (!BrandingUtils.isOriginalNextcloudClient(applicationContext)) {
binding.emptyListIcon.visibility = View.GONE
}
}

@SuppressLint("CheckResult")
@Suppress("Detekt.TooGenericExceptionCaught")
private fun checkToShowUnreadBubble() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.arbitrarystorage.ArbitraryStorageManager
import com.nextcloud.talk.databinding.ActivityDiagnoseBinding
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.BrandingUtils
import com.nextcloud.talk.utils.ClosedInterfaceImpl
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.NotificationUtils
Expand Down Expand Up @@ -115,8 +116,7 @@ class DiagnoseActivity : BaseActivity() {

override fun onPrepareOptionsMenu(menu: Menu): Boolean {
super.onPrepareOptionsMenu(menu)
menu.findItem(R.id.create_issue).isVisible =
applicationContext.packageName.equals(ORIGINAL_NEXTCLOUD_TALK_APPLICATION_ID)
menu.findItem(R.id.create_issue).isVisible = BrandingUtils.isOriginalNextcloudClient(applicationContext)
return true
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/nextcloud/talk/lock/LockedActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.app.KeyguardManager
import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -21,6 +22,7 @@ import autodagger.AutoInjector
import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.databinding.ActivityLockedBinding
import com.nextcloud.talk.utils.BrandingUtils
import com.nextcloud.talk.utils.SecurityUtils
import com.nextcloud.talk.utils.preferences.AppPreferences
import java.util.concurrent.Executor
Expand Down Expand Up @@ -55,13 +57,20 @@ class LockedActivity : AppCompatActivity() {

override fun onResume() {
super.onResume()
hideLogoForBrandedClients()

binding.unlockContainer.setOnClickListener {
checkIfWeAreSecure()
}
checkIfWeAreSecure()
}

private fun hideLogoForBrandedClients() {
if (!BrandingUtils.isOriginalNextcloudClient(applicationContext)) {
binding.appLogo.visibility = View.GONE
}
}

private fun checkIfWeAreSecure() {
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager?
if (keyguardManager?.isKeyguardSecure == true && appPreferences.isScreenLocked) {
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/nextcloud/talk/utils/BrandingUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2024 Marcel Hibbe <[email protected]>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.utils

import android.content.Context

object BrandingUtils {
private const val ORIGINAL_NEXTCLOUD_TALK_APPLICATION_ID = "com.nextcloud.talk2"

fun isOriginalNextcloudClient(context: Context): Boolean {
return context.packageName.equals(ORIGINAL_NEXTCLOUD_TALK_APPLICATION_ID)
}
}

0 comments on commit fc79dc8

Please sign in to comment.