Loading core/java/android/provider/Settings.java +24 −0 Original line number Diff line number Diff line Loading @@ -1757,6 +1757,30 @@ public final class Settings { */ public static final String SELECTED_CUSTOM_APP = "selected_custom_app"; /** * Specifies whether or not to use a custom app on search key press * @hide */ public static final String USE_CUSTOM_SEARCH_APP_TOGGLE = "use_custom_search_app_toggle"; /** * Contains activity to start on search key press * @hide */ public static final String USE_CUSTOM_SEARCH_APP_ACTIVITY = "use_custom_search_app_activity"; /** * Specifies whether or not to use a custom app on long search key press * @hide */ public static final String USE_CUSTOM_LONG_SEARCH_APP_TOGGLE = "use_custom_long_search_app_toggle"; /** * Contains activity to start on long search key press * @hide */ public static final String USE_CUSTOM_LONG_SEARCH_APP_ACTIVITY = "use_custom_long_search_app_activity"; /** * Stores the uri of the defined application for user key 1 * @hide Loading policy/src/com/android/internal/policy/impl/PhoneWindow.java +41 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.internal.view.menu.SubMenuBuilder; import android.app.KeyguardManager; import android.app.SearchManager; import android.content.ActivityNotFoundException; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; Loading @@ -47,6 +48,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.AndroidRuntimeException; import android.util.Config; Loading Loading @@ -79,6 +81,8 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import java.net.URISyntaxException; /** * Android-specific Window. * <p> Loading Loading @@ -1250,6 +1254,17 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (event.getRepeatCount() == 0) { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { // start custom app boolean mCustomLongSearchAppToggle=(Settings.System.getInt(getContext().getContentResolver(), Settings.System.USE_CUSTOM_LONG_SEARCH_APP_TOGGLE, 0) == 1); if(mCustomLongSearchAppToggle){ runCustomApp(Settings.System.getString(getContext().getContentResolver(), Settings.System.USE_CUSTOM_LONG_SEARCH_APP_ACTIVITY)); break; } // default behavior Configuration config = getContext().getResources().getConfiguration(); if (config.keyboard == Configuration.KEYBOARD_NOKEYS || config.hardKeyboardHidden Loading Loading @@ -1401,6 +1416,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { break; } if (event.isTracking() && !event.isCanceled()) { boolean mCustomSearchAppToggle=(Settings.System.getInt(getContext().getContentResolver(), Settings.System.USE_CUSTOM_SEARCH_APP_TOGGLE, 0) == 1); if(mCustomSearchAppToggle) runCustomApp(Settings.System.getString(getContext().getContentResolver(), Settings.System.USE_CUSTOM_SEARCH_APP_ACTIVITY)); else launchDefaultSearch(); } return true; Loading Loading @@ -2807,4 +2829,21 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { void sendCloseSystemWindows(String reason) { PhoneWindowManager.sendCloseSystemWindows(getContext(), reason); } void runCustomApp(String uri) { if (uri != null) { try { Intent i = Intent.parseUri(uri, 0); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); getContext().startActivity(i); } catch (URISyntaxException e) { } catch (ActivityNotFoundException e) { } } } } Loading
core/java/android/provider/Settings.java +24 −0 Original line number Diff line number Diff line Loading @@ -1757,6 +1757,30 @@ public final class Settings { */ public static final String SELECTED_CUSTOM_APP = "selected_custom_app"; /** * Specifies whether or not to use a custom app on search key press * @hide */ public static final String USE_CUSTOM_SEARCH_APP_TOGGLE = "use_custom_search_app_toggle"; /** * Contains activity to start on search key press * @hide */ public static final String USE_CUSTOM_SEARCH_APP_ACTIVITY = "use_custom_search_app_activity"; /** * Specifies whether or not to use a custom app on long search key press * @hide */ public static final String USE_CUSTOM_LONG_SEARCH_APP_TOGGLE = "use_custom_long_search_app_toggle"; /** * Contains activity to start on long search key press * @hide */ public static final String USE_CUSTOM_LONG_SEARCH_APP_ACTIVITY = "use_custom_long_search_app_activity"; /** * Stores the uri of the defined application for user key 1 * @hide Loading
policy/src/com/android/internal/policy/impl/PhoneWindow.java +41 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import com.android.internal.view.menu.SubMenuBuilder; import android.app.KeyguardManager; import android.app.SearchManager; import android.content.ActivityNotFoundException; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; Loading @@ -47,6 +48,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.SystemClock; import android.provider.Settings; import android.telephony.TelephonyManager; import android.util.AndroidRuntimeException; import android.util.Config; Loading Loading @@ -79,6 +81,8 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import java.net.URISyntaxException; /** * Android-specific Window. * <p> Loading Loading @@ -1250,6 +1254,17 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (event.getRepeatCount() == 0) { dispatcher.startTracking(event, this); } else if (event.isLongPress() && dispatcher.isTracking(event)) { // start custom app boolean mCustomLongSearchAppToggle=(Settings.System.getInt(getContext().getContentResolver(), Settings.System.USE_CUSTOM_LONG_SEARCH_APP_TOGGLE, 0) == 1); if(mCustomLongSearchAppToggle){ runCustomApp(Settings.System.getString(getContext().getContentResolver(), Settings.System.USE_CUSTOM_LONG_SEARCH_APP_ACTIVITY)); break; } // default behavior Configuration config = getContext().getResources().getConfiguration(); if (config.keyboard == Configuration.KEYBOARD_NOKEYS || config.hardKeyboardHidden Loading Loading @@ -1401,6 +1416,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { break; } if (event.isTracking() && !event.isCanceled()) { boolean mCustomSearchAppToggle=(Settings.System.getInt(getContext().getContentResolver(), Settings.System.USE_CUSTOM_SEARCH_APP_TOGGLE, 0) == 1); if(mCustomSearchAppToggle) runCustomApp(Settings.System.getString(getContext().getContentResolver(), Settings.System.USE_CUSTOM_SEARCH_APP_ACTIVITY)); else launchDefaultSearch(); } return true; Loading Loading @@ -2807,4 +2829,21 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { void sendCloseSystemWindows(String reason) { PhoneWindowManager.sendCloseSystemWindows(getContext(), reason); } void runCustomApp(String uri) { if (uri != null) { try { Intent i = Intent.parseUri(uri, 0); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); getContext().startActivity(i); } catch (URISyntaxException e) { } catch (ActivityNotFoundException e) { } } } }