Fix font issues

This commit is contained in:
serso 2014-07-27 18:15:14 +02:00
parent 821ca5311d
commit ebf103a7da
4 changed files with 25 additions and 4 deletions

Binary file not shown.

View File

@ -26,15 +26,14 @@ import android.app.Activity;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.os.Vibrator; import android.os.Vibrator;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.TextView;
import javax.annotation.Nonnull; import org.solovyev.android.Views;
import javax.annotation.Nullable;
import org.solovyev.android.calculator.history.CalculatorHistoryState; import org.solovyev.android.calculator.history.CalculatorHistoryState;
import org.solovyev.android.calculator.view.AngleUnitsButton; import org.solovyev.android.calculator.view.AngleUnitsButton;
import org.solovyev.android.calculator.view.NumeralBasesButton; import org.solovyev.android.calculator.view.NumeralBasesButton;
@ -45,6 +44,8 @@ import org.solovyev.common.listeners.JListeners;
import org.solovyev.common.listeners.Listeners; import org.solovyev.common.listeners.Listeners;
import org.solovyev.common.math.Point2d; import org.solovyev.common.math.Point2d;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
@ -208,6 +209,15 @@ public abstract class AbstractCalculatorHelper implements SharedPreferences.OnSh
CalculatorButtons.toggleEqualsButton(preferences, activity); CalculatorButtons.toggleEqualsButton(preferences, activity);
CalculatorButtons.initMultiplicationButton(root); CalculatorButtons.initMultiplicationButton(root);
NumeralBaseButtons.toggleNumericDigits(activity, preferences); NumeralBaseButtons.toggleNumericDigits(activity, preferences);
// some devices ship own fonts which causes issues with rendering. Let's use our own font for all text views
final Typeface typeFace = CalculatorApplication.getInstance().getTypeFace();
Views.processViewsOfType(root, TextView.class, new Views.ViewProcessor<TextView>() {
@Override
public void process(@Nonnull TextView view) {
view.setTypeface(typeFace);
}
});
} }
private void toggleButtonDirectionText(@Nonnull View root, int id, boolean showDirectionText, @Nonnull DragDirection... dragDirections) { private void toggleButtonDirectionText(@Nonnull View root, int id, boolean showDirectionText, @Nonnull DragDirection... dragDirections) {

View File

@ -25,6 +25,7 @@ package org.solovyev.android.calculator;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Typeface;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
@ -105,6 +106,9 @@ public class CalculatorApplication extends android.app.Application implements Sh
private final boolean withAds; private final boolean withAds;
@Nonnull
private Typeface typeFace;
/* /*
********************************************************************** **********************************************************************
* *
@ -211,6 +215,8 @@ public class CalculatorApplication extends android.app.Application implements Sh
Locator.getInstance().getLogger().debug(TAG, "Application started!"); Locator.getInstance().getLogger().debug(TAG, "Application started!");
Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!"); Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!");
typeFace = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
} }
private void setTheme(@Nonnull SharedPreferences preferences) { private void setTheme(@Nonnull SharedPreferences preferences) {
@ -248,6 +254,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
return wizards; return wizards;
} }
@Nonnull
public Typeface getTypeFace() {
return typeFace;
}
/* /*
********************************************************************** **********************************************************************
* *