Settings to support right mouse click, no real code yet.

This commit is contained in:
pelya
2010-11-05 18:01:55 +02:00
parent 6b250d3d50
commit 3c44578e93
5 changed files with 134 additions and 11 deletions

View File

@@ -23,6 +23,8 @@ class Globals {
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
public static boolean AppUsesMouse = false;
public static boolean AppNeedsTwoButtonMouse = false;
public static boolean AppNeedsArrowKeys = true;
@@ -55,6 +57,14 @@ class Globals {
public static int TrackballDampening = 0;
public static int AudioBufferConfig = 0;
public static boolean OptionalDataDownload[] = null;
public static final int RIGHT_CLICK_WITH_MENU_BUTTON = 0;
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
public static final int RIGHT_CLICK_WITH_PRESSURE = 2;
public static int RightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON;
public static boolean LeftClickUsesPressure = false;
public static boolean ShowScreenUnderFinger = false;
public static int ClickScreenPressure = 0;
public static int ClickScreenTouchspotSize = 0;
}
class LoadLibrary {

View File

@@ -49,6 +49,12 @@ class Settings
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
out.writeBoolean(Globals.OptionalDataDownload[i]);
out.writeInt(Globals.TouchscreenKeyboardTheme);
out.writeInt(Globals.RightClickMethod);
out.writeBoolean(Globals.ShowScreenUnderFinger);
out.writeBoolean(Globals.LeftClickUsesPressure);
out.writeInt(Globals.ClickScreenPressure);
out.writeInt(Globals.ClickScreenTouchspotSize);
out.close();
settingsLoaded = true;
@@ -80,6 +86,11 @@ class Settings
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
Globals.RightClickMethod = settingsFile.readInt();
Globals.ShowScreenUnderFinger = settingsFile.readBoolean();
Globals.LeftClickUsesPressure = settingsFile.readBoolean();
Globals.ClickScreenPressure = settingsFile.readInt();
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
settingsLoaded = true;
@@ -281,7 +292,7 @@ class Settings
if( item == 0 )
Globals.UseTouchscreenKeyboard = isChecked;
if( item == 1 )
Globals.UseAccelerometerAsArrowKeys = isChecked;
Globals.UseAccelerometerAsArrowKeys = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
@@ -395,7 +406,7 @@ class Settings
Globals.TouchscreenKeyboardTheme = 0;
if( ! Globals.UseTouchscreenKeyboard )
{
showAudioConfig(p);
showRightClickConfigConfig(p);
return;
}
@@ -415,10 +426,79 @@ class Settings
if( item == 1 )
Globals.TouchscreenKeyboardTheme = 0;
dialog.dismiss();
showRightClickConfigConfig(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showRightClickConfigConfig(final MainActivity p)
{
Globals.RightClickMethod = RIGHT_CLICK_WITH_MENU_BUTTON;
if( ! Globals.AppNeedsTwoButtonMouse )
{
showAdvancedPointAndClickConfigConfig(p);
return;
}
final CharSequence[] items = { p.getResources().getString(R.string.rightclick_menu),
p.getResources().getString(R.string.rightclick_multitouch),
p.getResources().getString(R.string.rightclick_pressure) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.rightclick_question);
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
Globals.RightClickMethod = item;
dialog.dismiss();
showAdvancedPointAndClickConfigConfig(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
}
static void showAdvancedPointAndClickConfigConfig(final MainActivity p)
{
Globals.ShowScreenUnderFinger = false;
Globals.LeftClickUsesPressure = false;
if( ! Globals.AppNeedsTwoButtonMouse )
{
showAudioConfig(p);
return;
}
final CharSequence[] items = (Globals.RightClickMethod == RIGHT_CLICK_WITH_PRESSURE) ?
{ p.getResources().getString(R.string.pointandclick_showcreenunderfinger) } :
{ p.getResources().getString(R.string.pointandclick_showcreenunderfinger),
p.getResources().getString(R.string.pointandclick_usepressure) };
AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(p.getResources().getString(R.string.pointandclick_question));
builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener()
{
public void onClick(DialogInterface dialog, int item, boolean isChecked)
{
if( item == 0 )
Globals.ShowScreenUnderFinger = isChecked;
if( item == 1 )
Globals.LeftClickUsesPressure = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
showAudioConfig(p);
}
});
AlertDialog alert = builder.create();
alert.setOwnerActivity(p);
alert.show();
@@ -455,7 +535,11 @@ class Settings
if( Globals.PhoneHasTrackball )
nativeSetTrackballUsed();
if( Globals.AppUsesMouse )
nativeSetMouseUsed();
nativeSetMouseUsed( Globals.RightClickMethod,
Globals.ShowScreenUnderFinger ? 1 : 0,
Globals.LeftClickUsesPressure ? 1 : 0,
Globals.ClickScreenPressure,
Globals.ClickScreenTouchspotSize );
if( Globals.AppUsesJoystick && (Globals.UseAccelerometerAsArrowKeys || Globals.UseTouchscreenKeyboard) )
nativeSetJoystickUsed();
if( Globals.AppUsesMultitouch )
@@ -514,7 +598,7 @@ class Settings
private static native void nativeSetTrackballUsed();
private static native void nativeSetTrackballDampening(int value);
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
private static native void nativeSetMouseUsed();
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickUsesPressure, int MaxForce, int MaxRadius);
private static native void nativeSetJoystickUsed();
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();

View File

@@ -59,6 +59,13 @@
<string name="accel_fixed_horiz">Fixed to table desk orientation</string>
<string name="accel_question_center">Accelerometer center position</string>
<string name="rightclick_question">Right mouse click triggered by:</string>
<string name="rightclick_menu">Menu key</string>
<string name="rightclick_multitouch">Touching screen with second finger (device should support that)</string>
<string name="rightclick_pressure">Pressing screen with force (device should support that)</string>
<string name="rightclick_question">Right mouse click triggered by:</string>
<string name="audiobuf_verysmall">Very small (fast devices, less lag)</string>
<string name="audiobuf_small">Small</string>
<string name="audiobuf_medium">Medium</string>