Fix button text size
This commit is contained in:
parent
a68e08201f
commit
9af30b08ce
@ -358,4 +358,8 @@ public final class App {
|
|||||||
"Failed to show permission settings for " + action, e);
|
"Failed to show permission settings for " + action, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isTablet(@NonNull Context context) {
|
||||||
|
return context.getResources().getBoolean(R.bool.cpp_tablet);
|
||||||
|
}
|
||||||
}
|
}
|
@ -25,9 +25,9 @@ package org.solovyev.android.calculator.about;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.FragmentTab;
|
import org.solovyev.android.calculator.FragmentTab;
|
||||||
import org.solovyev.android.calculator.R;
|
|
||||||
import org.solovyev.android.calculator.view.Tabs;
|
import org.solovyev.android.calculator.view.Tabs;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -39,8 +39,7 @@ public class AboutActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Class<? extends AboutActivity> getClass(@NonNull Context context) {
|
public static Class<? extends AboutActivity> getClass(@NonNull Context context) {
|
||||||
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
|
return App.isTablet(context) ? Dialog.class : AboutActivity.class;
|
||||||
return tablet ? Dialog.class : AboutActivity.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.FragmentTab;
|
import org.solovyev.android.calculator.FragmentTab;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
@ -41,8 +42,7 @@ public class FunctionsActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Class<? extends FunctionsActivity> getClass(@NonNull Context context) {
|
public static Class<? extends FunctionsActivity> getClass(@NonNull Context context) {
|
||||||
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
|
return App.isTablet(context) ? Dialog.class : FunctionsActivity.class;
|
||||||
return tablet ? Dialog.class : FunctionsActivity.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,8 +49,7 @@ public class HistoryActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Class<? extends HistoryActivity> getClass(@NonNull Context context) {
|
public static Class<? extends HistoryActivity> getClass(@NonNull Context context) {
|
||||||
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
|
return App.isTablet(context) ? Dialog.class : HistoryActivity.class;
|
||||||
return tablet ? Dialog.class : HistoryActivity.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
package org.solovyev.android.calculator.keyboard;
|
package org.solovyev.android.calculator.keyboard;
|
||||||
|
|
||||||
|
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING;
|
||||||
|
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING;
|
||||||
|
import static android.view.HapticFeedbackConstants.KEYBOARD_TAP;
|
||||||
|
import static org.solovyev.android.calculator.App.cast;
|
||||||
|
import static org.solovyev.android.calculator.App.getScreenMetrics;
|
||||||
|
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple;
|
||||||
|
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple_mobile;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
@ -11,8 +20,15 @@ import android.util.TypedValue;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.solovyev.android.Views;
|
import org.solovyev.android.Views;
|
||||||
import org.solovyev.android.calculator.*;
|
import org.solovyev.android.calculator.ActivityUi;
|
||||||
|
import org.solovyev.android.calculator.App;
|
||||||
|
import org.solovyev.android.calculator.Calculator;
|
||||||
|
import org.solovyev.android.calculator.Editor;
|
||||||
|
import org.solovyev.android.calculator.Keyboard;
|
||||||
|
import org.solovyev.android.calculator.Preferences;
|
||||||
|
import org.solovyev.android.calculator.PreferredPreferences;
|
||||||
import org.solovyev.android.calculator.buttons.CppSpecialButton;
|
import org.solovyev.android.calculator.buttons.CppSpecialButton;
|
||||||
import org.solovyev.android.calculator.view.ScreenMetrics;
|
import org.solovyev.android.calculator.view.ScreenMetrics;
|
||||||
import org.solovyev.android.views.Adjuster;
|
import org.solovyev.android.views.Adjuster;
|
||||||
@ -21,20 +37,18 @@ import org.solovyev.android.views.dragbutton.DragButton;
|
|||||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||||
import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static android.view.HapticFeedbackConstants.*;
|
import javax.annotation.Nonnull;
|
||||||
import static org.solovyev.android.calculator.App.cast;
|
import javax.inject.Inject;
|
||||||
import static org.solovyev.android.calculator.App.getScreenMetrics;
|
|
||||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple;
|
|
||||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple_mobile;
|
|
||||||
|
|
||||||
public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, SimpleDragListener.DragProcessor, View.OnClickListener {
|
public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, SimpleDragListener.DragProcessor, View.OnClickListener {
|
||||||
|
|
||||||
public static final float TEXT_SCALE = 0.6f;
|
public static float getTextScale(@NonNull Context context) {
|
||||||
|
return App.isTablet(context) ? 0.5f : 0.6f;
|
||||||
|
}
|
||||||
|
|
||||||
public static final float IMAGE_SCALE = 0.6f;
|
public static final float IMAGE_SCALE = 0.6f;
|
||||||
public static final float IMAGE_SCALE_ERASE = 0.5f;
|
public static final float IMAGE_SCALE_ERASE = 0.5f;
|
||||||
|
|
||||||
@ -57,14 +71,16 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
|||||||
protected int orientation = Configuration.ORIENTATION_PORTRAIT;
|
protected int orientation = Configuration.ORIENTATION_PORTRAIT;
|
||||||
private int textSize;
|
private int textSize;
|
||||||
private Preferences.Gui.Layout layout;
|
private Preferences.Gui.Layout layout;
|
||||||
|
private final float textScale;
|
||||||
|
|
||||||
public BaseKeyboardUi(@NonNull Application application) {
|
public BaseKeyboardUi(@NonNull Application application) {
|
||||||
listener = new SimpleDragListener(this, application);
|
listener = new SimpleDragListener(this, application);
|
||||||
|
textScale = getTextScale(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void adjustButton(@NonNull View button) {
|
public static void adjustButton(@NonNull View button) {
|
||||||
if (button instanceof TextView) {
|
if (button instanceof TextView) {
|
||||||
Adjuster.adjustText((TextView) button, TEXT_SCALE);
|
Adjuster.adjustText((TextView) button, getTextScale(button.getContext()));
|
||||||
} else if (button instanceof ImageView) {
|
} else if (button instanceof ImageView) {
|
||||||
Adjuster.adjustImage((ImageView) button, IMAGE_SCALE);
|
Adjuster.adjustImage((ImageView) button, IMAGE_SCALE);
|
||||||
}
|
}
|
||||||
@ -110,7 +126,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
|||||||
button.setOnDragListener(listener);
|
button.setOnDragListener(listener);
|
||||||
ActivityUi.setFont(button, typeface);
|
ActivityUi.setFont(button, typeface);
|
||||||
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||||
Adjuster.adjustText(button, TEXT_SCALE);
|
Adjuster.adjustText(button, textScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void hideText(@Nullable DirectionDragButton button, @Nonnull DragDirection... directions) {
|
protected final void hideText(@Nullable DirectionDragButton button, @Nonnull DragDirection... directions) {
|
||||||
|
@ -25,6 +25,7 @@ package org.solovyev.android.calculator.operators;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.FragmentTab;
|
import org.solovyev.android.calculator.FragmentTab;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
@ -39,8 +40,7 @@ public class OperatorsActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Class<? extends OperatorsActivity> getClass(@NonNull Context context) {
|
public static Class<? extends OperatorsActivity> getClass(@NonNull Context context) {
|
||||||
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
|
return App.isTablet(context) ? Dialog.class : OperatorsActivity.class;
|
||||||
return tablet ? Dialog.class : OperatorsActivity.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,8 +32,7 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
|
|||||||
private static final SparseArray<PrefDef> preferences = new SparseArray<>();
|
private static final SparseArray<PrefDef> preferences = new SparseArray<>();
|
||||||
|
|
||||||
public static Class<? extends PreferencesActivity> getClass(@NonNull Context context) {
|
public static Class<? extends PreferencesActivity> getClass(@NonNull Context context) {
|
||||||
final boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
|
return App.isTablet(context) ? Dialog.class : PreferencesActivity.class;
|
||||||
return tablet ? Dialog.class : PreferencesActivity.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -26,6 +26,8 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.FragmentTab;
|
import org.solovyev.android.calculator.FragmentTab;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
@ -40,8 +42,7 @@ public class VariablesActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Class<? extends VariablesActivity> getClass(@NonNull Context context) {
|
public static Class<? extends VariablesActivity> getClass(@NonNull Context context) {
|
||||||
boolean tablet = context.getResources().getBoolean(R.bool.cpp_tablet);
|
return App.isTablet(context) ? Dialog.class : VariablesActivity.class;
|
||||||
return tablet ? Dialog.class : VariablesActivity.class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,12 +22,15 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator.wizard;
|
package org.solovyev.android.calculator.wizard;
|
||||||
|
|
||||||
|
import static org.solovyev.android.calculator.App.cast;
|
||||||
|
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.ActivityUi;
|
import org.solovyev.android.calculator.ActivityUi;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
|
import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
|
||||||
@ -37,12 +40,11 @@ import org.solovyev.android.views.dragbutton.DragButton;
|
|||||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||||
import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.App.cast;
|
|
||||||
|
|
||||||
public class DragButtonWizardStep extends WizardFragment {
|
public class DragButtonWizardStep extends WizardFragment {
|
||||||
|
|
||||||
@ -76,7 +78,7 @@ public class DragButtonWizardStep extends WizardFragment {
|
|||||||
dragButton.setOnDragListener(
|
dragButton.setOnDragListener(
|
||||||
new SimpleDragListener(new DragButtonProcessor(), getActivity()));
|
new SimpleDragListener(new DragButtonProcessor(), getActivity()));
|
||||||
ActivityUi.setFont(dragButton, typeface);
|
ActivityUi.setFont(dragButton, typeface);
|
||||||
Adjuster.adjustText(dragButton, BaseKeyboardUi.TEXT_SCALE);
|
Adjuster.adjustText(dragButton, BaseKeyboardUi.getTextScale(getActivity()));
|
||||||
actionTextView = (TextView) root.findViewById(R.id.wizard_dragbutton_action_textview);
|
actionTextView = (TextView) root.findViewById(R.id.wizard_dragbutton_action_textview);
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
setAction((DragButtonAction) savedInstanceState.getSerializable(ACTION));
|
setAction((DragButtonAction) savedInstanceState.getSerializable(ACTION));
|
||||||
|
@ -96,9 +96,8 @@
|
|||||||
|
|
||||||
<style name="CppText.About">
|
<style name="CppText.About">
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:layout_width">fill_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:layout_height">fill_parent</item>
|
<item name="android:layout_height">match_parent</item>
|
||||||
<item name="android:textSize">@dimen/cpp_fragment_text_size</item>
|
|
||||||
<item name="android:padding">5dp</item>
|
<item name="android:padding">5dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user