Search in sources :

Example 1 with UsageView

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

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

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

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

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

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

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

the class BatteryInfoTest method assertHistoryAndEnhancedProjection.

private void assertHistoryAndEnhancedProjection(BatteryInfo info) {
    mockBatteryStatsHistory();
    UsageView view = mock(UsageView.class);
    doReturn(mContext).when(view).getContext();
    SparseIntArray pointsExpected = new SparseIntArray();
    pointsExpected.append(2000, 96);
    pointsExpected.append(2500, 95);
    pointsExpected.append(3000, 94);
    doReturn(pointsExpected).when(mFeatureFactory.powerUsageFeatureProvider).getEnhancedBatteryPredictionCurve(any(Context.class), anyLong());
    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());
    assertThat(pointsActual.getValue()).isEqualTo(pointsExpected);
}
Also used : Context(android.content.Context) UsageView(com.android.settings.graph.UsageView) SparseIntArray(android.util.SparseIntArray)

Example 5 with UsageView

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

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)

Aggregations

UsageView (com.android.settings.graph.UsageView)36 SparseIntArray (android.util.SparseIntArray)18 TextView (android.widget.TextView)12 Context (android.content.Context)6 View (android.view.View)6