Ricoh GR2 Control App for Android.
Revisão | ecd437caf35254be9341b97745d5f240aa527b17 (tree) |
---|---|
Hora | 2019-08-03 23:51:30 |
Autor | MRSa <mrsa@myad...> |
Commiter | MRSa |
物理ボタン(音量+)キーでシャッターが切れるようにする。
@@ -1,13 +1,13 @@ | ||
1 | 1 | apply plugin: 'com.android.application' |
2 | 2 | |
3 | 3 | android { |
4 | - compileSdkVersion 28 | |
4 | + compileSdkVersion 29 | |
5 | 5 | defaultConfig { |
6 | 6 | applicationId "net.osdn.gokigen.gr2control" |
7 | 7 | minSdkVersion 14 |
8 | - targetSdkVersion 28 | |
9 | - versionCode 1002001 | |
10 | - versionName "1.2.1" | |
8 | + targetSdkVersion 29 | |
9 | + versionCode 1002002 | |
10 | + versionName "1.2.2" | |
11 | 11 | } |
12 | 12 | buildTypes { |
13 | 13 | release { |
@@ -14,6 +14,7 @@ | ||
14 | 14 | android:label="@string/app_name" |
15 | 15 | android:roundIcon="@mipmap/ic_launcher_round" |
16 | 16 | android:usesCleartextTraffic="true" |
17 | + android:requestLegacyExternalStorage="true" | |
17 | 18 | android:supportsRtl="true" |
18 | 19 | android:theme="@style/AppTheme"> |
19 | 20 | <activity android:name=".Gr2ControlMain"> |
@@ -3,6 +3,7 @@ package net.osdn.gokigen.gr2control.liveview; | ||
3 | 3 | import android.app.Activity; |
4 | 4 | import android.content.SharedPreferences; |
5 | 5 | import android.util.Log; |
6 | +import android.view.KeyEvent; | |
6 | 7 | import android.view.MotionEvent; |
7 | 8 | import android.view.View; |
8 | 9 |
@@ -24,7 +25,7 @@ import androidx.preference.PreferenceManager; | ||
24 | 25 | * |
25 | 26 | * |
26 | 27 | */ |
27 | -class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener | |
28 | +class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchListener, View.OnKeyListener | |
28 | 29 | { |
29 | 30 | private final String TAG = toString(); |
30 | 31 | private final Activity context; |
@@ -383,4 +384,27 @@ class LiveViewClickTouchListener implements View.OnClickListener, View.OnTouchLi | ||
383 | 384 | Log.v(TAG, "onTouch() : " + id + " (" + motionEvent.getX() + "," + motionEvent.getY() + ")"); |
384 | 385 | return ((id == R.id.cameraLiveImageView)&&(focusingControl.driveAutoFocus(motionEvent))); |
385 | 386 | } |
387 | + | |
388 | + /** | |
389 | + * ボタンを押したときの対応 | |
390 | + * | |
391 | + */ | |
392 | + @Override | |
393 | + public boolean onKey(View view, int keyCode, @NonNull KeyEvent keyEvent) | |
394 | + { | |
395 | + Log.v(TAG, "onKey() : " + keyCode); | |
396 | + try | |
397 | + { | |
398 | + if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN)&& | |
399 | + ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)||(keyCode == KeyEvent.KEYCODE_CAMERA))) | |
400 | + { | |
401 | + pushedShutterButton(); | |
402 | + } | |
403 | + } | |
404 | + catch (Exception e) | |
405 | + { | |
406 | + e.printStackTrace(); | |
407 | + } | |
408 | + return (false); | |
409 | + } | |
386 | 410 | } |
@@ -163,6 +163,10 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo | ||
163 | 163 | imageView.setOnClickListener(onClickTouchListener); |
164 | 164 | imageView.setOnTouchListener(onClickTouchListener); |
165 | 165 | |
166 | + // キーイベントを拾うことにする | |
167 | + view.setOnKeyListener(onClickTouchListener); | |
168 | + view.setFocusableInTouchMode(true); | |
169 | + | |
166 | 170 | setOnClickListener(view, R.id.hideControlPanelTextView); |
167 | 171 | setOnClickListener(view, R.id.showControlPanelTextView); |
168 | 172 | setOnClickListener(view, R.id.showKeyPanelImageView); |
@@ -969,7 +973,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo | ||
969 | 973 | @Override |
970 | 974 | public void updateFocusedStatus(final boolean focused, final boolean focusLocked) |
971 | 975 | { |
972 | - Activity activity = getActivity(); | |
976 | + final Activity activity = getActivity(); | |
973 | 977 | try |
974 | 978 | { |
975 | 979 | if (activity != null) |
@@ -979,7 +983,7 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo | ||
979 | 983 | public void run() { |
980 | 984 | try |
981 | 985 | { |
982 | - ImageView view = getActivity().findViewById(R.id.focusUnlockImageView); | |
986 | + ImageView view = activity.findViewById(R.id.focusUnlockImageView); | |
983 | 987 | if (focused) { |
984 | 988 | Drawable icon = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_center_focus_strong_black_24dp, null); |
985 | 989 | if (icon != null) { |
@@ -7,7 +7,7 @@ buildscript { | ||
7 | 7 | jcenter() |
8 | 8 | } |
9 | 9 | dependencies { |
10 | - classpath 'com.android.tools.build:gradle:3.4.0' | |
10 | + classpath 'com.android.tools.build:gradle:3.4.2' | |
11 | 11 | |
12 | 12 | |
13 | 13 | // NOTE: Do not place your application dependencies here; they belong |