Added option for a full width LCD screen
This commit is contained in:
parent
05bc9c2312
commit
e9736ddab4
5 changed files with 41 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.ab.x48" android:installLocation="auto" android:versionCode="20" android:versionName="1.20">
|
||||
package="org.ab.x48" android:installLocation="auto" android:versionCode="21" android:versionName="1.21">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".X48"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
@ -39,5 +39,7 @@
|
|||
|
||||
<string name="numpad_explain">You can also tap the LCD screen, more convenient !</string>
|
||||
<string name="saveonexit_msgbox_value">Save memory and stack on exit</string>
|
||||
<string name="haptic_feedback">Enable Haptic Feedback</string>
|
||||
<string name="haptic_feedback">Haptic feedback</string>
|
||||
<string name="large_width">Large LCD screen</string>
|
||||
<string name="large_width_summary">Portrait mode only</string>
|
||||
</resources>
|
||||
|
|
|
@ -48,6 +48,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
Matrix matrixScreen;
|
||||
Matrix matrixBack;
|
||||
Paint paint;
|
||||
Paint screenPaint = null;
|
||||
|
||||
public HPView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
@ -81,6 +82,9 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
paint.setStyle(Style.FILL);
|
||||
paint.setARGB(128, 250, 250, 250);
|
||||
|
||||
screenPaint = null;
|
||||
screenPaint = new Paint();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -103,7 +107,16 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
//private short data [];
|
||||
private Bitmap keys [] = new Bitmap[MAX_TOUCHES];
|
||||
private Bitmap backBuffer;
|
||||
private boolean fullWidth;
|
||||
|
||||
public boolean isFullWidth() {
|
||||
return fullWidth;
|
||||
}
|
||||
|
||||
public void setFullWidth(boolean fullWidth) {
|
||||
this.fullWidth = fullWidth;
|
||||
}
|
||||
|
||||
public void refreshMainScreen(short data []) {
|
||||
Canvas c = null;
|
||||
try {
|
||||
|
@ -119,6 +132,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
|
||||
|
||||
if (backBuffer == null) {
|
||||
|
||||
Log.i("x48", "init backBuffer !: " + keybLite);
|
||||
backBuffer = Bitmap.createBitmap(c.getWidth(), c.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas backCanvas = new Canvas(backBuffer);
|
||||
|
@ -130,6 +144,11 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
p.setColor(srcColor);
|
||||
backCanvas.drawRect(0, 0, w, h, p);
|
||||
float lcd_ratio = (land?h:w) / 131;
|
||||
screenPaint.setFilterBitmap(false);
|
||||
if (!land && fullWidth) {
|
||||
screenPaint.setFilterBitmap(true);
|
||||
lcd_ratio = (land?h:(float)w) / 131;
|
||||
}
|
||||
int start_w = (int) (131*lcd_ratio);
|
||||
int start_h = (int) (71*lcd_ratio);
|
||||
float usable_w = w;
|
||||
|
@ -416,7 +435,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
c.drawBitmap(backBuffer, 0, 0, null);
|
||||
if (data != null)
|
||||
mainScreen.copyPixelsFromBuffer(ShortBuffer.wrap(data));
|
||||
c.drawBitmap(mainScreen, matrixScreen, null);
|
||||
c.drawBitmap(mainScreen, matrixScreen, screenPaint);
|
||||
for(int i=0;i<MAX_TOUCHES;i++) {
|
||||
if (touches[i]) {
|
||||
c.drawRoundRect(new RectF(new Rect(buttons_coords[i][0], buttons_coords[i][1], buttons_coords[i][2], buttons_coords[i][3])), 12f, 12f, paint);
|
||||
|
|
|
@ -36,6 +36,13 @@ public class Settings extends PreferenceActivity {
|
|||
hapticPref.setDefaultValue(true);
|
||||
inlinePrefCat.addPreference(hapticPref);
|
||||
|
||||
CheckBoxPreference largeLCDPref = new CheckBoxPreference(this);
|
||||
largeLCDPref.setKey("large_width");
|
||||
largeLCDPref.setTitle(R.string.large_width);
|
||||
largeLCDPref.setSummary(R.string.large_width_summary);
|
||||
largeLCDPref.setDefaultValue(false);
|
||||
inlinePrefCat.addPreference(largeLCDPref);
|
||||
|
||||
ListPreference listPref = new ListPreference(this);
|
||||
listPref.setEntries(R.array.contrast_entries);
|
||||
listPref.setEntryValues(R.array.contrast_values);
|
||||
|
|
|
@ -153,8 +153,11 @@ public class X48 extends Activity {
|
|||
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
saveonExit = mPrefs.getBoolean("saveOnExit", false);
|
||||
haptic = mPrefs.getBoolean("haptic", true);
|
||||
if (mainView != null)
|
||||
largeWidth = mPrefs.getBoolean("large_width", false);
|
||||
if (mainView != null) {
|
||||
mainView.setHapticFeedbackEnabled(haptic);
|
||||
mainView.setFullWidth(largeWidth);
|
||||
}
|
||||
currentOrientation = getResources().getConfiguration().orientation;
|
||||
}
|
||||
|
||||
|
@ -372,9 +375,12 @@ public class X48 extends Activity {
|
|||
String port2 = mPrefs.getString("port2", "0");
|
||||
managePort(2, port2);
|
||||
saveonExit = mPrefs.getBoolean("saveOnExit", false);
|
||||
haptic = mPrefs.getBoolean("haptic", true);
|
||||
if (mainView != null)
|
||||
haptic = mPrefs.getBoolean("haptic", true);
|
||||
largeWidth = mPrefs.getBoolean("large_width", false);
|
||||
if (mainView != null) {
|
||||
mainView.setHapticFeedbackEnabled(haptic);
|
||||
mainView.setFullWidth(largeWidth);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -383,6 +389,7 @@ public class X48 extends Activity {
|
|||
|
||||
private boolean saveonExit;
|
||||
private boolean haptic;
|
||||
private boolean largeWidth;
|
||||
|
||||
private void managePort(int number, String value) {
|
||||
int size = Integer.parseInt(value);
|
||||
|
|
Loading…
Reference in a new issue