Commit d425081c by app_dev@sobot.com

sobot common 0.6

parent 440b8dd5
...@@ -4,17 +4,15 @@ package com.sobot.moduletest; ...@@ -4,17 +4,15 @@ package com.sobot.moduletest;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import com.sobot.common.ui.SobotMarkConfig; import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.ui.base.SobotBaseActivity; import com.sobot.common.ui.base.SobotBaseActivity;
import com.sobot.common.ui.toast.SobotToastUtil; import com.sobot.common.ui.toast.SobotToastUtil;
import com.sobot.common.utils.SobotCommonApi; import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotCommonUtils; import com.sobot.common.utils.SobotImageUtils;
import com.sobot.network.http.HttpUtils; import com.sobot.network.http.HttpUtils;
import com.sobot.pictureframe.SobotBitmapUtil; import com.sobot.pictureframe.SobotBitmapUtil;
import com.sobot.utils.SobotImageUtils;
import com.sobot.utils.SobotLogUtils; import com.sobot.utils.SobotLogUtils;
import java.util.HashMap; import java.util.HashMap;
...@@ -44,8 +42,19 @@ public class MainActivity extends SobotBaseActivity { ...@@ -44,8 +42,19 @@ public class MainActivity extends SobotBaseActivity {
SobotBitmapUtil.display(this, R.mipmap.ic_launcher, img2); SobotBitmapUtil.display(this, R.mipmap.ic_launcher, img2);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("appId", "1c1da2c0aad047d7ba1d14ecd18ae4f6"); map.put("number", "142160000");
HttpUtils.getInstance().doPost(this, "https://api.sobot.com/chat-sdk/sdk/user/v1/getCategoryList.action", map, null, new HttpUtils.StringCallBack() { map.put("companyId", "1eae128b7e394aedafd28828bfa84767");
map.put("agentId", "969a7ee9fd4c42f48171b0128df2f16c");
map.put("displayNumber", "01051393569");
map.put("callWay", "2");
map.put("isRecordStereo", "false");
map.put("agentState", "1");
map.put("appId", "a4b246c8b67e4543b3b870ce62f75546");
map.put("groupId", "36b0f8eb2de948d99e89c8f0c3d92e68_5");
map.put("agentPhoneNum", "18600978969");
HttpUtils.getInstance().doPostByJsonString(this, "https://sobot.com/comm/api/4/call/agentOnWork?access_token=c273b74c-3b37-48cf-937f-9c46940cc19d", map, null, new HttpUtils.StringCallBack() {
@Override @Override
public void onResponse(String result) { public void onResponse(String result) {
SobotLogUtils.i(result); SobotLogUtils.i(result);
...@@ -63,14 +72,14 @@ public class MainActivity extends SobotBaseActivity { ...@@ -63,14 +72,14 @@ public class MainActivity extends SobotBaseActivity {
}); });
// selectPicFromLocal(); // selectPicFromLocal();
// selectVedioFromLocal(); // selectVedioFromLocal();
openCamera(); // openCamera();
} }
@Override @Override
protected void initData() { protected void initData() {
} }
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
try { try {
...@@ -90,7 +99,7 @@ public class MainActivity extends SobotBaseActivity { ...@@ -90,7 +99,7 @@ public class MainActivity extends SobotBaseActivity {
} }
} }
if (cameraFile != null && cameraFile.exists()) { if (cameraFile != null && cameraFile.exists()) {
SobotLogUtils.i("相机拍照:"+cameraFile.toString()); SobotLogUtils.i("相机拍照:" + cameraFile.toString());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -2,10 +2,9 @@ package com.sobot.moduletest; ...@@ -2,10 +2,9 @@ package com.sobot.moduletest;
import android.app.Application; import android.app.Application;
import com.sobot.network.apiUtils.SobotHttpUtils; import com.sobot.common.utils.SobotCommonApi;
import com.sobot.network.http.log.SobotNetLogUtils; import com.sobot.network.http.log.SobotNetLogUtils;
import com.sobot.utils.SobotLogUtils; import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotUtils;
/** /**
* @Description: java类作用描述 * @Description: java类作用描述
...@@ -17,8 +16,7 @@ public class MyApp extends Application { ...@@ -17,8 +16,7 @@ public class MyApp extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
SobotUtils.init(this); SobotCommonApi.init(this);
SobotHttpUtils.init(this);
SobotNetLogUtils.setShowDebug(true); SobotNetLogUtils.setShowDebug(true);
SobotLogUtils.setShowDebug(true); SobotLogUtils.setShowDebug(true);
......
...@@ -3,4 +3,8 @@ ...@@ -3,4 +3,8 @@
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#FF4081</color>
<color name="sobot_status_bar_color">#FF4081</color>
<color name="sobot_color_title_bar_bg">#FF4081</color>
</resources> </resources>
\ No newline at end of file
...@@ -13,14 +13,14 @@ android { ...@@ -13,14 +13,14 @@ android {
dependencies { dependencies {
api fileTree(include: ['*.jar'], dir: 'libs') api fileTree(include: ['*.jar'], dir: 'libs')
compileOnly 'com.squareup.okhttp3:okhttp:3.12.0' compileOnly 'com.squareup.okhttp3:okhttp:3.12.0'
compileOnly 'com.android.support:support-v4:28.0.0' compileOnly 'com.android.support:appcompat-v7:28.0.0'
// api project(':sobot_utils') // api project(':sobot_utils')
// api project(':sobot_pictureframe') // api project(':sobot_pictureframe')
// api project(':sobot_network') // api project(':sobot_network')
// api project(':sobot_gson') // api project(':sobot_gson')
api 'com.sobot.library:utils:1.0.1' api 'com.sobot.library:utils:1.0.4'
api 'com.sobot.library:picture:1.0.1' api 'com.sobot.library:picture:1.0.1'
api 'com.sobot.library:net:1.0.1' api 'com.sobot.library:net:1.0.3'
api 'com.sobot.library:gson:0.1' api 'com.sobot.library:gson:0.1'
} }
......
...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) { ...@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext { ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'sobotcommon' //项目名 PUBLISH_ARTIFACT_ID = 'sobotcommon' //项目名
PUBLISH_VERSION = '0.2' //版本号 PUBLISH_VERSION = '0.6' //版本号
} }
......
...@@ -35,8 +35,8 @@ import com.sobot.common.ui.permission.SobotPermissionTipDialog; ...@@ -35,8 +35,8 @@ import com.sobot.common.ui.permission.SobotPermissionTipDialog;
import com.sobot.common.ui.statusbar.SobotStatusBarUtils; import com.sobot.common.ui.statusbar.SobotStatusBarUtils;
import com.sobot.common.utils.SobotCommonApi; import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotCommonUtils; import com.sobot.common.utils.SobotCommonUtils;
import com.sobot.common.utils.SobotGlobalContext;
import com.sobot.common.utils.SobotResourceUtils; import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.utils.SobotGlobalContext;
import com.sobot.utils.SobotLogUtils; import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotSharedPreferencesUtil; import com.sobot.utils.SobotSharedPreferencesUtil;
import com.sobot.utils.SobotSystemUtils; import com.sobot.utils.SobotSystemUtils;
...@@ -85,7 +85,7 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -85,7 +85,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
setUpToolBar(); setUpToolBar();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
SobotGlobalContext.getInstance(getSobotBaseActivity()).addActivity(this); SobotGlobalContext.getInstance(getSobotBaseActivity()).addActivity(this);
View toolBar = findViewById(getResId("sobot_common_layout_titlebar")); View toolBar = findViewById(getResId("sobot_layout_titlebar"));
if (toolBar != null) { if (toolBar != null) {
setUpToolBarLeftMenu(); setUpToolBarLeftMenu();
...@@ -146,13 +146,6 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -146,13 +146,6 @@ public abstract class SobotBaseActivity extends FragmentActivity {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
conf.locale = language; conf.locale = language;
res.updateConfiguration(conf, dm); res.updateConfiguration(conf, dm);
} else {
//清除上次app 语言设置
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = new Configuration();
conf.locale = null;
res.updateConfiguration(conf, dm);
} }
} }
...@@ -277,7 +270,7 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -277,7 +270,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
SobotGlobalContext.getInstance(getSobotBaseActivity()).deleteActivity(this); SobotGlobalContext.getInstance(getSobotBaseActivity()).finishActivity(this);
super.onDestroy(); super.onDestroy();
} }
...@@ -462,15 +455,15 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -462,15 +455,15 @@ public abstract class SobotBaseActivity extends FragmentActivity {
return; return;
} }
} else if (type == 2) { } else if (type == 2) {
if (!checkStorageAndAudioPermission()) { if (!checkAudioPermission()) {
return; return;
} }
} else if (type == 3) { } else if (type == 3) {
if (!checkStorageAudioAndCameraPermission()) { if (!checkAudioAndCameraPermission()) {
return; return;
} }
} else if (type == 4) { } else if (type == 4) {
if (!checkStorageAndCameraPermission()) { if (!checkCameraPermission()) {
return; return;
} }
} }
...@@ -595,18 +588,8 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -595,18 +588,8 @@ public abstract class SobotBaseActivity extends FragmentActivity {
* *
* @return true, 已经获取权限;false,没有权限,尝试获取 * @return true, 已经获取权限;false,没有权限,尝试获取
*/ */
protected boolean checkStorageAndAudioPermission() { protected boolean checkAudioPermission() {
if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 23) { if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 23) {
if (Build.VERSION.SDK_INT >= 29 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 29) {
//分区存储 从andrid10手机开始 TargetSdkVersion >= 29,以下几种情况不需要文件存储权限
} else {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO},
SobotBaseConstant.SOBOT_CODE_PERMISSIONS_REQUEST);
return false;
}
}
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.RECORD_AUDIO) if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.RECORD_AUDIO)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, this.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO},
...@@ -637,19 +620,8 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -637,19 +620,8 @@ public abstract class SobotBaseActivity extends FragmentActivity {
* *
* @return true, 已经获取权限;false,没有权限,尝试获取 * @return true, 已经获取权限;false,没有权限,尝试获取
*/ */
protected boolean checkStorageAudioAndCameraPermission() { protected boolean checkAudioAndCameraPermission() {
if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 23) { if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 23) {
if (Build.VERSION.SDK_INT >= 29 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 29) {
//分区存储 从andrid10手机开始 TargetSdkVersion >= 29,不需要文件存储权限
} else {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE
, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}
, SobotBaseConstant.SOBOT_CODE_PERMISSIONS_REQUEST);
return false;
}
}
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.CAMERA) if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO} this.requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}
...@@ -687,18 +659,8 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -687,18 +659,8 @@ public abstract class SobotBaseActivity extends FragmentActivity {
* *
* @return true, 已经获取权限;false,没有权限,尝试获取 * @return true, 已经获取权限;false,没有权限,尝试获取
*/ */
protected boolean checkStorageAndCameraPermission() { protected boolean checkCameraPermission() {
if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 23) { if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 23) {
if (Build.VERSION.SDK_INT >= 29 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) >= 29) {
//分区存储 从andrid10手机开始 TargetSdkVersion >= 29,不需要文件存储权限
} else {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA},
SobotBaseConstant.SOBOT_CODE_PERMISSIONS_REQUEST);
return false;
}
}
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.CAMERA) if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
this.requestPermissions(new String[]{Manifest.permission.CAMERA}, this.requestPermissions(new String[]{Manifest.permission.CAMERA},
...@@ -745,14 +707,12 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -745,14 +707,12 @@ public abstract class SobotBaseActivity extends FragmentActivity {
SobotCommonUtils.openSelectPic(getSobotBaseActivity()); SobotCommonUtils.openSelectPic(getSobotBaseActivity());
} }
}; };
if (Build.VERSION.SDK_INT < 30 || SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity().getApplicationContext()) < 30) {
if (checkIsShowPermissionPop(getResString("sobot_memory_card"), getResString("sobot_memory_card_yongtu"), 1)) { if (checkIsShowPermissionPop(getResString("sobot_memory_card"), getResString("sobot_memory_card_yongtu"), 1)) {
return; return;
} }
if (!checkStoragePermission()) { if (!checkStoragePermission()) {
return; return;
} }
}
SobotCommonUtils.openSelectPic(this); SobotCommonUtils.openSelectPic(this);
} }
...@@ -777,14 +737,12 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -777,14 +737,12 @@ public abstract class SobotBaseActivity extends FragmentActivity {
SobotCommonUtils.openSelectVedio(getSobotBaseActivity()); SobotCommonUtils.openSelectVedio(getSobotBaseActivity());
} }
}; };
if (Build.VERSION.SDK_INT < 30 || SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) < 30) {
if (checkIsShowPermissionPop(getResString("sobot_memory_card"), getResString("sobot_memory_card_yongtu"), 1)) { if (checkIsShowPermissionPop(getResString("sobot_memory_card"), getResString("sobot_memory_card_yongtu"), 1)) {
return; return;
} }
if (!checkStoragePermission()) { if (!checkStoragePermission()) {
return; return;
} }
}
SobotCommonUtils.openSelectVedio(getSobotBaseActivity()); SobotCommonUtils.openSelectVedio(getSobotBaseActivity());
} }
...@@ -812,14 +770,12 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -812,14 +770,12 @@ public abstract class SobotBaseActivity extends FragmentActivity {
} }
} }
}; };
if (Build.VERSION.SDK_INT < 30 || SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity()) < 30) {
if (checkIsShowPermissionPop(TextUtils.isEmpty(title) ? getResString("sobot_camera") : title, TextUtils.isEmpty(content) ? getResString("sobot_camera_yongtu") : content, 4)) { if (checkIsShowPermissionPop(TextUtils.isEmpty(title) ? getResString("sobot_camera") : title, TextUtils.isEmpty(content) ? getResString("sobot_camera_yongtu") : content, 4)) {
return; return;
} }
if (!checkStorageAndCameraPermission()) { if (!checkCameraPermission()) {
return; return;
} }
}
if (isCameraCanUse()) { if (isCameraCanUse()) {
cameraFile = SobotCommonUtils.openCamera(getSobotBaseActivity()); cameraFile = SobotCommonUtils.openCamera(getSobotBaseActivity());
} }
......
...@@ -17,8 +17,8 @@ import android.widget.LinearLayout; ...@@ -17,8 +17,8 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.sobot.common.ui.SobotMarkConfig; import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.common.utils.SobotCommonApi; import com.sobot.common.utils.SobotCommonApi;
import com.sobot.common.utils.SobotResourceUtils;
import com.sobot.utils.SobotDensityUtil; import com.sobot.utils.SobotDensityUtil;
/** /**
......
package com.sobot.common.utils; package com.sobot.common.utils;
import android.app.Application; import android.app.Application;
import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import com.sobot.common.ui.SobotMarkConfig; import com.sobot.common.ui.SobotMarkConfig;
import com.sobot.gson.SobotGsonUtil;
import com.sobot.network.apiUtils.SobotHttpUtils; import com.sobot.network.apiUtils.SobotHttpUtils;
import com.sobot.network.http.log.SobotNetLogUtils; import com.sobot.network.http.log.SobotNetLogUtils;
import com.sobot.utils.SobotGlobalContext;
import com.sobot.utils.SobotLogUtils; import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotNetUtils;
import com.sobot.utils.SobotUtils;
public class SobotCommonApi { public class SobotCommonApi {
...@@ -22,8 +17,8 @@ public class SobotCommonApi { ...@@ -22,8 +17,8 @@ public class SobotCommonApi {
*/ */
public static void init(Application application) { public static void init(Application application) {
if (application != null) { if (application != null) {
SobotUtils.init(application);
SobotHttpUtils.init(application); SobotHttpUtils.init(application);
SobotGlobalContext.init(application);
} }
} }
......
...@@ -15,7 +15,6 @@ import android.support.v4.content.FileProvider; ...@@ -15,7 +15,6 @@ import android.support.v4.content.FileProvider;
import com.sobot.common.ui.SobotBaseConstant; import com.sobot.common.ui.SobotBaseConstant;
import com.sobot.common.ui.toast.SobotToastUtil; import com.sobot.common.ui.toast.SobotToastUtil;
import com.sobot.utils.SobotIOUtils; import com.sobot.utils.SobotIOUtils;
import com.sobot.utils.SobotPathManager;
import java.io.File; import java.io.File;
......
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