• R/O
  • HTTP
  • SSH
  • HTTPS

A01c: Commit

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


Commit MetaInfo

Révisionfcd1ff593bb33e1221a885a7ef00e88a424d36ed (tree)
l'heure2023-04-07 00:29:12
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

ロータリー入力に対応。

Change Summary

Modification

--- a/wear/src/main/java/jp/sfjp/gokigen/a01c/ManinActivity.kt
+++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/ManinActivity.kt
@@ -10,6 +10,7 @@ import android.provider.Settings
1010 import android.util.Log
1111 import android.view.MotionEvent
1212 import android.view.View
13+import android.view.ViewConfiguration
1314 import android.view.WindowManager
1415 import android.widget.ImageButton
1516 import android.widget.TextView
@@ -18,6 +19,10 @@ import androidx.appcompat.app.AppCompatActivity
1819 import androidx.core.app.ActivityCompat
1920 import androidx.core.content.ContextCompat
2021 import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
22+import androidx.core.view.InputDeviceCompat
23+import androidx.core.view.MotionEventCompat
24+import androidx.core.view.ViewConfigurationCompat
25+import androidx.core.widget.NestedScrollView
2126 import androidx.preference.PreferenceManager
2227 import jp.sfjp.gokigen.a01c.IShowInformation.operation
2328 import jp.sfjp.gokigen.a01c.liveview.*
@@ -29,6 +34,7 @@ import jp.sfjp.gokigen.a01c.preference.IPreferenceCameraPropertyAccessor
2934 import jp.sfjp.gokigen.a01c.preference.PreferenceAccessWrapper
3035 import jp.sfjp.gokigen.a01c.thetacamerawrapper.ThetaCameraController
3136 import jp.sfjp.gokigen.a01c.utils.GestureParser
37+import kotlin.math.roundToInt
3238
3339 /**
3440 * メインのActivity
@@ -255,6 +261,28 @@ class MainActivity : AppCompatActivity(), IChangeScene, IShowInformation, ICamer
255261 }
256262 }
257263
264+ override fun onGenericMotionEvent(ev: MotionEvent?): Boolean
265+ {
266+ try
267+ {
268+ if ((ev?.action == MotionEvent.ACTION_SCROLL)&& (ev.isFromSource(InputDeviceCompat.SOURCE_ROTARY_ENCODER)))
269+ {
270+ // ロータリー入力でスクロールする
271+ // Log.v(TAG, "Rotary Encoder Input")
272+ val view = findViewById<NestedScrollView>(R.id.main_screen)
273+ val delta = -ev.getAxisValue(MotionEventCompat.AXIS_SCROLL) *
274+ ViewConfigurationCompat.getScaledVerticalScrollFactor(ViewConfiguration.get(this), this)
275+ view.scrollBy(0, delta.roundToInt())
276+ return (true)
277+ }
278+ }
279+ catch (e: Exception)
280+ {
281+ e.printStackTrace()
282+ }
283+ return (super.onGenericMotionEvent(ev))
284+ }
285+
258286 /**
259287 * Intentを使ってWiFi設定画面を開く
260288 *
@@ -781,6 +809,7 @@ class MainActivity : AppCompatActivity(), IChangeScene, IShowInformation, ICamer
781809 return (packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS))
782810 }
783811
812+
784813 /**
785814 * タッチイベントをフックする
786815 *
--- a/wear/src/main/res/layout/activity_main.xml
+++ b/wear/src/main/res/layout/activity_main.xml
@@ -5,13 +5,13 @@
55 xmlns:tools="http://schemas.android.com/tools"
66 android:layout_width="match_parent"
77 android:layout_height="match_parent"
8+ android:id="@+id/main_screen"
89 android:padding="@dimen/box_inset_layout_padding"
910 android:background="@color/black"
1011 android:focusable="true"
1112 android:scrollbars="vertical"
1213 tools:context=".MainActivity"
1314 tools:deviceIds="wear">
14-
1515 <androidx.constraintlayout.widget.ConstraintLayout
1616 android:layout_height="match_parent"
1717 android:layout_width="match_parent"
Afficher sur ancien navigateur de dépôt.