mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Transliterate unsupported Russian characters into English
This commit is contained in:
parent
38e234552d
commit
c873312831
@ -77,6 +77,7 @@ dependencies {
|
||||
compile 'org.apache.commons:commons-lang3:3.4'
|
||||
|
||||
// compile project(":DaoCore")
|
||||
compile 'com.google.guava:guava:19.0'
|
||||
}
|
||||
|
||||
preBuild.dependsOn(":GBDaoGenerator:genSources")
|
||||
|
@ -14,6 +14,8 @@ import android.net.Uri;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -21,6 +23,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.hplus.HPlusConstants;
|
||||
@ -646,6 +649,7 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
private void showIncomingCall(String name, String number) {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("incomingCallIcon");
|
||||
name = transliterate(name);
|
||||
|
||||
//Enable call notifications
|
||||
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_ACTION_INCOMING_CALL, 1});
|
||||
@ -703,6 +707,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
LOG.debug("Show Notification: "+title+" --> "+body);
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("notification");
|
||||
title = transliterate(title);
|
||||
body = transliterate(body);
|
||||
|
||||
byte[] msg = new byte[20];
|
||||
for (int i = 0; i < msg.length; i++)
|
||||
@ -777,6 +783,49 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
//replace unsupported symbols to english analog
|
||||
private String transliterate(String txt){
|
||||
StringBuilder message = new StringBuilder();
|
||||
char[] chars = txt.toCharArray();
|
||||
|
||||
for (char c : chars)
|
||||
{
|
||||
message.append(transliterate(c));
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
//replace unsupported symbol to english analog text
|
||||
private String transliterate(char c){
|
||||
Map<Character, String> map = ImmutableMap.<Character, String>builder()
|
||||
.put('а', "a").put('б', "b").put('в', "v").put('г', "g")
|
||||
.put('д', "d").put('е', "e").put('ё', "jo").put('ж', "zh")
|
||||
.put('з', "z").put('и', "i").put('й', "jj").put('к', "k")
|
||||
.put('л', "l").put('м', "m").put('н', "n").put('о', "o")
|
||||
.put('п', "p").put('р', "r").put('с', "s").put('т', "t")
|
||||
.put('у', "u").put('ф', "f").put('х', "kh").put('ц', "c")
|
||||
.put('ч', "ch").put('ш', "sh").put('щ', "shh").put('ъ', "\"")
|
||||
.put('ы', "y").put('ь', "'").put('э', "eh").put('ю', "ju")
|
||||
.put('я', "ja")
|
||||
.build();
|
||||
|
||||
char lowerChar = Character.toLowerCase(c);
|
||||
|
||||
if (map.containsKey(lowerChar)) {
|
||||
String replace = map.get(lowerChar);
|
||||
|
||||
if (lowerChar != c)
|
||||
{
|
||||
return replace.toUpperCase();
|
||||
}
|
||||
|
||||
return replace;
|
||||
}
|
||||
|
||||
return String.valueOf(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
||||
BluetoothGattCharacteristic characteristic) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
<change>HPlus: Near real time Heart rate measurement</change>
|
||||
<change>HPlus: Experimental synchronization of activity data (only sleep, steps and intensity)</change>
|
||||
<change>HPlus: Fix some disconnection issues</change>
|
||||
<change>HPlus: Transliterate unsupported Russian characters into English</change>
|
||||
</release>
|
||||
<release version="0.16.0" versioncode="80">
|
||||
<change>New devices: HPlus (e.g. Zeblaze ZeBand), contributed by João Paulo Barraca</change>
|
||||
|
Loading…
Reference in New Issue
Block a user