1
0
Fork 0

Revert "For #11183: Redirect user to homescreen after widget added"

This reverts commit a8ed913654.
master
Sawyer Blatz 2020-07-02 10:48:35 -07:00
parent 3cbab45566
commit 8583cac8f8
1 changed files with 0 additions and 16 deletions

View File

@ -4,7 +4,6 @@
package org.mozilla.gecko.search
import android.app.ActivityManager
import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH
@ -37,21 +36,6 @@ class SearchWidgetProvider : AppWidgetProvider() {
override fun onEnabled(context: Context) {
context.settings().addSearchWidgetInstalled(1)
if (isAppInForeground(context)) {
val goHomeOnWidgetAdded = Intent(Intent.ACTION_MAIN)
goHomeOnWidgetAdded.addCategory(Intent.CATEGORY_HOME)
goHomeOnWidgetAdded.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(goHomeOnWidgetAdded)
}
}
// We need this because user can not add widget via launcher app without this
private fun isAppInForeground(context: Context): Boolean {
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val runningAppProcesses =
activityManager.runningAppProcesses ?: return false
return runningAppProcesses.any { it.processName == context.packageName &&
it.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND }
}
override fun onDeleted(context: Context, appWidgetIds: IntArray) {