Keyboard styles
@@ -71,7 +71,7 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
 | 
				
			|||||||
        final int parametersCount = parameterNames.size();
 | 
					        final int parametersCount = parameterNames.size();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        LinearLayout row = makeRow();
 | 
					        LinearLayout row = makeRow();
 | 
				
			||||||
        addImageButton(row, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_white_24dp);
 | 
					        addImageButton(row, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_grey300_24dp);
 | 
				
			||||||
        addButton(row, 0, parametersCount > 0 ? parameterNames.get(0) : "x");
 | 
					        addButton(row, 0, parametersCount > 0 ? parameterNames.get(0) : "x");
 | 
				
			||||||
        addButton(row, 0, "7");
 | 
					        addButton(row, 0, "7");
 | 
				
			||||||
        addButton(row, 0, "8");
 | 
					        addButton(row, 0, "8");
 | 
				
			||||||
@@ -88,7 +88,7 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
 | 
				
			|||||||
        addButton(row, 0, "6");
 | 
					        addButton(row, 0, "6");
 | 
				
			||||||
        addOperationButton(row, R.id.cpp_kb_button_divide, "/").setText("%", up).setText("sqrt", down);
 | 
					        addOperationButton(row, R.id.cpp_kb_button_divide, "/").setText("%", up).setText("sqrt", down);
 | 
				
			||||||
        addOperationButton(row, R.id.cpp_kb_button_minus, "−");
 | 
					        addOperationButton(row, R.id.cpp_kb_button_minus, "−");
 | 
				
			||||||
        final View backspace = addImageButton(row, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_white_24dp);
 | 
					        final View backspace = addImageButton(row, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_grey300_24dp);
 | 
				
			||||||
        EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
					        EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        row = makeRow();
 | 
					        row = makeRow();
 | 
				
			||||||
@@ -98,8 +98,8 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
 | 
				
			|||||||
        addButton(row, 0, "2");
 | 
					        addButton(row, 0, "2");
 | 
				
			||||||
        addButton(row, 0, "3");
 | 
					        addButton(row, 0, "3");
 | 
				
			||||||
        addButton(row, 0, "0").setText("00", up).setText("000", down);
 | 
					        addButton(row, 0, "0").setText("00", up).setText("000", down);
 | 
				
			||||||
        addImageButton(row, R.id.cpp_kb_button_space, R.drawable.ic_space_bar_white_24dp);
 | 
					        addImageButton(row, R.id.cpp_kb_button_space, R.drawable.ic_space_bar_grey300_24dp);
 | 
				
			||||||
        addImageButton(row, R.id.cpp_kb_button_close, R.drawable.ic_done_white_24dp);
 | 
					        addImageButton(row, R.id.cpp_kb_button_close, R.drawable.ic_done_grey300_24dp);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private void makeViewPort() {
 | 
					    private void makeViewPort() {
 | 
				
			||||||
@@ -115,7 +115,7 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
 | 
				
			|||||||
        addButton(row, 0, "5");
 | 
					        addButton(row, 0, "5");
 | 
				
			||||||
        addButton(row, 0, "6");
 | 
					        addButton(row, 0, "6");
 | 
				
			||||||
        addOperationButton(row, R.id.cpp_kb_button_divide, "/").setText("%", up).setText("sqrt", down);
 | 
					        addOperationButton(row, R.id.cpp_kb_button_divide, "/").setText("%", up).setText("sqrt", down);
 | 
				
			||||||
        final View backspace = addImageButton(row, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_white_24dp);
 | 
					        final View backspace = addImageButton(row, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_grey300_24dp);
 | 
				
			||||||
        EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
					        EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        row = makeRow();
 | 
					        row = makeRow();
 | 
				
			||||||
@@ -123,14 +123,14 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
 | 
				
			|||||||
        addButton(row, 0, "2");
 | 
					        addButton(row, 0, "2");
 | 
				
			||||||
        addButton(row, 0, "3");
 | 
					        addButton(row, 0, "3");
 | 
				
			||||||
        addOperationButton(row, R.id.cpp_kb_button_plus, "+");
 | 
					        addOperationButton(row, R.id.cpp_kb_button_plus, "+");
 | 
				
			||||||
        addImageButton(row, R.id.cpp_kb_button_space, R.drawable.ic_space_bar_white_24dp);
 | 
					        addImageButton(row, R.id.cpp_kb_button_space, R.drawable.ic_space_bar_grey300_24dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        row = makeRow();
 | 
					        row = makeRow();
 | 
				
			||||||
        addButton(row, R.id.cpp_kb_button_brackets, "( )").setText("(", up).setText(")", down);
 | 
					        addButton(row, R.id.cpp_kb_button_brackets, "( )").setText("(", up).setText(")", down);
 | 
				
			||||||
        addButton(row, 0, "0").setText("00", up).setText("000", down);
 | 
					        addButton(row, 0, "0").setText("00", up).setText("000", down);
 | 
				
			||||||
        addButton(row, 0, ".").setText(",", up);
 | 
					        addButton(row, 0, ".").setText(",", up);
 | 
				
			||||||
        addOperationButton(row, R.id.cpp_kb_button_minus, "−");
 | 
					        addOperationButton(row, R.id.cpp_kb_button_minus, "−");
 | 
				
			||||||
        addImageButton(row, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_white_24dp);
 | 
					        addImageButton(row, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_grey300_24dp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        row = makeRow();
 | 
					        row = makeRow();
 | 
				
			||||||
        final int parametersCount = parameterNames.size();
 | 
					        final int parametersCount = parameterNames.size();
 | 
				
			||||||
@@ -138,7 +138,7 @@ public class FloatingCalculatorKeyboard extends BaseFloatingKeyboard {
 | 
				
			|||||||
        addButton(row, 0, parametersCount > 1 ? parameterNames.get(1) : "y");
 | 
					        addButton(row, 0, parametersCount > 1 ? parameterNames.get(1) : "y");
 | 
				
			||||||
        addButton(row, R.id.cpp_kb_button_functions, "f");
 | 
					        addButton(row, R.id.cpp_kb_button_functions, "f");
 | 
				
			||||||
        addButton(row, R.id.cpp_kb_button_constants, "π");
 | 
					        addButton(row, R.id.cpp_kb_button_constants, "π");
 | 
				
			||||||
        addImageButton(row, R.id.cpp_kb_button_close, R.drawable.ic_done_white_24dp);
 | 
					        addImageButton(row, R.id.cpp_kb_button_close, R.drawable.ic_done_grey300_24dp);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public int getRowsCount(boolean landscape) {
 | 
					    public int getRowsCount(boolean landscape) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,10 +10,12 @@ import android.support.annotation.Nullable;
 | 
				
			|||||||
import android.util.TypedValue;
 | 
					import android.util.TypedValue;
 | 
				
			||||||
import android.view.HapticFeedbackConstants;
 | 
					import android.view.HapticFeedbackConstants;
 | 
				
			||||||
import android.view.View;
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.ImageView;
 | 
				
			||||||
import org.solovyev.android.Views;
 | 
					import org.solovyev.android.Views;
 | 
				
			||||||
import org.solovyev.android.calculator.*;
 | 
					import org.solovyev.android.calculator.*;
 | 
				
			||||||
import org.solovyev.android.calculator.buttons.CppSpecialButton;
 | 
					import org.solovyev.android.calculator.buttons.CppSpecialButton;
 | 
				
			||||||
import org.solovyev.android.calculator.view.ScreenMetrics;
 | 
					import org.solovyev.android.calculator.view.ScreenMetrics;
 | 
				
			||||||
 | 
					import org.solovyev.android.views.Adjuster;
 | 
				
			||||||
import org.solovyev.android.views.dragbutton.DirectionDragButton;
 | 
					import org.solovyev.android.views.dragbutton.DirectionDragButton;
 | 
				
			||||||
import org.solovyev.android.views.dragbutton.DragDirection;
 | 
					import org.solovyev.android.views.dragbutton.DragDirection;
 | 
				
			||||||
import org.solovyev.android.views.dragbutton.SimpleDragListener;
 | 
					import org.solovyev.android.views.dragbutton.SimpleDragListener;
 | 
				
			||||||
@@ -28,6 +30,9 @@ import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple_mobi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, SimpleDragListener.DragProcessor, View.OnClickListener {
 | 
					public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, SimpleDragListener.DragProcessor, View.OnClickListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected static final float TEXT_SCALE = 0.6f;
 | 
				
			||||||
 | 
					    protected static final float IMAGE_SCALE = 0.6f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @NonNull
 | 
					    @NonNull
 | 
				
			||||||
    protected final SimpleDragListener listener;
 | 
					    protected final SimpleDragListener listener;
 | 
				
			||||||
    @Inject
 | 
					    @Inject
 | 
				
			||||||
@@ -59,6 +64,18 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
 | 
				
			|||||||
        textSize = layout.optimized ? 0 : calculateTextSize();
 | 
					        textSize = layout.optimized ? 0 : calculateTextSize();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected final void prepareButton(@Nullable ImageView button) {
 | 
				
			||||||
 | 
					        prepareButton(button, IMAGE_SCALE);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected final void prepareButton(@Nullable ImageView button, float scale) {
 | 
				
			||||||
 | 
					        if (button == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        prepareButton((View) button);
 | 
				
			||||||
 | 
					        Adjuster.adjustImage(button, scale);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected final void prepareButton(@Nullable View button) {
 | 
					    protected final void prepareButton(@Nullable View button) {
 | 
				
			||||||
        if (button == null) {
 | 
					        if (button == null) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
@@ -76,6 +93,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
 | 
				
			|||||||
        if (textSize > 0) {
 | 
					        if (textSize > 0) {
 | 
				
			||||||
            button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
 | 
					            button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        Adjuster.adjustText(button, TEXT_SCALE);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected final void hideText(@Nullable DirectionDragButton button, @Nonnull DragDirection... directions) {
 | 
					    protected final void hideText(@Nullable DirectionDragButton button, @Nonnull DragDirection... directions) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@ import android.widget.ImageButton;
 | 
				
			|||||||
import butterknife.Bind;
 | 
					import butterknife.Bind;
 | 
				
			||||||
import butterknife.ButterKnife;
 | 
					import butterknife.ButterKnife;
 | 
				
			||||||
import jscl.NumeralBase;
 | 
					import jscl.NumeralBase;
 | 
				
			||||||
 | 
					import org.solovyev.android.Check;
 | 
				
			||||||
import org.solovyev.android.calculator.*;
 | 
					import org.solovyev.android.calculator.*;
 | 
				
			||||||
import org.solovyev.android.calculator.buttons.CppSpecialButton;
 | 
					import org.solovyev.android.calculator.buttons.CppSpecialButton;
 | 
				
			||||||
import org.solovyev.android.calculator.view.EditorLongClickEraser;
 | 
					import org.solovyev.android.calculator.view.EditorLongClickEraser;
 | 
				
			||||||
@@ -62,8 +63,10 @@ public class PartialKeyboardUi extends BaseKeyboardUi {
 | 
				
			|||||||
        prepareButton(leftButton);
 | 
					        prepareButton(leftButton);
 | 
				
			||||||
        prepareButton(equalsButton);
 | 
					        prepareButton(equalsButton);
 | 
				
			||||||
        prepareButton(clearButton);
 | 
					        prepareButton(clearButton);
 | 
				
			||||||
        prepareButton(eraseButton);
 | 
					 | 
				
			||||||
        if (eraseButton != null) {
 | 
					        if (eraseButton != null) {
 | 
				
			||||||
 | 
					            Check.isTrue(IMAGE_SCALE == 0.6f);
 | 
				
			||||||
 | 
					            // backspace button is too big, scale it more
 | 
				
			||||||
 | 
					            prepareButton(eraseButton, 0.5f);
 | 
				
			||||||
            EditorLongClickEraser.attachTo(eraseButton);
 | 
					            EditorLongClickEraser.attachTo(eraseButton);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (isSimpleLayout()) {
 | 
					        if (isSimpleLayout()) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,17 +56,17 @@ public class GreekFloatingKeyboard extends BaseFloatingKeyboard implements View.
 | 
				
			|||||||
    private void makeLastColumnLand(@NonNull LinearLayout rowView, int row) {
 | 
					    private void makeLastColumnLand(@NonNull LinearLayout rowView, int row) {
 | 
				
			||||||
        switch (row) {
 | 
					        switch (row) {
 | 
				
			||||||
            case 0:
 | 
					            case 0:
 | 
				
			||||||
                final View backspace = addImageButton(rowView, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_white_24dp);
 | 
					                final View backspace = addImageButton(rowView, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_grey300_24dp);
 | 
				
			||||||
                EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
					                EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 1:
 | 
					            case 1:
 | 
				
			||||||
                addButton(rowView, R.id.cpp_kb_button_change_case, "↑");
 | 
					                addButton(rowView, R.id.cpp_kb_button_change_case, "↑");
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 2:
 | 
					            case 2:
 | 
				
			||||||
                addImageButton(rowView, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_white_24dp);
 | 
					                addImageButton(rowView, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_grey300_24dp);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 3:
 | 
					            case 3:
 | 
				
			||||||
                addImageButton(rowView, R.id.cpp_kb_button_close, R.drawable.ic_done_white_24dp);
 | 
					                addImageButton(rowView, R.id.cpp_kb_button_close, R.drawable.ic_done_grey300_24dp);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                addButton(rowView, View.NO_ID, "");
 | 
					                addButton(rowView, View.NO_ID, "");
 | 
				
			||||||
@@ -80,17 +80,17 @@ public class GreekFloatingKeyboard extends BaseFloatingKeyboard implements View.
 | 
				
			|||||||
                addButton(rowView, R.id.cpp_kb_button_clear, "C");
 | 
					                addButton(rowView, R.id.cpp_kb_button_clear, "C");
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 1:
 | 
					            case 1:
 | 
				
			||||||
                final View backspace = addImageButton(rowView, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_white_24dp);
 | 
					                final View backspace = addImageButton(rowView, R.id.cpp_kb_button_backspace, R.drawable.ic_backspace_grey300_24dp);
 | 
				
			||||||
                EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
					                EditTextLongClickEraser.attachTo(backspace, user.getEditor());
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 2:
 | 
					            case 2:
 | 
				
			||||||
                addButton(rowView, R.id.cpp_kb_button_change_case, "↑");
 | 
					                addButton(rowView, R.id.cpp_kb_button_change_case, "↑");
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 3:
 | 
					            case 3:
 | 
				
			||||||
                addImageButton(rowView, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_white_24dp);
 | 
					                addImageButton(rowView, R.id.cpp_kb_button_keyboard, R.drawable.ic_keyboard_grey300_24dp);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 4:
 | 
					            case 4:
 | 
				
			||||||
                addImageButton(rowView, R.id.cpp_kb_button_close, R.drawable.ic_done_white_24dp);
 | 
					                addImageButton(rowView, R.id.cpp_kb_button_close, R.drawable.ic_done_grey300_24dp);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                addButton(rowView, View.NO_ID, "");
 | 
					                addButton(rowView, View.NO_ID, "");
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										109
									
								
								app/src/main/java/org/solovyev/android/views/Adjuster.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,109 @@
 | 
				
			|||||||
 | 
					package org.solovyev.android.views;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.drawable.Drawable;
 | 
				
			||||||
 | 
					import android.support.annotation.NonNull;
 | 
				
			||||||
 | 
					import android.support.annotation.Nullable;
 | 
				
			||||||
 | 
					import android.util.TypedValue;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.view.ViewTreeObserver;
 | 
				
			||||||
 | 
					import android.widget.ImageView;
 | 
				
			||||||
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static android.graphics.Matrix.MSCALE_Y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Adjuster {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final float[] MATRIX = new float[9];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void adjustText(@NonNull final TextView view, final float percentage) {
 | 
				
			||||||
 | 
					        ViewTreeObserver treeObserver = getTreeObserver(view);
 | 
				
			||||||
 | 
					        if (treeObserver == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        treeObserver.addOnPreDrawListener(new TextViewAdjuster(view, percentage));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Nullable
 | 
				
			||||||
 | 
					    private static ViewTreeObserver getTreeObserver(@NonNull View view) {
 | 
				
			||||||
 | 
					        final ViewTreeObserver treeObserver = view.getViewTreeObserver();
 | 
				
			||||||
 | 
					        if (treeObserver == null) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (!treeObserver.isAlive()) {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return treeObserver;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void adjustImage(@NonNull final ImageView view, final float percentage) {
 | 
				
			||||||
 | 
					        ViewTreeObserver treeObserver = getTreeObserver(view);
 | 
				
			||||||
 | 
					        if (treeObserver == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        treeObserver.addOnPreDrawListener(new ImageViewAdjuster(view, percentage));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static class TextViewAdjuster implements ViewTreeObserver.OnPreDrawListener {
 | 
				
			||||||
 | 
					        @NonNull
 | 
				
			||||||
 | 
					        private final TextView view;
 | 
				
			||||||
 | 
					        private final float percentage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public TextViewAdjuster(@NonNull TextView view, float percentage) {
 | 
				
			||||||
 | 
					            this.view = view;
 | 
				
			||||||
 | 
					            this.percentage = percentage;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean onPreDraw() {
 | 
				
			||||||
 | 
					            // assume that the view properties are constant
 | 
				
			||||||
 | 
					            final ViewTreeObserver treeObserver = getTreeObserver(view);
 | 
				
			||||||
 | 
					            if (treeObserver != null) {
 | 
				
			||||||
 | 
					                treeObserver.removeOnPreDrawListener(this);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            final int height = view.getHeight();
 | 
				
			||||||
 | 
					            final float oldTextSize = Math.round(view.getTextSize());
 | 
				
			||||||
 | 
					            final float newTextSize = Math.round(height * percentage);
 | 
				
			||||||
 | 
					            if (oldTextSize == newTextSize) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            view.setTextSize(TypedValue.COMPLEX_UNIT_PX, newTextSize);
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static class ImageViewAdjuster implements ViewTreeObserver.OnPreDrawListener {
 | 
				
			||||||
 | 
					        @NonNull
 | 
				
			||||||
 | 
					        private final ImageView view;
 | 
				
			||||||
 | 
					        private final float percentage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public ImageViewAdjuster(@NonNull ImageView view, float percentage) {
 | 
				
			||||||
 | 
					            this.view = view;
 | 
				
			||||||
 | 
					            this.percentage = percentage;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean onPreDraw() {
 | 
				
			||||||
 | 
					            // assume that the view properties are constant
 | 
				
			||||||
 | 
					            final ViewTreeObserver treeObserver = getTreeObserver(view);
 | 
				
			||||||
 | 
					            if (treeObserver != null) {
 | 
				
			||||||
 | 
					                treeObserver.removeOnPreDrawListener(this);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            final Drawable d = view.getDrawable();
 | 
				
			||||||
 | 
					            if (d == null) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            final int height = view.getHeight();
 | 
				
			||||||
 | 
					            view.getImageMatrix().getValues(MATRIX);
 | 
				
			||||||
 | 
					            final int oldImageHeight = Math.round(d.getIntrinsicHeight() * MATRIX[MSCALE_Y]);
 | 
				
			||||||
 | 
					            final int newImageHeight = Math.round(height * percentage);
 | 
				
			||||||
 | 
					            if (oldImageHeight == newImageHeight) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            final int newPaddings = Math.max(0, height - newImageHeight) / 2;
 | 
				
			||||||
 | 
					            view.setPadding(0, newPaddings, 0, newPaddings);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
		 Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 525 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_backspace_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 543 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_close_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 221 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_content_copy_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 266 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_content_paste_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 340 B  | 
| 
		 Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_file_download_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 163 B  | 
| 
		 Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 343 B  | 
| 
		 Before Width: | Height: | Size: 493 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_settings_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 843 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_share_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 698 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-hdpi/ic_space_bar_grey300_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 188 B  | 
| 
		 Before Width: | Height: | Size: 188 B After Width: | Height: | Size: 114 B  | 
| 
		 Before Width: | Height: | Size: 424 B  | 
| 
		 Before Width: | Height: | Size: 1.1 KiB  | 
| 
		 Before Width: | Height: | Size: 593 B  | 
| 
		 Before Width: | Height: | Size: 601 B  | 
| 
		 Before Width: | Height: | Size: 896 B  | 
| 
		 After Width: | Height: | Size: 264 B  | 
| 
		 After Width: | Height: | Size: 187 B  | 
| 
		 After Width: | Height: | Size: 327 B  | 
| 
		 After Width: | Height: | Size: 521 B  | 
| 
		 After Width: | Height: | Size: 722 B  | 
| 
		 Before Width: | Height: | Size: 371 B After Width: | Height: | Size: 371 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_backspace_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 392 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_close_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 175 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_content_copy_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 188 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_content_paste_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 244 B  | 
| 
		 Before Width: | Height: | Size: 207 B After Width: | Height: | Size: 207 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_file_download_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 116 B  | 
| 
		 Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B  | 
| 
		 Before Width: | Height: | Size: 385 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_settings_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 562 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_share_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 496 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-mdpi/ic_space_bar_grey300_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 147 B  | 
| 
		 Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 86 B  | 
| 
		 Before Width: | Height: | Size: 361 B  | 
| 
		 Before Width: | Height: | Size: 668 B  | 
| 
		 Before Width: | Height: | Size: 511 B  | 
| 
		 Before Width: | Height: | Size: 532 B  | 
| 
		 Before Width: | Height: | Size: 610 B  | 
| 
		 Before Width: | Height: | Size: 157 B  | 
| 
		 Before Width: | Height: | Size: 113 B  | 
| 
		 Before Width: | Height: | Size: 285 B  | 
| 
		 Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 640 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_backspace_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 724 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_close_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 257 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_content_copy_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 329 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_content_paste_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 460 B  | 
| 
		 Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 323 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_file_download_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 157 B  | 
| 
		 Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B  | 
| 
		 Before Width: | Height: | Size: 652 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_settings_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.0 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_share_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 938 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xhdpi/ic_space_bar_grey300_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 176 B  | 
| 
		 Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 95 B  | 
| 
		 Before Width: | Height: | Size: 357 B  | 
| 
		 Before Width: | Height: | Size: 1.5 KiB  | 
| 
		 Before Width: | Height: | Size: 544 B  | 
| 
		 Before Width: | Height: | Size: 461 B  | 
| 
		 Before Width: | Height: | Size: 1.1 KiB  | 
| 
		 Before Width: | Height: | Size: 838 B After Width: | Height: | Size: 838 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_backspace_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1023 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_close_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 347 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_content_copy_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 524 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_content_paste_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 703 B  | 
| 
		 Before Width: | Height: | Size: 455 B After Width: | Height: | Size: 455 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_file_download_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 197 B  | 
| 
		 Before Width: | Height: | Size: 389 B After Width: | Height: | Size: 389 B  | 
| 
		 Before Width: | Height: | Size: 940 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_settings_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.6 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_share_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxhdpi/ic_space_bar_grey300_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 186 B  | 
| 
		 Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 99 B  | 
| 
		 Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxxhdpi/ic_backspace_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.4 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxxhdpi/ic_close_white_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 436 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxxhdpi/ic_content_copy_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 727 B  | 
| 
		 After Width: | Height: | Size: 994 B  | 
| 
		 Before Width: | Height: | Size: 565 B After Width: | Height: | Size: 565 B  | 
| 
		 After Width: | Height: | Size: 233 B  | 
| 
		 Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 471 B  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxxhdpi/ic_settings_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 2.2 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxxhdpi/ic_share_white_48dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								app/src/main/res/drawable-xxxhdpi/ic_space_bar_grey300_24dp.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 198 B  | 
| 
		 Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 96 B  | 
@@ -29,7 +29,6 @@
 | 
				
			|||||||
    a:id="@id/cpp_button_0"
 | 
					    a:id="@id/cpp_button_0"
 | 
				
			||||||
    style="?attr/cpp_button_style_digit"
 | 
					    style="?attr/cpp_button_style_digit"
 | 
				
			||||||
    a:text="0"
 | 
					    a:text="0"
 | 
				
			||||||
    c:directionTextScale="0.5"
 | 
					 | 
				
			||||||
    c:textDown="000"
 | 
					    c:textDown="000"
 | 
				
			||||||
    c:textUp="00"
 | 
					    c:textUp="00"
 | 
				
			||||||
    tools:ignore="HardcodedText" />
 | 
					    tools:ignore="HardcodedText" />
 | 
				
			||||||
@@ -29,7 +29,6 @@
 | 
				
			|||||||
    a:id="@id/cpp_button_6"
 | 
					    a:id="@id/cpp_button_6"
 | 
				
			||||||
    style="?attr/cpp_button_style_digit"
 | 
					    style="?attr/cpp_button_style_digit"
 | 
				
			||||||
    a:text="6"
 | 
					    a:text="6"
 | 
				
			||||||
    c:directionTextScale="0.33;0.30;0.33;0.33"
 | 
					 | 
				
			||||||
    c:textDown="rad"
 | 
					    c:textDown="rad"
 | 
				
			||||||
    c:textLeft="F"
 | 
					    c:textLeft="F"
 | 
				
			||||||
    c:textUp="deg"
 | 
					    c:textUp="deg"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,6 @@
 | 
				
			|||||||
    a:id="@id/cpp_button_7"
 | 
					    a:id="@id/cpp_button_7"
 | 
				
			||||||
    style="?attr/cpp_button_style_digit"
 | 
					    style="?attr/cpp_button_style_digit"
 | 
				
			||||||
    a:text="7"
 | 
					    a:text="7"
 | 
				
			||||||
    c:directionTextScale="0.5;0.5;0.5;0.33"
 | 
					 | 
				
			||||||
    c:textDown="!"
 | 
					    c:textDown="!"
 | 
				
			||||||
    c:textLeft="0b:"
 | 
					    c:textLeft="0b:"
 | 
				
			||||||
    c:textUp="i"
 | 
					    c:textUp="i"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,6 @@
 | 
				
			|||||||
    a:id="@id/cpp_button_8"
 | 
					    a:id="@id/cpp_button_8"
 | 
				
			||||||
    style="?attr/cpp_button_style_digit"
 | 
					    style="?attr/cpp_button_style_digit"
 | 
				
			||||||
    a:text="8"
 | 
					    a:text="8"
 | 
				
			||||||
    c:directionTextScale="0.5;0.5;0.5;0.33"
 | 
					 | 
				
			||||||
    c:textDown="lg"
 | 
					    c:textDown="lg"
 | 
				
			||||||
    c:textLeft="0d:"
 | 
					    c:textLeft="0d:"
 | 
				
			||||||
    c:textUp="ln"
 | 
					    c:textUp="ln"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,6 @@
 | 
				
			|||||||
    a:id="@id/cpp_button_9"
 | 
					    a:id="@id/cpp_button_9"
 | 
				
			||||||
    style="?attr/cpp_button_style_digit"
 | 
					    style="?attr/cpp_button_style_digit"
 | 
				
			||||||
    a:text="9"
 | 
					    a:text="9"
 | 
				
			||||||
    c:directionTextScale="0.5;0.5;0.5;0.33"
 | 
					 | 
				
			||||||
    c:textDown="e"
 | 
					    c:textDown="e"
 | 
				
			||||||
    c:textLeft="0x:"
 | 
					    c:textLeft="0x:"
 | 
				
			||||||
    c:textUp="π"
 | 
					    c:textUp="π"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,4 +26,4 @@
 | 
				
			|||||||
    xmlns:a="http://schemas.android.com/apk/res/android"
 | 
					    xmlns:a="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
    a:id="@id/cpp_button_copy"
 | 
					    a:id="@id/cpp_button_copy"
 | 
				
			||||||
    style="?attr/cpp_button_style_control_image"
 | 
					    style="?attr/cpp_button_style_control_image"
 | 
				
			||||||
    a:src="@drawable/kb_copy" />
 | 
					    a:src="@drawable/ic_content_copy_white_48dp" />
 | 
				
			||||||
@@ -29,7 +29,6 @@
 | 
				
			|||||||
    a:id="@id/cpp_button_division"
 | 
					    a:id="@id/cpp_button_division"
 | 
				
			||||||
    style="?attr/cpp_button_style_operation"
 | 
					    style="?attr/cpp_button_style_operation"
 | 
				
			||||||
    a:text="/"
 | 
					    a:text="/"
 | 
				
			||||||
    c:directionTextScale="0.5"
 | 
					 | 
				
			||||||
    c:textDown="√"
 | 
					    c:textDown="√"
 | 
				
			||||||
    c:textUp="%"
 | 
					    c:textUp="%"
 | 
				
			||||||
    tools:ignore="HardcodedText" />
 | 
					    tools:ignore="HardcodedText" />
 | 
				
			||||||