Merge "Data activity icon in statusbar"

This commit is contained in:
Jason Monk
2017-02-24 14:13:59 +00:00
committed by Gerrit Code Review
11 changed files with 264 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
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:autoMirrored="true"
android:width="17dp"
android:height="17dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:name="in"
android:fillColor="#FFFFFFFF"
android:pathData="M8.7,12.2l-2.0,3.5l-2.0,-3.5z" />
</vector>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
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:autoMirrored="true"
android:width="17dp"
android:height="17dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:name="in"
android:fillColor="#FFFFFFFF"
android:pathData="M8.7,12.2l-2.0,3.5l-2.0,-3.5z" />
<path
android:name="out"
android:fillColor="#FFFFFFFF"
android:pathData="M0.5,15.7l2.0,-3.5l2.0,3.5z" />
</vector>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
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:autoMirrored="true"
android:width="17dp"
android:height="17dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:name="out"
android:fillColor="#FFFFFFFF"
android:pathData="M0.5,15.7l2.0,-3.5l2.0,3.5z" />
</vector>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
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:autoMirrored="true"
android:width="18.41dp"
android:height="17dp"
android:viewportWidth="26.0"
android:viewportHeight="24.0">
<path
android:name="in"
android:fillColor="#FFFFFFFF"
android:pathData="M8.7,18.3l-2.0,3.5l-2.0,-3.5z" />
</vector>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
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:autoMirrored="true"
android:width="18.41dp"
android:height="17dp"
android:viewportWidth="26.0"
android:viewportHeight="24.0">
<path
android:name="in"
android:fillColor="#FFFFFFFF"
android:pathData="M8.7,18.3l-2.0,3.5l-2.0,-3.5z" />
<path
android:name="out"
android:fillColor="#FFFFFFFF"
android:pathData="M0.5,21.8l2.0,-3.5l2.0,3.5z" />
</vector>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 The Android Open Source Project
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:autoMirrored="true"
android:width="18.41dp"
android:height="17dp"
android:viewportWidth="26.0"
android:viewportHeight="24.0">
<path
android:name="out"
android:fillColor="#FFFFFFFF"
android:pathData="M0.5,21.8l2.0,-3.5l2.0,3.5z" />
</vector>

View File

@@ -43,4 +43,10 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<ImageView
android:id="@+id/mobile_inout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
/>
</FrameLayout>

View File

@@ -70,6 +70,11 @@
android:layout_width="wrap_content"
android:alpha="0.0"
/>
<ImageView
android:id="@+id/wifi_inout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
</FrameLayout>
<View
android:id="@+id/wifi_signal_spacer"

View File

@@ -75,6 +75,8 @@ public class SignalClusterView
private boolean mWifiVisible = false;
private int mWifiStrengthId = 0;
private int mLastWifiStrengthId = -1;
private int mWifiActivityId = 0;
private int mLastWifiActivityId = -1;
private boolean mIsAirplaneMode = false;
private int mAirplaneIconId = 0;
private int mLastAirplaneIconId = -1;
@@ -89,6 +91,7 @@ public class SignalClusterView
ViewGroup mEthernetGroup, mWifiGroup;
View mNoSimsCombo;
ImageView mVpn, mEthernet, mWifi, mAirplane, mNoSims, mEthernetDark, mWifiDark, mNoSimsDark;
ImageView mWifiActivity;
View mWifiAirplaneSpacer;
View mWifiSignalSpacer;
LinearLayout mMobileSignalGroup;
@@ -180,6 +183,7 @@ public class SignalClusterView
mWifiGroup = (ViewGroup) findViewById(R.id.wifi_combo);
mWifi = (ImageView) findViewById(R.id.wifi_signal);
mWifiDark = (ImageView) findViewById(R.id.wifi_signal_dark);
mWifiActivity = (ImageView) findViewById(R.id.wifi_inout);
mAirplane = (ImageView) findViewById(R.id.airplane);
mNoSims = (ImageView) findViewById(R.id.no_sims);
mNoSimsDark = (ImageView) findViewById(R.id.no_sims_dark);
@@ -264,6 +268,10 @@ public class SignalClusterView
mWifiVisible = statusIcon.visible && !mBlockWifi;
mWifiStrengthId = statusIcon.icon;
mWifiDescription = statusIcon.contentDescription;
mWifiActivityId = activityIn && activityOut ? R.drawable.stat_sys_wifi_inout
: activityIn ? R.drawable.stat_sys_wifi_in
: activityOut ? R.drawable.stat_sys_wifi_out
: 0;
apply();
}
@@ -282,6 +290,10 @@ public class SignalClusterView
state.mMobileDescription = statusIcon.contentDescription;
state.mMobileTypeDescription = typeContentDescription;
state.mIsMobileTypeIconWide = statusType != 0 && isWide;
state.mMobileActivityId = activityIn && activityOut ? R.drawable.stat_sys_signal_inout
: activityIn ? R.drawable.stat_sys_signal_in
: activityOut ? R.drawable.stat_sys_signal_out
: 0;
apply();
}
@@ -404,6 +416,10 @@ public class SignalClusterView
mWifiDark.setImageDrawable(null);
mLastWifiStrengthId = -1;
}
if (mWifiActivity != null) {
mWifiActivity.setImageDrawable(null);
mLastWifiActivityId = -1;
}
for (PhoneState state : mPhoneStates) {
if (state.mMobile != null) {
@@ -420,6 +436,10 @@ public class SignalClusterView
state.mMobileType.setImageDrawable(null);
state.mLastMobileTypeId = -1;
}
if (state.mMobileActivity != null) {
state.mMobileActivity.setImageDrawable(null);
state.mLastMobileActivityId = -1;
}
}
if (mAirplane != null) {
@@ -473,6 +493,12 @@ public class SignalClusterView
setIconForView(mWifiDark, mWifiStrengthId);
mLastWifiStrengthId = mWifiStrengthId;
}
if (mWifiActivityId != mLastWifiActivityId) {
if (mWifiActivityId != 0) {
setIconForView(mWifiActivity, mWifiActivityId);
}
mLastWifiActivityId = mWifiActivityId;
}
mWifiGroup.setContentDescription(mWifiDescription);
mWifiGroup.setVisibility(View.VISIBLE);
} else {
@@ -484,6 +510,8 @@ public class SignalClusterView
(mWifiVisible ? "VISIBLE" : "GONE"),
mWifiStrengthId));
mWifiActivity.setVisibility(mWifiActivityId != 0 ? View.VISIBLE : View.GONE);
boolean anyMobileVisible = false;
int firstMobileTypeId = 0;
for (PhoneState state : mPhoneStates) {
@@ -560,6 +588,8 @@ public class SignalClusterView
applyDarkIntensity(
StatusBarIconController.getDarkIntensity(mTintArea, mWifi, mDarkIntensity),
mWifi, mWifiDark);
setTint(mWifiActivity,
StatusBarIconController.getTint(mTintArea, mWifiActivity, mIconTint));
applyDarkIntensity(
StatusBarIconController.getDarkIntensity(mTintArea, mEthernet, mDarkIntensity),
mEthernet, mEthernetDark);
@@ -584,14 +614,16 @@ public class SignalClusterView
private class PhoneState {
private final int mSubId;
private boolean mMobileVisible = false;
private int mMobileStrengthId = 0, mMobileTypeId = 0;
private int mMobileStrengthId = 0, mMobileTypeId = 0, mMobileActivityId = 0;
private int mLastMobileStrengthId = -1;
private int mLastMobileTypeId = -1;
private int mLastMobileActivityId = -1;
private boolean mIsMobileTypeIconWide;
private String mMobileDescription, mMobileTypeDescription;
private ViewGroup mMobileGroup;
private ImageView mMobile, mMobileDark, mMobileType;
private ImageView mMobileActivity;
public PhoneState(int subId, Context context) {
ViewGroup root = (ViewGroup) LayoutInflater.from(context)
@@ -605,6 +637,7 @@ public class SignalClusterView
mMobile = (ImageView) root.findViewById(R.id.mobile_signal);
mMobileDark = (ImageView) root.findViewById(R.id.mobile_signal_dark);
mMobileType = (ImageView) root.findViewById(R.id.mobile_type);
mMobileActivity = (ImageView) root.findViewById(R.id.mobile_inout);
}
public boolean apply(boolean isSecondaryIcon) {
@@ -619,6 +652,11 @@ public class SignalClusterView
mMobileType.setImageResource(mMobileTypeId);
mLastMobileTypeId = mMobileTypeId;
}
if (mLastMobileActivityId != mMobileActivityId) {
mMobileActivity.setImageResource(mMobileActivityId);
mLastMobileActivityId = mMobileActivityId;
}
mMobileGroup.setContentDescription(mMobileTypeDescription
+ " " + mMobileDescription);
mMobileGroup.setVisibility(View.VISIBLE);
@@ -640,6 +678,7 @@ public class SignalClusterView
(mMobileVisible ? "VISIBLE" : "GONE"), mMobileStrengthId, mMobileTypeId));
mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE);
mMobileActivity.setVisibility(mMobileActivityId != 0 ? View.VISIBLE : View.GONE);
return mMobileVisible;
}
@@ -699,6 +738,8 @@ public class SignalClusterView
StatusBarIconController.getDarkIntensity(tintArea, mMobile, darkIntensity),
mMobile, mMobileDark);
setTint(mMobileType, StatusBarIconController.getTint(tintArea, mMobileType, tint));
setTint(mMobileActivity,
StatusBarIconController.getTint(tintArea, mMobileActivity, tint));
}
}
}

View File

@@ -690,6 +690,7 @@ public class NetworkControllerImpl extends BroadcastReceiver
mDemoMode = true;
mDemoInetCondition = mInetCondition;
mDemoWifiState = mWifiSignalController.getState();
mDemoWifiState.ssid = "DemoMode";
} else if (mDemoMode && command.equals(COMMAND_EXIT)) {
if (DEBUG) Log.d(TAG, "Exiting demo mode");
mDemoMode = false;
@@ -735,6 +736,25 @@ public class NetworkControllerImpl extends BroadcastReceiver
: Math.min(Integer.parseInt(level), WifiIcons.WIFI_LEVEL_COUNT - 1);
mDemoWifiState.connected = mDemoWifiState.level >= 0;
}
String activity = args.getString("activity");
if (activity != null) {
switch (activity) {
case "inout":
mWifiSignalController.setActivity(WifiManager.DATA_ACTIVITY_INOUT);
break;
case "in":
mWifiSignalController.setActivity(WifiManager.DATA_ACTIVITY_IN);
break;
case "out":
mWifiSignalController.setActivity(WifiManager.DATA_ACTIVITY_OUT);
break;
default:
mWifiSignalController.setActivity(WifiManager.DATA_ACTIVITY_NONE);
break;
}
} else {
mWifiSignalController.setActivity(WifiManager.DATA_ACTIVITY_NONE);
}
mDemoWifiState.enabled = show;
mWifiSignalController.notifyListeners();
}
@@ -797,6 +817,26 @@ public class NetworkControllerImpl extends BroadcastReceiver
: Math.min(Integer.parseInt(level), icons[0].length - 1);
controller.getState().connected = controller.getState().level >= 0;
}
String activity = args.getString("activity");
if (activity != null) {
controller.getState().dataConnected = true;
switch (activity) {
case "inout":
controller.setActivity(TelephonyManager.DATA_ACTIVITY_INOUT);
break;
case "in":
controller.setActivity(TelephonyManager.DATA_ACTIVITY_IN);
break;
case "out":
controller.setActivity(TelephonyManager.DATA_ACTIVITY_OUT);
break;
default:
controller.setActivity(TelephonyManager.DATA_ACTIVITY_NONE);
break;
}
} else {
controller.setActivity(TelephonyManager.DATA_ACTIVITY_NONE);
}
controller.getState().enabled = show;
controller.notifyListeners();
}

View File

@@ -163,7 +163,7 @@ public class DemoModeFragment extends PreferenceFragment implements OnPreference
intent.putExtra("sims", "1");
intent.putExtra("nosim", "false");
intent.putExtra("level", "4");
intent.putExtra("datatypel", "");
intent.putExtra("datatype", "lte");
getContext().sendBroadcast(intent);
// Need to send this after so that the sim controller already exists.