Add Sync QS Tile
Update aospa_strings.xml Update aospa_strings.xml Update config.xml fix for paranoid systemui Change-Id: I83811b5bb55c3102259561fdb86cc732bfb511f5
This commit is contained in:
parent
3413938093
commit
d3924fd818
|
@ -16,6 +16,10 @@
|
|||
<!-- DataSwitch tile -->
|
||||
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
|
||||
|
||||
<!-- Sync tile -->
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
||||
|
||||
<application
|
||||
tools:replace="android:appComponentFactory"
|
||||
android:appComponentFactory=".SystemUIAppComponentFactory">
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2015 The CyanogenMod 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="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:pathData="M0.01,0h24v24h-24V0z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M12,4V2.21c0-0.45-0.54-0.67-0.85-0.35L8.35,4.65c-0.2,0.2-0.2,0.51,0,0.71l2.79,2.79C11.46,8.46,12,8.24,12,7.79V6 c3.31,0,6,2.69,6,6c0,0.79-0.15,1.56-0.44,2.25c-0.15,0.36-0.04,0.77,0.23,1.04v0c0.51,0.51,1.37,0.33,1.64-0.34 C19.8,14.04,20,13.04,20,12C20,7.58,16.42,4,12,4z M12,18c-3.31,0-6-2.69-6-6c0-0.79,0.15-1.56,0.44-2.25 c0.15-0.36,0.04-0.77-0.23-1.04l0,0C5.7,8.2,4.84,8.38,4.57,9.05C4.2,9.96,4,10.96,4,12c0,4.42,3.58,8,8,8v1.79 c0,0.45,0.54,0.67,0.85,0.35l2.79-2.79c0.2-0.2,0.2-0.51,0-0.71l-2.79-2.79C12.54,15.54,12,15.76,12,16.21V18z" />
|
||||
</vector>
|
|
@ -49,6 +49,11 @@
|
|||
<string name="quick_settings_sound_vibrate">Vibrate</string>
|
||||
<string name="quick_settings_sound_silent">Silent</string>
|
||||
|
||||
<!-- Sync QS tile -->
|
||||
<string name="quick_settings_sync_label">Sync</string>
|
||||
<string name="accessibility_quick_settings_sync_off">Sync off.</string>
|
||||
<string name="accessibility_quick_settings_sync_on">Sync on.</string>
|
||||
|
||||
<!-- Bluetooth dialog -->
|
||||
<string name="turn_on_bluetooth">Bluetooth</string>
|
||||
<string name="bluetooth_is_off">Bluetooth is off</string>
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
<!-- Tiles native to System UI. Order should match "quick_settings_tiles_default" -->
|
||||
<string name="quick_settings_tiles_stock" translatable="false">
|
||||
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
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -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<HeadsUpTile> mHeadsUpTileProvider;
|
||||
private final Provider<DcDimmingTile> mDcDimmingTileProvider;
|
||||
private final Provider<SoundTile> mSoundTileProvider;
|
||||
private final Provider<UsbTetherTile> mUsbTetherTileProvider;
|
||||
private final Provider<SyncTile> mSyncTileProvider;
|
||||
|
||||
@Inject
|
||||
public ParanoidQSFactoryImpl(Lazy<QSHost> qsHostLazy,
|
||||
|
@ -109,10 +110,9 @@ public class ParanoidQSFactoryImpl extends QSFactoryImpl {
|
|||
Provider<CaffeineTile> caffeineTileProvider,
|
||||
Provider<DataSwitchTile> dataSwitchTileProvider,
|
||||
Provider<HeadsUpTile> headsUpTileProvider,
|
||||
Provider<DcDimmingTile> dcDimTileProvider) {
|
||||
Provider<DcDimmingTile> dcDimTileProvider,
|
||||
Provider<SoundTile> soundTileProvider,
|
||||
Provider<UsbTetherTile> usbTetherTileProvider) {
|
||||
Provider<SyncTile> 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);
|
||||
}
|
||||
|
|
|
@ -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<BooleanState> {
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue