Loading packages/SystemUI/res/drawable/ic_qs_usb_tether_off.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The CyanogenMod 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:width="64dp" android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> <path android:fillColor="#4DFFFFFF" android:pathData="M48.677,29.715h5.255v-7.254h4.401l-7.047-9.612l-7.052,9.612h4.443V29.715z M54.688,46.753l3.645-4.971h-4.401v-7.255 h-5.255v6.215L54.688,46.753z M36.741,28.805v-3.923h2.109v-8.445h-8.444v6.034L36.741,28.805z M23.942,16.007v-1.679h4.562 l-6.547-8.976l-3.656,5.014L23.942,16.007z M28.916,34.699l22.692,22.692l3.324-3.324L7.6,6.734l-3.324,3.323l15.693,15.694 l0.004,10.381l-8.571-3.715v-3.896c1.257-0.734,2.111-2.079,2.111-3.639c0-2.33-1.887-4.222-4.224-4.222 c-2.332,0-4.222,1.892-4.222,4.222c0,1.56,0.854,2.905,2.113,3.639v6.668l12.794,5.547v5.609c-2.518,0.837-4.348,3.185-4.348,5.987 c0,3.495,2.835,6.333,6.332,6.333c3.501,0,6.337-2.838,6.337-6.333c0-2.802-1.83-5.15-4.352-5.987v-9.113L28.916,34.699z M23.938,29.72l1.843,1.843l-1.839,0.93L23.938,29.72z" /> </vector> No newline at end of file packages/SystemUI/res/drawable/ic_qs_usb_tether_on.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The CyanogenMod 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:width="64dp" android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> <path android:fillColor="#FFFFFF" android:pathData="M48.677,29.724h5.255V22.47h4.401l-7.047-9.611l-7.052,9.611h4.443V29.724z M48.677,34.537h5.255v7.254h4.401l-7.047,9.611 l-7.052-9.611h4.443V34.537z M38.85,16.447h-8.444v8.445h2.11v3.251l-8.574,4.36V14.337h4.562l-6.547-8.975l-6.545,8.975h4.561 v21.805l-8.571-3.715v-3.896c1.257-0.734,2.111-2.079,2.111-3.639c0-2.33-1.887-4.222-4.224-4.222c-2.332,0-4.222,1.892-4.222,4.222c0,1.56,0.854,2.905,2.113,3.639v6.668l12.794,5.547v5.609c-2.518,0.837-4.348,3.184-4.348,5.987c0,3.495,2.835,6.333,6.332,6.333c3.501,0,6.337-2.838,6.337-6.333c0-2.802-1.83-5.15-4.352-5.987v-9.113l12.798-6.512v-5.839h2.11L38.85,16.447L38.85,16.447z" /> </vector> No newline at end of file packages/SystemUI/res/values/cm_strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -122,4 +122,5 @@ <string name="accessibility_quick_settings_sync_changed_on">Sync turned on.</string> <string name="quick_settings_sync_label">Sync</string> <string name="quick_settings_volume_panel_label">Volume panel</string> <string name="quick_settings_usb_tether_label">USB tethering</string> </resources> packages/SystemUI/src/com/android/systemui/qs/tiles/UsbTetherTile.java 0 → 100644 +119 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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. */ package com.android.systemui.qs.tiles; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.usb.UsbManager; import android.provider.Settings; import android.net.ConnectivityManager; import com.android.internal.logging.MetricsConstants; import com.android.systemui.R; import com.android.systemui.qs.QSTile; /** * USB Tether quick settings tile */ public class UsbTetherTile extends QSTile<QSTile.BooleanState> { private static final Intent WIRELESS_SETTINGS = new Intent(Settings.ACTION_WIRELESS_SETTINGS); private final ConnectivityManager mConnectivityManager; private boolean mListening; private boolean mUsbTethered = false; private boolean mUsbConnected = false; public UsbTetherTile(Host host) { super(host); mConnectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); } protected BooleanState newTileState() { return new BooleanState(); } @Override public void setListening(boolean listening) { if (mListening == listening) return; mListening = listening; if (listening) { final IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_STATE); mContext.registerReceiver(mReceiver, filter); } else { mContext.unregisterReceiver(mReceiver); } } @Override protected void handleClick() { mConnectivityManager.setUsbTethering(!mUsbTethered); } @Override protected void handleLongClick() { mHost.startActivityDismissingKeyguard(WIRELESS_SETTINGS); } private void updateState() { String[] tetheredIfaces = mConnectivityManager.getTetheredIfaces(); String[] usbRegexs = mConnectivityManager.getTetherableUsbRegexs(); mUsbTethered = false; for (String s : tetheredIfaces) { for (String regex : usbRegexs) { if (s.matches(regex)) { mUsbTethered = true; return; } } } } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mUsbConnected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false); if (mUsbConnected && mConnectivityManager.isTetheringSupported()) { updateState(); } else { mUsbTethered = false; } refreshState(); } }; @Override protected void handleUpdateState(BooleanState state, Object arg) { state.visible = mUsbConnected && mConnectivityManager.isTetheringSupported(); state.value = mUsbTethered; state.label = mContext.getString(R.string.quick_settings_usb_tether_label); state.icon = mUsbTethered ? ResourceIcon.get(R.drawable.ic_qs_usb_tether_on) : ResourceIcon.get(R.drawable.ic_qs_usb_tether_off); } @Override public int getMetricsCategory() { return MetricsConstants.DONT_TRACK_ME_BRO; } } packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.android.systemui.qs.tiles.NfcTile; import com.android.systemui.qs.tiles.ProfilesTile; import com.android.systemui.qs.tiles.RotationLockTile; import com.android.systemui.qs.tiles.SyncTile; import com.android.systemui.qs.tiles.UsbTetherTile; import com.android.systemui.qs.tiles.VolumeTile; import com.android.systemui.qs.tiles.WifiTile; import com.android.systemui.statusbar.CustomTileData; Loading Loading @@ -340,6 +341,7 @@ public class QSTileHost implements QSTile.Host, Tunable { else if (tileSpec.equals("profiles")) return new ProfilesTile(this); else if (tileSpec.equals("sync")) return new SyncTile(this); else if (tileSpec.equals("volume_panel")) return new VolumeTile(this); else if (tileSpec.equals("usb_tether")) return new UsbTetherTile(this); else if (tileSpec.startsWith(IntentTile.PREFIX)) return IntentTile.create(this,tileSpec); else throw new IllegalArgumentException("Bad tile spec: " + tileSpec); } Loading Loading @@ -416,6 +418,7 @@ public class QSTileHost implements QSTile.Host, Tunable { else if (spec.equals("profiles")) return R.string.quick_settings_profiles; else if (spec.equals("sync")) return R.string.quick_settings_sync_label; else if (spec.equals("volume_panel")) return R.string.quick_settings_volume_panel_label; else if (spec.equals("usb_tether")) return R.string.quick_settings_usb_tether_label; return 0; } Loading Loading
packages/SystemUI/res/drawable/ic_qs_usb_tether_off.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The CyanogenMod 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:width="64dp" android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> <path android:fillColor="#4DFFFFFF" android:pathData="M48.677,29.715h5.255v-7.254h4.401l-7.047-9.612l-7.052,9.612h4.443V29.715z M54.688,46.753l3.645-4.971h-4.401v-7.255 h-5.255v6.215L54.688,46.753z M36.741,28.805v-3.923h2.109v-8.445h-8.444v6.034L36.741,28.805z M23.942,16.007v-1.679h4.562 l-6.547-8.976l-3.656,5.014L23.942,16.007z M28.916,34.699l22.692,22.692l3.324-3.324L7.6,6.734l-3.324,3.323l15.693,15.694 l0.004,10.381l-8.571-3.715v-3.896c1.257-0.734,2.111-2.079,2.111-3.639c0-2.33-1.887-4.222-4.224-4.222 c-2.332,0-4.222,1.892-4.222,4.222c0,1.56,0.854,2.905,2.113,3.639v6.668l12.794,5.547v5.609c-2.518,0.837-4.348,3.185-4.348,5.987 c0,3.495,2.835,6.333,6.332,6.333c3.501,0,6.337-2.838,6.337-6.333c0-2.802-1.83-5.15-4.352-5.987v-9.113L28.916,34.699z M23.938,29.72l1.843,1.843l-1.839,0.93L23.938,29.72z" /> </vector> No newline at end of file
packages/SystemUI/res/drawable/ic_qs_usb_tether_on.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <!-- Copyright (C) 2015 The CyanogenMod 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:width="64dp" android:height="64dp" android:viewportWidth="64" android:viewportHeight="64"> <path android:fillColor="#FFFFFF" android:pathData="M48.677,29.724h5.255V22.47h4.401l-7.047-9.611l-7.052,9.611h4.443V29.724z M48.677,34.537h5.255v7.254h4.401l-7.047,9.611 l-7.052-9.611h4.443V34.537z M38.85,16.447h-8.444v8.445h2.11v3.251l-8.574,4.36V14.337h4.562l-6.547-8.975l-6.545,8.975h4.561 v21.805l-8.571-3.715v-3.896c1.257-0.734,2.111-2.079,2.111-3.639c0-2.33-1.887-4.222-4.224-4.222c-2.332,0-4.222,1.892-4.222,4.222c0,1.56,0.854,2.905,2.113,3.639v6.668l12.794,5.547v5.609c-2.518,0.837-4.348,3.184-4.348,5.987c0,3.495,2.835,6.333,6.332,6.333c3.501,0,6.337-2.838,6.337-6.333c0-2.802-1.83-5.15-4.352-5.987v-9.113l12.798-6.512v-5.839h2.11L38.85,16.447L38.85,16.447z" /> </vector> No newline at end of file
packages/SystemUI/res/values/cm_strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -122,4 +122,5 @@ <string name="accessibility_quick_settings_sync_changed_on">Sync turned on.</string> <string name="quick_settings_sync_label">Sync</string> <string name="quick_settings_volume_panel_label">Volume panel</string> <string name="quick_settings_usb_tether_label">USB tethering</string> </resources>
packages/SystemUI/src/com/android/systemui/qs/tiles/UsbTetherTile.java 0 → 100644 +119 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 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. */ package com.android.systemui.qs.tiles; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.hardware.usb.UsbManager; import android.provider.Settings; import android.net.ConnectivityManager; import com.android.internal.logging.MetricsConstants; import com.android.systemui.R; import com.android.systemui.qs.QSTile; /** * USB Tether quick settings tile */ public class UsbTetherTile extends QSTile<QSTile.BooleanState> { private static final Intent WIRELESS_SETTINGS = new Intent(Settings.ACTION_WIRELESS_SETTINGS); private final ConnectivityManager mConnectivityManager; private boolean mListening; private boolean mUsbTethered = false; private boolean mUsbConnected = false; public UsbTetherTile(Host host) { super(host); mConnectivityManager = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); } protected BooleanState newTileState() { return new BooleanState(); } @Override public void setListening(boolean listening) { if (mListening == listening) return; mListening = listening; if (listening) { final IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_STATE); mContext.registerReceiver(mReceiver, filter); } else { mContext.unregisterReceiver(mReceiver); } } @Override protected void handleClick() { mConnectivityManager.setUsbTethering(!mUsbTethered); } @Override protected void handleLongClick() { mHost.startActivityDismissingKeyguard(WIRELESS_SETTINGS); } private void updateState() { String[] tetheredIfaces = mConnectivityManager.getTetheredIfaces(); String[] usbRegexs = mConnectivityManager.getTetherableUsbRegexs(); mUsbTethered = false; for (String s : tetheredIfaces) { for (String regex : usbRegexs) { if (s.matches(regex)) { mUsbTethered = true; return; } } } } private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { mUsbConnected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false); if (mUsbConnected && mConnectivityManager.isTetheringSupported()) { updateState(); } else { mUsbTethered = false; } refreshState(); } }; @Override protected void handleUpdateState(BooleanState state, Object arg) { state.visible = mUsbConnected && mConnectivityManager.isTetheringSupported(); state.value = mUsbTethered; state.label = mContext.getString(R.string.quick_settings_usb_tether_label); state.icon = mUsbTethered ? ResourceIcon.get(R.drawable.ic_qs_usb_tether_on) : ResourceIcon.get(R.drawable.ic_qs_usb_tether_off); } @Override public int getMetricsCategory() { return MetricsConstants.DONT_TRACK_ME_BRO; } }
packages/SystemUI/src/com/android/systemui/statusbar/phone/QSTileHost.java +3 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ import com.android.systemui.qs.tiles.NfcTile; import com.android.systemui.qs.tiles.ProfilesTile; import com.android.systemui.qs.tiles.RotationLockTile; import com.android.systemui.qs.tiles.SyncTile; import com.android.systemui.qs.tiles.UsbTetherTile; import com.android.systemui.qs.tiles.VolumeTile; import com.android.systemui.qs.tiles.WifiTile; import com.android.systemui.statusbar.CustomTileData; Loading Loading @@ -340,6 +341,7 @@ public class QSTileHost implements QSTile.Host, Tunable { else if (tileSpec.equals("profiles")) return new ProfilesTile(this); else if (tileSpec.equals("sync")) return new SyncTile(this); else if (tileSpec.equals("volume_panel")) return new VolumeTile(this); else if (tileSpec.equals("usb_tether")) return new UsbTetherTile(this); else if (tileSpec.startsWith(IntentTile.PREFIX)) return IntentTile.create(this,tileSpec); else throw new IllegalArgumentException("Bad tile spec: " + tileSpec); } Loading Loading @@ -416,6 +418,7 @@ public class QSTileHost implements QSTile.Host, Tunable { else if (spec.equals("profiles")) return R.string.quick_settings_profiles; else if (spec.equals("sync")) return R.string.quick_settings_sync_label; else if (spec.equals("volume_panel")) return R.string.quick_settings_volume_panel_label; else if (spec.equals("usb_tether")) return R.string.quick_settings_usb_tether_label; return 0; } Loading