changes
This commit is contained in:
parent
10d55263d2
commit
174b3ca593
@ -52,10 +52,12 @@
|
|||||||
a:layout_height="fill_parent"
|
a:layout_height="fill_parent"
|
||||||
a:layout_weight="4"/>
|
a:layout_weight="4"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/clearButton"
|
a:id="@+id/clearButton"
|
||||||
|
calc:textUp="dec"
|
||||||
a:text="@string/c_clear"
|
a:text="@string/c_clear"
|
||||||
|
calc:textDown="bin"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
a:onClick="clearButtonClickHandler"
|
a:onClick="clearButtonClickHandler"
|
||||||
|
@ -46,10 +46,12 @@
|
|||||||
a:layout_height="fill_parent"
|
a:layout_height="fill_parent"
|
||||||
a:layout_weight="4"/>
|
a:layout_weight="4"/>
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/clearButton"
|
a:id="@+id/clearButton"
|
||||||
|
calc:textUp="dec"
|
||||||
a:text="@string/c_clear"
|
a:text="@string/c_clear"
|
||||||
|
calc:textDown="bin"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
a:onClick="clearButtonClickHandler"
|
a:onClick="clearButtonClickHandler"
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
<include layout="@layout/calc_eight_digit_button"/>
|
<include layout="@layout/calc_eight_digit_button"/>
|
||||||
<include layout="@layout/calc_nine_digit_button"/>
|
<include layout="@layout/calc_nine_digit_button"/>
|
||||||
<include layout="@layout/calc_multiplication_button"/>
|
<include layout="@layout/calc_multiplication_button"/>
|
||||||
<include layout="@layout/calc_clear_button"/>
|
<include layout="@layout/calc_erase_button"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -50,7 +50,7 @@
|
|||||||
<include layout="@layout/calc_five_digit_button"/>
|
<include layout="@layout/calc_five_digit_button"/>
|
||||||
<include layout="@layout/calc_six_digit_button"/>
|
<include layout="@layout/calc_six_digit_button"/>
|
||||||
<include layout="@layout/calc_division_button"/>
|
<include layout="@layout/calc_division_button"/>
|
||||||
<include layout="@layout/calc_erase_button"/>
|
<include layout="@layout/calc_clear_button"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<include layout="@layout/calc_two_digit_button"/>
|
<include layout="@layout/calc_two_digit_button"/>
|
||||||
<include layout="@layout/calc_three_digit_button"/>
|
<include layout="@layout/calc_three_digit_button"/>
|
||||||
<include layout="@layout/calc_multiplication_button"/>
|
<include layout="@layout/calc_multiplication_button"/>
|
||||||
<include layout="@layout/calc_clear_button"/>
|
<include layout="@layout/calc_erase_button"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -44,7 +44,7 @@
|
|||||||
<include layout="@layout/calc_five_digit_button"/>
|
<include layout="@layout/calc_five_digit_button"/>
|
||||||
<include layout="@layout/calc_six_digit_button"/>
|
<include layout="@layout/calc_six_digit_button"/>
|
||||||
<include layout="@layout/calc_division_button"/>
|
<include layout="@layout/calc_division_button"/>
|
||||||
<include layout="@layout/calc_erase_button"/>
|
<include layout="@layout/calc_clear_button"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
~ or visit http://se.solovyev.org
|
~ or visit http://se.solovyev.org
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<org.solovyev.android.view.widgets.ColorButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.NumeralBasesButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
a:id="@+id/clearButton"
|
a:id="@+id/clearButton"
|
||||||
|
calc:textUp="dec"
|
||||||
a:text="@string/c_clear"
|
a:text="@string/c_clear"
|
||||||
|
calc:textDown="bin"
|
||||||
a:textStyle="bold"
|
a:textStyle="bold"
|
||||||
style="?controlImageButtonStyle"
|
style="?controlImageButtonStyle"
|
||||||
a:onClick="clearButtonClickHandler"/>
|
a:onClick="clearButtonClickHandler"/>
|
@ -9,7 +9,8 @@
|
|||||||
<org.solovyev.android.view.widgets.AngleUnitsButton xmlns:a="http://schemas.android.com/apk/res/android"
|
<org.solovyev.android.view.widgets.AngleUnitsButton xmlns:a="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
xmlns:calc="http://schemas.android.com/apk/res/org.solovyev.android.calculator"
|
||||||
calc:textUp="deg"
|
calc:textUp="deg"
|
||||||
a:id="@+id/sixDigitButton" a:text="6"
|
a:id="@+id/sixDigitButton"
|
||||||
|
a:text="6"
|
||||||
calc:textDown="rad"
|
calc:textDown="rad"
|
||||||
style="?digitButtonStyle"
|
style="?digitButtonStyle"
|
||||||
a:onClick="digitButtonClickHandler"/>
|
a:onClick="digitButtonClickHandler"/>
|
@ -22,6 +22,7 @@ import android.view.*;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import jscl.AngleUnit;
|
import jscl.AngleUnit;
|
||||||
|
import jscl.NumeralBase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
import org.solovyev.android.calculator.math.MathType;
|
||||||
@ -114,8 +115,14 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
|
|
||||||
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) findViewById(R.id.sixDigitButton);
|
final AngleUnitsButton angleUnitsButton = (AngleUnitsButton) findViewById(R.id.sixDigitButton);
|
||||||
if (angleUnitsButton != null) {
|
if (angleUnitsButton != null) {
|
||||||
final OnDragListener varsOnDragListener = new OnDragListenerVibrator(newOnDragListener(new AngleUnitsChanger(), dragPreferences), vibrator, preferences);
|
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new AngleUnitsChanger(), dragPreferences), vibrator, preferences);
|
||||||
angleUnitsButton.setOnDragListener(varsOnDragListener);
|
angleUnitsButton.setOnDragListener(onDragListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
final NumeralBasesButton numeralBasesButton = (NumeralBasesButton) findViewById(R.id.clearButton);
|
||||||
|
if (numeralBasesButton != null) {
|
||||||
|
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new NumeralBasesChanger(), dragPreferences), vibrator, preferences);
|
||||||
|
numeralBasesButton.setOnDragListener(onDragListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
final DragButton varsButton = (DragButton) findViewById(R.id.varsButton);
|
final DragButton varsButton = (DragButton) findViewById(R.id.varsButton);
|
||||||
@ -161,6 +168,39 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class NumeralBasesChanger implements SimpleOnDragListener.DragProcessor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean processDragEvent(@NotNull DragDirection dragDirection,
|
||||||
|
@NotNull DragButton dragButton,
|
||||||
|
@NotNull Point2d startPoint2d,
|
||||||
|
@NotNull MotionEvent motionEvent) {
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
|
if ( dragButton instanceof NumeralBasesButton ) {
|
||||||
|
final String directionText = ((NumeralBasesButton) dragButton).getText(dragDirection);
|
||||||
|
if ( directionText != null ) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
final NumeralBase numeralBase = NumeralBase.valueOf(directionText);
|
||||||
|
|
||||||
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorActivity.this);
|
||||||
|
final SharedPreferences.Editor editor = preferences.edit();
|
||||||
|
editor.putString(CalculatorEngine.NUMERAL_BASES_P_KEY, numeralBase.name());
|
||||||
|
editor.commit();
|
||||||
|
|
||||||
|
result = true;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.d(this.getClass().getName(), "Unsupported numeral base: " + directionText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class VarsDragProcessor implements SimpleOnDragListener.DragProcessor {
|
private class VarsDragProcessor implements SimpleOnDragListener.DragProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||||
|
* For more information, please, contact se.solovyev@gmail.com
|
||||||
|
* or visit http://se.solovyev.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.solovyev.android.view.widgets;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.text.TextPaint;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.solovyev.android.calculator.R;
|
||||||
|
import org.solovyev.android.calculator.model.CalculatorEngine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/8/11
|
||||||
|
* Time: 2:22 AM
|
||||||
|
*/
|
||||||
|
public class NumeralBasesButton extends DirectionDragButton {
|
||||||
|
|
||||||
|
public NumeralBasesButton(Context context, @NotNull AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initDirectionTextPaint(@NotNull Paint basePaint,
|
||||||
|
@NotNull DirectionTextData directionTextData,
|
||||||
|
@NotNull Resources resources) {
|
||||||
|
super.initDirectionTextPaint(basePaint, directionTextData, resources);
|
||||||
|
|
||||||
|
final TextPaint directionTextPaint = directionTextData.getPaint();
|
||||||
|
if (CalculatorEngine.instance.getEngine().getNumeralBase().name().equals(directionTextData.getText())) {
|
||||||
|
directionTextPaint.setColor(resources.getColor(R.color.selected_angle_unit_text_color));
|
||||||
|
} else {
|
||||||
|
directionTextPaint.setColor(resources.getColor(R.color.default_text_color));
|
||||||
|
directionTextPaint.setAlpha(getDefaultDirectionTextAlpha());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user