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 +3 −0 Original line number Diff line number Diff line Loading @@ -200,4 +200,7 @@ <string name="accessibility_quick_settings_sync_on">Sync on.</string> <string name="accessibility_quick_settings_sync_changed_off">Sync turned off.</string> <string name="accessibility_quick_settings_sync_changed_on">Sync turned on.</string> <!-- USB tethering QS tile --> <string name="quick_settings_usb_tether_label">USB tethering</string> </resources> packages/SystemUI/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" --> <string name="quick_settings_tiles_stock" translatable="false"> wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,adb_network,ambient_display,caffeine,heads_up,sync wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,adb_network,ambient_display,caffeine,heads_up,sync,usb_tether </string> <!-- The tiles to display in QuickSettings --> Loading packages/SystemUI/src/com/android/systemui/qs/tiles/UsbTetherTile.java 0 → 100644 +129 −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.systemui.R; import com.android.systemui.qs.QSTile; import org.cyanogenmod.internal.logging.CMMetricsLogger; /** * 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); } public 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); } @Override public Intent getLongClickIntent() { return null; } 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.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 CharSequence getTileLabel() { return mContext.getString(R.string.quick_settings_usb_tether_label); } @Override public int getMetricsCategory() { return CMMetricsLogger.TILE_USB_TETHER; } } 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 +3 −0 Original line number Diff line number Diff line Loading @@ -200,4 +200,7 @@ <string name="accessibility_quick_settings_sync_on">Sync on.</string> <string name="accessibility_quick_settings_sync_changed_off">Sync turned off.</string> <string name="accessibility_quick_settings_sync_changed_on">Sync turned on.</string> <!-- USB tethering QS tile --> <string name="quick_settings_usb_tether_label">USB tethering</string> </resources>
packages/SystemUI/res/values/config.xml +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ <!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" --> <string name="quick_settings_tiles_stock" translatable="false"> wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,adb_network,ambient_display,caffeine,heads_up,sync wifi,cell,battery,dnd,flashlight,rotation,bt,airplane,nfc,location,hotspot,inversion,saver,work,cast,night,adb_network,ambient_display,caffeine,heads_up,sync,usb_tether </string> <!-- The tiles to display in QuickSettings --> Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/UsbTetherTile.java 0 → 100644 +129 −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.systemui.R; import com.android.systemui.qs.QSTile; import org.cyanogenmod.internal.logging.CMMetricsLogger; /** * 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); } public 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); } @Override public Intent getLongClickIntent() { return null; } 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.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 CharSequence getTileLabel() { return mContext.getString(R.string.quick_settings_usb_tether_label); } @Override public int getMetricsCategory() { return CMMetricsLogger.TILE_USB_TETHER; } }