Buttons class moved

This commit is contained in:
serso 2016-02-05 16:43:13 +01:00
parent f50f8b599b
commit 9d9da8a608
3 changed files with 40 additions and 26 deletions

View File

@ -35,6 +35,7 @@ import android.view.View;
import android.widget.TextView;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.buttons.CppButtons;
import org.solovyev.android.calculator.history.History;
import org.solovyev.android.calculator.history.HistoryDragProcessor;
import org.solovyev.android.calculator.view.*;
@ -215,7 +216,7 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
angleUnitsButton = getButton(views, R.id.cpp_button_6);
if (angleUnitsButton != null) {
angleUnitsButton.setOnDragListener(newDragListener(new CalculatorButtons.AngleUnitsChanger(activity, keyboard, preferredPreferences), activity));
angleUnitsButton.setOnDragListener(newDragListener(new CppButtons.AngleUnitsChanger(activity, keyboard, preferredPreferences), activity));
}
final View eraseButton = getButton(views, R.id.cpp_button_erase);
@ -225,22 +226,22 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
clearButton = getButton(views, R.id.cpp_button_clear);
if (clearButton != null) {
clearButton.setOnDragListener(newDragListener(new CalculatorButtons.NumeralBasesChanger(activity, preferredPreferences), activity));
clearButton.setOnDragListener(newDragListener(new CppButtons.NumeralBasesChanger(activity, preferredPreferences), activity));
}
final DragButton varsButton = getButton(views, R.id.cpp_button_vars);
if (varsButton != null) {
varsButton.setOnDragListener(newDragListener(new CalculatorButtons.VarsDragProcessor(activity), activity));
varsButton.setOnDragListener(newDragListener(new CppButtons.VarsDragProcessor(activity), activity));
}
final DragButton functionsButton = getButton(views, R.id.cpp_button_functions);
if (functionsButton != null) {
functionsButton.setOnDragListener(newDragListener(new CalculatorButtons.FunctionsDragProcessor(activity), activity));
functionsButton.setOnDragListener(newDragListener(new CppButtons.FunctionsDragProcessor(activity), activity));
}
final DragButton roundBracketsButton = getButton(views, R.id.cpp_button_round_brackets);
if (roundBracketsButton != null) {
roundBracketsButton.setOnDragListener(newDragListener(new CalculatorButtons.RoundBracketsDragProcessor(keyboard), activity));
roundBracketsButton.setOnDragListener(newDragListener(new CppButtons.RoundBracketsDragProcessor(keyboard), activity));
}
if (layout == simple || layout == simple_mobile) {
@ -263,9 +264,9 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
toggleButtonDirectionText(views, R.id.cpp_button_plus, false, DragDirection.down, DragDirection.up);
}
CalculatorButtons.fixButtonsTextSize(theme, layout, root);
CalculatorButtons.toggleEqualsButton(preferences, activity);
CalculatorButtons.initMultiplicationButton(root);
CppButtons.fixButtonsTextSize(theme, layout, root);
CppButtons.toggleEqualsButton(preferences, activity);
CppButtons.initMultiplicationButton(root);
NumeralBaseButtons.toggleNumericDigits(activity, preferences);
new ButtonOnClickListener(keyboard).attachToViews(views);

View File

@ -29,6 +29,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import org.solovyev.android.calculator.buttons.CppButtons;
import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.NumeralBaseButtons.toggleNumericDigits;
@ -114,11 +116,11 @@ public class CalculatorKeyboardFragment extends Fragment implements SharedPrefer
}
if (showEqualsButton.isSameKey(key)) {
CalculatorButtons.toggleEqualsButton(preferences, this.getActivity());
CppButtons.toggleEqualsButton(preferences, this.getActivity());
}
if (multiplicationSign.isSameKey(key)) {
CalculatorButtons.initMultiplicationButton(getView());
CppButtons.initMultiplicationButton(getView());
}
}
}

View File

@ -20,7 +20,7 @@
* Site: http://se.solovyev.org
*/
package org.solovyev.android.calculator;
package org.solovyev.android.calculator.buttons;
import android.app.Activity;
import android.content.Context;
@ -33,9 +33,17 @@ import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import jscl.AngleUnit;
import jscl.NumeralBase;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.CalculatorEventType;
import org.solovyev.android.calculator.DigitButtonDragProcessor;
import org.solovyev.android.calculator.Engine;
import org.solovyev.android.calculator.Keyboard;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.PreferredPreferences;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.view.AngleUnitsButton;
import org.solovyev.android.calculator.view.NumeralBasesButton;
import org.solovyev.android.calculator.view.ScreenMetrics;
@ -46,9 +54,12 @@ import org.solovyev.android.views.dragbutton.SimpleDragListener;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class CalculatorButtons {
import jscl.AngleUnit;
import jscl.NumeralBase;
private CalculatorButtons() {
public final class CppButtons {
private CppButtons() {
}
@ -73,7 +84,7 @@ public final class CalculatorButtons {
}
}
static void initMultiplicationButton(@Nonnull View root) {
public static void initMultiplicationButton(@Nonnull View root) {
final View multiplicationButton = root.findViewById(R.id.cpp_button_multiplication);
if (multiplicationButton instanceof Button) {
((Button) multiplicationButton).setText(Locator.getInstance().getEngine().getMultiplicationSign());
@ -103,14 +114,14 @@ public final class CalculatorButtons {
}
}
static class RoundBracketsDragProcessor implements SimpleDragListener.DragProcessor {
public static class RoundBracketsDragProcessor implements SimpleDragListener.DragProcessor {
@Nonnull
private final Keyboard keyboard;
@Nonnull
private final DigitButtonDragProcessor upDownProcessor;
RoundBracketsDragProcessor(@Nonnull Keyboard keyboard) {
public RoundBracketsDragProcessor(@Nonnull Keyboard keyboard) {
this.keyboard = keyboard;
this.upDownProcessor = new DigitButtonDragProcessor(keyboard);
}
@ -126,12 +137,12 @@ public final class CalculatorButtons {
}
}
static class VarsDragProcessor implements SimpleDragListener.DragProcessor {
public static class VarsDragProcessor implements SimpleDragListener.DragProcessor {
@Nonnull
private Context context;
VarsDragProcessor(@Nonnull Context context) {
public VarsDragProcessor(@Nonnull Context context) {
this.context = context;
}
@ -149,7 +160,7 @@ public final class CalculatorButtons {
}
}
static class AngleUnitsChanger implements SimpleDragListener.DragProcessor {
public static class AngleUnitsChanger implements SimpleDragListener.DragProcessor {
@Nonnull
private final DigitButtonDragProcessor processor;
@ -159,7 +170,7 @@ public final class CalculatorButtons {
@Nonnull
private final PreferredPreferences preferredPreferences;
AngleUnitsChanger(@Nonnull Context context, @Nonnull Keyboard keyboard, @Nonnull PreferredPreferences preferredPreferences) {
public AngleUnitsChanger(@Nonnull Context context, @Nonnull Keyboard keyboard, @Nonnull PreferredPreferences preferredPreferences) {
this.context = context;
this.preferredPreferences = preferredPreferences;
this.processor = new DigitButtonDragProcessor(keyboard);
@ -198,14 +209,14 @@ public final class CalculatorButtons {
}
}
static class NumeralBasesChanger implements SimpleDragListener.DragProcessor {
public static class NumeralBasesChanger implements SimpleDragListener.DragProcessor {
@Nonnull
private final Context context;
@Nonnull
private final PreferredPreferences preferredPreferences;
NumeralBasesChanger(@Nonnull Context context, @Nonnull PreferredPreferences preferredPreferences) {
public NumeralBasesChanger(@Nonnull Context context, @Nonnull PreferredPreferences preferredPreferences) {
this.context = context;
this.preferredPreferences = preferredPreferences;
}
@ -238,12 +249,12 @@ public final class CalculatorButtons {
}
}
static class FunctionsDragProcessor implements SimpleDragListener.DragProcessor {
public static class FunctionsDragProcessor implements SimpleDragListener.DragProcessor {
@Nonnull
private Context context;
FunctionsDragProcessor(@Nonnull Context context) {
public FunctionsDragProcessor(@Nonnull Context context) {
this.context = context;
}