diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
index ef08817f..6ef0afd5 100644
--- a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
+++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java
@@ -23,20 +23,17 @@
package org.solovyev.android.calculator;
import android.content.SharedPreferences;
-import android.content.res.Resources;
-import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
-import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;
-
+import butterknife.Bind;
+import butterknife.ButterKnife;
import org.solovyev.android.calculator.converter.ConverterFragment;
import org.solovyev.android.calculator.history.History;
import org.solovyev.android.calculator.keyboard.PartialKeyboardUi;
@@ -45,9 +42,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
-import butterknife.Bind;
-import butterknife.ButterKnife;
-
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
@@ -76,9 +70,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
Toolbar toolbar;
@Bind(R.id.editor)
FrameLayout editor;
- @Nullable
- @Bind(R.id.card)
- CardView card;
private boolean useBackAsPrevious;
public CalculatorActivity() {
@@ -112,8 +103,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
startupHelper.onMainActivityOpened(this);
}
- toggleOrientationChange();
- prepareCardAndToolbar();
+ updateOrientation();
preferences.registerOnSharedPreferenceChangeListener(this);
preferredPreferences.check(this, false);
@@ -172,11 +162,11 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
}
if (Preferences.Gui.rotateScreen.getKey().equals(key)) {
- toggleOrientationChange();
+ updateOrientation();
}
}
- private void toggleOrientationChange() {
+ private void updateOrientation() {
if (Preferences.Gui.rotateScreen.getPreference(preferences)) {
setRequestedOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
} else {
@@ -205,26 +195,4 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
}
return false;
}
-
- private void prepareCardAndToolbar() {
- if (card == null) {
- return;
- }
- final Resources resources = getResources();
- final int cardTopMargin = resources.getDimensionPixelSize(R.dimen.cpp_card_margin);
- final int preLollipopCardTopPadding = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? card.getPaddingTop() : 0;
-
- {
- final ViewGroup.LayoutParams lp = toolbar.getLayoutParams();
- lp.height += cardTopMargin + preLollipopCardTopPadding;
- toolbar.setLayoutParams(lp);
- // center icons in toolbar
- toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + cardTopMargin / 2 + preLollipopCardTopPadding, toolbar.getPaddingRight(), toolbar.getPaddingBottom() + cardTopMargin / 2);
- }
- final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) card.getLayoutParams();
- final int actionWidth = resources.getDimensionPixelSize(R.dimen.abc_action_button_min_width_overflow_material) + 2 * resources.getDimensionPixelSize(R.dimen.abc_action_bar_overflow_padding_start_material);
- lp.leftMargin = actionWidth + 2 * toolbar.getPaddingLeft();
- lp.rightMargin = actionWidth + 2 * toolbar.getPaddingRight();
- card.setLayoutParams(lp);
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java b/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java
index 1b329c76..f517ea9b 100644
--- a/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java
+++ b/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java
@@ -22,17 +22,23 @@
package org.solovyev.android.calculator.wizard;
+import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
import android.widget.TextView;
+import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
+import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
+import org.solovyev.android.views.Adjuster;
import org.solovyev.android.views.dragbutton.DirectionDragButton;
import javax.annotation.Nonnull;
+import javax.inject.Inject;
+import static org.solovyev.android.calculator.App.cast;
import static org.solovyev.android.calculator.wizard.CalculatorMode.engineer;
import static org.solovyev.android.calculator.wizard.CalculatorMode.simple;
import static org.solovyev.android.views.dragbutton.DragDirection.*;
@@ -42,11 +48,20 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.
private DirectionDragButton button;
private TextView description;
+ @Inject
+ Typeface typeface;
+
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_choose_mode;
}
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ cast(this).getComponent().inject(this);
+ }
+
@Override
public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState);
@@ -58,6 +73,8 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.
spinner.setOnItemSelectedListener(this);
button = (DirectionDragButton) root.findViewById(R.id.wizard_mode_button);
+ BaseActivity.setFont(button, typeface);
+ Adjuster.adjustText(button, BaseKeyboardUi.getTextScale(getActivity()));
description = (TextView) root.findViewById(R.id.wizard_mode_description);
updateDescription(mode);
}
diff --git a/app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java b/app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java
index bb9c32b4..b987b19c 100644
--- a/app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java
+++ b/app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java
@@ -25,7 +25,6 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import static org.solovyev.android.calculator.App.cast;
-import static org.solovyev.android.calculator.App.toPixels;
public abstract class WizardFragment extends Fragment implements View.OnClickListener {
@@ -75,7 +74,7 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
final ViewGroup content = (ViewGroup) view.findViewById(R.id.wizard_content);
inflater.inflate(getViewResId(), content, true);
- Adjuster.maxWidth(content, toPixels(view, 300));
+ Adjuster.maxWidth(content, getResources().getDimensionPixelSize(R.dimen.cpp_wizard_max_width));
nextButton = (TextView) view.findViewById(R.id.wizard_next);
if (nextButton != null) {
diff --git a/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java b/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java
index 1af276b0..d401d2d5 100644
--- a/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java
+++ b/app/src/main/java/org/solovyev/android/views/dragbutton/DirectionTextView.java
@@ -2,10 +2,7 @@ package org.solovyev.android.views.dragbutton;
import android.content.Context;
import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.PointF;
-import android.graphics.Rect;
-import android.graphics.Typeface;
+import android.graphics.*;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextPaint;
@@ -112,14 +109,15 @@ public class DirectionTextView {
if (array.hasValue(direction.textAttr)) {
value = Strings.nullToEmpty(array.getString(direction.textAttr));
}
+ padding = array.getDimensionPixelSize(direction.paddingAttr, defPadding);
scale = array.getFloat(direction.scaleAttr, defScale);
} else {
value = "";
scale = defScale;
+ padding = defPadding;
}
alpha = defAlpha;
color = defColor;
- padding = defPadding;
initPaint(base);
}
@@ -214,12 +212,11 @@ public class DirectionTextView {
final int paddingRight = padding;
final int paddingTop = padding;
final int paddingBottom = padding;
- final int verticalPaddings = 0;
switch (direction) {
case up:
case down:
- offset.x = -paddingLeft - bounds.width();
+ offset.x = -paddingLeft - bounds.width() - bounds.left;
if (direction == DragDirection.up) {
offset.y = paddingTop + fixedTextHeight;
} else {
@@ -233,7 +230,7 @@ public class DirectionTextView {
} else {
offset.x = -paddingRight - bounds.width();
}
- offset.y = paddingTop - verticalPaddings / 2 + fixedTextHeight / 2;
+ offset.y = (paddingTop - paddingBottom) / 2 + fixedTextHeight / 2;
break;
}
}
diff --git a/app/src/main/java/org/solovyev/android/views/dragbutton/DragDirection.java b/app/src/main/java/org/solovyev/android/views/dragbutton/DragDirection.java
index 09889cdc..599b98fc 100644
--- a/app/src/main/java/org/solovyev/android/views/dragbutton/DragDirection.java
+++ b/app/src/main/java/org/solovyev/android/views/dragbutton/DragDirection.java
@@ -6,10 +6,10 @@ import org.solovyev.android.calculator.R;
public enum DragDirection {
- up(180f - 45f, 180f - 0f, R.styleable.DirectionText_directionTextUp, R.styleable.DirectionText_directionTextScaleUp),
- down(0f, 45f, R.styleable.DirectionText_directionTextDown, R.styleable.DirectionText_directionTextScaleDown),
- left(90f - 45f, 90f + 45f, R.styleable.DirectionText_directionTextLeft, R.styleable.DirectionText_directionTextScaleLeft),
- right(90f - 45f, 90f + 45f, R.styleable.DirectionText_directionTextRight, R.styleable.DirectionText_directionTextScaleRight);
+ up(180f - 45f, 180f - 0f, R.styleable.DirectionText_directionTextUp, R.styleable.DirectionText_directionTextScaleUp, R.styleable.DirectionText_directionTextPaddingUp),
+ down(0f, 45f, R.styleable.DirectionText_directionTextDown, R.styleable.DirectionText_directionTextScaleDown, R.styleable.DirectionText_directionTextPaddingDown),
+ left(90f - 45f, 90f + 45f, R.styleable.DirectionText_directionTextLeft, R.styleable.DirectionText_directionTextScaleLeft, R.styleable.DirectionText_directionTextPaddingLeft),
+ right(90f - 45f, 90f + 45f, R.styleable.DirectionText_directionTextRight, R.styleable.DirectionText_directionTextScaleRight, R.styleable.DirectionText_directionTextPaddingRight);
final float angleFrom;
final float angleTo;
@@ -17,11 +17,14 @@ public enum DragDirection {
final int textAttr;
@StyleableRes
final int scaleAttr;
+ @StyleableRes
+ final int paddingAttr;
- DragDirection(float angleFrom, float angleTo, int textAttr, int scaleAttr) {
+ DragDirection(float angleFrom, float angleTo, @StyleableRes int textAttr, @StyleableRes int scaleAttr, @StyleableRes int paddingAttr) {
this.angleFrom = angleFrom;
this.angleTo = angleTo;
this.textAttr = textAttr;
this.scaleAttr = scaleAttr;
+ this.paddingAttr = paddingAttr;
}
}
diff --git a/app/src/main/res/layout-sw600dp/activity_main.xml b/app/src/main/res/layout-sw600dp/activity_main.xml
deleted file mode 100644
index fb8f3557..00000000
--- a/app/src/main/res/layout-sw600dp/activity_main.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout-sw600dp/cpp_app_keyboard.xml b/app/src/main/res/layout-sw600dp/cpp_app_keyboard.xml
deleted file mode 100644
index a271e8b7..00000000
--- a/app/src/main/res/layout-sw600dp/cpp_app_keyboard.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/cpp_app_button_dot.xml b/app/src/main/res/layout/cpp_app_button_dot.xml
index 4b589a3a..426ed501 100644
--- a/app/src/main/res/layout/cpp_app_button_dot.xml
+++ b/app/src/main/res/layout/cpp_app_button_dot.xml
@@ -28,6 +28,7 @@
xmlns:tools="http://schemas.android.com/tools"
a:id="@id/cpp_button_period"
style="?attr/cpp_button_style_digit"
+ c:directionTextScale="0.6"
a:text="."
c:directionTextUp=","
tools:ignore="HardcodedText" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/cpp_app_button_equals_no_bg.xml b/app/src/main/res/layout/cpp_app_button_equals_no_bg.xml
index da06dcb8..bbf5774f 100644
--- a/app/src/main/res/layout/cpp_app_button_equals_no_bg.xml
+++ b/app/src/main/res/layout/cpp_app_button_equals_no_bg.xml
@@ -30,6 +30,7 @@
a:background="@drawable/button_no_bg"
a:text="="
a:textColor="?attr/cpp_text_color"
+ c:directionTextColor="?attr/cpp_text_color"
c:directionTextDown="@string/cpp_plot_button_text"
c:directionTextUp="≡"
tools:ignore="HardcodedText" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/cpp_app_button_history.xml b/app/src/main/res/layout/cpp_app_button_history.xml
index f247133f..1b29e5fc 100644
--- a/app/src/main/res/layout/cpp_app_button_history.xml
+++ b/app/src/main/res/layout/cpp_app_button_history.xml
@@ -27,5 +27,6 @@
a:id="@id/cpp_button_history"
style="?attr/cpp_button_style_control"
a:src="@drawable/ic_history_white_48dp"
+ app:directionTextScale="0.5"
app:directionTextDown="@string/cpp_kb_redo"
app:directionTextUp="@string/cpp_kb_undo" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/cpp_app_display.xml b/app/src/main/res/layout/cpp_app_display.xml
index 53a8b09d..c4608f24 100644
--- a/app/src/main/res/layout/cpp_app_display.xml
+++ b/app/src/main/res/layout/cpp_app_display.xml
@@ -25,5 +25,6 @@
\ No newline at end of file
+ android:paddingLeft="@dimen/cpp_display_padding_side"
+ android:paddingRight="@dimen/cpp_display_padding_side"
+ xmlns:android="http://schemas.android.com/apk/res/android"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/cpp_wizard_step_choose_mode.xml b/app/src/main/res/layout/cpp_wizard_step_choose_mode.xml
index f4a1bb96..e3b7fcec 100644
--- a/app/src/main/res/layout/cpp_wizard_step_choose_mode.xml
+++ b/app/src/main/res/layout/cpp_wizard_step_choose_mode.xml
@@ -59,8 +59,8 @@
diff --git a/app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml b/app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml
index fd63e74c..1dcdc36b 100644
--- a/app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml
+++ b/app/src/main/res/layout/cpp_wizard_step_choose_theme_preview.xml
@@ -27,14 +27,14 @@
a:layout_width="wrap_content"
a:layout_height="wrap_content"
a:background="?attr/cpp_editor_bg"
- a:minWidth="200dp"
+ a:minWidth="@dimen/cpp_wizard_preview_width"
a:orientation="vertical"
a:padding="3dp"
tools:ignore="Overdraw">
@@ -51,27 +51,27 @@
-
-
-
+
+
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/cpp_wizard_step_drag_button.xml b/app/src/main/res/layout/cpp_wizard_step_drag_button.xml
index 374dfc9b..f0a867b7 100644
--- a/app/src/main/res/layout/cpp_wizard_step_drag_button.xml
+++ b/app/src/main/res/layout/cpp_wizard_step_drag_button.xml
@@ -45,13 +45,11 @@
diff --git a/app/src/main/res/values-small/dimens.xml b/app/src/main/res/values-small/dimens.xml
index bf31e1b5..e1dd1368 100644
--- a/app/src/main/res/values-small/dimens.xml
+++ b/app/src/main/res/values-small/dimens.xml
@@ -24,5 +24,6 @@
18sp
20sp
40dp
- 1dp
+ 1dp
+ 1dp
\ No newline at end of file
diff --git a/app/src/main/res/values-sw600dp/dimens.xml b/app/src/main/res/values-sw600dp/dimens.xml
new file mode 100644
index 00000000..200cda90
--- /dev/null
+++ b/app/src/main/res/values-sw600dp/dimens.xml
@@ -0,0 +1,11 @@
+
+
+ 16dp
+ 16dp
+ 16dp
+ 400dp
+ 133dp
+ 400dp
+ 150dp
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 1118400f..dab546e8 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -13,7 +13,8 @@
- 0.3
1dp
- 4dp
+ 4dp
+ 2dp
30dp
12dp
@@ -27,6 +28,7 @@
5dp
3dp
+ 10dp
20dp
@@ -46,4 +48,8 @@
4dp
48dp
+ 200dp
+ 64dp
+ 300dp
+ 100dp
\ No newline at end of file
diff --git a/app/src/main/res/values/drag_attrs.xml b/app/src/main/res/values/drag_attrs.xml
index 3a1db08e..9f460954 100644
--- a/app/src/main/res/values/drag_attrs.xml
+++ b/app/src/main/res/values/drag_attrs.xml
@@ -9,6 +9,10 @@
+
+
+
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index cd8f8883..221c81dc 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -36,7 +36,10 @@
- centerInside
- @color/cpp_button_text
- @dimen/cpp_direction_text_scale
- - @dimen/cpp_keyboard_button_direction_text_padding
+ - @dimen/cpp_keyboard_button_direction_text_padding_updown
+ - @dimen/cpp_keyboard_button_direction_text_padding_updown
+ - @dimen/cpp_keyboard_button_direction_text_padding_updown
+ - @dimen/cpp_keyboard_button_direction_text_padding_left