Merge pull request #6083 from vector-im/feature/bma/remove_badge
Remove ShortcutBadger lib and usage (it was dead code)
This commit is contained in:
commit
7ae3f6ea40
|
@ -0,0 +1 @@
|
||||||
|
Remove ShortcutBadger lib and usage (it was dead code)
|
|
@ -141,7 +141,6 @@ ext.groups = [
|
||||||
'jline',
|
'jline',
|
||||||
'jp.wasabeef',
|
'jp.wasabeef',
|
||||||
'junit',
|
'junit',
|
||||||
'me.leolin',
|
|
||||||
'me.saket',
|
'me.saket',
|
||||||
'net.bytebuddy',
|
'net.bytebuddy',
|
||||||
'net.java',
|
'net.java',
|
||||||
|
|
|
@ -452,9 +452,6 @@ dependencies {
|
||||||
kapt libs.github.glideCompiler
|
kapt libs.github.glideCompiler
|
||||||
implementation 'com.github.yalantis:ucrop:2.2.8'
|
implementation 'com.github.yalantis:ucrop:2.2.8'
|
||||||
|
|
||||||
// Badge for compatibility
|
|
||||||
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
|
|
||||||
|
|
||||||
// Chat effects
|
// Chat effects
|
||||||
implementation 'nl.dionsegijn:konfetti-xml:2.0.2'
|
implementation 'nl.dionsegijn:konfetti-xml:2.0.2'
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2019 New Vector Ltd
|
* Copyright 2019 New Vector Ltd
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -32,7 +29,6 @@ import im.vector.app.BuildConfig
|
||||||
import im.vector.app.core.di.ActiveSessionHolder
|
import im.vector.app.core.di.ActiveSessionHolder
|
||||||
import im.vector.app.core.network.WifiDetector
|
import im.vector.app.core.network.WifiDetector
|
||||||
import im.vector.app.core.pushers.PushersManager
|
import im.vector.app.core.pushers.PushersManager
|
||||||
import im.vector.app.features.badge.BadgeProxy
|
|
||||||
import im.vector.app.features.notifications.NotifiableEventResolver
|
import im.vector.app.features.notifications.NotifiableEventResolver
|
||||||
import im.vector.app.features.notifications.NotificationDrawerManager
|
import im.vector.app.features.notifications.NotificationDrawerManager
|
||||||
import im.vector.app.features.notifications.NotificationUtils
|
import im.vector.app.features.notifications.NotificationUtils
|
||||||
|
@ -152,10 +148,6 @@ class VectorFirebaseMessagingService : FirebaseMessagingService() {
|
||||||
Timber.tag(loggerTag.value).d("## onMessageReceivedInternal()")
|
Timber.tag(loggerTag.value).d("## onMessageReceivedInternal()")
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the badge counter
|
|
||||||
val unreadCount = data["unread"]?.let { Integer.parseInt(it) } ?: 0
|
|
||||||
BadgeProxy.updateBadgeCount(applicationContext, unreadCount)
|
|
||||||
|
|
||||||
val session = activeSessionHolder.getSafeActiveSession()
|
val session = activeSessionHolder.getSafeActiveSession()
|
||||||
|
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
|
|
|
@ -369,11 +369,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
<br/>
|
<br/>
|
||||||
Copyright 2012 Square, Inc.
|
Copyright 2012 Square, Inc.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<b>ShortcutBadger</b>
|
|
||||||
<br/>
|
|
||||||
Copyright 2014 Leo Lin
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<b>diff-match-patch</b>
|
<b>diff-match-patch</b>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2019 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@file:Suppress("UNUSED_PARAMETER")
|
|
||||||
|
|
||||||
package im.vector.app.features.badge
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Build
|
|
||||||
import me.leolin.shortcutbadger.ShortcutBadger
|
|
||||||
import org.matrix.android.sdk.api.session.Session
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage application badge (displayed in the launcher).
|
|
||||||
*/
|
|
||||||
object BadgeProxy {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Badge is now managed by notification channel, so no need to use compatibility library in recent versions.
|
|
||||||
*
|
|
||||||
* @return true if library ShortcutBadger can be used
|
|
||||||
*/
|
|
||||||
private fun useShortcutBadger() = Build.VERSION.SDK_INT < Build.VERSION_CODES.O
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the application badge value.
|
|
||||||
*
|
|
||||||
* @param context the context
|
|
||||||
* @param badgeValue the new badge value
|
|
||||||
*/
|
|
||||||
fun updateBadgeCount(context: Context, badgeValue: Int) {
|
|
||||||
if (!useShortcutBadger()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ShortcutBadger.applyCount(context, badgeValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh the badge count for specific configurations.<br></br>
|
|
||||||
* The refresh is only effective if the device is:
|
|
||||||
* * offline * does not support FCM
|
|
||||||
* * FCM registration failed
|
|
||||||
* <br></br>Notifications rooms are parsed to track the notification count value.
|
|
||||||
*
|
|
||||||
* @param aSession session value
|
|
||||||
* @param aContext App context
|
|
||||||
*/
|
|
||||||
fun specificUpdateBadgeUnreadCount(aSession: Session?, aContext: Context?) {
|
|
||||||
if (!useShortcutBadger()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
val dataHandler: MXDataHandler
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if (null == aContext || null == aSession) {
|
|
||||||
Timber.w("## specificUpdateBadgeUnreadCount(): invalid input null values")
|
|
||||||
} else {
|
|
||||||
dataHandler = aSession.dataHandler
|
|
||||||
|
|
||||||
if (dataHandler == null) {
|
|
||||||
Timber.w("## specificUpdateBadgeUnreadCount(): invalid DataHandler instance")
|
|
||||||
} else {
|
|
||||||
if (aSession.isAlive) {
|
|
||||||
var isRefreshRequired: Boolean
|
|
||||||
val pushManager = Matrix.getInstance(aContext)!!.pushManager
|
|
||||||
|
|
||||||
// update the badge count if the device is offline, FCM is not supported or FCM registration failed
|
|
||||||
isRefreshRequired = !Matrix.getInstance(aContext)!!.isConnected
|
|
||||||
isRefreshRequired = isRefreshRequired or (null != pushManager && (!pushManager.useFcm() || !pushManager.hasRegistrationToken()))
|
|
||||||
|
|
||||||
if (isRefreshRequired) {
|
|
||||||
updateBadgeCount(aContext, dataHandler)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the badge count value according to the rooms content.
|
|
||||||
*
|
|
||||||
* @param aContext App context
|
|
||||||
* @param aDataHandler data handler instance
|
|
||||||
*/
|
|
||||||
private fun updateBadgeCount(aSession: Session?, aContext: Context?) {
|
|
||||||
if (!useShortcutBadger()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
//sanity check
|
|
||||||
if (null == aContext || null == aDataHandler) {
|
|
||||||
Timber.w("## updateBadgeCount(): invalid input null values")
|
|
||||||
} else if (null == aDataHandler.store) {
|
|
||||||
Timber.w("## updateBadgeCount(): invalid store instance")
|
|
||||||
} else {
|
|
||||||
val roomCompleteList = ArrayList(aDataHandler.store.rooms)
|
|
||||||
var unreadRoomsCount = 0
|
|
||||||
|
|
||||||
for (room in roomCompleteList) {
|
|
||||||
if (room.notificationCount > 0) {
|
|
||||||
unreadRoomsCount++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update the badge counter
|
|
||||||
Timber.v("## updateBadgeCount(): badge update count=$unreadRoomsCount")
|
|
||||||
updateBadgeCount(aContext, unreadRoomsCount)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue