Home | History | Annotate | Download | only in customize
      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     private int mLabelMinLines;
     30     public CustomizeTileView(Context context, QSIconView icon) {
     31         super(context, icon);
     32     }
     33 
     34     @Override
     35     protected void createLabel() {
     36         super.createLabel();
     37         mLabelMinLines = mLabel.getMinLines();
     38         View view = LayoutInflater.from(mContext).inflate(R.layout.qs_tile_label, null);
     39         mAppLabel = (TextView) view.findViewById(R.id.tile_label);
     40         mAppLabel.setAlpha(.6f);
     41         mAppLabel.setSingleLine(true);
     42         addView(view);
     43     }
     44 
     45     public void setShowAppLabel(boolean showAppLabel) {
     46         mAppLabel.setVisibility(showAppLabel ? View.VISIBLE : View.GONE);
     47         mLabel.setSingleLine(showAppLabel);
     48         if (!showAppLabel) {
     49             mLabel.setMinLines(mLabelMinLines);
     50         }
     51     }
     52 
     53     public void setAppLabel(CharSequence label) {
     54         if (!Objects.equal(label, mAppLabel.getText())) {
     55             mAppLabel.setText(label);
     56         }
     57     }
     58 
     59     public TextView getAppLabel() {
     60         return mAppLabel;
     61     }
     62 }
     63