├── .idea
├── .name
├── vcs.xml
├── runConfigurations.xml
├── gradle.xml
├── jarRepositories.xml
├── misc.xml
└── codeStyles
│ └── Project.xml
├── app
├── .gitignore
├── release
│ ├── app-release.apk
│ └── output.json
├── src
│ └── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── drawable-hdpi
│ │ │ └── ic_action_name.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_action_name.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_action_name.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_action_name.png
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ ├── ic_launcher_background.xml
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ ├── arrays.xml
│ │ │ └── styles.xml
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── animator
│ │ │ ├── animator_rotation_pause_to_play.xml
│ │ │ ├── animator_rotation_play_to_pause.xml
│ │ │ ├── animator_pause_to_play.xml
│ │ │ └── animator_play_to_pause.xml
│ │ ├── drawable-anydpi
│ │ │ └── ic_action_name.xml
│ │ ├── drawable
│ │ │ ├── animated_vector_pause_to_play.xml
│ │ │ ├── animated_vector_play_to_pause.xml
│ │ │ ├── play.xml
│ │ │ ├── pause.xml
│ │ │ ├── animated_selector_play_and_pause.xml
│ │ │ ├── ic_launcher_foreground.xml
│ │ │ └── ic_launcher_background.xml
│ │ └── layout
│ │ │ ├── activity_scrolling.xml
│ │ │ └── content_scrolling.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── oboard
│ │ └── backear
│ │ ├── PlayButton.java
│ │ └── ScrollingActivity.java
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── publish.keystore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── .gitignore
├── .github
└── workflows
│ └── android.yml
├── gradle.properties
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | 耳机返听
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name='耳机返听'
3 |
--------------------------------------------------------------------------------
/publish.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/publish.keystore
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/drawable-hdpi/ic_action_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/drawable-mdpi/ic_action_name.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/drawable-xhdpi/ic_action_name.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/drawable-xxhdpi/ic_action_name.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oboard/backear/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 180dp
3 | 16dp
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF5722
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 不管你是学习外语口语练习、还是读书朗诵练习,耳机里面都可以实时听见自己的声音。受限于Android系统音频通道延迟缺陷,有一些延迟。
2 |
3 | 
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":2,"versionName":"1.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jan 04 11:53:41 CST 2020
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-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 | #FF424242
7 |
8 |
--------------------------------------------------------------------------------
/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/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 耳机返听
3 |
4 | "\n\n不管你是学习外语口语练习、还是读书朗诵练习,耳机里面都可以实时听见自己的声音。\n\n"
5 | "受限于Android系统音频通道延迟缺陷,大约有10ms的延迟\n\n"
6 | "@一块小板子\n\n"
7 |
8 | Settings
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/animator_rotation_pause_to_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/animator_rotation_play_to_pause.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-anydpi/ic_action_name.xml:
--------------------------------------------------------------------------------
1 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/animated_vector_pause_to_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/animated_vector_play_to_pause.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/animator_pause_to_play.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/animator_play_to_pause.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 | pull_request:
7 | branches: [ "master" ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v3
16 | - name: set up JDK 11
17 | uses: actions/setup-java@v3
18 | with:
19 | java-version: '11'
20 | distribution: 'temurin'
21 | cache: gradle
22 |
23 | - name: Grant execute permission for gradlew
24 | run: chmod +x gradlew
25 | - name: Build with Gradle
26 | run: ./gradlew build
27 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pause.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.0"
6 | defaultConfig {
7 | applicationId "oboard.backear"
8 | minSdkVersion 21
9 | targetSdkVersion 29
10 | versionCode 3
11 | versionName "1.2"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled true
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'androidx.appcompat:appcompat:1.1.0'
24 | testImplementation 'junit:junit:4.12'
25 | implementation 'com.google.android.material:material:1.0.0'
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/animated_selector_play_and_pause.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
13 |
17 |
18 |
22 |
--------------------------------------------------------------------------------
/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/main/res/values/arrays.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 | - 未经处理的信号
26 | - 回声消除
27 |
28 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
6 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
17 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_scrolling.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
44 |
45 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/oboard/backear/PlayButton.java:
--------------------------------------------------------------------------------
1 | package oboard.backear;
2 |
3 |
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 |
9 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
10 |
11 |
12 | /**
13 | * Created by will on 2018/8/4.
14 | */
15 |
16 | @SuppressLint("AppCompatCustomView")
17 | public class PlayButton extends FloatingActionButton {
18 |
19 | //当前播放状态 true正在播放 false暂停播放
20 | private boolean isPlay = false;
21 |
22 | //提供给使用者的点击监听
23 | private OnPlayOrPauseClick onPlayOrPauseClick;
24 |
25 | public PlayButton(Context context) {
26 | super(context);
27 | }
28 |
29 | public PlayButton(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | initView();
32 | }
33 |
34 | public PlayButton(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | }
37 |
38 | private void initView() {
39 | setScaleType(ScaleType.FIT_CENTER);
40 | //初始化图像,将选择器配置进去
41 | setImageResource(R.drawable.animated_selector_play_and_pause);
42 | //设置点击事件
43 | setOnClickListener(new OnClickListener() {
44 | @Override
45 | public void onClick(View v) {
46 |
47 | changeState();
48 |
49 | }
50 | });
51 | }
52 |
53 | //根据当前状态进行切换
54 | public void changeState() {
55 | if (!isFastClick()) {
56 | isPlay = !isPlay;
57 | final int[] state = {android.R.attr.state_checked * (isPlay ? 1 : -1)};
58 | setImageState(state, true);
59 | if (null != onPlayOrPauseClick) {
60 | onPlayOrPauseClick.onClick(!isPlay);
61 | }
62 | }
63 | }
64 |
65 | //播放
66 | public void toPlay() {
67 | if (isPlay) {
68 | return;
69 | } else {
70 | changeState();
71 | }
72 | }
73 |
74 | //暂停
75 | public void toPause() {
76 | if (!isPlay) {
77 | return;
78 | } else {
79 | changeState();
80 | }
81 | }
82 |
83 | private long lastClickTime;
84 |
85 | //防止快速点击
86 | public boolean isFastClick() {
87 | boolean flag = true;
88 | long currentClickTime = System.currentTimeMillis();
89 | if ((currentClickTime - lastClickTime) >= 500) {
90 | flag = false;
91 | }
92 | lastClickTime = currentClickTime;
93 | return false;//flag;
94 | }
95 |
96 | //获取当前播放状态
97 | public boolean isPlay() {
98 | return isPlay;
99 | }
100 |
101 |
102 | public void setOnPlayOrPauseClick(OnPlayOrPauseClick onPlayOrPauseClick) {
103 | this.onPlayOrPauseClick = onPlayOrPauseClick;
104 | }
105 |
106 | public interface OnPlayOrPauseClick {
107 | void onClick(boolean isPlay);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_scrolling.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
18 |
22 |
27 |
28 |
32 |
37 |
38 |
42 |
47 |
48 |
52 |
53 |
57 |
58 |
64 |
65 |
66 |
67 |
74 |
75 |
79 |
80 |
84 |
85 |
91 |
92 |
93 |
94 |
101 |
102 |
103 |
104 |
108 |
109 |
113 |
114 |
120 |
121 |
122 |
123 |
130 |
131 |
135 |
136 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/oboard/backear/ScrollingActivity.java:
--------------------------------------------------------------------------------
1 | package oboard.backear;
2 |
3 | import android.Manifest;
4 | import android.annotation.SuppressLint;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.pm.PackageManager;
8 | import android.content.res.Configuration;
9 | import android.media.AudioFormat;
10 | import android.media.AudioManager;
11 | import android.media.AudioRecord;
12 | import android.media.AudioTrack;
13 | import android.net.Uri;
14 | import android.os.Build;
15 | import android.os.Bundle;
16 | import android.view.View;
17 | import android.widget.AdapterView;
18 | import android.widget.SeekBar;
19 | import android.widget.Spinner;
20 | import android.widget.TextView;
21 |
22 | import androidx.annotation.NonNull;
23 | import androidx.appcompat.app.AppCompatActivity;
24 | import androidx.appcompat.widget.Toolbar;
25 | import androidx.core.app.ActivityCompat;
26 | import androidx.core.content.ContextCompat;
27 |
28 | import java.io.UnsupportedEncodingException;
29 | import java.net.URLEncoder;
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | public class ScrollingActivity extends AppCompatActivity implements Runnable {
34 | int frequency = 44100;
35 | int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
36 | int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
37 | int recBufSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
38 | int plyBufSize = AudioTrack.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
39 | AudioRecord audioRecord;
40 | AudioTrack audioTrack;
41 | Thread thread = null;
42 | float increase = 1;
43 | int increaseLate = 0;
44 | float stereoVolume = 0;
45 | int inputSource = 1;
46 | AudioManager audioManager;
47 | List recBufL = new ArrayList();
48 | List recBufT = new ArrayList();
49 | // private Handler handler = new Handler() {
50 | // @Override
51 | // public void handleMessage(Message msg) {
52 | // super.handleMessage(msg);
53 | // //if (msg != null)
54 | // //voiceLineView.setVolume(msg.what);//主线程更新分贝大小
55 | // }
56 | // };
57 | private boolean isAlive = true;
58 |
59 | public static void checkPermission(AppCompatActivity activity) {
60 | int checkPermission = ContextCompat.checkSelfPermission(activity, Manifest.permission.RECORD_AUDIO);
61 | if (checkPermission != PackageManager.PERMISSION_GRANTED) {
62 | ActivityCompat.requestPermissions(activity, new String[]{
63 | Manifest.permission.RECORD_AUDIO}, 123);
64 | }
65 | }
66 |
67 | // //需要录音权限
68 | //
69 | // @Override
70 | //
71 | // protected void onCreate(Bundle savedInstanceState) {
72 | // super.onCreate(savedInstanceState);
73 | // setContentView(R.layout.activity_main);
74 | // voiceLineView = findViewById(R.id.voicLine);
75 | // start = findViewById(R.id.start);
76 | // checkPermission(this);
77 | // start.setOnClickListener(new View.OnClickListener() {
78 | // @Override
79 | // public void onClick(View v) {
80 | // if (thread == null) {
81 | //
82 | // thread = new Thread(MainActivity.this);//启动线程
83 | // isAlive = true;
84 | // thread.start();
85 | // start.setText("停止");
86 | // } else {
87 | // isAlive = false;//关闭线程
88 | // thread = null;
89 | // start.setText("开始");
90 | // }
91 | // }
92 | // });
93 | // }
94 |
95 | //检查当前系统是否已开启暗黑模式
96 | public static boolean getDarkModeStatus(Context context) {
97 | int mode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
98 | return mode == Configuration.UI_MODE_NIGHT_YES;
99 | }
100 |
101 | @Override
102 | public void run() {
103 |
104 | //录音对象
105 | audioRecord = new AudioRecord(inputSource, frequency, channelConfiguration, audioEncoding, recBufSize);
106 | //setOutSpeak();
107 | //声音播放对象
108 | audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, frequency, channelConfiguration, audioEncoding, plyBufSize, AudioTrack.MODE_STREAM);
109 | audioRecord.startRecording();
110 | byte[] recBuf = new byte[recBufSize];
111 | recBufL.clear();
112 | recBufT.clear();
113 | //延迟增强
114 | long startT = System.currentTimeMillis();
115 | audioTrack.play();
116 | while (isAlive) {
117 |
118 | final int readLen = audioRecord.read(recBuf, 0, recBufSize);//获取录音缓存值
119 | for (int i = 0; i < recBuf.length; i++) recBuf[i] *= increase;
120 | recBufL.add(recBuf.clone());
121 | recBufT.add(System.currentTimeMillis() + increaseLate * 1000);
122 | // if (System.currentTimeMillis() - increaseLate * 1000 > startT) {
123 | if (!recBufL.isEmpty()) {
124 | if (System.currentTimeMillis() > recBufT.get(0)) {
125 | recBufL.remove(0);
126 | recBufT.remove(0);
127 | byte[] re = recBufL.get(0).clone();
128 | audioTrack.write(re, 0, re.length);//将获取到录音数据向声音播放对象写入
129 | // }
130 | }
131 | }
132 | //计算声音分贝大小
133 | //long v = 0;
134 | // 将 buffer 内容取出,进行平方和运算
135 | //for (byte b : recBuf) {
136 | // v += b * b;
137 | //}
138 | // 平方和除以数据总长度,得到音量大小。
139 | //double mean = v / (double) readLen;
140 | //double volume = 10 * Math.log10(mean);
141 | //Message msg = handler.obtainMessage();
142 | //msg.what = (int) volume;
143 | //handler.sendMessage(msg);//发送到主线程更新分贝显示
144 | }
145 | audioTrack.stop();//停止播放
146 | audioRecord.stop();//停止录音
147 |
148 | }
149 |
150 | @Override
151 | protected void onDestroy() {
152 | isAlive = false;//退出时停止麦克风功能
153 | thread = null;
154 | super.onDestroy();
155 | }
156 |
157 | @Override
158 | protected void onCreate(Bundle savedInstanceState) {
159 | if (getDarkModeStatus(this)) {
160 | setTheme(R.style.AppThemeDark);
161 | } else {
162 | setTheme(R.style.AppTheme);
163 | }
164 |
165 | super.onCreate(savedInstanceState);
166 | setContentView(R.layout.activity_scrolling);
167 | checkPermission(this);
168 | Toolbar toolbar = findViewById(R.id.toolbar);
169 | setSupportActionBar(toolbar);
170 | if (getDarkModeStatus(this)) {
171 | toolbar.setPopupTheme(R.style.AppThemeDark_PopupOverlay);
172 | } else {
173 | toolbar.setPopupTheme(R.style.AppTheme_PopupOverlay);
174 | }
175 |
176 | final PlayButton fab = (PlayButton) findViewById(R.id.fab);
177 | fab.setOnPlayOrPauseClick(new PlayButton.OnPlayOrPauseClick() {
178 | @Override
179 | public void onClick(boolean isPlay) {
180 | if (thread == null) {
181 | thread = new Thread(ScrollingActivity.this);//启动线程
182 | isAlive = true;
183 | thread.start();
184 | } else {
185 | isAlive = false;//关闭线程
186 | thread = null;
187 | }
188 | }
189 | });
190 |
191 | Spinner spinner = (Spinner) findViewById(R.id.spinner1);
192 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
193 | @Override
194 | public void onItemSelected(AdapterView> adapterView, View view, int pos, long id) {
195 | //String[] channels = getResources().getStringArray(R.array.channels);
196 | channelConfiguration = pos + 2;
197 | fab.toPause();
198 | }
199 |
200 | @Override
201 | public void onNothingSelected(AdapterView> parent) {
202 | // Another interface callback
203 | }
204 | });
205 |
206 | Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
207 | spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
208 | @Override
209 | public void onItemSelected(AdapterView> adapterView, View view, int pos, long id) {
210 | //String[] channels = getResources().getStringArray(R.array.channels);
211 | inputSource = pos;
212 | fab.toPause();
213 | }
214 |
215 | @Override
216 | public void onNothingSelected(AdapterView> parent) {
217 | // Another interface callback
218 | }
219 | });
220 | audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
221 |
222 | Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
223 | spinner3.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
224 | @Override
225 | public void onItemSelected(AdapterView> adapterView, View view, int pos, long id) {
226 | //String[] channels = getResources().getStringArray(R.array.channels);
227 | switch (pos) {
228 | //切换到外放
229 | //注意此处,蓝牙未断开时使用MODE_IN_COMMUNICATION而不是MODE_NORMAL
230 | case 0:
231 | audioManager.setMode(audioManager.isBluetoothScoOn() ? AudioManager.MODE_IN_COMMUNICATION : AudioManager.MODE_NORMAL);
232 | audioManager.stopBluetoothSco();
233 | audioManager.setBluetoothScoOn(false);
234 | audioManager.setSpeakerphoneOn(true);
235 | break;
236 | /*
237 | 切换到蓝牙音箱*/
238 | case 1:
239 | audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
240 | audioManager.startBluetoothSco();
241 | audioManager.setBluetoothScoOn(true);
242 | audioManager.setSpeakerphoneOn(false);
243 | break;
244 | //注意:以下两个方法还未验证
245 | case 2:
246 | audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
247 | audioManager.stopBluetoothSco();
248 | audioManager.setBluetoothScoOn(false);
249 | audioManager.setSpeakerphoneOn(false);
250 | break;
251 | /*
252 | 切换到听筒
253 | */
254 | case 3:
255 | audioManager.setSpeakerphoneOn(false);
256 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
257 | audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
258 | } else {
259 | audioManager.setMode(AudioManager.MODE_IN_CALL);
260 | }
261 | break;
262 | }
263 | fab.toPause();
264 | }
265 |
266 | @Override
267 | public void onNothingSelected(AdapterView> parent) {
268 | // Another interface callback
269 | }
270 | });
271 |
272 | SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
273 | final TextView textView = (TextView) findViewById(R.id.textView);
274 | seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
275 | @SuppressLint("SetTextI18n")
276 | @Override
277 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
278 | textView.setText(" " + i + "x");
279 | increase = i;
280 | }
281 |
282 | @Override
283 | public void onStartTrackingTouch(SeekBar seekBar) {
284 |
285 | }
286 |
287 | @Override
288 | public void onStopTrackingTouch(SeekBar seekBar) {
289 |
290 | }
291 | });
292 | SeekBar seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
293 | final TextView textView2 = (TextView) findViewById(R.id.textView2);
294 | seekBar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
295 | @Override
296 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
297 | textView2.setText(String.valueOf(Float.parseFloat(String.valueOf(i - 5)) / 5));
298 | stereoVolume = Float.valueOf(String.valueOf(Integer.valueOf(i).toString())) / 10;
299 | if (audioTrack != null)
300 | audioTrack.setStereoVolume(1 - stereoVolume, stereoVolume);
301 | }
302 |
303 | @Override
304 | public void onStartTrackingTouch(SeekBar seekBar) {
305 |
306 | }
307 |
308 | @Override
309 | public void onStopTrackingTouch(SeekBar seekBar) {
310 |
311 | }
312 | });
313 | SeekBar seekBar3 = (SeekBar) findViewById(R.id.seekBar3);
314 | final TextView textView3 = (TextView) findViewById(R.id.textView3);
315 | seekBar3.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
316 | @SuppressLint("SetTextI18n")
317 | @Override
318 | public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
319 | textView3.setText(" " + i + "秒");
320 | increaseLate = i;
321 | }
322 |
323 | @Override
324 | public void onStartTrackingTouch(SeekBar seekBar) {
325 |
326 | }
327 |
328 | @Override
329 | public void onStopTrackingTouch(SeekBar seekBar) {
330 |
331 | }
332 | });
333 | /*
334 | fab.setOnClickListener(new View.OnClickListener() {
335 | @Override
336 | public void onClick(View view) {
337 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
338 | .setAction("Action", null).show();
339 | }
340 | });*/
341 | }
342 |
343 |
344 | @Override
345 | public void onConfigurationChanged(@NonNull Configuration newConfig) {
346 | super.onConfigurationChanged(newConfig);
347 | }
348 |
349 | public void juanzeng(View view) {
350 | Intent intent = new Intent(Intent.ACTION_VIEW);
351 | String str = "";
352 | try {
353 | str = "alipays://platformapi/startapp?saId=10000007&qrcode=" + URLEncoder.encode("https://qr.alipay.com/tsx00700h1zpzwoodysyhda", "UTF-8");
354 | } catch (UnsupportedEncodingException e) {
355 | e.printStackTrace();
356 | }
357 | //str是支付宝或微信链接,直接在微信里面点击链接,也可调起
358 |
359 | Uri uri = Uri.parse(str);
360 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
361 | intent.setData(uri);
362 | startActivity(intent);
363 | }
364 |
365 | }
366 |
--------------------------------------------------------------------------------