Skip to content

Commit

Permalink
Revert "For mozilla-mobile#11183: Redirect user to homescreen after w…
Browse files Browse the repository at this point in the history
…idget added"

This reverts commit a8ed913.
  • Loading branch information
sblatz committed Jul 2, 2020
1 parent 3cbab45 commit 8583cac
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions app/src/main/java/org/mozilla/gecko/search/SearchWidgetProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8583cac

Please sign in to comment.