Fix fonts in floating keyboards
This commit is contained in:
parent
ddb7d1b94c
commit
b9432db42a
@ -24,6 +24,7 @@ import org.solovyev.android.calculator.history.History;
|
|||||||
import org.solovyev.android.calculator.language.Language;
|
import org.solovyev.android.calculator.language.Language;
|
||||||
import org.solovyev.android.calculator.language.Languages;
|
import org.solovyev.android.calculator.language.Languages;
|
||||||
import org.solovyev.android.calculator.view.Tabs;
|
import org.solovyev.android.calculator.view.Tabs;
|
||||||
|
import org.solovyev.android.views.dragbutton.DirectionDragImageButton;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -86,6 +87,14 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
ga.getAnalytics().reportActivityStart(activity);
|
ga.getAnalytics().reportActivityStart(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setFont(@Nonnull View view, @Nonnull Typeface newTypeface) {
|
||||||
|
if (view instanceof TextView) {
|
||||||
|
setFont((TextView) view, newTypeface);
|
||||||
|
} else if (view instanceof DirectionDragImageButton) {
|
||||||
|
((DirectionDragImageButton) view).setTypeface(newTypeface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setFont(@Nonnull TextView view, @Nonnull Typeface newTypeface) {
|
public static void setFont(@Nonnull TextView view, @Nonnull Typeface newTypeface) {
|
||||||
final Typeface oldTypeface = view.getTypeface();
|
final Typeface oldTypeface = view.getTypeface();
|
||||||
if (oldTypeface == newTypeface) {
|
if (oldTypeface == newTypeface) {
|
||||||
@ -248,6 +257,4 @@ public class BaseActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,23 +34,9 @@ import android.support.annotation.NonNull;
|
|||||||
import android.support.v7.view.ContextThemeWrapper;
|
import android.support.v7.view.ContextThemeWrapper;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
import android.view.*;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import org.solovyev.android.calculator.*;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.AppModule;
|
|
||||||
import org.solovyev.android.calculator.BaseActivity;
|
|
||||||
import org.solovyev.android.calculator.DisplayState;
|
|
||||||
import org.solovyev.android.calculator.DisplayView;
|
|
||||||
import org.solovyev.android.calculator.Editor;
|
|
||||||
import org.solovyev.android.calculator.EditorState;
|
|
||||||
import org.solovyev.android.calculator.EditorView;
|
|
||||||
import org.solovyev.android.calculator.Keyboard;
|
|
||||||
import org.solovyev.android.calculator.Preferences;
|
|
||||||
import org.solovyev.android.calculator.R;
|
|
||||||
import org.solovyev.android.calculator.buttons.CppButton;
|
import org.solovyev.android.calculator.buttons.CppButton;
|
||||||
import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
|
import org.solovyev.android.calculator.keyboard.BaseKeyboardUi;
|
||||||
import org.solovyev.android.views.Adjuster;
|
import org.solovyev.android.views.Adjuster;
|
||||||
@ -59,14 +45,8 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING;
|
import static android.view.HapticFeedbackConstants.*;
|
||||||
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING;
|
import static android.view.WindowManager.LayoutParams.*;
|
||||||
import static android.view.HapticFeedbackConstants.KEYBOARD_TAP;
|
|
||||||
import static android.view.HapticFeedbackConstants.LONG_PRESS;
|
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
|
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
|
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
|
|
||||||
import static org.solovyev.android.calculator.App.cast;
|
import static org.solovyev.android.calculator.App.cast;
|
||||||
|
|
||||||
public class FloatingCalculatorView {
|
public class FloatingCalculatorView {
|
||||||
@ -377,9 +357,7 @@ public class FloatingCalculatorView {
|
|||||||
} else {
|
} else {
|
||||||
BaseKeyboardUi.adjustButton(button);
|
BaseKeyboardUi.adjustButton(button);
|
||||||
}
|
}
|
||||||
if (button instanceof TextView) {
|
BaseActivity.setFont(button, typeface);
|
||||||
BaseActivity.setFont((TextView) button, typeface);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
final WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
@ -26,6 +26,7 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.LayoutRes;
|
import android.support.annotation.LayoutRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@ -83,6 +84,8 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
@Inject
|
@Inject
|
||||||
Keyboard keyboard;
|
Keyboard keyboard;
|
||||||
@Inject
|
@Inject
|
||||||
|
Typeface typeface;
|
||||||
|
@Inject
|
||||||
FunctionsRegistry functionsRegistry;
|
FunctionsRegistry functionsRegistry;
|
||||||
@Inject
|
@Inject
|
||||||
VariablesRegistry variablesRegistry;
|
VariablesRegistry variablesRegistry;
|
||||||
@ -497,6 +500,12 @@ public abstract class BaseFunctionFragment extends BaseDialogFragment implements
|
|||||||
return keyboard.isVibrateOnKeypress();
|
return keyboard.isVibrateOnKeypress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Typeface getTypeface() {
|
||||||
|
return typeface;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void done() {
|
public void done() {
|
||||||
keyboardWindow.hide();
|
keyboardWindow.hide();
|
||||||
|
@ -15,6 +15,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
|
import org.solovyev.android.calculator.BaseActivity;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ public abstract class BaseFloatingKeyboard implements FloatingKeyboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void fillButton(@NonNull View button, @IdRes int id) {
|
protected void fillButton(@NonNull View button, @IdRes int id) {
|
||||||
|
BaseActivity.setFont(button, user.getTypeface());
|
||||||
button.setId(id);
|
button.setId(id);
|
||||||
button.setBackgroundResource(buttonBackground);
|
button.setBackgroundResource(buttonBackground);
|
||||||
button.setPadding(sidePadding, 1, sidePadding, 1);
|
button.setPadding(sidePadding, 1, sidePadding, 1);
|
||||||
|
@ -115,6 +115,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
|||||||
// we call android.view.View.performHapticFeedback(int, int) from #onClick
|
// we call android.view.View.performHapticFeedback(int, int) from #onClick
|
||||||
button.setHapticFeedbackEnabled(false);
|
button.setHapticFeedbackEnabled(false);
|
||||||
button.setOnClickListener(this);
|
button.setOnClickListener(this);
|
||||||
|
BaseActivity.setFont(button, typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void prepareButton(@Nullable DirectionDragImageButton button) {
|
protected final void prepareButton(@Nullable DirectionDragImageButton button) {
|
||||||
@ -125,7 +126,6 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
|||||||
button.setVibrateOnDrag(keyboard.isVibrateOnKeypress());
|
button.setVibrateOnDrag(keyboard.isVibrateOnKeypress());
|
||||||
prepareButton((ImageView) button);
|
prepareButton((ImageView) button);
|
||||||
button.setOnDragListener(listener);
|
button.setOnDragListener(listener);
|
||||||
button.setTypeface(typeface);
|
|
||||||
button.setTextSize(textSize);
|
button.setTextSize(textSize);
|
||||||
Adjuster.adjustText(button, AdjusterHelper.instance, textScale, 0);
|
Adjuster.adjustText(button, AdjusterHelper.instance, textScale, 0);
|
||||||
}
|
}
|
||||||
@ -138,7 +138,6 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
|||||||
button.setVibrateOnDrag(keyboard.isVibrateOnKeypress());
|
button.setVibrateOnDrag(keyboard.isVibrateOnKeypress());
|
||||||
prepareButton((View) button);
|
prepareButton((View) button);
|
||||||
button.setOnDragListener(listener);
|
button.setOnDragListener(listener);
|
||||||
BaseActivity.setFont(button, typeface);
|
|
||||||
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||||
Adjuster.adjustText(button, textScale);
|
Adjuster.adjustText(button, textScale);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package org.solovyev.android.calculator.keyboard;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -35,5 +36,7 @@ public interface FloatingKeyboard {
|
|||||||
|
|
||||||
boolean isVibrateOnKeypress();
|
boolean isVibrateOnKeypress();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
Typeface getTypeface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import android.content.Context;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.TextInputLayout;
|
import android.support.design.widget.TextInputLayout;
|
||||||
@ -93,6 +94,8 @@ public class EditVariableFragment extends BaseDialogFragment implements View.OnF
|
|||||||
@Inject
|
@Inject
|
||||||
Keyboard keyboard;
|
Keyboard keyboard;
|
||||||
@Inject
|
@Inject
|
||||||
|
Typeface typeface;
|
||||||
|
@Inject
|
||||||
FunctionsRegistry functionsRegistry;
|
FunctionsRegistry functionsRegistry;
|
||||||
@Inject
|
@Inject
|
||||||
VariablesRegistry variablesRegistry;
|
VariablesRegistry variablesRegistry;
|
||||||
@ -421,5 +424,11 @@ public class EditVariableFragment extends BaseDialogFragment implements View.OnF
|
|||||||
public boolean isVibrateOnKeypress() {
|
public boolean isVibrateOnKeypress() {
|
||||||
return keyboard.isVibrateOnKeypress();
|
return keyboard.isVibrateOnKeypress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Typeface getTypeface() {
|
||||||
|
return typeface;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user