Git Product home page Git Product logo

irurueta-android-gesture-bitmap-view's Introduction

irurueta-android-gesture-bitmap-view

A touch gesture capable Android view to display bitmaps and perform scaling, translation and rotation on the bitmap

Build Status

Code Smells Coverage

Duplicated lines Lines of code

Maintainability Quality gate Reliability

Security Technical debt Vulnerabilities

Maven Central

API Documentation

Overview

This library contains a view that can display a bitmap an handle touch gestures to translate, scale and rotate displayed bitmap.

Demo

Usage

Add the following dependency to your project:

implementation 'com.irurueta:irurueta-android-gesture-bitmap-view:1.0.1'

The view can be added to your xml layout as the example below:

    <com.irurueta.android.gesturebitmap.GestureBitmapView
        android:id="@+id/gesture_bitmap"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:src="@drawable/image"/>

The following properties are supported in xml layouts:

  • src: drawable to be displayed
  • displayType: enum to indicate the way the bitmap is initially displayed. The following options are supported:
    • none: bitmap is displayed at original scale, without additional rotation or translation.
    • fit_if_bigger: bitmap is initially scaled only if bigger than the limits of the view.
    • fit_x_top: bitmap is initially scaled to fit horizontally while keeping aspect ratio. Bitmap is aligned on top border of the view.
    • fit_x_bottom: bitmap is initially scaled to fit horizontally while keeping aspect ratio. Bitmap is aligned on bottom border of the view.
    • fit_x_center: bitmap is initially scaled to fit horizontally while keeping aspect ratio. Bitmap is vertically centered.
    • fit_y_left: bitmap is initially scaled to fit vertically while keeping aspect ratio. Bitmap is aligned to the left border of the view.
    • fit_y_right: bitmap is initially scaled to fit vertically while keeping aspect ratio. Bitmap is aligned to the right border of the view.
    • fit_y_center: bitmap is initially scaled to fit vertically while keeping aspect ratio. Bitmap is horizontally centered.
    • center_crop: bitmap is initially scaled to fill the whole view and centered on the view while preserving aspect ratio.
  • animationDurationMillis: duration of animations when doing smoooth scaling or translation and expressed in milliseconds.
  • rotationEnabled: indicates whether the view handles rotation gestures with two fingers. If false, bitmap rotations are not allowed.
  • scaleEnabled: indicates whether the view handles pinch gestures to zoom bitmap. If false, bitmap scaling is not allowed.
  • scrollEnabled: indicates whether the view handles scroll gestures to translate bitmap. If false, scrolling is not allowed.
  • twoFingerScrollEnabled: indicates whether scrolling can be done with two fingers. If enabled, scrolling can be done while doing scaling or rotation (if those are enabled as well), otherwise scrolling can only be done with one finger (if scrolling is also enabled).
  • exclusiveTwoFingerScrollEnabled: indicates whether scroll using two fingers is exclusive. When this is true, and both scrollEnabled and twoFingerScrollEnabled are also true, then scroll is disabled with one finger and can only be done with two fingers. If false and both scrollEnabled and twoFingerScrollEnabled, then scroll can be made with both one or two fingers.
  • doubleTapEnabled: indicates whether double tap can be used to increase the scale at tapped location by a certain jump factor.
  • minScale: minimum allowed scale to display the bitmap. This is only taken into account if scale is enabled. When double tap is enabled and maximum scale is reached, then the next double tap resets scale to this value.
  • maxScale: maximum allowed scale to display the bitmap. This is only taken into account if scale is enabled. When double tap is enabled and this scale is reached, then the next double tap resets scale to the minimum value.
  • scaleFactorJump: scale factor to increase the scale when double tap is done.
  • minScaleMargin: amount of margin given when minimum scale is exceeded. A positive value can be used to make a bouncing effect, so that bitmap bounces back to minimum scale when such scale is exceeded.
  • maxScaleMargin: amount of margin given when maximum scale is exceeded. A positive value can be used to make a bouncing effect, so that bitmap bounces back to maximum scale when such scale is exceeded.
  • leftScrollMargin: amount of left margin given when left boundary of bitmap is reached while scrolling. A positive value can be used to make a bouncing effect, so that bitmap bounces back to the left side when left boundary is exceeded.
  • topScrollMargin: amount of top margin given when top boundary of bitmap is reached while scrolling. A positive value can be used to make a bouncing effect, so that bitmap bounces back to the top side when top boundary is exceeded.
  • rightScrollMargin: amount of right margin given when right boundary of bitmap is reached while scrolling. A positive value can be used to make a bouncing effect, so that bitmap bounces back to the right side when right boundary is exceeded.
  • bottomScrollMargin: amount of bottom margin given when bottom boundary of bitmap is reached while scrolling. A positive value can be used to make a bouncing effect, so that bitmap bounces back to the bottom side when bottom boundary is reached.

Additional details

This library is contained within the lib module in source code. app module contains an example of an application using the view contained in the lib module.

Gradle taks

To execute all unit tests, execute:

gradlew test

To execute all instrumentation tests, first make sure you have connected a device or emulator and execute:

gradlew connectedAndroidTest

If you only want to run tests of a specific module, execute:

gradlew lib:test

or

gradlew lib:connectedAndroidTest

where "lib" is the name of the library module in the project

To generate documentation, run:

gradlew dokkaHtml

To execute sonarqube, run:

gradlew sonarqube

To convert exec files to xml and html reports:

java -jar jacoco-0.8.7/lib/jacococli.jar report lib/build/jacoco/testReleaseUnitTest.exec --classfiles lib/build/tmp/kotlin-classes/release --html lib/build/reports/coverage/test --xml lib/build/reports/coverage/test/report.xml

Github actions to release library in maven central has been configured following: https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/

irurueta-android-gesture-bitmap-view's People

Contributors

albertoirurueta avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

irurueta-android-gesture-bitmap-view's Issues

Support for tension when overscrolling

Currently when overscrolling, when a limit is reached, scrolling suddenly stops and when user releases, bitmap bounces back to the expected position.
A smoother implementation could be made by adding increasing tension as the user overscrolls.

Fling on rotation

Currently when releasing after scrolling fast, a fling event is generated that further scrolls the bitmap depending on previous scrolling speed.

A similar behaviour could be added to rotation.
Currently, when rotation finishes, it stops suddenly

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.