Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
76d708b9
authored
Apr 30, 2020
by
mReturn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev模式下切换开发环境
parent
85ef039a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
267 additions
and
34 deletions
app/src/main/java/com/dayu/bigfish/InitializeActivity.java
app/src/main/java/com/dayu/bigfish/presenter/setting/SettingPresenter.java
app/src/main/java/com/dayu/bigfish/ui/SettingActivity.java
app/src/main/res/layout/activity_setting.xml
baseSDK/src/main/java/com/dayu/common/Constants.java
baseSDK/src/main/java/com/dayu/utils/AppUtils.java
baseSDK/src/main/res/values/strings.xml
app/src/main/java/com/dayu/bigfish/InitializeActivity.java
View file @
76d708b9
...
...
@@ -17,16 +17,20 @@ import com.dayu.bigfish.ui.MainActivity;
import
com.dayu.bigfish.ui.ManagerActivity
;
import
com.dayu.common.Constants
;
import
com.dayu.event.UserInfo
;
import
com.dayu.managercenter.data.Spu
;
import
com.dayu.managercenter.ui.activity.ServiceStationActivity
;
import
com.dayu.provider.router.RouterPath
;
import
com.dayu.usercenter.ui.activity.SmsLoginActivity
;
import
com.dayu.utils.AppUtils
;
import
com.dayu.utils.LogUtils
;
import
com.dayu.utils.MPermissionUtils
;
import
com.dayu.utils.SPUtils
;
import
com.dayu.utils.StationManager
;
import
com.dayu.utils.UserManager
;
import
com.dayu.widgets.CustomDialog
;
import
com.hyphenate.EMCallBack
;
import
com.hyphenate.chat.EMClient
;
import
com.megvii.idcardlib.util.Constant
;
import
com.umeng.analytics.MobclickAgent
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -46,6 +50,12 @@ public class InitializeActivity extends DataBindingActivity<ActivityInitializeMa
@Override
public
void
initView
()
{
if
(
Constants
.
CAN_CHANGE_ENV
){
AppUtils
.
initEnv
();
}
else
{
SPUtils
.
put
(
"env"
,
Constants
.
ENVIROMENT
);
}
MobclickAgent
.
openActivityDurationTrack
(
false
);
mActivity
=
this
;
String
[]
mPerArr
=
new
String
[]{
Manifest
.
permission
.
READ_PHONE_STATE
,
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
...
...
app/src/main/java/com/dayu/bigfish/presenter/setting/SettingPresenter.java
View file @
76d708b9
...
...
@@ -182,4 +182,17 @@ public class SettingPresenter extends SettingContract.Presenter {
mView
.
startActivity
(
FeedBackActivity
.
class
,
bundle
);
MobclickAgent
.
onEvent
(
MyApplication
.
getContext
(),
"feed_back"
);
}
public
void
toDev
(){
AppUtils
.
changeToDevEnv
();
AppUtils
.
exitApp
();
}
public
void
toUat
(){
AppUtils
.
changeToUatEnv
();
AppUtils
.
exitApp
();
}
public
void
toRelease
(){
AppUtils
.
changeToReleaseEnv
();
AppUtils
.
exitApp
();
}
}
app/src/main/java/com/dayu/bigfish/ui/SettingActivity.java
View file @
76d708b9
...
...
@@ -8,6 +8,7 @@ import android.os.Build;
import
android.os.Environment
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.content.FileProvider
;
import
android.view.View
;
import
com.alibaba.android.arouter.facade.annotation.Route
;
import
com.dayu.base.api.DownloadService
;
...
...
@@ -19,7 +20,9 @@ import com.dayu.bigfish.api.protocol.VersionInfo;
import
com.dayu.bigfish.databinding.ActivitySettingBinding
;
import
com.dayu.bigfish.presenter.setting.SettingContract
;
import
com.dayu.bigfish.presenter.setting.SettingPresenter
;
import
com.dayu.common.Constants
;
import
com.dayu.provider.router.RouterPath
;
import
com.dayu.utils.AppUtils
;
import
com.dayu.widgets.CustomDialog
;
import
com.dayu.widgets.listener.OnCloseListener
;
import
com.dayu.widgets.listener.onDownloadListener
;
...
...
@@ -42,8 +45,21 @@ public class SettingActivity extends BaseActivity<SettingPresenter, ActivitySett
@Override
public
void
initView
()
{
mBind
.
toolbar
.
setNavigationOnClickListener
(
v
->
dumpBack
());
mBind
.
toolbar
.
setNavigationOnClickListener
(
v
->
dumpBack
());
mBind
.
tvTitle
.
setText
(
getString
(
R
.
string
.
setting_center
));
initChangeEnv
();
}
//初始化切换开发环境相关布局
private
void
initChangeEnv
()
{
mBind
.
llChangeEnv
.
setVisibility
(
Constants
.
CAN_CHANGE_ENV
?
View
.
VISIBLE
:
View
.
GONE
);
mBind
.
rlDev
.
setVisibility
(
AppUtils
.
isDevEnv
()
?
View
.
GONE
:
View
.
VISIBLE
);
mBind
.
rlUat
.
setVisibility
(
AppUtils
.
isUatEnv
()
?
View
.
GONE
:
View
.
VISIBLE
);
mBind
.
rlRelease
.
setVisibility
(
AppUtils
.
isReleaseEnv
()
?
View
.
GONE
:
View
.
VISIBLE
);
// if (Constants.IS_DEBUG) {
// mBind.tvTitle.setOnClickListener(v -> onTitleClick());
// }
}
@Override
...
...
@@ -123,4 +139,16 @@ public class SettingActivity extends BaseActivity<SettingPresenter, ActivitySett
.
setContentText
(
getString
(
R
.
string
.
new_version
));
notificationManager
.
notify
(
0
,
builder
.
build
());
}
private
int
clickCount
=
0
;
public
void
onTitleClick
()
{
clickCount
++;
if
(
clickCount
>=
5
){
mBind
.
llChangeEnv
.
setVisibility
(
View
.
VISIBLE
);
clickCount
=
0
;
}
}
}
app/src/main/res/layout/activity_setting.xml
View file @
76d708b9
...
...
@@ -217,6 +217,94 @@
<TextView
style=
"@style/line"
/>
<LinearLayout
android:visibility=
"gone"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:id=
"@+id/ll_change_env"
>
<RelativeLayout
android:id=
"@+id/rl_dev"
android:layout_width=
"match_parent"
android:layout_height=
"54dp"
android:background=
"@color/cl_white"
android:onClick=
"@{()->presenter.toDev()}"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"13.3dp"
android:text=
"Dev环境"
android:textColor=
"@color/cl_home_title_text_color"
android:textSize=
"14.7sp"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"13.3dp"
android:src=
"@mipmap/list_more"
/>
</RelativeLayout>
<TextView
style=
"@style/line"
/>
<RelativeLayout
android:id=
"@+id/rl_uat"
android:layout_width=
"match_parent"
android:layout_height=
"54dp"
android:background=
"@color/cl_white"
android:onClick=
"@{()->presenter.toUat()}"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"13.3dp"
android:text=
"Uat环境"
android:textColor=
"@color/cl_home_title_text_color"
android:textSize=
"14.7sp"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"13.3dp"
android:src=
"@mipmap/list_more"
/>
</RelativeLayout>
<TextView
style=
"@style/line"
/>
<RelativeLayout
android:id=
"@+id/rl_release"
android:layout_width=
"match_parent"
android:layout_height=
"54dp"
android:background=
"@color/cl_white"
android:onClick=
"@{()->presenter.toRelease()}"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"13.3dp"
android:text=
"正式环境"
android:textColor=
"@color/cl_home_title_text_color"
android:textSize=
"14.7sp"
/>
<ImageView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_centerVertical=
"true"
android:layout_marginRight=
"13.3dp"
android:src=
"@mipmap/list_more"
/>
</RelativeLayout>
<TextView
style=
"@style/line"
/>
</LinearLayout>
<Button
android:id=
"@+id/exit_button"
android:layout_width=
"match_parent"
...
...
baseSDK/src/main/java/com/dayu/common/Constants.java
View file @
76d708b9
...
...
@@ -35,47 +35,51 @@ public class Constants {
/**
* dev环境配置.
*/
// public static final int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static final String ENVIROMENT = "debug";
// public static final String BASE_URL = "http://47.94.101.239:3112";
// public final static String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply";
// public final static String UP_VIDEO = "/file/uploadVideoOne?targetPath=dev/video";
// public final static String WEB_SOP = "http://47.94.101.239:9004/#/sop";
// public final static String CHECK_MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manyServiceResult";
// public final static String MULTI_WEB_SOP = "http://47.94.101.239:9004/#/manySop";
// public final static String WEB_SOP_DETAIL = "http://47.94.101.239:9004/#/sopdetail";
// public final static String WEB_ZHI_SHI = "http://47.94.101.239:9004/#/detail";
// public static final boolean IS_DEBUG = true;
public
static
String
ENVIROMENT
=
"debug"
;
public
static
final
int
LOG_LEVEL
=
LogUtils
.
LEVEL_ALL
;
public
static
String
BASE_URL
=
"http://47.94.101.239:3112"
;
public
static
String
WEB_SOP
=
"http://47.94.101.239:9004/#/sop"
;
public
static
String
CHECK_MULTI_WEB_SOP
=
"http://47.94.101.239:9004/#/manyServiceResult"
;
public
static
String
MULTI_WEB_SOP
=
"http://47.94.101.239:9004/#/manySop"
;
public
static
String
WEB_SOP_DETAIL
=
"http://47.94.101.239:9004/#/sopdetail"
;
public
static
String
WEB_ZHI_SHI
=
"http://47.94.101.239:9004/#/detail"
;
public
static
final
String
UP_PHOTO
=
"/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply"
;
public
static
final
String
UP_VIDEO
=
"/file/uploadVideoOne?targetPath=dev/video"
;
public
static
final
boolean
IS_DEBUG
=
true
;
public
static
final
boolean
CAN_CHANGE_ENV
=
true
;
//是否显示切换开发环境菜单
/**
* uat测试环境配置.
*/
// public static
final
String ENVIROMENT = "uat";
// public static
final
int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static
final
String BASE_URL = "http://47.95.223.6:3112";
// public
final static String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply
";
// public
final static String UP_VIDEO = "/file/uploadVideoOne?targetPath=test/video
";
// public
final static String WEB_SOP = "http://47.95.223.6:9004/#/sop
";
// public
final static String WEB_SOP_DETAIL = "http://47.95.223.6:9004/#/sopdetail
";
// public
final static String WEB_ZHI_SHI = "http://47.95.223.6:9004/#/detail
";
// public
final static String CHECK_MULTI_WEB_SOP = "http://47.95.223.6:9004/#/manyServiceResult
";
// public
final static String MULTI_WEB_SOP = "http://47.95.223.6:9004/#/manySop
";
// public static String ENVIROMENT = "uat";
// public static int LOG_LEVEL = LogUtils.LEVEL_ALL;
// public static String BASE_URL = "http://47.95.223.6:3112";
// public
static String WEB_SOP = "http://47.95.223.6:9004/#/sop
";
// public
static String WEB_SOP_DETAIL = "http://47.95.223.6:9004/#/sopdetail
";
// public
static String WEB_ZHI_SHI = "http://47.95.223.6:9004/#/detail
";
// public
static String CHECK_MULTI_WEB_SOP = "http://47.95.223.6:9004/#/manyServiceResult
";
// public
static String MULTI_WEB_SOP = "http://47.95.223.6:9004/#/manySop
";
// public
static final String UP_PHOTO = "/file/uploadMore?targetPath=test/sp/mobile/android/business/checkApply
";
// public
static final String UP_VIDEO = "/file/uploadVideoOne?targetPath=test/video
";
// public static final boolean IS_DEBUG = true;
// public static final boolean CAN_CHANGE_ENV = false; //是否显示切换开发环境菜单
/**
* 正式环境.
*/
public
static
final
String
ENVIROMENT
=
"release"
;
public
static
final
int
LOG_LEVEL
=
LogUtils
.
LEVEL_OFF
;
public
static
final
String
BASE_URL
=
"https://mobile.kf.ai"
;
public
final
static
String
UP_PHOTO
=
"/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply"
;
public
final
static
String
UP_VIDEO
=
"/file/uploadVideoOne?targetPath=online/video"
;
public
final
static
String
WEB_SOP
=
"https://sop.kf.ai/#/sop"
;
public
final
static
String
WEB_SOP_DETAIL
=
"https://sop.kf.ai/#/sopdetail"
;
public
final
static
String
WEB_ZHI_SHI
=
"https://sop.kf.ai/#/detail"
;
public
final
static
String
CHECK_MULTI_WEB_SOP
=
"https://sop.kf.ai/#/manyServiceResult"
;
public
final
static
String
MULTI_WEB_SOP
=
"https://sop.kf.ai/#/manySop"
;
public
static
final
boolean
IS_DEBUG
=
false
;
// public static String ENVIROMENT = "release";
// public static int LOG_LEVEL = LogUtils.LEVEL_OFF;
// public static String BASE_URL = "https://mobile.kf.ai";
// public static String WEB_SOP = "https://sop.kf.ai/#/sop";
// public static String WEB_SOP_DETAIL = "https://sop.kf.ai/#/sopdetail";
// public static String WEB_ZHI_SHI = "https://sop.kf.ai/#/detail";
// public static String CHECK_MULTI_WEB_SOP = "https://sop.kf.ai/#/manyServiceResult";
// public static String MULTI_WEB_SOP = "https://sop.kf.ai/#/manySop";
// public static final String UP_PHOTO = "/file/uploadMore?targetPath=online/sp/mobile/android/business/checkApply";
// public static final String UP_VIDEO = "/file/uploadVideoOne?targetPath=online/video";
// public static final boolean IS_DEBUG = false;
// public static final boolean CAN_CHANGE_ENV = false; //是否显示切换开发环境菜单
/**
* 统一配置.
...
...
baseSDK/src/main/java/com/dayu/utils/AppUtils.java
View file @
76d708b9
package
com
.
dayu
.
utils
;
import
android.annotation.SuppressLint
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.telephony.TelephonyManager
;
import
com.alibaba.android.arouter.launcher.ARouter
;
import
com.dayu.baselibrary.R
;
import
com.dayu.common.BaseApplication
;
import
com.dayu.common.BaseConstant
;
import
com.dayu.common.Constants
;
import
com.hyphenate.chat.EMClient
;
/**
...
...
@@ -19,6 +24,7 @@ public class AppUtils {
public
static
String
getIMEI
()
{
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
BaseApplication
.
getBaseApp
().
getSystemService
(
BaseApplication
.
getContext
().
TELEPHONY_SERVICE
);
@SuppressLint
(
"MissingPermission"
)
String
imei
=
telephonyManager
.
getDeviceId
();
return
imei
;
...
...
@@ -40,4 +46,88 @@ public class AppUtils {
}
}
public
static
boolean
isReleaseEnv
()
{
return
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
).
equals
(
"release"
);
}
public
static
boolean
isDevEnv
()
{
return
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
).
equals
(
"debug"
);
}
public
static
boolean
isUatEnv
()
{
return
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
).
equals
(
"uat"
);
}
/**
* 切换到dev环境
*/
public
static
void
changeToDevEnv
()
{
SPUtils
.
put
(
"env"
,
"debug"
);
Constants
.
ENVIROMENT
=
"debug"
;
Constants
.
BASE_URL
=
"http://47.94.101.239:3112"
;
Constants
.
WEB_SOP
=
"http://47.94.101.239:9004/#/sop"
;
Constants
.
CHECK_MULTI_WEB_SOP
=
"http://47.94.101.239:9004/#/manyServiceResult"
;
Constants
.
MULTI_WEB_SOP
=
"http://47.94.101.239:9004/#/manySop"
;
Constants
.
WEB_SOP_DETAIL
=
"http://47.94.101.239:9004/#/sopdetail"
;
Constants
.
WEB_ZHI_SHI
=
"http://47.94.101.239:9004/#/detail"
;
}
/**
* 切换到uat环境
*/
public
static
void
changeToUatEnv
()
{
SPUtils
.
put
(
"env"
,
"uat"
);
Constants
.
ENVIROMENT
=
"uat"
;
Constants
.
BASE_URL
=
"http://47.95.223.6:3112"
;
Constants
.
WEB_SOP
=
"http://47.95.223.6:9004/#/sop"
;
Constants
.
WEB_SOP_DETAIL
=
"http://47.95.223.6:9004/#/sopdetail"
;
Constants
.
WEB_ZHI_SHI
=
"http://47.95.223.6:9004/#/detail"
;
Constants
.
CHECK_MULTI_WEB_SOP
=
"http://47.95.223.6:9004/#/manyServiceResult"
;
Constants
.
MULTI_WEB_SOP
=
"http://47.95.223.6:9004/#/manySop"
;
}
/**
* 切换到release环境
*/
public
static
void
changeToReleaseEnv
()
{
SPUtils
.
put
(
"env"
,
"release"
);
Constants
.
ENVIROMENT
=
"release"
;
Constants
.
BASE_URL
=
"https://mobile.kf.ai"
;
Constants
.
WEB_SOP
=
"https://sop.kf.ai/#/sop"
;
Constants
.
WEB_SOP_DETAIL
=
"https://sop.kf.ai/#/sopdetail"
;
Constants
.
WEB_ZHI_SHI
=
"https://sop.kf.ai/#/detail"
;
Constants
.
CHECK_MULTI_WEB_SOP
=
"https://sop.kf.ai/#/manyServiceResult"
;
Constants
.
MULTI_WEB_SOP
=
"https://sop.kf.ai/#/manySop"
;
}
/**
* 退出登录
*/
public
static
void
exitApp
(){
EMClient
.
getInstance
().
logout
(
true
);
UserManager
.
getInstance
().
clearUserInfo
();
AppManager
.
getInstance
().
finishAllActivity
();
System
.
exit
(
0
);
}
/**
* 初始化开发环境
*/
public
static
void
initEnv
()
{
String
env
=
(
String
)
SPUtils
.
get
(
"env"
,
Constants
.
ENVIROMENT
);
switch
(
env
){
case
"debug"
:
changeToDevEnv
();
break
;
case
"uat"
:
changeToUatEnv
();
break
;
case
"release"
:
changeToReleaseEnv
();
break
;
}
}
}
baseSDK/src/main/res/values/strings.xml
View file @
76d708b9
...
...
@@ -114,7 +114,7 @@
<string
name=
"is_loading"
>
正在加载
</string>
<string
name=
"have_no_data"
>
没有更多数据
</string>
<string
name=
"try_load_again"
>
加载失败(再次上拉试试~)
</string>
<string
name=
"enviroment_debug"
>
测试
环境%1$s
</string>
<string
name=
"enviroment_debug"
>
Dev
环境%1$s
</string>
<string
name=
"enviroment_uat"
>
UAT环境%1$s
</string>
<string
name=
"enviroment_demons"
>
演示环境%1$s
</string>
<string
name=
"account_notice"
>
您的账号在另一台设备中登录
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment