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