Multiplication button for widget
This commit is contained in:
parent
97c8b6b6d6
commit
8cda4424a3
@ -9,6 +9,7 @@ import android.util.Log;
|
|||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import jscl.AngleUnit;
|
import jscl.AngleUnit;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
@ -59,7 +60,9 @@ public final class CalculatorButtons {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void initMultiplicationButton(@NotNull RemoteViews views) {
|
||||||
|
views.setTextViewText(R.id.multiplicationButton, CalculatorLocatorImpl.getInstance().getEngine().getMultiplicationSign());
|
||||||
|
}
|
||||||
|
|
||||||
public static void toggleEqualsButton(@Nullable SharedPreferences preferences,
|
public static void toggleEqualsButton(@Nullable SharedPreferences preferences,
|
||||||
@NotNull Activity activity) {
|
@NotNull Activity activity) {
|
||||||
|
@ -117,6 +117,8 @@ public class CalculatorWidgetProvider extends AppWidgetProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CalculatorButtons.initMultiplicationButton(views);
|
||||||
|
|
||||||
updateEditorState(context, views, editorState);
|
updateEditorState(context, views, editorState);
|
||||||
updateDisplayState(context, views, displayState);
|
updateDisplayState(context, views, displayState);
|
||||||
|
|
||||||
@ -179,21 +181,13 @@ public class CalculatorWidgetProvider extends AppWidgetProvider {
|
|||||||
|
|
||||||
private void updateDisplayState(@NotNull Context context, @NotNull RemoteViews views, @NotNull CalculatorDisplayViewState displayState) {
|
private void updateDisplayState(@NotNull Context context, @NotNull RemoteViews views, @NotNull CalculatorDisplayViewState displayState) {
|
||||||
if (displayState.isValid()) {
|
if (displayState.isValid()) {
|
||||||
setText(views, R.id.calculatorDisplay, displayState.getText());
|
views.setTextViewText(R.id.calculatorDisplay, displayState.getText());
|
||||||
setTextColor(views, R.id.calculatorDisplay, context.getResources().getColor(R.color.default_text_color));
|
views.setTextColor(R.id.calculatorDisplay, context.getResources().getColor(R.color.default_text_color));
|
||||||
} else {
|
} else {
|
||||||
setTextColor(views, R.id.calculatorDisplay, context.getResources().getColor(R.color.display_error_text_color));
|
views.setTextColor(R.id.calculatorDisplay, context.getResources().getColor(R.color.display_error_text_color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText(@NotNull RemoteViews views, int textViewId, @Nullable CharSequence text) {
|
|
||||||
views.setTextViewText(textViewId, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTextColor(@NotNull RemoteViews views, int textViewId, int textColor) {
|
|
||||||
views.setTextColor(textViewId, textColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateEditorState(@NotNull Context context, @NotNull RemoteViews views, @NotNull CalculatorEditorViewState editorState) {
|
private void updateEditorState(@NotNull Context context, @NotNull RemoteViews views, @NotNull CalculatorEditorViewState editorState) {
|
||||||
String text = editorState.getText();
|
String text = editorState.getText();
|
||||||
|
|
||||||
@ -204,7 +198,7 @@ public class CalculatorWidgetProvider extends AppWidgetProvider {
|
|||||||
newText = Html.fromHtml(text.substring(0, selection) + "<font color=\"#" + getCursorColor(context) + "\">|</font>" + text.substring(selection));
|
newText = Html.fromHtml(text.substring(0, selection) + "<font color=\"#" + getCursorColor(context) + "\">|</font>" + text.substring(selection));
|
||||||
}
|
}
|
||||||
CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "New editor state: " + text);
|
CalculatorLocatorImpl.getInstance().getNotifier().showDebugMessage(TAG, "New editor state: " + text);
|
||||||
setText(views, R.id.calculatorEditor, newText);
|
views.setTextViewText(R.id.calculatorEditor, newText);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user