Commit 88c9d5e2 by zhengnw@sobot.com

common 只是gson、net、utils、sobot_pictureframe的集合,所有的ui相关的都放到widget里

parent c4d4b0ac
package com.sobot.moduletest;
import static com.sobot.common.ui.SobotBaseConstant.REQUEST_CODE_PICTURE;
import static com.sobot.widget.ui.SobotBaseConstant.REQUEST_CODE_PICTURE;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.widget.ImageView;
import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.ui.base.SobotBaseActivity;
import com.sobot.common.ui.toast.SobotToastUtil;
import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotImageUtils;
import com.sobot.network.apiUtils.SobotHttpUtils;
import com.sobot.network.http.HttpBaseUtils;
import com.sobot.pictureframe.SobotBitmapUtil;
import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotSDCardUtils;
import com.sobot.widget.SobotWidgetApi;
import com.sobot.widget.image.photoview.SobotPhotoView;
import com.sobot.widget.loading.SobotLoadingLayout;
import com.sobot.widget.refresh.layout.api.RefreshLayout;
import com.sobot.widget.refresh.layout.footer.ClassicsFooter;
import com.sobot.widget.refresh.layout.header.ClassicsHeader;
import com.sobot.widget.ui.SobotMarkConfig;
import com.sobot.widget.ui.base.SobotBaseActivity;
import com.sobot.widget.ui.toast.SobotToastUtil;
import java.io.File;
import java.util.HashMap;
......@@ -44,7 +44,7 @@ public class MainActivity extends SobotBaseActivity {
protected void initView() {
SobotToastUtil.showCustomToast(getSobotBaseActivity(), "sdafdsafsadfasdfsdaf");
SobotCommonApi.setSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP, true);
SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP, true);
setTitle("ddddd");
SobotBitmapUtil.display(getSobotBaseActivity(), "https://img.sobot.com/console/common/face/admin.png", getAvatarImageView(true));
img = findViewById(R.id.img);
......
......@@ -2,8 +2,9 @@ package com.sobot.moduletest;
import android.support.multidex.MultiDexApplication;
import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.utils.SobotCommonApi;
import com.sobot.widget.SobotWidgetApi;
import com.sobot.widget.ui.SobotMarkConfig;
/**
* @Description: java类作用描述
......@@ -18,11 +19,10 @@ public class MyApp extends MultiDexApplication {
// Fresco.initialize(this);
// 主要是添加下面这句代码
// MultiDex.install(this);
SobotCommonApi.init(this,"https://sobot.com");
SobotCommonApi.init(this, "https://sobot.com");
SobotCommonApi.setShowLogDebug(true);
SobotCommonApi.setSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN,false);
SobotCommonApi.setSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH,false);
SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN, false);
SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH, false);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
......@@ -14,8 +14,8 @@ buildscript {
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
......
......@@ -8,12 +8,25 @@ android {
defaultConfig {
minSdkVersion 14
}
//这里就是打jar包
task makeJar(type: Copy) {
//删除旧的jar包
delete 'build/libs/sobot_common_1.2.6.jar'
//原地址
from('build/intermediates/packaged-classes/release/')
//导出jar包的地址
into('build/libs/')
//包含的jar包
include('classes.jar')
//重命名jar包为mysdk
rename ('classes.jar', 'sobot_common_1.2.6.jar')
}
makeJar.dependsOn(build)
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
compileOnly 'com.squareup.okhttp3:okhttp:3.12.0'
compileOnly 'com.android.support:appcompat-v7:28.0.0'
// api project(':sobot_utils')
// api project(':sobot_pictureframe')
// api project(':sobot_network')
......
......@@ -13,7 +13,7 @@ ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'sobotcommon' //项目名
// PUBLISH_ARTIFACT_ID = 'sobotcommon_x' //项目名
PUBLISH_VERSION = '1.2.4' //版本号
PUBLISH_VERSION = '1.2.6' //版本号
}
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sobot.common">
<!-- 访问权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<application>
<provider
android:name=".ui.provider.SobotFileProvider"
android:authorities="${applicationId}.sobot_fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/sobot_provider_paths" />
</provider>
</application>
</manifest>
\ No newline at end of file
package com.sobot.common.login;
public interface SobotLoginConstant {
String SOBOT_LOGIN_USER_INFO = "sobot_login_user_info";//登录客服信息
}
package com.sobot.common.login;
import android.content.Context;
import android.text.TextUtils;
import com.sobot.common.login.callback.SobotResultBlock;
import com.sobot.common.login.callback.SobotResultCode;
import com.sobot.common.login.db.HostManager;
import com.sobot.common.login.db.LoginUserInfoUtils;
import com.sobot.common.login.db.ServiceInfoManager;
import com.sobot.common.login.model.HostModel;
import com.sobot.common.login.model.LoginUserEntity;
import com.sobot.common.login.model.ServiceFunctionVoModel;
import com.sobot.common.login.model.SobotServiceInfoModel;
import com.sobot.gson.SobotGsonUtil;
import com.sobot.network.apiUtils.SobotBaseCode;
import com.sobot.network.apiUtils.SobotHttpUtils;
import com.sobot.network.http.HttpBaseUtils;
import com.sobot.utils.SobotSharedPreferencesUtil;
import org.json.JSONArray;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* app 登录合并类
*/
public class SobotLoginTools {
/**
* 获取登录信息
*/
public static LoginUserEntity getLoginInfo() {
return LoginUserInfoUtils.getUser();
}
/**
* 获取坐席信息
*/
public static SobotServiceInfoModel getServiceInfoModel() {
return ServiceInfoManager.getInstance().getInfo();
}
/**
* 获取域名信息
*/
public static HostModel getHostModel() {
return HostManager.getInstance().getHost();
}
// 执行APP登录接口
public static void doAppLogin(final Object cancelTag, final Context mContext, final String host, Map<String, Object> params, final SobotResultBlock resultBlock) {
SobotHttpUtils.doPost(cancelTag, host + "/chat-sdk/sdk/admin/v1/login.action", params, new HttpBaseUtils.StringCallBack() {
@Override
public void onResponse(String result) {
if (!TextUtils.isEmpty(result)) {
SobotBaseCode<LoginUserEntity> baseModel = SobotGsonUtil.jsonToBeans(result, new com.sobot.gson.reflect.TypeToken<SobotBaseCode<LoginUserEntity>>() {
}.getType());
if (baseModel != null) {
//登录接口和获取坐席信息权限接口都成功才算真正登录成功
if ("1".equals(baseModel.getCode()) && baseModel.getData() != null) {
LoginUserInfoUtils.setUser(baseModel.getData());
getLoginUserInfo(cancelTag, mContext, baseModel.getData(), host, baseModel.getData().getToken(), resultBlock);
} else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, baseModel.getMsg(), baseModel.getCode());
}
} else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "接口请求结果为空", null);
}
}
}
@Override
public void onError(Exception e, String msg, int responseCode) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
@Override
public void inProgress(int progress) {
}
});
}
/**
* 调用座席接口
*
* @param cancelTag
* @param mContext
* @param host
* @param token
* @param resultBlock 返回坐席信息
*/
public static void getLoginUserInfo(final Object cancelTag, final Context mContext, String host, final String token, final SobotResultBlock resultBlock) {
getLoginUserInfo(cancelTag, mContext, null, host, token, resultBlock);
}
/**
* 调用座席接口
*
* @param cancelTag
* @param mContext
* @param loginUser 如果不为空 resultBlock返回就是这个;如果为空,返回坐席信息
* @param host
* @param token
* @param resultBlock
*/
public static void getLoginUserInfo(final Object cancelTag, final Context mContext, final LoginUserEntity loginUser, String host, final String token, final SobotResultBlock resultBlock) {
final String url = host + "/basic-config-service/consoleAuth/queryAppAgentMenus";
Map<String, String> headerMap = new HashMap<>();
headerMap.put("temp-id", token);
SobotHttpUtils.doGet(cancelTag, url, null, headerMap, new HttpBaseUtils.StringCallBack() {
@Override
public void onResponse(String result) {
if (!TextUtils.isEmpty(result)) {
try {
org.json.JSONObject resonseObj = new org.json.JSONObject(result);
String retCode = resonseObj.optString("retCode");
String retMsg = resonseObj.optString("retMsg");
if ("000000".equals(retCode)) {
SobotServiceInfoModel serviceInfoModel = SobotGsonUtil.jsonToBean(resonseObj.optString("item"), SobotServiceInfoModel.class);
List<ServiceFunctionVoModel> functions = new ArrayList<>();
JSONArray items = resonseObj.optJSONArray("items");
getListByObj(functions, items);
serviceInfoModel.setFunctionStr(functions);
//保存在数据库
ServiceInfoManager.getInstance().saveInfo(serviceInfoModel);
SobotSharedPreferencesUtil.getInstance(mContext).put(SobotLoginConstant.SOBOT_LOGIN_USER_INFO, serviceInfoModel);
if (loginUser != null) {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", loginUser);
} else {
resultBlock.resultBolok(SobotResultCode.CODE_SUCCEEDED, "登录成功", serviceInfoModel);
}
} else {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, retMsg == null ? "" : retMsg, null);
}
} catch (Exception e) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, "", null);
}
}
}
@Override
public void onError(Exception e, String msg, int responseCode) {
resultBlock.resultBolok(SobotResultCode.CODE_FAILED, msg, null);
}
@Override
public void inProgress(int progress) {
}
});
}
private static void getListByObj(List<ServiceFunctionVoModel> list, JSONArray items) {
try {
if (null != items) {
for (int i = 0; i < items.length(); i++) {
org.json.JSONObject o = items.getJSONObject(i);
ServiceFunctionVoModel functionVoModel = SobotGsonUtil.jsonToBean(o.toString(), ServiceFunctionVoModel.class);
if (functionVoModel != null) {
list.add(functionVoModel);
}
boolean hasChildren = o.optBoolean("hasChildren", false);
if (hasChildren) {
if (null != o.optJSONArray("children")) {
JSONArray childrens = o.getJSONArray("children");
getListByObj(list, childrens);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.sobot.common.login.callback;
/**
* 回调接口
*/
public interface SobotResultBlock {
/**
*
* @param code 成功 失败 失败后处理继续处理业务
* @param msg 描述
* @param obj 返回值
*/
void resultBolok(SobotResultCode code, String msg, Object obj);
}
package com.sobot.common.login.callback;
/**
* 回调结果
*/
public enum SobotResultCode {
CODE_FAILED,//失败
CODE_SUCCEEDED;//成功
}
package com.sobot.common.login.db;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.sobot.common.login.model.HostModel;
import com.sobot.common.utils.SobotGlobalContext;
import java.util.List;
/**
* 域名 操作类
*/
public class HostManager extends SobotCommonDao<HostModel> {
private HostManager(Context context) {
super(new SobotCommonDBHelper(context));
}
//volatile关键字确保多线程下正确处理
private volatile static HostManager mInstance;
public static HostManager getInstance() {
//第一次判空
if (mInstance == null) {
//进入同步区域
synchronized (HostManager.class) {
//第二次判空
if (mInstance == null) {
mInstance = new HostManager(SobotGlobalContext.getAppContext());
}
}
}
return mInstance;
}
@Override
public String getTableName() {
return SobotCommonDBHelper.TABLE_SOBOT_HOST;
}
@Override
public void unInit() {
}
@Override
public HostModel parseCursorToBean(Cursor cursor) {
HostModel model = new HostModel();
model.setDesc(cursor.getString(cursor.getColumnIndex("hostDesc")));
model.setHost(cursor.getString(cursor.getColumnIndex("host")));
model.setJanussipProxy(cursor.getString(cursor.getColumnIndex("janussipProxy")));
model.setJanusSocket(cursor.getString(cursor.getColumnIndex("janusSocket")));
model.setOpenApiHost(cursor.getString(cursor.getColumnIndex("openApiHost")));
model.setStompSocket(cursor.getString(cursor.getColumnIndex("stompSocket")));
return model;
}
@Override
public ContentValues getContentValues(HostModel hostModel) {
ContentValues contentValues = new ContentValues();
contentValues.put("hostDesc", hostModel.getDesc());
contentValues.put("host", hostModel.getHost());
contentValues.put("janussipProxy", hostModel.getJanussipProxy());
contentValues.put("janusSocket", hostModel.getJanusSocket());
contentValues.put("openApiHost", hostModel.getOpenApiHost());
contentValues.put("stompSocket", hostModel.getStompSocket());
return contentValues;
}
public void saveHost(HostModel host) {
insert(host);
}
/**
* 获取最近用户记录 按日期倒序
*/
public HostModel getHost() {
List<HostModel> list = query(null, null, null, null, null, null, null);
return list.size() > 0 ? list.get(0) : null;
}
}
package com.sobot.common.login.db;
import com.sobot.common.login.model.LoginUserEntity;
/**
* 获取当前登录用户信息
*/
public class LoginUserInfoUtils {
private static LoginUserEntity user;
public synchronized static LoginUserEntity getUser() {
if (user == null || user.getAid() == null) {
user = LoginUserManager.getInstance().getCurUser();
}
return user;
}
public static void setUser(LoginUserEntity newUser) {
LoginUserManager.getInstance().deleteAll();
user = newUser;
if (user != null) {
LoginUserManager.getInstance().insert(user);
} else {
HostManager.getInstance().deleteAll();
ServiceInfoManager.getInstance().deleteAll();
}
}
}
package com.sobot.common.login.db;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.sobot.common.login.model.LoginUserEntity;
import com.sobot.common.utils.SobotGlobalContext;
import com.sobot.gson.SobotGsonUtil;
import java.util.List;
import java.util.Map;
/**
* 登录用户信息 操作类
*/
public class LoginUserManager extends SobotCommonDao<LoginUserEntity> {
private LoginUserManager(Context context) {
super(new SobotCommonDBHelper(context));
}
//volatile关键字确保多线程下正确处理
private volatile static LoginUserManager mInstance;
public static LoginUserManager getInstance() {
//第一次判空
if (mInstance == null) {
//进入同步区域
synchronized (LoginUserManager.class) {
//第二次判空
if (mInstance == null) {
mInstance = new LoginUserManager(SobotGlobalContext.getAppContext());
}
}
}
return mInstance;
}
@Override
public String getTableName() {
return SobotCommonDBHelper.TABLE_LOGIN_USER;
}
@Override
public void unInit() {
}
@Override
public LoginUserEntity parseCursorToBean(Cursor cursor) {
LoginUserEntity model = new LoginUserEntity();
model.setTempId(cursor.getString(cursor.getColumnIndex("tempId")));
model.setNickName(cursor.getString(cursor.getColumnIndex("nickName")));
model.setStaffName(cursor.getString(cursor.getColumnIndex("staffName")));
model.setMaxServiceCount(cursor.getInt(cursor.getColumnIndex("maxServiceCount")));
model.setBlackFunction(cursor.getInt(cursor.getColumnIndex("blackFunction")));
String transferFunction = cursor.getString(cursor.getColumnIndex("transferFunction"));
Map<String, Boolean> map = SobotGsonUtil.jsonToMaps(transferFunction);
model.setTicketFunction(map);
model.setFace(cursor.getString(cursor.getColumnIndex("face")));
model.setCompanyName(cursor.getString(cursor.getColumnIndex("companyName")));
model.setAppKey(cursor.getString(cursor.getColumnIndex("appKey")));
model.setSid(cursor.getString(cursor.getColumnIndex("sid")));
model.setPu(cursor.getString(cursor.getColumnIndex("pu")));
model.setPuid(cursor.getString(cursor.getColumnIndex("puid")));
model.setToken(cursor.getString(cursor.getColumnIndex("token")));
model.setCusRoleName(cursor.getString(cursor.getColumnIndex("cusRoleName")));
model.setAid(cursor.getString(cursor.getColumnIndex("aid")));
model.setCenterNumber(cursor.getString(cursor.getColumnIndex("centerNumber")));
model.setAccountStatus(cursor.getString(cursor.getColumnIndex("accountStatus")));
model.setImFlag(cursor.getInt(cursor.getColumnIndex("imFlag")));
model.setCusRoleId(cursor.getInt(cursor.getColumnIndex("cusRoleId")));
model.setStatus(cursor.getInt(cursor.getColumnIndex("status")));
model.setTopFlag(cursor.getInt(cursor.getColumnIndex("topFlag")));
model.setSortFlag(cursor.getInt(cursor.getColumnIndex("sortFlag")));
model.setFuseWork(cursor.getInt(cursor.getColumnIndex("fuseWork")));
model.setCallV6Flag(cursor.getInt(cursor.getColumnIndex("callV6Flag")));
model.setCallV1Flag(cursor.getInt(cursor.getColumnIndex("callV1Flag")));
model.setTransferAuditFlag(cursor.getInt(cursor.getColumnIndex("transferAuditFlag")));
model.setKbVersion(cursor.getInt(cursor.getColumnIndex("kbVersion")) + "");
model.setCompanyId(cursor.getString(cursor.getColumnIndex("companyId")));
model.setLanguage(cursor.getString(cursor.getColumnIndex("local_language")));
return model;
}
@Override
public ContentValues getContentValues(LoginUserEntity userAccount) {
ContentValues contentValues = new ContentValues();
contentValues.put("_id", 8888);
contentValues.put("tempId", userAccount.getTempId());
contentValues.put("nickName", userAccount.getNickName());
contentValues.put("staffName", userAccount.getStaffName());
contentValues.put("maxServiceCount", userAccount.getMaxServiceCount());
contentValues.put("blackFunction", userAccount.getBlackFunction());
contentValues.put("transferFunction", userAccount.getTransferFunction());
contentValues.put("ticketFunction", SobotGsonUtil.beanToJson(userAccount.getTicketFunction()));
contentValues.put("face", userAccount.getFace());
contentValues.put("companyName", userAccount.getCompanyName());
contentValues.put("appKey", userAccount.getAppKey());
contentValues.put("sid", userAccount.getSid());
contentValues.put("pu", userAccount.getPu());
contentValues.put("puid", userAccount.getPuid());
contentValues.put("token", userAccount.getToken());
contentValues.put("cusRoleName", userAccount.getCusRoleName());
contentValues.put("aid", userAccount.getAid());
contentValues.put("centerNumber", userAccount.getCenterNumber());
contentValues.put("accountStatus", userAccount.getAccountStatus());
contentValues.put("imFlag", userAccount.isImFlag());
contentValues.put("cusRoleId", userAccount.getCusRoleId());
contentValues.put("status", userAccount.getStatus());
contentValues.put("topFlag", userAccount.getTopFlag());
contentValues.put("sortFlag", userAccount.getSortFlag());
contentValues.put("fuseWork", userAccount.getFuseWork());
contentValues.put("callV6Flag", userAccount.getCallV6Flag());
contentValues.put("callV1Flag", userAccount.getCallV1Flag());
contentValues.put("transferAuditFlag", userAccount.getTransferAuditFlag());
int kbVersion = 1;
if ("6".contains(userAccount.getKbVersion())) {
kbVersion = 6;
}
contentValues.put("kbVersion", kbVersion);
contentValues.put("companyId", userAccount.getCompanyId());
contentValues.put("local_language", userAccount.getLanguage());
return contentValues;
}
public void saveUser(LoginUserEntity user) {
insert(user);
}
/**
* 获取最近用户记录 按日期倒序
*/
public LoginUserEntity getCurUser() {
List<LoginUserEntity> list = query(null, null, null, null, null, null, null);
return list.size() > 0 ? list.get(0) : null;
}
}
package com.sobot.common.login.db;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import com.sobot.common.login.model.ServiceFunctionVoModel;
import com.sobot.common.login.model.SobotServiceInfoModel;
import com.sobot.common.utils.SobotGlobalContext;
import com.sobot.gson.SobotGsonUtil;
import com.sobot.gson.reflect.TypeToken;
import java.util.List;
/**
* 坐席信息 操作类
*/
public class ServiceInfoManager extends SobotCommonDao<SobotServiceInfoModel> {
private ServiceInfoManager(Context context) {
super(new SobotCommonDBHelper(context));
}
//volatile关键字确保多线程下正确处理
private volatile static ServiceInfoManager mInstance;
public static ServiceInfoManager getInstance() {
//第一次判空
if (mInstance == null) {
//进入同步区域
synchronized (LoginUserManager.class) {
//第二次判空
if (mInstance == null) {
mInstance = new ServiceInfoManager(SobotGlobalContext.getAppContext());
}
}
}
return mInstance;
}
@Override
public String getTableName() {
return SobotCommonDBHelper.TABLE_SERVICE_INFO;
}
@Override
public void unInit() {
}
@Override
public SobotServiceInfoModel parseCursorToBean(Cursor cursor) {
SobotServiceInfoModel model = new SobotServiceInfoModel();
model.setServiceId(cursor.getString(cursor.getColumnIndex("serviceId")));
model.setServiceName(cursor.getString(cursor.getColumnIndex("serviceName")));
model.setCusRoleId(cursor.getString(cursor.getColumnIndex("cusRoleId")));
model.setCusRoleName(cursor.getString(cursor.getColumnIndex("cusRoleName")));
model.setServiceLanguage(cursor.getString(cursor.getColumnIndex("language")));
model.setNewBossSwitch(cursor.getInt(cursor.getColumnIndex("newBossSwitch")));
model.setRegion(cursor.getInt(cursor.getColumnIndex("region")));
String functionStr = cursor.getString(cursor.getColumnIndex("functionStr"));
List<ServiceFunctionVoModel> list = SobotGsonUtil.jsonToBeans(functionStr, new TypeToken<List<ServiceFunctionVoModel>>() {
}.getType());
model.setFunctionStr(list);
return model;
}
@Override
public ContentValues getContentValues(SobotServiceInfoModel infoModel) {
ContentValues contentValues = new ContentValues();
contentValues.put("serviceId", infoModel.getServiceId());
contentValues.put("serviceName", infoModel.getServiceName());
contentValues.put("cusRoleId", infoModel.getCusRoleId());
contentValues.put("cusRoleName", infoModel.getCusRoleName());
contentValues.put("language", infoModel.getServiceLanguage());
contentValues.put("newBossSwitch", infoModel.getNewBossSwitch());
contentValues.put("region", infoModel.getRegion());
contentValues.put("functionStr", SobotGsonUtil.beanToJson(infoModel.getFunctionStr()));
return contentValues;
}
public void saveInfo(SobotServiceInfoModel host) {
insert(host);
}
/**
* 获取最近用户记录 按日期倒序
*/
public SobotServiceInfoModel getInfo() {
List<SobotServiceInfoModel> list = query(null, null, null, null, null, null, null);
return list.size() > 0 ? list.get(0) : null;
}
}
package com.sobot.common.login.db;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* DB辅助类
*/
class SobotCommonDBHelper extends SQLiteOpenHelper {
private static final String DB_CACHE_NAME = "sobot_common.db";
private static final int DB_CACHE_VERSION = 1;
static final String TABLE_LOGIN_USER = "login_user";
static final String TABLE_SOBOT_HOST = "sobot_host";
static final String TABLE_SERVICE_INFO = "sobot_service";
static final Lock lock = new ReentrantLock();
SobotCommonDBHelper(Context context) {
super(context, DB_CACHE_NAME, null, DB_CACHE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
onFirstCreate(db);
// 若不是第一个版本安装,直接执行数据库升级
// 请不要修改FIRST_DATABASE_VERSION的值,其为第一个数据库版本大小
final int FIRST_DATABASE_VERSION = 1;
onUpgrade(db, FIRST_DATABASE_VERSION, DB_CACHE_VERSION);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.beginTransaction();
try {
while (oldVersion < newVersion) {
upgradeDB(db, oldVersion, newVersion);
oldVersion++;
}
db.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
db.endTransaction();
}
}
/**
* 初始版本创建数据库需要执行的操作
*
* @param db
*/
private void onFirstCreate(SQLiteDatabase db) {
String sql = "create table " + TABLE_LOGIN_USER + "(_id INTEGER PRIMARY KEY," +
"tempId varchar(80)," +
"nickName varchar(300)," +
"staffName varchar(600), " +
"maxServiceCount INTEGER," +
"blackFunction INTEGER DEFAULT 1," +
"ticketFunction varchar(1000), " +
"transferFunction INTEGER DEFAULT 1, " +
"face varchar(300), " +
"companyName varchar(300), " +
"appKey varchar(40), " +
"sid varchar(40), " +
"pu varchar(40), " +
"puid varchar(40), " +
"token varchar(300), " +
"cusRoleName varchar(200), " +
"aid varchar(40), " +
"centerNumber varchar(40), " +
"accountStatus varchar(2), " +
"imFlag INTEGER, " +
"cusRoleId INTEGER, " +
"status INTEGER DEFAULT 1, " +
"topFlag INTEGER, " +
"sortFlag INTEGER , " +
"fuseWork INTEGER , " +
"callV6Flag INTEGER , " +
"callV1Flag INTEGER , " +
"transferAuditFlag INTEGER , " +
"kbVersion INTEGER , " +
"local_language varchar(10) , " +
"companyId varchar(40))";
db.execSQL(sql);
//添加客服信息表
String sql_service = "create table " + TABLE_SERVICE_INFO + "(" +
"serviceId varchar(40)," +
"serviceName varchar(600)," +
"cusRoleId varchar(10)," +
"cusRoleName varchar(200)," +
"functionStr varchar(1000)," +
"newBossSwitch INTEGER," +
"region INTEGER," +
"language varchar(10))";
db.execSQL(sql_service);
String sql_host = "create table " + TABLE_SOBOT_HOST + "(" +
"host varchar(80)," +
"hostDesc varchar(80)," +
"janussipProxy varchar(80)," +
"openApiHost varchar(80)," +
"stompSocket varchar(80)," +
"janusSocket varchar(80))";
db.execSQL(sql_host);
}
/**
* 升级数据需要执行的操作,初始版本以后所有版本的升级都会执行这个方法
*
* @param db
* @param oldVersion
* @param newVersion
*/
private void upgradeDB(SQLiteDatabase db, int oldVersion, int newVersion) {
switch (oldVersion) {
default:
break;
}
}
}
package com.sobot.common.login.model;
import java.io.Serializable;
/**
* 所有域名
*/
public class HostModel implements Serializable {
private String desc;// "香港",
private String host;// "http://hk.sobot.com/",
private String janusSocket;// "wss://rtc.sobot.com.cn/janus",
private String janussipProxy;// "sip:192.168.30.68:5060",
private String openApiHost;// "https://openapi.sobot.com",
private String stompSocket;// "wss://openapi.sobot.com/v6.0.0/webmsg/cc-webmsg"
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getJanusSocket() {
return janusSocket;
}
public void setJanusSocket(String janusSocket) {
this.janusSocket = janusSocket;
}
public String getJanussipProxy() {
return janussipProxy;
}
public void setJanussipProxy(String janussipProxy) {
this.janussipProxy = janussipProxy;
}
public String getOpenApiHost() {
return openApiHost;
}
public void setOpenApiHost(String openApiHost) {
this.openApiHost = openApiHost;
}
public String getStompSocket() {
return stompSocket;
}
public void setStompSocket(String stompSocket) {
this.stompSocket = stompSocket;
}
}
package com.sobot.common.login.model;
import com.sobot.gson.annotations.Expose;
import com.sobot.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class LoginUserEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String tempId; //客服temp-id
private String nickName; //客服昵称
private String staffName; //客服名称
private int maxServiceCount; //最大接待量
private int blackFunction = 1; //是否有拉黑权限 0 没有 1 有
private int transferFunction = 1; //是否有转接权限 0 没有 1 有
private String face; //头像url
private int status; //账号状态 1正常0登录邮箱或密码不正确 2用户已在pc端登录
private String companyId;//sysNum
private String appKey;
private String sid;
private String pu;
private String puid;
private String token;
private int imFlag;//0是工单客服 1是在线客服
private int cusRoleId;//身份id 3333:超级管理员;1111:在线客服;2222:管理员
private String cusRoleName;//身份名称 客服身份
private String aid;//userid
private int topFlag;//星标置顶 0不置顶 1置顶
private int sortFlag;//会话排序 0 按接入顺序 1 按新消息时间
private String centerNumber;//如果不为空,说明开通了呼叫功能
private int fuseWork;//1-存在融合工作台,使用新版服务总计 0-没有融合工作台
/**
* 1 账号开通v6;其它是v1
*/
private int callV6Flag;
private int callV1Flag;//是否是V1,方便做那个呼叫v1/v6切换的功能
private Map<String, Boolean> ticketFunction;//1222 可删除工单 ;1223 可删除工单回复;1224 可关闭工单; 1225 可激活工单 1230 工单操作历史权限
// 1231-工单状态 ; 1611-查看App客户中心
private int transferAuditFlag;//转接审核开关 0关闭 1开启
private String companyName;//公司名称
private String accountStatus;//企业账号版本:旗舰版
private String kbVersion;//智能回复,查询版本v6/v1
private String language;//国际化指定语言 3.1.3新增 为空时,默认中文
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getAccountStatus() {
return accountStatus;
}
public void setAccountStatus(String accountStatus) {
this.accountStatus = accountStatus;
}
@Expose
@SerializedName("wslink.bak")
private List<String> wslinkBak;//通道地址
@Expose
@SerializedName("wslink.default")
private String wslinkDefault;//通道默认地址
public String getAid() {
return aid;
}
public void setAid(String aid) {
this.aid = aid;
}
public int getBlackFunction() {
return blackFunction;
}
public void setBlackFunction(int blackFunction) {
this.blackFunction = blackFunction;
}
public int getTransferFunction() {
return transferFunction;
}
public void setTransferFunction(int transferFunction) {
this.transferFunction = transferFunction;
}
public List<String> getWslinkBak() {
return wslinkBak;
}
public void setWslinkBak(List<String> wslinkBak) {
this.wslinkBak = wslinkBak;
}
public String getWslinkDefault() {
return wslinkDefault;
}
public void setWslinkDefault(String wslinkDefault) {
this.wslinkDefault = wslinkDefault;
}
public int getCusRoleId() {
return cusRoleId;
}
public void setCusRoleId(int cusRoleId) {
this.cusRoleId = cusRoleId;
}
public String getCusRoleName() {
return cusRoleName;
}
public void setCusRoleName(String cusRoleName) {
this.cusRoleName = cusRoleName;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public int isImFlag() {
return imFlag;
}
public void setImFlag(int imFlag) {
this.imFlag = imFlag;
}
public String getPu() {
return pu;
}
public void setPu(String pu) {
this.pu = pu;
}
public String getPuid() {
return puid;
}
public void setPuid(String puid) {
this.puid = puid;
}
public String getTempId() {
return tempId;
}
public void setTempId(String tempId) {
this.tempId = tempId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public int getMaxServiceCount() {
return maxServiceCount;
}
public void setMaxServiceCount(int maxServiceCount) {
this.maxServiceCount = maxServiceCount;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getAppKey() {
return appKey;
}
public void setAppKey(String appKey) {
this.appKey = appKey;
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
public int getTopFlag() {
return topFlag;
}
public void setTopFlag(int topFlag) {
this.topFlag = topFlag;
}
public int getSortFlag() {
return sortFlag;
}
public void setSortFlag(int sortFlag) {
this.sortFlag = sortFlag;
}
public String getCenterNumber() {
return centerNumber;
}
public void setCenterNumber(String centerNumber) {
this.centerNumber = centerNumber;
}
public Map<String, Boolean> getTicketFunction() {
return ticketFunction;
}
public void setTicketFunction(Map<String, Boolean> ticketFunction) {
this.ticketFunction = ticketFunction;
}
public boolean getTransferAuditFlag() {
return transferAuditFlag == 1 ? true : false;
}
public void setTransferAuditFlag(int transferAuditFlag) {
this.transferAuditFlag = transferAuditFlag;
}
public int getFuseWork() {
return fuseWork;
}
public void setFuseWork(int fuseWork) {
this.fuseWork = fuseWork;
}
public int getCallV6Flag() {
return callV6Flag;
}
public void setCallV6Flag(int callV6Flag) {
this.callV6Flag = callV6Flag;
}
public int getCallV1Flag() {
return callV1Flag;
}
public void setCallV1Flag(int callV1Flag) {
this.callV1Flag = callV1Flag;
}
public String getKbVersion() {
return kbVersion;
}
public void setKbVersion(String kbVersion) {
this.kbVersion = kbVersion;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
}
package com.sobot.common.login.model;
import java.io.Serializable;
//权限信息
public class ServiceFunctionVoModel implements Serializable {
//旧版console权限标识
private String id;
//新版console权限标识
private String code;
//是否有子类权限
private boolean hasChildren;
public ServiceFunctionVoModel() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public boolean isHasChildren() {
return hasChildren;
}
public void setHasChildren(boolean hasChildren) {
this.hasChildren = hasChildren;
}
@Override
public String toString() {
return "SobotCusFunctionVoModel{" +
"id='" + id + '\'' +
"code='" + code + '\'' +
"cohasChildrende='" + hasChildren + '\'' +
'}';
}
}
package com.sobot.common.login.model;
import java.io.Serializable;
public class SobotBaseCodeThird<T> implements Serializable {
public T item;
public String retMsg;
public String retCode;
public int totalCount;
public T getItem() {
return item;
}
public void setItem(T item) {
this.item = item;
}
public String getRetMsg() {
return retMsg;
}
public void setRetMsg(String retMsg) {
this.retMsg = retMsg;
}
public String getRetCode() {
return retCode;
}
public void setRetCode(String retCode) {
this.retCode = retCode;
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
}
\ No newline at end of file
package com.sobot.common.login.model;
import java.io.Serializable;
import java.util.List;
/**
* 登录后的客服信息
*/
public class SobotServiceInfoModel implements Serializable {
/**
* 客服id
*/
private String serviceId;
/**
* 客服名字
*/
private String serviceName;
/**
* 角色id
*/
private String cusRoleId;
/**
* 角色名称
*/
private String cusRoleName;
/**
* 0 只用旧console 其他都是新console;
*/
private int newBossSwitch;
/**
* 权限信息
*/
private List<ServiceFunctionVoModel> functionStr;
private String serviceLanguage;
//区域环境(0国内 1国外)
private int region;
/**
* 公司id
*/
private String companyId;
/**
* 1 账号开通v6;其它是v1
*/
private int callV6Flag;
private String language;
/**
* 手机号
*/
private String phoneNo;
/**
* 权限 "globalPermissions": ["calldetails-newcustomers", "sw-ccc-thxq-xzkh", "calldetails-editcustomer", "DepartmentalAppealReview", "sw-ccc-thxq-bjkh",
* "A00008", "calldetails-relatedcustomers", "ChatQualityScore", "237283747", "sw-ccc-thxq-glkh", "calldetails-savesersummary", "CallQualityScore", "allTicket",
* "sw-ccc-thxq-bcfwzj", "calldetails-newworkorder", "ChatRecheck", "sw-ccc-thxq-xjgd", "mw-ccc-thxq-gdcd", "sw-ccc-thxq-gdcd", "calldetails-recordingandplay",
* "sw-ccc-thxq-fsdx", "calldetails-recorddownload", "sw-ccc-thxq-lybf", "calldetails-messageplay", "sw-ccc-thxq-lyxz", "mw-ccc-thxq-liuyxz", "sw-ccc-thxq-dhhb",
* "sw-ccc-thxq-liuybf", "sw-ccc-thxq-liuyxz", "9999"]
*/
private List<String> globalPermissions;
//是否是号码脱敏,true 脱敏,false 明文
private boolean hideFlag;
public List<String> getGlobalPermissions() {
return globalPermissions;
}
public void setGlobalPermissions(List<String> globalPermissions) {
this.globalPermissions = globalPermissions;
}
public boolean isHideFlag() {
if (null != globalPermissions && globalPermissions.contains("9999")) {
return true;
}
return false;
}
public void setHideFlag(boolean hideFlag) {
this.hideFlag = hideFlag;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public int getCallV6Flag() {
return callV6Flag;
}
public void setCallV6Flag(int callV6Flag) {
this.callV6Flag = callV6Flag;
}
public String getPhoneNo() {
return phoneNo;
}
public void setPhoneNo(String phoneNo) {
this.phoneNo = phoneNo;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getCusRoleId() {
return cusRoleId;
}
public void setCusRoleId(String cusRoleId) {
this.cusRoleId = cusRoleId;
}
public String getCusRoleName() {
return cusRoleName;
}
public void setCusRoleName(String cusRoleName) {
this.cusRoleName = cusRoleName;
}
public List<ServiceFunctionVoModel> getFunctionStr() {
return functionStr;
}
public void setFunctionStr(List<ServiceFunctionVoModel> functionStr) {
this.functionStr = functionStr;
}
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public int getNewBossSwitch() {
return newBossSwitch;
}
public void setNewBossSwitch(int newBossSwitch) {
this.newBossSwitch = newBossSwitch;
}
public String getServiceLanguage() {
return serviceLanguage;
}
public void setServiceLanguage(String serviceLanguage) {
this.serviceLanguage = serviceLanguage;
}
public int getRegion() {
return region;
}
public void setRegion(int region) {
this.region = region;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
}
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 全功能管理员
*/
public class PermissionAllFunctionAdministrator implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionAllFunctionAdministrator(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_TALK, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_STATISTIC, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_ONLINE, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_CALL, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_ONLINE, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_CALL, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE__STATISTIC_ROBOT, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_PERSON_STATUS, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_SESSION_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_EDIT_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_DEL_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_CALL, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
\ No newline at end of file
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 全功能客服
*/
public class PermissionAllFunctionCustomerService implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionAllFunctionCustomerService(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_TALK, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_PERSON_STATUS, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_SESSION_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_CALL, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
\ No newline at end of file
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 呼叫管理员
*/
public class PermissionCallAdministrators implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionCallAdministrators(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_STATISTIC, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_CALL, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_CALL, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_EDIT_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_DEL_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_CALL, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
\ No newline at end of file
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 呼叫客服
*/
public class PermissionCallCustomerService implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionCallCustomerService(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_CALL, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 在线管理员
*/
public class PermissionOnLineAdministrators implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionOnLineAdministrators(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_TALK, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_STATISTIC, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_ONLINE, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_ONLINE, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE__STATISTIC_ROBOT, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_PERSON_STATUS, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_SESSION_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_EDIT_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_DEL_WORK_ORDER, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
\ No newline at end of file
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 在线客服
*/
public class PermissionOnLineCustomerService implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionOnLineCustomerService(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_TALK, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_PERSON_STATUS, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_SESSION_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 超级管理员
*/
public class PermissionSuper implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionSuper() {
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_TALK, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_STATISTIC, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_ONLINE, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_CALL, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_ONLINE, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_CALL, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE__STATISTIC_ROBOT, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_PERSON_STATUS, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_SET_SESSION_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_EDIT_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_DEL_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_CALL, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
\ No newline at end of file
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 工单管理员
*/
public class PermissionWorkOrderAdministrators implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionWorkOrderAdministrators(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_MONITOR_STATISTIC, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_STATISTIC_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_EDIT_WORK_ORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_DEL_WORK_ORDER, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
\ No newline at end of file
package com.sobot.common.login.permission;
import android.util.SparseBooleanArray;
/**
* 工单客服
*/
public class PermissionWorkOrderCustomerService implements SobotPermissionApi {
private SparseBooleanArray sparseArray;
public PermissionWorkOrderCustomerService(){
sparseArray = new SparseBooleanArray();
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_WORKORDER, true);
sparseArray.put(SobotPermissionApi.USER_PERMISSION_TYPE_OTHER, true);
}
@Override
public boolean checkPermission(int type) {
return sparseArray.get(type);
}
}
package com.sobot.common.login.permission;
/**
* 权限常量类
*/
public interface SobotPermissionApi {
//对话权限
int USER_PERMISSION_TYPE_TALK = 0;
//工单权限
int USER_PERMISSION_TYPE_WORKORDER = 1;
//呼叫权限
int USER_PERMISSION_TYPE_CALL = 15;
//客户中心
String USER_PERMISSION_TYPE_USER_CENTEER = "1611";
//监控统计权限
int USER_PERMISSION_TYPE_MONITOR_STATISTIC = 2;
//监控-在线权限
int USER_PERMISSION_TYPE_MONITOR_ONLINE = 3;
//监控-呼叫权限
int USER_PERMISSION_TYPE_MONITOR_CALL = 4;
//统计-在线权限
int USER_PERMISSION_TYPE_STATISTIC_ONLINE = 5;
//统计-呼叫权限
int USER_PERMISSION_TYPE_STATISTIC_CALL = 6;
//统计-工单权限
int USER_PERMISSION_TYPE_STATISTIC_WORKORDER = 7;
//统计-机器人权限
int USER_PERMISSION_TYPE__STATISTIC_ROBOT = 8;
//设置-个人状态权限
int USER_PERMISSION_TYPE_SET_PERSON_STATUS = 9;
//设置-会话顺序权限
int USER_PERMISSION_TYPE_SET_SESSION_ORDER = 10;
//设置权限
int USER_PERMISSION_TYPE_OTHER = 11;
//工单详情页是否有右上角的编辑工单权限
int USER_PERMISSION_TYPE_EDIT_WORK_ORDER = 12;
//工单详情页是否有右上角的删除工单权限
int USER_PERMISSION_TYPE_DEL_WORK_ORDER = 13;
boolean checkPermission(int type);
}
\ No newline at end of file
package com.sobot.common.utils;
import android.app.Application;
import android.content.res.Resources;
import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.network.apiUtils.SobotHttpUtils;
import com.sobot.network.http.log.SobotNetLogUtils;
import com.sobot.utils.SobotLogUtils;
......@@ -44,34 +42,4 @@ public class SobotCommonApi {
SobotLogUtils.setShowDebug(isDebug);
SobotNetLogUtils.setShowDebug(true);
}
/**
* 获取开关状态
*
* @param markConfig 开关名
* @return
* @see SobotMarkConfig 取值
*/
public static boolean getSwitchMarkStatus(int markConfig) {
if ((markConfig & (markConfig - 1)) == 0)
return SobotMarkConfig.getON_OFF(markConfig);
else {
throw new Resources.NotFoundException("markConfig 必须为2的指数次幂");
}
}
/**
* 设置开关状态
*
* @param markConfig 开关名 必须为 2 的非负数整数次幂
* @param isOn
* @see SobotMarkConfig 取值
*/
public static void setSwitchMarkStatus(int markConfig, boolean isOn) {
if ((markConfig & (markConfig - 1)) == 0)
SobotMarkConfig.setON_OFF(markConfig, isOn);
else {
throw new Resources.NotFoundException("markConfig 必须为2的指数次幂");
}
}
}
package com.sobot.common.utils;
import com.sobot.utils.SobotStringUtils;
//加密工具类
public class SobotEncryptionUtil {
// Base64加密
public static String encode(String str) {
if (SobotStringUtils.isEmpty(str)) {
return "";
}
byte[] encodeBytes = SobotBase64.getMimeEncoder().encode(str.getBytes());
return new String(encodeBytes);
}
// Base64解密
public static String decode(String str) {
if (SobotStringUtils.isEmpty(str)) {
return "";
}
byte[] decodeBytes = SobotBase64.getMimeDecoder().decode(str.getBytes());
return new String(decodeBytes);
}
}
\ No newline at end of file
......@@ -12,9 +12,6 @@ import java.util.Stack;
/**
* @Description: 全局上下文
* @Author: znw
* @Date: 2021/7/19 下午2:17
* @Version: 1.0
*/
public class SobotGlobalContext {
private Context mApplicationContext;
......
......@@ -3,7 +3,6 @@ package com.sobot.common.utils;
import android.content.Context;
import android.graphics.Color;
import android.os.Environment;
import android.support.v4.content.ContextCompat;
import java.io.BufferedReader;
import java.io.FileInputStream;
......@@ -33,10 +32,6 @@ public class SobotResourceUtils {
return getIdByName(context, "color", name);
}
public static int getResColorValue(Context context, String name) {
return ContextCompat.getColor(context, getResColorId(context, name));
}
public static int getDrawableId(Context context, String name) {
return SobotResourceUtils.getIdByName(context, "drawable", name);
}
......@@ -86,7 +81,7 @@ public class SobotResourceUtils {
FileInputStream fis = null;
try {
fis = new FileInputStream(filePathName);
InputStreamReader reader = new InputStreamReader(fis,"UTF-8");
InputStreamReader reader = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(reader);
String line;
while ((line = br.readLine()) != null) {
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="sobot_no_permission_text">You are not authorized to do so</string>
<string name="sobot_go_setting">To set up</string>
<string name="sobot_btn_submit">Submit</string>
<string name="sobot_btn_cancle">Cancel</string>
<string name="sobot_no_write_external_storage_permission">No write external storage permission</string>
<string name="sobot_no_record_audio_permission">Unable to record</string>
<string name="sobot_no_camera_permission">No camera permission</string>
<string name="sobot_want_use_your"> want to visit yours </string>
<string name="sobot_memory_card">File</string>
<string name="sobot_memory_card_yongtu">You can send pictures, videos and files to describe the problem when you consult customer service and leave a message</string>
<string name="sobot_camera">Camera</string>
<string name="sobot_camera_yongtu">You can send photos and videos for help when consulting customer service and leaving a message</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--通用 颜色-->
<!--白色-->
<color name="sobot_white">#FFFFFF</color>
<!--绿色-->
<color name="sobot_common_green">#0DAEAF</color>
<!--主要文本色 大部分界面里的黑色文字-->
<color name="sobot_common_gray1">#D1D1D6</color>
<!--次要文本色-->
<color name="sobot_common_gray2">#7C7C80</color>
<!--占位文本色-->
<color name="sobot_common_gray3">#7C7C80</color>
<!--一级背景色-->
<color name="sobot_common_gray6">#1B1B1C</color>
<!--二级背景色-->
<color name="sobot_common_gray7">#262628</color>
<!-- 主题色 默认绿色 -->
<color name="sobot_color">@color/sobot_common_green</color>
<!--文字颜色 绿色变白色-->
<color name="sobot_common_wenzi_green_white">@color/sobot_color</color>
<!--线条分割线颜色-->
<color name="sobot_common_line_gray">#272729</color>
<!-- 头部开始 -->
<!-- 头部背景 -->
<color name="sobot_color_title_bar_bg">@color/sobot_white</color>
<!-- 状态栏的颜色设置 -->
<color name="sobot_status_bar_color">@color/sobot_color_title_bar_bg</color>
<!-- 头部中间昵称颜色 -->
<color name="sobot_color_title_bar_title">@color/sobot_common_gray1</color>
<!-- 头部两侧菜单字体颜色 -->
<color name="sobot_color_title_bar_menu_text">@color/sobot_common_gray1</color>
<!--头部头像边框颜色-->
<color name="sobot_color_title_bar_avatar_line">#EDEEF0</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--圆形-->
<attr name="sobot_round_as_circle" format="boolean" />
<!--全部圆角半径-->
<attr name="sobot_round_corner" format="integer|dimension" />
<!--针对各个角的半径-->
<attr name="sobot_round_corner_top_left" format="integer|dimension" />
<attr name="sobot_round_corner_top_right" format="integer|dimension" />
<attr name="sobot_round_corner_bottom_left" format="integer|dimension" />
<attr name="sobot_round_corner_bottom_right" format="integer|dimension" />
<!--描边颜色/半径-->
<attr name="sobot_stroke_color" format="color|reference" />
<attr name="sobot_stroke_width" format="integer|dimension" />
<!-- 是否剪裁 RCLayout 的背景 -->
<attr name="sobot_clip_background" format="boolean" />
<!--真正用于解析的属性-->
<declare-styleable name="SobotRCAttrs">
<attr name="sobot_round_as_circle" />
<attr name="sobot_round_corner" />
<attr name="sobot_round_corner_top_left" />
<attr name="sobot_round_corner_top_right" />
<attr name="sobot_round_corner_bottom_left" />
<attr name="sobot_round_corner_bottom_right" />
<attr name="sobot_stroke_color" />
<attr name="sobot_stroke_width" />
<attr name="sobot_clip_background" />
</declare-styleable>
<!--假体:用于提示-->
<declare-styleable name="sobot_RCRelativeLayout">
<attr name="sobot_round_as_circle" />
<attr name="sobot_round_corner" />
<attr name="sobot_round_corner_top_left" />
<attr name="sobot_round_corner_top_right" />
<attr name="sobot_round_corner_bottom_left" />
<attr name="sobot_round_corner_bottom_right" />
<attr name="sobot_stroke_color" />
<attr name="sobot_stroke_width" />
<attr name="sobot_clip_background" />
</declare-styleable>
<declare-styleable name="sobot_RCImageView">
<attr name="sobot_round_as_circle" />
<attr name="sobot_round_corner" />
<attr name="sobot_round_corner_top_left" />
<attr name="sobot_round_corner_top_right" />
<attr name="sobot_round_corner_bottom_left" />
<attr name="sobot_round_corner_bottom_right" />
<attr name="sobot_stroke_color" />
<attr name="sobot_stroke_width" />
<attr name="sobot_clip_background" />
</declare-styleable>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--通用 颜色-->
<!--白色-->
<color name="sobot_white">#FFFFFF</color>
<!--绿色-->
<color name="sobot_common_green">#0DAEAF</color>
<!--主要文本色 大部分界面里的黑色文字-->
<color name="sobot_common_gray1">#515A7C</color>
<!--次要文本色-->
<color name="sobot_common_gray2">#ACB5C4</color>
<!--占位文本色-->
<color name="sobot_common_gray3">#DDE0E6</color>
<!--一级背景色-->
<color name="sobot_common_gray6">#FFFFFF</color>
<!--二级背景色-->
<color name="sobot_common_gray7">#FFF2F5F7</color>
<!-- 主题色 默认绿色 -->
<color name="sobot_color">@color/sobot_common_green</color>
<!--文字颜色 绿色变白色-->
<color name="sobot_common_wenzi_green_white">@color/sobot_color</color>
<!--线条分割线颜色-->
<color name="sobot_common_line_gray">#EDEEF0</color>
<!-- 头部开始 -->
<!-- 头部背景 -->
<color name="sobot_color_title_bar_bg">@color/sobot_white</color>
<!-- 状态栏的颜色设置 -->
<color name="sobot_status_bar_color">@color/sobot_color_title_bar_bg</color>
<!-- 头部中间昵称颜色 -->
<color name="sobot_color_title_bar_title">@color/sobot_common_gray1</color>
<!-- 头部两侧菜单字体颜色 -->
<color name="sobot_color_title_bar_menu_text">@color/sobot_common_gray1</color>
<!--头部头像边框颜色-->
<color name="sobot_color_title_bar_avatar_line">#EDEEF0</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="sobot_no_permission_text">您还没有授权相关权限</string>
<string name="sobot_go_setting">去设置</string>
<string name="sobot_btn_cancle">取消</string>
<string name="sobot_btn_submit">确定</string>
<string name="sobot_no_write_external_storage_permission">没有存储权限</string>
<string name="sobot_no_record_audio_permission">没有麦克风权限</string>
<string name="sobot_no_camera_permission">没有相机权限</string>
<string name="sobot_want_use_your">想访问您的</string>
<string name="sobot_memory_card">文件</string>
<string name="sobot_memory_card_yongtu">您可以在咨询客服和留言时,发送图片、视频、文件描述问题</string>
<string name="sobot_camera">相机</string>
<string name="sobot_camera_yongtu">您可以在咨询客服和留言时,发送拍摄的照片和视频获取帮助</string>
</resources>
\ No newline at end of file
......@@ -45,6 +45,7 @@ public class HttpBaseUtils {
final StringCallBack callback) {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......@@ -104,6 +105,7 @@ public class HttpBaseUtils {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......@@ -162,6 +164,7 @@ public class HttpBaseUtils {
final StringCallBack callback) {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......@@ -230,6 +233,7 @@ public class HttpBaseUtils {
final StringCallBack callback) {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......@@ -323,6 +327,7 @@ public class HttpBaseUtils {
String path, final StringCallBack callback) {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
SobotNetLogUtils.i("上传文件地址: --> " + path);
if (headerMap == null) {
headerMap = new HashMap<>();
......@@ -415,6 +420,7 @@ public class HttpBaseUtils {
String path, String imageFile) {
SobotNetLogUtils.i("上传文件 请求URL: --> " + url_str);
SobotNetLogUtils.i("上传文件 请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......@@ -473,6 +479,7 @@ public class HttpBaseUtils {
url_str, Map<String, Object> paramMap, Map<String, String> headerMap) {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......@@ -491,6 +498,7 @@ public class HttpBaseUtils {
IOException {
SobotNetLogUtils.i("请求URL: --> " + url_str);
SobotNetLogUtils.i("请求参数: --> " + paramMap);
SobotNetLogUtils.i("请求头参数: --> " + headerMap);
if (headerMap == null) {
headerMap = new HashMap<>();
}
......
......@@ -14,6 +14,7 @@ dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
compileOnly 'com.android.support:appcompat-v7:28.0.0'
compileOnly 'com.android.support:recyclerview-v7:28.0.0'
api 'com.sobot.library:utils:1.1.1'
}
......
......@@ -13,7 +13,7 @@ ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'widget' //项目名
// PUBLISH_ARTIFACT_ID = 'widget_x' //项目名
PUBLISH_VERSION = '1.0' //版本号
PUBLISH_VERSION = '1.0.2' //版本号
}
......
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.sobot.widget">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sobot.widget">
<!-- 访问权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<application>
<provider
android:name=".ui.provider.SobotFileProvider"
android:authorities="${applicationId}.sobot_fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/sobot_provider_paths" />
</provider>
</application>
</manifest>
\ No newline at end of file
package com.sobot.widget;
import android.content.res.Resources;
import com.sobot.widget.ui.SobotMarkConfig;
public class SobotWidgetApi {
/**
* 获取开关状态
*
* @param markConfig 开关名
* @return
* @see SobotMarkConfig 取值
*/
public static boolean getSwitchMarkStatus(int markConfig) {
if ((markConfig & (markConfig - 1)) == 0)
return SobotMarkConfig.getON_OFF(markConfig);
else {
throw new Resources.NotFoundException("markConfig 必须为2的指数次幂");
}
}
/**
* 设置开关状态
*
* @param markConfig 开关名 必须为 2 的非负数整数次幂
* @param isOn
* @see SobotMarkConfig 取值
*/
public static void setSwitchMarkStatus(int markConfig, boolean isOn) {
if ((markConfig & (markConfig - 1)) == 0)
SobotMarkConfig.setON_OFF(markConfig, isOn);
else {
throw new Resources.NotFoundException("markConfig 必须为2的指数次幂");
}
}
}
package com.sobot.common.ui;
package com.sobot.widget.ui;
public class SobotBaseConstant {
//申请权限的code
......
package com.sobot.common.ui.base;
package com.sobot.widget.ui.base;
import android.Manifest;
import android.content.Context;
......@@ -24,22 +24,22 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.sobot.common.ui.SobotBaseConstant;
import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.ui.image.SobotRCImageView;
import com.sobot.common.ui.notchlib.SobotINotchScreen;
import com.sobot.common.ui.notchlib.SobotNotchScreenManager;
import com.sobot.common.ui.permission.SobotPermissionListener;
import com.sobot.common.ui.permission.SobotPermissionListenerImpl;
import com.sobot.common.ui.permission.SobotPermissionTipDialog;
import com.sobot.common.ui.statusbar.SobotStatusBarUtils;
import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotCommonUtils;
import com.sobot.common.utils.SobotGlobalContext;
import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotSharedPreferencesUtil;
import com.sobot.utils.SobotSystemUtils;
import com.sobot.widget.R;
import com.sobot.widget.SobotWidgetApi;
import com.sobot.widget.ui.SobotBaseConstant;
import com.sobot.widget.ui.SobotMarkConfig;
import com.sobot.widget.ui.image.SobotRCImageView;
import com.sobot.widget.ui.notchlib.SobotINotchScreen;
import com.sobot.widget.ui.notchlib.SobotNotchScreenManager;
import com.sobot.widget.ui.permission.SobotPermissionListener;
import com.sobot.widget.ui.permission.SobotPermissionListenerImpl;
import com.sobot.widget.ui.permission.SobotPermissionTipDialog;
import com.sobot.widget.ui.statusbar.SobotStatusBarUtils;
import com.sobot.widget.ui.utils.SobotResourceUtils;
import com.sobot.widget.ui.utils.SobotWidgetUtils;
import java.io.File;
import java.util.Locale;
......@@ -59,14 +59,14 @@ public abstract class SobotBaseActivity extends FragmentActivity {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
if (!SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
if (!SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);//竖屏
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);//横屏
}
}
if (SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN) && SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH)) {
if (SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN) && SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH)) {
// 支持显示到刘海区域
SobotNotchScreenManager.getInstance().setDisplayInNotch(this);
// 设置Activity全屏
......@@ -84,7 +84,6 @@ public abstract class SobotBaseActivity extends FragmentActivity {
}
setUpToolBar();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
SobotGlobalContext.getInstance(getSobotBaseActivity()).addActivity(this);
View toolBar = findViewById(getResId("sobot_layout_titlebar"));
if (toolBar != null) {
setUpToolBarLeftMenu();
......@@ -109,7 +108,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
}
public void displayInNotch(final View view) {
if (SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN) && SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH) && view != null) {
if (SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN) && SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH) && view != null) {
// 获取刘海屏信息
SobotNotchScreenManager.getInstance().getNotchInfo(this, new SobotINotchScreen.NotchScreenCallback() {
@Override
......@@ -286,7 +285,6 @@ public abstract class SobotBaseActivity extends FragmentActivity {
@Override
protected void onDestroy() {
SobotGlobalContext.getInstance(getSobotBaseActivity()).removeActivity(this);
super.onDestroy();
}
......@@ -333,7 +331,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
if (isShowAvatar) {
tmpAvatart.setVisibility(View.VISIBLE);
tmpAvatart.setRoundAsCircle(true);
tmpAvatart.setStrokeColor(SobotResourceUtils.getResColorValue(getSobotBaseActivity(), "sobot_color_title_bar_avatar_line"));
tmpAvatart.setStrokeColor(getResources().getColor(R.color.sobot_color_title_bar_avatar_line));
} else {
tmpAvatart.setVisibility(View.GONE);
}
......@@ -451,6 +449,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
return (getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN;
}
/**
* 检测是否需要弹出权限用途提示框pop,如果弹出,则拦截接下来的处理逻辑,自己处理
*
......@@ -460,7 +459,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
* @return
*/
public boolean checkIsShowPermissionPop(String title, String content, final int type) {
if (SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP)) {
if (SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP)) {
if (!isHasPermission(type)) {
SobotPermissionTipDialog dialog = new SobotPermissionTipDialog(getSobotBaseActivity(), title, content, new SobotPermissionTipDialog.ClickViewListener() {
@Override
......@@ -720,7 +719,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
sobotPermissionListener = new SobotPermissionListenerImpl() {
@Override
public void onPermissionSuccessListener() {
SobotCommonUtils.openSelectPic(getSobotBaseActivity());
SobotWidgetUtils.openSelectPic(getSobotBaseActivity());
}
};
if (checkIsShowPermissionPop(getResString("sobot_memory_card"), getResString("sobot_memory_card_yongtu"), 1)) {
......@@ -729,7 +728,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
if (!checkStoragePermission()) {
return;
}
SobotCommonUtils.openSelectPic(this);
SobotWidgetUtils.openSelectPic(this);
}
/**
......@@ -750,7 +749,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
sobotPermissionListener = new SobotPermissionListenerImpl() {
@Override
public void onPermissionSuccessListener() {
SobotCommonUtils.openSelectVedio(getSobotBaseActivity());
SobotWidgetUtils.openSelectVedio(getSobotBaseActivity());
}
};
if (checkIsShowPermissionPop(getResString("sobot_memory_card"), getResString("sobot_memory_card_yongtu"), 1)) {
......@@ -759,7 +758,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
if (!checkStoragePermission()) {
return;
}
SobotCommonUtils.openSelectVedio(getSobotBaseActivity());
SobotWidgetUtils.openSelectVedio(getSobotBaseActivity());
}
/**
......@@ -782,7 +781,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
@Override
public void onPermissionSuccessListener() {
if (isCameraCanUse()) {
cameraFile = SobotCommonUtils.openCamera(getSobotBaseActivity());
cameraFile = SobotWidgetUtils.openCamera(getSobotBaseActivity());
}
}
};
......@@ -793,7 +792,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
return;
}
if (isCameraCanUse()) {
cameraFile = SobotCommonUtils.openCamera(getSobotBaseActivity());
cameraFile = SobotWidgetUtils.openCamera(getSobotBaseActivity());
}
}
}
\ No newline at end of file
package com.sobot.common.ui.image;
package com.sobot.widget.ui.image;
public interface RCAttrs {
void setClipBackground(boolean clipBackground);
......
package com.sobot.common.ui.image;
package com.sobot.widget.ui.image;
import android.content.Context;
......@@ -19,7 +19,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import com.sobot.common.R;
import com.sobot.widget.R;
import java.util.ArrayList;
......
package com.sobot.common.ui.image;
package com.sobot.widget.ui.image;
import android.annotation.SuppressLint;
import android.content.Context;
......
package com.sobot.common.ui.image;
package com.sobot.widget.ui.image;
import android.content.Context;
import android.graphics.Canvas;
......
package com.sobot.common.ui.image.helper;
package com.sobot.widget.ui.image.helper;
public interface RCAttrs {
void setClipBackground(boolean clipBackground);
......
......@@ -20,7 +20,7 @@
* WebSite: http://www.gcssloop.com
*/
package com.sobot.common.ui.image.helper;
package com.sobot.widget.ui.image.helper;
import android.content.Context;
......@@ -40,7 +40,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import com.sobot.common.R;
import com.sobot.widget.R;
import java.util.ArrayList;
......
package com.sobot.common.ui.notchlib;
package com.sobot.widget.ui.notchlib;
import android.app.Activity;
import android.graphics.Rect;
......
package com.sobot.common.ui.notchlib;
package com.sobot.widget.ui.notchlib;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import com.sobot.common.ui.notchlib.impl.AndroidPNotchScreen;
import com.sobot.common.ui.notchlib.impl.HuaweiNotchScreen;
import com.sobot.common.ui.notchlib.impl.MiNotchScreen;
import com.sobot.common.ui.notchlib.impl.OppoNotchScreen;
import com.sobot.common.ui.notchlib.impl.VivoNotchScreen;
import com.sobot.common.ui.notchlib.utils.RomUtils;
import com.sobot.widget.ui.notchlib.impl.AndroidPNotchScreen;
import com.sobot.widget.ui.notchlib.impl.HuaweiNotchScreen;
import com.sobot.widget.ui.notchlib.impl.MiNotchScreen;
import com.sobot.widget.ui.notchlib.impl.OppoNotchScreen;
import com.sobot.widget.ui.notchlib.impl.VivoNotchScreen;
import com.sobot.widget.ui.notchlib.utils.RomUtils;
import java.util.List;
......@@ -68,9 +68,8 @@ public class SobotNotchScreenManager {
private SobotINotchScreen getNotchScreen() {
SobotINotchScreen notchScreen = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
notchScreen = new AndroidPNotchScreen();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) notchScreen = new AndroidPNotchScreen();
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (RomUtils.isHuawei()) {
notchScreen = new HuaweiNotchScreen();
} else if (RomUtils.isOppo()) {
......
package com.sobot.common.ui.notchlib.impl;
package com.sobot.widget.ui.notchlib.impl;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -10,7 +10,7 @@ import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import com.sobot.common.ui.notchlib.SobotINotchScreen;
import com.sobot.widget.ui.notchlib.SobotINotchScreen;
import java.util.List;
......
package com.sobot.common.ui.notchlib.impl;
package com.sobot.widget.ui.notchlib.impl;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -7,8 +7,8 @@ import android.os.Build;
import android.view.Window;
import android.view.WindowManager;
import com.sobot.common.ui.notchlib.SobotINotchScreen;
import com.sobot.common.ui.notchlib.utils.ScreenUtil;
import com.sobot.widget.ui.notchlib.SobotINotchScreen;
import com.sobot.widget.ui.notchlib.utils.ScreenUtil;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
......
package com.sobot.common.ui.notchlib.impl;
package com.sobot.widget.ui.notchlib.impl;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -7,8 +7,8 @@ import android.graphics.Rect;
import android.os.Build;
import android.view.Window;
import com.sobot.common.ui.notchlib.SobotINotchScreen;
import com.sobot.common.ui.notchlib.utils.ScreenUtil;
import com.sobot.widget.ui.notchlib.SobotINotchScreen;
import com.sobot.widget.ui.notchlib.utils.ScreenUtil;
import java.lang.reflect.Method;
import java.util.ArrayList;
......
package com.sobot.common.ui.notchlib.impl;
package com.sobot.widget.ui.notchlib.impl;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -6,8 +6,8 @@ import android.graphics.Rect;
import android.os.Build;
import android.text.TextUtils;
import com.sobot.common.ui.notchlib.SobotINotchScreen;
import com.sobot.common.ui.notchlib.utils.ScreenUtil;
import com.sobot.widget.ui.notchlib.SobotINotchScreen;
import com.sobot.widget.ui.notchlib.utils.ScreenUtil;
import java.lang.reflect.Method;
import java.util.ArrayList;
......
package com.sobot.common.ui.notchlib.impl;
package com.sobot.widget.ui.notchlib.impl;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -7,8 +7,8 @@ import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import com.sobot.common.ui.notchlib.SobotINotchScreen;
import com.sobot.common.ui.notchlib.utils.ScreenUtil;
import com.sobot.widget.ui.notchlib.SobotINotchScreen;
import com.sobot.widget.ui.notchlib.utils.ScreenUtil;
import java.lang.reflect.Method;
import java.util.ArrayList;
......
package com.sobot.common.ui.notchlib.utils;
package com.sobot.widget.ui.notchlib.utils;
import android.annotation.SuppressLint;
import android.os.Build;
......
package com.sobot.common.ui.notchlib.utils;
package com.sobot.widget.ui.notchlib.utils;
import android.app.Activity;
import android.content.Context;
......
package com.sobot.common.ui.permission;
package com.sobot.widget.ui.permission;
import android.app.Activity;
import android.app.Dialog;
......@@ -16,10 +16,11 @@ import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.utils.SobotDensityUtil;
import com.sobot.widget.R;
import com.sobot.widget.SobotWidgetApi;
import com.sobot.widget.ui.SobotMarkConfig;
import com.sobot.widget.ui.utils.SobotResourceUtils;
/**
* 权限提示框提示
......@@ -35,7 +36,7 @@ public class SobotPermissionDialog extends Dialog implements View.OnClickListene
private String title;
public SobotPermissionDialog(Activity context, ClickViewListener itemsOnClick) {
super(context, SobotResourceUtils.getIdByName(context, "style", "sobot_noAnimDialogStyle"));
super(context, R.style.sobot_noAnimDialogStyle);
this.viewListenern = itemsOnClick;
screenHeight = SobotDensityUtil.getScreenHeight(context);
......@@ -45,7 +46,7 @@ public class SobotPermissionDialog extends Dialog implements View.OnClickListene
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.gravity = Gravity.CENTER;
//横屏设置dialog全屏
if (SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH) && SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
if (SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH) && SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
}
setParams(context, layoutParams);
......@@ -61,7 +62,7 @@ public class SobotPermissionDialog extends Dialog implements View.OnClickListene
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(SobotResourceUtils.getIdByName(getContext(), "layout", "sobot_common_permission_popup"));
setContentView(R.layout.sobot_common_permission_popup);
initView();
}
......
package com.sobot.common.ui.permission;
package com.sobot.widget.ui.permission;
import android.app.Activity;
import android.content.Context;
......
package com.sobot.common.ui.permission;
package com.sobot.widget.ui.permission;
import android.app.Activity;
import android.app.Dialog;
......@@ -16,11 +16,12 @@ import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotCommonUtils;
import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.utils.SobotDensityUtil;
import com.sobot.utils.SobotSystemUtils;
import com.sobot.widget.R;
import com.sobot.widget.SobotWidgetApi;
import com.sobot.widget.ui.SobotMarkConfig;
import com.sobot.widget.ui.utils.SobotResourceUtils;
/**
* 权限用途提示弹窗
......@@ -39,7 +40,7 @@ public class SobotPermissionTipDialog extends Dialog implements View.OnClickList
private String mContent;
public SobotPermissionTipDialog(Activity context, ClickViewListener itemsOnClick) {
super(context, SobotResourceUtils.getIdByName(context, "style", "sobot_noAnimDialogStyle"));
super(context, R.style.sobot_noAnimDialogStyle);
this.viewListenern = itemsOnClick;
screenHeight = SobotDensityUtil.getScreenHeight(context);
......@@ -49,7 +50,7 @@ public class SobotPermissionTipDialog extends Dialog implements View.OnClickList
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.gravity = Gravity.CENTER;
//横屏设置dialog全屏
if (SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH) && SobotCommonApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
if (SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH) && SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
}
setParams(context, layoutParams);
......@@ -66,7 +67,7 @@ public class SobotPermissionTipDialog extends Dialog implements View.OnClickList
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(SobotResourceUtils.getIdByName(getContext(), "layout", "sobot_common_permission_purpose_tip_popup"));
setContentView(R.layout.sobot_common_permission_purpose_tip_popup);
initView();
}
......@@ -83,7 +84,7 @@ public class SobotPermissionTipDialog extends Dialog implements View.OnClickList
private void initView() {
titleView = (TextView) findViewById(SobotResourceUtils.getIdByName(getContext(), "id", "sobot_dialog_title"));
if (!TextUtils.isEmpty(title)) {
titleView.setText("\"" + SobotCommonUtils.getAppName(getContext()) + "\" " + SobotResourceUtils.getResString(getContext(), "sobot_want_use_your") + title);
titleView.setText("\"" + SobotSystemUtils.getAppName(getContext()) + "\" " + SobotResourceUtils.getResString(getContext(), "sobot_want_use_your") + title);
}
contentTV = (TextView) findViewById(SobotResourceUtils.getIdByName(getContext(), "id", "sobot_dialog_content"));
if (!TextUtils.isEmpty(mContent)) {
......
package com.sobot.common.ui.provider;
package com.sobot.widget.ui.provider;
import android.support.v4.content.FileProvider;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.annotation.TargetApi;
import android.os.Build;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.annotation.TargetApi;
import android.app.Activity;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.annotation.TargetApi;
import android.os.Build;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.annotation.TargetApi;
import android.os.Build;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.annotation.TargetApi;
import android.os.Build;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.content.Context;
import android.content.res.Resources;
......
package com.sobot.common.ui.statusbar;
package com.sobot.widget.ui.statusbar;
import android.content.Context;
import android.os.Build;
......
package com.sobot.common.ui.toast;
package com.sobot.widget.ui.toast;
import android.content.Context;
import android.view.Gravity;
......@@ -7,7 +7,8 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.widget.ui.utils.SobotResourceUtils;
/**
* 自定义时长的Toast
......
package com.sobot.common.ui.toast;
package com.sobot.widget.ui.toast;
import android.content.Context;
import android.os.Handler;
......
package com.sobot.widget.ui.utils;
import android.content.Context;
import android.graphics.Color;
import android.os.Environment;
import android.support.v4.content.ContextCompat;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class SobotResourceUtils {
public static int getIdByName(Context context, String className,
String resName) {
context = context.getApplicationContext();
String packageName = context.getPackageName();
int indentify = context.getResources().getIdentifier(resName,
className, packageName);
return indentify;
}
public static int getResLayoutId(Context context, String name) {
return getIdByName(context, "layout", name);
}
public static int getResStrId(Context context, String name) {
return getIdByName(context, "string", name);
}
public static int getResColorId(Context context, String name) {
return getIdByName(context, "color", name);
}
public static int getResColorValue(Context context, String name) {
return ContextCompat.getColor(context, getResColorId(context, name));
}
public static int getDrawableId(Context context, String name) {
return SobotResourceUtils.getIdByName(context, "drawable", name);
}
public static String getResString(Context context, String name) {
return context.getResources().getString(getResStrId(context, name));
}
public static int getResId(Context context, String name) {
return SobotResourceUtils.getIdByName(context, "id", name);
}
//颜色id 转16进制颜色码
public static String getColorById(Context context, String name) {
if (context == null) {
return "";
}
StringBuffer stringBuffer = new StringBuffer();
int color = context.getResources().getColor(getResColorId(context, name));
stringBuffer.append("#");
stringBuffer.append(Integer.toHexString(Color.alpha(color)));
stringBuffer.append(Integer.toHexString(Color.red(color)));
stringBuffer.append(Integer.toHexString(Color.green(color)));
stringBuffer.append(Integer.toHexString(Color.blue(color)));
return stringBuffer.toString();
}
/**
* 从External文件目录下读取文件
*
* @param filePathName 要读取的文件的路径+文件名
* @return
* @throws IOException
*/
public static String readExternal(String filePathName) throws IOException {
StringBuffer stringBuffer = new StringBuffer();
// 获取External的可用状态
String storageState = Environment.getExternalStorageState();
if (storageState.equals(Environment.MEDIA_MOUNTED)) {
// 当External的可用状态为可用时
// 打开文件输入流
FileInputStream fis = null;
try {
fis = new FileInputStream(filePathName);
InputStreamReader reader = new InputStreamReader(fis,"UTF-8");
BufferedReader br = new BufferedReader(reader);
String line;
while ((line = br.readLine()) != null) {
stringBuffer.append(line);
}
br.close();
reader.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
return stringBuffer.toString();
}
}
\ No newline at end of file
package com.sobot.common.utils;
package com.sobot.widget.ui.utils;
import android.app.Activity;
import android.content.ContentValues;
......@@ -8,17 +8,19 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.support.v4.content.FileProvider;
import com.sobot.common.ui.SobotBaseConstant;
import com.sobot.common.ui.toast.SobotToastUtil;
import com.sobot.utils.SobotIOUtils;
import com.sobot.widget.ui.SobotBaseConstant;
import com.sobot.widget.ui.toast.SobotToastUtil;
import java.io.File;
import java.security.MessageDigest;
public class SobotCommonUtils {
public class SobotWidgetUtils {
/**
* activity打开选择图片界面
......@@ -114,7 +116,7 @@ public class SobotCommonUtils {
* @return
*/
public static File openCamera(Activity act, Fragment childFragment) {
String path = SobotPathManager.getInstance().getPicDir() + System.currentTimeMillis() + ".jpg";
String path = getPicDir(act) + System.currentTimeMillis() + ".jpg";
// 创建图片文件存放的位置
File cameraFile = new File(path);
SobotIOUtils.createFolder(cameraFile.getParentFile());
......@@ -169,4 +171,48 @@ public class SobotCommonUtils {
}
return "";
}
private static final String PIC_DIR = "pic";
private static String mRootPath;
private static final String ROOT_DIR = "download";
//sdcard/download/xxxx/pic
public static String getPicDir(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return getRootDir(context) + File.separator + PIC_DIR + File.separator;
} else {
return context.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getPath() + File.separator;
}
}
public static String getRootDir(Context context) {
if (mRootPath == null) {
String packageName = context != null ? context.getPackageName() : "";
mRootPath = Environment.getExternalStorageDirectory().getPath() + File.separator + ROOT_DIR + File.separator + encode(packageName + "cache_sobot");
}
return mRootPath;
}
private static String encode(String str) {
StringBuilder sb = new StringBuilder();
try {
MessageDigest instance = MessageDigest.getInstance("MD5");
byte[] digest = instance.digest(str.getBytes());
for (byte b : digest) {
int num = b & 0xff;
String hex = Integer.toHexString(num);
if (hex.length() < 2) {
sb.append("0");
}
sb.append(hex);
}
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
}
\ No newline at end of file
......@@ -36,7 +36,7 @@
android:gravity="center"
android:orientation="horizontal">
<com.sobot.common.ui.image.SobotRCImageView
<com.sobot.widget.ui.image.SobotRCImageView
android:id="@+id/sobot_avatar_iv"
android:layout_width="38dp"
android:layout_height="38dp"
......
......@@ -19,27 +19,27 @@
android:id="@+id/sobot_dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:textColor="@color/sobot_common_gray1"
android:textSize="17sp"
android:layout_marginEnd="5dp"
android:layout_marginStart="5dp" />
android:textSize="17sp" />
<TextView
android:id="@+id/sobot_dialog_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:textColor="@color/sobot_common_gray1"
android:textSize="14sp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" />
android:textSize="14sp" />
<View
android:layout_width="match_parent"
......
......@@ -22,4 +22,42 @@
<!--下拉刷新 尾部 加载中 旋转控件颜色-->
<color name="sobot_refresh_footer_progress_color">@color/sobot_refresh_progress_color</color>
<!--通用 颜色-->
<!--白色-->
<color name="sobot_white">#FFFFFF</color>
<!--绿色-->
<color name="sobot_common_green">#0DAEAF</color>
<!--主要文本色 大部分界面里的黑色文字-->
<color name="sobot_common_gray1">#D1D1D6</color>
<!--次要文本色-->
<color name="sobot_common_gray2">#7C7C80</color>
<!--占位文本色-->
<color name="sobot_common_gray3">#7C7C80</color>
<!--一级背景色-->
<color name="sobot_common_gray6">#1B1B1C</color>
<!--二级背景色-->
<color name="sobot_common_gray7">#262628</color>
<!-- 主题色 默认绿色 -->
<color name="sobot_color">@color/sobot_common_green</color>
<!--文字颜色 绿色变白色-->
<color name="sobot_common_wenzi_green_white">@color/sobot_color</color>
<!--线条分割线颜色-->
<color name="sobot_common_line_gray">#272729</color>
<!-- 头部开始 -->
<!-- 头部背景 -->
<color name="sobot_color_title_bar_bg">@color/sobot_white</color>
<!-- 状态栏的颜色设置 -->
<color name="sobot_status_bar_color">@color/sobot_color_title_bar_bg</color>
<!-- 头部中间昵称颜色 -->
<color name="sobot_color_title_bar_title">@color/sobot_common_gray1</color>
<!-- 头部两侧菜单字体颜色 -->
<color name="sobot_color_title_bar_menu_text">@color/sobot_common_gray1</color>
<!--头部头像边框颜色-->
<color name="sobot_color_title_bar_avatar_line">#EDEEF0</color>
</resources>
......@@ -188,4 +188,61 @@
<attr name="sobot_tileBackgroundColor" format="color"/>
</declare-styleable>
<!--圆形-->
<attr name="sobot_round_as_circle" format="boolean" />
<!--全部圆角半径-->
<attr name="sobot_round_corner" format="integer|dimension" />
<!--针对各个角的半径-->
<attr name="sobot_round_corner_top_left" format="integer|dimension" />
<attr name="sobot_round_corner_top_right" format="integer|dimension" />
<attr name="sobot_round_corner_bottom_left" format="integer|dimension" />
<attr name="sobot_round_corner_bottom_right" format="integer|dimension" />
<!--描边颜色/半径-->
<attr name="sobot_stroke_color" format="color|reference" />
<attr name="sobot_stroke_width" format="integer|dimension" />
<!-- 是否剪裁 RCLayout 的背景 -->
<attr name="sobot_clip_background" format="boolean" />
<!--真正用于解析的属性-->
<declare-styleable name="SobotRCAttrs">
<attr name="sobot_round_as_circle" />
<attr name="sobot_round_corner" />
<attr name="sobot_round_corner_top_left" />
<attr name="sobot_round_corner_top_right" />
<attr name="sobot_round_corner_bottom_left" />
<attr name="sobot_round_corner_bottom_right" />
<attr name="sobot_stroke_color" />
<attr name="sobot_stroke_width" />
<attr name="sobot_clip_background" />
</declare-styleable>
<!--假体:用于提示-->
<declare-styleable name="sobot_RCRelativeLayout">
<attr name="sobot_round_as_circle" />
<attr name="sobot_round_corner" />
<attr name="sobot_round_corner_top_left" />
<attr name="sobot_round_corner_top_right" />
<attr name="sobot_round_corner_bottom_left" />
<attr name="sobot_round_corner_bottom_right" />
<attr name="sobot_stroke_color" />
<attr name="sobot_stroke_width" />
<attr name="sobot_clip_background" />
</declare-styleable>
<declare-styleable name="sobot_RCImageView">
<attr name="sobot_round_as_circle" />
<attr name="sobot_round_corner" />
<attr name="sobot_round_corner_top_left" />
<attr name="sobot_round_corner_top_right" />
<attr name="sobot_round_corner_bottom_left" />
<attr name="sobot_round_corner_bottom_right" />
<attr name="sobot_stroke_color" />
<attr name="sobot_stroke_width" />
<attr name="sobot_clip_background" />
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -27,4 +27,43 @@
<!--加载布局控件文字颜色-->
<color name="sobot_loading_layout_text_color">#8B98AD</color>
<!--通用 颜色-->
<!--白色-->
<color name="sobot_white">#FFFFFF</color>
<!--绿色-->
<color name="sobot_common_green">#0DAEAF</color>
<!--主要文本色 大部分界面里的黑色文字-->
<color name="sobot_common_gray1">#515A7C</color>
<!--次要文本色-->
<color name="sobot_common_gray2">#ACB5C4</color>
<!--占位文本色-->
<color name="sobot_common_gray3">#DDE0E6</color>
<!--一级背景色-->
<color name="sobot_common_gray6">#FFFFFF</color>
<!--二级背景色-->
<color name="sobot_common_gray7">#FFF2F5F7</color>
<!-- 主题色 默认绿色 -->
<color name="sobot_color">@color/sobot_common_green</color>
<!--文字颜色 绿色变白色-->
<color name="sobot_common_wenzi_green_white">@color/sobot_color</color>
<!--线条分割线颜色-->
<color name="sobot_common_line_gray">#EDEEF0</color>
<!-- 头部开始 -->
<!-- 头部背景 -->
<color name="sobot_color_title_bar_bg">@color/sobot_white</color>
<!-- 状态栏的颜色设置 -->
<color name="sobot_status_bar_color">@color/sobot_color_title_bar_bg</color>
<!-- 头部中间昵称颜色 -->
<color name="sobot_color_title_bar_title">@color/sobot_common_gray1</color>
<!-- 头部两侧菜单字体颜色 -->
<color name="sobot_color_title_bar_menu_text">@color/sobot_common_gray1</color>
<!--头部头像边框颜色-->
<color name="sobot_color_title_bar_avatar_line">#EDEEF0</color>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment