Giter Site home page Giter Site logo

bixi-android's Introduction

Bixi Android library

CircleCI License

Bixi library is an Android service receiving gesture events from Bixi Bluetooth devices

Download Bixi library Showcase from Google Play :

Download YoutubeTv library Showcase from Google Play

What is Bixi ?

Bixi is a small bluetooth touch-free controller with built in battery made by Bluemint Labs

bixi

Gestures

List of gesture events :

  • CENTER_TO_TOP
  • CENTER_TO_BOTTOM
  • CENTER_TO_LEFT
  • CENTER_TO_RIGHT
  • LINEAR_END
  • LINEAR_CHANGE (the specific value is given)
  • DOUBLE_TAP

How to include it in your Android project ?

with Gradle, from jcenter or maven central :

compile 'fr.bmartel:bixi-service:1.1'

How to use it ?

Use BixiClient service wrapper :

  • Kotlin example :
class MainActivity : Activity() {

    private lateinit var bixiClient: BixiClient

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        bixiClient = BixiClient(this, object : IBixiListener {
            override fun onServiceConnected() {
                Log.v("bixi-lib", "service is connected - ready to receive events")

                //start scanning
                bixiClient.startScan()
            }

            override fun onStartScan() {
                Log.v("bixi-lib", "scan started")
            }

            override fun onEndScan() {
                Log.v("bixi-lib", "scan stopped")
            }

            override fun onDeviceDiscovered(device: BtDevice) {
                Log.v("bixi-lib", "new Bixi device discovered : " + device.deviceName)

                //stop scanning
                bixiClient.stopScan()

                //connect to this device
                bixiClient.connectDevice(device.deviceAddress)
            }

            override fun onDeviceDisconnected(device: BtDevice) {
                Log.v("bixi-lib", "device disconnected : " + device.deviceName)
            }

            override fun onDeviceConnected(device: BtDevice) {
                Log.v("bixi-lib", "device connected : " + device.deviceName)

                //set a listener to be notified when a gesture event occur
                bixiClient.getDevice(device)!!.setBixiGestureListener(object : IGestureListener {
                    override fun onGestureChange(event: BixiEvent) {
                        Log.v("bixi-lib", "received gesture event : " + event.gesture)
                    }
                })
            }

            override fun onBluetoothOff() {
                Log.v("bixi-lib", "bluetooth hasn't been activated (user refused the popup)")
            }

            override fun onPermissionDenied() {
                Log.v("bixi-lib", "location permission was denied (necessary to scan)")
            }
        })
        bixiClient.init(this)
    }

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        bixiClient.onRequestPermissionsResult(requestCode, grantResults)
    }
}
  • Java example :
public class MainActivity extends Activity {

    BixiClient bixiClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        bixiClient = new BixiClient(this, new IBixiListener() {
            @Override
            public void onServiceConnected() {
                Log.v("bixi-lib", "service is connected - ready to receive events");

                //start scanning
                bixiClient.startScan();
            }

            @Override
            public void onStartScan() {
                Log.v("bixi-lib", "scan started");
            }

            @Override
            public void onEndScan() {
                Log.v("bixi-lib", "scan stopped");
            }

            @Override
            public void onDeviceDiscovered(BtDevice device) {
                Log.v("bixi-lib", "new Bixi device discovered : " + device.getDeviceName());

                //stop scanning
                bixiClient.stopScan();

                //connect to this device
                bixiClient.connectDevice(device.getDeviceAddress());
            }

            @Override
            public void onDeviceDisconnected(BtDevice device) {
                Log.v("bixi-lib", "device disconnected : " + device.getDeviceName());
            }

            @Override
            public void onDeviceConnected(BtDevice device) {
                Log.v("bixi-lib", "device connected : " + device.getDeviceName());

                //set a listener to be notified when a gesture event occur
                bixiClient.getDevice(device).setBixiGestureListener(new IGestureListener() {
                    @Override
                    public void onGestureChange(BixiEvent event) {
                        Log.v("bixi-lib", "received gesture event : " + event.getGesture());
                    }
                });
            }

            @Override
            public void onBluetoothOff() {
                Log.v("bixi-lib", "bluetooth hasn't been activated (user refused the popup)");
            }

            @Override
            public void onPermissionDenied() {
                Log.v("bixi-lib", "location permission was denied (necessary to scan)");
            }
        });
        bixiClient.init(this);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        bixiClient.onRequestPermissionsResult(requestCode, grantResults);
    }
}

In the app module, you can find an example using a Singleton

Requirements

This project require Android SDK 19+

Build Library

Get source code

git clone [email protected]:bertrandmartel/bixi-android.git
cd bixi-android

Build

./gradlew build

About

License

The MIT License (MIT) Copyright (c) 2017-2018 Bertrand Martel

bixi-android's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.