1
0
mirror of https://gitlab.com/neothefox/LayTray synced 2026-03-23 21:54:54 +03:00

Improved icon visibility

Now a new unknown layout is going to be added automatically
Added summary
This commit is contained in:
NeoTheFox 2018-07-06 11:17:06 +03:00
parent 6f70fc1a23
commit 03bb19a559
3 changed files with 17 additions and 4 deletions

View File

@ -20,6 +20,7 @@
android:name=".IconService"
android:enabled="true"
android:exported="true"
android:summary="A simple keyboard layout indicator for physical keyboards"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>

View File

@ -50,15 +50,23 @@ implements SharedPreferences.OnSharedPreferenceChangeListener{
protected void updateNotification(String toast)
{
Notification icon;
Icon smallIcon = Icon.createWithBitmap(textAsBitmap(layouts.getString(toast, "??"), 30, Color.WHITE));
Notification indicator;
String textIcon = layouts.getString(toast,"EMPT");
if(textIcon == "EMPT")
{
SharedPreferences.Editor layoutsEditor = layouts.edit();
layoutsEditor.putString(toast, "??");
layoutsEditor.commit();
textIcon = "??";
}
Icon smallIcon = Icon.createWithBitmap(textAsBitmap(textIcon, 48, Color.WHITE));
icon = new Notification.Builder(this)
indicator = new Notification.Builder(this)
.setSmallIcon(smallIcon)
.setContentTitle(toast)
.setOngoing(true)
.build();
iconManager.notify(0, icon);
iconManager.notify(0, indicator);
return;
}
@ -66,6 +74,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener{
public Bitmap textAsBitmap(String text, float textSize, int textColor) {
Paint paint = new Paint(ANTI_ALIAS_FLAG);
paint.setTextSize(textSize);
paint.setFakeBoldText(true);
paint.setColor(textColor);
paint.setTextAlign(Paint.Align.LEFT);
float baseline = -paint.ascent(); // ascent() is negative

View File

@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
</resources>