├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── Msc.jar │ ├── YoudaoBase.jar │ ├── YoudaoCnDictOffline.jar │ ├── YoudaoTranslateOffline.jar │ ├── YoudaoTranslateOnline.jar │ ├── arm64-v8a │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ └── libmsc.so │ ├── armeabi-v7a │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ └── libmsc.so │ ├── armeabi │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ ├── liblocalTransEngine.so │ │ └── libmsc.so │ ├── jcore-android-1.1.9.jar │ ├── jmessage-android_v2.4.1.jar │ ├── jpush-android-3.1.1.jar │ ├── mips │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ └── libmsc.so │ ├── mips64 │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ └── libmsc.so │ ├── x86 │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ └── libmsc.so │ └── x86_64 │ │ ├── libdict-parser.so │ │ ├── libjcore118.so │ │ ├── libjcore119.so │ │ └── libmsc.so ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── jakera │ │ └── smartchat │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── iflytek │ │ │ ├── recognize.xml │ │ │ ├── voice_bg.9.png │ │ │ ├── voice_empty.png │ │ │ ├── voice_full.png │ │ │ ├── waiting.png │ │ │ └── warning.png │ │ ├── t.wav │ │ ├── test.wav │ │ └── yinfu.wav │ ├── ic_launcher-web.png │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── jakera │ │ │ └── smartchat │ │ │ ├── Activity │ │ │ ├── ChatActivity.java │ │ │ ├── ContactAuthorActivity.java │ │ │ ├── CropPortraitAcitivity.java │ │ │ ├── MainActivity.java │ │ │ ├── ModifyPortraitActivity.java │ │ │ ├── RecognizerActivity.java │ │ │ ├── RegisterLoginActivity.java │ │ │ ├── SplashActivity.java │ │ │ └── UserInfoActivity.java │ │ │ ├── Adapter │ │ │ ├── ChatRecyclerViewAdapter.java │ │ │ ├── ContactAuthorViewPagerAdapter.java │ │ │ ├── FriendsListRecyclerAdapter.java │ │ │ ├── MessageRecyclerViewAdapter.java │ │ │ └── WatchMoreRecyclerAdapter.java │ │ │ ├── Entry │ │ │ ├── AnimalOrPlant.java │ │ │ ├── BaseMessageEntry.java │ │ │ ├── BeautifulPictureEntry.java │ │ │ ├── Car.java │ │ │ ├── Dish.java │ │ │ ├── MessageEntry.java │ │ │ ├── TextMessageEntry.java │ │ │ └── VoiceMessageEntry.java │ │ │ ├── Fragment │ │ │ ├── FriendsListFragment.java │ │ │ ├── MessageListFragment.java │ │ │ ├── SmartChatFragmentAdapter.java │ │ │ ├── UserInfoFragment.java │ │ │ └── WatchMoreFragment.java │ │ │ ├── Interface │ │ │ ├── EndLessOnScrollListener.java │ │ │ └── ItemClickListener.java │ │ │ ├── Others │ │ │ └── PicassoTransformation.java │ │ │ ├── Receiver │ │ │ └── PushReceiver.java │ │ │ ├── SmartChatApp.java │ │ │ ├── SmartChatConstant.java │ │ │ ├── SmartChatService.java │ │ │ ├── Utils │ │ │ ├── AudioDecode.java │ │ │ ├── AudioManager.java │ │ │ ├── AudioRecorderUtil.java │ │ │ ├── BaiduAuthService.java │ │ │ ├── BaiduFileUtil.java │ │ │ ├── Base64Util.java │ │ │ ├── DeleteFileUtil.java │ │ │ ├── DialogManager.java │ │ │ ├── FileUtil.java │ │ │ ├── GsonUtils.java │ │ │ ├── HttpUtil.java │ │ │ ├── MediaManager.java │ │ │ ├── MySQLiteOpenHelper.java │ │ │ ├── OkhttpHelper.java │ │ │ ├── RecognizerHelper.java │ │ │ ├── RecognizerUtil.java │ │ │ ├── SharePreferenceUtils.java │ │ │ ├── SpeechSynthesizerUtil.java │ │ │ ├── TimeUtil.java │ │ │ └── TranslateUtil.java │ │ │ └── Views │ │ │ ├── AudioRecorderButton.java │ │ │ ├── BubbleDrawable.java │ │ │ ├── BubbleImageView.java │ │ │ ├── BubbleLinearLayout.java │ │ │ ├── BubbleTextView.java │ │ │ ├── CircleImageView.java │ │ │ ├── ClipView.java │ │ │ ├── ClipViewLayout.java │ │ │ └── LoadingDialog.java │ └── res │ │ ├── anim │ │ ├── tranlate_dialog_in.xml │ │ └── tranlate_dialog_out.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── address.png │ │ ├── back.png │ │ ├── btn_recorder_normal.xml │ │ ├── btn_recording.xml │ │ ├── btn_red_round_shape.xml │ │ ├── button_blue_round_shape.xml │ │ ├── camera.png │ │ ├── chatto_bg_focused.9.png │ │ ├── chinese.png │ │ ├── dialog_loading_bg.9.png │ │ ├── edit_border.xml │ │ ├── english.png │ │ ├── ic_launcher_background.xml │ │ ├── icon_add_friends.png │ │ ├── loading.png │ │ ├── message.png │ │ ├── more.png │ │ ├── news.png │ │ ├── password.png │ │ ├── person.png │ │ ├── robot_portrait.jpeg │ │ ├── voice.png │ │ ├── voice_chat.png │ │ ├── wyu1.jpeg │ │ ├── wyu2.jpeg │ │ ├── wyu3.jpeg │ │ └── wyu4.jpeg │ │ ├── layout │ │ ├── acitivity_modify_portrait.xml │ │ ├── activity_chat.xml │ │ ├── activity_contact_author.xml │ │ ├── activity_crop_portrait.xml │ │ ├── activity_main.xml │ │ ├── activity_recognizer.xml │ │ ├── activity_register_login.xml │ │ ├── activity_splash.xml │ │ ├── activity_userinfo.xml │ │ ├── chat_left_item.xml │ │ ├── chat_right_item.xml │ │ ├── dialog_item_edittext.xml │ │ ├── dialog_loading.xml │ │ ├── dialog_recorder.xml │ │ ├── friends_list_fragment.xml │ │ ├── friends_list_item.xml │ │ ├── message_list_fragment.xml │ │ ├── message_list_item.xml │ │ ├── portrait_bottom_bar.xml │ │ ├── title_bar.xml │ │ ├── user_info_fragment.xml │ │ ├── vp_item_author.xml │ │ ├── watch_more_fragment.xml │ │ └── watch_more_list_item.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── authenticatication.png │ │ ├── cabbage.png │ │ ├── car.png │ │ ├── chat_sound_left.png │ │ ├── chat_sound_right.png │ │ ├── contact.png │ │ ├── foreward.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ ├── ic_launcher_round.png │ │ ├── icon.png │ │ ├── modify.png │ │ ├── monkey.png │ │ ├── plant.png │ │ ├── recorder.png │ │ ├── splash.jpeg │ │ ├── sunset.png │ │ ├── v1.png │ │ ├── v2.png │ │ ├── v3.png │ │ ├── v4.png │ │ ├── v5.png │ │ ├── v6.png │ │ ├── v7.png │ │ ├── voice_cancel.png │ │ └── voice_to_short.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── attrs.xml │ │ ├── bubbleView_attrs.xml │ │ ├── colors.xml │ │ ├── jpush_style.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── jakera │ └── smartchat │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── 个人资料.png ├── 主界面.png ├── 发送语音.png ├── 启动页.png ├── 好友列表.png ├── 我的.png ├── 注册登陆.png ├── 看看.png └── 菜品识别.png /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SmartChat 2 | 3 | 本社交软件基于Android开发平台进行软件设计,以Android Studio、Android SDK作为软件开发工具,Git作为版本控件工具。以科大讯飞平台为语音识别及文本转换作为语音识别以及文本转换为语音支持平台,以图灵机器人作为智能应答机器人,以有道翻译作为翻译支持平台。以极光平台作为用户管理、即时通讯、推送平台。 4 | 5 | ## 其中涉及到许多云平台的集成: 6 | >1、科大讯飞 7 | >2、极光平台 8 | >3、百度图片识别 9 | >4、图灵机器人 10 | >5、有道翻译 11 | 12 | ## 依赖了许多的库: 13 | >1、RecyclerView 14 | >2、Okhttp3 15 | >3、cardView 16 | >4、gson 17 | >5、picasso 18 | >6、FFmpeg 19 | 20 | ## 自定义的View: 21 | >1、圆角头像 22 | >2、按住说话 23 | 24 | 当然还有数据库操作、Sharedpreference等等。涉及面比较广,代码方面不建议过多参考,由于当时对Android的理解有限,所以有些设计未免存在缺陷,毕竟是一个学生的作品。 25 | 26 | 27 | * 个人的建议是下载下来,跑起来,然后在这个基础上去优化代码逻辑,比如说,在数据库的设计上,有诸多的不合理,如果能够进行优化,当然是能学到不少的东西。另外,在离线信息的处理上,我并没有真正做处理,这里也是一个学习的方向。另外一个,聊天内容目前只做了语音和文本,没有表情,位置、视频等等,从这些做进一步的改进也是非常棒的,甚至红包、朋友圈功能等等。当然也可以从优化入手,分析其内存的占用情况,网络的访问合不合理等等,进行优化,也是一种交流学习的大好机会,欢迎这些同学和我交流,说不定能把它完善成一个有用的项目。 28 | * 不得不说的是,完成这个项目的过程是漫长的,前后花了近两个月的时间,提交了58次代码。而又是令人兴奋的,是我毕业前验证自己自学成果的见证,也是我个人到目前为此由个人从头搭建成而的最为完善的一个项目。也是非常感谢实习公司给了我非常宽限的花习时间,还有同学兼同学一起勉励做设计的那段时光,大家每天都在为自己的项目添光加彩的日子,真是非常地怀念。 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.example.jakera.smartchat" 7 | minSdkVersion 22 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | sourceSets { 20 | main { 21 | jniLibs.srcDirs = ["libs"] 22 | } 23 | } 24 | productFlavors { 25 | } 26 | } 27 | 28 | dependencies { 29 | implementation fileTree(include: ['*.jar'], dir: 'libs') 30 | implementation 'com.android.support:appcompat-v7:26.0.0-beta1' 31 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 35 | implementation files('libs/Msc.jar') 36 | implementation 'com.android.support:recyclerview-v7:26.0.0-beta1' 37 | implementation 'com.squareup.okhttp3:okhttp:3.4.1' 38 | implementation files('libs/YoudaoBase.jar') 39 | implementation files('libs/YoudaoCnDictOffline.jar') 40 | implementation files('libs/YoudaoTranslateOffline.jar') 41 | implementation files('libs/YoudaoTranslateOnline.jar') 42 | //加入极光的推送及IM 43 | implementation files('libs/jmessage-android_v2.4.1.jar') 44 | implementation files('libs/jpush-android-3.1.1.jar') 45 | implementation files('libs/jcore-android-1.1.9.jar') 46 | implementation 'com.android.support:cardview-v7:26.0.0-beta1' 47 | implementation 'com.google.code.gson:gson:2.2.4' 48 | implementation 'com.squareup.picasso:picasso:2.3.2' 49 | implementation 'com.writingminds:FFmpegAndroid:0.3.2' 50 | } 51 | -------------------------------------------------------------------------------- /app/libs/Msc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/Msc.jar -------------------------------------------------------------------------------- /app/libs/YoudaoBase.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/YoudaoBase.jar -------------------------------------------------------------------------------- /app/libs/YoudaoCnDictOffline.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/YoudaoCnDictOffline.jar -------------------------------------------------------------------------------- /app/libs/YoudaoTranslateOffline.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/YoudaoTranslateOffline.jar -------------------------------------------------------------------------------- /app/libs/YoudaoTranslateOnline.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/YoudaoTranslateOnline.jar -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/arm64-v8a/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/arm64-v8a/libjcore118.so -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/arm64-v8a/libjcore119.so -------------------------------------------------------------------------------- /app/libs/arm64-v8a/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/arm64-v8a/libmsc.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi-v7a/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi-v7a/libjcore118.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi-v7a/libjcore119.so -------------------------------------------------------------------------------- /app/libs/armeabi-v7a/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi-v7a/libmsc.so -------------------------------------------------------------------------------- /app/libs/armeabi/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/armeabi/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi/libjcore118.so -------------------------------------------------------------------------------- /app/libs/armeabi/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi/libjcore119.so -------------------------------------------------------------------------------- /app/libs/armeabi/liblocalTransEngine.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi/liblocalTransEngine.so -------------------------------------------------------------------------------- /app/libs/armeabi/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/armeabi/libmsc.so -------------------------------------------------------------------------------- /app/libs/jcore-android-1.1.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/jcore-android-1.1.9.jar -------------------------------------------------------------------------------- /app/libs/jmessage-android_v2.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/jmessage-android_v2.4.1.jar -------------------------------------------------------------------------------- /app/libs/jpush-android-3.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/jpush-android-3.1.1.jar -------------------------------------------------------------------------------- /app/libs/mips/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/mips/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips/libjcore118.so -------------------------------------------------------------------------------- /app/libs/mips/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips/libjcore119.so -------------------------------------------------------------------------------- /app/libs/mips/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips/libmsc.so -------------------------------------------------------------------------------- /app/libs/mips64/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips64/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/mips64/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips64/libjcore118.so -------------------------------------------------------------------------------- /app/libs/mips64/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips64/libjcore119.so -------------------------------------------------------------------------------- /app/libs/mips64/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/mips64/libmsc.so -------------------------------------------------------------------------------- /app/libs/x86/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/x86/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86/libjcore118.so -------------------------------------------------------------------------------- /app/libs/x86/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86/libjcore119.so -------------------------------------------------------------------------------- /app/libs/x86/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86/libmsc.so -------------------------------------------------------------------------------- /app/libs/x86_64/libdict-parser.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86_64/libdict-parser.so -------------------------------------------------------------------------------- /app/libs/x86_64/libjcore118.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86_64/libjcore118.so -------------------------------------------------------------------------------- /app/libs/x86_64/libjcore119.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86_64/libjcore119.so -------------------------------------------------------------------------------- /app/libs/x86_64/libmsc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/libs/x86_64/libmsc.so -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/jakera/smartchat/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.jakera.smartchat", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/assets/iflytek/recognize.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/iflytek/recognize.xml -------------------------------------------------------------------------------- /app/src/main/assets/iflytek/voice_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/iflytek/voice_bg.9.png -------------------------------------------------------------------------------- /app/src/main/assets/iflytek/voice_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/iflytek/voice_empty.png -------------------------------------------------------------------------------- /app/src/main/assets/iflytek/voice_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/iflytek/voice_full.png -------------------------------------------------------------------------------- /app/src/main/assets/iflytek/waiting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/iflytek/waiting.png -------------------------------------------------------------------------------- /app/src/main/assets/iflytek/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/iflytek/warning.png -------------------------------------------------------------------------------- /app/src/main/assets/t.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/t.wav -------------------------------------------------------------------------------- /app/src/main/assets/test.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/test.wav -------------------------------------------------------------------------------- /app/src/main/assets/yinfu.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/assets/yinfu.wav -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Activity/ContactAuthorActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Activity; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.view.ViewPager; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.View; 9 | import android.view.Window; 10 | import android.view.WindowManager; 11 | import android.widget.ImageView; 12 | import android.widget.LinearLayout; 13 | import android.widget.TextView; 14 | 15 | import com.example.jakera.smartchat.Adapter.ContactAuthorViewPagerAdapter; 16 | import com.example.jakera.smartchat.R; 17 | import com.example.jakera.smartchat.Utils.RecognizerHelper; 18 | 19 | import java.util.ArrayList; 20 | 21 | /** 22 | * Created by jakera on 18-3-23. 23 | */ 24 | 25 | public class ContactAuthorActivity extends AppCompatActivity { 26 | 27 | int[] imageResIds = new int[]{R.drawable.wyu1, R.drawable.wyu2, R.drawable.wyu3, R.drawable.wyu4}; 28 | 29 | private ViewPager viewPager; 30 | 31 | private ImageView iv_user_info_back; 32 | 33 | private TextView tv_title_bar_center; 34 | 35 | 36 | @Override 37 | protected void onCreate(@Nullable Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | Window window = getWindow(); 40 | //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏 41 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 42 | //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色 43 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 44 | //设置状态栏颜色 45 | window.setStatusBarColor(Color.BLACK); 46 | getSupportActionBar().hide(); 47 | setContentView(R.layout.activity_contact_author); 48 | 49 | init(); 50 | 51 | 52 | } 53 | 54 | private void init() { 55 | viewPager = (ViewPager) findViewById(R.id.viewpager_contact_author); 56 | viewPager.setAdapter(new ContactAuthorViewPagerAdapter(this, imageResIds)); 57 | 58 | iv_user_info_back = (ImageView) findViewById(R.id.iv_title_bar_back); 59 | iv_user_info_back.setVisibility(View.VISIBLE); 60 | iv_user_info_back.setOnClickListener(new View.OnClickListener() { 61 | @Override 62 | public void onClick(View v) { 63 | onBackPressed(); 64 | } 65 | }); 66 | 67 | tv_title_bar_center = (TextView) findViewById(R.id.tv_title_bar_center); 68 | tv_title_bar_center.setText(getString(R.string.contact_author)); 69 | 70 | new Thread(new Runnable() { 71 | @Override 72 | public void run() { 73 | while (true) { 74 | runOnUiThread(new Runnable() { 75 | @Override 76 | public void run() { 77 | viewPager.setCurrentItem((viewPager.getCurrentItem() + 1) % imageResIds.length); 78 | } 79 | }); 80 | try { 81 | Thread.sleep(3000); 82 | } catch (InterruptedException e) { 83 | e.printStackTrace(); 84 | } 85 | } 86 | } 87 | }).start(); 88 | 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Activity/CropPortraitAcitivity.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Activity; 2 | 3 | import android.Manifest; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.graphics.Color; 9 | import android.net.Uri; 10 | import android.os.Bundle; 11 | import android.provider.MediaStore; 12 | import android.support.annotation.Nullable; 13 | import android.support.v4.app.ActivityCompat; 14 | import android.support.v4.content.ContextCompat; 15 | import android.support.v7.app.AppCompatActivity; 16 | import android.util.Log; 17 | import android.view.View; 18 | import android.view.Window; 19 | import android.view.WindowManager; 20 | import android.widget.ImageView; 21 | import android.widget.TextView; 22 | 23 | import com.example.jakera.smartchat.R; 24 | import com.example.jakera.smartchat.Views.ClipViewLayout; 25 | 26 | import java.io.File; 27 | import java.io.IOException; 28 | import java.io.OutputStream; 29 | 30 | /** 31 | * Created by jakera on 18-2-24. 32 | */ 33 | 34 | public class CropPortraitAcitivity extends AppCompatActivity { 35 | 36 | // private ImageView iv_crop_portrait; 37 | private ClipViewLayout clipViewLayout; 38 | private TextView tv_cro_portrait_ok, tv_cro_portrait_cancel; 39 | 40 | private String TAG = "CropPortraitActivity"; 41 | 42 | 43 | @Override 44 | protected void onCreate(@Nullable Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | Window window = getWindow(); 47 | //取消设置透明状态栏,使 ContentView 内容不再覆盖状态栏 48 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 49 | //需要设置这个 flag 才能调用 setStatusBarColor 来设置状态栏颜色 50 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 51 | //设置状态栏颜色 52 | window.setStatusBarColor(Color.BLACK); 53 | getSupportActionBar().hide(); 54 | setContentView(R.layout.activity_crop_portrait); 55 | 56 | if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { 57 | ActivityCompat.requestPermissions(this, 58 | new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 59 | 1); 60 | } 61 | 62 | // iv_crop_portrait=(ImageView)findViewById(R.id.iv_crop_portrait); 63 | clipViewLayout = (ClipViewLayout) findViewById(R.id.clipView_layout); 64 | tv_cro_portrait_ok = (TextView) findViewById(R.id.tv_cro_portrait_ok); 65 | tv_cro_portrait_ok.setOnClickListener(new View.OnClickListener() { 66 | @Override 67 | public void onClick(View v) { 68 | generateUriAndReturn(); 69 | } 70 | }); 71 | tv_cro_portrait_cancel = (TextView) findViewById(R.id.tv_cro_portrait_cancel); 72 | tv_cro_portrait_cancel.setOnClickListener(new View.OnClickListener() { 73 | @Override 74 | public void onClick(View v) { 75 | finish(); 76 | } 77 | }); 78 | Intent intent = getIntent(); 79 | if (intent != null) { 80 | 81 | //Bitmap过大,不能用Bundle进行传输,故使用Uri来代替 82 | Bundle bundle = intent.getExtras(); 83 | Uri bmpUri = (Uri) bundle.getParcelable("bitmapUri"); 84 | if (bmpUri == null) { 85 | //由于保存图片需要时间,所以,直接在新的Activity里进行读取 86 | bmpUri = Uri.fromFile(new File(getCacheDir(), "user_portrait_temp.jpg")); 87 | } 88 | clipViewLayout.setImageSrc(bmpUri); 89 | } 90 | 91 | } 92 | 93 | 94 | /** 95 | * 生成Uri并且通过setResult返回给打开的activity 96 | */ 97 | private void generateUriAndReturn() { 98 | //调用返回剪切图 99 | Bitmap zoomedCropBitmap; 100 | // if (type == 1) { 101 | // zoomedCropBitmap = clipViewLayout1.clip(); 102 | // } else { 103 | zoomedCropBitmap = clipViewLayout.clip(); 104 | // } 105 | if (zoomedCropBitmap == null) { 106 | Log.e("android", "zoomedCropBitmap == null"); 107 | return; 108 | } 109 | // /data/user/0/com.example.jakera.smartchat/cache 110 | //Uri mSaveUri = Uri.fromFile(new File(getCacheDir(), "cropped_" + System.currentTimeMillis() + ".jpg")); 111 | Uri mSaveUri = Uri.fromFile(new File(getCacheDir(), "user_portrait.jpg")); 112 | Log.i(TAG, getCacheDir().getAbsolutePath()); 113 | if (mSaveUri != null) { 114 | OutputStream outputStream = null; 115 | try { 116 | outputStream = getContentResolver().openOutputStream(mSaveUri); 117 | if (outputStream != null) { 118 | zoomedCropBitmap.compress(Bitmap.CompressFormat.JPEG, 90, outputStream); 119 | } 120 | } catch (IOException ex) { 121 | Log.e("android", "Cannot open file: " + mSaveUri, ex); 122 | } finally { 123 | if (outputStream != null) { 124 | try { 125 | outputStream.close(); 126 | } catch (IOException e) { 127 | e.printStackTrace(); 128 | } 129 | } 130 | } 131 | Intent intent = new Intent(CropPortraitAcitivity.this, ModifyPortraitActivity.class); 132 | intent.putExtra("portrait", "sucess"); 133 | startActivity(intent); 134 | finish(); 135 | } 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Activity/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.CountDownTimer; 6 | import android.os.Handler; 7 | import android.support.annotation.Nullable; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.WindowManager; 10 | import android.widget.TextView; 11 | 12 | import com.example.jakera.smartchat.R; 13 | import com.example.jakera.smartchat.SmartChatConstant; 14 | import com.example.jakera.smartchat.Utils.SharePreferenceUtils; 15 | 16 | /** 17 | * Created by jakera on 18-2-8. 18 | */ 19 | 20 | public class SplashActivity extends AppCompatActivity { 21 | private TextView tv_count_time; 22 | private Handler handler; 23 | private MyCountDownTimer myCountDownTimer; 24 | 25 | @Override 26 | protected void onCreate(@Nullable Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_splash); 29 | getSupportActionBar().hide(); 30 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 31 | 32 | tv_count_time = (TextView) findViewById(R.id.tv_count_time); 33 | myCountDownTimer = new MyCountDownTimer(1000, 1000); 34 | myCountDownTimer.start(); 35 | handler = new Handler(); 36 | handler.postDelayed(new Runnable() { 37 | @Override 38 | public void run() { 39 | if ((Boolean) SharePreferenceUtils.get(SplashActivity.this, SmartChatConstant.SPISLOGINKEY, false)) { 40 | Intent intent = new Intent(SplashActivity.this, MainActivity.class); 41 | startActivity(intent); 42 | } else { 43 | Intent intent = new Intent(SplashActivity.this, RegisterLoginActivity.class); 44 | startActivity(intent); 45 | } 46 | SplashActivity.this.finish(); 47 | 48 | } 49 | }, 1000); 50 | 51 | 52 | } 53 | 54 | private class MyCountDownTimer extends CountDownTimer { 55 | public MyCountDownTimer(long millisInFuture, long countDownInterval) { 56 | super(millisInFuture, countDownInterval); 57 | } 58 | 59 | @Override 60 | public void onFinish() { 61 | tv_count_time.setText(getString(R.string.jumping)); 62 | } 63 | 64 | @Override 65 | public void onTick(long millisUntilFinished) { 66 | tv_count_time.setText("倒计时(" + millisUntilFinished / 1000 + "秒)"); 67 | } 68 | } 69 | 70 | 71 | } 72 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Adapter/ContactAuthorViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v4.view.PagerAdapter; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | 9 | import com.example.jakera.smartchat.R; 10 | 11 | /** 12 | * Created by jakera on 18-3-23. 13 | */ 14 | 15 | public class ContactAuthorViewPagerAdapter extends PagerAdapter { 16 | 17 | private Context context; 18 | private int[] imageResIds; 19 | 20 | public ContactAuthorViewPagerAdapter(Context context, int[] imageResIds) { 21 | this.context = context; 22 | this.imageResIds = imageResIds; 23 | } 24 | 25 | @Override 26 | public int getCount() { 27 | return imageResIds.length; 28 | } 29 | 30 | @Override 31 | public boolean isViewFromObject(View view, Object object) { 32 | return view == object; 33 | } 34 | 35 | @Override 36 | public void destroyItem(ViewGroup container, int position, Object object) { 37 | container.removeView((View) object); 38 | } 39 | 40 | @Override 41 | public Object instantiateItem(ViewGroup container, int position) { 42 | View view = View.inflate(context, R.layout.vp_item_author, null); 43 | ImageView imageView = (ImageView) view.findViewById(R.id.iv_vp_item); 44 | imageView.setImageResource(imageResIds[position]); 45 | container.addView(view); 46 | return view; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Adapter/FriendsListRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Adapter; 2 | 3 | import android.graphics.Bitmap; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.example.jakera.smartchat.Entry.MessageEntry; 12 | import com.example.jakera.smartchat.Interface.ItemClickListener; 13 | import com.example.jakera.smartchat.R; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import cn.jpush.im.android.api.callback.GetAvatarBitmapCallback; 19 | import cn.jpush.im.android.api.model.UserInfo; 20 | 21 | /** 22 | * Created by jakera on 18-2-22. 23 | */ 24 | 25 | public class FriendsListRecyclerAdapter extends RecyclerView.Adapter { 26 | private List datas; 27 | private ItemClickListener mItemClickListener; 28 | 29 | public void setOnItemClickListener(ItemClickListener itemClickListener) { 30 | mItemClickListener = itemClickListener; 31 | } 32 | 33 | public void setDatas(List datas) { 34 | this.datas = datas; 35 | } 36 | 37 | @Override 38 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 39 | FriendsViewHolder viewHolder = new FriendsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.friends_list_item, null)); 40 | return viewHolder; 41 | } 42 | 43 | @Override 44 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 45 | final FriendsViewHolder friendsViewHolder = (FriendsViewHolder) holder; 46 | UserInfo userInfo = datas.get(position); 47 | // TODO:更改头像 48 | userInfo.getAvatarBitmap(new GetAvatarBitmapCallback() { 49 | @Override 50 | public void gotResult(int i, String s, Bitmap bitmap) { 51 | friendsViewHolder.iv_portrait.setImageBitmap(bitmap); 52 | } 53 | }); 54 | friendsViewHolder.iv_portrait.setTag(position); 55 | friendsViewHolder.tv_username.setText(userInfo.getUserName()); 56 | } 57 | 58 | @Override 59 | public int getItemCount() { 60 | if (datas == null) { 61 | datas = new ArrayList<>(); 62 | } 63 | return datas.size(); 64 | } 65 | 66 | 67 | private class FriendsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 68 | private ImageView iv_portrait; 69 | private TextView tv_username; 70 | 71 | public FriendsViewHolder(View itemView) { 72 | super(itemView); 73 | iv_portrait = (ImageView) itemView.findViewById(R.id.iv_friends_list_portrait); 74 | tv_username = (TextView) itemView.findViewById(R.id.tv_friends_list_username); 75 | itemView.setOnClickListener(this); 76 | } 77 | 78 | @Override 79 | public void onClick(View v) { 80 | if (mItemClickListener != null) { 81 | mItemClickListener.OnItemClick(v, (Integer) iv_portrait.getTag()); 82 | } 83 | } 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Adapter/MessageRecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Adapter; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.BitmapFactory; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.example.jakera.smartchat.Entry.MessageEntry; 13 | import com.example.jakera.smartchat.Interface.ItemClickListener; 14 | import com.example.jakera.smartchat.R; 15 | 16 | import java.io.File; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import cn.jpush.im.android.api.JMessageClient; 21 | import cn.jpush.im.android.api.callback.GetAvatarBitmapCallback; 22 | import cn.jpush.im.android.api.callback.GetUserInfoCallback; 23 | import cn.jpush.im.android.api.model.UserInfo; 24 | 25 | /** 26 | * Created by jakera on 18-2-1. 27 | */ 28 | 29 | public class MessageRecyclerViewAdapter extends RecyclerView.Adapter { 30 | private List datas = new ArrayList<>(); 31 | private ItemClickListener mItemClickListener; 32 | 33 | public void setDatas(List datas){ 34 | this.datas=datas; 35 | } 36 | 37 | public void setOnItemClickListener(ItemClickListener itemClickListener){ 38 | mItemClickListener=itemClickListener; 39 | } 40 | 41 | @Override 42 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 43 | MessageViewHolder viewHolder=new MessageViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.message_list_item,null)); 44 | return viewHolder; 45 | } 46 | 47 | @Override 48 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 49 | final MessageViewHolder tempHolder = (MessageViewHolder) holder; 50 | final MessageEntry tempMessage = datas.get(position); 51 | 52 | JMessageClient.getUserInfo(tempMessage.getUsername(), new GetUserInfoCallback() { 53 | @Override 54 | public void gotResult(int i, String s, UserInfo userInfo) { 55 | userInfo.getAvatarBitmap(new GetAvatarBitmapCallback() { 56 | @Override 57 | public void gotResult(int i, String s, Bitmap bitmap) { 58 | tempHolder.iv_portrait.setImageBitmap(bitmap); 59 | } 60 | }); 61 | tempHolder.tv_title.setText(userInfo.getNickname()); 62 | } 63 | }); 64 | //为Item设置监听所用 65 | tempHolder.iv_portrait.setTag(position); 66 | tempHolder.tv_content.setText(tempMessage.getContent()); 67 | tempHolder.tv_time.setText(tempMessage.getTime()); 68 | } 69 | 70 | @Override 71 | public int getItemCount() { 72 | return datas.size(); 73 | } 74 | private class MessageViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ 75 | 76 | private ImageView iv_portrait; 77 | private TextView tv_title,tv_content,tv_time; 78 | 79 | public MessageViewHolder(View itemView) { 80 | super(itemView); 81 | iv_portrait=(ImageView)itemView.findViewById(R.id.iv_message_list_portrait); 82 | tv_title=(TextView)itemView.findViewById(R.id.tv_message_list_title); 83 | tv_content=(TextView)itemView.findViewById(R.id.tv_message_list_content); 84 | tv_time=(TextView)itemView.findViewById(R.id.tv_message_list_time); 85 | itemView.setOnClickListener(this); 86 | } 87 | 88 | @Override 89 | public void onClick(View v) { 90 | if (mItemClickListener!=null){ 91 | mItemClickListener.OnItemClick(v,(Integer) iv_portrait.getTag()); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Adapter/WatchMoreRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | 10 | import com.example.jakera.smartchat.Entry.BeautifulPictureEntry; 11 | import com.example.jakera.smartchat.Interface.ItemClickListener; 12 | import com.example.jakera.smartchat.Others.PicassoTransformation; 13 | import com.example.jakera.smartchat.R; 14 | import com.squareup.picasso.Picasso; 15 | import com.squareup.picasso.Transformation; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * Created by jakera on 18-2-23. 22 | */ 23 | 24 | public class WatchMoreRecyclerAdapter extends RecyclerView.Adapter { 25 | 26 | private Context context; 27 | 28 | private ItemClickListener itemClickListener; 29 | 30 | public void setItemClickListener(ItemClickListener listener) { 31 | this.itemClickListener = listener; 32 | } 33 | 34 | public void setContext(Context context) { 35 | this.context = context; 36 | } 37 | 38 | private List datas = new ArrayList<>(); 39 | 40 | public void setDatas(List datas, boolean isRefresh) { 41 | if (isRefresh) { 42 | this.datas = datas; 43 | } else { 44 | this.datas.addAll(datas); 45 | } 46 | this.notifyDataSetChanged(); 47 | } 48 | 49 | @Override 50 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 51 | WatchMoreViewHolder watchMoreViewHolder = new WatchMoreViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.watch_more_list_item, null)); 52 | return watchMoreViewHolder; 53 | } 54 | 55 | @Override 56 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 57 | WatchMoreViewHolder tempViewHolder = (WatchMoreViewHolder) holder; 58 | BeautifulPictureEntry.Data picData = datas.get(position); 59 | //按比例缩放 60 | Transformation transformation = new PicassoTransformation(tempViewHolder.iv_watch_more_item, 2); 61 | Picasso.with(context) 62 | .load(picData.url) 63 | .transform(transformation) 64 | .placeholder(R.drawable.loading) 65 | .into(tempViewHolder.iv_watch_more_item); 66 | tempViewHolder.iv_watch_more_item.setTag(position); 67 | } 68 | 69 | @Override 70 | public int getItemCount() { 71 | return datas.size(); 72 | } 73 | 74 | 75 | private class WatchMoreViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 76 | private ImageView iv_watch_more_item; 77 | 78 | public WatchMoreViewHolder(View itemView) { 79 | super(itemView); 80 | iv_watch_more_item = itemView.findViewById(R.id.iv_watch_more_item); 81 | itemView.setOnClickListener(this); 82 | } 83 | 84 | @Override 85 | public void onClick(View v) { 86 | if (itemClickListener != null) { 87 | itemClickListener.OnItemClick(v, (Integer) iv_watch_more_item.getTag()); 88 | } 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/AnimalOrPlant.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by jakera on 18-3-12. 7 | */ 8 | 9 | // {"log_id": 5501585968413412039, "result": [{"score": "0.91606", "name": "美国短毛猫"}, {"score": "0.0342665", "name": "美国硬毛猫"}, {"score": "0.00994411", "name": "美国短尾猫"}, {"score": "0.0085082", "name": "埃及猫"}, {"score": "0.00656378", "name": "短毛家猫"}, {"score": "0.00562214", "name": "豹猫"}]} 10 | public class AnimalOrPlant { 11 | public long log_id; 12 | public List result; 13 | 14 | public class AnimalInfo { 15 | public String score; 16 | public String name; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/BaseMessageEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * Created by jakera on 18-2-2. 7 | */ 8 | 9 | public class BaseMessageEntry { 10 | public final static int SENDMESSAGE=0; 11 | public final static int RECEIVEMESSAGE=1; 12 | private String userName; 13 | private int viewType=1; 14 | 15 | public int getViewType() { 16 | return viewType; 17 | } 18 | 19 | public void setViewType(int viewType) { 20 | this.viewType = viewType; 21 | } 22 | 23 | public String getUserName() { 24 | return userName; 25 | } 26 | 27 | public void setUserName(String userName) { 28 | this.userName = userName; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/BeautifulPictureEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by jakera on 18-2-23. 7 | */ 8 | //{"code":200,"msg":"成功!","data":[{"createdAt":"2017-07-10T08:02:25.353Z","publishedAt":"2017-07-10T12:48:49.297Z","type":"美图","url":"https://ws1.sinaimg.cn/large/610dc034ly1fhegpeu0h5j20u011iae5.jpg"}, 9 | public class BeautifulPictureEntry { 10 | public int code; 11 | public String msg; 12 | public List data; 13 | 14 | public class Data { 15 | public String createdAt; 16 | public String publishedAt; 17 | public String type; 18 | public String url; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/Car.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by jakera on 18-3-9. 7 | */ 8 | 9 | public class Car { 10 | public long log_id; 11 | public List result; 12 | public String color_result; 13 | 14 | public class CarInfo { 15 | public double score; 16 | public String name; 17 | public String year; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/Dish.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by jakera on 18-3-13. 7 | */ 8 | 9 | public class Dish { 10 | public long log_id; 11 | public int result_num; 12 | public List result; 13 | 14 | public class DishInfo { 15 | public String calorie; 16 | public boolean has_calorie; 17 | public String name; 18 | public String probability; 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/MessageEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.drawable.Drawable; 5 | 6 | /** 7 | * Created by jakera on 18-1-31. 8 | */ 9 | 10 | public class MessageEntry { 11 | 12 | private String username; 13 | private String nickname; 14 | private String content; 15 | private String time; 16 | 17 | 18 | 19 | 20 | public void setContent(String content) { 21 | this.content = content; 22 | } 23 | 24 | public void setTime(String time) { 25 | this.time = time; 26 | } 27 | 28 | public String getUsername() { 29 | return username; 30 | } 31 | 32 | public void setUsername(String username) { 33 | this.username = username; 34 | } 35 | 36 | public String getNickname() { 37 | return nickname; 38 | } 39 | 40 | public void setNickname(String nickname) { 41 | this.nickname = nickname; 42 | } 43 | 44 | public String getContent() { 45 | return content; 46 | } 47 | 48 | public String getTime() { 49 | return time; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/TextMessageEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * Created by jakera on 18-2-1. 7 | */ 8 | 9 | public class TextMessageEntry extends BaseMessageEntry{ 10 | private String content; 11 | 12 | 13 | public String getContent() { 14 | return content; 15 | } 16 | 17 | public void setContent(String content) { 18 | this.content = content; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Entry/VoiceMessageEntry.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Entry; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * Created by jakera on 18-2-2. 7 | */ 8 | 9 | public class VoiceMessageEntry extends BaseMessageEntry{ 10 | 11 | float time; 12 | String filePath; 13 | public VoiceMessageEntry(float time, String filePath) { 14 | super(); 15 | this.time = time; 16 | this.filePath = filePath; 17 | } 18 | public float getTime() { 19 | return time; 20 | } 21 | public void setTime(float time) { 22 | this.time = time; 23 | } 24 | public String getFilePath() { 25 | return filePath; 26 | } 27 | public void setFilePath(String filePath) { 28 | this.filePath = filePath; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Fragment/FriendsListFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Fragment; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v4.app.Fragment; 9 | import android.support.v7.widget.LinearLayoutManager; 10 | import android.support.v7.widget.RecyclerView; 11 | import android.support.v7.widget.StaggeredGridLayoutManager; 12 | import android.util.Log; 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | 17 | import com.example.jakera.smartchat.Activity.ChatActivity; 18 | import com.example.jakera.smartchat.Activity.MainActivity; 19 | import com.example.jakera.smartchat.Adapter.FriendsListRecyclerAdapter; 20 | import com.example.jakera.smartchat.Interface.ItemClickListener; 21 | import com.example.jakera.smartchat.R; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | import java.util.Locale; 26 | 27 | import cn.jpush.im.android.api.ContactManager; 28 | import cn.jpush.im.android.api.JMessageClient; 29 | import cn.jpush.im.android.api.callback.GetUserInfoListCallback; 30 | import cn.jpush.im.android.api.event.ContactNotifyEvent; 31 | import cn.jpush.im.android.api.event.OfflineMessageEvent; 32 | import cn.jpush.im.android.api.model.Conversation; 33 | import cn.jpush.im.android.api.model.Message; 34 | import cn.jpush.im.android.api.model.UserInfo; 35 | import cn.jpush.im.api.BasicCallback; 36 | 37 | /** 38 | * Created by jakera on 18-1-25. 39 | */ 40 | 41 | public class FriendsListFragment extends Fragment implements ItemClickListener { 42 | 43 | private String TAG = "FriensListFragment"; 44 | private RecyclerView recyclerView; 45 | private FriendsListRecyclerAdapter friendsListRecyclerAdapter; 46 | private List datas; 47 | 48 | 49 | public FriendsListFragment() { 50 | } 51 | 52 | @Nullable 53 | @Override 54 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 55 | View view=inflater.inflate(R.layout.friends_list_fragment,container,false); 56 | recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview_friends_list); 57 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 58 | friendsListRecyclerAdapter = new FriendsListRecyclerAdapter(); 59 | friendsListRecyclerAdapter.setOnItemClickListener(this); 60 | datas = new ArrayList<>(); 61 | recyclerView.setAdapter(friendsListRecyclerAdapter); 62 | initView(); 63 | return view; 64 | } 65 | 66 | @Override 67 | public void onResume() { 68 | super.onResume(); 69 | // //注册事件,以接收各种用户请求 70 | // JMessageClient.registerEventReceiver(this); 71 | 72 | ContactManager.getFriendList(new GetUserInfoListCallback() { 73 | @Override 74 | public void gotResult(int responseCode, String responseMessage, List userInfoList) { 75 | if (0 == responseCode) { 76 | //获取好友列表成功 77 | friendsListRecyclerAdapter.setDatas(userInfoList); 78 | datas = userInfoList; 79 | friendsListRecyclerAdapter.notifyDataSetChanged(); 80 | } else { 81 | //获取好友列表失败 82 | Log.i(TAG, "获取好友列表失败"); 83 | } 84 | } 85 | }); 86 | } 87 | 88 | public void initView() { 89 | 90 | } 91 | 92 | @Override 93 | public void onPause() { 94 | super.onPause(); 95 | JMessageClient.unRegisterEventReceiver(this); 96 | } 97 | 98 | @Override 99 | public void onDestroy() { 100 | super.onDestroy(); 101 | } 102 | 103 | 104 | // /** 105 | // * 类似MessageEvent事件的接收,上层在需要的地方增加OfflineMessageEvent事件的接收 106 | // * 即可实现离线消息的接收。 107 | // **/ 108 | // public void onEvent(OfflineMessageEvent event) { 109 | // //获取事件发生的会话对象 110 | // Log.i(TAG, "收到消息"); 111 | // Conversation conversation = event.getConversation(); 112 | // List newMessageList = event.getOfflineMessageList();//获取此次离线期间会话收到的新消息列表 113 | // System.out.println(String.format(Locale.SIMPLIFIED_CHINESE, "收到%d条来自%s的离线消息。\n", newMessageList.size(), conversation.getTargetId())); 114 | // for (int i = 0; i < newMessageList.size(); i++) { 115 | // // {"text":"你好","extras":{}} 116 | // Log.i(TAG, "i=" + i + "," + newMessageList.get(i).getContent().toJson()); 117 | //// Log.i(TAG,"i="+i+","+newMessageList.get(i).getContent().); 118 | // 119 | // } 120 | // 121 | // 122 | // } 123 | 124 | 125 | @Override 126 | public void OnItemClick(View v, int position) { 127 | String username = ((UserInfo) datas.get(position)).getUserName(); 128 | Intent intent = new Intent(getActivity(), ChatActivity.class); 129 | Bundle data = new Bundle(); 130 | data.putString("username", username); 131 | intent.putExtra("username", data); 132 | startActivity(intent); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Fragment/SmartChatFragmentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Fragment; 2 | 3 | import android.graphics.Paint; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentPagerAdapter; 7 | import com.example.jakera.smartchat.SmartChatConstant; 8 | 9 | /** 10 | * Created by jakera on 18-1-25. 11 | */ 12 | 13 | 14 | //http://www.runoob.com/w3cnote/android-tutorial-fragment-demo4.html 15 | 16 | public class SmartChatFragmentAdapter extends FragmentPagerAdapter { 17 | 18 | private final int PAGER_COUNT=4; 19 | private MessageListFragment mMessageListFragment=null; 20 | private FriendsListFragment mFriendsListFragment=null; 21 | private WatchMoreFragment mWatchMoreFragment=null; 22 | private UserInfoFragment mUserInfoFragment=null; 23 | 24 | public SmartChatFragmentAdapter(FragmentManager fm) { 25 | super(fm); 26 | mMessageListFragment=new MessageListFragment(); 27 | mFriendsListFragment=new FriendsListFragment(); 28 | mWatchMoreFragment=new WatchMoreFragment(); 29 | mUserInfoFragment=new UserInfoFragment(); 30 | } 31 | 32 | @Override 33 | public Fragment getItem(int position) { 34 | Fragment fragment=null; 35 | switch (position){ 36 | case SmartChatConstant.PAGE_ONE: 37 | fragment=mMessageListFragment; 38 | break; 39 | case SmartChatConstant.PAGE_TWO: 40 | fragment=mFriendsListFragment; 41 | break; 42 | case SmartChatConstant.PAGE_THREE: 43 | fragment=mWatchMoreFragment; 44 | break; 45 | case SmartChatConstant.PAGE_FOUR: 46 | fragment=mUserInfoFragment; 47 | break; 48 | } 49 | return fragment; 50 | } 51 | 52 | @Override 53 | public int getCount() { 54 | return PAGER_COUNT; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Fragment/WatchMoreFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.widget.SwipeRefreshLayout; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.support.v7.widget.StaggeredGridLayoutManager; 9 | import android.util.Log; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | 14 | import com.example.jakera.smartchat.Activity.MainActivity; 15 | import com.example.jakera.smartchat.Adapter.WatchMoreRecyclerAdapter; 16 | import com.example.jakera.smartchat.Entry.BeautifulPictureEntry; 17 | import com.example.jakera.smartchat.Interface.EndLessOnScrollListener; 18 | import com.example.jakera.smartchat.R; 19 | import com.example.jakera.smartchat.Utils.OkhttpHelper; 20 | import com.google.gson.Gson; 21 | 22 | import java.io.IOException; 23 | 24 | import okhttp3.Call; 25 | import okhttp3.Callback; 26 | import okhttp3.Response; 27 | 28 | /** 29 | * Created by jakera on 18-1-25. 30 | */ 31 | 32 | public class WatchMoreFragment extends Fragment implements Callback { 33 | 34 | private RecyclerView recyclerview_watch_more; 35 | private WatchMoreRecyclerAdapter watchMoreRecyclerAdapter; 36 | private StaggeredGridLayoutManager staggeredGridLayoutManager; 37 | 38 | private OkhttpHelper okhttpHelper; 39 | 40 | 41 | private BeautifulPictureEntry datas; 42 | 43 | private SwipeRefreshLayout swipe_refresh_layout; 44 | 45 | private boolean isRefresh = false; 46 | 47 | private String TAG = "WatchMoreFragment"; 48 | 49 | public WatchMoreFragment() { 50 | } 51 | 52 | @Nullable 53 | @Override 54 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 55 | View view=inflater.inflate(R.layout.watch_more_fragment,container,false); 56 | recyclerview_watch_more = (RecyclerView) view.findViewById(R.id.recyclerview_watch_more); 57 | staggeredGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL); 58 | recyclerview_watch_more.setLayoutManager(staggeredGridLayoutManager); 59 | watchMoreRecyclerAdapter = new WatchMoreRecyclerAdapter(); 60 | watchMoreRecyclerAdapter.setContext(getContext()); 61 | recyclerview_watch_more.setAdapter(watchMoreRecyclerAdapter); 62 | swipe_refresh_layout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout); 63 | swipe_refresh_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { 64 | @Override 65 | public void onRefresh() { 66 | isRefresh = true; 67 | okhttpHelper.getByUrl("https://www.apiopen.top/meituApi?page=0"); 68 | } 69 | }); 70 | recyclerview_watch_more.addOnScrollListener(new EndLessOnScrollListener(staggeredGridLayoutManager) { 71 | @Override 72 | public void onLoadMore() { 73 | Log.i(TAG, "recycler is loading......."); 74 | okhttpHelper.getByUrl("https://www.apiopen.top/meituApi?page=0"); 75 | } 76 | }); 77 | init(); 78 | return view; 79 | } 80 | 81 | public void init() { 82 | okhttpHelper = new OkhttpHelper(); 83 | okhttpHelper.setCallback(this); 84 | okhttpHelper.getByUrl("https://www.apiopen.top/meituApi?page=0"); 85 | 86 | } 87 | 88 | 89 | @Override 90 | public void onFailure(Call call, IOException e) { 91 | 92 | } 93 | 94 | @Override 95 | public void onResponse(Call call, Response response) throws IOException { 96 | 97 | Gson gson = new Gson(); 98 | datas = gson.fromJson(response.body().string(), BeautifulPictureEntry.class); 99 | getActivity().runOnUiThread(new Runnable() { 100 | @Override 101 | public void run() { 102 | watchMoreRecyclerAdapter.setDatas(datas.data, isRefresh); 103 | if (isRefresh) { 104 | swipe_refresh_layout.setRefreshing(false); 105 | isRefresh = false; 106 | } 107 | 108 | } 109 | }); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Interface/EndLessOnScrollListener.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Interface; 2 | 3 | import android.support.v7.widget.LinearLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.support.v7.widget.StaggeredGridLayoutManager; 6 | import android.util.Log; 7 | 8 | /** 9 | * Created by jakera on 18-2-28. 10 | */ 11 | 12 | /** 13 | * 得进行其他布局管理器的适配 14 | */ 15 | 16 | public abstract class EndLessOnScrollListener extends RecyclerView.OnScrollListener { 17 | // 声明一个 LinearLayoutManager 18 | private StaggeredGridLayoutManager staggeredGridLayoutManager; 19 | // 已经加载出来的Item的数量 20 | private int totalItemCount; 21 | // 在屏幕上可见的item数量 22 | private int visibleItemCount; 23 | // 在屏幕可见的Item中的第一个 24 | private int[] firstVisibleItem; 25 | // 是否正在上拉数据 26 | private boolean loading = false; 27 | 28 | public EndLessOnScrollListener(StaggeredGridLayoutManager staggeredGridLayoutManager) { 29 | this.staggeredGridLayoutManager = staggeredGridLayoutManager; 30 | } 31 | 32 | @Override 33 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) { 34 | super.onScrolled(recyclerView, dx, dy); 35 | visibleItemCount = recyclerView.getChildCount(); 36 | totalItemCount = staggeredGridLayoutManager.getItemCount(); 37 | firstVisibleItem = staggeredGridLayoutManager.findFirstVisibleItemPositions(null); 38 | 39 | if (!loading && totalItemCount - visibleItemCount == firstVisibleItem[0]) { 40 | onLoadMore(); 41 | loading = true; 42 | } else { 43 | loading = false; 44 | } 45 | } 46 | 47 | /** 48 | * 提供一个抽闲方法,在Activity中监听到这个EndLessOnScrollListener * 并且实现这个方法 * 49 | */ 50 | public abstract void onLoadMore(); 51 | } 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Interface/ItemClickListener.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Interface; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by jakera on 18-2-1. 7 | */ 8 | 9 | public interface ItemClickListener { 10 | void OnItemClick(View v,int position); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Others/PicassoTransformation.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Others; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.util.DisplayMetrics; 6 | import android.view.View; 7 | import android.view.WindowManager; 8 | 9 | import com.squareup.picasso.Transformation; 10 | 11 | /** 12 | * Created by jakera on 18-2-24. 13 | */ 14 | 15 | 16 | //让picasso按照比例缩放 17 | public class PicassoTransformation implements Transformation { 18 | 19 | int screenWidth; 20 | double targetWidth; 21 | 22 | /** 23 | * @param view 为了得到contenxt对象获得屏幕宽度 24 | * @param aver 根据屏幕宽度进行的等分 25 | */ 26 | public PicassoTransformation(View view, int aver) { 27 | WindowManager wm = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE); 28 | DisplayMetrics displayMetrics = new DisplayMetrics(); 29 | wm.getDefaultDisplay().getMetrics(displayMetrics); 30 | //获得屏幕宽度 31 | screenWidth = displayMetrics.widthPixels; 32 | targetWidth = screenWidth / aver; 33 | } 34 | 35 | @Override 36 | public Bitmap transform(Bitmap bitmap) { 37 | if (bitmap.getWidth() == 0 || bitmap.getHeight() == 0) { 38 | return bitmap; 39 | } 40 | //得到图片宽高比,每个参数必须强转成double型 41 | double ratio = (double) bitmap.getWidth() / (double) bitmap.getHeight(); 42 | 43 | Bitmap bitmapResult = null; 44 | if (bitmap != null) { 45 | bitmapResult = Bitmap.createScaledBitmap(bitmap, (int) (targetWidth + 0.5), (int) ((targetWidth / ratio) + 0.5), false); 46 | } 47 | if (bitmap != bitmapResult) { 48 | bitmap.recycle(); 49 | } 50 | 51 | return bitmapResult; 52 | } 53 | 54 | @Override 55 | public String key() { 56 | return "transformation" + screenWidth; 57 | } 58 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Receiver/PushReceiver.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Receiver; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.text.TextUtils; 8 | import android.util.Log; 9 | 10 | import org.json.JSONException; 11 | import org.json.JSONObject; 12 | 13 | import java.util.Iterator; 14 | 15 | import cn.jpush.android.api.JPushInterface; 16 | import cn.jpush.im.android.api.options.RegisterOptionalUserInfo; 17 | 18 | /** 19 | * 自定义接收器 20 | *

21 | * 如果不定义这个 Receiver,则: 22 | * 1) 默认用户会打开主界面 23 | * 2) 接收不到自定义消息 24 | */ 25 | public class PushReceiver extends BroadcastReceiver { 26 | private static final String TAG = "PushReceiver"; 27 | 28 | @Override 29 | public void onReceive(Context context, Intent intent) { 30 | 31 | //TODO:接收广播的逻辑 32 | Log.i(TAG, "onReceive"); 33 | 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/SmartChatApp.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat; 2 | 3 | import android.app.Application; 4 | import android.content.Intent; 5 | import android.util.Log; 6 | 7 | import com.example.jakera.smartchat.Activity.ChatActivity; 8 | import com.example.jakera.smartchat.Utils.SharePreferenceUtils; 9 | import com.example.jakera.smartchat.Utils.SpeechSynthesizerUtil; 10 | import com.github.hiteshsondhi88.libffmpeg.FFmpeg; 11 | import com.github.hiteshsondhi88.libffmpeg.FFmpegLoadBinaryResponseHandler; 12 | import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegNotSupportedException; 13 | import com.iflytek.cloud.SpeechConstant; 14 | import com.iflytek.cloud.SpeechUtility; 15 | import com.youdao.sdk.app.YouDaoApplication; 16 | 17 | import cn.jpush.android.api.JPushInterface; 18 | import cn.jpush.im.android.api.JMessageClient; 19 | 20 | /** 21 | * Created by jakera on 18-1-24. 22 | */ 23 | 24 | public class SmartChatApp extends Application { 25 | private final String APPID="5a686b03"; 26 | private String TAG = "SmartChatApp"; 27 | 28 | public static String USERNAME; 29 | 30 | @Override 31 | public void onCreate() { 32 | super.onCreate(); 33 | 34 | USERNAME = (String) SharePreferenceUtils.get(this, SmartChatConstant.SPUSERNAME, ""); 35 | 36 | new Thread(new Runnable() { 37 | @Override 38 | public void run() { 39 | //讯飞语音初始化工作 40 | SpeechUtility.createUtility(SmartChatApp.this, SpeechConstant.APPID + "=" + APPID); 41 | //讯飞文本生成初始化工作 42 | SpeechSynthesizerUtil.getInstance().init(SmartChatApp.this); 43 | 44 | //有道智云初始化工作 45 | YouDaoApplication.init(SmartChatApp.this, SmartChatConstant.YOUDAOAPIKEY); 46 | 47 | 48 | //极光推送 49 | JPushInterface.setDebugMode(true); 50 | JPushInterface.init(SmartChatApp.this); 51 | //极光即时通信 52 | JMessageClient.setDebugMode(true); 53 | JMessageClient.init(SmartChatApp.this); 54 | 55 | Intent intent = new Intent(SmartChatApp.this, SmartChatService.class); 56 | startService(intent); 57 | 58 | final FFmpeg fFmpeg = FFmpeg.getInstance(SmartChatApp.this); 59 | try { 60 | fFmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() { 61 | @Override 62 | public void onFailure() { 63 | Log.i(TAG, "onFailure,FFmpeg加载失败"); 64 | } 65 | 66 | @Override 67 | public void onSuccess() { 68 | Log.i(TAG, "onFailure,FFmpeg加载成功"); 69 | } 70 | 71 | @Override 72 | public void onStart() { 73 | Log.i(TAG, "onFailure,FFmpeg加载开始"); 74 | } 75 | 76 | @Override 77 | public void onFinish() { 78 | Log.i(TAG, "onFailure,FFmpeg加载完成"); 79 | } 80 | }); 81 | } catch (FFmpegNotSupportedException e) { 82 | e.printStackTrace(); 83 | } 84 | 85 | 86 | } 87 | }).start(); 88 | 89 | Log.i("SmartChat", "i am onCreate...."); 90 | 91 | 92 | 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/SmartChatConstant.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat; 2 | 3 | /** 4 | * Created by jakera on 18-1-25. 5 | */ 6 | 7 | public class SmartChatConstant { 8 | 9 | 10 | //https://www.apiopen.top/meituApi?page=0 美图api 11 | 12 | //几个代表页面的常量 13 | public static final int PAGE_ONE = 0; 14 | public static final int PAGE_TWO = 1; 15 | public static final int PAGE_THREE = 2; 16 | public static final int PAGE_FOUR = 3; 17 | 18 | //图灵机器人相关 19 | public static final String TULINGAPI="http://www.tuling123.com/openapi/api"; 20 | public static final String TULINGROBOTAPIKEY="c12638962d45e9d325ce432506a0b"; //请替换为自己的平台KEY 21 | 22 | //有道智云翻译 23 | public static final String YOUDAOAPIKEY = "52b126ae925be"; //请替换为自己的平台KEY 24 | 25 | public static final String APPNAME = "smartchat"; 26 | 27 | public static final String SPISLOGINKEY = "isLogin"; 28 | public static final String SPUSERNAME = "username"; 29 | 30 | 31 | //百度 32 | public static final String BAIDUAPIKEY = "eM8bZQD44G2wzKznM1Mx"; //请替换为自己的平台KEY 33 | public static final String BAIDUSECRETKEY = "9ldsgbi31QDSHfYzOukH6FTH9W1iG"; //请替换为自己的平台KEY 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/AudioManager.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | 4 | import android.media.MediaRecorder; 5 | import android.util.Log; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.util.UUID; 10 | 11 | /** 12 | * Created by jakera on 18-2-2. 13 | */ 14 | 15 | /** 16 | * 使用MediaRecorder类录音,输出amr格式文件。录音20s,输出的音频文件大概为33K(已写测试代码) 17 | * ffmpeg -i D:\Testaudio\dizi.mp3 -ar 8000 -ac 1 -acodec pcm_u8 d:\testaudio\dizi.wav 18 | * linux下,可用sox对音频文件进行转换及处理 19 | */ 20 | 21 | public class AudioManager { 22 | private MediaRecorder mMediaRecorder; 23 | 24 | private String mDir; 25 | private String mCurrentFilePath; 26 | 27 | private boolean isPrepared; 28 | 29 | private String TAG="AudioManager"; 30 | 31 | private static AudioManager mInstance; 32 | private AudioManager(String dir){ 33 | mDir = dir; 34 | } 35 | 36 | /** 37 | * 回调准备完毕 38 | * @author Administrator 39 | * 40 | */ 41 | public interface AudioStateListener{ 42 | void wellPrepared(); 43 | } 44 | 45 | public AudioStateListener mListener; 46 | 47 | public void setOnAudioStateListener(AudioStateListener listener){ 48 | mListener = listener; 49 | } 50 | 51 | 52 | 53 | public static AudioManager getInstance(String dir){ 54 | if (mInstance == null) { 55 | synchronized (AudioManager.class) { 56 | if (mInstance == null) { 57 | mInstance = new AudioManager(dir); 58 | } 59 | } 60 | } 61 | return mInstance; 62 | } 63 | 64 | public void prepareAudio(){ 65 | 66 | try { 67 | isPrepared = false; 68 | File dir = new File(mDir); 69 | if (!dir.exists()) { 70 | dir.mkdirs(); 71 | } 72 | String fileName = generateFileName(); 73 | File file = new File(dir, fileName); 74 | 75 | mCurrentFilePath = file.getAbsolutePath(); 76 | mMediaRecorder = new MediaRecorder(); 77 | //设置输出文件 78 | mMediaRecorder.setOutputFile(file.getAbsolutePath()); 79 | //设置MediaRecorder的音频源为麦克风 80 | mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); 81 | //设置音频的格式 82 | mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); 83 | //设置采样率 84 | mMediaRecorder.setAudioSamplingRate(8000); 85 | //设置音频的编码为amr 86 | mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 87 | mMediaRecorder.prepare(); 88 | 89 | mMediaRecorder.start(); 90 | //准备结束 91 | isPrepared = true; 92 | if (mListener != null) { 93 | mListener.wellPrepared(); 94 | } 95 | 96 | } catch (IllegalStateException e) { 97 | // TODO Auto-generated catch block 98 | e.printStackTrace(); 99 | } catch (IOException e) { 100 | // TODO Auto-generated catch block 101 | e.printStackTrace(); 102 | } 103 | } 104 | 105 | /** 106 | * 随机生成文件的名称 107 | * @return 108 | */ 109 | private String generateFileName() { 110 | // TODO Auto-generated method stub 111 | return UUID.randomUUID().toString() + ".amr"; 112 | //return "123.amr"; 113 | } 114 | 115 | 116 | 117 | public int getVoiceLevel(int maxLevel){ 118 | if (isPrepared) { 119 | try { 120 | //mMediaRecorder.getMaxAmplitude() 1-32767 121 | return maxLevel*mMediaRecorder.getMaxAmplitude()/32768+1; 122 | } catch (Exception e) { 123 | // TODO: handle exception 124 | } 125 | 126 | } 127 | return 1; 128 | } 129 | 130 | public void release(){ 131 | mMediaRecorder.stop(); 132 | mMediaRecorder.release(); 133 | mMediaRecorder = null; 134 | } 135 | 136 | public void cancel(){ 137 | release(); 138 | if (mCurrentFilePath != null) { 139 | File file = new File(mCurrentFilePath); 140 | file.delete(); 141 | mCurrentFilePath = null; 142 | } 143 | 144 | } 145 | 146 | public String getCurrentFilePath() { 147 | // TODO Auto-generated method stub 148 | return mCurrentFilePath; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/BaiduAuthService.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import com.example.jakera.smartchat.SmartChatConstant; 4 | 5 | import org.json.JSONObject; 6 | 7 | import java.io.BufferedReader; 8 | import java.io.InputStreamReader; 9 | import java.net.HttpURLConnection; 10 | import java.net.URL; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | /** 15 | * Created by jakera on 18-3-9. 16 | * 获取token 17 | */ 18 | 19 | public class BaiduAuthService { 20 | 21 | 22 | /** 23 | * 获取权限token 24 | * 25 | * @return 返回示例: 26 | * { 27 | * "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567", 28 | * "expires_in": 2592000 29 | * } 30 | */ 31 | public static String getAuth() { 32 | // 官网获取的 API Key 更新为你注册的 33 | String clientId = SmartChatConstant.BAIDUAPIKEY; 34 | // 官网获取的 Secret Key 更新为你注册的 35 | String clientSecret = SmartChatConstant.BAIDUSECRETKEY; 36 | return getAuth(clientId, clientSecret); 37 | } 38 | 39 | /** 40 | * 获取API访问token 41 | * 该token有一定的有效期,需要自行管理,当失效时需重新获取. 42 | * 43 | * @param ak - 百度云官网获取的 API Key 44 | * @param sk - 百度云官网获取的 Securet Key 45 | * @return assess_token 示例: 46 | * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567" 47 | */ 48 | public static String getAuth(String ak, String sk) { 49 | // 获取token地址 50 | String authHost = "https://aip.baidubce.com/oauth/2.0/token?"; 51 | String getAccessTokenUrl = authHost 52 | // 1. grant_type为固定参数 53 | + "grant_type=client_credentials" 54 | // 2. 官网获取的 API Key 55 | + "&client_id=" + ak 56 | // 3. 官网获取的 Secret Key 57 | + "&client_secret=" + sk; 58 | try { 59 | URL realUrl = new URL(getAccessTokenUrl); 60 | // 打开和URL之间的连接 61 | HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection(); 62 | connection.setRequestMethod("GET"); 63 | connection.connect(); 64 | // 获取所有响应头字段 65 | Map> map = connection.getHeaderFields(); 66 | // 遍历所有的响应头字段 67 | for (String key : map.keySet()) { 68 | System.err.println(key + "--->" + map.get(key)); 69 | } 70 | // 定义 BufferedReader输入流来读取URL的响应 71 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); 72 | String result = ""; 73 | String line; 74 | while ((line = in.readLine()) != null) { 75 | result += line; 76 | } 77 | /** 78 | * 返回结果示例 79 | */ 80 | System.err.println("result:" + result); 81 | JSONObject jsonObject = new JSONObject(result); 82 | String access_token = jsonObject.getString("access_token"); 83 | return access_token; 84 | } catch (Exception e) { 85 | System.err.printf("获取token失败!"); 86 | e.printStackTrace(System.err); 87 | } 88 | return null; 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/BaiduFileUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import java.io.*; 4 | 5 | /** 6 | * 文件读取工具类 7 | */ 8 | public class BaiduFileUtil { 9 | 10 | /** 11 | * 读取文件内容,作为字符串返回 12 | */ 13 | public static String readFileAsString(String filePath) throws IOException { 14 | File file = new File(filePath); 15 | if (!file.exists()) { 16 | throw new FileNotFoundException(filePath); 17 | } 18 | 19 | if (file.length() > 1024 * 1024 * 1024) { 20 | throw new IOException("File is too large"); 21 | } 22 | 23 | StringBuilder sb = new StringBuilder((int) (file.length())); 24 | // 创建字节输入流 25 | FileInputStream fis = new FileInputStream(filePath); 26 | // 创建一个长度为10240的Buffer 27 | byte[] bbuf = new byte[10240]; 28 | // 用于保存实际读取的字节数 29 | int hasRead = 0; 30 | while ((hasRead = fis.read(bbuf)) > 0) { 31 | sb.append(new String(bbuf, 0, hasRead)); 32 | } 33 | fis.close(); 34 | return sb.toString(); 35 | } 36 | 37 | /** 38 | * 根据文件路径读取byte[] 数组 39 | */ 40 | public static byte[] readFileByBytes(String filePath) throws IOException { 41 | File file = new File(filePath); 42 | if (!file.exists()) { 43 | throw new FileNotFoundException(filePath); 44 | } else { 45 | ByteArrayOutputStream bos = new ByteArrayOutputStream((int) file.length()); 46 | BufferedInputStream in = null; 47 | 48 | try { 49 | in = new BufferedInputStream(new FileInputStream(file)); 50 | short bufSize = 1024; 51 | byte[] buffer = new byte[bufSize]; 52 | int len1; 53 | while (-1 != (len1 = in.read(buffer, 0, bufSize))) { 54 | bos.write(buffer, 0, len1); 55 | } 56 | 57 | byte[] var7 = bos.toByteArray(); 58 | return var7; 59 | } finally { 60 | try { 61 | if (in != null) { 62 | in.close(); 63 | } 64 | } catch (IOException var14) { 65 | var14.printStackTrace(); 66 | } 67 | 68 | bos.close(); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/Base64Util.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | /** 4 | * Base64 工具类 5 | */ 6 | public class Base64Util { 7 | private static final char last2byte = (char) Integer.parseInt("00000011", 2); 8 | private static final char last4byte = (char) Integer.parseInt("00001111", 2); 9 | private static final char last6byte = (char) Integer.parseInt("00111111", 2); 10 | private static final char lead6byte = (char) Integer.parseInt("11111100", 2); 11 | private static final char lead4byte = (char) Integer.parseInt("11110000", 2); 12 | private static final char lead2byte = (char) Integer.parseInt("11000000", 2); 13 | private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; 14 | 15 | public Base64Util() { 16 | } 17 | 18 | public static String encode(byte[] from) { 19 | StringBuilder to = new StringBuilder((int) ((double) from.length * 1.34D) + 3); 20 | int num = 0; 21 | char currentByte = 0; 22 | 23 | int i; 24 | for (i = 0; i < from.length; ++i) { 25 | for (num %= 8; num < 8; num += 6) { 26 | switch (num) { 27 | case 0: 28 | currentByte = (char) (from[i] & lead6byte); 29 | currentByte = (char) (currentByte >>> 2); 30 | case 1: 31 | case 3: 32 | case 5: 33 | default: 34 | break; 35 | case 2: 36 | currentByte = (char) (from[i] & last6byte); 37 | break; 38 | case 4: 39 | currentByte = (char) (from[i] & last4byte); 40 | currentByte = (char) (currentByte << 2); 41 | if (i + 1 < from.length) { 42 | currentByte = (char) (currentByte | (from[i + 1] & lead2byte) >>> 6); 43 | } 44 | break; 45 | case 6: 46 | currentByte = (char) (from[i] & last2byte); 47 | currentByte = (char) (currentByte << 4); 48 | if (i + 1 < from.length) { 49 | currentByte = (char) (currentByte | (from[i + 1] & lead4byte) >>> 4); 50 | } 51 | } 52 | 53 | to.append(encodeTable[currentByte]); 54 | } 55 | } 56 | 57 | if (to.length() % 4 != 0) { 58 | for (i = 4 - to.length() % 4; i > 0; --i) { 59 | to.append("="); 60 | } 61 | } 62 | 63 | return to.toString(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/DeleteFileUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * Created by jakera on 18-3-15. 7 | */ 8 | 9 | public class DeleteFileUtil { 10 | /** 11 | * 删除文件,可以是文件或文件夹 12 | * 13 | * @param fileName 要删除的文件名 14 | * @return 删除成功返回true,否则返回false 15 | */ 16 | public static boolean delete(String fileName) { 17 | File file = new File(fileName); 18 | if (!file.exists()) { 19 | System.out.println("删除文件失败:" + fileName + "不存在!"); 20 | return false; 21 | } else { 22 | if (file.isFile()) 23 | return deleteFile(fileName); 24 | else 25 | return deleteDirectory(fileName); 26 | } 27 | } 28 | 29 | /** 30 | * 删除单个文件 31 | * 32 | * @param fileName 要删除的文件的文件名 33 | * @return 单个文件删除成功返回true,否则返回false 34 | */ 35 | public static boolean deleteFile(String fileName) { 36 | File file = new File(fileName); 37 | // 如果文件路径所对应的文件存在,并且是一个文件,则直接删除 38 | if (file.exists() && file.isFile()) { 39 | if (file.delete()) { 40 | System.out.println("删除单个文件" + fileName + "成功!"); 41 | return true; 42 | } else { 43 | System.out.println("删除单个文件" + fileName + "失败!"); 44 | return false; 45 | } 46 | } else { 47 | System.out.println("删除单个文件失败:" + fileName + "不存在!"); 48 | return false; 49 | } 50 | } 51 | 52 | /** 53 | * 删除目录及目录下的文件 54 | * 55 | * @param dir 要删除的目录的文件路径 56 | * @return 目录删除成功返回true,否则返回false 57 | */ 58 | public static boolean deleteDirectory(String dir) { 59 | // 如果dir不以文件分隔符结尾,自动添加文件分隔符 60 | if (!dir.endsWith(File.separator)) 61 | dir = dir + File.separator; 62 | File dirFile = new File(dir); 63 | // 如果dir对应的文件不存在,或者不是一个目录,则退出 64 | if ((!dirFile.exists()) || (!dirFile.isDirectory())) { 65 | System.out.println("删除目录失败:" + dir + "不存在!"); 66 | return false; 67 | } 68 | boolean flag = true; 69 | // 删除文件夹中的所有文件包括子目录 70 | File[] files = dirFile.listFiles(); 71 | for (int i = 0; i < files.length; i++) { 72 | // 删除子文件 73 | if (files[i].isFile()) { 74 | flag = DeleteFileUtil.deleteFile(files[i].getAbsolutePath()); 75 | if (!flag) 76 | break; 77 | } 78 | // 删除子目录 79 | else if (files[i].isDirectory()) { 80 | flag = DeleteFileUtil.deleteDirectory(files[i] 81 | .getAbsolutePath()); 82 | if (!flag) 83 | break; 84 | } 85 | } 86 | if (!flag) { 87 | System.out.println("删除目录失败!"); 88 | return false; 89 | } 90 | // 删除当前目录 91 | if (dirFile.delete()) { 92 | System.out.println("删除目录" + dir + "成功!"); 93 | return true; 94 | } else { 95 | return false; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/DialogManager.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | /** 4 | * Created by jakera on 18-2-2. 5 | */ 6 | 7 | import android.app.Dialog; 8 | import android.content.Context; 9 | import android.util.Log; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | 15 | import com.example.jakera.smartchat.R; 16 | 17 | public class DialogManager { 18 | 19 | private Dialog mDialog; 20 | 21 | private ImageView mIcon; 22 | private ImageView mVoice; 23 | 24 | private TextView mLable; 25 | 26 | private Context mContext; 27 | 28 | private String TAG="DialogManager"; 29 | 30 | public DialogManager(Context context){ 31 | mContext = context; 32 | } 33 | 34 | public void showRecordingDialog(){ 35 | mDialog = new Dialog(mContext, R.style.Theme_AudioDialog); 36 | LayoutInflater inflater = LayoutInflater.from(mContext); 37 | View view = inflater.inflate(R.layout.dialog_recorder, null); 38 | mDialog.setContentView(view); 39 | 40 | mIcon = (ImageView) mDialog.findViewById(R.id.id_recorder_dialog_icon); 41 | mVoice = (ImageView) mDialog.findViewById(R.id.id_recorder_dialog_voice); 42 | mLable = (TextView) mDialog.findViewById(R.id.id_recorder_dialog_label); 43 | 44 | mDialog.show(); 45 | } 46 | 47 | public void recording(){ 48 | if (mDialog != null && mDialog.isShowing()) { 49 | mIcon.setVisibility(View.VISIBLE); 50 | mVoice.setVisibility(View.VISIBLE); 51 | mLable.setVisibility(View.VISIBLE); 52 | 53 | mIcon.setImageResource(R.mipmap.recorder); 54 | mLable.setText("手指上滑,取消发送"); 55 | } 56 | } 57 | 58 | public void wantToCancel(){ 59 | if (mDialog != null && mDialog.isShowing()) { 60 | mIcon.setVisibility(View.VISIBLE); 61 | mVoice.setVisibility(View.GONE); 62 | mLable.setVisibility(View.VISIBLE); 63 | 64 | mIcon.setImageResource(R.mipmap.voice_cancel); 65 | mLable.setText("松开手指,取消发送"); 66 | } 67 | } 68 | 69 | public void tooShort(){ 70 | if (mDialog != null && mDialog.isShowing()) { 71 | mIcon.setVisibility(View.VISIBLE); 72 | mVoice.setVisibility(View.GONE); 73 | mLable.setVisibility(View.VISIBLE); 74 | 75 | mIcon.setImageResource(R.mipmap.voice_to_short); 76 | mLable.setText("录音时间过短"); 77 | } 78 | } 79 | 80 | public void dimissDialog(){ 81 | if (mDialog != null && mDialog.isShowing()) { 82 | mDialog.dismiss(); 83 | mDialog = null; 84 | } 85 | } 86 | 87 | /** 88 | * 通过level去更新voice上的图片 89 | * @param level1-7 90 | */ 91 | public void updateVoiceLevel(int level){ 92 | if (mDialog != null && mDialog.isShowing()) { 93 | //这里注意你放V1-V7的位置,若在drawable目录下,则defType为drawable,若放在mipmap下,则改为drawable. 94 | int resId = mContext.getResources().getIdentifier("v"+level, "mipmap", 95 | mContext.getPackageName()); 96 | mVoice.setImageResource(resId); 97 | } 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/GsonUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Baidu, Inc. All Rights Reserved. 3 | */ 4 | package com.example.jakera.smartchat.Utils; 5 | 6 | import com.google.gson.Gson; 7 | import com.google.gson.GsonBuilder; 8 | import com.google.gson.JsonParseException; 9 | 10 | import java.lang.reflect.Type; 11 | 12 | /** 13 | * Json工具类. 14 | */ 15 | public class GsonUtils { 16 | private static Gson gson = new GsonBuilder().create(); 17 | 18 | public static String toJson(Object value) { 19 | return gson.toJson(value); 20 | } 21 | 22 | public static T fromJson(String json, Class classOfT) throws JsonParseException { 23 | return gson.fromJson(json, classOfT); 24 | } 25 | 26 | public static T fromJson(String json, Type typeOfT) throws JsonParseException { 27 | return (T) gson.fromJson(json, typeOfT); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/HttpUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.DataOutputStream; 5 | import java.io.InputStreamReader; 6 | import java.net.HttpURLConnection; 7 | import java.net.URL; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * http 工具类 13 | */ 14 | public class HttpUtil { 15 | 16 | public static String post(String requestUrl, String accessToken, String params) 17 | throws Exception { 18 | String contentType = "application/x-www-form-urlencoded"; 19 | return HttpUtil.post(requestUrl, accessToken, contentType, params); 20 | } 21 | 22 | public static String post(String requestUrl, String accessToken, String contentType, String params) 23 | throws Exception { 24 | String encoding = "UTF-8"; 25 | if (requestUrl.contains("nlp")) { 26 | encoding = "GBK"; 27 | } 28 | return HttpUtil.post(requestUrl, accessToken, contentType, params, encoding); 29 | } 30 | 31 | public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding) 32 | throws Exception { 33 | String url = requestUrl + "?access_token=" + accessToken; 34 | return HttpUtil.postGeneralUrl(url, contentType, params, encoding); 35 | } 36 | 37 | public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding) 38 | throws Exception { 39 | URL url = new URL(generalUrl); 40 | // 打开和URL之间的连接 41 | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 42 | connection.setRequestMethod("POST"); 43 | // 设置通用的请求属性 44 | connection.setRequestProperty("Content-Type", contentType); 45 | connection.setRequestProperty("Connection", "Keep-Alive"); 46 | connection.setUseCaches(false); 47 | connection.setDoOutput(true); 48 | connection.setDoInput(true); 49 | 50 | // 得到请求的输出流对象 51 | DataOutputStream out = new DataOutputStream(connection.getOutputStream()); 52 | out.write(params.getBytes(encoding)); 53 | out.flush(); 54 | out.close(); 55 | 56 | // 建立实际的连接 57 | connection.connect(); 58 | // 获取所有响应头字段 59 | Map> headers = connection.getHeaderFields(); 60 | // 遍历所有的响应头字段 61 | for (String key : headers.keySet()) { 62 | System.err.println(key + "--->" + headers.get(key)); 63 | } 64 | // 定义 BufferedReader输入流来读取URL的响应 65 | BufferedReader in = null; 66 | in = new BufferedReader( 67 | new InputStreamReader(connection.getInputStream(), encoding)); 68 | String result = ""; 69 | String getLine; 70 | while ((getLine = in.readLine()) != null) { 71 | result += getLine; 72 | } 73 | in.close(); 74 | System.err.println("result:" + result); 75 | return result; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/MediaManager.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import android.media.AudioManager; 4 | import android.media.MediaPlayer; 5 | 6 | /** 7 | * Created by jakera on 18-2-2. 8 | */ 9 | 10 | public class MediaManager { 11 | private static MediaPlayer mMediaPlayer; 12 | private static boolean isPause; 13 | 14 | public static void playSound(String filePath, 15 | MediaPlayer.OnCompletionListener onCompletionListener){ 16 | if (mMediaPlayer == null) { 17 | mMediaPlayer = new MediaPlayer(); 18 | mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { 19 | 20 | @Override 21 | public boolean onError(MediaPlayer mp, int what, int extra) { 22 | // TODO Auto-generated method stub 23 | mMediaPlayer.reset(); 24 | return false; 25 | } 26 | }); 27 | }else { 28 | mMediaPlayer.reset(); 29 | } 30 | try { 31 | // mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 32 | // mMediaPlayer.setOnCompletionListener(onCompletionListener); 33 | mMediaPlayer.setDataSource(filePath); 34 | //一定要加入这句才能够正常地录音 35 | mMediaPlayer.prepare(); 36 | mMediaPlayer.start(); 37 | } catch (Exception e) { 38 | // TODO: handle exception 39 | } 40 | } 41 | 42 | public static void pause(){ 43 | if (mMediaPlayer!=null && mMediaPlayer.isPlaying()) { 44 | mMediaPlayer.pause(); 45 | isPause = true; 46 | } 47 | } 48 | public static void resume(){ 49 | if (mMediaPlayer != null && isPause) { 50 | mMediaPlayer.start(); 51 | isPause = false; 52 | } 53 | } 54 | public static void release(){ 55 | if (mMediaPlayer != null) { 56 | mMediaPlayer.release(); 57 | mMediaPlayer = null; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/MySQLiteOpenHelper.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.database.sqlite.SQLiteDatabase; 6 | import android.database.sqlite.SQLiteOpenHelper; 7 | 8 | import com.example.jakera.smartchat.SmartChatApp; 9 | import com.example.jakera.smartchat.SmartChatConstant; 10 | 11 | import cn.jpush.im.android.api.JMessageClient; 12 | 13 | /** 14 | * Created by jakera on 18-3-7. 15 | */ 16 | 17 | public class MySQLiteOpenHelper extends SQLiteOpenHelper { 18 | private static final int DB_VERSION = 1; 19 | //TODO:这里用户名要缓存到本地,否则会出现 20 | private static final String DB_NAME = SmartChatApp.USERNAME + ".db"; 21 | public static final String TABLEMESSAGELIST = "MessageList"; 22 | public static final int MessageTextType = 0; 23 | public static final int MessageVoiceType = 1; 24 | 25 | public MySQLiteOpenHelper(Context context) { 26 | super(context, DB_NAME, null, DB_VERSION); 27 | } 28 | 29 | @Override 30 | public void onCreate(SQLiteDatabase db) { 31 | String sql = "create table if not exists " + TABLEMESSAGELIST + " (username text, content text,time text)"; 32 | db.execSQL(sql); 33 | } 34 | 35 | @Override 36 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 37 | String sql = "DROP TABLE IF EXISTS " + TABLEMESSAGELIST; 38 | db.execSQL(sql); 39 | onCreate(db); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/OkhttpHelper.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | 4 | import android.util.Log; 5 | 6 | import com.example.jakera.smartchat.SmartChatConstant; 7 | 8 | import org.json.JSONArray; 9 | import org.json.JSONObject; 10 | import org.json.JSONTokener; 11 | 12 | import java.io.IOException; 13 | 14 | import okhttp3.Call; 15 | import okhttp3.Callback; 16 | import okhttp3.FormBody; 17 | import okhttp3.OkHttpClient; 18 | import okhttp3.Request; 19 | import okhttp3.Response; 20 | 21 | /** 22 | * Created by jakera on 18-2-1. 23 | */ 24 | 25 | public class OkhttpHelper { 26 | 27 | private OkHttpClient client; 28 | 29 | 30 | private Request request; 31 | 32 | private String TAG="OkhttpHelper"; 33 | 34 | private Callback callback; 35 | 36 | public OkhttpHelper() { 37 | client=new OkHttpClient(); 38 | 39 | } 40 | 41 | public void setCallback(Callback callback){ 42 | this.callback=callback; 43 | } 44 | 45 | public void postToTuLingRobot(String content,String userId){ 46 | //请求体要作为临时变量,否则,第二次请求时add参数时,会加入第一次的数据,导入请求失败 47 | FormBody.Builder formBody; 48 | formBody=new FormBody.Builder(); 49 | formBody.add("key",SmartChatConstant.TULINGROBOTAPIKEY); 50 | formBody.add("info",content); 51 | //用户id,可以关联上下文 52 | formBody.add("userid", userId); 53 | request=new Request.Builder() 54 | .url(SmartChatConstant.TULINGAPI) 55 | .post(formBody.build()) 56 | .build(); 57 | client.newCall(request).enqueue(callback); 58 | } 59 | 60 | public void getByUrl(String url) { 61 | Request request = new Request.Builder() 62 | .url(url) 63 | .build(); 64 | client.newCall(request).enqueue(callback); 65 | 66 | } 67 | 68 | 69 | public String parseTuLingResult(String json){ 70 | String result="不想理你"; 71 | try { 72 | JSONObject jsonObject = new JSONObject(json); 73 | result=jsonObject.getString("text"); 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | } 77 | return result; 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/RecognizerUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileNotFoundException; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.util.ArrayList; 9 | 10 | import org.json.JSONArray; 11 | import org.json.JSONObject; 12 | 13 | import com.iflytek.cloud.ErrorCode; 14 | import com.iflytek.cloud.SpeechConstant; 15 | import com.iflytek.cloud.SpeechUtility; 16 | 17 | import android.content.Context; 18 | 19 | /** 20 | * 功能性函数扩展类 21 | */ 22 | public class RecognizerUtil { 23 | /** 24 | * 读取asset目录下文件。 25 | * @return content 26 | */ 27 | public static String readFile(Context mContext,String file,String code) 28 | { 29 | int len = 0; 30 | byte []buf = null; 31 | String result = ""; 32 | try { 33 | InputStream in = mContext.getAssets().open(file); 34 | len = in.available(); 35 | buf = new byte[len]; 36 | in.read(buf, 0, len); 37 | 38 | result = new String(buf,code); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | return result; 43 | } 44 | /** 45 | * 将字节缓冲区按照固定大小进行分割成数组 46 | * @param buffer 缓冲区 47 | * @param length 缓冲区大小 48 | * @param spsize 切割块大小 49 | * @return 50 | */ 51 | public static ArrayList splitBuffer(byte[] buffer, int length, int spsize) 52 | { 53 | ArrayList array = new ArrayList(); 54 | if(spsize <= 0 || length <= 0 || buffer == null || buffer.length < length) 55 | return array; 56 | int size = 0; 57 | while(size < length) 58 | { 59 | int left = length - size; 60 | if(spsize < left) 61 | { 62 | byte[] sdata = new byte[spsize]; 63 | System.arraycopy(buffer,size,sdata,0,spsize); 64 | array.add(sdata); 65 | size += spsize; 66 | }else 67 | { 68 | byte[] sdata = new byte[left]; 69 | System.arraycopy(buffer,size,sdata,0,left); 70 | array.add(sdata); 71 | size += left; 72 | } 73 | } 74 | return array; 75 | } 76 | /** 77 | * 获取语记是否包含离线听写资源,如未包含跳转至资源下载页面 78 | *1.PLUS_LOCAL_ALL: 本地所有资源 79 | 2.PLUS_LOCAL_ASR: 本地识别资源 80 | 3.PLUS_LOCAL_TTS: 本地合成资源 81 | */ 82 | public static String checkLocalResource(){ 83 | String resource = SpeechUtility.getUtility().getParameter(SpeechConstant.PLUS_LOCAL_ASR); 84 | try { 85 | JSONObject result = new JSONObject(resource); 86 | int ret = result.getInt(SpeechUtility.TAG_RESOURCE_RET); 87 | switch (ret) { 88 | case ErrorCode.SUCCESS: 89 | JSONArray asrArray = result.getJSONObject("result").optJSONArray("asr"); 90 | if (asrArray != null) { 91 | int i = 0; 92 | // 查询否包含离线听写资源 93 | for (; i < asrArray.length(); i++) { 94 | if("iat".equals(asrArray.getJSONObject(i).get(SpeechConstant.DOMAIN))){ 95 | //asrArray中包含语言、方言字段,后续会增加支持方言的本地听写。 96 | //如:"accent": "mandarin","language": "zh_cn" 97 | break; 98 | } 99 | } 100 | if (i >= asrArray.length()) { 101 | 102 | SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR); 103 | return "没有听写资源,跳转至资源下载页面"; 104 | } 105 | }else { 106 | SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR); 107 | return "没有听写资源,跳转至资源下载页面"; 108 | } 109 | break; 110 | case ErrorCode.ERROR_VERSION_LOWER: 111 | return "语记版本过低,请更新后使用本地功能"; 112 | case ErrorCode.ERROR_INVALID_RESULT: 113 | SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR); 114 | return "获取结果出错,跳转至资源下载页面"; 115 | case ErrorCode.ERROR_SYSTEM_PREINSTALL: 116 | //语记为厂商预置版本。 117 | default: 118 | break; 119 | } 120 | } catch (Exception e) { 121 | SpeechUtility.getUtility().openEngineSettings(SpeechConstant.ENG_ASR); 122 | return "获取结果出错,跳转至资源下载页面"; 123 | } 124 | return ""; 125 | } 126 | 127 | /** 128 | * 读取asset目录下音频文件。 129 | * 130 | * @return 二进制文件数据 131 | */ 132 | public static byte[] readAudioFile(Context context, String filename) { 133 | try { 134 | InputStream ins = context.getAssets().open(filename); 135 | byte[] data = new byte[ins.available()]; 136 | 137 | ins.read(data); 138 | ins.close(); 139 | 140 | return data; 141 | } catch (IOException e) { 142 | // TODO Auto-generated catch block 143 | e.printStackTrace(); 144 | } 145 | 146 | return null; 147 | } 148 | 149 | /** 150 | * 根据路径将声音流进行解析 151 | * 152 | * @param filePath 153 | * @return 154 | */ 155 | public static byte[] readAudioFilePath(String filePath) { 156 | File f = new File(filePath); 157 | byte[] data = new byte[(int) f.length()]; //创建合适文件大小的数组 158 | InputStream in = null; 159 | try { 160 | in = new FileInputStream(f); 161 | in.read(data); //读取文件中的内容到b[]数组 162 | in.close(); 163 | } catch (FileNotFoundException e) { 164 | e.printStackTrace(); 165 | } catch (IOException e) { 166 | e.printStackTrace(); 167 | } 168 | 169 | return data; 170 | } 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | } 179 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/SpeechSynthesizerUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | /** 4 | * Created by jakera on 18-2-6. 5 | */ 6 | 7 | import android.content.Context; 8 | import android.os.Bundle; 9 | import android.util.Log; 10 | 11 | import com.iflytek.cloud.InitListener; 12 | import com.iflytek.cloud.SpeechConstant; 13 | import com.iflytek.cloud.SpeechError; 14 | import com.iflytek.cloud.SpeechSynthesizer; 15 | import com.iflytek.cloud.SynthesizerListener; 16 | 17 | /** 18 | * 描述:语音播放工具类 * 19 | * 使用:直接用类名调用得到对实例,然后传入文本直接可以播放文本 20 | */ 21 | public class SpeechSynthesizerUtil { 22 | private static SpeechSynthesizerUtil audioUtils; 23 | private SpeechSynthesizer mySynthesizer; 24 | 25 | public SpeechSynthesizerUtil() { 26 | } 27 | 28 | /** 29 | * 描述:单例 * 30 | */ 31 | public static SpeechSynthesizerUtil getInstance() { 32 | if (audioUtils == null) { 33 | synchronized (SpeechSynthesizerUtil.class) { 34 | if (audioUtils == null) { 35 | audioUtils = new SpeechSynthesizerUtil(); 36 | } 37 | } 38 | } 39 | return audioUtils; 40 | } 41 | 42 | private InitListener myInitListener = new InitListener() { 43 | @Override 44 | public void onInit(int code) { 45 | Log.d("mySynthesiezer:", "InitListener init() code = " + code); 46 | } 47 | }; 48 | 49 | /** 50 | * 描述:初始化语音配置 * 51 | */ 52 | public void init(Context context) { 53 | //处理语音合成关键类 54 | mySynthesizer = SpeechSynthesizer.createSynthesizer(context, myInitListener); 55 | //设置发音人 56 | mySynthesizer.setParameter(SpeechConstant.VOICE_NAME, "xiaoyan"); 57 | //设置音调 58 | mySynthesizer.setParameter(SpeechConstant.PITCH, "50"); 59 | //设置音量 60 | mySynthesizer.setParameter(SpeechConstant.VOLUME, "50"); 61 | } 62 | 63 | /** 64 | * 描述:根据传入的文本转换音频并播放 * 65 | */ 66 | public void speakText(String content) { 67 | int code = mySynthesizer.startSpeaking(content, new SynthesizerListener() { 68 | @Override 69 | public void onSpeakBegin() { 70 | } 71 | 72 | @Override 73 | public void onBufferProgress(int i, int i1, int i2, String s) { 74 | } 75 | 76 | @Override 77 | public void onSpeakPaused() { 78 | } 79 | 80 | @Override 81 | public void onSpeakResumed() { 82 | } 83 | 84 | @Override 85 | public void onSpeakProgress(int i, int i1, int i2) { 86 | } 87 | 88 | @Override 89 | public void onCompleted(SpeechError speechError) { 90 | } 91 | 92 | @Override 93 | public void onEvent(int i, int i1, int i2, Bundle bundle) { 94 | } 95 | }); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/TimeUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | /** 8 | * Created by jakera on 18-3-8. 9 | */ 10 | 11 | public class TimeUtil { 12 | 13 | /* 14 | * 将时间转换为时间戳 15 | */ 16 | public static String dateToStamp(String s) throws ParseException { 17 | String res; 18 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 19 | Date date = simpleDateFormat.parse(s); 20 | long ts = date.getTime(); 21 | res = String.valueOf(ts); 22 | return res; 23 | 24 | } 25 | 26 | 27 | /* 28 | * 将时间戳转换为时间 29 | */ 30 | public static String stampToDate(String s) { 31 | String res; 32 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 33 | long lt = new Long(s); 34 | Date date = new Date(lt); 35 | res = simpleDateFormat.format(date); 36 | return res; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Utils/TranslateUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Utils; 2 | 3 | import android.util.Log; 4 | 5 | import com.example.jakera.smartchat.SmartChatConstant; 6 | import com.youdao.sdk.app.Language; 7 | import com.youdao.sdk.app.LanguageUtils; 8 | import com.youdao.sdk.ydonlinetranslate.Translator; 9 | import com.youdao.sdk.ydtranslate.Translate; 10 | import com.youdao.sdk.ydtranslate.TranslateErrorCode; 11 | import com.youdao.sdk.ydtranslate.TranslateListener; 12 | import com.youdao.sdk.ydtranslate.TranslateParameters; 13 | 14 | /** 15 | * Created by jakera on 18-2-6. 16 | */ 17 | 18 | /** 19 | * 110错误是因为服务端的应用没有绑定相应的服务,所以得创建服务之后,再进行服务绑定。 20 | */ 21 | 22 | public class TranslateUtil { 23 | 24 | public static void translate(String fromLanguage, String toLanguage, String content, TranslateListener listener) { 25 | 26 | //查词对象初始化,请设置source参数为app对应的名称(英文字符串) 27 | Language langFrom = LanguageUtils.getLangByName(fromLanguage); 28 | //若设置为自动,则查询自动识别源语言,自动识别不能保证完全正确,最好传源语言类型 29 | //Language langFrom = LanguageUtils.getLangByName("自动"); 30 | Language langTo = LanguageUtils.getLangByName(toLanguage); 31 | 32 | TranslateParameters tps = new TranslateParameters.Builder() 33 | .source(SmartChatConstant.APPNAME) 34 | .from(langFrom).to(langTo).build(); 35 | 36 | Translator translator = Translator.getInstance(tps); 37 | 38 | 39 | //查询,返回两种情况,一种是成功,相关结果存储在result参数中, 40 | // 另外一种是失败,失败信息放在TranslateErrorCode 是一个枚举类,整个查询是异步的,为了简化操作,回调都是在主线程发生。 41 | 42 | translator.lookup(content, "requestId", listener); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Views/BubbleLinearLayout.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Views; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.RectF; 6 | import android.util.AttributeSet; 7 | import android.widget.LinearLayout; 8 | 9 | import com.example.jakera.smartchat.R; 10 | 11 | 12 | /** 13 | * Created by lgp on 2015/3/25. 14 | */ 15 | public class BubbleLinearLayout extends LinearLayout { 16 | private BubbleDrawable bubbleDrawable; 17 | private float mArrowWidth; 18 | private float mAngle; 19 | private float mArrowHeight; 20 | private float mArrowPosition; 21 | private BubbleDrawable.ArrowLocation mArrowLocation; 22 | private int bubbleColor; 23 | private boolean mArrowCenter; 24 | public BubbleLinearLayout(Context context) { 25 | super(context); 26 | initView(null); 27 | } 28 | 29 | public BubbleLinearLayout(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | initView(attrs); 32 | } 33 | 34 | 35 | private void initView(AttributeSet attrs){ 36 | if (attrs != null){ 37 | TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.BubbleView); 38 | mArrowWidth = array.getDimension(R.styleable.BubbleView_arrowWidth, 39 | BubbleDrawable.Builder.DEFAULT_ARROW_WITH); 40 | mArrowHeight = array.getDimension(R.styleable.BubbleView_arrowHeight, 41 | BubbleDrawable.Builder.DEFAULT_ARROW_HEIGHT); 42 | mAngle = array.getDimension(R.styleable.BubbleView_angle, 43 | BubbleDrawable.Builder.DEFAULT_ANGLE); 44 | mArrowPosition = array.getDimension(R.styleable.BubbleView_arrowPosition, 45 | BubbleDrawable.Builder.DEFAULT_ARROW_POSITION); 46 | bubbleColor = array.getColor(R.styleable.BubbleView_bubbleColor, 47 | BubbleDrawable.Builder.DEFAULT_BUBBLE_COLOR); 48 | int location = array.getInt(R.styleable.BubbleView_arrowLocation, 0); 49 | mArrowLocation = BubbleDrawable.ArrowLocation.mapIntToValue(location); 50 | mArrowCenter = array.getBoolean(R.styleable.BubbleView_arrowCenter, false); 51 | array.recycle(); 52 | } 53 | } 54 | 55 | @Override 56 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 57 | super.onSizeChanged(w, h, oldw, oldh); 58 | if (w > 0 && h > 0){ 59 | setUp(w, h); 60 | } 61 | } 62 | 63 | private void setUp(int left, int right, int top, int bottom){ 64 | if (right < left || bottom < top) 65 | return; 66 | RectF rectF = new RectF(left, top, right, bottom); 67 | bubbleDrawable = new BubbleDrawable.Builder() 68 | .rect(rectF) 69 | .arrowLocation(mArrowLocation) 70 | .bubbleType(BubbleDrawable.BubbleType.COLOR) 71 | .angle(mAngle) 72 | .arrowHeight(mArrowHeight) 73 | .arrowWidth(mArrowWidth) 74 | .arrowPosition(mArrowPosition) 75 | .bubbleColor(bubbleColor) 76 | .arrowCenter(mArrowCenter) 77 | .build(); 78 | } 79 | 80 | private void setUp(int width, int height){ 81 | setUp(getPaddingLeft(), width - getPaddingRight(), 82 | getPaddingTop(), height - getPaddingBottom()); 83 | setBackgroundDrawable(bubbleDrawable); 84 | } 85 | 86 | public void setUpBubbleDrawable () { 87 | setBackgroundDrawable(null); 88 | post(new Runnable() { 89 | @Override 90 | public void run() { 91 | setUp(getWidth(), getHeight()); 92 | } 93 | }); 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Views/BubbleTextView.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Views; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.content.res.TypedArray; 6 | import android.graphics.Canvas; 7 | import android.graphics.RectF; 8 | import android.util.AttributeSet; 9 | import android.widget.TextView; 10 | 11 | import com.example.jakera.smartchat.R; 12 | 13 | 14 | /** 15 | * Created by lgp on 2015/3/24. 16 | */ 17 | @SuppressLint("AppCompatCustomView") 18 | public class BubbleTextView extends TextView { 19 | private BubbleDrawable bubbleDrawable; 20 | private float mArrowWidth; 21 | private float mAngle; 22 | private float mArrowHeight; 23 | private float mArrowPosition; 24 | private int bubbleColor; 25 | private BubbleDrawable.ArrowLocation mArrowLocation; 26 | private boolean mArrowCenter; 27 | 28 | public BubbleTextView(Context context) { 29 | super(context); 30 | initView(null); 31 | } 32 | 33 | public BubbleTextView(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | initView(attrs); 36 | } 37 | 38 | public BubbleTextView(Context context, AttributeSet attrs, int defStyle) { 39 | super(context, attrs, defStyle); 40 | initView(attrs); 41 | } 42 | 43 | private void initView(AttributeSet attrs) { 44 | if (attrs != null) { 45 | TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.BubbleView); 46 | mArrowWidth = array.getDimension(R.styleable.BubbleView_arrowWidth, 47 | BubbleDrawable.Builder.DEFAULT_ARROW_WITH); 48 | mArrowHeight = array.getDimension(R.styleable.BubbleView_arrowHeight, 49 | BubbleDrawable.Builder.DEFAULT_ARROW_HEIGHT); 50 | mAngle = array.getDimension(R.styleable.BubbleView_angle, 51 | BubbleDrawable.Builder.DEFAULT_ANGLE); 52 | mArrowPosition = array.getDimension(R.styleable.BubbleView_arrowPosition, 53 | BubbleDrawable.Builder.DEFAULT_ARROW_POSITION); 54 | bubbleColor = array.getColor(R.styleable.BubbleView_bubbleColor, 55 | BubbleDrawable.Builder.DEFAULT_BUBBLE_COLOR); 56 | int location = array.getInt(R.styleable.BubbleView_arrowLocation, 0); 57 | mArrowLocation = BubbleDrawable.ArrowLocation.mapIntToValue(location); 58 | mArrowCenter = array.getBoolean(R.styleable.BubbleView_arrowCenter, false); 59 | array.recycle(); 60 | } 61 | setUpPadding(); 62 | } 63 | 64 | @Override 65 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 66 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 67 | } 68 | 69 | @Override 70 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 71 | super.onSizeChanged(w, h, oldw, oldh); 72 | if (w > 0 && h > 0) { 73 | setUp(w, h); 74 | } 75 | } 76 | 77 | @Override 78 | public void layout(int l, int t, int r, int b) { 79 | super.layout(l, t, r, b); 80 | setUp(); 81 | } 82 | 83 | @Override 84 | protected void onDraw(Canvas canvas) { 85 | if (bubbleDrawable != null) 86 | bubbleDrawable.draw(canvas); 87 | super.onDraw(canvas); 88 | } 89 | 90 | private void setUp(int width, int height) { 91 | setUp(0, width, 0, height); 92 | } 93 | 94 | private void setUp() { 95 | setUp(getWidth(), getHeight()); 96 | } 97 | 98 | private void setUp(int left, int right, int top, int bottom) { 99 | RectF rectF = new RectF(left, top, right, bottom); 100 | bubbleDrawable = new BubbleDrawable.Builder() 101 | .rect(rectF) 102 | .arrowLocation(mArrowLocation) 103 | .bubbleType(BubbleDrawable.BubbleType.COLOR) 104 | .angle(mAngle) 105 | .arrowHeight(mArrowHeight) 106 | .arrowWidth(mArrowWidth) 107 | .bubbleColor(bubbleColor) 108 | .arrowPosition(mArrowPosition) 109 | .arrowCenter(mArrowCenter) 110 | .build(); 111 | } 112 | 113 | private void setUpPadding() { 114 | int left = getPaddingLeft(); 115 | int right = getPaddingRight(); 116 | int top = getPaddingTop(); 117 | int bottom = getPaddingBottom(); 118 | switch (mArrowLocation) { 119 | case LEFT: 120 | left += mArrowWidth; 121 | break; 122 | case RIGHT: 123 | right += mArrowWidth; 124 | break; 125 | case TOP: 126 | top += mArrowHeight; 127 | break; 128 | case BOTTOM: 129 | bottom += mArrowHeight; 130 | break; 131 | } 132 | setPadding(left, top, right, bottom); 133 | } 134 | 135 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Views/ClipView.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Views; 2 | 3 | /** 4 | * Created by jakera on 18-2-24. 5 | */ 6 | 7 | import android.annotation.SuppressLint; 8 | import android.content.Context; 9 | import android.graphics.Canvas; 10 | import android.graphics.Color; 11 | import android.graphics.Paint; 12 | import android.graphics.PorterDuff; 13 | import android.graphics.PorterDuffXfermode; 14 | import android.graphics.Rect; 15 | import android.graphics.Xfermode; 16 | import android.util.AttributeSet; 17 | import android.util.DisplayMetrics; 18 | import android.view.View; 19 | import android.view.WindowManager; 20 | 21 | /** 22 | * 头像上传裁剪框 23 | */ 24 | public class ClipView extends View { 25 | private Paint paint = new Paint(); 26 | //画裁剪区域边框的画笔 27 | private Paint borderPaint = new Paint(); 28 | //裁剪框水平方向间距 29 | private float mHorizontalPadding; 30 | //裁剪框边框宽度 31 | private int clipBorderWidth; 32 | //裁剪圆框的半径 33 | private int clipRadiusWidth; 34 | //裁剪框矩形宽度 35 | private int clipWidth; 36 | //裁剪框类别,(圆形、矩形),默认为圆形 37 | private ClipType clipType = ClipType.CIRCLE; 38 | private Xfermode xfermode; 39 | 40 | public ClipView(Context context) { 41 | this(context, null); 42 | } 43 | 44 | public ClipView(Context context, AttributeSet attrs) { 45 | this(context, attrs, 0); 46 | } 47 | 48 | public ClipView(Context context, AttributeSet attrs, int defStyle) { 49 | super(context, attrs, defStyle); 50 | //去锯齿 51 | paint.setAntiAlias(true); 52 | borderPaint.setStyle(Paint.Style.STROKE); 53 | borderPaint.setColor(Color.WHITE); 54 | borderPaint.setStrokeWidth(clipBorderWidth); 55 | borderPaint.setAntiAlias(true); 56 | xfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_OUT); 57 | } 58 | 59 | @SuppressLint("WrongConstant") 60 | @Override 61 | protected void onDraw(Canvas canvas) { 62 | super.onDraw(canvas); 63 | int LAYER_FLAGS = Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG 64 | | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG 65 | | Canvas.CLIP_TO_LAYER_SAVE_FLAG; 66 | //通过Xfermode的DST_OUT来产生中间的透明裁剪区域,一定要另起一个Layer(层) 67 | canvas.saveLayer(0, 0, this.getWidth(), this.getHeight(), null, LAYER_FLAGS); 68 | //设置背景 69 | canvas.drawColor(Color.parseColor("#a8000000")); 70 | paint.setXfermode(xfermode); 71 | //绘制圆形裁剪框 72 | if (clipType == ClipType.CIRCLE) { 73 | //中间的透明的圆 74 | canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2, clipRadiusWidth, paint); 75 | //白色的圆边框 76 | canvas.drawCircle(this.getWidth() / 2, this.getHeight() / 2, clipRadiusWidth, borderPaint); 77 | } else if (clipType == ClipType.RECTANGLE) { //绘制矩形裁剪框 78 | //绘制中间的矩形 79 | canvas.drawRect(mHorizontalPadding, this.getHeight() / 2 - clipWidth / 2, 80 | this.getWidth() - mHorizontalPadding, this.getHeight() / 2 + clipWidth / 2, paint); 81 | //绘制白色的矩形边框 82 | canvas.drawRect(mHorizontalPadding, this.getHeight() / 2 - clipWidth / 2, 83 | this.getWidth() - mHorizontalPadding, this.getHeight() / 2 + clipWidth / 2, borderPaint); 84 | } 85 | //出栈,恢复到之前的图层,意味着新建的图层会被删除,新建图层上的内容会被绘制到canvas (or the previous layer) 86 | canvas.restore(); 87 | } 88 | 89 | /** 90 | * 获取裁剪区域的Rect 91 | * 92 | * @return 93 | */ 94 | public Rect getClipRect() { 95 | Rect rect = new Rect(); 96 | //宽度的一半 - 圆的半径 97 | rect.left = (this.getWidth() / 2 - clipRadiusWidth); 98 | //宽度的一半 + 圆的半径 99 | rect.right = (this.getWidth() / 2 + clipRadiusWidth); 100 | //高度的一半 - 圆的半径 101 | rect.top = (this.getHeight() / 2 - clipRadiusWidth); 102 | //高度的一半 + 圆的半径 103 | rect.bottom = (this.getHeight() / 2 + clipRadiusWidth); 104 | return rect; 105 | } 106 | 107 | /** 108 | * 设置裁剪框边框宽度 109 | * 110 | * @param clipBorderWidth 111 | */ 112 | public void setClipBorderWidth(int clipBorderWidth) { 113 | this.clipBorderWidth = clipBorderWidth; 114 | borderPaint.setStrokeWidth(clipBorderWidth); 115 | invalidate(); 116 | } 117 | 118 | /** 119 | * 设置裁剪框水平间距 120 | * 121 | * @param mHorizontalPadding 122 | */ 123 | public void setmHorizontalPadding(float mHorizontalPadding) { 124 | this.mHorizontalPadding = mHorizontalPadding; 125 | this.clipRadiusWidth = (int) (getScreenWidth(getContext()) - 2 * mHorizontalPadding) / 2; 126 | this.clipWidth = clipRadiusWidth * 2; 127 | } 128 | 129 | /** 130 | * 获得屏幕高度 131 | * 132 | * @param context 133 | * @return 134 | */ 135 | public static int getScreenWidth(Context context) { 136 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 137 | DisplayMetrics outMetrics = new DisplayMetrics(); 138 | wm.getDefaultDisplay().getMetrics(outMetrics); 139 | return outMetrics.widthPixels; 140 | } 141 | 142 | 143 | /** 144 | * 设置裁剪框类别 145 | * 146 | * @param clipType 147 | */ 148 | public void setClipType(ClipType clipType) { 149 | this.clipType = clipType; 150 | } 151 | 152 | /** 153 | * 裁剪框类别,圆形、矩形 154 | */ 155 | public enum ClipType { 156 | CIRCLE, RECTANGLE 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/jakera/smartchat/Views/LoadingDialog.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat.Views; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.widget.LinearLayout; 7 | import android.widget.TextView; 8 | 9 | import com.example.jakera.smartchat.R; 10 | 11 | /** 12 | * Created by jakera on 18-2-9. 13 | */ 14 | 15 | public class LoadingDialog extends Dialog { 16 | 17 | private TextView tv; 18 | private String content; 19 | 20 | /** 21 | * style很关键 22 | */ 23 | public LoadingDialog(Context context) { 24 | super(context, R.style.loadingDialogStyle); 25 | } 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.dialog_loading); 31 | tv = (TextView) findViewById(R.id.tv_dialog_loading); 32 | // tv.setText(getContext().getString(R.string.login_now)); 33 | tv.setText(content); 34 | LinearLayout linearLayout = (LinearLayout) this.findViewById(R.id.linearLayout_loading_dialog); 35 | linearLayout.getBackground().setAlpha(210); 36 | } 37 | 38 | public void setTextContent(String content) { 39 | this.content = content; 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/res/anim/tranlate_dialog_in.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/anim/tranlate_dialog_out.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/address.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_recorder_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_recording.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_red_round_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_blue_round_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/camera.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/chatto_bg_focused.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/chatto_bg_focused.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/chinese.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/chinese.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/dialog_loading_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/dialog_loading_bg.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/edit_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/english.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/english.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_add_friends.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/icon_add_friends.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/loading.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/message.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/news.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/news.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/password.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/person.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/robot_portrait.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/robot_portrait.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/voice.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/voice_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/voice_chat.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/wyu1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/wyu1.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/wyu2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/wyu2.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/wyu3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/wyu3.jpeg -------------------------------------------------------------------------------- /app/src/main/res/drawable/wyu4.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/drawable/wyu4.jpeg -------------------------------------------------------------------------------- /app/src/main/res/layout/acitivity_modify_portrait.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_chat.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 16 | 17 | 25 | 26 | 35 | 36 | 43 | 44 | 57 | 58 | 68 | 69 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_contact_author.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 15 | 16 | 20 | 21 | 22 | 23 | 30 | 31 | 38 | 39 | 46 | 47 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_crop_portrait.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 34 | 35 | 43 | 44 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 14 | 22 | 23 | 30 | 31 | 32 | 40 | 41 | 47 | 48 | 54 | 55 | 61 | 62 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_recognizer.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 17 | 18 | 25 | 26 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/chat_left_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 13 | 29 | 30 | 42 | 43 | 54 | 55 | 56 | 57 | 58 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/chat_right_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 24 | 25 | 39 | 40 | 47 | 48 | 49 | 50 | 51 | 60 | 61 | 62 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_item_edittext.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_loading.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 16 | 24 | 25 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_recorder.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 20 | 21 | 27 | 28 | 29 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/layout/friends_list_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/friends_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/message_list_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/message_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 23 | 24 | 34 | 35 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/portrait_bottom_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 23 | 24 | 28 | 29 | 40 | 41 | 45 | 46 | 57 | 58 | 62 | 63 | 64 | 67 | 68 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/title_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 13 | 23 | 24 | 32 | 33 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/user_info_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 17 | 18 | 27 | 28 | 38 | 39 | 48 | 49 | 56 | 57 | 65 | 66 | 67 | 68 | 69 | 77 | 78 | 79 | 80 | 89 | 90 | 91 | 92 | 100 | 101 | 102 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 129 | 130 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /app/src/main/res/layout/vp_item_author.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/watch_more_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/watch_more_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/authenticatication.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/authenticatication.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/cabbage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/cabbage.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/car.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/chat_sound_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/chat_sound_left.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/chat_sound_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/chat_sound_right.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/contact.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/foreward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/foreward.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/modify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/modify.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/monkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/monkey.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/plant.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/plant.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/recorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/recorder.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/splash.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/splash.jpeg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/sunset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/sunset.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v1.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v2.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v3.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v4.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v5.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v6.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/v7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/v7.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/voice_cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/voice_cancel.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/voice_to_short.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-hdpi/voice_to_short.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values/bubbleView_attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | #000000 8 | #ffffff 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/jpush_style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 智言智语 3 | 4 | 5 | 聊聊 6 | 好友列表 7 | 看看 8 | 我的 9 | 10 | 发送 11 | 12 | 按住 说话 13 | 松开 发送 14 | 松开手指,取消发送 15 | 16 | 17 | 正在跳转 18 | 19 | 20 | 注册 21 | 登录 22 | 确定 23 | 退出登陆 24 | 25 | %s表示你同意该软件用户服务协议和隐私政策 26 | 27 | 用户名不能为空! 28 | 密码不能为空! 29 | 两次输入密码不正确,请重新输入! 30 | 注册成功! 31 | 注册失败!请检测网络是否连接! 32 | 帐号已被注册 33 | 密码输入错误 34 | 登陆失败,请检查是否正常联网 35 | 36 | 恭喜你,授权成功 37 | 38 | 联系开发者 39 | 40 | 41 | 头像 42 | 昵称 43 | 年龄 44 | 个性签名 45 | 46 | 正在登陆... 47 | 个人资料 48 | 49 | 修改头像 50 | 拍照 51 | 从手机相册中选择 52 | 保存图片 53 | 取消 54 | 55 | 获取用户信息失败 56 | 57 | 添加好友 58 | 收到好友请求 59 | 想要加你为好友 60 | 恭喜你,添加好友成功 61 | 很抱歉,对方拒绝了你的请求 62 | 63 | 接收 64 | 拒绝 65 | 66 | 恭喜你,修改成功 67 | 68 | 修改昵称 69 | 修改个性签名 70 | 71 | 我的二维码 72 | 73 | 车型识别 74 | 动物识别 75 | 植物识别 76 | 菜品识别 77 | 78 | 正在识别...... 79 | 80 | 联系作者 81 | 82 | 83 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 20 | 21 | 22 | 29 | 30 | 31 | 43 | 44 | 45 | 46 | 50 | 51 | 52 | 56 | 57 | 58 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/jakera/smartchat/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.jakera.smartchat; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.0' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | 19 | android.useDeprecatedNdk = true 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Mar 10 11:11:32 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /个人资料.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/个人资料.png -------------------------------------------------------------------------------- /主界面.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/主界面.png -------------------------------------------------------------------------------- /发送语音.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/发送语音.png -------------------------------------------------------------------------------- /启动页.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/启动页.png -------------------------------------------------------------------------------- /好友列表.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/好友列表.png -------------------------------------------------------------------------------- /我的.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/我的.png -------------------------------------------------------------------------------- /注册登陆.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/注册登陆.png -------------------------------------------------------------------------------- /看看.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/看看.png -------------------------------------------------------------------------------- /菜品识别.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakera123/SmartChat/10ac4aea212ddf5405b0a0df24cc6d1ac5d04e50/菜品识别.png --------------------------------------------------------------------------------