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.car.settings.common; 18 19 import android.content.res.Resources; 20 import android.content.res.Resources.Theme; 21 import android.graphics.drawable.GradientDrawable; 22 import android.util.AttributeSet; 23 24 import com.android.car.settings.R; 25 26 import org.xmlpull.v1.XmlPullParser; 27 import org.xmlpull.v1.XmlPullParserException; 28 29 import java.io.IOException; 30 31 /** 32 * Top-level icon background shape. 33 * 34 * Adapted from {@link com.android.settingslib.widget.AdaptiveIconShapeDrawable} 35 */ 36 public class TopLevelIconShapeDrawable extends GradientDrawable { TopLevelIconShapeDrawable()37 public TopLevelIconShapeDrawable() { 38 super(); 39 } 40 TopLevelIconShapeDrawable(Resources resources)41 public TopLevelIconShapeDrawable(Resources resources) { 42 super(); 43 init(resources); 44 } 45 46 @Override inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)47 public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) 48 throws XmlPullParserException, IOException { 49 super.inflate(r, parser, attrs, theme); 50 init(r); 51 } 52 init(Resources resources)53 private void init(Resources resources) { 54 setShape(resources.getInteger(R.integer.config_top_level_icon_shape)); 55 } 56 } 57