Cleanup, fixes and minimal controls as persistent option

This commit is contained in:
shagrath 2010-09-21 00:52:33 +02:00
parent e9736ddab4
commit dc07bab99d
10 changed files with 54 additions and 309 deletions

View file

@ -2483,7 +2483,7 @@ emulate()
{
schedule();
}
} while (!enter_debugger);
} while (!enter_debugger); // exit_state
return 0;
}

Binary file not shown.

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
<color name="candidate_normal">#FF000000</color>
<color name="candidate_recommended">#FFE35900</color>
<color name="candidate_other">#ff808080</color>
<color name="candidate_background">#bbffffff</color>
</resources>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
<dimen name="key_height">61dip</dimen>
<dimen name="candidate_font_height">16sp</dimen>
<dimen name="candidate_vertical_padding">6sp</dimen>
</resources>

View file

@ -42,4 +42,6 @@
<string name="haptic_feedback">Haptic feedback</string>
<string name="large_width">Large LCD screen</string>
<string name="large_width_summary">Portrait mode only</string>
<string name="show_lite_keyb">Minimal controls</string>
<string name="show_lite_keyb_summary">Also, easy shortcut: touch the LCD</string>
</resources>

View file

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="25%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
>
<Row>
<!-- <Key android:codes="17" android:keyLabel="SWAP" android:keyWidth="25%p" android:keyEdgeFlags="left"/> -->
<Key android:codes="24" android:keyLabel="ENTER" android:keyWidth="50%p" />
<Key android:codes="28" android:keyLabel="DROP" android:keyWidth="50%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<!-- <Key android:codes="-1" android:keyIcon="@drawable/sym_keyboard_done" android:isModifier="true"/> -->
<Key android:codes="30" android:keyLabel="7" android:keyEdgeFlags="left"/>
<Key android:codes="31" android:keyLabel="8"/>
<Key android:codes="32" android:keyLabel="9"/>
<Key android:codes="33" android:keyLabel="/" android:keyEdgeFlags="right"/>
</Row>
<Row>
<!-- <Key android:codes="34" android:keyLabel="SHL" android:keyEdgeFlags="left"/>-->
<Key android:codes="35" android:keyLabel="4" android:keyEdgeFlags="left"/>
<Key android:codes="36" android:keyLabel="5"/>
<Key android:codes="37" android:keyLabel="6"/>
<Key android:codes="38" android:keyLabel="*" android:keyEdgeFlags="right"/>
</Row>
<Row>
<!-- <Key android:codes="39" android:keyLabel="SHR" android:keyEdgeFlags="left"/>-->
<Key android:codes="40" android:keyLabel="1" android:keyEdgeFlags="left"/>
<Key android:codes="41" android:keyLabel="2"/>
<Key android:codes="42" android:keyLabel="3"/>
<Key android:codes="43" android:keyLabel="-" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="44" android:keyLabel="ON" android:keyEdgeFlags="left"/>
<Key android:codes="45" android:keyLabel="0"/>
<Key android:codes="46" android:keyLabel="."/>
<Key android:codes="48" android:keyLabel="+" android:keyEdgeFlags="right"/>
</Row>
</Keyboard>

View file

@ -1,68 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2008, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="20%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="@dimen/key_height"
>
<Row>
<Key android:codes="24" android:keyLabel="ENTER" android:keyWidth="60%p" android:keyEdgeFlags="left"/>
<Key android:codes="28" android:keyLabel="DROP" android:keyWidth="40%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="29" android:keyLabel="!" android:keyEdgeFlags="left"/>
<Key android:codes="30" android:keyLabel="SOLVE"/>
<Key android:codes="31" android:keyLabel="8"/>
<Key android:codes="32" android:keyLabel="9"/>
<Key android:codes="48" android:keyLabel="+" android:keyWidth="18%p"/>
<Key android:codes="43" android:keyLabel="-" android:keyWidth="18%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="34" android:keyLabel="SHL" android:keyEdgeFlags="left"/>
<Key android:codes="35" android:keyLabel="4" />
<Key android:codes="36" android:keyLabel="5"/>
<Key android:codes="37" android:keyLabel="6"/>
<Key android:codes="38" android:keyLabel="*" android:keyWidth="18%p"/>
<Key android:codes="33" android:keyLabel="/" android:keyWidth="18%p" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="39" android:keyLabel="SHR" android:keyEdgeFlags="left"/>
<Key android:codes="40" android:keyLabel="1"/>
<Key android:codes="41" android:keyLabel="2"/>
<Key android:codes="42" android:keyLabel="3"/>
<Key android:codes="28" android:keyWidth="36%p" android:keyLabel="DROP" android:keyEdgeFlags="right"/>
</Row>
<Row>
<Key android:codes="44" android:keyLabel="ON" android:keyEdgeFlags="left"/>
<Key android:codes="46" android:keyLabel="."/>
<Key android:codes="45" android:keyLabel="0"/>
<Key android:codes="47" android:keyIcon="@drawable/sym_keyboard_space"/>
<Key android:codes="24" android:keyLabel="ENTER" android:keyEdgeFlags="right"/>
</Row>
</Keyboard>

View file

@ -6,6 +6,7 @@ import java.util.Vector;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -106,7 +107,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
//private short data [];
private Bitmap keys [] = new Bitmap[MAX_TOUCHES];
private Bitmap backBuffer;
protected Bitmap backBuffer;
private boolean fullWidth;
public boolean isFullWidth() {
@ -126,11 +127,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
if (c != null) {
if (land) {
keybLite = false;
}
if (backBuffer == null) {
Log.i("x48", "init backBuffer !: " + keybLite);
@ -174,7 +171,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
{(int)(lcd_pos_x+67*lcd_ratio), 0}, {(int)(lcd_pos_x+91*lcd_ratio), 0}, {(int)(lcd_pos_x+112*lcd_ratio), 0} };
int green = Color.rgb(80, 96, 104);
p.setColor(green);
if (!keybLite)
if (!keybLite || land)
backCanvas.drawRect(0, 0, usable_w, start_h+menu_key_height, p);
matrixScreen = new Matrix();
@ -191,7 +188,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
float key_width = 0f;
float key_y = 0f;
float key_height = 0f;
if (!keybLite) {
if (!keybLite || land) {
if (k < 6) {
// A, B, C...
key_width = usable_w / 6;
@ -382,7 +379,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
yrank = 4;
}
key_x = key_width*(4-xrank);
key_y = start_h + regular_key_height_right*(yrank);
key_y = start_h + key_height*(yrank);
} else
key_width = 0;
}
@ -412,7 +409,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
//ratio_ky = key_height / (float) bh;
delta_y = ((int)key_height-bh)/2;
}
if (!keybLite && !land && (k == 30 || k == 31 || k == 32 ||
if (!keybLite && !land && !fullWidth && (k == 30 || k == 31 || k == 32 ||
k == 35 || k == 36 || k == 37 ||
k == 40 || k == 41 || k == 42 || k == 39)) {
Paint p2 = new Paint();
@ -482,9 +479,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
}
if (code == -1 && action == MotionEvent.ACTION_DOWN && currentOrientation != Configuration.ORIENTATION_LANDSCAPE ) {
//x48.flipkeyboard();
keybLite = !keybLite;
backBuffer = null;
refreshMainScreen(null);
((X48) getContext()).changeKeybLite();
return true;
}
@ -499,6 +494,14 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
private boolean keybLite = false;
public boolean isKeybLite() {
return keybLite;
}
public void setKeybLite(boolean keybLite) {
this.keybLite = keybLite;
}
public synchronized void key(int code, boolean down) {
//Log.i("x48", "code: " + code + " / " + down);
if (code < MAX_TOUCHES) {

View file

@ -43,6 +43,13 @@ public class Settings extends PreferenceActivity {
largeLCDPref.setDefaultValue(false);
inlinePrefCat.addPreference(largeLCDPref);
CheckBoxPreference keybLitePref = new CheckBoxPreference(this);
keybLitePref.setKey("keybLite");
keybLitePref.setTitle(R.string.show_lite_keyb);
keybLitePref.setSummary(R.string.show_lite_keyb_summary);
keybLitePref.setDefaultValue(false);
inlinePrefCat.addPreference(keybLitePref);
ListPreference listPref = new ListPreference(this);
listPref.setEntries(R.array.contrast_entries);
listPref.setEntryValues(R.array.contrast_values);

View file

@ -11,6 +11,7 @@ import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Configuration;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
@ -25,12 +26,7 @@ import android.view.Window;
public class X48 extends Activity {
private KeyboardView theKeyboard = null;
private Keyboard currentKeyboardLayout = null;
private Keyboard theKeyboardLayout0 = null;
private Keyboard theKeyboardLayout1 = null;
private HPView mainView;
private HPView mainView;
static final private int LOAD_ID = Menu.FIRST +1;
static final private int SAVE_ID = Menu.FIRST +2;
static final private int SETTINGS_ID = Menu.FIRST +5 ;
@ -39,69 +35,6 @@ public class X48 extends Activity {
static final private int ROM_ID = 123;
public class theKeyboardActionListener implements OnKeyboardActionListener{
@Override
public void onKey(int primaryCode, int[] keyCodes) {
}
@Override
public void onPress(int primaryCode) {
if (mainView != null)
mainView.key(primaryCode, true);
}
@Override
public void onRelease(int primaryCode) {
if (mainView != null)
mainView.key(primaryCode, false);
if (primaryCode == 39) {
if (currentKeyboardLayout.equals(theKeyboardLayout0)) {
currentKeyboardLayout = theKeyboardLayout1;
theKeyboard.setKeyboard(currentKeyboardLayout);
} else {
if (currentKeyboardLayout.equals(theKeyboardLayout1)) {
currentKeyboardLayout = theKeyboardLayout0;
theKeyboard.setKeyboard(currentKeyboardLayout);
}
}
}
}
@Override
public void onText(CharSequence text) {
// TODO Auto-generated method stub
}
@Override
public void swipeDown() {
}
@Override
public void swipeLeft() {
}
@Override
public void swipeRight() {
// TODO Auto-generated method stub
}
@Override
public void swipeUp() {
// TODO Auto-generated method stub
}};
// http://www.hpcalc.org/hp48/pc/emulators/gxrom-r.zip
@Override
@ -142,25 +75,32 @@ public class X48 extends Activity {
setContentView(R.layout.main);
mainView = (HPView) findViewById(R.id.hpview);
theKeyboard = (KeyboardView) findViewById(R.id.EditKeyboard01);
currentKeyboardLayout = theKeyboardLayout0 = new Keyboard(this, R.xml.state0);
theKeyboardLayout1 = new Keyboard(this, R.xml.state1);
theKeyboard.setKeyboard(currentKeyboardLayout);
theKeyboard.setOnKeyboardActionListener(new theKeyboardActionListener());
theKeyboard.setVisibility(View.INVISIBLE);
theKeyboard.setPreviewEnabled(false);
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
saveonExit = mPrefs.getBoolean("saveOnExit", false);
haptic = mPrefs.getBoolean("haptic", true);
largeWidth = mPrefs.getBoolean("large_width", false);
if (mainView != null) {
mainView.setHapticFeedbackEnabled(haptic);
mainView.setFullWidth(largeWidth);
}
checkPrefs();
currentOrientation = getResources().getConfiguration().orientation;
}
public void checkPrefs() {
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
saveonExit = mPrefs.getBoolean("saveOnExit", false);
if (mainView != null) {
mainView.setHapticFeedbackEnabled(mPrefs.getBoolean("haptic", true));
mainView.setFullWidth(mPrefs.getBoolean("large_width", false));
mainView.setKeybLite(mPrefs.getBoolean("keybLite", false));
}
}
public void changeKeybLite() {
if (mainView != null) {
mainView.setKeybLite(!mainView.isKeybLite());
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
Editor e = mPrefs.edit();
e.putBoolean("keybLite", mainView.isKeybLite());
e.commit();
mainView.backBuffer = null;
refreshMainScreen(null);
}
}
public void refreshMainScreen(short data []) {
mainView.refreshMainScreen(data);
}
@ -216,7 +156,7 @@ public class X48 extends Activity {
// given them shortcuts.
//menu.add(0, RESET_ID, 0, R.string.reset);
menu.add(0, SAVE_ID, 0, R.string.save_state);
menu.add(0, SAVE_ID, 0, R.string.save_state);
menu.add(0, LOAD_ID, 0, R.string.load_prog);
menu.add(0, SETTINGS_ID, 0, R.string.settings);
menu.add(0, RESET_ID, 0, R.string.reset_memory);
@ -242,6 +182,7 @@ public class X48 extends Activity {
case SAVE_ID:
saveState();
return true;
case LOAD_ID:
//loadProg("/data/data/org.ab.x48/SKUNK");
Intent loadFileIntent = new Intent();
@ -374,13 +315,7 @@ public class X48 extends Activity {
managePort(1, port1);
String port2 = mPrefs.getString("port2", "0");
managePort(2, port2);
saveonExit = mPrefs.getBoolean("saveOnExit", false);
haptic = mPrefs.getBoolean("haptic", true);
largeWidth = mPrefs.getBoolean("large_width", false);
if (mainView != null) {
mainView.setHapticFeedbackEnabled(haptic);
mainView.setFullWidth(largeWidth);
}
checkPrefs();
}
}
@ -388,9 +323,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);
File f = AssetUtil.getSDDir();
@ -475,22 +408,7 @@ public class X48 extends Activity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
/*Log.i("x48", "corientation: " + currentOrientation);
if (currentOrientation != newConfig.orientation) {
Log.i("x48", "orientation: " + newConfig.orientation);
if (mainView != null)
mainView.pause(true);
currentOrientation = newConfig.orientation;
}*/
currentOrientation = newConfig.orientation;
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE && theKeyboard.getVisibility()==View.VISIBLE)
theKeyboard.setVisibility(View.INVISIBLE);
}
public void flipkeyboard() {
if (theKeyboard.getVisibility()==View.VISIBLE)
theKeyboard.setVisibility(View.INVISIBLE);
else
theKeyboard.setVisibility(View.VISIBLE);
}
}