Pong: DeviceExtras: Drop powershare switch
- We are using lineage powershare Signed-off-by: Abhay Singh Gill <abhaygill017@gmail.com>
This commit is contained in:
committed by
Ghosuto
parent
4b42f757f0
commit
cbc9de925e
@@ -73,18 +73,6 @@
|
||||
android:resource="@string/device_summary" />
|
||||
</activity>
|
||||
|
||||
<!-- PowerShare tile -->
|
||||
<service
|
||||
android:name="org.neoteric.device.DeviceExtras.PowerShareTileService"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/ic_powershare"
|
||||
android:label="@string/powershare_mode_title"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- OTG tile -->
|
||||
<service
|
||||
android:name="org.neoteric.device.DeviceExtras.OTGTileService"
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (C) 2020 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:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#000"
|
||||
android:pathData="M18,16.5v4.17C18,21.4,17.4,22,16.66,22H7.33C6.6,22,6,21.4,6,20.67V15V5.33C6,4.6,6.6,4,7.33,4H9.5V2h5v2h2.17 C17.4,4,18,4.6,18,5.33V7.5h-2V6H8v9v5h8v-3.5H18z M13,15.5h-2V14c0-1.65,1.35-3,3-3h4V9l3,3l-3,3v-2h-4c-0.55,0-1,0.45-1,1V15.5z"/>
|
||||
</vector>
|
||||
@@ -20,11 +20,6 @@
|
||||
<string name="device_title">Device Extras</string>
|
||||
<string name="device_summary">Adjust device specific settings</string>
|
||||
|
||||
<!-- Power -->
|
||||
<string name="power_title">Power</string>
|
||||
<string name="powershare_mode_title">Wireless powershare</string>
|
||||
<string name="powershare_mode_summary">Enable reverse wireless charging</string>
|
||||
|
||||
<!-- USB -->
|
||||
<string name="usb_title">USB</string>
|
||||
<string name="otg_mode_title">USB-OTG</string>
|
||||
|
||||
@@ -19,17 +19,6 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res/org.neoteric.device.DeviceExtras"
|
||||
android.title="@string/device_title">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="power"
|
||||
android:title="@string/power_title">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="powershare"
|
||||
android:icon="@drawable/ic_powershare"
|
||||
android:title="@string/powershare_mode_title"
|
||||
android:summary="@string/powershare_mode_summary" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="usb"
|
||||
android:title="@string/usb_title">
|
||||
@@ -40,4 +29,5 @@
|
||||
android:title="@string/otg_mode_title"
|
||||
android:summary="@string/otg_mode_summary" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
||||
@@ -34,10 +34,8 @@ import org.neoteric.device.DeviceExtras.FileUtils;
|
||||
import org.neoteric.device.DeviceExtras.R;
|
||||
|
||||
public class DeviceExtras extends PreferenceFragment {
|
||||
public static final String KEY_POWERSHARE_SWITCH = "powershare";
|
||||
public static final String KEY_OTG_SWITCH = "otg";
|
||||
|
||||
private static TwoStatePreference mPowerShareModeSwitch;
|
||||
private static TwoStatePreference mOTGModeSwitch;
|
||||
|
||||
@Override
|
||||
@@ -45,13 +43,6 @@ public class DeviceExtras extends PreferenceFragment {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getContext());
|
||||
addPreferencesFromResource(R.xml.main);
|
||||
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
// PowerShare
|
||||
mPowerShareModeSwitch = (TwoStatePreference) findPreference(KEY_POWERSHARE_SWITCH);
|
||||
if (PowerShareModeSwitch.isSupported()) {
|
||||
mPowerShareModeSwitch.setChecked(PowerShareModeSwitch.isCurrentlyEnabled());
|
||||
mPowerShareModeSwitch.setOnPreferenceChangeListener(new PowerShareModeSwitch());
|
||||
}
|
||||
|
||||
// OTG
|
||||
mOTGModeSwitch = (TwoStatePreference) findPreference(KEY_OTG_SWITCH);
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The OmniROM Project
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.neoteric.device.DeviceExtras;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
|
||||
import org.neoteric.device.DeviceExtras.FileUtils;
|
||||
|
||||
public class PowerShareModeSwitch implements OnPreferenceChangeListener {
|
||||
|
||||
public static final String FILE = "/sys/class/qcom-battery/wireless_boost_en";
|
||||
|
||||
public static boolean isSupported() {
|
||||
return FileUtils.fileWritable(FILE);
|
||||
}
|
||||
|
||||
public static boolean isCurrentlyEnabled() {
|
||||
return (isSupported() && FileUtils.getFileValueAsBoolean(FILE, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Boolean enabled = (Boolean) newValue;
|
||||
FileUtils.writeValue(FILE, enabled ? "1" : "0");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,6 @@ public class Startup extends BroadcastReceiver {
|
||||
public void onReceive(final Context context, final Intent bootintent) {
|
||||
boolean enabled = false;
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
enabled = sharedPrefs.getBoolean(DeviceExtras.KEY_POWERSHARE_SWITCH, false);
|
||||
if (PowerShareModeSwitch.isSupported() && enabled) {
|
||||
restore(PowerShareModeSwitch.FILE, enabled);
|
||||
}
|
||||
enabled = sharedPrefs.getBoolean(DeviceExtras.KEY_OTG_SWITCH, false);
|
||||
if (OTGModeSwitch.isSupported() && enabled) {
|
||||
restore(OTGModeSwitch.FILE, enabled);
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The OmniROM Project
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package org.neoteric.device.DeviceExtras;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.service.quicksettings.TileService;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.neoteric.device.DeviceExtras.DeviceExtras;
|
||||
|
||||
public class PowerShareTileService extends TileService {
|
||||
@Override
|
||||
public void onStartListening() {
|
||||
super.onStartListening();
|
||||
updateState();
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
Tile mTile = getQsTile();
|
||||
if (mTile != null) {
|
||||
boolean enabled = getEnabled();
|
||||
mTile.setSubtitle(enabled ?
|
||||
getString(R.string.accessibility_quick_settings_on) :
|
||||
getString(R.string.accessibility_quick_settings_off));
|
||||
mTile.setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
|
||||
mTile.updateTile();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
super.onClick();
|
||||
setEnabled(!getEnabled());
|
||||
updateState();
|
||||
}
|
||||
|
||||
private boolean getEnabled() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(this).getBoolean(DeviceExtras.KEY_POWERSHARE_SWITCH, false);
|
||||
}
|
||||
|
||||
private void setEnabled(boolean enabled) {
|
||||
FileUtils.writeValue(PowerShareModeSwitch.FILE, enabled ? "1" : "0");
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
sharedPrefs.edit().putBoolean(DeviceExtras.KEY_POWERSHARE_SWITCH, enabled).apply();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user