aboutsummaryrefslogtreecommitdiff
path: root/configpanel/src
diff options
context:
space:
mode:
Diffstat (limited to 'configpanel/src')
-rw-r--r--configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java31
-rw-r--r--configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java86
-rw-r--r--configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java82
-rw-r--r--configpanel/src/org/lineageos/settings/device/Constants.java40
-rw-r--r--configpanel/src/org/lineageos/settings/device/Startup.java62
-rw-r--r--configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java43
-rw-r--r--configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java71
7 files changed, 0 insertions, 415 deletions
diff --git a/configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java b/configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java
deleted file mode 100644
index 737dbd5..0000000
--- a/configpanel/src/org/lineageos/settings/device/ButtonSettingsActivity.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2016 The CyanogenMod Project
- * (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 org.lineageos.settings.device;
-
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-
-public class ButtonSettingsActivity extends PreferenceActivity {
-
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- getFragmentManager().beginTransaction().replace(android.R.id.content,
- new ButtonSettingsFragment()).commit();
- }
-}
diff --git a/configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java b/configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java
deleted file mode 100644
index 493aac9..0000000
--- a/configpanel/src/org/lineageos/settings/device/ButtonSettingsFragment.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2016 The CyanogenMod Project
- * (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 org.lineageos.settings.device;
-
-import android.app.ActionBar;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.support.v14.preference.PreferenceFragment;
-import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.ListPreference;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.PreferenceCategory;
-import android.support.v7.preference.PreferenceManager;
-import android.text.TextUtils;
-import android.view.MenuItem;
-
-import org.lineageos.internal.util.FileUtils;
-import org.lineageos.internal.util.PackageManagerUtils;
-
-public class ButtonSettingsFragment extends PreferenceFragment
- implements OnPreferenceChangeListener {
-
- @Override
- public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
- addPreferencesFromResource(R.xml.button_panel);
- final ActionBar actionBar = getActivity().getActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
- }
-
- @Override
- public boolean onPreferenceChange(Preference pref, Object newValue) {
- SwitchPreferenceBackend backend = Constants.sBackendsMap.get(pref.getKey());
- Boolean value = (Boolean) newValue;
-
- backend.setValue(value);
-
- return true;
- }
-
- @Override
- public void addPreferencesFromResource(int preferencesResId) {
- super.addPreferencesFromResource(preferencesResId);
-
- // Initialize node preferences
- for (String key : Constants.sBackendsMap.keySet()) {
- SwitchPreference pref = (SwitchPreference) findPreference(key);
- if (pref == null) {
- continue;
- }
-
- pref.setOnPreferenceChangeListener(this);
-
- SwitchPreferenceBackend backend = Constants.sBackendsMap.get(key);
- if (!backend.isValid()) {
- pref.setEnabled(false);
- } else {
- pref.setChecked(backend.getValue());
- }
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == android.R.id.home) {
- getActivity().onBackPressed();
- return true;
- }
- return false;
- }
-}
diff --git a/configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java b/configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java
deleted file mode 100644
index b91d8b1..0000000
--- a/configpanel/src/org/lineageos/settings/device/ConfigPanelSearchIndexablesProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2016 The CyanogenMod Project
- * (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 org.lineageos.settings.device;
-
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.provider.SearchIndexableResource;
-import android.provider.SearchIndexablesProvider;
-
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_CLASS_NAME;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_ICON_RESID;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_ACTION;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RANK;
-import static android.provider.SearchIndexablesContract.COLUMN_INDEX_XML_RES_RESID;
-import static android.provider.SearchIndexablesContract.INDEXABLES_RAW_COLUMNS;
-import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
-import static android.provider.SearchIndexablesContract.NON_INDEXABLES_KEYS_COLUMNS;
-
-public class ConfigPanelSearchIndexablesProvider extends SearchIndexablesProvider {
- private static final String TAG = "ConfigPanelSearchIndexablesProvider";
-
- public static final int SEARCH_IDX_BUTTON_PANEL = 0;
-
- private static SearchIndexableResource[] INDEXABLE_RES = new SearchIndexableResource[]{
- new SearchIndexableResource(1, R.xml.button_panel,
- ButtonSettingsActivity.class.getName(),
- R.drawable.ic_settings_additional_buttons),
- };
-
- @Override
- public boolean onCreate() {
- return true;
- }
-
- @Override
- public Cursor queryXmlResources(String[] projection) {
- MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
- cursor.addRow(generateResourceRef(INDEXABLE_RES[SEARCH_IDX_BUTTON_PANEL]));
- return cursor;
- }
-
- private static Object[] generateResourceRef(SearchIndexableResource sir) {
- Object[] ref = new Object[7];
- ref[COLUMN_INDEX_XML_RES_RANK] = sir.rank;
- ref[COLUMN_INDEX_XML_RES_RESID] = sir.xmlResId;
- ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = null;
- ref[COLUMN_INDEX_XML_RES_ICON_RESID] = sir.iconResId;
- ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = "com.android.settings.action.EXTRA_SETTINGS";
- ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = "org.lineageos.settings.device";
- ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = sir.className;
- return ref;
- }
-
- @Override
- public Cursor queryRawData(String[] projection) {
- MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
- return cursor;
- }
-
- @Override
- public Cursor queryNonIndexableKeys(String[] projection) {
- MatrixCursor cursor = new MatrixCursor(NON_INDEXABLES_KEYS_COLUMNS);
- return cursor;
- }
-}
diff --git a/configpanel/src/org/lineageos/settings/device/Constants.java b/configpanel/src/org/lineageos/settings/device/Constants.java
deleted file mode 100644
index fd77073..0000000
--- a/configpanel/src/org/lineageos/settings/device/Constants.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2016 The CyanogenMod Project
- * (C) 2017-2018 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 org.lineageos.settings.device;
-
-import org.lineageos.internal.util.FileUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Constants {
-
- // Preference keys
- public static final String BUTTON_SWAP_KEY = "button_swap";
-
- // Nodes
- public static final String BUTTON_SWAP_PATH = "/proc/touchpanel/reversed_keys_enable";
-
- // Holds <preference_key> -> <proc_node> mapping
- public static final Map<String, SwitchPreferenceBackend> sBackendsMap = new HashMap<>();
-
- static {
- sBackendsMap.put(BUTTON_SWAP_KEY,
- new SwitchPreferenceFilesBackend(BUTTON_SWAP_PATH, false));
- }
-}
diff --git a/configpanel/src/org/lineageos/settings/device/Startup.java b/configpanel/src/org/lineageos/settings/device/Startup.java
deleted file mode 100644
index d3af1de..0000000
--- a/configpanel/src/org/lineageos/settings/device/Startup.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2016 The CyanogenMod Project
- * (C) 2017-2018 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 org.lineageos.settings.device;
-
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.SharedPreferences;
-import android.support.v7.preference.PreferenceManager;
-import android.util.Log;
-
-import org.lineageos.internal.util.FileUtils;
-
-public class Startup extends BroadcastReceiver {
-
- private static final String TAG = Startup.class.getSimpleName();
-
- @Override
- public void onReceive(Context context, Intent intent) {
- final String action = intent.getAction();
- if (lineageos.content.Intent.ACTION_INITIALIZE_LINEAGE_HARDWARE.equals(action)) {
- enableComponent(context, ButtonSettingsActivity.class.getName());
-
- // Restore saved preference values
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- for (String key : Constants.sBackendsMap.keySet()) {
- SwitchPreferenceBackend backend = Constants.sBackendsMap.get(key);
- Boolean value = preferences.getBoolean(key, backend.getDefaultValue());
-
- backend.setValue(value);
- }
- }
- }
-
- private void enableComponent(Context context, String component) {
- ComponentName name = new ComponentName(context, component);
- PackageManager pm = context.getPackageManager();
- if (pm.getComponentEnabledSetting(name)
- == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
- pm.setComponentEnabledSetting(name,
- PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
- PackageManager.DONT_KILL_APP);
- }
- }
-}
diff --git a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java b/configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java
deleted file mode 100644
index 3100f4a..0000000
--- a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceBackend.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2018 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 org.lineageos.settings.device;
-
-public abstract class SwitchPreferenceBackend {
- protected Boolean mDefaultValue;
- protected Boolean mValue;
-
- public SwitchPreferenceBackend(Boolean defaultValue) {
- mDefaultValue = defaultValue;
- mValue = defaultValue;
- }
-
- public Boolean getValue() {
- return mValue;
- }
-
- public Boolean getDefaultValue() {
- return mDefaultValue;
- }
-
- public void setDefaultValue() {
- setValue(mDefaultValue);
- }
-
- public abstract void setValue(Boolean value);
-
- public abstract Boolean isValid();
-}
diff --git a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java b/configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java
deleted file mode 100644
index f701bbc..0000000
--- a/configpanel/src/org/lineageos/settings/device/SwitchPreferenceFilesBackend.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2018 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 org.lineageos.settings.device;
-
-import org.lineageos.internal.util.FileUtils;
-
-public class SwitchPreferenceFilesBackend extends SwitchPreferenceBackend {
-
- private String[] mPaths;
- private Boolean mValid;
-
- public SwitchPreferenceFilesBackend(String[] paths, Boolean defaultValue) {
- super(defaultValue);
- mPaths = paths;
- updateValidity();
- }
-
- public SwitchPreferenceFilesBackend(String path, Boolean defaultValue) {
- this(new String[]{path}, defaultValue);
- }
-
- @Override
- public void setValue(Boolean value) {
- for (String path : mPaths) {
- if (!FileUtils.isFileWritable(path)) {
- continue;
- }
-
- FileUtils.writeLine(path, value ? "1" : "0");
- }
-
- mValue = value;
- }
-
- @Override
- public Boolean isValid() {
- return mValid;
- }
-
- private void updateValidity() {
- Boolean valid = false;
-
- /*
- * Only one path might be available on a specific device,
- * but we need to try multiple to handle multiple kernel drivers.
- * Cache the validity to avoid slow fragment rendering times.
- */
- for (String path : mPaths) {
- if (FileUtils.isFileReadable(path) && FileUtils.isFileWritable(path)) {
- valid = true;
- break;
- }
- }
-
- mValid = valid;
- }
-}