8bdbdc8b0811b88efb8ff4f40ac0520f2dce5975
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Aesthetic adaptations for Android
16 module android_calculator
22 init do set_android_style
(native
, app
.native_activity
,
23 (text
or else "?").is_int
,
24 ["+","-","×","C","÷","=","."].has
(text
))
26 # Set color and text style
27 private fun set_android_style
(java_button
: NativeButton, activity
: NativeActivity,
28 is_number
: Bool, is_basic_op
: Bool)
31 int back_color_id = 0;
33 back_color_id = R.color.pad_numeric_background_color;
35 back_color_id = R.color.pad_operator_background_color;
37 back_color_id = R.color.pad_advanced_background_color;
39 int text_color = activity.getResources().getColor(R.color.pad_button_advanced_text_color);
40 java_button.setTextColor(text_color);
42 java_button.setBackgroundResource(back_color_id);
44 // Center label, use lowercase and make text bigger
45 java_button.setGravity(android.view.Gravity.CENTER);
46 java_button.setAllCaps(false);
47 java_button.setTextSize(android.util.TypedValue.COMPLEX_UNIT_FRACTION, 100.0f);
52 init do set_android_style
(native
, app
.native_activity
)
54 # Set text style and hide cursor
55 private fun set_android_style
(java_edit_text
: NativeEditText, activity
: NativeActivity)
57 java_edit_text.setBackgroundResource(R.color.display_background_color);
58 java_edit_text.setTextColor(
59 activity.getResources().getColor(R.color.display_formula_text_color));
60 java_edit_text.setTextSize(android.util.TypedValue.COMPLEX_UNIT_FRACTION, 120.0f);
61 java_edit_text.setCursorVisible(false);
62 java_edit_text.setGravity(android.view.Gravity.CENTER_VERTICAL | android.view.Gravity.END);