Remove ShortcutBadger lib and usage (it was dead code)

This commit is contained in:
Benoit Marty 2022-05-18 09:05:26 +02:00 committed by Benoit Marty
parent 8f7789f269
commit adb537006a
5 changed files with 1 additions and 138 deletions

1
changelog.d/6041.misc Normal file
View File

@ -0,0 +1 @@
Remove ShortcutBadger lib and usage (it was dead code)

View File

@ -141,7 +141,6 @@ ext.groups = [
'jline',
'jp.wasabeef',
'junit',
'me.leolin',
'me.saket',
'net.bytebuddy',
'net.java',

View File

@ -452,9 +452,6 @@ dependencies {
kapt libs.github.glideCompiler
implementation 'com.github.yalantis:ucrop:2.2.8'
// Badge for compatibility
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
// Chat effects
implementation 'nl.dionsegijn:konfetti-xml:2.0.2'

View File

@ -369,11 +369,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<br/>
Copyright 2012 Square, Inc.
</li>
<li>
<b>ShortcutBadger</b>
<br/>
Copyright 2014 Leo Lin
</li>
<li>
<b>diff-match-patch</b>
<br/>

View File

@ -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)
}
*/
}
}