1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package android.support.car.ui; 17 18import android.content.Intent; 19import android.os.Bundle; 20import android.support.v4.app.NotificationCompat; 21 22/** 23 * Android Auto {@link android.app.Notification.Action} extender. 24 * NOTE: this will move into the platform and support-lib when the API stabilizes. 25 * @hide 26 */ 27public class CarActionExtender implements NotificationCompat.Action.Extender { 28 private static final String EXTRA_AUTO_EXTENDER = "android.auto.EXTENSIONS"; 29 private static final String EXTRA_INTENT = "intent"; 30 31 private Intent mIntent; 32 33 public CarActionExtender() { 34 } 35 36 public CarActionExtender(NotificationCompat.Action action) { 37 Bundle autoBundle = action.getExtras(); 38 39 if (autoBundle != null) { 40 mIntent = autoBundle.getParcelable(EXTRA_INTENT); 41 } 42 } 43 44 @Override 45 public NotificationCompat.Action.Builder extend(NotificationCompat.Action.Builder builder) { 46 Bundle autoBundle = new Bundle(); 47 48 autoBundle.putParcelable(EXTRA_INTENT, mIntent); 49 50 builder.getExtras().putBundle(EXTRA_AUTO_EXTENDER, autoBundle); 51 return builder; 52 } 53 54 public void setIntent(Intent intent) { 55 mIntent = intent; 56 } 57 58 public Intent getIntent() { 59 return mIntent; 60 } 61} 62