HPlus: Detect Zeband Plus Unicode Support
This commit is contained in:
parent
497f9a6658
commit
8a39d8b2eb
|
@ -132,6 +132,7 @@ public final class HPlusConstants {
|
||||||
public static final String PREF_HPLUS_WRIST = "hplus_wrist";
|
public static final String PREF_HPLUS_WRIST = "hplus_wrist";
|
||||||
public static final String PREF_HPLUS_SIT_START_TIME = "hplus_sit_start_time";
|
public static final String PREF_HPLUS_SIT_START_TIME = "hplus_sit_start_time";
|
||||||
public static final String PREF_HPLUS_SIT_END_TIME = "hplus_sit_end_time";
|
public static final String PREF_HPLUS_SIT_END_TIME = "hplus_sit_end_time";
|
||||||
|
public static final String PREF_HPLUS_UNICODE = "hplus_unicode";
|
||||||
|
|
||||||
public static final Map<Character, byte[]> transliterateMap = new HashMap<Character, byte[]>(){
|
public static final Map<Character, byte[]> transliterateMap = new HashMap<Character, byte[]>(){
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.bluetooth.le.ScanFilter;
|
import android.bluetooth.le.ScanFilter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.ParcelUuid;
|
import android.os.ParcelUuid;
|
||||||
|
@ -281,4 +282,13 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator {
|
||||||
return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_END_TIME, 0);
|
return prefs.getInt(HPlusConstants.PREF_HPLUS_SIT_END_TIME, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setUnicodeSupport(String address, boolean state){
|
||||||
|
SharedPreferences.Editor editor = prefs.getPreferences().edit();
|
||||||
|
editor.putBoolean(HPlusConstants.PREF_HPLUS_UNICODE + "_" + address, state);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getUnicodeSupport(String address){
|
||||||
|
return (prefs.getBoolean(HPlusConstants.PREF_HPLUS_UNICODE, false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,13 +501,18 @@ class HPlusHandlerThread extends GBDeviceIoThread {
|
||||||
if(data.length >= 11){
|
if(data.length >= 11){
|
||||||
major = data[10] & 0xFF;
|
major = data[10] & 0xFF;
|
||||||
minor = data[9] & 0xFF;
|
minor = data[9] & 0xFF;
|
||||||
|
|
||||||
|
int hwMajor = data[2] & 0xFF;
|
||||||
|
int hwMinor = data[1] & 0xFF;
|
||||||
|
|
||||||
|
getDevice().setFirmwareVersion2(hwMajor + "." + hwMinor);
|
||||||
|
mHPlusSupport.setUnicodeSupport((data[3] != 0));
|
||||||
}else {
|
}else {
|
||||||
major = data[2] & 0xFF;
|
major = data[2] & 0xFF;
|
||||||
minor = data[1] & 0xFF;
|
minor = data[1] & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
getDevice().setFirmwareVersion(major + "." + minor);
|
getDevice().setFirmwareVersion(major + "." + minor);
|
||||||
|
|
||||||
getDevice().sendDeviceUpdateIntent(getContext());
|
getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -660,6 +660,10 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUnicodeSupport(boolean support){
|
||||||
|
HPlusCoordinator.setUnicodeSupport(gbDevice.getAddress(), support);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showIncomingCall(String name, String rawNumber) {
|
private void showIncomingCall(String name, String rawNumber) {
|
||||||
try {
|
try {
|
||||||
|
@ -737,6 +741,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
|
|
||||||
int length = messageBytes.length / 17;
|
int length = messageBytes.length / 17;
|
||||||
|
|
||||||
|
length = length > 5 ? 5 : length;
|
||||||
|
|
||||||
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_INCOMING_MESSAGE, HPlusConstants.ARG_INCOMING_MESSAGE});
|
builder.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_INCOMING_MESSAGE, HPlusConstants.ARG_INCOMING_MESSAGE});
|
||||||
|
|
||||||
int remaining = Math.min(255, (messageBytes.length % 17 > 0) ? length + 1 : length);
|
int remaining = Math.min(255, (messageBytes.length % 17 > 0) ? length + 1 : length);
|
||||||
|
@ -808,10 +814,10 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||||
cs = HPlusConstants.transliterateMap.get(c);
|
cs = HPlusConstants.transliterateMap.get(c);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (HPlusCoordinator.getLanguage(this.gbDevice.getAddress()) == HPlusConstants.ARG_LANGUAGE_CN)
|
if(HPlusCoordinator.getUnicodeSupport(this.gbDevice.getAddress()))
|
||||||
cs = c.toString().getBytes("GB2312");
|
cs = c.toString().getBytes("Unicode");
|
||||||
else
|
else
|
||||||
cs = c.toString().getBytes("UTF-8");
|
cs = c.toString().getBytes("GB2312");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
//Fallback. Result string may be strange, but better than nothing
|
//Fallback. Result string may be strange, but better than nothing
|
||||||
cs = c.toString().getBytes();
|
cs = c.toString().getBytes();
|
||||||
|
|
Loading…
Reference in New Issue