Search in sources :

Example 11 with UsageView

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

the class BatteryHistoryPreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    final long startTime = System.currentTimeMillis();
    if (mBatteryInfo == null) {
        return;
    }
    ((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
    mSummaryView = (TextView) view.findViewById(R.id.bottom_summary);
    if (mSummary != null) {
        mSummaryView.setText(mSummary);
    }
    if (hideSummary) {
        mSummaryView.setVisibility(View.GONE);
    }
    UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
    usageView.findViewById(R.id.label_group).setAlpha(.7f);
    mBatteryInfo.bindHistory(usageView);
    BatteryUtils.logRuntime(TAG, "onBindViewHolder", startTime);
}
Also used : UsageView(com.android.settings.graph.UsageView) TextView(android.widget.TextView)

Example 12 with UsageView

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

the class BatteryHistoryPreference method onBindViewHolder.

@Override
public void onBindViewHolder(PreferenceViewHolder view) {
    super.onBindViewHolder(view);
    final long startTime = System.currentTimeMillis();
    if (mBatteryInfo == null) {
        return;
    }
    ((TextView) view.findViewById(R.id.charge)).setText(mBatteryInfo.batteryPercentString);
    mSummaryView = (TextView) view.findViewById(R.id.bottom_summary);
    if (mSummary != null) {
        mSummaryView.setText(mSummary);
    }
    if (hideSummary) {
        mSummaryView.setVisibility(View.GONE);
    }
    UsageView usageView = (UsageView) view.findViewById(R.id.battery_usage);
    usageView.findViewById(R.id.label_group).setAlpha(.7f);
    mBatteryInfo.bindHistory(usageView);
    BatteryUtils.logRuntime(TAG, "onBindViewHolder", startTime);
}
Also used : UsageView(com.android.settings.graph.UsageView) TextView(android.widget.TextView)

Example 13 with UsageView

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

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 14 with UsageView

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

the class BatteryInfoTest method assertOnlyHistory.

private void assertOnlyHistory(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    info.bindHistory(view);
    verify(view, times(1)).configureGraph(anyInt(), anyInt());
    verify(view, times(1)).addPath(any(SparseIntArray.class));
    verify(view, never()).addProjectedPath(any(SparseIntArray.class));
}
Also used : UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Example 15 with UsageView

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

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)

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