Loading packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarFacetButton.java +18 −8 Original line number Diff line number Diff line Loading @@ -110,24 +110,34 @@ public class CarFacetButton extends LinearLayout { mComponentNames = componentNameString.split(FACET_FILTER_DELIMITER); } setOnClickListener(v -> { intent.putExtra(EXTRA_FACET_LAUNCH_PICKER, mSelected); mContext.startActivityAsUser(intent, UserHandle.CURRENT); }); setOnClickListener(getButtonClickListener(intent)); if (longPressIntentString != null) { final Intent longPressIntent = Intent.parseUri(longPressIntentString, Intent.URI_INTENT_SCHEME); setOnLongClickListener(v -> { mContext.startActivityAsUser(longPressIntent, UserHandle.CURRENT); return true; }); setOnLongClickListener(getButtonLongClickListener(longPressIntent)); } } catch (Exception e) { throw new RuntimeException("Failed to attach intent", e); } } /** Defines the behavior of a button click. */ protected OnClickListener getButtonClickListener(Intent toSend) { return v -> { toSend.putExtra(EXTRA_FACET_LAUNCH_PICKER, mSelected); mContext.startActivityAsUser(toSend, UserHandle.CURRENT); }; } /** Defines the behavior of a long click. */ protected OnLongClickListener getButtonLongClickListener(Intent toSend) { return v -> { mContext.startActivityAsUser(toSend, UserHandle.CURRENT); return true; }; } private void setupIcons(TypedArray styledAttributes) { mSelectedAlpha = styledAttributes.getFloat( R.styleable.CarFacetButton_selectedAlpha, mSelectedAlpha); Loading packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarNavigationButton.java +30 −20 Original line number Diff line number Diff line Loading @@ -90,38 +90,48 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag try { if (mIntent != null) { final Intent intent = Intent.parseUri(mIntent, Intent.URI_INTENT_SCHEME); setOnClickListener(v -> { setOnClickListener(getButtonClickListener(intent)); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach intent", e); } try { if (mLongIntent != null) { final Intent intent = Intent.parseUri(mLongIntent, Intent.URI_INTENT_SCHEME); setOnLongClickListener(getButtonLongClickListener(intent)); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach long press intent", e); } } /** Defines the behavior of a button click. */ protected OnClickListener getButtonClickListener(Intent toSend) { return v -> { try { if (mBroadcastIntent) { mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); mContext.sendBroadcastAsUser(toSend, UserHandle.CURRENT); return; } mContext.startActivityAsUser(intent, UserHandle.CURRENT); mContext.startActivityAsUser(toSend, UserHandle.CURRENT); } catch (Exception e) { Log.e(TAG, "Failed to launch intent", e); } }); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach intent", e); }; } /** Defines the behavior of a long click. */ protected OnLongClickListener getButtonLongClickListener(Intent toSend) { return v -> { try { if (mLongIntent != null) { final Intent intent = Intent.parseUri(mLongIntent, Intent.URI_INTENT_SCHEME); setOnLongClickListener(v -> { try { mContext.startActivityAsUser(intent, UserHandle.CURRENT); mContext.startActivityAsUser(toSend, UserHandle.CURRENT); } catch (Exception e) { Log.e(TAG, "Failed to launch intent", e); } // consume event either way return true; }); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach long press intent", e); } }; } /** Loading Loading
packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarFacetButton.java +18 −8 Original line number Diff line number Diff line Loading @@ -110,24 +110,34 @@ public class CarFacetButton extends LinearLayout { mComponentNames = componentNameString.split(FACET_FILTER_DELIMITER); } setOnClickListener(v -> { intent.putExtra(EXTRA_FACET_LAUNCH_PICKER, mSelected); mContext.startActivityAsUser(intent, UserHandle.CURRENT); }); setOnClickListener(getButtonClickListener(intent)); if (longPressIntentString != null) { final Intent longPressIntent = Intent.parseUri(longPressIntentString, Intent.URI_INTENT_SCHEME); setOnLongClickListener(v -> { mContext.startActivityAsUser(longPressIntent, UserHandle.CURRENT); return true; }); setOnLongClickListener(getButtonLongClickListener(longPressIntent)); } } catch (Exception e) { throw new RuntimeException("Failed to attach intent", e); } } /** Defines the behavior of a button click. */ protected OnClickListener getButtonClickListener(Intent toSend) { return v -> { toSend.putExtra(EXTRA_FACET_LAUNCH_PICKER, mSelected); mContext.startActivityAsUser(toSend, UserHandle.CURRENT); }; } /** Defines the behavior of a long click. */ protected OnLongClickListener getButtonLongClickListener(Intent toSend) { return v -> { mContext.startActivityAsUser(toSend, UserHandle.CURRENT); return true; }; } private void setupIcons(TypedArray styledAttributes) { mSelectedAlpha = styledAttributes.getFloat( R.styleable.CarFacetButton_selectedAlpha, mSelectedAlpha); Loading
packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarNavigationButton.java +30 −20 Original line number Diff line number Diff line Loading @@ -90,38 +90,48 @@ public class CarNavigationButton extends com.android.keyguard.AlphaOptimizedImag try { if (mIntent != null) { final Intent intent = Intent.parseUri(mIntent, Intent.URI_INTENT_SCHEME); setOnClickListener(v -> { setOnClickListener(getButtonClickListener(intent)); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach intent", e); } try { if (mLongIntent != null) { final Intent intent = Intent.parseUri(mLongIntent, Intent.URI_INTENT_SCHEME); setOnLongClickListener(getButtonLongClickListener(intent)); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach long press intent", e); } } /** Defines the behavior of a button click. */ protected OnClickListener getButtonClickListener(Intent toSend) { return v -> { try { if (mBroadcastIntent) { mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); mContext.sendBroadcastAsUser(toSend, UserHandle.CURRENT); return; } mContext.startActivityAsUser(intent, UserHandle.CURRENT); mContext.startActivityAsUser(toSend, UserHandle.CURRENT); } catch (Exception e) { Log.e(TAG, "Failed to launch intent", e); } }); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach intent", e); }; } /** Defines the behavior of a long click. */ protected OnLongClickListener getButtonLongClickListener(Intent toSend) { return v -> { try { if (mLongIntent != null) { final Intent intent = Intent.parseUri(mLongIntent, Intent.URI_INTENT_SCHEME); setOnLongClickListener(v -> { try { mContext.startActivityAsUser(intent, UserHandle.CURRENT); mContext.startActivityAsUser(toSend, UserHandle.CURRENT); } catch (Exception e) { Log.e(TAG, "Failed to launch intent", e); } // consume event either way return true; }); } } catch (URISyntaxException e) { throw new RuntimeException("Failed to attach long press intent", e); } }; } /** Loading