Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93a751d6 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 23979 into eclair

* changes:
  Do a better job at finding the activity associated with a dialog when triggering search.
parents 1e52988a 7bafed86
Loading
Loading
Loading
Loading
+20 −2
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.internal.policy.PolicyManager;
import android.content.Context;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface;
import android.content.ComponentName;
import android.content.ComponentName;
import android.content.ContextWrapper;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.net.Uri;
import android.os.Bundle;
import android.os.Bundle;
@@ -801,14 +802,31 @@ public class Dialog implements DialogInterface, Window.Callback,


        // associate search with owner activity if possible (otherwise it will default to
        // associate search with owner activity if possible (otherwise it will default to
        // global search).
        // global search).
        final ComponentName appName = mOwnerActivity == null ? null
        final ComponentName appName = getAssociatedActivity();
                : mOwnerActivity.getComponentName();
        final boolean globalSearch = (appName == null);
        final boolean globalSearch = (appName == null);
        searchManager.startSearch(null, false, appName, null, globalSearch);
        searchManager.startSearch(null, false, appName, null, globalSearch);
        dismiss();
        dismiss();
        return true;
        return true;
    }
    }


    /**
     * @return The activity associated with this dialog, or null if there is no assocaited activity.
     */
    private ComponentName getAssociatedActivity() {
        Activity activity = mOwnerActivity;
        Context context = getContext();
        while (activity == null && context != null) {
            if (context instanceof Activity) {
                activity = (Activity) context;  // found it!
            } else {
                context = (context instanceof ContextWrapper) ?
                        ((ContextWrapper) context).getBaseContext() : // unwrap one level
                        null;                                         // done
            }
        }
        return activity == null ? null : activity.getComponentName();
    }



    /**
    /**
     * Request that key events come to this dialog. Use this if your
     * Request that key events come to this dialog. Use this if your