OPC(Olympus Air)用撮影アプリ。
Révision | fcd1ff593bb33e1221a885a7ef00e88a424d36ed (tree) |
---|---|
l'heure | 2023-04-07 00:29:12 |
Auteur | MRSa <mrsa@myad...> |
Commiter | MRSa |
ロータリー入力に対応。
@@ -10,6 +10,7 @@ import android.provider.Settings | ||
10 | 10 | import android.util.Log |
11 | 11 | import android.view.MotionEvent |
12 | 12 | import android.view.View |
13 | +import android.view.ViewConfiguration | |
13 | 14 | import android.view.WindowManager |
14 | 15 | import android.widget.ImageButton |
15 | 16 | import android.widget.TextView |
@@ -18,6 +19,10 @@ import androidx.appcompat.app.AppCompatActivity | ||
18 | 19 | import androidx.core.app.ActivityCompat |
19 | 20 | import androidx.core.content.ContextCompat |
20 | 21 | 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 | |
21 | 26 | import androidx.preference.PreferenceManager |
22 | 27 | import jp.sfjp.gokigen.a01c.IShowInformation.operation |
23 | 28 | import jp.sfjp.gokigen.a01c.liveview.* |
@@ -29,6 +34,7 @@ import jp.sfjp.gokigen.a01c.preference.IPreferenceCameraPropertyAccessor | ||
29 | 34 | import jp.sfjp.gokigen.a01c.preference.PreferenceAccessWrapper |
30 | 35 | import jp.sfjp.gokigen.a01c.thetacamerawrapper.ThetaCameraController |
31 | 36 | import jp.sfjp.gokigen.a01c.utils.GestureParser |
37 | +import kotlin.math.roundToInt | |
32 | 38 | |
33 | 39 | /** |
34 | 40 | * メインのActivity |
@@ -255,6 +261,28 @@ class MainActivity : AppCompatActivity(), IChangeScene, IShowInformation, ICamer | ||
255 | 261 | } |
256 | 262 | } |
257 | 263 | |
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 | + | |
258 | 286 | /** |
259 | 287 | * Intentを使ってWiFi設定画面を開く |
260 | 288 | * |
@@ -781,6 +809,7 @@ class MainActivity : AppCompatActivity(), IChangeScene, IShowInformation, ICamer | ||
781 | 809 | return (packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_GPS)) |
782 | 810 | } |
783 | 811 | |
812 | + | |
784 | 813 | /** |
785 | 814 | * タッチイベントをフックする |
786 | 815 | * |
@@ -5,13 +5,13 @@ | ||
5 | 5 | xmlns:tools="http://schemas.android.com/tools" |
6 | 6 | android:layout_width="match_parent" |
7 | 7 | android:layout_height="match_parent" |
8 | + android:id="@+id/main_screen" | |
8 | 9 | android:padding="@dimen/box_inset_layout_padding" |
9 | 10 | android:background="@color/black" |
10 | 11 | android:focusable="true" |
11 | 12 | android:scrollbars="vertical" |
12 | 13 | tools:context=".MainActivity" |
13 | 14 | tools:deviceIds="wear"> |
14 | - | |
15 | 15 | <androidx.constraintlayout.widget.ConstraintLayout |
16 | 16 | android:layout_height="match_parent" |
17 | 17 | android:layout_width="match_parent" |