Skip to content

Commit

Permalink
Change button font for key mapping screen
Browse files Browse the repository at this point in the history
  • Loading branch information
woesss committed Apr 26, 2024
1 parent ee3ec23 commit 694eb8f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 Yury Kharchenko
* Copyright 2020-2024 Yury Kharchenko
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,23 +16,23 @@

package javax.microedition.lcdui.graphics;

import android.content.res.Resources;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Typeface;
import android.os.Build;
import android.util.TypedValue;

import androidx.core.content.res.ResourcesCompat;

import javax.microedition.lcdui.Image;
import javax.microedition.util.ContextHolder;

public class CanvasWrapper {
private static final float TEXT_SIZE_KEYBOARD = 22;
import ru.playsoftware.j2meloader.R;

public class CanvasWrapper {
private final Paint drawPaint = new Paint();
private final Paint fillPaint = new Paint();
private final Paint textPaint = new Paint();
Expand All @@ -52,10 +52,9 @@ public CanvasWrapper(boolean filterBitmap) {
fillPaint.setStyle(Paint.Style.FILL);

// init text paint
Resources res = ContextHolder.getAppContext().getResources();
Typeface typeface = Typeface.createFromAsset(res.getAssets(), "Roboto-Regular.ttf");
textPaint.setTypeface(typeface);
textSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE_KEYBOARD, res.getDisplayMetrics());
Context context = ContextHolder.getAppContext();
textPaint.setTypeface(ResourcesCompat.getFont(context, R.font.roboto_regular));
textSize = context.getResources().getDimension(R.dimen._22sp);
textPaint.setTextSize(textSize);
textPaint.setTextAlign(Paint.Align.CENTER);
textAscent = textPaint.ascent();
Expand Down
File renamed without changes.
54 changes: 51 additions & 3 deletions app/src/main/res/layout/activity_keymapper.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:layout_height="match_parent"
android:layout_width="match_parent">

<ScrollView
android:layout_width="match_parent"
Expand All @@ -30,6 +30,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_a"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -38,6 +40,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_menu"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -46,6 +50,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_b"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />
</LinearLayout>

Expand All @@ -65,6 +71,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_left_soft"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -73,6 +81,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_up"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -81,6 +91,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_right_soft"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand All @@ -96,6 +108,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_left"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -104,6 +118,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_f"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -112,6 +128,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_right"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand All @@ -127,6 +145,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_d"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -135,6 +155,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_down"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -143,6 +165,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_c"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand All @@ -159,6 +183,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_1"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -167,6 +193,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_2"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -175,6 +203,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_3"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand All @@ -190,6 +220,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_4"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -198,6 +230,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_5"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -206,6 +240,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_6"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand All @@ -221,6 +257,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_7"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -229,6 +267,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_8"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -237,6 +277,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_9"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand All @@ -252,6 +294,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_star"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -260,6 +304,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_0"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

<Button
Expand All @@ -268,6 +314,8 @@
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:text="@string/virtual_key_pound"
android:textSize="@dimen/_22sp"
app:fontFamily="@font/roboto_regular"
tools:ignore="ButtonStyle" />

</LinearLayout>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="height_config_row">48dp</dimen>
<dimen name="_22sp">22sp</dimen>
</resources>

0 comments on commit 694eb8f

Please sign in to comment.