Search in sources :

Example 1 with DataUsageGraph

use of com.android.systemui.qs.DataUsageGraph in project android_frameworks_base by ResurrectionRemix.

the class DataUsageDetailView method bind.

public void bind(DataUsageController.DataUsageInfo info) {
    final Resources res = mContext.getResources();
    final int titleId;
    final long bytes;
    @ColorInt int usageColor = 0;
    final String top;
    String bottom = null;
    if (info.usageLevel < info.warningLevel || info.limitLevel <= 0) {
        // under warning, or no limit
        titleId = R.string.quick_settings_cellular_detail_data_usage;
        bytes = info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_warning, formatBytes(info.warningLevel));
    } else if (info.usageLevel <= info.limitLevel) {
        // over warning, under limit
        titleId = R.string.quick_settings_cellular_detail_remaining_data;
        bytes = info.limitLevel - info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
    } else {
        // over limit
        titleId = R.string.quick_settings_cellular_detail_over_limit;
        bytes = info.usageLevel - info.limitLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
        usageColor = mContext.getColor(R.color.system_warning_color);
    }
    if (usageColor == 0) {
        usageColor = Utils.getColorAccent(mContext);
    }
    final TextView title = (TextView) findViewById(android.R.id.title);
    title.setText(titleId);
    final TextView usage = (TextView) findViewById(R.id.usage_text);
    usage.setText(formatBytes(bytes));
    usage.setTextColor(usageColor);
    final DataUsageGraph graph = (DataUsageGraph) findViewById(R.id.usage_graph);
    graph.setLevels(info.limitLevel, info.warningLevel, info.usageLevel);
    final TextView carrier = (TextView) findViewById(R.id.usage_carrier_text);
    carrier.setText(info.carrier);
    final TextView period = (TextView) findViewById(R.id.usage_period_text);
    period.setText(info.period);
    final TextView infoTop = (TextView) findViewById(R.id.usage_info_top_text);
    infoTop.setVisibility(top != null ? View.VISIBLE : View.GONE);
    infoTop.setText(top);
    final TextView infoBottom = (TextView) findViewById(R.id.usage_info_bottom_text);
    infoBottom.setVisibility(bottom != null ? View.VISIBLE : View.GONE);
    infoBottom.setText(bottom);
    boolean showLevel = info.warningLevel > 0 || info.limitLevel > 0;
    graph.setVisibility(showLevel ? View.VISIBLE : View.GONE);
    if (!showLevel) {
        infoTop.setVisibility(View.GONE);
    }
}
Also used : ColorInt(android.annotation.ColorInt) DataUsageGraph(com.android.systemui.qs.DataUsageGraph) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Example 2 with DataUsageGraph

use of com.android.systemui.qs.DataUsageGraph in project android_frameworks_base by crdroidandroid.

the class DataUsageDetailView method bind.

public void bind(DataUsageController.DataUsageInfo info) {
    final Resources res = mContext.getResources();
    final int titleId;
    final long bytes;
    @ColorInt int usageColor = 0;
    final String top;
    String bottom = null;
    if (info.usageLevel < info.warningLevel || info.limitLevel <= 0) {
        // under warning, or no limit
        titleId = R.string.quick_settings_cellular_detail_data_usage;
        bytes = info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_warning, formatBytes(info.warningLevel));
    } else if (info.usageLevel <= info.limitLevel) {
        // over warning, under limit
        titleId = R.string.quick_settings_cellular_detail_remaining_data;
        bytes = info.limitLevel - info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
    } else {
        // over limit
        titleId = R.string.quick_settings_cellular_detail_over_limit;
        bytes = info.usageLevel - info.limitLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
        usageColor = mContext.getColor(R.color.system_warning_color);
    }
    if (usageColor == 0) {
        usageColor = Utils.getColorAccent(mContext);
    }
    final TextView title = (TextView) findViewById(android.R.id.title);
    title.setText(titleId);
    final TextView usage = (TextView) findViewById(R.id.usage_text);
    usage.setText(formatBytes(bytes));
    usage.setTextColor(usageColor);
    final DataUsageGraph graph = (DataUsageGraph) findViewById(R.id.usage_graph);
    graph.setLevels(info.limitLevel, info.warningLevel, info.usageLevel);
    final TextView carrier = (TextView) findViewById(R.id.usage_carrier_text);
    carrier.setText(info.carrier);
    final TextView period = (TextView) findViewById(R.id.usage_period_text);
    period.setText(info.period);
    final TextView infoTop = (TextView) findViewById(R.id.usage_info_top_text);
    infoTop.setVisibility(top != null ? View.VISIBLE : View.GONE);
    infoTop.setText(top);
    final TextView infoBottom = (TextView) findViewById(R.id.usage_info_bottom_text);
    infoBottom.setVisibility(bottom != null ? View.VISIBLE : View.GONE);
    infoBottom.setText(bottom);
    boolean showLevel = info.warningLevel > 0 || info.limitLevel > 0;
    graph.setVisibility(showLevel ? View.VISIBLE : View.GONE);
    if (!showLevel) {
        infoTop.setVisibility(View.GONE);
    }
}
Also used : ColorInt(android.annotation.ColorInt) DataUsageGraph(com.android.systemui.qs.DataUsageGraph) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Example 3 with DataUsageGraph

use of com.android.systemui.qs.DataUsageGraph in project platform_frameworks_base by android.

the class DataUsageDetailView method bind.

public void bind(DataUsageController.DataUsageInfo info) {
    final Resources res = mContext.getResources();
    final int titleId;
    final long bytes;
    @ColorInt int usageColor = 0;
    final String top;
    String bottom = null;
    if (info.usageLevel < info.warningLevel || info.limitLevel <= 0) {
        // under warning, or no limit
        titleId = R.string.quick_settings_cellular_detail_data_usage;
        bytes = info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_warning, formatBytes(info.warningLevel));
    } else if (info.usageLevel <= info.limitLevel) {
        // over warning, under limit
        titleId = R.string.quick_settings_cellular_detail_remaining_data;
        bytes = info.limitLevel - info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
    } else {
        // over limit
        titleId = R.string.quick_settings_cellular_detail_over_limit;
        bytes = info.usageLevel - info.limitLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
        usageColor = mContext.getColor(R.color.system_warning_color);
    }
    if (usageColor == 0) {
        usageColor = Utils.getColorAccent(mContext);
    }
    final TextView title = (TextView) findViewById(android.R.id.title);
    title.setText(titleId);
    final TextView usage = (TextView) findViewById(R.id.usage_text);
    usage.setText(formatBytes(bytes));
    usage.setTextColor(usageColor);
    final DataUsageGraph graph = (DataUsageGraph) findViewById(R.id.usage_graph);
    graph.setLevels(info.limitLevel, info.warningLevel, info.usageLevel);
    final TextView carrier = (TextView) findViewById(R.id.usage_carrier_text);
    carrier.setText(info.carrier);
    final TextView period = (TextView) findViewById(R.id.usage_period_text);
    period.setText(info.period);
    final TextView infoTop = (TextView) findViewById(R.id.usage_info_top_text);
    infoTop.setVisibility(top != null ? View.VISIBLE : View.GONE);
    infoTop.setText(top);
    final TextView infoBottom = (TextView) findViewById(R.id.usage_info_bottom_text);
    infoBottom.setVisibility(bottom != null ? View.VISIBLE : View.GONE);
    infoBottom.setText(bottom);
    boolean showLevel = info.warningLevel > 0 || info.limitLevel > 0;
    graph.setVisibility(showLevel ? View.VISIBLE : View.GONE);
    if (!showLevel) {
        infoTop.setVisibility(View.GONE);
    }
}
Also used : ColorInt(android.annotation.ColorInt) DataUsageGraph(com.android.systemui.qs.DataUsageGraph) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Example 4 with DataUsageGraph

use of com.android.systemui.qs.DataUsageGraph in project android_frameworks_base by AOSPA.

the class DataUsageDetailView method bind.

public void bind(DataUsageController.DataUsageInfo info) {
    final Resources res = mContext.getResources();
    final int titleId;
    final long bytes;
    @ColorInt int usageColor = 0;
    final String top;
    String bottom = null;
    if (info.usageLevel < info.warningLevel || info.limitLevel <= 0) {
        // under warning, or no limit
        titleId = R.string.quick_settings_cellular_detail_data_usage;
        bytes = info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_warning, formatBytes(info.warningLevel));
    } else if (info.usageLevel <= info.limitLevel) {
        // over warning, under limit
        titleId = R.string.quick_settings_cellular_detail_remaining_data;
        bytes = info.limitLevel - info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
    } else {
        // over limit
        titleId = R.string.quick_settings_cellular_detail_over_limit;
        bytes = info.usageLevel - info.limitLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
        usageColor = mContext.getColor(R.color.system_warning_color);
    }
    if (usageColor == 0) {
        usageColor = Utils.getColorAccent(mContext);
    }
    final TextView title = (TextView) findViewById(android.R.id.title);
    title.setText(titleId);
    final TextView usage = (TextView) findViewById(R.id.usage_text);
    usage.setText(formatBytes(bytes));
    usage.setTextColor(usageColor);
    final DataUsageGraph graph = (DataUsageGraph) findViewById(R.id.usage_graph);
    graph.setLevels(info.limitLevel, info.warningLevel, info.usageLevel);
    final TextView carrier = (TextView) findViewById(R.id.usage_carrier_text);
    carrier.setText(info.carrier);
    final TextView period = (TextView) findViewById(R.id.usage_period_text);
    period.setText(info.period);
    final TextView infoTop = (TextView) findViewById(R.id.usage_info_top_text);
    infoTop.setVisibility(top != null ? View.VISIBLE : View.GONE);
    infoTop.setText(top);
    final TextView infoBottom = (TextView) findViewById(R.id.usage_info_bottom_text);
    infoBottom.setVisibility(bottom != null ? View.VISIBLE : View.GONE);
    infoBottom.setText(bottom);
    boolean showLevel = info.warningLevel > 0 || info.limitLevel > 0;
    graph.setVisibility(showLevel ? View.VISIBLE : View.GONE);
    if (!showLevel) {
        infoTop.setVisibility(View.GONE);
    }
}
Also used : ColorInt(android.annotation.ColorInt) DataUsageGraph(com.android.systemui.qs.DataUsageGraph) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Example 5 with DataUsageGraph

use of com.android.systemui.qs.DataUsageGraph in project android_frameworks_base by DirtyUnicorns.

the class DataUsageDetailView method bind.

public void bind(DataUsageController.DataUsageInfo info) {
    final Resources res = mContext.getResources();
    final int titleId;
    final long bytes;
    @ColorInt int usageColor = 0;
    final String top;
    String bottom = null;
    if (info.usageLevel < info.warningLevel || info.limitLevel <= 0) {
        // under warning, or no limit
        titleId = R.string.quick_settings_cellular_detail_data_usage;
        bytes = info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_warning, formatBytes(info.warningLevel));
    } else if (info.usageLevel <= info.limitLevel) {
        // over warning, under limit
        titleId = R.string.quick_settings_cellular_detail_remaining_data;
        bytes = info.limitLevel - info.usageLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
    } else {
        // over limit
        titleId = R.string.quick_settings_cellular_detail_over_limit;
        bytes = info.usageLevel - info.limitLevel;
        top = res.getString(R.string.quick_settings_cellular_detail_data_used, formatBytes(info.usageLevel));
        bottom = res.getString(R.string.quick_settings_cellular_detail_data_limit, formatBytes(info.limitLevel));
        usageColor = mContext.getColor(R.color.system_warning_color);
    }
    if (usageColor == 0) {
        usageColor = Utils.getColorAccent(mContext);
    }
    final TextView title = (TextView) findViewById(android.R.id.title);
    title.setText(titleId);
    final TextView usage = (TextView) findViewById(R.id.usage_text);
    usage.setText(formatBytes(bytes));
    usage.setTextColor(usageColor);
    final DataUsageGraph graph = (DataUsageGraph) findViewById(R.id.usage_graph);
    graph.setLevels(info.limitLevel, info.warningLevel, info.usageLevel);
    final TextView carrier = (TextView) findViewById(R.id.usage_carrier_text);
    carrier.setText(info.carrier);
    final TextView period = (TextView) findViewById(R.id.usage_period_text);
    period.setText(info.period);
    final TextView infoTop = (TextView) findViewById(R.id.usage_info_top_text);
    infoTop.setVisibility(top != null ? View.VISIBLE : View.GONE);
    infoTop.setText(top);
    final TextView infoBottom = (TextView) findViewById(R.id.usage_info_bottom_text);
    infoBottom.setVisibility(bottom != null ? View.VISIBLE : View.GONE);
    infoBottom.setText(bottom);
    boolean showLevel = info.warningLevel > 0 || info.limitLevel > 0;
    graph.setVisibility(showLevel ? View.VISIBLE : View.GONE);
    if (!showLevel) {
        infoTop.setVisibility(View.GONE);
    }
}
Also used : ColorInt(android.annotation.ColorInt) DataUsageGraph(com.android.systemui.qs.DataUsageGraph) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Aggregations

ColorInt (android.annotation.ColorInt)5 Resources (android.content.res.Resources)5 TextView (android.widget.TextView)5 DataUsageGraph (com.android.systemui.qs.DataUsageGraph)5