diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 202e593..13bfea4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -16,6 +16,10 @@
+
+
+
+
diff --git a/res/drawable/ic_qs_sync.xml b/res/drawable/ic_qs_sync.xml
new file mode 100644
index 0000000..a207b8a
--- /dev/null
+++ b/res/drawable/ic_qs_sync.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
diff --git a/res/values/aospa_strings.xml b/res/values/aospa_strings.xml
index c97fa90..10d06a7 100644
--- a/res/values/aospa_strings.xml
+++ b/res/values/aospa_strings.xml
@@ -49,6 +49,11 @@
Vibrate
Silent
+
+ Sync
+ Sync off.
+ Sync on.
+
Bluetooth
Bluetooth is off
diff --git a/res/values/config.xml b/res/values/config.xml
index 0a358c1..e0605e1 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -8,8 +8,7 @@
- internet,bt,flashlight,dnd,alarm,airplane,nfc,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,caffeine,dataswitch,heads_up,dc_dimming
- internet,bt,flashlight,dnd,alarm,airplane,nfc,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,caffeine,dataswitch,heads_up,dc_dimming,aod,usb_tether,sound
+ internet,bt,flashlight,dnd,alarm,airplane,nfc,controls,wallet,rotation,battery,cast,screenrecord,mictoggle,cameratoggle,location,hotspot,inversion,saver,dark,work,night,reverse,reduce_brightness,qr_code_scanner,onehanded,color_correction,dream,caffeine,dataswitch,heads_up,dc_dimming,aod,usb_tether,sound,sync
diff --git a/src/co/aospa/systemui/qs/tileimpl/ParanoidQSFactoryImpl.java b/src/co/aospa/systemui/qs/tileimpl/ParanoidQSFactoryImpl.java
index 77fbecf..7336a1f 100644
--- a/src/co/aospa/systemui/qs/tileimpl/ParanoidQSFactoryImpl.java
+++ b/src/co/aospa/systemui/qs/tileimpl/ParanoidQSFactoryImpl.java
@@ -49,6 +49,7 @@ import com.android.systemui.qs.tiles.ReduceBrightColorsTile;
import com.android.systemui.qs.tiles.RotationLockTile;
import com.android.systemui.qs.tiles.ScreenRecordTile;
import com.android.systemui.qs.tiles.SoundTile;
+import com.android.systemui.qs.tiles.SyncTile;
import com.android.systemui.qs.tiles.UiModeNightTile;
import com.android.systemui.qs.tiles.WifiTile;
import com.android.systemui.qs.tiles.WorkModeTile;
@@ -71,7 +72,7 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
private final Provider mHeadsUpTileProvider;
private final Provider mDcDimmingTileProvider;
private final Provider mSoundTileProvider;
- private final Provider mUsbTetherTileProvider;
+ private final Provider mSyncTileProvider;
@Inject
public ParanoidQSFactoryImpl(Lazy qsHostLazy,
@@ -109,10 +110,9 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
Provider caffeineTileProvider,
Provider dataSwitchTileProvider,
Provider headsUpTileProvider,
- Provider dcDimTileProvider) {
Provider dcDimTileProvider,
Provider soundTileProvider,
- Provider usbTetherTileProvider) {
+ Provider syncTileProvider) {
super(qsHostLazy, customTileBuilderProvider, wifiTileProvider, internetTileProvider,
bluetoothTileProvider, cellularTileProvider, dndTileProvider,
colorInversionTileProvider, airplaneModeTileProvider, workModeTileProvider,
@@ -129,7 +129,7 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
mHeadsUpTileProvider = headsUpTileProvider;
mDcDimmingTileProvider = dcDimTileProvider;
mSoundTileProvider = soundTileProvider;
- mUsbTetherTileProvider = usbTetherTileProvider;
+ mSyncTileProvider = syncTileProvider;
}
@Nullable
@@ -144,10 +144,10 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
return mHeadsUpTileProvider.get();
case "dc_dimming":
return mDcDimmingTileProvider.get();
- case "usb_tether":
- return mUsbTetherTileProvider.get();
- case "sound":
+ case "sound":
return mSoundTileProvider.get();
+ case "sync":
+ return mSyncTileProvider.get();
default:
return super.createTileInternal(tileSpec);
}
diff --git a/src/co/aospa/systemui/qs/tiles/SyncTile.java b/src/co/aospa/systemui/qs/tiles/SyncTile.java
new file mode 100644
index 0000000..1375215
--- /dev/null
+++ b/src/co/aospa/systemui/qs/tiles/SyncTile.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod Project
+ * Copyright (C) 2017 The LineageOS 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 static com.android.internal.logging.MetricsLogger.VIEW_UNKNOWN;
+
+import android.content.ContentResolver;
+import android.content.Intent;
+import android.content.SyncStatusObserver;
+import android.os.Handler;
+import android.os.Looper;
+import android.service.quicksettings.Tile;
+import android.view.View;
+
+import androidx.annotation.Nullable;
+
+import com.android.internal.logging.MetricsLogger;
+import com.android.systemui.R;
+import com.android.systemui.dagger.qualifiers.Background;
+import com.android.systemui.dagger.qualifiers.Main;
+import com.android.systemui.plugins.ActivityStarter;
+import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.plugins.qs.QSTile.BooleanState;
+import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.logging.QSLogger;
+import com.android.systemui.qs.tileimpl.QSTileImpl;
+
+import javax.inject.Inject;
+
+/** Quick settings tile: Sync **/
+public class SyncTile extends QSTileImpl {
+
+ private final Icon mIcon = ResourceIcon.get(R.drawable.ic_qs_sync);
+
+ private Object mSyncObserverHandle = null;
+ private boolean mListening;
+
+ @Inject
+ public SyncTile(
+ QSHost host,
+ @Background Looper backgroundLooper,
+ @Main Handler mainHandler,
+ FalsingManager falsingManager,
+ MetricsLogger metricsLogger,
+ StatusBarStateController statusBarStateController,
+ ActivityStarter activityStarter,
+ QSLogger qsLogger
+ ) {
+ super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
+ statusBarStateController, activityStarter, qsLogger);
+ }
+
+ @Override
+ public BooleanState newTileState() {
+ return new BooleanState();
+ }
+
+ @Override
+ protected void handleClick(@Nullable View view) {
+ ContentResolver.setMasterSyncAutomatically(!mState.value);
+ refreshState();
+ }
+
+ @Override
+ public Intent getLongClickIntent() {
+ Intent intent = new Intent("android.settings.SYNC_SETTINGS");
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ return intent;
+ }
+
+ @Override
+ protected void handleUpdateState(BooleanState state, Object arg) {
+ state.value = ContentResolver.getMasterSyncAutomatically();
+ state.label = mContext.getString(R.string.quick_settings_sync_label);
+ state.icon = mIcon;
+ if (state.value) {
+ state.contentDescription = mContext.getString(
+ R.string.accessibility_quick_settings_sync_on);
+ state.state = Tile.STATE_ACTIVE;
+ } else {
+ state.contentDescription = mContext.getString(
+ R.string.accessibility_quick_settings_sync_off);
+ state.state = Tile.STATE_INACTIVE;
+ }
+ }
+
+ @Override
+ public CharSequence getTileLabel() {
+ return mContext.getString(R.string.quick_settings_sync_label);
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return VIEW_UNKNOWN;
+ }
+
+ @Override
+ public void handleSetListening(boolean listening) {
+ if (mListening == listening) return;
+ mListening = listening;
+
+ if (listening) {
+ mSyncObserverHandle = ContentResolver.addStatusChangeListener(
+ ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, mSyncObserver);
+ } else {
+ ContentResolver.removeStatusChangeListener(mSyncObserverHandle);
+ mSyncObserverHandle = null;
+ }
+ }
+
+ private SyncStatusObserver mSyncObserver = new SyncStatusObserver() {
+ public void onStatusChanged(int which) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ refreshState();
+ }
+ });
+ }
+ };
+}