mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-02 15:15:09 +00:00
refactor getTickerText
This commit is contained in:
@@ -489,16 +489,13 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
|||||||
* instead the ticker text.
|
* instead the ticker text.
|
||||||
*/
|
*/
|
||||||
private String getTickerText(Notification notification) {
|
private String getTickerText(Notification notification) {
|
||||||
final String TITLE_KEY = "android.title";
|
|
||||||
final String TEXT_KEY = "android.text";
|
|
||||||
String ticker = "";
|
String ticker = "";
|
||||||
|
|
||||||
if (notification != null) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
try {
|
try {
|
||||||
Bundle extras = notification.extras;
|
Bundle extras = notification.extras;
|
||||||
String extraTitle = extractStringFromExtra(extras, TITLE_KEY);
|
String extraTitle = extractStringFromExtra(extras, Notification.EXTRA_TITLE);
|
||||||
String extraText = extractStringFromExtra(extras, TEXT_KEY);
|
String extraText = extractStringFromExtra(extras, Notification.EXTRA_TEXT);
|
||||||
|
|
||||||
if (extraTitle != null && extraText != null && !extraText.isEmpty()) {
|
if (extraTitle != null && extraText != null && !extraText.isEmpty()) {
|
||||||
ticker = extraTitle + ": " + extraText;
|
ticker = extraTitle + ": " + extraText;
|
||||||
@@ -515,7 +512,6 @@ public class NotificationsPlugin extends Plugin implements NotificationReceiver.
|
|||||||
if (ticker.isEmpty()) {
|
if (ticker.isEmpty()) {
|
||||||
ticker = (notification.tickerText != null) ? notification.tickerText.toString() : "";
|
ticker = (notification.tickerText != null) ? notification.tickerText.toString() : "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ticker;
|
return ticker;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user