StatusBar.java revision 88db0ee2afbae38b53a0527506f0890914a7f115
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, int direction, boolean RtlEnabled)
34            throws XmlPullParserException {
35        // FIXME: if direction is RTL but it's not enabled in application manifest, mirror this bar.
36
37        super(context, density, LinearLayout.HORIZONTAL, "/bars/status_bar.xml", "status_bar.xml");
38
39        // FIXME: use FILL_H?
40        setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
41        setBackgroundColor(0xFF000000);
42
43        // Cannot access the inside items through id because no R.id values have been
44        // created for them.
45        // We do know the order though.
46        // 0 is the spacer
47        loadIcon(1, "stat_sys_wifi_signal_4_fully.png", density);
48        Drawable drawable = loadIcon(2, ResourceType.DRAWABLE, "stat_sys_battery_charge");
49        if (drawable instanceof LevelListDrawable) {
50            ((LevelListDrawable) drawable).setLevel(100);
51        }
52    }
53
54    @Override
55    protected TextView getStyleableTextView() {
56        return null;
57    }
58}
59