StatusBar.java revision 891b703f7b1e0e396d16477cc66a286da7161b49
1/*
2 * Copyright (C) 2011 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
17package com.android.layoutlib.bridge.bars;
18
19import com.android.resources.Density;
20import com.android.resources.ResourceType;
21
22import org.xmlpull.v1.XmlPullParserException;
23
24import android.content.Context;
25import android.graphics.drawable.Drawable;
26import android.graphics.drawable.LevelListDrawable;
27import android.view.Gravity;
28import android.widget.LinearLayout;
29import android.widget.TextView;
30
31public class StatusBar extends CustomBar {
32
33    public StatusBar(Context context, Density density) throws XmlPullParserException {
34        super(context, density, LinearLayout.HORIZONTAL, "/bars/status_bar.xml", "status_bar.xml");
35
36        // FIXME: use FILL_H?
37        setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
38        setBackgroundColor(0xFF000000);
39
40        // Cannot access the inside items through id because no R.id values have been
41        // created for them.
42        // We do know the order though.
43        // 0 is the spacer
44        loadIcon(1, "stat_sys_wifi_signal_4_fully.png", density);
45        Drawable drawable = loadIcon(2, ResourceType.DRAWABLE, "stat_sys_battery_charge");
46        if (drawable instanceof LevelListDrawable) {
47            ((LevelListDrawable) drawable).setLevel(100);
48        }
49    }
50
51    @Override
52    protected TextView getStyleableTextView() {
53        return null;
54    }
55}
56