Search in sources :

Example 26 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by SudaMod.

the class BatteryInfoTest method assertHistoryAndLinearProjection.

private void assertHistoryAndLinearProjection(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    info.bindHistory(view);
    verify(view, times(2)).configureGraph(anyInt(), anyInt());
    verify(view, times(1)).addPath(any(SparseIntArray.class));
    ArgumentCaptor<SparseIntArray> pointsActual = ArgumentCaptor.forClass(SparseIntArray.class);
    verify(view, times(1)).addProjectedPath(pointsActual.capture());
    // Check that we have two points and the first is correct.
    assertThat(pointsActual.getValue().size()).isEqualTo(2);
    assertThat(pointsActual.getValue().keyAt(0)).isEqualTo(2000);
    assertThat(pointsActual.getValue().valueAt(0)).isEqualTo(97);
}
Also used : UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Example 27 with UsageView

use of com.android.settings.graph.UsageView in project android_packages_apps_Settings by SudaMod.

the class BatteryHistoryDetail method updateEverything.

private void updateEverything() {
    BatteryInfo.getBatteryInfo(getContext(), info -> {
        final View view = getView();
        info.bindHistory((UsageView) view.findViewById(R.id.battery_usage), mChargingParser, mScreenOn, mGpsParser, mFlashlightParser, mCameraParser, mWifiParser, mCpuParser, mPhoneParser);
        ((TextView) view.findViewById(R.id.charge)).setText(info.batteryPercentString);
        ((TextView) view.findViewById(R.id.estimation)).setText(info.remainingLabel);
        bindData(mChargingParser, R.string.battery_stats_charging_label, R.id.charging_group);
        bindData(mScreenOn, R.string.battery_stats_screen_on_label, R.id.screen_on_group);
        bindData(mGpsParser, R.string.battery_stats_gps_on_label, R.id.gps_group);
        bindData(mFlashlightParser, R.string.battery_stats_flashlight_on_label, R.id.flashlight_group);
        bindData(mCameraParser, R.string.battery_stats_camera_on_label, R.id.camera_group);
        bindData(mWifiParser, R.string.battery_stats_wifi_running_label, R.id.wifi_group);
        bindData(mCpuParser, R.string.battery_stats_wake_lock_label, R.id.cpu_group);
        bindData(mPhoneParser, R.string.battery_stats_phone_signal_label, R.id.cell_network_group);
    }, mStats, false);
}
Also used : TextView(android.widget.TextView) UsageView(com.android.settings.graph.UsageView) TextView(android.widget.TextView) View(android.view.View)

Example 28 with UsageView

use of com.android.settings.graph.UsageView in project platform_packages_apps_Settings by BlissRoms.

the class ChartDataUsagePreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    UsageView chart = (UsageView) holder.findViewById(R.id.data_usage);
    if (mNetwork == null)
        return;
    int top = getTop();
    chart.clearPaths();
    chart.configureGraph(toInt(mEnd - mStart), top);
    calcPoints(chart);
    chart.setBottomLabels(new CharSequence[] { Utils.formatDateRange(getContext(), mStart, mStart), Utils.formatDateRange(getContext(), mEnd, mEnd) });
    bindNetworkPolicy(chart, mPolicy, top);
}
Also used : UsageView(com.android.settings.graph.UsageView)

Example 29 with UsageView

use of com.android.settings.graph.UsageView in project platform_packages_apps_Settings by BlissRoms.

the class BatteryInfoTest method assertHistoryAndLinearProjection.

private void assertHistoryAndLinearProjection(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    info.bindHistory(view);
    verify(view, times(2)).configureGraph(anyInt(), anyInt());
    verify(view, times(1)).addPath(any(SparseIntArray.class));
    ArgumentCaptor<SparseIntArray> pointsActual = ArgumentCaptor.forClass(SparseIntArray.class);
    verify(view, times(1)).addProjectedPath(pointsActual.capture());
    // Check that we have two points and the first is correct.
    assertThat(pointsActual.getValue().size()).isEqualTo(2);
    assertThat(pointsActual.getValue().keyAt(0)).isEqualTo(2000);
    assertThat(pointsActual.getValue().valueAt(0)).isEqualTo(97);
}
Also used : UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Example 30 with UsageView

use of com.android.settings.graph.UsageView in project platform_packages_apps_Settings by BlissRoms.

the class BatteryHistoryDetail method updateEverything.

private void updateEverything() {
    BatteryInfo.getBatteryInfo(getContext(), info -> {
        final View view = getView();
        info.bindHistory((UsageView) view.findViewById(R.id.battery_usage), mChargingParser, mScreenOn, mGpsParser, mFlashlightParser, mCameraParser, mWifiParser, mCpuParser, mPhoneParser);
        ((TextView) view.findViewById(R.id.charge)).setText(info.batteryPercentString);
        ((TextView) view.findViewById(R.id.estimation)).setText(info.remainingLabel);
        bindData(mChargingParser, R.string.battery_stats_charging_label, R.id.charging_group);
        bindData(mScreenOn, R.string.battery_stats_screen_on_label, R.id.screen_on_group);
        bindData(mGpsParser, R.string.battery_stats_gps_on_label, R.id.gps_group);
        bindData(mFlashlightParser, R.string.battery_stats_flashlight_on_label, R.id.flashlight_group);
        bindData(mCameraParser, R.string.battery_stats_camera_on_label, R.id.camera_group);
        bindData(mWifiParser, R.string.battery_stats_wifi_running_label, R.id.wifi_group);
        bindData(mCpuParser, R.string.battery_stats_wake_lock_label, R.id.cpu_group);
        bindData(mPhoneParser, R.string.battery_stats_phone_signal_label, R.id.cell_network_group);
    }, mStats, false);
}
Also used : TextView(android.widget.TextView) UsageView(com.android.settings.graph.UsageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

UsageView (com.android.settings.graph.UsageView)31 SparseIntArray (android.util.SparseIntArray)15 TextView (android.widget.TextView)11 View (android.view.View)6 Context (android.content.Context)5