352 lines
15 KiB
Java
352 lines
15 KiB
Java
package cn.trans88.taxiappkotlin;
|
|
|
|
import android.content.Context;
|
|
import android.util.Log;
|
|
|
|
import cn.trans88.taxiappkotlin.util.YoungUtil;
|
|
|
|
public class Configurations {
|
|
private Context context;
|
|
|
|
private static Configurations cfg;
|
|
private Configurations(Context c){
|
|
context = c;
|
|
}
|
|
|
|
public static Configurations config(Context c){
|
|
if(cfg == null)
|
|
cfg = new Configurations(c);
|
|
return cfg;
|
|
}
|
|
|
|
//将老的cn.trans88.taxiappkotlin.logic.Settings
|
|
public void init(){
|
|
|
|
boolean init = context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("init", false);
|
|
if(init) return;
|
|
|
|
boolean firstReg = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("isFirstRegister", true);
|
|
if(firstReg){
|
|
YoungUtil.YoungLog("first register");
|
|
YoungUtil.YoungLog("cannot read file :cn.trans88.taxiappkotlin.logic.Settings");
|
|
registerTokenSave("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWY4OTNiODE1NzIzMDk0YWQzZmM5MTI0IiwiZ3JvdXBfaWQiOiI1Zjg5M2I4MTU3MjMwOTRhZDNmYzkxMjYiLCJ1c2VyX2lkIjoiNWY4OTNiODE1NzIzMDk0YWQzZmM5MTI1In0.o2M6CE2yFi7dvjILb485sQF436eMDdKwzTryK4rw3W0");
|
|
appTokenSave("");
|
|
companySave(TaxiApp.Companion.getSANLE());
|
|
syncSave(true);
|
|
logServiceUrlSave("http://taxihub.cn:2348/");
|
|
connServiceUrlSave("");
|
|
screenSizeXSave(160);
|
|
screenSizeYSave(64);
|
|
taxiInfoSave("");
|
|
cardIdSave( "");
|
|
taxiServiceUrlSave( "");
|
|
downloadUrlSave( "");
|
|
accountIdSave( "");
|
|
taxiBaseUrlSave("http://taxihub.cn:2346/");
|
|
isDeleteOldAdvitiseSave( false);
|
|
isFirstRegisterSave(true);
|
|
enableWriteLogSave( false);
|
|
advertiseOrderSave( "");
|
|
loggerSwitchSave(false);
|
|
gpsSwitchSave(false);
|
|
upload_debug_file_urlSave("http://taxihub.cn:2345/postDebugFile");
|
|
}else{
|
|
YoungUtil.YoungLog("copy configurations");
|
|
YoungUtil.YoungLog("read file :cn.trans88.taxiappkotlin.logic.Settings OK");
|
|
String registerToken = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("registerToken", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWY4OTNiODE1NzIzMDk0YWQzZmM5MTI0IiwiZ3JvdXBfaWQiOiI1Zjg5M2I4MTU3MjMwOTRhZDNmYzkxMjYiLCJ1c2VyX2lkIjoiNWY4OTNiODE1NzIzMDk0YWQzZmM5MTI1In0.o2M6CE2yFi7dvjILb485sQF436eMDdKwzTryK4rw3W0");
|
|
String appToken = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("appToken", "");
|
|
String company = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("company", TaxiApp.Companion.getSANLE());
|
|
boolean sync = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("sync", true);
|
|
String logServiceUrl = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("logServiceUrl", "http://taxihub.cn:2348/");
|
|
String connServiceUrl = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("connServiceUrl", "");
|
|
int x = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getInt("screenSizeX", 160);
|
|
int y = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getInt("screenSizeY", 64);
|
|
String taxiInfo = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("taxiInfo", "");
|
|
String cardId = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("cardId", "");
|
|
String taxiServiceUrl = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("taxiServiceUrl", "");
|
|
String downloadUrl = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("downloadUrl", "");
|
|
String accountId = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("accountId", "");
|
|
String taxiBaseUrl = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("taxiBaseUrl", "http://taxihub.cn:2346/");
|
|
boolean isDeleteOldAdvitise = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("isDeleteOldAdvitise", false);
|
|
boolean isFirstRegister = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("isFirstRegister", true);
|
|
boolean enableWriteLog = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("enableWriteLog", false);
|
|
boolean loggerSwitch = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("loggerSwitch", true);
|
|
boolean gpsSwitch = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getBoolean("gpsSwitch", true);
|
|
String upload_debug_file_url = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("upload_debug_file_url", "http://taxihub.cn:2345/postDebugFile");
|
|
String advertiseOrder = context.getSharedPreferences("cn.trans88.taxiappkotlin.logic.Settings", Context.MODE_PRIVATE).getString("advertiseOrder", "");
|
|
|
|
/*YoungUtil.YoungLog("yzd", registerToken);
|
|
YoungUtil.YoungLog("yzd", appToken);
|
|
YoungUtil.YoungLog("yzd", company);
|
|
YoungUtil.YoungLog("yzd", "" +sync);
|
|
YoungUtil.YoungLog("yzd", logServiceUrl);
|
|
YoungUtil.YoungLog("yzd", connServiceUrl);
|
|
YoungUtil.YoungLog("yzd", "" +x);
|
|
YoungUtil.YoungLog("yzd", "" + y);
|
|
YoungUtil.YoungLog("yzd", taxiInfo);
|
|
YoungUtil.YoungLog("yzd", cardId);
|
|
YoungUtil.YoungLog("yzd", taxiServiceUrl);
|
|
YoungUtil.YoungLog("yzd", downloadUrl);
|
|
YoungUtil.YoungLog("yzd", accountId);
|
|
YoungUtil.YoungLog("yzd", taxiBaseUrl);
|
|
YoungUtil.YoungLog("yzd", "" + isDeleteOldAdvitise);
|
|
YoungUtil.YoungLog("yzd", "" + isFirstRegister);
|
|
YoungUtil.YoungLog("yzd", "" + enableWriteLog);
|
|
YoungUtil.YoungLog("yzd", advertiseOrder);
|
|
YoungUtil.YoungLog("yzd", "" + loggerSwitch);
|
|
YoungUtil.YoungLog("yzd", "" + gpsSwitch);
|
|
YoungUtil.YoungLog("yzd", "" + upload_debug_file_url);
|
|
*/
|
|
|
|
registerTokenSave(registerToken);
|
|
appTokenSave(appToken);
|
|
companySave(company);
|
|
syncSave(sync);
|
|
logServiceUrlSave(logServiceUrl);
|
|
connServiceUrlSave(connServiceUrl);
|
|
screenSizeXSave(x);
|
|
screenSizeYSave(y);
|
|
taxiInfoSave(taxiInfo);
|
|
cardIdSave(cardId);
|
|
taxiServiceUrlSave(taxiServiceUrl);
|
|
downloadUrlSave(downloadUrl);
|
|
accountIdSave(accountId);
|
|
taxiBaseUrlSave(taxiBaseUrl);
|
|
isDeleteOldAdvitiseSave(isDeleteOldAdvitise);
|
|
isFirstRegisterSave(isFirstRegister);
|
|
enableWriteLogSave(enableWriteLog);
|
|
advertiseOrderSave(advertiseOrder);
|
|
loggerSwitchSave(loggerSwitch);
|
|
gpsSwitchSave(gpsSwitch);
|
|
upload_debug_file_urlSave(upload_debug_file_url);
|
|
}
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("init", true).apply();
|
|
}
|
|
|
|
|
|
public String registerToken(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("registerToken", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50X2lkIjoiNWY4OTNiODE1NzIzMDk0YWQzZmM5MTI0IiwiZ3JvdXBfaWQiOiI1Zjg5M2I4MTU3MjMwOTRhZDNmYzkxMjYiLCJ1c2VyX2lkIjoiNWY4OTNiODE1NzIzMDk0YWQzZmM5MTI1In0.o2M6CE2yFi7dvjILb485sQF436eMDdKwzTryK4rw3W0");
|
|
}
|
|
|
|
public void registerTokenSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("registerToken", s).apply();
|
|
}
|
|
|
|
public String appToken(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("appToken", "");
|
|
}
|
|
|
|
public void appTokenSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("appToken", s).apply();
|
|
}
|
|
|
|
public String company(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("company", TaxiApp.Companion.getSANLE());
|
|
}
|
|
|
|
public void companySave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("company", s).apply();
|
|
}
|
|
|
|
public boolean sync(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("sync", true);
|
|
}
|
|
|
|
public void syncSave(Boolean b){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("sync", b).apply();
|
|
}
|
|
|
|
public String logServiceUrl(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("logServiceUrl", "http://taxihub.cn:2348/");
|
|
}
|
|
|
|
public void logServiceUrlSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("logServiceUrl", s).apply();
|
|
}
|
|
|
|
public String connServiceUrl(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("connServiceUrl", "");
|
|
}
|
|
|
|
public void connServiceUrlSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("connServiceUrl", s).apply();
|
|
}
|
|
|
|
public int screenSizeX(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getInt("screenSizeX", 160);
|
|
}
|
|
|
|
public void screenSizeXSave(int x){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putInt("screenSizeX", x).apply();
|
|
}
|
|
|
|
public int screenSizeY(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getInt("screenSizeY", 64);
|
|
}
|
|
|
|
public void screenSizeYSave(int y){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putInt("screenSizeY", y).apply();
|
|
}
|
|
|
|
public String taxiInfo(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("taxiInfo", "");
|
|
}
|
|
|
|
public void taxiInfoSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("taxiInfo", s).apply();
|
|
}
|
|
|
|
public String cardId(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("cardId", "");
|
|
}
|
|
|
|
public void cardIdSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("cardId", s).apply();
|
|
}
|
|
|
|
public String taxiServiceUrl(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("taxiServiceUrl", "");
|
|
}
|
|
|
|
public void taxiServiceUrlSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("taxiServiceUrl", s).apply();
|
|
}
|
|
|
|
public String downloadUrl(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("downloadUrl", "");
|
|
}
|
|
|
|
public void downloadUrlSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("downloadUrl", s).apply();
|
|
}
|
|
|
|
public String accountId(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("accountId", "");
|
|
}
|
|
|
|
public void accountIdSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("accountId", s).apply();
|
|
}
|
|
|
|
public String taxiBaseUrl(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("taxiBaseUrl", "http://taxihub.cn:2346/");
|
|
}
|
|
|
|
public void taxiBaseUrlSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("taxiBaseUrl", s).apply();
|
|
}
|
|
|
|
public boolean isDeleteOldAdvitise(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("isDeleteOldAdvitise", false);
|
|
}
|
|
|
|
public void isDeleteOldAdvitiseSave(boolean b){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("isDeleteOldAdvitise", b).apply();
|
|
}
|
|
|
|
public boolean isFirstRegister(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("isFirstRegister", true);
|
|
}
|
|
|
|
public void isFirstRegisterSave(boolean b){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("isFirstRegister", b).apply();
|
|
}
|
|
public boolean enableWriteLog(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("enableWriteLog", false);
|
|
}
|
|
|
|
public void enableWriteLogSave(boolean b){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("enableWriteLog", b).apply();
|
|
}
|
|
public boolean loggerSwitch(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("loggerSwitch", false);
|
|
}
|
|
|
|
public void loggerSwitchSave(boolean b){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("loggerSwitch", b).apply();
|
|
}
|
|
public boolean gpsSwitch(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("gpsSwitch", false);
|
|
}
|
|
|
|
public void gpsSwitchSave(boolean b){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("gpsSwitch", b).apply();
|
|
}
|
|
|
|
public String advertiseOrder(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("advertiseOrder", "");
|
|
}
|
|
|
|
public void advertiseOrderSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("advertiseOrder", s).apply();
|
|
}
|
|
|
|
public String upload_debug_file_url(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("upload_debug_file_url", "http://lichenplatform:2345/postDebugFile");
|
|
}
|
|
|
|
public void upload_debug_file_urlSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("upload_debug_file_url", s).apply();
|
|
}
|
|
|
|
/**
|
|
* 当前TaxiApp播放的是否是定时广告
|
|
* @return
|
|
*/
|
|
public Boolean isTimedAdvertise(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getBoolean("isTimedAdvertise", false);
|
|
}
|
|
|
|
/**
|
|
* 当前TaxiApp播放的是否是定时广告
|
|
* @param s
|
|
*/
|
|
public void isTimedAdvertiseSave(Boolean s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putBoolean("isTimedAdvertise", s).apply();
|
|
}
|
|
|
|
public String timedAdList(){
|
|
return context.getSharedPreferences("config", Context.MODE_PRIVATE).getString("timedAdList", "");
|
|
}
|
|
|
|
public void timedAdListSave(String s){
|
|
context.getSharedPreferences("config", Context.MODE_PRIVATE).edit().putString("timedAdList", s).apply();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|