Skip to content

Commit

Permalink
[3/3] add offscreen gestures
Browse files Browse the repository at this point in the history
Import KeyHandler from Omnirom 5.1

Thanks to Max Weninger and omnirom team

[1/3] spanish33/android_frameworks_base@bd1c73d
[2/3] spanish33/android_packages_apps_Settings@59cf81b
  • Loading branch information
spanish33 committed Oct 20, 2015
1 parent b68951f commit 6b3de47
Show file tree
Hide file tree
Showing 27 changed files with 662 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Find7Parts/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := Find7Parts
LOCAL_CERTIFICATE := platform

# Required so that symbols used by the jni library doesn't get stripped out
LOCAL_PROGUARD_ENABLED := disabled

include $(BUILD_PACKAGE)

include $(call all-makefiles-under,$(LOCAL_PATH))
32 changes: 32 additions & 0 deletions Find7Parts/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.omnirom.device"
android:sharedUserId="android.uid.system" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="21" />
<application
android:icon="@drawable/icon"
android:label="@string/offscreen_gestures_settings"
android:theme="@android:style/Theme.Material.Settings"
android:supportsRtl="true" >
<activity
android:name="org.omnirom.device.DeviceSettings"
android:exported="true"
android:label="@string/offscreen_gestures_settings"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="org.omnirom.device.Startup" >
<intent-filter android:priority="100" >
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
Binary file added Find7Parts/res/drawable-hdpi/Thumbs.db
Binary file not shown.
Binary file added Find7Parts/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Find7Parts/res/drawable-mdpi/Thumbs.db
Binary file not shown.
Binary file added Find7Parts/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Find7Parts/res/drawable-xhdpi/Thumbs.db
Binary file not shown.
Binary file added Find7Parts/res/drawable-xhdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Find7Parts/res/drawable/Thumbs.db
Binary file not shown.
Binary file added Find7Parts/res/drawable/ic_vibrations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions Find7Parts/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The OmniROM 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.
-->
<resources>
<string name="app_name">Find 7</string>
<string name="category_gestures_title">Appui écran éteint</string>
<string name="double_tap_wake_title_head">Double appui pour réveiller</string>
<string name="double_tap_wake_summary_head">Un double appui sur l\'écran réveille l\'appareil</string>
<string name="camera_title_head">Appareil photo</string>
<string name="camera_summary_head">Dessiner un cercle pour démarrer l\'appareil photo</string>
<string name="torch_title_head">Torche</string>
<string name="torch_summary_head">Dessiner un V pour afficher la torche</string>

<string name="offscreen_gestures_settings">hors gestes d écran</string>
</resources>
12 changes: 12 additions & 0 deletions Find7Parts/res/values-it/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Find 7</string>
<string name="category_gestures_title">Gesture da schermo spento</string>
<string name="double_tap_wake_title_head">Doppio tocco</string>
<string name="double_tap_wake_summary_head">Effettua un doppio tocco sullo schermo per attivare il device</string>
<string name="camera_title_head">Fotocamera</string>
<string name="camera_summary_head">Disegna un \"O\" per attivare la fotocamera</string>
<string name="torch_title_head">Torcia</string>
<string name="torch_summary_head">Disegna una \"V\" per attivare la torcia</string>

</resources>
25 changes: 25 additions & 0 deletions Find7Parts/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The OmniROM 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.
-->
<resources>
<string name="app_name">Find 7</string>
<string name="category_gestures_title">Off screen gestures</string>
<string name="double_tap_wake_title_head">Double tap to wake</string>
<string name="double_tap_wake_summary_head">Double tap on screen will wake the device</string>
<string name="camera_title_head">Camera</string>
<string name="camera_summary_head">Draw a circle to start camera</string>

<string name="offscreen_gestures_settings">Off screen gestures</string>
</resources>
24 changes: 24 additions & 0 deletions Find7Parts/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 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.
-->

<resources>
<!-- Theme for the activity com.android.phone.Settings, which is the
"Mobile network settings" screen (used on non-voice-capable
tablets as well as regular phone devices.) -->
<style name="Theme.Main" parent="@android:style/Theme.Holo">
<item name="android:actionBarStyle">@android:style/Widget.Holo.ActionBar.Solid</item>
</style>
</resources>
16 changes: 16 additions & 0 deletions Find7Parts/res/xml/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/category_gestures_title" >
<CheckBoxPreference
android:key="double_tap"
android:summary="@string/double_tap_wake_summary_head"
android:title="@string/double_tap_wake_title_head" />

<CheckBoxPreference
android:key="camera"
android:summary="@string/camera_summary_head"
android:title="@string/camera_title_head" />

</PreferenceCategory>

</PreferenceScreen>
66 changes: 66 additions & 0 deletions Find7Parts/src/org/omnirom/device/CameraGestureSwitch.java
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 CameraGestureSwitch implements OnPreferenceChangeListener {

private static final String FILE = "/proc/touchpanel/camera_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_CAMERA_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;
}

}
80 changes: 80 additions & 0 deletions Find7Parts/src/org/omnirom/device/DeviceSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.TwoStatePreference;
import android.view.MenuItem;

public class DeviceSettings extends PreferenceActivity {

public static final String KEY_DOUBLE_TAP_SWITCH = "double_tap";
public static final String KEY_CAMERA_SWITCH = "camera";

private TwoStatePreference mDoubleTapSwitch;
private TwoStatePreference mCameraSwitch;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);

addPreferencesFromResource(R.xml.main);

mDoubleTapSwitch = (TwoStatePreference) findPreference(KEY_DOUBLE_TAP_SWITCH);
mDoubleTapSwitch.setEnabled(DoubleTapSwitch.isSupported());
mDoubleTapSwitch.setChecked(DoubleTapSwitch.isEnabled(this));
mDoubleTapSwitch.setOnPreferenceChangeListener(new DoubleTapSwitch());

mCameraSwitch = (TwoStatePreference) findPreference(KEY_CAMERA_SWITCH);
mCameraSwitch.setEnabled(CameraGestureSwitch.isSupported());
mCameraSwitch.setChecked(CameraGestureSwitch.isEnabled(this));
mCameraSwitch.setOnPreferenceChangeListener(new CameraGestureSwitch());

}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
default:
break;
}
return super.onOptionsItemSelected(item);
}

@Override
protected void onResume() {
super.onResume();
}

@Override
protected void onPause() {
super.onPause();
}


@Override
protected void onDestroy() {
super.onDestroy();
}
}
66 changes: 66 additions & 0 deletions Find7Parts/src/org/omnirom/device/DoubleTapSwitch.java
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 DoubleTapSwitch implements OnPreferenceChangeListener {

private static final String FILE = "/proc/touchpanel/double_tap_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_DOUBLE_TAP_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;
}

}
Loading

0 comments on commit 6b3de47

Please sign in to comment.