• R/O
  • HTTP
  • SSH
  • HTTPS

A01c: Commit

OPC(Olympus Air)用撮影アプリ。


Commit MetaInfo

Révision8b04cb0bcb03c95da779195bcef8575e2aef0c44 (tree)
l'heure2021-02-04 00:05:40
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

Theta用にOpenGLのビューを用意する(準備その2)。

Change Summary

Modification

--- a/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java
+++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java
@@ -10,6 +10,8 @@ import android.os.Vibrator;
1010 import android.preference.PreferenceManager;
1111 import android.provider.Settings;
1212 import android.util.Log;
13+import android.view.MotionEvent;
14+import android.view.View;
1315 import android.widget.ImageButton;
1416 import android.widget.TextView;
1517 import android.Manifest;
@@ -29,11 +31,11 @@ import jp.sfjp.gokigen.a01c.liveview.ICameraStatusReceiver;
2931 import jp.sfjp.gokigen.a01c.liveview.IMessageDrawer;
3032 import jp.sfjp.gokigen.a01c.liveview.CameraLiveViewOnTouchListener;
3133 import jp.sfjp.gokigen.a01c.liveview.glview.GokigenGLView;
32-import jp.sfjp.gokigen.a01c.liveview.glview.ILiveViewRefresher;
3334 import jp.sfjp.gokigen.a01c.olycamerawrapper.OlyCameraCoordinator;
3435 import jp.sfjp.gokigen.a01c.preference.IPreferenceCameraPropertyAccessor;
3536 import jp.sfjp.gokigen.a01c.preference.PreferenceAccessWrapper;
3637 import jp.sfjp.gokigen.a01c.thetacamerawrapper.ThetaCameraController;
38+import jp.sfjp.gokigen.a01c.utils.GestureParser;
3739
3840 /**
3941 * メインのActivity
@@ -49,7 +51,7 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS
4951 private PowerManager powerManager = null;
5052 private CameraLiveImageView liveView = null;
5153 private GokigenGLView glView = null;
52- private ILiveViewRefresher glViewRefresher = null;
54+ private GestureParser gestureParser = null;
5355 private ICameraController currentCoordinator = null;
5456 private ICameraController olyAirCoordinator = null;
5557 private ICameraController thetaCoordinator = null;
@@ -368,16 +370,28 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS
368370 if (liveView == null)
369371 {
370372 liveView = findViewById(R.id.liveview);
373+ liveView.setVisibility(View.VISIBLE);
371374 }
372375 CameraLiveViewListenerImpl liveViewListener = new CameraLiveViewListenerImpl(liveView);
373-/*
374- if (glView == null)
376+ gestureParser = null;
377+ glView = null;
378+ boolean enableGlView = preferences.getBoolean(IPreferenceCameraPropertyAccessor.THETA_GL_VIEW, false);
379+ if ((enableGlView)&&(connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)))
375380 {
376- glView = findViewById(R.id.glview);
377- glViewRefresher = glView;
378- glView.setImageProvider(liveViewListener);
381+ if (glView == null)
382+ {
383+ // GL VIEW に切り替える
384+ glView = findViewById(R.id.glview);
385+ }
386+ if (glView != null)
387+ {
388+ // GL VIEW に切り替える
389+ gestureParser = new GestureParser(getApplicationContext(), glView);
390+ glView.setImageProvider(liveViewListener);
391+ glView.setVisibility(View.VISIBLE);
392+ liveView.setVisibility(View.GONE);
393+ }
379394 }
380-*/
381395 olyAirCoordinator = new OlyCameraCoordinator(this, liveView, this, this);
382396 thetaCoordinator = new ThetaCameraController(this, this, this);
383397 currentCoordinator = (connectionMethod.contains(IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_THETA)) ? thetaCoordinator : olyAirCoordinator;
@@ -792,6 +806,23 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS
792806 }
793807
794808 /**
809+ * タッチイベントをフックする
810+ *
811+ *
812+ */
813+ @Override
814+ public boolean dispatchTouchEvent(MotionEvent event)
815+ {
816+ //Log.v(TAG, " dispatchTouchEvent() ");
817+ if (gestureParser != null)
818+ {
819+ //Log.v(TAG, " onTouch() ");
820+ gestureParser.onTouch(event);
821+ }
822+ return (super.dispatchTouchEvent(event));
823+ }
824+
825+ /**
795826 *
796827 *
797828 */
@@ -945,7 +976,17 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS
945976 liveView = findViewById(R.id.liveview);
946977 }
947978 liveView.setupInitialBackgroundImage(this);
979+ liveView.setVisibility(View.VISIBLE);
948980 liveView.invalidate();
981+
982+ if (glView != null)
983+ {
984+ glView.setVisibility(View.GONE);
985+ glView = null;
986+ }
987+
988+
989+
949990 }
950991 catch (Exception e)
951992 {
--- a/wear/src/main/java/jp/sfjp/gokigen/a01c/preference/IPreferenceCameraPropertyAccessor.java
+++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/preference/IPreferenceCameraPropertyAccessor.java
@@ -15,6 +15,8 @@ public interface IPreferenceCameraPropertyAccessor
1515 String FRAME_GRID = "frame_grid";
1616 String FRAME_GRID_DEFAULT_VALUE = "0";
1717
18+ String THETA_GL_VIEW = "theta_gl_view";
19+
1820 String IMAGE_CONVERTER = "image_converter";
1921 String IMAGE_CONVERTER_DEFAULT_VALUE = "0";
2022
--- a/wear/src/main/java/jp/sfjp/gokigen/a01c/preference/PreferenceInitializer.kt
+++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/preference/PreferenceInitializer.kt
@@ -32,6 +32,10 @@ class PreferenceInitializer
3232 IPreferenceCameraPropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE
3333 )
3434 }
35+ if (!items.containsKey(IPreferenceCameraPropertyAccessor.THETA_GL_VIEW))
36+ {
37+ editor.putBoolean(IPreferenceCameraPropertyAccessor.THETA_GL_VIEW, false)
38+ }
3539 editor.apply()
3640 }
3741 catch (e : Exception)
--- /dev/null
+++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/utils/GestureParser.kt
@@ -0,0 +1,93 @@
1+package jp.sfjp.gokigen.a01c.utils
2+
3+import android.content.Context
4+import android.view.GestureDetector
5+import android.view.MotionEvent
6+import android.view.ScaleGestureDetector
7+import jp.sfjp.gokigen.a01c.liveview.glview.ILiveViewRefresher
8+
9+class GestureParser(context : Context, private val imageView : ILiveViewRefresher) : GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener
10+{
11+ private val gestureDetector = GestureDetector(context, this)
12+ private val scaleGestureDetector = ScaleGestureDetector(context, this)
13+
14+ // View.OnTouchListener
15+ fun onTouch(event: MotionEvent?): Boolean
16+ {
17+ return (gestureDetector.onTouchEvent(event) || scaleGestureDetector.onTouchEvent(event))
18+ }
19+
20+ // GestureDetector.OnGestureListener
21+ override fun onDown(e: MotionEvent?): Boolean
22+ {
23+ //Log.v(TAG, " Gesture onDown")
24+ return (false)
25+ }
26+
27+ // GestureDetector.OnGestureListener
28+ override fun onShowPress(e: MotionEvent?)
29+ {
30+ //Log.v(TAG, " Gesture onShowPress")
31+ }
32+
33+ // GestureDetector.OnGestureListener
34+ override fun onSingleTapUp(e: MotionEvent?): Boolean
35+ {
36+ //Log.v(TAG, " Gesture onSingleTapUp")
37+ return (false)
38+ }
39+
40+ // GestureDetector.OnGestureListener
41+ override fun onScroll(e1: MotionEvent?, e2: MotionEvent?, distanceX: Float, distanceY: Float): Boolean
42+ {
43+ //Log.v(TAG, " Gesture onScroll")
44+ imageView.moveView(distanceX, distanceY)
45+ return (false)
46+ }
47+
48+ // GestureDetector.OnGestureListener
49+ override fun onLongPress(e: MotionEvent?)
50+ {
51+ //Log.v(TAG, " Gesture onLongPress")
52+ imageView.resetView()
53+ }
54+
55+ // GestureDetector.OnGestureListener
56+ override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float): Boolean
57+ {
58+ //Log.v(TAG, " Gesture onFling")
59+ return (false)
60+ }
61+
62+ // ScaleGestureDetector.OnScaleGestureListener
63+ override fun onScale(detector: ScaleGestureDetector?): Boolean
64+ {
65+ //Log.v(TAG, " Gesture onScale")
66+ try
67+ {
68+ if (detector != null)
69+ {
70+ imageView.setScaleFactor(detector.scaleFactor)
71+ return (true)
72+ }
73+ }
74+ catch (e : Exception)
75+ {
76+ e.printStackTrace()
77+ }
78+ return (false)
79+ }
80+
81+ // ScaleGestureDetector.OnScaleGestureListener
82+ override fun onScaleBegin(detector: ScaleGestureDetector?): Boolean
83+ {
84+ //Log.v(TAG, " Gesture onScaleBegin")
85+ return (true)
86+ }
87+
88+ // ScaleGestureDetector.OnScaleGestureListener
89+ override fun onScaleEnd(detector: ScaleGestureDetector?)
90+ {
91+ //Log.v(TAG, " Gesture onScaleEnd")
92+ }
93+}
--- a/wear/src/main/res/layout-round/activity_main.xml
+++ b/wear/src/main/res/layout-round/activity_main.xml
@@ -29,7 +29,7 @@
2929 android:layout_width="match_parent"
3030 android:layout_height="match_parent"
3131 android:gravity="center"
32- />
32+ />
3333
3434 <LinearLayout
3535 android:layout_width="match_parent"
Afficher sur ancien navigateur de dépôt.