mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 04:13:53 +01:00
* Fixes bug causing the progress dialog to load forever (#5212) * Fixes bug causing the progress dialog to load forever (#5212) * remove unnecessary new line (#5212)
This commit is contained in:
parent
26eaa4650d
commit
988b83dc32
2 changed files with 21 additions and 13 deletions
|
|
@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
@ -49,21 +50,29 @@ public class NotificationHelper {
|
||||||
* @param intent the intent to be fired when the notification is clicked
|
* @param intent the intent to be fired when the notification is clicked
|
||||||
*/
|
*/
|
||||||
public void showNotification(Context context,
|
public void showNotification(Context context,
|
||||||
String notificationTitle,
|
String notificationTitle,
|
||||||
String notificationMessage,
|
String notificationMessage,
|
||||||
int notificationId,
|
int notificationId,
|
||||||
Intent intent) {
|
Intent intent) {
|
||||||
|
|
||||||
notificationBuilder.setDefaults(DEFAULT_ALL)
|
notificationBuilder.setDefaults(DEFAULT_ALL)
|
||||||
.setContentTitle(notificationTitle)
|
.setContentTitle(notificationTitle)
|
||||||
.setStyle(new NotificationCompat.BigTextStyle()
|
.setStyle(new NotificationCompat.BigTextStyle()
|
||||||
.bigText(notificationMessage))
|
.bigText(notificationMessage))
|
||||||
.setSmallIcon(R.drawable.ic_launcher)
|
.setSmallIcon(R.drawable.ic_launcher)
|
||||||
.setProgress(0, 0, false)
|
.setProgress(0, 0, false)
|
||||||
.setOngoing(false)
|
.setOngoing(false)
|
||||||
.setPriority(PRIORITY_HIGH);
|
.setPriority(PRIORITY_HIGH);
|
||||||
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
|
||||||
|
|
||||||
|
// Check if the API level is 31 or higher to modify the flag
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
// For API level 31 or above, PendingIntent requires either FLAG_IMMUTABLE or FLAG_MUTABLE to be set
|
||||||
|
flags |= PendingIntent.FLAG_IMMUTABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, flags);
|
||||||
notificationBuilder.setContentIntent(pendingIntent);
|
notificationBuilder.setContentIntent(pendingIntent);
|
||||||
notificationManager.notify(notificationId, notificationBuilder.build());
|
notificationManager.notify(notificationId, notificationBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,6 @@ class DepictsPresenter @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
repository.cleanup()
|
repository.cleanup()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue