Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
东方怂天
HuaZaiLauncher
提交
ac39f44b
H
HuaZaiLauncher
项目概览
东方怂天
/
HuaZaiLauncher
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
HuaZaiLauncher
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ac39f44b
编写于
6月 24, 2020
作者:
东方怂天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化了启动速度,增加了新页面。
上级
cf0ad4cd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
199 addition
and
41 deletion
+199
-41
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+17
-8
app/src/main/java/cn/EasertnDay/HuaZai/LauncherActivity.java
app/src/main/java/cn/EasertnDay/HuaZai/LauncherActivity.java
+25
-0
app/src/main/java/cn/EasertnDay/HuaZai/SplashActivity.java
app/src/main/java/cn/EasertnDay/HuaZai/SplashActivity.java
+11
-0
app/src/main/java/cn/EasertnDay/HuaZai/UserRegesite.java
app/src/main/java/cn/EasertnDay/HuaZai/UserRegesite.java
+126
-28
app/src/main/res/layout/activity_splash.xml
app/src/main/res/layout/activity_splash.xml
+7
-0
app/src/main/res/layout/activity_user_regesite.xml
app/src/main/res/layout/activity_user_regesite.xml
+13
-5
未找到文件。
app/src/main/AndroidManifest.xml
浏览文件 @
ac39f44b
...
...
@@ -22,11 +22,13 @@
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
"cn.EasertnDay.HuaZai.UserRegesite"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.SplashActivity"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -37,7 +39,8 @@
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.UserInformationSet"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.easternday.huazai.InformationService"
>
</activity>
...
...
@@ -52,33 +55,39 @@
android:name=
"cn.EasertnDay.HuaZai.SecondaryPage.TZXX"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.SecondaryPage.GJX"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.SecondaryPage.ZXXL"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.SecondaryPage.KWTBX"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.LauncherActivity"
android:configChanges=
"orientation|keyboardHidden|screenSize"
android:screenOrientation=
"landscape"
android:theme=
"@style/Theme.AppCompat.NoActionBar"
>
android:theme=
"@style/Theme.AppCompat.NoActionBar"
android:launchMode=
"singleTask"
>
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.HuaZaiActivity"
>
android:launchMode="singleTask"
</activity>
<activity
android:name=
"cn.EasertnDay.HuaZai.BasicMainActivity"
...
...
app/src/main/java/cn/EasertnDay/HuaZai/LauncherActivity.java
浏览文件 @
ac39f44b
...
...
@@ -78,6 +78,18 @@ public class LauncherActivity extends AppCompatActivity {
wifiInfo
=
wifiManager
.
getConnectionInfo
();
//WIFI信息
WifiIcon
=
findViewById
(
R
.
id
.
wifiIcon
);
//WIFI图标
//悬浮窗
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
//判断系统版本
if
(!
Settings
.
canDrawOverlays
(
this
))
{
Toast
.
makeText
(
this
,
"当前无权限,请授权"
,
Toast
.
LENGTH_SHORT
);
startActivityForResult
(
new
Intent
(
Settings
.
ACTION_MANAGE_OVERLAY_PERMISSION
,
Uri
.
parse
(
"package:"
+
getPackageName
())),
0
);
}
else
{
startService
(
new
Intent
(
LauncherActivity
.
this
,
InformationService
.
class
));
}
}
else
{
startService
(
new
Intent
(
LauncherActivity
.
this
,
InformationService
.
class
));
}
//触摸设置进入调试
SettingButton
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
...
...
@@ -322,4 +334,17 @@ public class LauncherActivity extends AppCompatActivity {
}
}
};
//悬浮窗判断
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
0
)
{
if
(!
Settings
.
canDrawOverlays
(
this
))
{
Toast
.
makeText
(
this
,
"授权失败"
,
Toast
.
LENGTH_SHORT
).
show
();
}
else
{
Toast
.
makeText
(
this
,
"授权成功"
,
Toast
.
LENGTH_SHORT
).
show
();
startService
(
new
Intent
(
LauncherActivity
.
this
,
InformationService
.
class
));
}
}
}
}
app/src/main/java/cn/EasertnDay/HuaZai/SplashActivity.java
浏览文件 @
ac39f44b
...
...
@@ -14,6 +14,7 @@ import android.support.constraint.ConstraintLayout;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.Toast
;
...
...
@@ -42,6 +43,8 @@ public class SplashActivity extends AppCompatActivity implements IAsrResultListe
ConstraintLayout
mLinearLayout
;
//总布局
ImageView
SplashMaskImage
;
//启动图遮罩
Intent
ii
=
new
Intent
(
SplashActivity
.
this
,
InformationService
.
class
);
//学生信息
File
file
=
new
File
(
InformationService
.
savePath
+
InformationService
.
fileName
);
boolean
IsInit
=
false
;
...
...
@@ -222,4 +225,12 @@ public class SplashActivity extends AppCompatActivity implements IAsrResultListe
e
.
printStackTrace
();
}
}
public
void
OnClick
(
View
view
)
{
if
(
IsInit
){
Log
.
d
(
"WHZ"
,
"垃圾应用"
);
Intent
myIntent
=
new
Intent
(
context
,
LauncherActivity
.
class
);
startActivity
(
myIntent
);
}
}
}
app/src/main/java/cn/EasertnDay/HuaZai/UserRegesite.java
浏览文件 @
ac39f44b
package
cn.EasertnDay.HuaZai
;
import
android.app.Activity
;
import
android.os.Handler
;
import
android.content.Intent
;
import
android.os.*
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
cn.EasertnDay.HuaZai.SecondaryPage.VoicePage
;
import
cn.EasternDay.HuaZai.R
;
import
com.unisound.sdk.asr.AsrEvent
;
import
com.unisound.sdk.asr.UnisoundAsrEngine
;
...
...
@@ -12,23 +17,55 @@ import com.unisound.sdk.asr.impl.IAsrResultListener;
import
com.unisound.sdk.tts.TtsOption
;
import
com.unisound.sdk.tts.UnisoundTtsEngine
;
import
com.unisound.sdk.tts.audiotrack.AndroidAudioTrack
;
import
com.unisound.sdk.tts.impl.ITtsEventListener
;
import
com.unisound.sdk.tts.param.UnisoundTtsPlayMode
;
import
com.unisound.sdk.utils.SdkLogMgr
;
import
org.json.JSONObject
;
public
class
UserRegesite
extends
AppCompatActivity
implements
IAsrResultListener
{
import
java.util.regex.Pattern
;
public
class
UserRegesite
extends
AppCompatActivity
{
Activity
context
=
this
;
String
TAG
=
"纣纣"
;
static
String
UserName
;
static
boolean
IsChinese
=
true
;
static
int
STATUS
=
0
;
//语音识别需要的
private
UnisoundAsrEngine
unisoundAsrEngine
;
//语音合成需要的
private
UnisoundTtsEngine
unisoundTtsEngine
;
TextView
Mess
;
ImageView
Show
;
//语音交互
public
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
switch
(
msg
.
what
)
{
case
0
:
handler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
STATUS
++;
}
},
3000
);
}
}
};
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_user_regesite
);
Mess
=
findViewById
(
R
.
id
.
RegisterMessage
);
Show
=
findViewById
(
R
.
id
.
FuckingShow
);
//语音识别
unisoundAsrEngine
=
VoicePresenter
.
getInstance
().
getUnisoundAsrEngine
();
...
...
@@ -45,42 +82,103 @@ public class UserRegesite extends AppCompatActivity implements IAsrResultListene
unisoundTtsEngine
.
setTtsOption
(
TtsOption
.
TTS_OPTION_BACK_SIL
,
50
);
unisoundTtsEngine
.
setTtsOption
(
TtsOption
.
TTS_OPTION_VOICE_NAME
,
"tangtang"
);
stopService
(
new
Intent
(
UserRegesite
.
this
,
InformationService
.
class
));
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
//开始收声
VoicePresenter
.
getInstance
().
setAsrListener
(
(
IAsrResultListener
)
context
);
VoicePresenter
.
getInstance
().
setAsrListener
(
iAsrResultListener
);
if
(
unisoundAsrEngine
.
startWakeUp
())
{
unisound
TtsEngine
.
playTts
(
"小朋友你叫什么名字?"
);
unisound
AsrEngine
.
startAsr
(
false
);
}
}
@Override
public
void
onResult
(
int
event
,
String
result
)
{
if
(
event
==
AsrEvent
.
ASR_EVENT_ASR_RESULT
)
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
result
);
String
asrResult
=
jsonObject
.
getString
(
"asr_recongize"
);
if
(!
TextUtils
.
isEmpty
(
asrResult
))
{
//语音监听
private
IAsrResultListener
iAsrResultListener
=
new
IAsrResultListener
()
{
@Override
public
void
onResult
(
int
event
,
String
result
)
{
Log
.
d
(
TAG
,
event
+
"||onResult: "
+
result
);
if
(
event
==
AsrEvent
.
ASR_EVENT_ASR_RESULT
)
{
try
{
Log
.
d
(
TAG
+
TAG
,
String
.
valueOf
(
STATUS
));
JSONObject
jsonObject
=
new
JSONObject
(
result
);
String
asrResult
=
jsonObject
.
getString
(
"asr_recongize"
);
Log
.
d
(
TAG
,
String
.
valueOf
(
STATUS
));
if
(
STATUS
==
0
)
{
handler
.
sendEmptyMessage
(
0
);
unisoundTtsEngine
.
playTts
(
"请选择语言"
);
Mess
.
setText
(
"请选择语言|Please select language\n【中文|English】"
);
STATUS
++;
}
else
if
(
STATUS
==
2
&&
asrResult
!=
""
)
{
IsChinese
=
!
asrResult
.
contains
(
"English"
);
STATUS
++;
}
else
if
(
STATUS
==
3
&&
asrResult
!=
""
)
{
unisoundTtsEngine
.
playTts
(
"好的小朋友你选择了"
+
(
IsChinese
?
"中文,"
:
"English,"
)
+
"那么,小朋友你叫什么名字呢?"
);
Mess
.
setText
(
"小朋友你叫什么名字"
);
handler
.
sendEmptyMessage
(
0
);
STATUS
++;
}
else
if
(
STATUS
==
5
&&
asrResult
!=
""
)
{
UserName
=
asrResult
.
replace
(
"我叫"
,
""
);
unisoundTtsEngine
.
playTts
(
"小朋友你是叫"
+
UserName
+
"吗?"
);
STATUS
++;
}
else
if
(
STATUS
==
6
&&
asrResult
!=
""
)
{
if
(
Pattern
.
matches
(
".*不.*"
,
asrResult
)
||
Pattern
.
matches
(
"退出"
,
asrResult
)
||
Pattern
.
matches
(
"否定"
,
asrResult
)
||
Pattern
.
matches
(
".*no.*"
,
asrResult
)
||
Pattern
.
matches
(
"否定"
,
asrResult
)
||
Pattern
.
matches
(
"i'm really want to but.*"
,
asrResult
)
||
Pattern
.
matches
(
"我还有其他事"
,
asrResult
)
||
Pattern
.
matches
(
"让我休息一下"
,
asrResult
)
||
Pattern
.
matches
(
"我累了"
,
asrResult
)
||
Pattern
.
matches
(
"改天吧"
,
asrResult
)
||
Pattern
.
matches
(
"错"
,
asrResult
)
||
Pattern
.
matches
(
"i'm not sure"
,
asrResult
)
||
Pattern
.
matches
(
"never"
,
asrResult
)
||
Pattern
.
matches
(
"none"
,
asrResult
)
||
Pattern
.
matches
(
"can't"
,
asrResult
)
||
Pattern
.
matches
(
"be a let down"
,
asrResult
)
||
Pattern
.
matches
(
"turn .* down"
,
asrResult
))
{
unisoundTtsEngine
.
playTts
(
"请小朋友你自己设置吧!"
);
STATUS
++;
Intent
myIntent
=
new
Intent
(
context
,
UserInformationSet
.
class
);
startActivity
(
myIntent
);
}
else
if
(
Pattern
.
matches
(
".*是.*"
,
asrResult
))
{
unisoundTtsEngine
.
playTts
(
"好的,"
+
UserName
+
"小朋友!"
);
STATUS
++;
Intent
myIntent
=
new
Intent
(
context
,
LauncherActivity
.
class
);
startActivity
(
myIntent
);
}
}
}
catch
(
Exception
e
)
{
SdkLogMgr
.
d
(
TAG
,
"error:"
+
e
.
toString
());
}
}
catch
(
Exception
e
)
{
unisoundAsrEngine
.
startWakeUp
();
unisoundAsrEngine
.
startAsr
(
false
);
}
if
(
event
==
AsrEvent
.
ASR_EVENT_WAKEUP_RESULT
)
{
unisoundAsrEngine
.
startAsr
(
false
);
}
}
}
@Override
public
void
onEvent
(
int
event
)
{
}
@Override
public
void
onEvent
(
int
event
)
{
Log
.
d
(
TAG
,
"onEvent:"
+
event
);
if
(
event
==
AsrEvent
.
ASR_EVENT_VAD_SPEECH_END
)
{
VoicePresenter
.
getInstance
().
getUnisoundAsrEngine
().
stopAsr
(
false
);
}
}
@Override
public
void
onError
(
int
error
)
{
unisoundAsrEngine
.
startWakeUp
(
);
}
@Override
public
void
onError
(
int
error
)
{
Log
.
d
(
TAG
,
"onError:"
+
error
);
}
@Override
public
void
onSessionId
(
String
sessionId
)
{
@Override
public
void
onSessionId
(
String
s
)
{
}
}
};
}
app/src/main/res/layout/activity_splash.xml
浏览文件 @
ac39f44b
...
...
@@ -9,4 +9,11 @@
android:background=
"@drawable/splash"
android:id=
"@+id/SplashMe"
>
<Button
android:text=
"跳过"
android:onClick=
"OnClick"
android:layout_width=
"150dp"
android:layout_height=
"75dp"
android:id=
"@+id/Skip_Button"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:layout_marginTop=
"50dp"
android:layout_marginEnd=
"100dp"
/>
</android.support.constraint.ConstraintLayout>
app/src/main/res/layout/activity_user_regesite.xml
浏览文件 @
ac39f44b
...
...
@@ -7,11 +7,19 @@
android:layout_height=
"match_parent"
tools:context=
"cn.EasertnDay.HuaZai.UserRegesite"
android:background=
"@drawable/main_background"
>
<TextView
android:layout_width=
"
10
00px"
android:layout_height=
"200px"
android:gravity=
"center"
android:background=
"@drawable/img_d
i
kuang"
<TextView
android:layout_width=
"
5
00px"
android:layout_height=
"200px"
android:gravity=
"center"
android:background=
"@drawable/img_d
uihua
kuang"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:layout_marginTop=
"50dp"
android:text=
"测试"
android:textSize=
"35dp"
android:textColor=
"@color/colorPrimaryDark"
android:id=
"@+id/RegisterMessage"
/>
app:layout_constraintTop_toTopOf=
"parent"
android:text=
""
android:textSize=
"35dp"
android:textColor=
"@color/colorPrimaryDark"
android:id=
"@+id/RegisterMessage"
app:layout_constraintHorizontal_bias=
"0.3"
app:layout_constraintBottom_toBottomOf=
"parent"
/>
<ImageView
android:layout_width=
"400dp"
android:layout_height=
"400dp"
app:srcCompat=
"@drawable/huazai"
android:id=
"@+id/FuckingShow"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.8"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.5"
/>
</android.support.constraint.ConstraintLayout>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录