Jason Monk | 0b349ad | 2016-04-04 11:18:03 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.qs.customize; |
| 16 | |
| 17 | import android.content.Context; |
| 18 | import android.view.LayoutInflater; |
| 19 | import android.view.View; |
| 20 | import android.widget.TextView; |
| 21 | import com.android.systemui.R; |
| 22 | import com.android.systemui.qs.QSIconView; |
| 23 | import com.android.systemui.qs.QSTileView; |
| 24 | import libcore.util.Objects; |
| 25 | |
| 26 | public class CustomizeTileView extends QSTileView { |
| 27 | |
| 28 | private TextView mAppLabel; |
| 29 | |
| 30 | public CustomizeTileView(Context context, QSIconView icon) { |
| 31 | super(context, icon); |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | protected void createLabel() { |
| 36 | super.createLabel(); |
| 37 | View view = LayoutInflater.from(mContext).inflate(R.layout.qs_tile_label, null); |
| 38 | mAppLabel = (TextView) view.findViewById(R.id.tile_label); |
| 39 | mAppLabel.setAlpha(.6f); |
| 40 | mAppLabel.setSingleLine(true); |
| 41 | addView(view); |
| 42 | } |
| 43 | |
| 44 | public void setShowAppLabel(boolean showAppLabel) { |
| 45 | mAppLabel.setVisibility(showAppLabel ? View.VISIBLE : View.GONE); |
| 46 | mLabel.setSingleLine(showAppLabel); |
| 47 | } |
| 48 | |
| 49 | public void setAppLabel(CharSequence label) { |
| 50 | if (!Objects.equal(label, mAppLabel.getText())) { |
| 51 | mAppLabel.setText(label); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | public TextView getAppLabel() { |
| 56 | return mAppLabel; |
| 57 | } |
| 58 | } |