1 /* 2 * Copyright (C) 2021 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 */ 16 17 package com.android.systemui.car.qc; 18 19 import android.content.Context; 20 import android.content.res.TypedArray; 21 import android.util.AttributeSet; 22 23 import androidx.annotation.Nullable; 24 25 import com.android.car.qc.view.QCView; 26 import com.android.systemui.R; 27 28 /** 29 * Quick Control View Element for CarSystemUI. 30 * 31 * This extended class allows for specifying a local or remote quick controls provider via xml 32 * attributes. This is then retrieved by a {@link SystemUIQCViewController} to be bound and 33 * controlled. 34 * 35 * @attr ref R.styleable#SystemUIQCView_remoteQCProvider 36 * @attr ref R.styleable#SystemUIQCView_localQCProvider 37 */ 38 public class SystemUIQCView extends QCView { 39 private String mRemoteUri; 40 private String mLocalClass; 41 SystemUIQCView(Context context)42 public SystemUIQCView(Context context) { 43 super(context); 44 init(context, /* attrs= */ null); 45 } 46 SystemUIQCView(Context context, AttributeSet attrs)47 public SystemUIQCView(Context context, AttributeSet attrs) { 48 super(context, attrs); 49 init(context, attrs); 50 } 51 SystemUIQCView(Context context, AttributeSet attrs, int defStyleAttr)52 public SystemUIQCView(Context context, AttributeSet attrs, int defStyleAttr) { 53 super(context, attrs, defStyleAttr); 54 init(context, attrs); 55 } 56 SystemUIQCView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)57 public SystemUIQCView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 58 super(context, attrs, defStyleAttr, defStyleRes); 59 init(context, attrs); 60 } 61 init(Context context, AttributeSet attrs)62 private void init(Context context, AttributeSet attrs) { 63 TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SystemUIQCView); 64 mRemoteUri = a.getString(R.styleable.SystemUIQCView_remoteQCProvider); 65 mLocalClass = a.getString(R.styleable.SystemUIQCView_localQCProvider); 66 a.recycle(); 67 } 68 69 @Nullable getRemoteUriString()70 public String getRemoteUriString() { 71 return mRemoteUri; 72 } 73 74 @Nullable getLocalClassString()75 public String getLocalClassString() { 76 return mLocalClass; 77 } 78 } 79