• Stars
    star
    99
  • Rank 343,315 (Top 7 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Screen orientation detector for android

Build Status

Bubble is an Android library for obtaining screen orientation. By default, Android supports screen orientation changes by providing a callback. Unfortunately this mechanism has a huge drawback. When system handles the screen orientation change it recreates the view from scratch, making it impossible to create smooth transitions. Moreover if you lock the activity's orientation in AndroidManifest, the callback is not invoked any more. Thus if you would like to have a custom view transition on a screen orientation change, you have to detect it by yourself what is pretty complicated.

Thanks to Bubble you could achieve result as in a camera application. Widgets can be rotated without recreating the whole activity:

Kotlin

The Library, sample and unit tests are written fully in Kotlin and Bubble still is fully compatible with typical Java-Andorid projects.

Import

Import to project:

compile 'pl.touk.android:bubble:1.0.0'

Usage

Bubble provides information about screen orientation each time new orientation is detected. Provided orientation is one of the following:

  • PORTRAIT
  • REVERSE_PORTRAIT
  • LANDSCAPE
  • REVERSE_LANDSCAPE

To get information from Bubble you have to register for events, and if you do not want to receive events any more, should unregister to avoid memory leaks. Bubble provides two APIs that can be used.

RxJava

Please notice sample is written in Kotlin.

class BubbleSampleActivity : AppCompatActivity() {
    val bubble: Bubble = Bubble()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_bubble_sample)
        textView = findViewById(R.id.label) as TextView
        bubble.register(this)
            .subscribe { bubbleEvent: BubbleEvent -> rotateTo(bubbleEvent.orientation) }
    }
    ...
}

Callback

Please notice sample is written in Kotlin.

class BubbleSampleActivity : AppCompatActivity() {
    val bubble: Bubble = Bubble()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_bubble_sample)
        textView = findViewById(R.id.label) as TextView
        bubble.register({ bubbleEvent: BubbleEvent -> rotateTo(bubbleEvent.orientation) }, this)
    }
    ...
}

How does it work

Bubble uses an accelerometer to obtain Pitch and Roll of a telephone. An accelerometer is very sensitive so values are bunched and then Bubble produce a new event base on the bunch and the last obtained orientation.

License

Copyright 2015 original author or authors

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.

More Repositories

1

nussknacker

Low-code tool for automating actions on real time data | Stream processing for the users.
Scala
652
star
2

krush

Idiomatic persistence layer forย Kotlin
Kotlin
248
star
3

sputnik

Static code review for your Gerrit patchsets. Runs Checkstyle, PMD, FindBugs, Scalastyle, CodeNarc, JSLint for you!
Java
201
star
4

excel-export

excel-export grails plugin
Groovy
58
star
5

kotlin-exposed-realworld

Medium clone backend using Kotlin, Spring, Krush and Exposed. API as specified on https://realworld.io/
Kotlin
48
star
6

plumber

plumber helps you tame NiFi flow
Scala
44
star
7

sputnik-ci

Sputnik.ci - Continuous code reviews
Python
16
star
8

dockds

Docker contained database autoconfiguration for Spring Boot
Java
11
star
9

janusz

Slack bot for simplifying developer life
Java
10
star
10

http-mock-server

Groovy
9
star
11

nussknacker-kubernetes

Example deployment setup for running Nussknacker with Flink on Kubernetes cluster.
Shell
8
star
12

nussknacker-quickstart

Docker Demo for Nussknacker - A visual tool to define and run real-time decision algorithms. Brings agility to business teams, liberates developers to focus on technology.
Shell
8
star
13

ctrl-pkw

Informacje na temat akcji "policzymy gล‚osy w wyborach prezydenckich" i aplikacji dostฤ™pne na stronie
Java
8
star
14

nussknacker-helm

Helm chart installing Nussknacker
Shell
7
star
15

re-cms

A simple embeddable CMS
Clojure
6
star
16

akka-http-swagger

An attempt to automatically generate and serve swagger documentation for REST APIs built with akka-http
JavaScript
5
star
17

hades

High Availability Data Source
Java
5
star
18

touk-bash

Bash snippets for your development
Shell
5
star
19

influxdb-reporter

Reporter to Influxdb 0.9 implementing (extended) Dropwizard metrics API
Scala
5
star
20

excel-export-samples

Examples on how to use excel-export plugin
Groovy
5
star
21

camel-spock

Small library allowing you to test your Camel routes with Spock
Groovy
5
star
22

airboat

A no-ceremony code review app, firstly developed during summer internships (2012) at TouK
JavaScript
4
star
23

RapidOSS3TouK

TouK Open Source fork to RapidOSS v3. RapidOSS is delivered by iFountain (http://www.ifountain.com) and you should go for stabe/official builds there. This here is to allow us to share any work we can, so it can be merged back to officiall build if it's worth it.
Groovy
4
star
24

jedzieTramwaj

Scala
3
star
25

QuaK

2D liero/soldat-inspired game made in 2 MD during internal TouK hackaton
Kotlin
3
star
26

jpub-maven-plugin

Maven3 plugin that integrates Oracle JPublisher into Maven project lifecycle
Groovy
3
star
27

nussknacker-flink-compatibility

Additional code needed for using Nussknacker with different Flink versions
Scala
3
star
28

petasos

A better user interface for https://github.com/allegro/hermes
TypeScript
3
star
29

confitura-man

A simple JS game created during 1-day hackathon.
JavaScript
3
star
30

cxf-utils

Java
2
star
31

jedzie-tramwaj-web

CoffeeScript
2
star
32

duck404

JavaScript
2
star
33

krush-example

Example project using krush
Kotlin
2
star
34

ormtest

Framework for unit testing Spring based DAOs
Java
2
star
35

angular-typewriter

Typewriter angular directive
JavaScript
2
star
36

angular-workshop

Source code from workshop about AngularJS @ TouK
JavaScript
2
star
37

gxt-tools

Java
2
star
38

widerest

RESTful API for Broadleaf Commerce
Java
2
star
39

touk-framework

Java
2
star
40

sonar-file-alerts-plugin

This plugin raises alerts on file level in Sonar. It extends default behaviour, which raises alerts only at root project level.
Java
2
star
41

nussknacker-scenario-examples-library

Nussknacker Scenario Examples Library
Shell
1
star
42

nifi-oidc-quickstart

Example NiFi and NiFi Registry with authorization by external OpenId Connect provider
Shell
1
star
43

nussknacker-installation-example

Example, docker-based installation of Nu (https://github.com/TouK/nussknacker) and its dependencies.
Shell
1
star
44

nussknacker-firebase-example

Shell
1
star
45

nussknacker-elasticsearch-example

docker-compose example showing how to process business events stored on elasticsearch using nussknacker
Shell
1
star
46

devoxx-tv

Chromecast Hello World
JavaScript
1
star
47

gwtaculous

Java
1
star
48

touk-url

Haskell
1
star
49

nk-windows

Window manager used in Nussknacker (nussknacker.io)
TypeScript
1
star
50

ignite-issues

Java
1
star
51

nussknacker-sample-components

Sample components for Nussknacker
Scala
1
star
52

ksp-example

Kotlin Symbol Processing example
Kotlin
1
star
53

metatype-exporter-maven-plugin

Generate markdown file from OSGI metatype xml
Groovy
1
star
54

touk-angular-lib

CoffeeScript
1
star
55

nussknacker-benchmarks

Benchmarks for Nussknacker - A visual tool to define and run real-time decision algorithms. Brings agility to business teams, liberates developers to focus on technology.
Python
1
star