Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
石璀亮
/
turingos
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 51d6cbe8
authored
Aug 03, 2019
by
cuiliang.shi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0.2 优化
1 parent
a376de32
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
40 deletions
.idea/misc.xml
README.md
app/build.gradle
app/src/main/java/com/toscl/turingos/MainActivity.java
app/src/main/res/layout/activity_main.xml
app/src/main/res/values/strings.xml
app/src/main/res/values/styles.xml
.idea/misc.xml
View file @
51d6cbe
...
...
@@ -35,7 +35,7 @@
</value>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
8
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_
7
"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
...
...
README.md
0 → 100644
View file @
51d6cbe
# 图灵机器人sdk开发
## 签名信息
alias: turingos
password: agenewturing
\ No newline at end of file
app/build.gradle
View file @
51d6cbe
...
...
@@ -15,8 +15,8 @@ android {
applicationId
"com.toscl.turingos"
minSdkVersion
15
targetSdkVersion
22
versionCode
1
versionName
"0.
1
"
versionCode
2
versionName
"0.
2
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
ndk
{
...
...
app/src/main/java/com/toscl/turingos/MainActivity.java
View file @
51d6cbe
...
...
@@ -2,7 +2,6 @@ package com.toscl.turingos;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
import
android.content.pm.ApplicationInfo
;
import
android.content.pm.PackageManager
;
import
android.graphics.Color
;
...
...
@@ -30,6 +29,7 @@ import com.toscl.turingos.util.ContentBean;
import
com.toscl.turingos.util.FunctionConstants
;
import
com.toscl.turingos.util.MusicHandler
;
import
com.toscl.turingos.util.OSDataTransformUtil
;
import
com.toscl.turingos.util.PreferencesUtil
;
import
com.toscl.turingos.util.SkillsSlotUtil
;
import
com.toscl.turingos.util.TuringMusic
;
import
com.toscl.turingos.view.PlayView
;
...
...
@@ -179,20 +179,20 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// Snackbar.with(this).text("正在播放中...").duration(300).show(this);
}
private
void
addContactToRobot
()
{
private
void
uploadThePhoneInfoToTuring
()
{
AppAndContactsBean
appAndContactsBean
=
new
AppAndContactsBean
();
SharedPreferences
preferences
=
getSharedPreferences
(
"simstatus"
,
Context
.
MODE_PRIVATE
);
if
(
preferences
.
getBoolean
(
"robot_first_start"
,
true
))
{
if
(!
PreferencesUtil
.
getInstance
(
mContext
).
getBoolean
(
"is_uploaded_contact_2"
,
false
))
{
Map
<
String
,
String
>
appMap
=
SkillsSlotUtil
.
queryFilterAppInfo
(
MainActivity
.
this
);
appAndContactsBean
.
setAppsMap
(
appMap
);
SharedPreferences
.
Editor
editor
=
preferences
.
edit
();
editor
.
putBoolean
(
"robot_first_start"
,
false
);
editor
.
apply
();
PreferencesUtil
.
getInstance
(
mContext
).
putBoolean
(
"is_uploaded_contact_2"
,
true
);
}
Map
<
String
,
String
>
contactMap
=
SkillsSlotUtil
.
getContacts
(
MainActivity
.
this
);
Map
<
String
,
String
>
contactMap
=
SkillsSlotUtil
.
getContacts
(
mContext
);
appAndContactsBean
.
setContactMap
(
contactMap
);
SemanticManager
.
getInstance
().
uploadAppsAndContacts
(
appAndContactsBean
,
new
OnHttpRequestListener
()
{
@Override
public
void
onSuccess
(
String
result
)
{
...
...
@@ -259,7 +259,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if
(!
welcome
.
equals
(
""
))
{
ttsSequenceList
.
add
(
welcome
);
// mResultText.setText(welcome);
handleTtsOfWelcome
(
ttsSequenceList
);
readTheInfo
(
ttsSequenceList
);
}
}
...
...
@@ -293,9 +293,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(!
mFirstIn
)
{
/*
if (!mFirstIn) {
initSDK();
}
}
*/
}
private
ScrollEditText
mResultText
;
...
...
@@ -325,8 +325,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
List
<
String
>
ttsSequenceList
=
new
ArrayList
<>();
ttsSequenceList
.
add
(
"我是"
+
getString
(
R
.
string
.
app_name
)
+
",有什么可以帮你的吗"
);
handleTtsOfWelcome
(
ttsSequenceList
);
addContactToRobot
();
readTheInfo
(
ttsSequenceList
);
uploadThePhoneInfoToTuring
();
}
}
...
...
@@ -353,25 +353,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
public
void
onError
(
final
int
errorCode
,
final
String
s
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
mLoginSuccess
=
false
;
// mResultText.setText(s);
Log
.
d
(
TAG
,
"handleMyTips"
);
Message
msg
=
new
Message
();
msg
.
arg1
=
2
;
msg
.
obj
=
s
;
msg
.
arg1
=
3
;
msg
.
obj
=
"请检查网络后重试"
;
mLoadToastHandler
.
sendMessageAtTime
(
msg
,
100
);
traceTheErrorAndShowIt
();
}
});
if
(
errorCode
==
50000
){
mGlobalDialog
.
setTitleText
(
"请检查网络后重试"
);
mGlobalDialog
.
show
();
}
Log
.
e
(
TAG
,
"errorCode="
+
errorCode
+
" errorMsg="
+
s
);
}
};
...
...
@@ -614,14 +603,14 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if
(
mLoginSuccess
){
List
<
String
>
ttsSequenceList
=
new
ArrayList
<>();
ttsSequenceList
.
add
(
msg
.
obj
.
toString
());
handleTtsOfWelcome
(
ttsSequenceList
);
readTheInfo
(
ttsSequenceList
);
}
break
;
}
}
};
private
void
handleTtsOfWelcome
(
final
List
<
String
>
ttsSequenceList
)
{
private
void
readTheInfo
(
final
List
<
String
>
ttsSequenceList
)
{
Log
.
d
(
TAG
,
"ttsSequenceList SIZE = "
+
ttsSequenceList
.
size
());
Message
msg
=
new
Message
();
...
...
@@ -633,7 +622,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
TTSManager
.
getInstance
().
startTTS
(
ttsSequenceList
.
get
(
0
),
new
TTSListener
()
{
@Override
public
void
onSpeakBegin
(
String
s
)
{
Log
.
d
(
TAG
,
"
handleTtsOfWelcome
- ttsSequenceList onSpeakBegin"
);
Log
.
d
(
TAG
,
"
readTheInfo
- ttsSequenceList onSpeakBegin"
);
}
@Override
...
...
@@ -731,6 +720,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
};
private
void
traceTheErrorAndShowIt
()
{
Log
.
d
(
TAG
,
"traceTheErrorAndShowIt"
);
handleMyTips
(
getString
(
R
.
string
.
app_name
)
+
"刚刚出小差了,请再试一次吧"
);
}
...
...
@@ -904,7 +894,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
Log
.
d
(
TAG
,
"asrListener - onError: "
+
errorMessage
);
if
(
errorMessage
.
getCode
()
==
10006
)
{
//TODO
AsrManager
.
getInstance
().
stop
();
AsrManager
.
getInstance
().
init
(
getApplicationContext
(),
new
InitialListener
()
{
...
...
@@ -931,15 +920,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
public
void
onVolumeChange
(
int
i
)
{
if
(
i
>
20
)
{
/*
if (i > 20) {
mSilentTime = System.currentTimeMillis();
}
if (System.currentTimeMillis() - mSilentTime > 3000) {
Log.d(TAG, "Silent ERROR");
traceTheErrorAndShowIt();
AsrManager.getInstance().stop();
TTSManager.getInstance().stopTTS();
}
}
*/
}
};
...
...
app/src/main/res/layout/activity_main.xml
View file @
51d6cbe
...
...
@@ -3,7 +3,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"
#880E0E0E
"
>
android:background=
"
@mipmap/timg
"
>
<LinearLayout
android:layout_width=
"match_parent"
...
...
@@ -56,6 +56,9 @@
android:layout_width=
"45dp"
android:layout_height=
"49dp"
android:layout_weight=
"1"
android:nextFocusUp=
"@id/playview"
android:nextFocusLeft=
"@id/playview"
android:nextFocusRight=
"@id/playview"
android:background=
"@drawable/selector_record_bg"
android:clickable=
"true"
android:focusable=
"true"
...
...
@@ -107,7 +110,11 @@
app:solidColor=
"@color/color_3"
app:strokeWidth=
"10dp"
app:triangleColor=
"@color/color_3"
app:triangleHeight=
"40dp"
/>
app:triangleHeight=
"40dp"
android:nextFocusDown=
"@id/iat_recognize"
android:nextFocusUp=
"@id/iat_recognize"
android:nextFocusLeft=
"@id/iat_recognize"
android:nextFocusRight=
"@id/iat_recognize"
/>
</LinearLayout>
</RelativeLayout>
...
...
app/src/main/res/values/strings.xml
View file @
51d6cbe
<resources>
<string
name=
"app_name"
>
小
毛
</string>
<string
name=
"app_name"
>
小
P
</string>
<string
name=
"turing_appkey"
>
19693c9351fb41c9bb7b5b2695fd890b
</string>
<string
name=
"turing_secret"
>
goV639J27FRW8Y9F
</string>
<string
name=
"network_error"
>
网络慢.缓冲失败
</string>
...
...
app/src/main/res/values/styles.xml
View file @
51d6cbe
...
...
@@ -23,9 +23,11 @@
<item
name=
"windowNoTitle"
>
true
</item>
</style>
<style
name=
"AppTheme.Launcher"
>
<item
name=
"android:windowFullscreen"
>
true
</item>
<item
name=
"android:windowContentOverlay"
>
@null
</item>
<item
name=
"android:windowBackground"
>
@color/float_transparent
</item>
<item
name=
"android:windowIsTranslucent"
>
true
</item>
<item
name=
"android:windowFullscreen"
>
true
</item>
<item
name=
"android:windowNoTitle"
>
true
</item>
</style>
<style
name=
"dialog"
parent=
"@android:style/Theme.Dialog"
>
<item
name=
"android:windowFrame"
>
@null
</item>
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment