Choose mode wizard step
This commit is contained in:
parent
655f4dc3bf
commit
b7a05b66bc
@ -28,6 +28,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import org.solovyev.common.math.Point2d;
|
||||
import org.solovyev.common.text.NumberParser;
|
||||
@ -117,7 +118,7 @@ public class DirectionDragButton extends DragButton {
|
||||
}
|
||||
}
|
||||
|
||||
protected static enum GuiDragDirection {
|
||||
public static enum GuiDragDirection {
|
||||
up(DragDirection.up, 0) {
|
||||
@Override
|
||||
public int getAttributeId() {
|
||||
@ -240,7 +241,7 @@ public class DirectionDragButton extends DragButton {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private final Map<GuiDragDirection, DirectionTextData> textDataMap = new EnumMap<GuiDragDirection, DirectionTextData>(GuiDragDirection.class);
|
||||
private final Map<GuiDragDirection, DirectionTextData> textDataMap = new EnumMap<>(GuiDragDirection.class);
|
||||
|
||||
@Nonnull
|
||||
protected String directionTextScale = DEFAULT_DIRECTION_TEXT_SCALE;
|
||||
@ -312,6 +313,7 @@ public class DirectionDragButton extends DragButton {
|
||||
initDirectionTextPaint(basePaint, textData);
|
||||
textData.position = textData.direction.getTextPosition(textData.paint, basePaint, textData.text, getText(), getWidth(), getHeight());
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,9 +363,20 @@ public class DirectionDragButton extends DragButton {
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(@Nullable String text, @Nonnull GuiDragDirection direction) {
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
final DirectionTextData data = new DirectionTextData(direction, text);
|
||||
initDirectionTextPaint(getPaint(), data);
|
||||
textDataMap.put(direction, data);
|
||||
} else {
|
||||
textDataMap.remove(direction);
|
||||
}
|
||||
measureText();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getText(@Nonnull GuiDragDirection direction) {
|
||||
DirectionTextData td = this.textDataMap.get(direction);
|
||||
DirectionTextData td = textDataMap.get(direction);
|
||||
if (td == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -29,6 +29,7 @@ import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.calculator.drag.DirectionDragButton;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -42,6 +43,7 @@ import static org.solovyev.android.calculator.wizard.CalculatorMode.*;
|
||||
*/
|
||||
public class ChooseModeWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
private DirectionDragButton button;
|
||||
private TextView description;
|
||||
|
||||
@Override
|
||||
@ -59,12 +61,23 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.
|
||||
spinner.setSelection(mode == simple ? 0 : 1);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
|
||||
button = (DirectionDragButton) root.findViewById(R.id.wizard_mode_button);
|
||||
description = (TextView) root.findViewById(R.id.wizard_mode_description);
|
||||
updateDescription(mode);
|
||||
}
|
||||
|
||||
private void updateDescription(@Nonnull CalculatorMode mode) {
|
||||
description.setText(mode == simple ? R.string.cpp_wizard_mode_simple_description : R.string.cpp_wizard_mode_engineer_description);
|
||||
boolean simple = mode == CalculatorMode.simple;
|
||||
description.setText(simple ? R.string.cpp_wizard_mode_simple_description : R.string.cpp_wizard_mode_engineer_description);
|
||||
if (simple) {
|
||||
button.setText("", DirectionDragButton.GuiDragDirection.up);
|
||||
button.setText("", DirectionDragButton.GuiDragDirection.down);
|
||||
button.setText("", DirectionDragButton.GuiDragDirection.left);
|
||||
} else {
|
||||
button.setText("sin", DirectionDragButton.GuiDragDirection.up);
|
||||
button.setText("ln", DirectionDragButton.GuiDragDirection.down);
|
||||
button.setText("i", DirectionDragButton.GuiDragDirection.left);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,18 +33,43 @@
|
||||
a:layout_height="wrap_content"
|
||||
a:textAppearance="@android:style/TextAppearance.Large"
|
||||
style="@style/WizardLabel"
|
||||
a:text="@string/cpp_wizard_mode_title"/>
|
||||
a:layout_marginBottom="20dp"
|
||||
a:text="@string/cpp_wizard_mode_title" />
|
||||
|
||||
<Spinner
|
||||
a:id="@+id/wizard_mode_spinner"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
style="@style/WizardLabel"/>
|
||||
a:layout_marginBottom="20dp"
|
||||
style="@style/WizardLabel" />
|
||||
|
||||
<LinearLayout
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
a:orientation="vertical"
|
||||
a:gravity="center_horizontal|top">
|
||||
|
||||
<FrameLayout
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
a:padding="3dp"
|
||||
a:layout_marginBottom="10dp"
|
||||
a:background="?attr/cpp_main_bg">
|
||||
|
||||
<org.solovyev.android.calculator.drag.DirectionDragButton xmlns:c="http://schemas.android.com/apk/res-auto"
|
||||
a:id="@+id/wizard_mode_button"
|
||||
a:text="7"
|
||||
c:directionTextScale="0.5"
|
||||
a:layout_width="100dp"
|
||||
a:layout_height="100dp"
|
||||
style="?attr/cpp_button_style_digit" />
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
a:id="@+id/wizard_mode_description"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
style="@style/WizardLabel.Last"/>
|
||||
style="@style/WizardLabel.Last" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -97,7 +97,7 @@
|
||||
<item name="android:background">@color/cpp_metro_button_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Wizard.Light" parent="Cpp.Theme.Light">
|
||||
<style name="Cpp.Theme.Wizard" parent="Cpp.Theme.Material">
|
||||
<item name="android:windowBackground">@color/cpp_wizard_bg</item>
|
||||
<item name="android:colorEdgeEffect">@color/cpp_wizard_overscroll</item>
|
||||
<item name="colorAccent">@color/cpp_wizard_primary</item>
|
||||
@ -106,7 +106,7 @@
|
||||
<item name="android:textColorPrimary">@color/cpp_wizard_primary</item>
|
||||
</style>
|
||||
|
||||
<style name="Cpp.Theme.Wizard" parent="Cpp.Theme">
|
||||
<style name="Cpp.Theme.Wizard.Light" parent="Cpp.Theme.Material.Light">
|
||||
<item name="android:windowBackground">@color/cpp_wizard_bg</item>
|
||||
<item name="android:colorEdgeEffect">@color/cpp_wizard_overscroll</item>
|
||||
<item name="colorAccent">@color/cpp_wizard_primary</item>
|
||||
|
Loading…
Reference in New Issue
Block a user