diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 95ae832..0ec6a3a 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 5d6f65c..b8f80d7 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -9,7 +9,7 @@ - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 2a9d1aa..1049205 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,9 +2,9 @@ - + - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 47663ec..3818961 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 + compileSdkVersion 28 defaultConfig { applicationId "hbisoft.com.surfaceviewpinchzoom" minSdkVersion 18 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -20,8 +20,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:27.1.1' - implementation 'com.android.support.constraint:constraint-layout:1.1.0' + implementation 'com.android.support:appcompat-v7:28.0.0' testImplementation 'junit:junit:4.12' - implementation project(path: ':lib') + implementation project(path: ':zoomable') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7886db8..e934ae7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> diff --git a/app/src/main/java/com/lucemanb/MainActivity.java b/app/src/main/java/com/lucemanb/MainActivity.java new file mode 100644 index 0000000..e2435c7 --- /dev/null +++ b/app/src/main/java/com/lucemanb/MainActivity.java @@ -0,0 +1,76 @@ +package com.lucemanb; + +import android.app.Activity; +import android.graphics.SurfaceTexture; +import android.media.MediaPlayer; +import android.os.Bundle; +import android.view.Surface; +import android.view.TextureView; + +import com.lucemanb.zoomable.ZoomableTextureView; + +import java.io.IOException; +import hbisoft.com.surfaceviewpinchzoom.R; + + +public class MainActivity extends Activity{ + + String path = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"; + private MediaPlayer mediaPlayerTexture; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + final MediaPlayer.OnPreparedListener listener = new MediaPlayer.OnPreparedListener() { + @Override + public void onPrepared(MediaPlayer mp) { + mp.start(); + } + }; + + ZoomableTextureView textureView = findViewById(R.id.textureView); + + textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() { + @Override + public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { + Surface s = new Surface(surface); + mediaPlayerTexture = new MediaPlayer(); + mediaPlayerTexture.setSurface(s); + try { + mediaPlayerTexture.setDataSource(path); + } catch (IOException e) { + e.printStackTrace(); + } + mediaPlayerTexture.prepareAsync(); + mediaPlayerTexture.setOnPreparedListener(listener); + } + + @Override + public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { + + } + + @Override + public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { + return false; + } + + @Override + public void onSurfaceTextureUpdated(SurfaceTexture surface) { + + } + }); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + if (mediaPlayerTexture != null) { + mediaPlayerTexture.release(); + mediaPlayerTexture = null; + } + } + +} diff --git a/app/src/main/java/hbisoft/com/surfaceviewpinchzoom/MainActivity.java b/app/src/main/java/hbisoft/com/surfaceviewpinchzoom/MainActivity.java deleted file mode 100644 index fb0ce94..0000000 --- a/app/src/main/java/hbisoft/com/surfaceviewpinchzoom/MainActivity.java +++ /dev/null @@ -1,88 +0,0 @@ -package hbisoft.com.surfaceviewpinchzoom; - -import android.app.Activity; -import android.content.Intent; -import android.graphics.SurfaceTexture; -import android.media.AudioManager; -import android.media.MediaPlayer; -import android.net.Uri; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.TextureView; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.RelativeLayout; - -import com.lucem.lib.ZoomableTextureView; - -import java.io.IOException; - -public class MainActivity extends Activity implements TextureView.SurfaceTextureListener, MediaPlayer.OnPreparedListener{ - - String path = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"; - private MediaPlayer mediaPlayerTexture; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - ZoomableTextureView textureView = (ZoomableTextureView) findViewById(R.id.textureView); - textureView.setSurfaceTextureListener(this); - } - - private void prepareTextureView(SurfaceTexture surface) { - Surface s = new Surface(surface); - mediaPlayerTexture = new MediaPlayer(); - mediaPlayerTexture.setSurface(s); - try { - mediaPlayerTexture.setDataSource(path); - } catch (IOException e) { - e.printStackTrace(); - } - mediaPlayerTexture.prepareAsync(); - mediaPlayerTexture.setOnPreparedListener(this); - } - - @Override - public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) { - prepareTextureView(surfaceTexture); - } - - @Override - public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i1) { - - } - - @Override - public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) { - return false; - } - - @Override - public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) { - - } - - /** - * MediaPlayer - **/ - @Override - public void onPrepared(MediaPlayer mediaPlayer) { - mediaPlayer.start(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (mediaPlayerTexture != null) { - mediaPlayerTexture.release(); - mediaPlayerTexture = null; - } - } -} diff --git a/app/src/main/res/layout/activity_frames.xml b/app/src/main/res/layout/activity_frames.xml new file mode 100644 index 0000000..16577a7 --- /dev/null +++ b/app/src/main/res/layout/activity_frames.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index f1386bf..8704d86 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -5,7 +5,7 @@ android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".MainActivity"> + tools:context="com.lucemanb.MainActivity"> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -150,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..f955316 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +46,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/lib/src/main/res/values/strings.xml b/lib/src/main/res/values/strings.xml deleted file mode 100644 index d8b1ac9..0000000 --- a/lib/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - lib - diff --git a/settings.gradle b/settings.gradle index 3cbe249..ea1f668 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':lib' +include ':app', ':zoomable' diff --git a/lib/.gitignore b/zoomable/.gitignore similarity index 100% rename from lib/.gitignore rename to zoomable/.gitignore diff --git a/lib/build.gradle b/zoomable/build.gradle similarity index 85% rename from lib/build.gradle rename to zoomable/build.gradle index f692eb4..b7cc512 100644 --- a/lib/build.gradle +++ b/zoomable/build.gradle @@ -1,13 +1,11 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 27 - - + compileSdkVersion 28 defaultConfig { minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" @@ -26,8 +24,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - - implementation 'com.android.support:appcompat-v7:27.1.1' + implementation 'com.android.support:appcompat-v7:28.0.0' 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' diff --git a/lib/proguard-rules.pro b/zoomable/proguard-rules.pro similarity index 100% rename from lib/proguard-rules.pro rename to zoomable/proguard-rules.pro diff --git a/lib/src/androidTest/java/com/lucem/lib/ExampleInstrumentedTest.java b/zoomable/src/androidTest/java/com/lucemanb/zoomablevideo/ExampleInstrumentedTest.java similarity index 83% rename from lib/src/androidTest/java/com/lucem/lib/ExampleInstrumentedTest.java rename to zoomable/src/androidTest/java/com/lucemanb/zoomablevideo/ExampleInstrumentedTest.java index 90cb166..7707a35 100644 --- a/lib/src/androidTest/java/com/lucem/lib/ExampleInstrumentedTest.java +++ b/zoomable/src/androidTest/java/com/lucemanb/zoomablevideo/ExampleInstrumentedTest.java @@ -1,4 +1,4 @@ -package com.lucem.lib; +package com.lucemanb.zoomablevideo; import android.content.Context; import android.support.test.InstrumentationRegistry; @@ -21,6 +21,6 @@ public void useAppContext() { // Context of the app under test. Context appContext = InstrumentationRegistry.getTargetContext(); - assertEquals("com.lucem.lib.test", appContext.getPackageName()); + assertEquals("com.lucemanb.zoomablevideo.test", appContext.getPackageName()); } } diff --git a/lib/src/main/AndroidManifest.xml b/zoomable/src/main/AndroidManifest.xml similarity index 61% rename from lib/src/main/AndroidManifest.xml rename to zoomable/src/main/AndroidManifest.xml index 1ac7e34..2ce3405 100644 --- a/lib/src/main/AndroidManifest.xml +++ b/zoomable/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ + package="com.lucemanb.zoomablevideo" /> diff --git a/lib/src/main/java/com/lucem/lib/ZoomableTextureView.java b/zoomable/src/main/java/com/lucemanb/zoomable/ZoomableTextureView.java similarity index 99% rename from lib/src/main/java/com/lucem/lib/ZoomableTextureView.java rename to zoomable/src/main/java/com/lucemanb/zoomable/ZoomableTextureView.java index 4298a78..793d426 100644 --- a/lib/src/main/java/com/lucem/lib/ZoomableTextureView.java +++ b/zoomable/src/main/java/com/lucemanb/zoomable/ZoomableTextureView.java @@ -1,4 +1,4 @@ -package com.lucem.lib; +package com.lucemanb.zoomable; import android.content.Context; import android.content.res.TypedArray; @@ -12,7 +12,10 @@ import android.view.TextureView; import android.view.View; +import com.lucemanb.zoomablevideo.R; + public class ZoomableTextureView extends TextureView { + private static final String SUPERSTATE_KEY = "superState"; private static final String MIN_SCALE_KEY = "minScale"; private static final String MAX_SCALE_KEY = "maxScale"; diff --git a/lib/src/main/res/values/attrs.xml b/zoomable/src/main/res/values/attrs.xml similarity index 100% rename from lib/src/main/res/values/attrs.xml rename to zoomable/src/main/res/values/attrs.xml diff --git a/zoomable/src/main/res/values/strings.xml b/zoomable/src/main/res/values/strings.xml new file mode 100644 index 0000000..8544636 --- /dev/null +++ b/zoomable/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + ZoomableVideo + diff --git a/lib/src/test/java/com/lucem/lib/ExampleUnitTest.java b/zoomable/src/test/java/com/lucemanb/zoomablevideo/ExampleUnitTest.java similarity index 90% rename from lib/src/test/java/com/lucem/lib/ExampleUnitTest.java rename to zoomable/src/test/java/com/lucemanb/zoomablevideo/ExampleUnitTest.java index cef2d1b..c9efff9 100644 --- a/lib/src/test/java/com/lucem/lib/ExampleUnitTest.java +++ b/zoomable/src/test/java/com/lucemanb/zoomablevideo/ExampleUnitTest.java @@ -1,4 +1,4 @@ -package com.lucem.lib; +package com.lucemanb.zoomablevideo; import org.junit.Test;