Skip to content
Browse files

2.0a1

  • Loading branch information...
1 parent 9298891 commit ba9ae449b55e0f4fcb034ab3b8106a99c78a5ecd @lpar committed May 27, 2012
View
BIN Artwork/RPN calculator 512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
133 Artwork/RPN calculator.svg
@@ -16,7 +16,7 @@
version="1.1"
inkscape:version="0.48.0 r9654"
sodipodi:docname="RPN calculator.svg"
- inkscape:export-filename="/home/meta/Documents/My icons/RPN calculator 512.png"
+ inkscape:export-filename="/Users/meta/Programming/Eclipse Workspace/RPN/Artwork/RPN calculator 512.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
style="display:inline">
@@ -435,7 +435,8 @@
y1="981.41119"
x2="110.96732"
y2="852.21997"
- gradientUnits="userSpaceOnUse" />
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-0.93723167,-1.0169671e-5)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3989"
@@ -453,7 +454,8 @@
y1="739.17767"
x2="348.75443"
y2="609.98651"
- gradientUnits="userSpaceOnUse" />
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-13.247811,-49.611132)" />
<filter
id="filter4438"
inkscape:label="Drop shadow"
@@ -586,6 +588,56 @@
in="SourceGraphic" />
</feMerge>
</filter>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3989"
+ id="linearGradient3115"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-13.247811,-49.611132)"
+ x1="380.45938"
+ y1="739.17767"
+ x2="348.75443"
+ y2="609.98651" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3989"
+ id="linearGradient3117"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-13.247811,-49.611132)"
+ x1="380.45938"
+ y1="739.17767"
+ x2="348.75443"
+ y2="609.98651" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3989"
+ id="linearGradient3119"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="translate(-13.247811,-49.611132)"
+ x1="380.45938"
+ y1="739.17767"
+ x2="348.75443"
+ y2="609.98651" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3989"
+ id="linearGradient3122"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.0093062,0,0,0.9907796,17.402152,-39.203561)"
+ x1="380.45938"
+ y1="739.17767"
+ x2="348.75443"
+ y2="609.98651" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3989"
+ id="linearGradient3125"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.0093062,0,0,0.9907796,-46.385288,-35.697331)"
+ x1="380.45938"
+ y1="739.17767"
+ x2="348.75443"
+ y2="609.98651" />
</defs>
<sodipodi:namedview
id="base"
@@ -594,16 +646,16 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
- inkscape:zoom="1.4726562"
- inkscape:cx="255.32095"
- inkscape:cy="256"
+ inkscape:zoom="0.84"
+ inkscape:cx="44.606664"
+ inkscape:cy="257.63311"
inkscape:document-units="px"
- inkscape:current-layer="layer3"
+ inkscape:current-layer="layer1"
showgrid="true"
- inkscape:window-width="1920"
- inkscape:window-height="1025"
- inkscape:window-x="-2"
- inkscape:window-y="-3"
+ inkscape:window-width="1280"
+ inkscape:window-height="752"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
@@ -638,31 +690,31 @@
height="224"
x="16"
y="16"
- ry="32" />
+ ry="16" />
<rect
- style="fill:url(#linearGradient3919);fill-opacity:1.0;stroke:none;display:inline;filter:url(#filter4480)"
+ style="fill:url(#linearGradient3919);fill-opacity:1;stroke:none;display:inline;filter:url(#filter4480)"
id="rect3894-2"
width="224"
height="224"
x="256"
y="16"
- ry="32" />
+ ry="16" />
<rect
- style="fill:url(#linearGradient3953);fill-opacity:1.0;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;filter:url(#filter4452)"
+ style="fill:url(#linearGradient3953);fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;filter:url(#filter4452)"
id="rect3894-8"
width="224"
height="224"
x="16"
y="256"
- ry="32" />
+ ry="16" />
<rect
- style="fill:url(#linearGradient3953-5);fill-opacity:1.0;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;filter:url(#filter4438)"
+ style="fill:url(#linearGradient3953-5);fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline;filter:url(#filter4438)"
id="rect3894-6"
width="224"
height="224"
x="256"
y="256"
- ry="32" />
+ ry="16" />
</g>
<g
inkscape:label="Layer 1"
@@ -677,34 +729,34 @@
height="192"
x="32"
y="572.36218"
- ry="15.999997" />
+ ry="0" />
<rect
style="fill:url(#linearGradient3832);fill-opacity:1;stroke:none"
id="rect3007-4"
width="192"
height="192"
x="272"
y="572.36218"
- ry="15.999997" />
+ ry="0" />
<rect
style="fill:url(#linearGradient3879);fill-opacity:1;stroke:none"
id="rect3007-1"
width="192"
height="192"
x="32"
y="812.36218"
- ry="15.999997" />
+ ry="0" />
<rect
style="fill:url(#linearGradient3832-0);fill-opacity:1;stroke:none"
id="rect3007-4-1"
width="192"
height="192"
x="272"
y="812.36218"
- ry="15.999997" />
+ ry="0" />
<text
xml:space="preserve"
- style="font-size:50.14451599000000215px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient4011);fill-opacity:1;stroke:none;font-family:Sans"
+ style="font-size:50.14451599px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient4011);fill-opacity:1;stroke:none;font-family:Sans"
x="80.286858"
y="739.04614"
id="text3916"
@@ -714,33 +766,32 @@
id="tspan3918"
x="80.286858"
y="739.04614"
- style="font-size:180.52024840999999356px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Droid Sans;-inkscape-font-specification:Droid Sans Bold;fill-opacity:1;fill:url(#linearGradient4011)">1</tspan></text>
- <text
- xml:space="preserve"
- style="font-size:64.50615691999999513px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient4013);fill-opacity:1;stroke:none;font-family:Sans"
- x="266.88739"
- y="756.49103"
- id="text3916-2"
- sodipodi:linespacing="125%"
- transform="scale(1.0093062,0.9907796)"><tspan
- sodipodi:role="line"
- id="tspan3918-2"
- x="266.88739"
- y="756.49103"
- style="font-size:232.22215271000001735px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Droid Sans;-inkscape-font-specification:Droid Sans Bold;fill-opacity:1;fill:url(#linearGradient4013)">⤶</tspan></text>
+ style="font-size:180.52024840999999356px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;fill:url(#linearGradient4011);fill-opacity:1;font-family:Roboto;-inkscape-font-specification:Roboto Medium">1</tspan></text>
+ <path
+ inkscape:connector-curvature="0"
+ id="path3113"
+ d="m 332,676.36218 c 13.70301,0.0255 79.24645,-0.13594 80,0 l 0,-72 16,0 0,88 -96,0"
+ style="font-size:232.22215271px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient3125);fill-opacity:1;stroke:none;font-family:Droid Sans Fallback;-inkscape-font-specification:Droid Sans Fallback"
+ sodipodi:nodetypes="cccccc" />
+ <path
+ sodipodi:nodetypes="ccccccscccccc"
+ inkscape:connector-curvature="0"
+ id="path3109"
+ d="m 337.12902,689.64099 16.48007,31.45639 c 1.83106,4.19417 2.74661,7.19001 2.74668,8.98753 -7e-5,2.39666 -0.91562,3.595 -2.74668,3.59503 -2.44155,-3e-5 -5.18822,-1.49795 -8.24003,-4.49377 L 306,695.03352 c -3.66226,-3.595 -5.49337,-7.19001 -5.49336,-10.78504 -1e-5,-3.59499 1.8311,-6.89042 5.49336,-9.8863 l 39.36906,-35.05139 c 3.05181,-2.99577 5.79848,-4.49369 8.24003,-4.49377 1.83106,8e-5 2.74661,1.498 2.74668,4.49377 -7e-5,1.79757 -0.91562,4.79342 -2.74668,8.98754 l -18.83584,30.01399"
+ style="font-size:232.22215271px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient3122);fill-opacity:1;stroke:none;font-family:Droid Sans Fallback;-inkscape-font-specification:Droid Sans Fallback" />
<text
xml:space="preserve"
- style="font-size:49.56055068999999236px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient4003);fill-opacity:1;stroke:none;font-family:Sans"
- x="80.1996"
+ style="font-size:49.56055069px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient4003);fill-opacity:1;stroke:none;font-family:Sans"
+ x="79.262367"
y="981.41119"
id="text3916-1"
sodipodi:linespacing="125%"
transform="scale(1.0093062,0.9907796)"><tspan
sodipodi:role="line"
id="tspan3918-8"
- x="80.1996"
+ x="79.262367"
y="981.41119"
- style="font-size:178.41798400999999785px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Droid Sans;-inkscape-font-specification:Droid Sans Bold;fill-opacity:1;fill:url(#linearGradient4003)">2</tspan></text>
+ style="font-size:178.41798401px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;fill:url(#linearGradient4003);fill-opacity:1;font-family:Roboto;-inkscape-font-specification:Roboto Medium">2</tspan></text>
<text
xml:space="preserve"
style="font-size:77.69850922000000537px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient3995);fill-opacity:1;stroke:none;font-family:Sans"
View
BIN assets/fonts/Roboto-Light.ttf
Binary file not shown.
View
BIN res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN res/drawable-xhdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
63 res/layout/main.xml
@@ -2,10 +2,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:orientation="vertical">
-
+ android:orientation="vertical"
+ android:id="@+id/MainLayout" android:gravity="top|left">
+
<FrameLayout android:layout_width="wrap_content" android:layout_weight="1.0"
- android:layout_height="0dp" android:fillViewport="true">
+ android:layout_height="0dp" android:fillViewport="true" android:id="@+id/TopFrame">
<HorizontalScrollView
android:id="@+id/Scroll"
@@ -17,14 +18,16 @@
android:fillViewport="true">
<LinearLayout android:id="@+id/ScrollInsides"
- android:orientation="horizontal" android:layout_width="wrap_content"
+ android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="fill_parent" android:fillViewport="true">
<TextView
android:id="@+id/Display"
style="@android:style/TextAppearance.Large"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ android:layout_height="0dp"
+ android:fillViewport="true"
+ android:layout_weight="1.0"
android:layout_gravity="bottom|right"
android:background="#eeeeee"
android:gravity="bottom|right"
@@ -33,7 +36,6 @@
android:paddingRight="8sp"
android:paddingTop="0sp"
android:scrollHorizontally="false"
- android:text="&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;&#x0a;"
android:textColor="#000"
android:typeface="monospace" />
@@ -53,63 +55,62 @@
android:id="@+id/keygrid"
android:layout_weight="0"
android:columnCount="5"
- android:gravity="fill"
android:rowCount="5" >
-<Button android:text="&#x221a;" android:id="@+id/sqrt" android:onClick="clickHandler" android:tag="sqrt" style="?android:attr/buttonStyleSmall" />
+<Button android:text="&#x221a;" android:id="@+id/sqrt" android:onClick="clickHandler" android:tag="sqrt" style="@style/CalculatorButtonSmallStyle" />
-<Button android:text="&#x215f;&#x2093;" android:id="@+id/recip" android:onClick="clickHandler" android:tag="1/x" style="?android:attr/buttonStyleSmall" />
+<Button android:text="&#x215f;&#x2093;" android:id="@+id/recip" android:onClick="clickHandler" android:tag="1/x" style="@style/CalculatorButtonSmallStyle" />
-<Button android:text="&#x2093;&#x207f;" android:id="@+id/power" android:onClick="clickHandler" android:tag="pow" style="?android:attr/buttonStyleSmall" />
+<Button android:text="&#x2093;&#x207f;" android:id="@+id/power" android:onClick="clickHandler" android:tag="pow" style="@style/CalculatorButtonSmallStyle" />
-<Button android:text="SWAP" android:id="@+id/swap" android:onClick="clickHandler" android:tag="swap" style="?android:attr/buttonStyleSmall" />
+<Button android:text="SWAP" android:id="@+id/swap" android:onClick="clickHandler" android:tag="swap" style="@style/CalculatorButtonSmallStyle" />
-<Button android:text="DROP" android:id="@+id/drop" android:onClick="clickHandler" android:tag="drop" style="?android:attr/buttonStyleSmall" />
+<Button android:text="DROP" android:id="@+id/drop" android:onClick="clickHandler" android:tag="drop" style="@style/CalculatorButtonSmallStyle" />
-<Button android:text="SET DP" android:id="@+id/sdp" android:onClick="clickHandler" android:tag="sdp" style="?android:attr/buttonStyleSmall" />
+<Button android:text="DP" android:id="@+id/sdp" android:onClick="clickHandler" android:tag="sdp" style="@style/CalculatorButtonSmallStyle" />
<Button
android:id="@+id/k7"
android:onClick="clickHandler"
android:tag="7"
- android:text="7" />
+ android:text="7" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="8" android:id="@+id/k8" android:tag="8" android:onClick="clickHandler" />
+ <Button android:text="8" android:id="@+id/k8" android:tag="8" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="9" android:id="@+id/k9" android:tag="9" android:onClick="clickHandler" />
+ <Button android:text="9" android:id="@+id/k9" android:tag="9" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="&#x00f7;" android:id="@+id/div" android:tag="/" android:onClick="clickHandler" />
+ <Button android:text="&#x00f7;" android:id="@+id/div" android:tag="/" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="&#x232b;" android:id="@+id/bsp" android:tag="bsp" android:onClick="clickHandler" />
+ <Button android:text="&#x232b;" android:id="@+id/bsp" android:tag="bsp" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="4" android:id="@+id/k4" android:tag="4" android:onClick="clickHandler" />
+ <Button android:text="4" android:id="@+id/k4" android:tag="4" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="5" android:id="@+id/k5" android:tag="5" android:onClick="clickHandler" />
+ <Button android:text="5" android:id="@+id/k5" android:tag="5" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="6" android:id="@+id/k6" android:tag="6" android:onClick="clickHandler" />
+ <Button android:text="6" android:id="@+id/k6" android:tag="6" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="&#x00d7;" android:id="@+id/mult" android:tag="*" android:onClick="clickHandler" />
+ <Button android:text="&#x00d7;" android:id="@+id/mult" android:tag="*" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="E&#x0a;N&#x0a;T&#x0a;E&#x0a;R" android:id="@+id/enter" android:tag="enter" style="?android:attr/buttonStyleSmall" android:layout_rowSpan="2" android:onClick="clickHandler" />
+ <Button android:text="E&#x0a;N&#x0a;T&#x0a;E&#x0a;R" android:id="@+id/enter" android:tag="enter" style="@style/CalculatorButtonSmallStyle" android:layout_rowSpan="2" android:onClick="clickHandler" />
- <Button android:text="1" android:id="@+id/k1" android:tag="1" android:onClick="clickHandler" />
+ <Button android:text="1" android:id="@+id/k1" android:tag="1" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="2" android:id="@+id/k2" android:tag="2" android:onClick="clickHandler" />
+ <Button android:text="2" android:id="@+id/k2" android:tag="2" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="3" android:id="@+id/k3" android:tag="3" android:onClick="clickHandler" />
+ <Button android:text="3" android:id="@+id/k3" android:tag="3" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="&#x2212;" android:id="@+id/minus" android:tag="-" android:onClick="clickHandler" />
+ <Button android:text="&#x2212;" android:id="@+id/minus" android:tag="-" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="0" android:id="@+id/k0" android:tag="0" android:onClick="clickHandler" />
+ <Button android:text="0" android:id="@+id/k0" android:tag="0" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
- <Button android:onClick="clickHandler" android:id="@+id/point" android:text="&#x00b7;" android:tag="." />
+ <Button android:onClick="clickHandler" android:id="@+id/point" android:text="&#x00b7;" android:tag="." style="@style/CalculatorButtonLargeStyle" />
- <Button android:onClick="clickHandler" android:id="@+id/chs" android:tag="chs" android:text="&#x00b1;" />
+ <Button android:onClick="clickHandler" android:id="@+id/chs" android:tag="chs" android:text="&#x00b1;" style="@style/CalculatorButtonLargeStyle" />
- <Button android:text="&#x002b;" android:id="@+id/plus" android:tag="+" android:onClick="clickHandler" />
+ <Button android:text="&#x002b;" android:id="@+id/plus" android:tag="+" android:onClick="clickHandler" style="@style/CalculatorButtonLargeStyle" />
</com.ath0.rpn.CalculatorKeyLayout>
View
7 res/menu/main.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Action bar menu -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- We use the system IDs for copy and paste, and the system-provided internationalized title -->
+ <item android:id="@android:id/copy" android:title="@android:string/copy" android:showAsAction="never"></item>
+ <item android:id="@android:id/paste" android:title="@android:string/paste" android:showAsAction="never"></item>
+</menu>
View
85 res/values/styles.xml
@@ -1,88 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <style name="Theme.RPN" parent="android:Theme.Black.NoTitleBar">
- </style>
-
- <style name="CalculatorDisplay" parent="@android:style/TextAppearance.Large">
- <item name="android:background">#a5af91</item>
- <item name="android:textColor">#000</item>
- <item name="android:padding">3dp</item>
- </style>
- <style name="LandscapeCalculatorDisplay" parent="@android:style/TextAppearance.Small">
- <item name="android:background">#a5af91</item>
- <item name="android:textColor">#000</item>
- <item name="android:padding">3dp</item>
- </style>
-
- <style name="CalculatorButtonStyle">
- <item name="android:hapticFeedbackEnabled">true</item>
- <item name="android:textSize">30sp</item>
- <item name="android:focusable">true</item>
- <item name="android:layout_width">64dp</item>
- <item name="android:layout_height">78dp</item>
- </style>
- <style name="LandscapeCalculatorButtonStyle">
- <item name="android:hapticFeedbackEnabled">true</item>
- <item name="android:textSize">15sp</item>
- <item name="android:focusable">true</item>
- <item name="android:layout_width">80dp</item>
- <item name="android:layout_height">37dp</item>
- </style>
-
- <style name="EnterButtonStyle" parent="CalculatorButtonStyle">
- <item name="android:textSize">15sp</item>
- <item name="android:layout_width">64dp</item>
- <item name="android:layout_height">156dp</item>
- </style>
- <style name="LandscapeEnterButtonStyle" parent="LandscapeCalculatorButtonStyle">
- <item name="android:textSize">15sp</item>
- <item name="android:layout_width">80dp</item>
- <item name="android:layout_height">74dp</item>
- </style>
-
- <style name="CalculatorTextButtonStyle">
- <item name="android:hapticFeedbackEnabled">true</item>
- <item name="android:textSize">14sp</item>
- <item name="android:focusable">true</item>
- <item name="android:layout_width">64dp</item>
- <item name="android:layout_height">78dp</item>
- </style>
- <style name="LandscapeCalculatorTextButtonStyle">
- <item name="android:hapticFeedbackEnabled">true</item>
- <item name="android:textSize">14sp</item>
- <item name="android:focusable">true</item>
- <item name="android:layout_width">80dp</item>
- <item name="android:layout_height">37dp</item>
- </style>
- <style name="ShiftButtonStyle" parent="@android:style/Widget.Button.Toggle">
- <item name="android:hapticFeedbackEnabled">true</item>
- <item name="android:textSize">20sp</item>
- <item name="android:focusable">true</item>
- <item name="android:layout_width">64dp</item>
- <item name="android:layout_height">78dp</item>
- </style>
- <style name="LandscapeShiftButtonStyle">
+ <style name="CalculatorButtonLargeStyle" parent="@android:style/Widget.Holo.Button">
<item name="android:hapticFeedbackEnabled">true</item>
- <item name="android:textSize">13sp</item>
- <item name="android:focusable">true</item>
- <item name="android:layout_width">80dp</item>
- <item name="android:layout_height">37dp</item>
+ <item name="android:textSize">24sp</item>
+ <item name="android:layout_gravity">top|left</item>
</style>
- <style name="MissingButtonStyle">
- <item name="android:hapticFeedbackEnabled">false</item>
- <item name="android:background">#00000000</item>
- <item name="android:focusable">false</item>
- <item name="android:layout_width">64dp</item>
- <item name="android:layout_height">78dp</item>
- </style>
- <style name="LandscapeMissingButtonStyle">
- <item name="android:hapticFeedbackEnabled">false</item>
- <item name="android:background">#00000000</item>
- <item name="android:focusable">false</item>
- <item name="android:layout_width">80dp</item>
- <item name="android:layout_height">37dp</item>
+ <style name="CalculatorButtonSmallStyle" parent="@android:style/Widget.Holo.Button.Small">
+ <item name="android:hapticFeedbackEnabled">true</item>
+ <item name="android:layout_gravity">top|left</item>
</style>
</resources>
View
10 src/com/ath0/rpn/CalculatorKeyLayout.java
@@ -1,6 +1,8 @@
package com.ath0.rpn;
import android.content.Context;
+import android.content.res.AssetManager;
+import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.GridLayout;
@@ -41,7 +43,9 @@ public void onSizeChanged(int w, int h, int oldw, int oldh) {
int padding = enter.getTop() - del.getTop();
/* System.out.println("Padding seems to be" + Integer.toString(padding)); */
// Set some keys to custom font so they show up correctly
- // Typeface rpnfont = Typeface.createFromAsset(this.mycontext.getAssets(), "samplefont.ttf");
+ AssetManager assets = this.mycontext.getAssets();
+ Typeface rpnfont = Typeface.createFromAsset(assets, "fonts/RPN.TTF");
+ Typeface roboto = Typeface.createFromAsset(assets, "fonts/Roboto-Light.ttf");
// Resize everything except enter
for(int i = 0; i < getChildCount(); i++) {
Button key = (Button) getChildAt(i);
@@ -54,7 +58,9 @@ public void onSizeChanged(int w, int h, int oldw, int oldh) {
key.setWidth(kw);
// System.out.println("Set width and height for key #" + Integer.toString(i));
if (k == R.id.bsp || k == R.id.recip || k == R.id.power || k == R.id.sqrt) {
- // key.setTypeface(rpnfont);
+ key.setTypeface(rpnfont);
+ } else {
+ key.setTypeface(roboto);
}
}
View
46 src/com/ath0/rpn/CalculatorStack.java
@@ -2,6 +2,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.Stack;
@@ -225,4 +226,49 @@ public int getScale() {
return this.scale;
}
+ public void sqrt() {
+ if (!this.stack.isEmpty()) {
+ BigDecimal x = sqrt(this.stack.pop(), INTERNAL_SCALE);
+ this.stack.push(x);
+ }
+ }
+
+ /**
+ * Compute the square root of x to a given scale, x >= 0.
+ * Use Newton's algorithm.
+ * Taken from "Java Number Cruncher: The Java Programmer's Guide to Numerical Computing"
+ * (Ronald Mak, 2003) http://goo.gl/CXpi2
+ * @param x the value of x
+ * @param scale the desired scale of the result
+ * @return the result value
+ */
+ private static BigDecimal sqrt(BigDecimal x, int scale)
+ {
+ // Check that x >= 0.
+ if (x.signum() < 0) {
+ throw new IllegalArgumentException("x < 0");
+ }
+
+ // n = x*(10^(2*scale))
+ BigInteger n = x.movePointRight(scale << 1).toBigInteger();
+
+ // The first approximation is the upper half of n.
+ int bits = (n.bitLength() + 1) >> 1;
+ BigInteger ix = n.shiftRight(bits);
+ BigInteger ixPrev;
+
+ // Loop until the approximations converge
+ // (two successive approximations are equal after rounding).
+ do {
+ ixPrev = ix;
+
+ // x = (x + n/x)/2
+ ix = ix.add(n.divide(ix)).shiftRight(1);
+
+ Thread.yield();
+ } while (ix.compareTo(ixPrev) != 0);
+
+ return new BigDecimal(ix, scale);
+ }
+
}
View
116 src/com/ath0/rpn/Main.java
@@ -9,14 +9,20 @@
import java.io.ObjectOutputStream;
import android.app.Activity;
+import android.content.ClipData;
+import android.content.ClipDescription;
+import android.content.ClipboardManager;
import android.content.Context;
-import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.View.OnKeyListener;
+import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.TextView;
import android.widget.Toast;
@@ -26,6 +32,8 @@
private InputBuffer buffer;
private CalculatorStack stack;
private String error;
+ private Menu optionsmenu;
+ private int screenlines;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -43,26 +51,43 @@ public void onCreate(Bundle savedInstanceState) {
t.requestFocus();
t.setOnKeyListener(this); */
loadState();
- updateDisplay();
+ }
+
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ // At this point we are guaranteed to have been laid out on screen
+ final TextView t = (TextView) findViewById(R.id.Display);
+ final FrameLayout hsv = (FrameLayout) findViewById(R.id.TopFrame);
+ this.screenlines = 1 + Math.round((float) hsv.getHeight() / (float) t.getLineHeight());
+ System.out.println("Frame height = " + Integer.toString(hsv.getHeight()));
+ System.out.println("Line height = " + Integer.toString(t.getLineHeight()));
+ System.out.println("Lines = " + Integer.toString(this.screenlines));
+ updateDisplay();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ this.optionsmenu = menu;
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.main, menu);
+ return true;
}
/**
- * Update the 4-level stack.
+ * Update the N-level stack.
*/
public void updateDisplay() {
final TextView t = (TextView) findViewById(R.id.Display);
- int lines;
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
- lines = 2;
- } else {
- lines = 4;
- }
- System.out.println("Lines = " + Integer.toString(lines));
StringBuilder text;
if (this.buffer.isEmpty() && this.error == null) {
if (this.stack.isEmpty()) {
// Display zero rather than a totally empty display
- text = new StringBuilder("\n\n\n0");
+ text = new StringBuilder();
+ for (int i = 1; i < this.screenlines - 1; i++) {
+ text.append('\n');
+ }
+ text.append('0');
int sc = this.stack.getScale();
if (sc > 0) {
text.append('.');
@@ -71,10 +96,10 @@ public void updateDisplay() {
}
}
} else {
- text = this.stack.toString(lines);
+ text = this.stack.toString(this.screenlines);
}
} else {
- text = this.stack.toString(lines - 1);
+ text = this.stack.toString(this.screenlines - 1);
text.append("\n");
if (this.error == null) {
text.append(this.buffer.get());
@@ -83,7 +108,7 @@ public void updateDisplay() {
this.error = null;
}
}
- t.setLines(lines);
+ t.setLines(this.screenlines);
t.setText(text);
scrollToRight();
}
@@ -198,6 +223,10 @@ public void clickHandler(final View v) {
implicitPush();
this.stack.chs();
updateDisplay();
+ } else if ("sqrt".equals(key)) {
+ implicitPush();
+ this.stack.sqrt();
+ updateDisplay();
} else if ("enter".equals(key)) {
keyEnter();
} else {
@@ -298,4 +327,63 @@ private void reportError(String thrower, String message) {
toast.show();
Log.e(thrower,message);
}
+
+ private boolean copy() {
+ Context c = this.getBaseContext();
+ ClipboardManager clipboard = (ClipboardManager) c.getSystemService(Context.CLIPBOARD_SERVICE);
+ final TextView t = (TextView) findViewById(R.id.Display);
+ String text = t.getText().toString();
+ int lastnl = text.lastIndexOf('\n');
+ String tocopy = text.substring(lastnl + 1);
+ System.out.println("Putting " + tocopy + " on clipboard");
+ ClipData clip = ClipData.newPlainText("RPN calculator value", tocopy);
+ clipboard.setPrimaryClip(clip);
+ return true;
+ }
+
+ private boolean paste() {
+ Context ctx = this.getBaseContext();
+ ClipboardManager clipboard = (ClipboardManager) ctx.getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
+ CharSequence text = item.getText();
+ System.out.println("Asked to paste " + text.toString());
+ // Dispatch as keypresses to self
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ keyOther(c);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ System.out.println("Preparing options menu");
+ Context c = this.getBaseContext();
+ ClipboardManager clipboard = (ClipboardManager) c.getSystemService(Context.CLIPBOARD_SERVICE);
+ MenuItem pasteitem = this.optionsmenu.findItem(android.R.id.paste);
+ if (!(clipboard.hasPrimaryClip())) {
+ System.out.println("Clipboard is empty");
+ pasteitem.setEnabled(false);
+ } else if (!(clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN))) {
+ System.out.println("Clipboard has no plain text");
+ pasteitem.setEnabled(false);
+ } else {
+ System.out.println("Clipboard is OK");
+ pasteitem.setEnabled(true);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ System.out.println("Menu item selected!");
+ switch (item.getItemId()) {
+ case android.R.id.copy:
+ return this.copy();
+ case android.R.id.paste:
+ return this.paste();
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
}
View
37 src/com/ath0/rpn/StackView.java
@@ -1,37 +0,0 @@
-package com.ath0.rpn;
-
-import android.content.ClipData;
-import android.content.Context;
-import android.content.ClipboardManager;
-import android.util.AttributeSet;
-import android.widget.EditText;
-
-public class StackView extends EditText {
-
- public StackView(Context context) {
- super(context);
- }
-
- public StackView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public StackView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public boolean onTextContextMenuItem(int id) {
- if (id == android.R.id.copy) {
- Context c = this.getContext();
- ClipboardManager clipboard = (ClipboardManager) c.getSystemService(Context.CLIPBOARD_SERVICE);
- String text = this.getText().toString();
- int lastnl = text.lastIndexOf('\n');
- String tocopy = text.substring(lastnl + 1);
- ClipData clip = ClipData.newPlainText("RPN calculator value",tocopy);
- clipboard.setPrimaryClip(clip);
- return true;
- }
- return false;
- }
-
-}

0 comments on commit ba9ae44

Please sign in to comment.
Something went wrong with that request. Please try again.