Skip to content

Commit

Permalink
base: Statusbar Network Traffic [1/2]
Browse files Browse the repository at this point in the history
-----
abc ezio84:
use O darkintensity api
use arrows vectors from aosp net arrows commit (thanks @Mazda-- for this find!): ezio84/abc_frameworks_base@ad71ae1
fix visual glitch on statusbar expand (arrows showing and quickly hiding again)
don't show arrows when no data
remove unit settings (KB is good)
remove interval (set to 1sec by def) and single arrow options
don't get settings values again when not needed
fix padding between arrows and speed values and expose the padding value
code cleanup
-----

Change-Id: I026f67caec69a09c0c1969a09fbe99aa6b6f0510
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
  • Loading branch information
Haus1 authored and darknius09 committed Nov 17, 2022
1 parent a79deb9 commit 2ea2bb7
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 2 deletions.
12 changes: 12 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4703,6 +4703,18 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
*/
public static final String FOD_ANIM = "fod_recognizing_animation_list";


/**
* Wheter to show network traffic indicator in statusbar
* @hide
*/
public static final String NETWORK_TRAFFIC_STATE = "network_traffic_state";
/**
* Network traffic inactivity threshold (default is 1 kBs)
* @hide
*/
public static final String NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD = "network_traffic_autohide_threshold";

/**
* Show pointer location on screen?
* 0 = no
Expand Down
29 changes: 29 additions & 0 deletions packages/SystemUI/res/drawable/stat_sys_network_traffic_updown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2017 The Android Open Source Project
Copyright (C) 2017 ABC rom
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="5dp"
android:height="17.0dp"
android:viewportWidth="7.1"
android:viewportHeight="24.0">
<path
android:fillColor="#ffffff"
android:pathData="M3.6000004,10.8l3.5,0.0 -3.5,-7.3 0.0,0.0 0.0,0.0 0.0,0.0 0.0,0.0 -3.6,7.3z"/>
<path
android:fillColor="#ffffff"
android:pathData="M3.6000004,13.2l-3.6,0.0 3.6,7.3 0.0,0.0 0.0,0.0 0.0,0.0 0.0,0.0 3.5,-7.3z"/>
</vector>
12 changes: 11 additions & 1 deletion packages/SystemUI/res/layout/status_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,23 @@
android:gravity="center_horizontal|center_vertical"/>

<com.android.keyguard.AlphaOptimizedLinearLayout android:id="@+id/system_icon_area"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center_vertical|end"
>

<com.android.systemui.statusbar.policy.NetworkTraffic
android:id="@+id/networkTraffic"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:singleLine="false"
android:fontFamily="sans-serif-condensed"
android:gravity="right|center_vertical"/>

<include layout="@layout/system_icons" />

</com.android.keyguard.AlphaOptimizedLinearLayout>
Expand Down
5 changes: 5 additions & 0 deletions packages/SystemUI/res/values/custom_dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@
<dimen name="status_bar_battery_icon_circle_width">13.5dp</dimen>

<dimen name="qs_clock_start_20">20dp</dimen>

<!-- Network traffic monitor -->
<dimen name="net_traffic_multi_text_size">8dp</dimen>
<dimen name="net_traffic_txt_img_padding">2dp</dimen>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {

private final float mIconAlphaWhenOpaque;

private View mLeftSide, mStatusIcons, mBattery, mClock, mCenterClock, mRightClock;
private View mLeftSide, mStatusIcons, mBattery, mClock, mCenterClock, mRightClock, mNetworkTraffic;

private Animator mCurrentAnimation;

Expand All @@ -48,6 +48,7 @@ public PhoneStatusBarTransitions(PhoneStatusBarView statusBarView, View backgrou
mClock = statusBarView.findViewById(R.id.clock);
mCenterClock = statusBarView.findViewById(R.id.center_clock);
mRightClock = statusBarView.findViewById(R.id.right_clock);
mNetworkTraffic = statusBarView.findViewById(R.id.networkTraffic);
applyModeBackground(-1, getMode(), false /*animate*/);
applyMode(getMode(), false /*animate*/);
}
Expand Down Expand Up @@ -94,6 +95,7 @@ private void applyMode(int mode, boolean animate) {
animateTransitionTo(mClock, newAlphaBC),
animateTransitionTo(mCenterClock, newAlphaBC),
animateTransitionTo(mRightClock, newAlphaBC)
animateTransitionTo(mNetworkTraffic, newAlpha)
);
if (isLightsOut(mode)) {
anims.setDuration(LIGHTS_OUT_DURATION);
Expand All @@ -107,6 +109,7 @@ private void applyMode(int mode, boolean animate) {
mClock.setAlpha(newAlphaBC);
mCenterClock.setAlpha(newAlphaBC);
mRightClock.setAlpha(newAlphaBC);
mNetworkTraffic.setAlpha(newAlpha);
}
}
}
Loading

0 comments on commit 2ea2bb7

Please sign in to comment.