Style changes
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user