[Android] Tools module for common utility classes
Geoffrey Métais
git at videolan.org
Thu Apr 26 13:59:16 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Apr 25 18:48:55 2018 +0200| [8e153e538a676c7383cc98f29cc015c12c451f0b] | committer: Geoffrey Métais
Tools module for common utility classes
> https://code.videolan.org/videolan/vlc-android/commit/8e153e538a676c7383cc98f29cc015c12c451f0b
---
medialibrary/build.gradle | 1 +
.../org/videolan/medialibrary/Medialibrary.java | 4 ++-
settings.gradle | 2 +-
tools/.gitignore | 1 +
tools/build.gradle | 41 ++++++++++++++++++++++
tools/proguard-rules.pro | 21 +++++++++++
.../org/commontools/ExampleInstrumentedTest.java | 26 ++++++++++++++
tools/src/main/AndroidManifest.xml | 8 +++++
.../java/videolan/org/commontools}/LiveEvent.kt | 2 +-
.../videolan/org/commontools/ExampleUnitTest.java | 17 +++++++++
vlc-android/build.gradle | 2 +-
11 files changed, 121 insertions(+), 4 deletions(-)
diff --git a/medialibrary/build.gradle b/medialibrary/build.gradle
index 5aa6d322c..79218c77b 100644
--- a/medialibrary/build.gradle
+++ b/medialibrary/build.gradle
@@ -66,4 +66,5 @@ dependencies {
api "com.android.support:support-compat:$rootProject.ext.appCompatVersion"
api "com.android.support:support-fragment:$rootProject.ext.appCompatVersion"
testImplementation 'junit:junit:4.12'
+ implementation project(':tools')
}
\ No newline at end of file
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 028f58272..daa3dffcd 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -36,6 +36,8 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
+import videolan.org.commontools.LiveEvent;
+
public class Medialibrary {
private static final String TAG = "VLC/JMedialibrary";
@@ -536,7 +538,7 @@ public class Medialibrary {
}
}
- public static LiveData<MediaWrapper> lastThumb = new MutableLiveData<>();
+ public static LiveData<MediaWrapper> lastThumb = new LiveEvent<>();
@SuppressWarnings({"unused", "unchecked"})
void onMediaThumbnailReady(MediaWrapper media, boolean success) {
if (success) ((MutableLiveData)lastThumb).postValue(media);
diff --git a/settings.gradle b/settings.gradle
index 4289312de..3c253dfd4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,3 +1,3 @@
-include ':libvlc', ':api', ':axmlrpc', ':medialibrary'
+include ':libvlc', ':api', ':axmlrpc', ':medialibrary', ':tools'
include ':vlc-android'
project(':axmlrpc').projectDir = new File('java-libs/axmlrpc')
\ No newline at end of file
diff --git a/tools/.gitignore b/tools/.gitignore
new file mode 100644
index 000000000..796b96d1c
--- /dev/null
+++ b/tools/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/tools/build.gradle b/tools/build.gradle
new file mode 100644
index 000000000..598d81495
--- /dev/null
+++ b/tools/build.gradle
@@ -0,0 +1,41 @@
+apply plugin: 'com.android.feature'
+apply plugin: 'kotlin-android'
+
+android {
+ compileSdkVersion 27
+
+
+ baseFeature true
+
+ defaultConfig {
+ minSdkVersion 14
+ targetSdkVersion 27
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ api 'com.android.support:appcompat-v7:27.1.1'
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+ application project(':vlc-android')
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+}
+repositories {
+ mavenCentral()
+}
diff --git a/tools/proguard-rules.pro b/tools/proguard-rules.pro
new file mode 100644
index 000000000..f1b424510
--- /dev/null
+++ b/tools/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/tools/src/androidTest/java/videolan/org/commontools/ExampleInstrumentedTest.java b/tools/src/androidTest/java/videolan/org/commontools/ExampleInstrumentedTest.java
new file mode 100644
index 000000000..fe7fe1570
--- /dev/null
+++ b/tools/src/androidTest/java/videolan/org/commontools/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package videolan.org.commontools;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+ at RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("videolan.org.commontools.test", appContext.getPackageName());
+ }
+}
diff --git a/tools/src/main/AndroidManifest.xml b/tools/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..6dd2d0715
--- /dev/null
+++ b/tools/src/main/AndroidManifest.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="videolan.org.commontools"
+ android:versionCode="2"
+ android:versionName="3.0.0" >
+ <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="26"/>
+
+</manifest>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/util/LiveEvent.kt b/tools/src/main/java/videolan/org/commontools/LiveEvent.kt
similarity index 96%
rename from vlc-android/src/org/videolan/vlc/util/LiveEvent.kt
rename to tools/src/main/java/videolan/org/commontools/LiveEvent.kt
index a58b3a6ee..a4d7eaa48 100644
--- a/vlc-android/src/org/videolan/vlc/util/LiveEvent.kt
+++ b/tools/src/main/java/videolan/org/commontools/LiveEvent.kt
@@ -1,4 +1,4 @@
-package org.videolan.vlc.util
+package videolan.org.commontools
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.MutableLiveData
diff --git a/tools/src/test/java/videolan/org/commontools/ExampleUnitTest.java b/tools/src/test/java/videolan/org/commontools/ExampleUnitTest.java
new file mode 100644
index 000000000..676eb14c5
--- /dev/null
+++ b/tools/src/test/java/videolan/org/commontools/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package videolan.org.commontools;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index b5aaa3162..a3d90c1f8 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -204,9 +204,9 @@ dependencies {
kapt "com.android.databinding:compiler:$rootProject.ext.android_plugin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.ext.kotlinx_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinx_version"
-
implementation "android.arch.lifecycle:extensions:$rootProject.ext.archVersion"
kapt "android.arch.lifecycle:compiler:$rootProject.ext.archVersion"
+ implementation project(':tools')
}
kotlin {
More information about the Android
mailing list