android-release: $(shell ${NITLS} -M src/scientific src/android_calculator.nit) ${NITC} android/res/drawable-hdpi/icon.png
mkdir -p bin
- ${NITC} -o bin/calculator.apk src/scientific -m src/android_calculator.nit --release
+ ${NITC} -o bin/calculator.apk src/android_calculator.nit --release
+ ${NITC} -o bin/scientific.apk src/scientific -m src/android_calculator.nit --release
android/res/drawable-hdpi/icon.png: art/icon.svg ../../contrib/inkscape_tools/bin/svg_to_icons
mkdir -p android/res
../../contrib/inkscape_tools/bin/svg_to_icons art/icon.svg --android --out android/res/
-src/scientific/android/res/drawable-hdpi/icon.png: art/icon_sci.svg ../../contrib/inkscape_tools/bin/svg_to_icons
+src/scientific/android/res/drawable-hdpi/icon.png: art/icon-sci.svg ../../contrib/inkscape_tools/bin/svg_to_icons
mkdir -p src/scientific/android/res
../../contrib/inkscape_tools/bin/svg_to_icons art/icon-sci.svg --android --out src/scientific/android/res/
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2014 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>
+
+ <!-- Default background color for the status bar. -->
+ <color name="calculator_accent_color">#00BCD4</color>
+
+ <!-- Color to indicate an error has occured. -->
+ <color name="calculator_error_color">#F40056</color>
+
+ <!-- Background color of the calculator display. -->
+ <color name="display_background_color">#FFF</color>
+
+ <!-- Text color for the formula in the calculator display. -->
+ <color name="display_formula_text_color">#8A000000</color>
+
+ <!-- Text color for the result in the calculator display. -->
+ <color name="display_result_text_color">#6C000000</color>
+
+ <!-- Background color for the numeric pad. -->
+ <color name="pad_numeric_background_color">#434343</color>
+
+ <!-- Background color for the operator pad. -->
+ <color name="pad_operator_background_color">#636363</color>
+
+ <!-- Background color for the advanced pad. -->
+ <color name="pad_advanced_background_color">#1DE9B6</color>
+
+ <!-- Text color for a button in a pad. -->
+ <color name="pad_button_text_color">#FFF</color>
+
+ <!-- Text color for a button in the advanced pad. -->
+ <color name="pad_button_advanced_text_color">#91000000</color>
+
+ <!-- Ripple color when a button is pressed in a pad. -->
+ <color name="pad_button_ripple_color">#33FFFFFF</color>
+
+ <!-- Ripple color when a button is pressed in a pad. -->
+ <color name="pad_button_advanced_ripple_color">#1A000000</color>
+
+</resources>
import android
redef class Button
- init do set_android_style(native, (text or else "?").is_int)
+ init do set_android_style(native, app.native_activity,
+ (text or else "?").is_int,
+ ["+","-","×","C","÷","=","."].has(text))
- private fun set_android_style(java_button: NativeButton, is_number: Bool)
+ # Set color and text style
+ private fun set_android_style(java_button: NativeButton, activity: NativeActivity,
+ is_number: Bool, is_basic_op: Bool)
in "Java" `{
- // Flatten the background and use a different color for digit buttons
- int color = is_number? android.graphics.Color.DKGRAY: android.graphics.Color.TRANSPARENT;
- java_button.setBackgroundColor(color);
+ // Set color
+ int back_color_id = 0;
+ if (is_number)
+ back_color_id = R.color.pad_numeric_background_color;
+ else if (is_basic_op)
+ back_color_id = R.color.pad_operator_background_color;
+ else {
+ back_color_id = R.color.pad_advanced_background_color;
- // Center the label on both horizontal and vertical axes
- java_button.setGravity(android.view.Gravity.CENTER);
+ int text_color = activity.getResources().getColor(R.color.pad_button_advanced_text_color);
+ java_button.setTextColor(text_color);
+ }
+ java_button.setBackgroundResource(back_color_id);
- // Set lowercase text to correctly display constants like e and π
+ // Center label, use lowercase and make text bigger
+ java_button.setGravity(android.view.Gravity.CENTER);
java_button.setAllCaps(false);
+ java_button.setTextSize(android.util.TypedValue.COMPLEX_UNIT_FRACTION, 100.0f);
+ `}
+end
+
+redef class TextInput
+ init do set_android_style(native, app.native_activity)
+
+ # Set text style and hide cursor
+ private fun set_android_style(java_edit_text: NativeEditText, activity: NativeActivity)
+ in "Java" `{
+ java_edit_text.setBackgroundResource(R.color.display_background_color);
+ java_edit_text.setTextColor(
+ activity.getResources().getColor(R.color.display_formula_text_color));
+ java_edit_text.setTextSize(android.util.TypedValue.COMPLEX_UNIT_FRACTION, 120.0f);
+ java_edit_text.setCursorVisible(false);
+ java_edit_text.setGravity(android.view.Gravity.CENTER_VERTICAL | android.view.Gravity.END);
`}
end