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

Compare commits

..

9 Commits
1.8 ... master

Author SHA1 Message Date
6714018074 Merge branch '1.9_flags' of https://gitlab.com/mikhail.krupskiy/LayTray 2019-01-11 21:34:37 +03:00
Mikhail Krupskiy
8167c776d7 Ability to select an Icon instead of text. 2019-01-09 11:44:49 +00:00
d137306d09 Pushed version to 1.10 2018-09-18 15:07:32 +03:00
9c62b6a457 Cleaning up the translations and making Lint happy 2018-09-18 15:04:05 +03:00
bdd885de67 moved cs res to the /res folder 2018-09-18 14:55:47 +03:00
1358857959 Merged Czech translation
Updated build tools
2018-09-18 14:53:55 +03:00
630d19514d Merge branch 'master' into 'master'
l10n - added Czech localization

See merge request neothefox/LayTray!3
2018-09-18 10:26:37 +00:00
Pavel Borecki
8b11d25111 l10n - added Czech localization 2018-09-18 10:26:37 +00:00
e245cd7a62 Bumped version to 1.9 2018-07-28 16:47:55 +03:00
15 changed files with 264 additions and 19 deletions

View File

@ -6,8 +6,8 @@ android {
applicationId "space.neothefox.laytray"
minSdkVersion 23
targetSdkVersion 27
versionCode 9
versionName "1.8"
versionCode 11
versionName "1.10"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {

View File

@ -8,6 +8,7 @@ import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@ -33,6 +34,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
private final AccessibilityServiceInfo serviceInfo = new AccessibilityServiceInfo();
private SharedPreferences layouts;
private SharedPreferences iconsPrefs;
private SharedPreferences options;
private String lastToast;
@ -50,6 +52,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
serviceInfo.notificationTimeout = 100;
this.setServiceInfo(serviceInfo);
layouts = getSharedPreferences("layouts", 0);
iconsPrefs = getSharedPreferences("icons", 0);
options = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
lastToast = "EMPT";
options.registerOnSharedPreferenceChangeListener(this);
@ -90,11 +93,20 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
layoutsEditor.apply();
textIcon = "??";
}
Icon smallIcon = Icon.createWithBitmap(textAsBitmap(textIcon,
Integer.parseInt(options.getString("textSize", "48")),
options.getBoolean("textFakeBold", true),
Integer.parseInt(options.getString("textMode", "0")),
Color.WHITE));
Icon smallIcon;
if (Integer.parseInt(options.getString("textMode", "0")) == 4) {
// Icon selected
smallIcon = Icon.createWithResource(this, iconsPrefs.getInt(toast, R.drawable.ic_language_default));
} else {
// Text variations
smallIcon = Icon.createWithBitmap(textAsBitmap(textIcon,
Integer.parseInt(options.getString("textSize", "48")),
options.getBoolean("textFakeBold", true),
Integer.parseInt(options.getString("textMode", "0")),
Color.WHITE));
}
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
@ -104,6 +116,7 @@ implements SharedPreferences.OnSharedPreferenceChangeListener
.setOngoing(true)
.setVisibility(Notification.VISIBILITY_SECRET)
.build();
}
else
{

View File

@ -0,0 +1,56 @@
package space.neothefox.laytray;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.Spinner;
public class IconsAdapter extends BaseAdapter {
private Context context;
private int flags[];
private LayoutInflater inflter;
public IconsAdapter(Context applicationContext, int[] flags) {
this.context = applicationContext;
this.flags = flags;
inflter = (LayoutInflater.from(applicationContext));
}
@Override
public int getCount() {
return flags.length;
}
@Override
public Object getItem(int i) {
return flags[i];
}
@Override
public long getItemId(int i) {
return 0;
}
public int getPosition(int value) {
int position = -1;
for (int i = 0; i < flags.length; i++) {
if (value == flags[i]) {
position = i;
break;
}
}
return position;
}
@Override
public View getView(int i, View convertView, ViewGroup parent) {
convertView = inflter.inflate(R.layout.spinner_item, null);
ImageView icon = (ImageView) convertView.findViewById(R.id.imageView);
icon.setImageResource(flags[i]);
return convertView;
}
}

View File

@ -19,13 +19,14 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Space;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Map;
public class MainActivity extends AppCompatActivity
@ -35,6 +36,8 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
private LinearLayout layoutLister;
private SharedPreferences layouts;
private SharedPreferences iconsPrefs;
private boolean shouldRefresh = true;
@Override
protected void onCreate(Bundle savedInstanceState)
@ -43,6 +46,7 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
setContentView(R.layout.activity_main);
layoutLister = findViewById(R.id.scrollLinearLayout);
layouts = getSharedPreferences("layouts", 0);
iconsPrefs = getSharedPreferences("icons", 0);
updateLayouts();
FloatingActionButton addButton = findViewById(R.id.floatingActionButton);
@ -82,8 +86,13 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
entry.getValue().toString());
i++;
if(!entry.getKey().equals("EMPT"))
addLine(layoutLister, entry.getKey(), entry.getValue().toString());
if(!entry.getKey().equals("EMPT")) {
addLine(
layoutLister, entry.getKey(),
entry.getValue().toString(),
iconsPrefs.getInt(entry.getKey(), R.drawable.ic_language_default)
);
}
}
if(i == 0)
populateLayouts();
@ -97,14 +106,20 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
{
Log.d("map values", "Shared Prefs are empty");
SharedPreferences.Editor layoutsEditor = layouts.edit();
SharedPreferences.Editor iconsEditor = iconsPrefs.edit();
iconsEditor.clear();
layoutsEditor.clear();
layoutsEditor.putString("Русский", "RU");
layoutsEditor.putString("Буквы (АБВ)", "EN");
layoutsEditor.putString("EMPT", "??");
shouldRefresh = false;
iconsEditor.apply();
shouldRefresh = true;
layoutsEditor.apply();
}
private void addLine(LinearLayout parent, String name, String icon)
private void addLine(LinearLayout parent, String name, String icon, int iconDrawableId)
{
final LinearLayout layoutLine = new LinearLayout(getApplicationContext());
layoutLine.setOrientation(LinearLayout.HORIZONTAL);
@ -123,11 +138,29 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
layoutIcon.setText(icon);
layoutLine.addView(layoutIcon);
// Icons Dropdown
final int[] iconFlags = {
R.drawable.ic_language_default,
R.drawable.ic_flag_russia,
R.drawable.ic_flag_gb,
R.drawable.ic_flag_belarus,
R.drawable.ic_flag_ukr
};
IconsAdapter arrayAdapter = new IconsAdapter(this, iconFlags);
final Spinner iconSpinner = new Spinner(this);
iconSpinner.setAdapter(arrayAdapter);
iconSpinner.setSelection(arrayAdapter.getPosition(iconDrawableId));
layoutLine.addView(iconSpinner);
iconSpinner.setSelection(arrayAdapter.getPosition(iconDrawableId));
Space space = new Space(getApplicationContext());
space.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT, 2));
ViewGroup.LayoutParams.MATCH_PARENT, 2));
layoutLine.addView(space);
final Button removeButton = new Button(getApplicationContext());
removeButton.setText("");
removeButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
@ -155,23 +188,35 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
if (count != 0)
{
SharedPreferences.Editor layoutsEditor = layouts.edit();
SharedPreferences.Editor iconsEditor = iconsPrefs.edit();
layoutsEditor.clear();
iconsEditor.clear();
for (int i=0; i < count; i++)
{
LinearLayout layoutLine = (LinearLayout)parent.getChildAt(i);
TextView layoutName = (TextView)layoutLine.getChildAt(0);
EditText layoutIcon = (EditText)layoutLine.getChildAt(1);
Spinner layoutDropdown = (Spinner)layoutLine.getChildAt(2);
String layoutNameValue = layoutName.getText().toString();
String layoutIconValue = layoutIcon.getText().toString();
int layoutDropdownValue = (int)layoutDropdown.getSelectedItem();
if(!layoutNameValue.equals(""))
{
if(!layoutIconValue.equals(""))
if(!layoutIconValue.equals("")) {
layoutsEditor.putString(layoutNameValue, layoutIconValue);
else
iconsEditor.putInt(layoutNameValue, layoutDropdownValue);
} else {
layoutsEditor.putString(layoutNameValue, "??");
iconsEditor.putInt(layoutNameValue, layoutDropdownValue);
}
}
}
shouldRefresh = false;
iconsEditor.apply();
shouldRefresh = true;
layoutsEditor.apply();
} else {
populateLayouts();
}
}
@ -264,8 +309,11 @@ implements View.OnClickListener, DialogInterface.OnClickListener, SharedPreferen
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
layouts = getSharedPreferences("layouts", 0);
updateLayouts();
if (shouldRefresh) {
layouts = getSharedPreferences("layouts", 0);
iconsPrefs = getSharedPreferences("icons", 0);
updateLayouts();
}
}
private boolean isPackageInstalled(String packageName, PackageManager packageManager)

View File

@ -0,0 +1,6 @@
<vector android:height="24dp" android:viewportHeight="2"
android:viewportWidth="3" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#66000000" android:pathData="M0,1h3v0.75h-3z"/>
<path android:fillColor="#99000000" android:pathData="M0,0h3v1h-3z"/>
<path android:fillColor="#FF000000" android:pathData="M0,0h0.5v1.75h-3z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="32dp" android:viewportHeight="25.1"
android:viewportWidth="40.9" android:width="48dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M18,0h5v10h18v5H23.1a3,3 0,0 0,-0.3 0,0.6 0.6,0 0,0 0,0.2v9.9H18V15H0v-5h18a1,1 0,0 0,0 -0.1z"/>
<path android:fillColor="#99000000" android:pathData="M15.6,0v7a1.4,1.4 0,0 1,-0.3 -0.1L4.3,0.2 4.2,0zM36.7,0a2.8,2.8 0,0 1,-0.3 0.2L25.7,6.8l-0.4,0.3L25.3,0zM4.2,25a2,2 0,0 1,0.3 -0.1l10.8,-6.7 0.3,-0.2v7zM25.3,25v-6.9l0.3,0.1 10.9,6.7a1.6,1.6 0,0 1,0.2 0.2zM0,2.2l0.3,0.1 8.3,5.1v0.2L0,7.6zM41,7.6h-8.8l0.3,-0.2 8,-5a4,4 0,0 1,0.4 -0.2zM0,17.5h8.7a2.6,2.6 0,0 1,-0.2 0.2l-8.1,5a2.3,2.3 0,0 1,-0.4 0.2zM41,22.9a1.4,1.4 0,0 1,-0.3 -0.1l-8.3,-5.1 -0.1,-0.2h8.6z"/>
</vector>

View File

@ -0,0 +1,6 @@
<vector android:height="24dp" android:viewportHeight="512.001"
android:viewportWidth="512.001" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M512,200.093H0V97.104c0,-4.875 3.953,-8.828 8.828,-8.828h494.345c4.875,0 8.828,3.953 8.828,8.828L512,200.093L512,200.093z"/>
<path android:fillColor="#88000000" android:pathData="M503.172,423.725H8.828c-4.875,0 -8.828,-3.953 -8.828,-8.828V311.909h512v102.988C512,419.773 508.047,423.725 503.172,423.725z"/>
<path android:fillColor="#22000000" android:pathData="M0,200.091h512v111.81h-512z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="2"
android:viewportWidth="3" android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#88000000" android:pathData="M0,1h3v1h-3z"/>
<path android:fillColor="#FF000000" android:pathData="M0,0h3v1h-3z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM18.92,8h-2.95c-0.32,-1.25 -0.78,-2.45 -1.38,-3.56 1.84,0.63 3.37,1.91 4.33,3.56zM12,4.04c0.83,1.2 1.48,2.53 1.91,3.96h-3.82c0.43,-1.43 1.08,-2.76 1.91,-3.96zM4.26,14C4.1,13.36 4,12.69 4,12s0.1,-1.36 0.26,-2h3.38c-0.08,0.66 -0.14,1.32 -0.14,2 0,0.68 0.06,1.34 0.14,2L4.26,14zM5.08,16h2.95c0.32,1.25 0.78,2.45 1.38,3.56 -1.84,-0.63 -3.37,-1.9 -4.33,-3.56zM8.03,8L5.08,8c0.96,-1.66 2.49,-2.93 4.33,-3.56C8.81,5.55 8.35,6.75 8.03,8zM12,19.96c-0.83,-1.2 -1.48,-2.53 -1.91,-3.96h3.82c-0.43,1.43 -1.08,2.76 -1.91,3.96zM14.34,14L9.66,14c-0.09,-0.66 -0.16,-1.32 -0.16,-2 0,-0.68 0.07,-1.35 0.16,-2h4.68c0.09,0.65 0.16,1.32 0.16,2 0,0.68 -0.07,1.34 -0.16,2zM14.59,19.56c0.6,-1.11 1.06,-2.31 1.38,-3.56h2.95c-0.96,1.65 -2.49,2.93 -4.33,3.56zM16.36,14c0.08,-0.66 0.14,-1.32 0.14,-2 0,-0.68 -0.06,-1.34 -0.14,-2h3.38c0.16,0.64 0.26,1.31 0.26,2s-0.1,1.36 -0.26,2h-3.38z"/>
</vector>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="5dp"
android:src="@drawable/ic_info_black_24dp" />
<!--
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:text="Icon"
android:textColor="#000" />
-->
</LinearLayout>

View File

@ -37,12 +37,14 @@
<item>Тэкст у крузе</item>
<item>Тэкст у квадраце</item>
<item>Тэкст у квадраце з абрысам</item>
<item>Іконка</item>
</string-array>
<string-array name="pref_notification_mode_list_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string name="pref_title_icon_builder">Рэдактар іконак</string>
@ -57,4 +59,5 @@
<string name="close">Зачыніць</string>
<string name="unsupported_device">Тэлефон не падтрымліваецца</string>
<string name="title_icon_channel">онкa раскладкі</string>
<string name="unsupported_device_description">Гэты тэлефон не хапае клавіятуры BlackBerry. LayTray не будзе працаваць без яго.</string>
</resources>

View File

@ -0,0 +1,64 @@
<resources>
<string name="service_description">Jednoduchá ikona rozvržení klávesnice</string>
<string name="accessibility_summary">LayTray je třeba zapnout v aplikaci zpřístupnění, protože jediný způsob, jak na Android zjistit rozvržení, je sledovat oznámení Toast. LayTray nemůže vidět co píšete a neodesílá žádná data o vaší aktivitě třetím stranám</string>
<string name="activity_info">Přiřadit název k ikoně rozvržení</string>
<string name="title_activity_settings">Nastavení</string>
<string name="toast_enableme">Je třeba službu zapnout!</string>
<string name="unsupported_device">Nepodporovaný telefon</string>
<string name="unsupported_device_description">Tento telefon postrádá BlackBerry klávesnici. LayTray bez ní nefunguje.</string>
<string name="close">Zavřít</string>
<string name="toast_saved">Uloženo</string>
<string name="title_icon_channel">Ikona rozvržení klávesnice</string>
<!-- Strings related to Settings -->
<!-- Example General settings -->
<string name="pref_header_general">Obecné</string>
<string name="pref_title_default_app_name">Aplikace pro dohlížení</string>
<string-array name="pref_default_app_name_list_titles">
<item>klávesnice Blackberry</item>
</string-array>
<string-array name="pref_default_app_name_list_values">
<item>com.blackberry.keyboard</item>
</string-array>
<string name="pref_title_notification_importance">Důležitost oznámení</string>
<string-array name="pref_notification_importance_list_titles">
<item>Výchozí</item>
<item>Vysoká</item>
<item>Nízká</item>
<item>Min</item>
</string-array>
<string-array name="pref_notification_importance_list_values">
<item>0</item>
<item>1</item>
<item>-1</item>
<item>-2</item>
</string-array>
<string name="pref_title_notification_mode">Notification shape</string>
<string-array name="pref_notification_mode_list_titles">
<item>Samotný text</item>
<item>Text v kruhu</item>
<item>Text ve čtverci</item>
<item>Text v obrysu čtverce</item>
<item>Ikona</item>
</string-array>
<string-array name="pref_notification_mode_list_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string name="pref_title_icon_builder">Vytváření ikony</string>
<!-- Example settings for Notifications -->
<string name="pref_header_notifications">Oznamování</string>
<string name="pref_title_text_fake_bold">Tučně</string>
<string name="pref_title_text_size">Velikost textu</string>
<string name="title_about">O aplikaci</string>
</resources>

View File

@ -37,12 +37,14 @@
<item>Текст в круге</item>
<item>Текст в квадрате</item>
<item>Текст в квадрате с обводкой</item>
<item>Иконка</item>
</string-array>
<string-array name="pref_notification_mode_list_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string name="pref_title_icon_builder">Редактор иконок</string>
@ -57,4 +59,5 @@
<string name="close">Закрыть</string>
<string name="unsupported_device">Телефон не поддерживается</string>
<string name="title_icon_channel">Иконка раскладки</string>
<string name="unsupported_device_description">На этом телефоне отсутствует клавиатура BlackBerry. LayTray не будет работать без него.</string>
</resources>

View File

@ -6,7 +6,7 @@
<string name="title_activity_settings">Settings</string>
<string name="toast_enableme">You have to enable the service!</string>
<string name="unsupported_device">Unsupported phone</string>
<string name="unsupported_device_description" translatable="false">This phone is missing the BlackBerry Keyboard. LayTray will not work without it.</string>
<string name="unsupported_device_description">This phone is missing the BlackBerry Keyboard. LayTray will not work without it.</string>
<string name="close">Close</string>
<string name="toast_saved">Saved</string>
<string name="title_icon_channel">Layout icon</string>
@ -43,12 +43,14 @@
<item>Text in circle</item>
<item>Text in a square</item>
<item>Text in a square outline</item>
<item>Icon</item>
</string-array>
<string-array name="pref_notification_mode_list_values">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string name="pref_title_icon_builder">Icon builder</string>
@ -64,5 +66,6 @@
Distributed on the terms of GNU GPLv3 licence \n
\n
Translated by:\n
Belarusian - Edward Asviacinski</string>
Belarusian - Edward Asviacinski\n
Czech - Pavel Borecki</string>
</resources>

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong