Skip to content

michelelacorte/ForceTouch

Repository files navigation

ForceTouch

Simple implementation of ForceTouch on Android

Twitter

API

License

Android Arsenal

##WHAT IS FORCE TOUCH?

You know that Android already detects different screen pressure from API 5? (Eclair, Android 2.0)

Well, I wanted to enlighten you about it, I created a library for Android that takes advantage of this property to implement the Force Touch (or 3D Touch), I have also created a dedicated app to give the opportunity for developers and not, try this library, the app is on the Play Store.

This library can also be used on the launcher and by doing so you can implement ForceTouch on icons of the applications, not using the Long Press (shortcut) introduced in android 7.1. I set myself a custom launcher to test the touch force and are currently in the testing phase, just ready you will see everything on GitHub.

##DONATIONS

This project needs you! If you would like to support this project's further development, the creator of this project or the continuous maintenance of this project, feel free to donate. Your donation is highly appreciated (and I love food, coffee and beer). Thank you!

PayPal

  • Donate $5: Thank's for creating this project, here's a coffee (or some beer) for you!

  • Donate $10: Wow, I am stunned. Let me take you to the movies!ù

  • Donate $15: I really appreciate your work, let's grab some lunch!

  • Donate $25: That's some awesome stuff you did right there, dinner is on me!

  • Donate $50: I really really want to support this project, great job!

  • Donate $100: You are the man! This project saved me hours (if not days) of struggle and hard work, simply awesome!

  • Donate $2799: Go buddy, buy Macbook Pro for yourself!

Of course, you can also choose what you want to donate! All donations are awesome!! Follow this link Donate!!

If you want to contribute you may download Donation App from Google Play

#v2.0.0 Big Update!! (Coming Soon)

###Here we are! ###The touch force is ready and is going to get on the custom launcher !!

###As promised I've implemented Force Touch in my custom launcher ... and you see the picture

###Yes, I'm working with shortcuts Android 7.1 Nougat! and will soon be available for custom launcher from API 14 !! ###See an example here (beta)

###I've also implemented Activity to calibrate Force Touch depending on screen device!! ###Stay Tuned! ###For changelog see v2.0.0 in CHANGELOG section

##EXAMPLE

####Force Touch is on Google Play!!!

Get it on Google Play

####If you want to help me please download Donation App!!

Get it on Google Play

alt tag

##USAGE

Add this to build.gradle

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

Than add this dependencies

compile 'com.github.michelelacorte:ForceTouch:1.0.1'
final ForceTouchListener forceTouchListener = new ForceTouchListener(getApplicationContext(), 70, 0.27f, true, true, new Callback() {
                        @Override
                        public void onForceTouch() {
                            //functionToInvokeOnForceTouch();
                        }

                        @Override
                        public void onNormalTouch() { 
                            //functionToInvokeOnNormalTouch(); 
                        }
                    });

Than you can use Listener with setOnTouchListener method of View

view.setOnTouchListener(forceTouchListener);

##SYSTEM REQUIREMENT

Android API 14+

##STATUS

project maintained

##CHANGELOG

v2.0.0 (Coming Soon!)

  • Added params View view, MotionEvent motionEvent to onNormalTouch and onForceTouch callback method
  • Added ForceTouchGestureListener for set force touch to custom Launcher! (similar to ForceTouchListener class)
  • Added Activity Calibration to calibrate force touch before use it!

v1.0.1

  • Added isProgressive boolean to detect progressive pressure! (Default false).
  • Added isVibrate boolean to set vibration.
  • Added method onNormalTouch to Callback interface, the method is invoked when pressure is low (not overtake pressureLimit).
  • Interface ForceTouchExecution renamed with Callback.
  • Improved example App.

v1.0.0

  • Support API 14+ (API 25 Compatible)
  • Added class ForceTouchListener with constructor to create Force Touch witch custom param.
  • Added interface ForceTouchExecution with method onForceTouch for define custom action onForceTouch detected.
  • Added example App.

##CREDITS

Author: Michele Lacorte (micky1995g@gmail.com)

Follow my Google+

##CONTRIBUTING

If you want to contribute to the project fork it and open Pull Request, or contact me by e-mail.

Each proposal will be accepted!

##LICENSE

Copyright 2016 Michele Lacorte

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.

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay