Hi All,
I have recently been trying to port an augmented reality research project to the Galaxy Camera (EK-GC100) and have hit a few stumbling blocks. The main one of these is that whilst I can control the camera using software UI controls and the Android camera API, I would like to use the hardware zoom and shutter controls. My understanding based on trawling this forum is that it hasn't been done, but can anyone confirm whether or not this is the case? And if it is possible, how should I go about it? Any help would be greatly appreciated.
Thanks
Answered my own question!
It's ok, I've figured out the answer to this! I suspected Samsung may have been using the standard key event constants so wrote a very simple app to read out the key code value for any key down or up events. This app confirmed my thoughts. The constants used are:
Zoom in button pressed: KEYCODE_ZOOM_IN (value 168)
Zoom out button pressed: KEYCODE_ZOOM_OUT (value 169)
Shutter button pressed halfway: KEYCODE_FOCUS (value 80)
Shutter button pressed fully: KEYCODE_CAMERA (value 27)
When I pressed and held any of these buttons, the keycodes were sent repeatedly at a fairly high frequency. To make button handling a bit smoother, I have added some simple checks. If the user holds down a button, the first keycode is registered. The following 5 are ignored, then the 6th would be registered and the 5 event counter resets. If the user lets go of a button, this counter is also reset. The result is that the camera handles the zoom and shutter commands better than if I were just acting on every received keycode. Some example code is below:
Code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_ZOOM_IN:
if(hwBtnHeldCounter==0)
{
zoomIn();
hwBtnHeldCounter++;
}
else if(hwBtnHeldCounter==5)
{
// reset counter
hwBtnHeldCounter = 0;
}
else
{
// increment counter
hwBtnHeldCounter++;
}
return true;
default:
return super.onKeyDown(keyCode, event);
}
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_ZOOM_IN:
// reset counter
hwBtnHeldCounter=0;
return true;
default:
return super.onKeyUp(keyCode, event);
}
}
Hope this helps some other aspiring Galaxy Camera developers out!
Hello,
I'm very new to Android development and to this site, so I'm sorry if I'm posting a common issue or in the wrong place.
I am using a tutorial to just develop a simple app to get my feet wet.
I'm at the point where I create an Action Bar, and this is what I have in MainActivity.java :
@override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu.
// Adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
// Access the Share Item defined in menu XML
MenuItem shareItem = menu.findItem(R.id.menu_item_share);
// Access the object responsible for
// putting together the sharing submenu
if (shareItem != null) {
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider();
}
// Create an Intent to share your content
setShareIntent();
return true;
}
For the bold and highlighted part of the code, Android Studio is saying that cannot be applied. This is not allowing me to run the app.
Thanks for any help/advice!
1) Can anyone bring me back code of the press (BACK) devices such as the Galaxy LG etc., that kind of goes back button all the time back
2) Is it possible to make any changes in SPINNER another color? That is when I open the SPINNER any changes / Line will be a different color I choose?
3) just an example I built an app that chooses an image from the media Phone, after it came to ImageView this over and across, it's some of the images
How do I IMAGEVIEW rotation? I realized it is called rotation How do I use it?
1)
Code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// do something
yourView.notifyBackPressed();
return false;
}
return super.onKeyDown(keyCode, event);
}
And in your View have to implement method, for example notifyBackPressed();
2) Good question i need to know that!
3)
Code:
private void rotate(float degree) {
final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(0);
rotateAnim.setFillAfter(true);
imgview.startAnimation(rotateAnim);
}
Bye
cristaccio85 said:
1)
Code:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
// do something
yourView.notifyBackPressed();
return false;
}
return super.onKeyDown(keyCode, event);
}
And in your View have to implement method, for example notifyBackPressed();
2) Good question i need to know that!
3)
Code:
private void rotate(float degree) {
final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(0);
rotateAnim.setFillAfter(true);
imgview.startAnimation(rotateAnim);
}
Bye
Click to expand...
Click to collapse
The best, thanks 7
I want to have the phone screen change to landscape mode when a particular page is loaded in webview. My code is not working. There are no errors. It's just simply not changing into landscape mode when the particular page is loaded in webview. Is there something I forgot or am I doing this incorrectly. I don't want to force landscape when webview is loaded as there are other web pages that are used that need to be shown in portrait. Maybe possibly I forgot something else? I'm stuck.
Code:
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if( url.startsWith("http:")) {
return false;
}
//CHANGE INTO LANDSCAPE FOR SIGNATURE
if( url.contains("get-signature.php")) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
return true;
}
//Wont let me post link in forum. "LINK" is to open google maps
if(url.contains("LINK")) {
Uri gmmIntentUri = Uri.parse(url);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (mapIntent.resolveActivity(getPackageManager()) != null) {
startActivity(mapIntent);
}
return true;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity( intent );
return true;
}
});
Sharing my Android 12 mods as Xposed modules. You need Magisk+Lsposed installed obviously.
Two of the mods do not respond well to user controlled settings within the module so I've made separate modules for them:
1. xPixel
- Disable Screen ON on plugged
- Disable ADB debugging notification
- Activate AOD on plugged
- Disable Lock screen timeout
- Long press actions for Navbar buttons:
___ HOME > Screen OFF (see NOTE bellow)
___ BACK > Kill foreground app
___ RECENT > switch ON - Launch custom app, OFF - acts as MENU key
- Disable 'Power off' on Lock screen if device is secured with pin, pattern or password
- Advanced Power menu with user selectable options:
___ Soft restart
___ Recovery
___ Bootloader
___ Fastboot
___ SystemUI restart
___ Keep A12 Power menu look 'n fill for Restart submenu
2. Battery Estimate Gone
- Show Battery percentage instead of estimated time remaining in expanded notifications Status bar
3. Double Tap to Wake
- Double Tap to check phone instead of the default Single Tap
- Double Tap timeout is user configurable
NOTE: Disable Google Assistant in Settings > Apps > Default apps > Digital assistant app > Default digital assistant app > set to None for better experience if using longpress HOME screen OFF.
Enjoy!
can I get a button to add a shortcut to bg.nijel.xpixel/.SettingsActivity on my homescreen?
or add it to category `android.intent.category.LAUNCHER` / set `android:exported="true"`
meiskam said:
can I get a button to add a shortcut to bg.nijel.xpixel/.SettingsActivity on my homescreen?
or add it to category `android.intent.category.LAUNCHER` / set `android:exported="true"`
Click to expand...
Click to collapse
Updated.. added LAUNCHER category, please redownload from OP.
so, another feature request , I'd love long-press RECENT to push a KEYCODE_MENU KeyboardEvent, like when phones used to have a hardware menu button
something like:
Java:
Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_MENU );
+ INJECT_EVENTS permission
No need for that method, I directly set the key code for recent button in it's instance of KeyButtonView class with Xposed, much easier... As a matter of fact Android 12 on pixel doesn't transmit any key code event for the recent button. Anyway...
MENU key code is actually a pretty good idea, that way when you disable custom app launching you get menu button with long pressing the recent button... How I didn't think of that?! Double functionality... Definitely will do... but I am out of town for the next 2 weeks so later.
Updated xPixel - now if "RECENT custom app" is disabled, long pressing RECENT acts as MENU button. Please redownload from OP...
xPixel updated - fixed recent apps popup after MENU key in some cases. Please redownload from OP...
nijel8 said:
Sharing my Android 12 mods as Xposed modules. You need Magisk+Lsposed installed obviously.
Two of the mods do not respond well to user controlled settings within the module so I've made separate modules for them:
1. xPixel:
-Disable Screen ON on plugged
-Disable ADB debugging notification
-Activate AOD on plugged
-Disable Lock screen timeout
-Long press actions for Navbar buttons:
-HOME > Screen OFF
-BACK > Kill foreground app
-RECENT > switch ON - Launch custom app, OFF - acts as MENU key
2. Battery Estimate Gone
-Show Battery percentage instead of estimated time remaining in expanded notifications Status bar
3. Double Tap to Wake
-Double Tap to check phone instead of the default Single Tap
Enjoy!
Click to expand...
Click to collapse
For #3, is there an Android 11 equivalent?
ap1618 said:
For #3, is there an Android 11 equivalent?
Click to expand...
Click to collapse
Don't know, never looked in A11 code. If you wonna look at it this is the xposed module source code:
Code:
package bg.nijel.doubletaptowake;
import android.annotation.SuppressLint;
import android.view.MotionEvent;
import java.util.Timer;
import java.util.TimerTask;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import de.robv.android.xposed.callbacks.XCallback;
import static de.robv.android.xposed.XposedBridge.log;
public class DoubleTaptoWake implements IXposedHookLoadPackage {
private static boolean mDoubleTap = false;
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
if (lpparam.packageName.equals("com.android.systemui")) {
try {
Class<?> clazz = XposedHelpers.
findClass("com.android.systemui.statusbar.phone.NotificationShadeWindowViewController$1",
lpparam.classLoader);
XposedHelpers.findAndHookMethod(clazz,
"onSingleTapConfirmed", MotionEvent.class,
new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
@SuppressLint("PrivateApi")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
param.setResult(true);
//log("nijel888 DoubleTaptoWake onSingleTapConfirmed");
}
});
Class<?> clazzz = XposedHelpers.
findClass("com.android.systemui.doze.DozeTriggers", lpparam.classLoader);
XposedHelpers.findAndHookMethod(clazzz,
"onSensor", int.class, float.class, float.class, float[].class,
new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
@SuppressLint("PrivateApi")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
int pulseReason = (int) param.args[0];
if (pulseReason == 9) {
if (!mDoubleTap) {
param.setResult(null);
mDoubleTap = true;
new Timer().schedule(new TimerTask() {
@Override
public void run() {
mDoubleTap = false;
}
}, 400);
}
}
//log("nijel888 DoubleTaptoWake onSensor");
}
});
} catch (Throwable t) {
log(t);
}
}
}
}
I have no idea what's going on there in the code
When i tried to install the apk it said problem parsing the package, then I saw that the title says Android 12...
nijel8 said:
Don't know, never looked in A11 code. If you wonna look at it this is the xposed module source code:
Code:
package bg.nijel.doubletaptowake;
import android.annotation.SuppressLint;
import android.view.MotionEvent;
import java.util.Timer;
import java.util.TimerTask;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import de.robv.android.xposed.callbacks.XCallback;
import static de.robv.android.xposed.XposedBridge.log;
public class DoubleTaptoWake implements IXposedHookLoadPackage {
private static boolean mDoubleTap = false;
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
if (lpparam.packageName.equals("com.android.systemui")) {
try {
Class<?> clazz = XposedHelpers.
findClass("com.android.systemui.statusbar.phone.NotificationShadeWindowViewController$1",
lpparam.classLoader);
XposedHelpers.findAndHookMethod(clazz,
"onSingleTapConfirmed", MotionEvent.class,
new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
@SuppressLint("PrivateApi")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
param.setResult(true);
//log("nijel888 DoubleTaptoWake onSingleTapConfirmed");
}
});
Class<?> clazzz = XposedHelpers.
findClass("com.android.systemui.doze.DozeTriggers", lpparam.classLoader);
XposedHelpers.findAndHookMethod(clazzz,
"onSensor", int.class, float.class, float.class, float[].class,
new XC_MethodHook(XCallback.PRIORITY_HIGHEST) {
@SuppressLint("PrivateApi")
@Override
protected void beforeHookedMethod(MethodHookParam param) {
int pulseReason = (int) param.args[0];
if (pulseReason == 9) {
if (!mDoubleTap) {
param.setResult(null);
mDoubleTap = true;
new Timer().schedule(new TimerTask() {
@Override
public void run() {
mDoubleTap = false;
}
}, 400);
}
}
//log("nijel888 DoubleTaptoWake onSensor");
}
});
} catch (Throwable t) {
log(t);
}
}
}
}
Click to expand...
Click to collapse
Oh yeah... It's build for A12 only with API 31, can't test it on A11 so...
nijel8 said:
Oh yeah... It's build for A12 only with API 31, can't test it on A11 so...
Click to expand...
Click to collapse
Is there a way you can just rebuild it supporting A11 as minimum?
It should just work right?
Don't know if the hooked methods even exist in A11... Lot is changed, for example 90% and more of A11 GravityBox code doesn't work in A12, that was what actually made me do these modules...
Edit: Nope, the important method that captures the tap is missing from A11 code and I don't feel like digging again... sorry
nijel8 said:
Oh undo
nijel8 said:
Sharing my Android 12 mods as Xposed modules. You need Magisk+Lsposed installed obviously.
Two of the mods do not respond well to user controlled settings within the module so I've made separate modules for them:
1. xPixel:
-Disable Screen ON on plugged
-Disable ADB debugging notification
-Activate AOD on plugged
-Disable Lock screen timeout
-Long press actions for Navbar buttons:
-HOME > Screen OFF
-BACK > Kill foreground app
-RECENT > switch ON - Launch custom app, OFF - acts as MENU key
2. Battery Estimate Gone
-Show Battery percentage instead of estimated time remaining in expanded notifications Status bar
3. Double Tap to Wake
-Double Tap to check phone instead of the default Single Tap
Enjoy!
Click to expand...
Click to collapse
Thank you so much for making these. I was so tired of getting accidental wakeups with the single tap. The double tap to wake works well but I am running into times where it doesn't wake up after it's been off for a little while.
Click to expand...
Click to collapse
Yeah, me too, will see if I can debug it...
nijel8 said:
Yeah, me too, will see if I can debug it...
Click to expand...
Click to collapse
Great thanks a lot! Also not a big deal and it may be something conflicting on my end but screen timeout doesn't seem to lock device even if I toggle the option on and off in xPixel. Cheers
Reechings said:
Great thanks a lot! Also not a big deal and it may be something conflicting on my end but screen timeout doesn't seem to lock device even if I toggle the option on and off in xPixel. Cheers
Click to expand...
Click to collapse
Sorry ignore this. Didn't realize default behavior was to not lock right when the screen goes off and I just had to adjust it in security settings.
@nijel8
Not sure what phone you have but I don't think the double tap to wake mod works for me at all on January build for Pixel 6 Pro. I think it may also be because of a mod I am using by Typhus that adds a bunch of custom ROM stuff.
Reechings said:
@nijel8
Not sure what phone you have but I don't think the double tap to wake mod works for me at all on January build for Pixel 6 Pro. I think it may also be because of a mod I am using by Typhus that adds a bunch of custom ROM stuff.
Click to expand...
Click to collapse
Works well on my Pixel 5a with latest January build and all monthly builds before. Nothing has changed in AOSP code since A12 release...
The xposed module source code is few posts above.
nijel8 said:
Works well on my Pixel 5a with latest January build and all monthly builds before. Nothing has changed in AOSP code since A12 release...
The xposed module source code is few posts abov
nijel8 said:
Works well on my Pixel 5a with latest January build and all monthly builds before. Nothing has changed in AOSP code since A12 release...
The xposed module source code is few posts above.
Click to expand...
Click to collapse
Ok I guess maybe it's conflicting with this mod or something: https://forum.xda-developers.com/t/...for-pixel-devices-pixel-6-pro-thread.4362595/
Click to expand...
Click to collapse