forked from AOSParadox/android_device_oneplus_bacon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bacon : Update Find7Parts add torch gesture
- Loading branch information
Showing
8 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (C) 2013 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.omnirom.device; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.preference.Preference; | ||
import android.preference.Preference.OnPreferenceChangeListener; | ||
import android.preference.PreferenceManager; | ||
|
||
public class TorchGestureSwitch implements OnPreferenceChangeListener { | ||
|
||
private static final String FILE = "/proc/touchpanel/flashlight_enable"; | ||
|
||
public static boolean isSupported() { | ||
return Utils.fileWritable(FILE); | ||
} | ||
|
||
public static boolean isEnabled(Context context) { | ||
boolean enabled = Utils.getFileValueAsBoolean(FILE, false); | ||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); | ||
return sharedPrefs.getBoolean(DeviceSettings.KEY_TORCH_SWITCH, enabled); | ||
} | ||
|
||
/** | ||
* Restore setting from SharedPreferences. (Write to kernel.) | ||
* @param context The context to read the SharedPreferences from | ||
*/ | ||
public static void restore(Context context) { | ||
if (!isSupported()) { | ||
return; | ||
} | ||
|
||
boolean enabled = isEnabled(context); | ||
if(enabled) | ||
Utils.writeValue(FILE, "1"); | ||
else | ||
Utils.writeValue(FILE, "0"); | ||
} | ||
|
||
@Override | ||
public boolean onPreferenceChange(Preference preference, Object newValue) { | ||
Boolean enabled = (Boolean) newValue; | ||
if(enabled) | ||
Utils.writeValue(FILE, "1"); | ||
else | ||
Utils.writeValue(FILE, "0"); | ||
return true; | ||
} | ||
|
||
} |