changes
This commit is contained in:
@@ -22,6 +22,7 @@ import android.view.*;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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);
|
||||
if (angleUnitsButton != null) {
|
||||
final OnDragListener varsOnDragListener = new OnDragListenerVibrator(newOnDragListener(new AngleUnitsChanger(), dragPreferences), vibrator, preferences);
|
||||
angleUnitsButton.setOnDragListener(varsOnDragListener);
|
||||
final OnDragListener onDragListener = new OnDragListenerVibrator(newOnDragListener(new AngleUnitsChanger(), dragPreferences), vibrator, preferences);
|
||||
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);
|
||||
@@ -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 {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user