Skip to content

Commit 0e8b300

Browse files
committed
Merged in task/add-example (pull request #1)
Task/add example Approved-by: Tim Gortworst Approved-by: Jelle Heemskerk
2 parents 617874e + de6e326 commit 0e8b300

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1042
-37
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
.gradle
2+
local.properties
13
/build
2-
*.iml
4+
*.iml
5+
.idea
6+
gradle/local.properties

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Imagin
2+
3+
Imagin is an Android library, written in Kotlin. It attaches to an ImageView and allows you to add 'pinch to zoom', 'swipe to close', 'double tap to zoom' and dragging functionality. Because it attaches to a regular ImageView, it allows you to use all existing functionality of the ImageView or extend the ImageView to add extra functionality. Keep in mind that Imagin sets an OnTouchListener on the ImageView.
4+
5+
This library is currently supported on Android 5.1 Lollipop (22) and higher.
6+
7+
![](https://github.com/nos-digital/imagin/preview.gif)
8+
9+
## Usage
10+
11+
1. Add the Imagin library to your `build.gradle` file:
12+
13+
```gradle
14+
dependencies {
15+
implementation("nl.nos.imagin:${imagin.version}")
16+
}
17+
```
18+
19+
2. Usage in your project:
20+
21+
Load an image into an ImageView like usual.
22+
23+
```kotlin
24+
Imagin.with(imageWrapper, imageView)
25+
// enable double tap to zoom functionality
26+
.enableDoubleTapToZoom()
27+
// enable pinch to zoom functionality
28+
.enablePinchToZoom()
29+
// add an event listener when the user does a single tap
30+
.enableSingleTap(object : SingleTapHandler.OnSingleTapListener {
31+
override fun onSingleTap() {
32+
Toast.makeText(imageView.context, picture.name, Toast.LENGTH_SHORT).show()
33+
}
34+
})
35+
// this allows us to do an action when the user swipes the ImageView vertically and/or horizontally
36+
.enableScroll(
37+
allowScrollOutOfBoundsHorizontally = false,
38+
allowScrollOutOfBoundsVertically = true,
39+
scrollDistanceToCloseInPx = distanceToClose
40+
) {
41+
onSwipedToCloseListener?.onSwipeToClose()
42+
}
43+
```
44+
45+
## Licence
46+
47+
Imagin is available under the MIT license.

build.gradle

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,28 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
13
buildscript {
4+
ext.kotlin_version = '1.3.50'
25
repositories {
3-
mavenCentral()
6+
google()
7+
jcenter()
8+
49
}
510
dependencies {
11+
classpath 'com.android.tools.build:gradle:3.5.1'
12+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13+
// NOTE: Do not place your application dependencies here; they belong
14+
// in the individual module build.gradle files
615
}
716
}
817

9-
apply plugin: 'com.android.library'
10-
apply plugin: 'kotlin-android'
11-
apply plugin: 'kotlin-android-extensions'
12-
13-
android {
14-
compileSdkVersion compileVersion
15-
16-
defaultConfig {
17-
minSdkVersion minVersion
18-
targetSdkVersion targetVersion
19-
versionCode 1
20-
versionName "1.0"
21-
}
22-
23-
compileOptions {
24-
sourceCompatibility JavaVersion.VERSION_1_8
25-
targetCompatibility JavaVersion.VERSION_1_8
26-
}
18+
allprojects {
19+
repositories {
20+
google()
21+
jcenter()
2722

28-
buildTypes {
29-
debug {}
30-
staging {
31-
matchingFallbacks = ['release']
32-
}
33-
release {}
3423
}
3524
}
3625

37-
dependencies {
38-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
39-
40-
// Test dependencies
41-
testImplementation 'junit:junit:4.12'
42-
testImplementation 'org.mockito:mockito-core:2.8.9'
43-
}
26+
task clean(type: Delete) {
27+
delete rootProject.buildDir
28+
}

example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

example/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'com.android.application'
2+
3+
apply plugin: 'kotlin-android'
4+
5+
apply plugin: 'kotlin-android-extensions'
6+
7+
android {
8+
compileSdkVersion 28
9+
defaultConfig {
10+
applicationId "nl.nos.imagin.demo"
11+
minSdkVersion 22
12+
targetSdkVersion 28
13+
versionCode 1
14+
versionName "1.0"
15+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
implementation fileTree(dir: 'libs', include: ['*.jar'])
27+
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
28+
implementation 'com.android.support:appcompat-v7:28.0.0'
29+
implementation 'com.android.support:recyclerview-v7:28.0.0'
30+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
31+
32+
implementation project(path: ':library')
33+
}

example/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="nl.nos.imagin.example">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
13+
<activity android:name=".overview.OverviewActivity">
14+
<intent-filter>
15+
<action android:name="android.intent.action.MAIN" />
16+
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
21+
<activity android:name=".gallery.GalleryActivity" />
22+
23+
</application>
24+
25+
</manifest>
1.16 MB
Loading
1.12 MB
Loading
1.31 MB
Loading

0 commit comments

Comments
 (0)