Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
ab504794
Commit
ab504794
authored
May 26, 2022
by
upwork.021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 代码提交
parent
a3309601
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
438 additions
and
1 deletions
+438
-1
AndroidManifest.xml
m-muse/src/main/AndroidManifest.xml
+1
-0
ChooseMusicActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/ChooseMusicActivity.kt
+163
-0
PlayMeditationActivity.kt
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
+4
-1
ChooseMusicDialog.kt
m-muse/src/main/java/com/yidianling/muse/dialog/ChooseMusicDialog.kt
+130
-0
JsInterface.kt
m-muse/src/main/java/com/yidianling/muse/dialog/JsInterface.kt
+49
-0
dialog_bottom_enter.xml
m-muse/src/main/res/anim/dialog_bottom_enter.xml
+15
-0
dialog_bottom_exit.xml
m-muse/src/main/res/anim/dialog_bottom_exit.xml
+15
-0
ic_close_choose_music.png
m-muse/src/main/res/drawable-xhdpi/ic_close_choose_music.png
+0
-0
shape_bg_solid_282e3f_r_top_20.xml
m-muse/src/main/res/drawable/shape_bg_solid_282e3f_r_top_20.xml
+9
-0
dialog_choose_music.xml
m-muse/src/main/res/layout/dialog_choose_music.xml
+36
-0
styles.xml
m-muse/src/main/res/values/styles.xml
+16
-0
No files found.
m-muse/src/main/AndroidManifest.xml
View file @
ab504794
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
android:name=
".activity.MeditationTimeOffActivity"
android:name=
".activity.MeditationTimeOffActivity"
android:screenOrientation=
"portrait"
android:screenOrientation=
"portrait"
android:theme=
"@style/platform_NoTitleTheme"
/>
android:theme=
"@style/platform_NoTitleTheme"
/>
<activity
android:name=
".activity.ChooseMusicActivity"
/>
<service
android:name=
".service.MeditationWindowService"
/>
<service
android:name=
".service.MeditationWindowService"
/>
...
...
m-muse/src/main/java/com/yidianling/muse/activity/ChooseMusicActivity.kt
0 → 100644
View file @
ab504794
package
com.yidianling.muse.activity
import
android.annotation.SuppressLint
import
android.content.Context
import
android.content.Intent
import
android.content.res.Resources
import
android.net.Uri
import
android.os.Build
import
android.os.Bundle
import
android.text.TextUtils
import
android.view.View
import
android.webkit.WebResourceRequest
import
android.webkit.WebSettings
import
android.webkit.WebView
import
android.webkit.WebViewClient
import
com.ydl.utils.WebUrlParamsUtils
import
com.ydl.ydlcommon.base.BaseActivity
import
com.ydl.ydlcommon.event.MeditationEvent
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.muse.R
import
com.yidianling.muse.dialog.JsInterface
import
de.greenrobot.event.EventBus
import
kotlinx.android.synthetic.main.dialog_choose_music.*
/**
* Created by Ykai on 2022/5/26.
*/
class
ChooseMusicActivity
:
BaseActivity
()
{
private
lateinit
var
mUrl
:
String
companion
object
{
private
const
val
URL
=
"url"
fun
launch
(
context
:
Context
,
url
:
String
)
{
Intent
(
context
,
ChooseMusicActivity
::
class
.
java
).
apply
{
putExtra
(
URL
,
url
)
context
.
startActivity
(
this
)
}
}
}
override
fun
initDataAndEvent
()
{
//正常获取入参
mUrl
=
intent
.
getStringExtra
(
URL
)
}
override
fun
layoutResId
():
Int
{
return
R
.
layout
.
dialog_choose_music
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
initView
()
}
@SuppressLint
(
"SetJavaScriptEnabled"
)
private
fun
initView
()
{
// 移除有漏洞的系统接口
wv_choose_music
.
removeJavascriptInterface
(
"searchBoxJavaBridge_"
)
wv_choose_music
.
removeJavascriptInterface
(
"accessibility"
)
wv_choose_music
.
removeJavascriptInterface
(
"accessibilityTraversal"
)
val
mWebSettings
:
WebSettings
=
wv_choose_music
.
settings
mWebSettings
.
javaScriptEnabled
=
true
//支持js
mWebSettings
.
defaultTextEncodingName
=
"GBK"
//设置字符编码
mWebSettings
.
domStorageEnabled
=
true
mWebSettings
.
textZoom
=
100
//设置字体不跟随字体变化而变化
mWebSettings
.
allowFileAccessFromFileURLs
=
true
mWebSettings
.
blockNetworkImage
=
false
// 解决图片不显示
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
mWebSettings
.
mixedContentMode
=
WebSettings
.
LOAD_NORMAL
}
wv_choose_music
.
scrollBarStyle
=
View
.
SCROLLBARS_INSIDE_OVERLAY
//滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
val
jsInterface
=
JsInterface
(
this
)
wv_choose_music
.
addJavascriptInterface
(
jsInterface
,
"javascriptHandler"
)
val
url
=
setUrlHeightParams
(
mUrl
)
LogUtil
.
e
(
url
)
wv_choose_music
.
loadUrl
(
url
)
wv_choose_music
.
webViewClient
=
object
:
WebViewClient
(){
override
fun
onPageFinished
(
view
:
WebView
?,
url
:
String
?)
{
super
.
onPageFinished
(
view
,
url
)
}
override
fun
shouldOverrideUrlLoading
(
view
:
WebView
,
request
:
WebResourceRequest
):
Boolean
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
view
.
loadUrl
(
request
.
url
.
toString
())
}
else
{
view
.
loadUrl
(
request
.
toString
())
}
return
true
}
}
ll_close
.
setOnClickListener
{
finish
()
}
}
fun
switchSound
(
mediaId
:
Int
,
meditationId
:
Long
,
meditationType
:
Int
,
businessType
:
Int
,
buried
:
String
?,
mediaUrl
:
String
?,
mediaCoverUrl
:
String
?,
title
:
String
?,
desc
:
String
?,
status
:
Int
)
{
val
event
=
MeditationEvent
(
mediaId
,
meditationId
,
meditationType
,
businessType
,
status
,
buried
!!
,
mediaUrl
!!
,
mediaCoverUrl
!!
,
title
!!
,
desc
!!
)
EventBus
.
getDefault
().
post
(
event
)
}
/**
* 专家详情页改版 需要url后面拼接状态栏高度 并且隐藏导航栏
*
* @param url
* @return
*/
private
fun
setUrlHeightParams
(
url
:
String
):
String
{
var
resultUrl
:
String
?
=
url
try
{
val
uri
=
Uri
.
parse
(
url
)
val
host
=
uri
.
host
if
(!
TextUtils
.
isEmpty
(
host
)
&&
host
.
contains
(
"nodeapi.ydl"
))
{
//马亮的需求,在nodeapi.ydl.com 地址后面拼上公共参数,用于判断是否为app
val
uriAppendSuffix
:
String
=
""
resultUrl
=
WebUrlParamsUtils
.
getSuffix
(
url
,
uriAppendSuffix
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
pinjie
(
resultUrl
)
}
private
fun
pinjie
(
jumpUrl
:
String
?):
String
{
var
useUrl
=
StringBuffer
().
append
(
jumpUrl
).
toString
()
val
res
:
Resources
=
resources
val
doctorUrlArray
=
res
.
getStringArray
(
R
.
array
.
platform_doctorUrls
)
for
(
url
in
doctorUrlArray
)
{
if
(
useUrl
.
contains
(
url
))
{
var
lastUrl
=
useUrl
.
replace
(
url
.
toRegex
(),
""
)
if
(
lastUrl
.
contains
(
"?"
))
{
lastUrl
=
lastUrl
.
substring
(
0
,
lastUrl
.
indexOf
(
"?"
))
}
try
{
//不报错就说明可以转成long,就说明是专家详情页地址
lastUrl
.
toLong
()
if
(!
lastUrl
.
contains
(
"/"
))
{
if
(
useUrl
.
endsWith
(
"?"
))
{
useUrl
=
useUrl
.
substring
(
0
,
useUrl
.
indexOf
(
"?"
))
}
}
}
catch
(
e
:
NumberFormatException
)
{
e
.
printStackTrace
()
}
}
}
return
useUrl
}
}
\ No newline at end of file
m-muse/src/main/java/com/yidianling/muse/activity/PlayMeditationActivity.kt
View file @
ab504794
...
@@ -24,6 +24,7 @@ import com.yidianling.common.tools.ToastUtil
...
@@ -24,6 +24,7 @@ import com.yidianling.common.tools.ToastUtil
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.home.http.MuseHttp
import
com.yidianling.muse.R
import
com.yidianling.muse.R
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.bean.MeditationPlayModuleBean
import
com.yidianling.muse.dialog.ChooseMusicDialog
import
com.yidianling.muse.event.MeditationFloatEvent
import
com.yidianling.muse.event.MeditationFloatEvent
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.helper.MediaPlayerManager
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
import
com.yidianling.muse.utils.MediaPlayerTimeUtil
...
@@ -282,7 +283,9 @@ class PlayMeditationActivity : BaseActivity() {
...
@@ -282,7 +283,9 @@ class PlayMeditationActivity : BaseActivity() {
return
@setOnClickListener
return
@setOnClickListener
}
}
if
(!
mediaListLink
.
isNullOrBlank
())
{
if
(!
mediaListLink
.
isNullOrBlank
())
{
NewH5Activity
.
start
(
this
,
H5Params
(
mediaListLink
!!
,
null
))
ChooseMusicActivity
.
launch
(
this
,
mediaListLink
!!
)
// val chooseMusicDialog = ChooseMusicDialog(this,H5Params(mediaListLink!!, null))
// chooseMusicDialog.show()
}
}
}
}
...
...
m-muse/src/main/java/com/yidianling/muse/dialog/ChooseMusicDialog.kt
0 → 100644
View file @
ab504794
package
com.yidianling.muse.dialog
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Dialog
import
android.content.res.Resources
import
android.net.Uri
import
android.os.Build
import
android.os.Bundle
import
android.text.TextUtils
import
android.view.Gravity
import
android.view.View
import
android.view.WindowManager
import
android.webkit.WebSettings
import
com.ydl.utils.WebUrlParamsUtils
import
com.ydl.webview.H5Params
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.common.tools.RxDeviceTool
import
com.yidianling.muse.R
import
com.yidianling.muse.activity.PlayMeditationActivity
import
kotlinx.android.synthetic.main.dialog_choose_music.*
/**
* Created by Ykai on 2022/5/26.
*
* 选择音乐弹窗,内部是h5页面
*/
class
ChooseMusicDialog
(
activity
:
Activity
,
h5Params
:
H5Params
)
:
Dialog
(
activity
,
R
.
style
.
music_dialog_style
)
{
private
val
mActivity
=
activity
private
val
h5Params
:
H5Params
=
h5Params
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
// 设置宽度全屏
//dialog去除默认边距,宽度占满全屏
val
window
=
window
!!
window
.
setWindowAnimations
(
R
.
style
.
dialog_anim
)
// 把 DecorView 的默认 padding 取消,同时 DecorView 的默认大小也会取消
window
.
decorView
.
setPadding
(
0
,
0
,
0
,
0
)
val
layoutParams
=
window
.
attributes
layoutParams
.
gravity
=
Gravity
.
BOTTOM
layoutParams
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
layoutParams
.
height
=
(
RxDeviceTool
.
getScreenHeight
(
context
)*
0.89
).
toInt
()
window
.
attributes
=
layoutParams
setContentView
(
R
.
layout
.
dialog_choose_music
)
initView
()
}
@SuppressLint
(
"SetJavaScriptEnabled"
)
private
fun
initView
()
{
// 移除有漏洞的系统接口
wv_choose_music
.
removeJavascriptInterface
(
"searchBoxJavaBridge_"
)
wv_choose_music
.
removeJavascriptInterface
(
"accessibility"
)
wv_choose_music
.
removeJavascriptInterface
(
"accessibilityTraversal"
)
val
mWebSettings
:
WebSettings
=
wv_choose_music
.
settings
mWebSettings
.
javaScriptEnabled
=
true
//支持js
mWebSettings
.
defaultTextEncodingName
=
"GBK"
//设置字符编码
mWebSettings
.
domStorageEnabled
=
true
mWebSettings
.
textZoom
=
100
//设置字体不跟随字体变化而变化
mWebSettings
.
allowFileAccessFromFileURLs
=
true
mWebSettings
.
blockNetworkImage
=
false
// 解决图片不显示
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
mWebSettings
.
mixedContentMode
=
WebSettings
.
LOAD_NORMAL
}
wv_choose_music
.
scrollBarStyle
=
View
.
SCROLLBARS_INSIDE_OVERLAY
//滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
// val jsInterface = JsInterface(mActivity as PlayMeditationActivity)
// wv_choose_music.addJavascriptInterface(jsInterface, "javascriptHandler")
val
url
=
setUrlHeightParams
(
h5Params
.
url
)
wv_choose_music
.
loadUrl
(
url
)
ll_close
.
setOnClickListener
{
dismiss
()
}
}
/**
* 专家详情页改版 需要url后面拼接状态栏高度 并且隐藏导航栏
*
* @param url
* @return
*/
private
fun
setUrlHeightParams
(
url
:
String
):
String
{
var
resultUrl
:
String
?
=
url
try
{
val
uri
=
Uri
.
parse
(
url
)
val
host
=
uri
.
host
if
(!
TextUtils
.
isEmpty
(
host
)
&&
host
.
contains
(
"nodeapi.ydl"
))
{
//马亮的需求,在nodeapi.ydl.com 地址后面拼上公共参数,用于判断是否为app
val
uriAppendSuffix
=
""
resultUrl
=
WebUrlParamsUtils
.
getSuffix
(
url
,
uriAppendSuffix
)
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
return
pinjie
(
resultUrl
)
}
private
fun
pinjie
(
jumpUrl
:
String
?):
String
{
var
useUrl
=
StringBuffer
().
append
(
jumpUrl
).
toString
()
val
res
:
Resources
=
mActivity
.
resources
val
doctorUrlArray
=
res
.
getStringArray
(
R
.
array
.
platform_doctorUrls
)
for
(
url
in
doctorUrlArray
)
{
if
(
useUrl
.
contains
(
url
))
{
var
lastUrl
=
useUrl
.
replace
(
url
.
toRegex
(),
""
)
if
(
lastUrl
.
contains
(
"?"
))
{
lastUrl
=
lastUrl
.
substring
(
0
,
lastUrl
.
indexOf
(
"?"
))
}
try
{
//不报错就说明可以转成long,就说明是专家详情页地址
lastUrl
.
toLong
()
if
(!
lastUrl
.
contains
(
"/"
))
{
if
(
useUrl
.
endsWith
(
"?"
))
{
useUrl
=
useUrl
.
substring
(
0
,
useUrl
.
indexOf
(
"?"
))
}
}
}
catch
(
e
:
NumberFormatException
)
{
e
.
printStackTrace
()
}
}
}
return
useUrl
}
}
\ No newline at end of file
m-muse/src/main/java/com/yidianling/muse/dialog/JsInterface.kt
0 → 100644
View file @
ab504794
package
com.yidianling.muse.dialog
import
android.webkit.JavascriptInterface
import
com.google.gson.GsonBuilder
import
com.ydl.webview.H5JsBean
import
com.yidianling.common.tools.LogUtil
import
com.yidianling.muse.activity.ChooseMusicActivity
/**
* Created by Ykai on 2021/8/23.
* 个人主页js交互类
*/
class
JsInterface
(
webActivity
:
ChooseMusicActivity
)
{
private
var
mWebActivity
=
webActivity
private
val
gson
by
lazy
{
GsonBuilder
().
create
()
}
@JavascriptInterface
fun
sendDataToOC
(
params
:
String
)
{
LogUtil
.
i
(
"js"
,
params
)
val
jsData
=
gson
.
fromJson
(
params
,
H5JsBean
::
class
.
java
)
jumpAction
(
jsData
)
}
private
fun
jumpAction
(
jsData
:
H5JsBean
)
{
when
(
jsData
.
cmd
?.
action_name
)
{
"switch_sound"
->
{
jsData
.
cmd
!!
.
params
?.
let
{
val
mediaId
=
it
.
mediaId
val
meditationId
=
it
.
meditationId
val
meditationType
=
it
.
meditionType
val
businessType
=
it
.
businessType
val
buried
=
it
.
buried
val
mediaUrl
=
it
.
mediaUrl
val
mediaCoverUrl
=
it
.
coverImageUrl
val
title
=
it
.
title
val
desc
=
it
.
desc
val
status
=
it
.
status
if
(
mediaId
!=
null
&&
meditationId
!=
null
&&
meditationType
!=
null
)
{
mWebActivity
.
switchSound
(
mediaId
,
meditationType
.
toLong
(),
businessType
!!
,
meditationId
,
buried
,
mediaUrl
,
mediaCoverUrl
,
title
,
desc
,
status
)
}
}
}
}
}
}
\ No newline at end of file
m-muse/src/main/res/anim/dialog_bottom_enter.xml
0 → 100644
View file @
ab504794
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:duration=
"200"
android:interpolator=
"@android:anim/decelerate_interpolator"
>
<translate
android:fromYDelta=
"100%"
android:toYDelta=
"0%"
/>
<alpha
android:fromAlpha=
"0"
android:toAlpha=
"1"
/>
</set>
\ No newline at end of file
m-muse/src/main/res/anim/dialog_bottom_exit.xml
0 → 100644
View file @
ab504794
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:duration=
"200"
android:interpolator=
"@android:anim/accelerate_interpolator"
>
<translate
android:fromYDelta=
"0%"
android:toYDelta=
"100%"
/>
<alpha
android:fromAlpha=
"1"
android:toAlpha=
"0"
/>
</set>
\ No newline at end of file
m-muse/src/main/res/drawable-xhdpi/ic_close_choose_music.png
0 → 100644
View file @
ab504794
1.58 KB
m-muse/src/main/res/drawable/shape_bg_solid_282e3f_r_top_20.xml
0 → 100644
View file @
ab504794
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"#282E3F"
/>
<corners
android:topLeftRadius=
"@dimen/platform_dp_20"
android:topRightRadius=
"@dimen/platform_dp_20"
/>
</shape>
\ No newline at end of file
m-muse/src/main/res/layout/dialog_choose_music.xml
0 → 100644
View file @
ab504794
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:background=
"@drawable/shape_bg_solid_282e3f_r_top_20"
>
<LinearLayout
android:id=
"@+id/ll_close"
android:layout_width=
"match_parent"
android:gravity=
"center_horizontal"
android:layout_height=
"38dp"
app:layout_constraintTop_toTopOf=
"parent"
>
<ImageView
android:layout_width=
"24dp"
android:layout_height=
"10dp"
android:src=
"@drawable/ic_close_choose_music"
android:layout_marginTop=
"12dp"
/>
</LinearLayout>
<WebView
android:id=
"@+id/wv_choose_music"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
app:layout_constraintTop_toBottomOf=
"@id/ll_close"
app:layout_constraintBottom_toBottomOf=
"parent"
android:background=
"#282E3F"
android:scrollbars=
"none"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
m-muse/src/main/res/values/styles.xml
View file @
ab504794
...
@@ -16,4 +16,19 @@
...
@@ -16,4 +16,19 @@
</style>
</style>
<style
name=
"music_dialog_style"
parent=
"@android:style/Theme.Dialog"
>
<item
name=
"android:windowBackground"
>
@color/transparent
</item>
<item
name=
"android:windowFrame"
>
@null
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
<item
name=
"android:windowIsFloating"
>
true
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
<item
name=
"android:backgroundDimEnabled"
>
true
</item>
</style>
<!-- 弹框-底部弹出动画 -->
<style
name=
"dialog_anim"
mce_bogus=
"1"
parent=
"android:Animation"
>
<item
name=
"android:windowEnterAnimation"
>
@anim/dialog_bottom_enter
</item>
<item
name=
"android:windowExitAnimation"
>
@anim/dialog_bottom_exit
</item>
</style>
</resources>
</resources>
\ No newline at end of file
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