Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoshuai904 committed May 4, 2023
1 parent 72a8645 commit 63a095e
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 91 deletions.
13 changes: 5 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '28.0.3'
compileSdkVersion 30
buildToolsVersion '30.0.0'

defaultConfig {
applicationId "com.maple.recordwav"
minSdkVersion 19
targetSdkVersion 26
versionCode 11
targetSdkVersion 30
versionCode 12
versionName "1.0.2"
}
buildTypes {
Expand All @@ -21,11 +21,8 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'ch.acra:acra:4.9.2'
implementation 'androidx.appcompat:appcompat:1.0.0'

implementation project(':recorder')

implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
24 changes: 2 additions & 22 deletions app/src/main/java/com/maple/recordwav/WavApp.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
package com.maple.recordwav;

import android.app.Application;
import android.os.Environment;
import android.util.Log;

import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;

import java.io.File;

@ReportsCrashes(
mode = ReportingInteractionMode.DIALOG,
mailTo = "[email protected]",
resToastText = R.string.crash_toast_text,
resDialogText = R.string.crash_dialog_text,
resDialogIcon = R.drawable.ic_launcher,
resDialogTitle = R.string.crash_dialog_title,
resDialogCommentPrompt = R.string.crash_dialog_comment_prompt,
// resDialogTheme = R.style.AppTheme_Dialog,
resDialogOkToast = R.string.crash_dialog_ok_toast
)
public class WavApp extends Application {
private static WavApp app;

Expand All @@ -31,7 +15,6 @@ public void onCreate() {
app = this;
super.onCreate();

ACRA.init(this);
initPath();
}

Expand All @@ -40,11 +23,8 @@ public void onCreate() {
*/
private void initPath() {
String ROOT = "";// /storage/emulated/0
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
// ROOT = getBaseContext().getFilesDir().getPath();
ROOT = Environment.getExternalStorageDirectory().getPath();
Log.e("app", "系统方法:" + ROOT);
}
ROOT = getApplicationContext().getExternalFilesDir("").getAbsolutePath();
Log.e("app", "系统方法:" + ROOT);
rootPath = ROOT + rootPath;

File lrcFile = new File(rootPath);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/maple/recordwav/base/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/com/maple/recordwav/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@

import android.Manifest;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTabHost;

import com.maple.recordwav.R;
import com.maple.recordwav.utils.T;
import com.maple.recordwav.utils.permission.PermissionFragment;
import com.maple.recordwav.utils.permission.PermissionListener;

import butterknife.BindArray;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
* @author maple
* @time 2018/4/8.
*/
public class MainActivity extends FragmentActivity {
@BindView(R.id.tv_title) TextView mTitle;
@BindView(R.id.tabhost) FragmentTabHost mTabHost;
TextView mTitle;
FragmentTabHost mTabHost;

// Fragment界面
private Class[] fragmentArray = {RecordPage.class, PlayPage.class, ParsePage.class};
// 选项卡图片
private int[] mImageViewArray = {R.drawable.tab_record_icon, R.drawable.tab_play_icon, R.drawable.tab_parse_icon};
// 选项卡文字
@BindArray(R.array.tab_fun_array) String[] mTextViewArray;
String[] mTextViewArray;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
mTitle = findViewById(R.id.tv_title);
mTabHost = findViewById(R.id.tabhost);

mTextViewArray = getResources().getStringArray(R.array.tab_fun_array);

initView();

Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/maple/recordwav/ui/ParsePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* 获取wav文件的信息
*
* @author maple
* @time 16/5/20 下午6:40
*/
public class ParsePage extends BaseFragment {
@BindView(R.id.tv_info) TextView tv_info;
@BindView(R.id.lv_parse) ListView lv_parse;
TextView tv_info;
ListView lv_parse;

ArrayAdapter<String> adapter;
private List<String> wavFilelist;
Expand Down Expand Up @@ -61,7 +58,8 @@ public void handleMessage(android.os.Message msg) {
@Override
public View initView(LayoutInflater inflater) {
view = inflater.inflate(R.layout.fragment_parse, null);
ButterKnife.bind(this, view);
tv_info = view.findViewById(R.id.tv_info);
lv_parse = view.findViewById(R.id.lv_parse);

loadingDialog = new LoadingDialog(getActivity());
tv_info.setText("WAV 解析界面!");
Expand Down
10 changes: 4 additions & 6 deletions app/src/main/java/com/maple/recordwav/ui/PlayPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* wav 文件播放
*
Expand All @@ -37,8 +34,8 @@
public class PlayPage extends BaseFragment {
public static final int SEARCH_MESSAGE_CODE = 200;

@BindView(R.id.tv_des) TextView tv_des;
@BindView(R.id.lv_wav) ListView lv_wav;
TextView tv_des;
ListView lv_wav;

ArrayAdapter<String> adapter;
private List<String> wavFileList;
Expand All @@ -65,7 +62,8 @@ public void handleMessage(android.os.Message msg) {
@Override
public View initView(LayoutInflater inflater) {
view = inflater.inflate(R.layout.fragment_play, null);
ButterKnife.bind(this, view);
tv_des = view.findViewById(R.id.tv_des);
lv_wav = view.findViewById(R.id.lv_wav);

loadingDialog = new LoadingDialog(getActivity());
tv_des.setText("WAV 播放界面!");
Expand Down
22 changes: 12 additions & 10 deletions app/src/main/java/com/maple/recordwav/ui/RecordPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,19 @@

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
* 录制 WavRecorder 界面
*
* @author maple
* @time 16/4/18 下午2:53
*/
public class RecordPage extends BaseFragment {
@BindView(R.id.iv_voice_img) ImageView iv_voice_img;
@BindView(R.id.com_voice_time) Chronometer com_voice_time;
@BindView(R.id.bt_start) Button bt_start;
@BindView(R.id.bt_stop) Button bt_stop;
@BindView(R.id.bt_pause_resume) Button bt_pause_resume;
@BindView(R.id.skipSilence) CheckBox skipSilence;
ImageView iv_voice_img;
Chronometer com_voice_time;
Button bt_start;
Button bt_stop;
Button bt_pause_resume;
CheckBox skipSilence;

Recorder recorder;
boolean isRecording = false;
Expand All @@ -49,7 +46,12 @@ public class RecordPage extends BaseFragment {
@Override
public View initView(LayoutInflater inflater) {
view = inflater.inflate(R.layout.fragment_record, null);
ButterKnife.bind(this, view);
iv_voice_img = view.findViewById(R.id.iv_voice_img);
com_voice_time = view.findViewById(R.id.com_voice_time);
bt_start = view.findViewById(R.id.bt_start);
bt_stop = view.findViewById(R.id.bt_stop);
bt_pause_resume = view.findViewById(R.id.bt_pause_resume);
skipSilence = view.findViewById(R.id.skipSilence);

return view;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import com.maple.recordwav.R;

import junit.framework.Assert;

/**
* loading dialog
Expand All @@ -32,7 +31,7 @@ public LoadingDialog(Context context, boolean isShowAsFloatWindow) {
super(context, R.style.CustomDialog);

if (!isShowAsFloatWindow) {
Assert.assertTrue("context must be Activity in Dialog.", context instanceof Activity);
// Assert.assertTrue("context must be Activity in Dialog.", context instanceof Activity);
} else {
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AlertDialog;
import android.text.TextUtils;

import java.util.ArrayList;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
android:layout_weight="1"
android:background="@color/mainBGColor" />

<android.support.v4.app.FragmentTabHost
<androidx.fragment.app.FragmentTabHost
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
Expand All @@ -30,6 +30,6 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
</android.support.v4.app.FragmentTabHost>
</androidx.fragment.app.FragmentTabHost>
</LinearLayout>

8 changes: 0 additions & 8 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,4 @@
<string name="preview">播放</string>


<string name="crash_toast_text">Ooooops ! I crashed, but a report has been sent to my developer to help fix the issue !</string>
<string name="crash_dialog_title">CrashTest has crashed</string>
<string name="crash_dialog_text">An unexpected error occurred forcing the
application to stop. Please help us fix this by sending us error data,
all you have to do is click OK.</string>
<string name="crash_dialog_comment_prompt">You might add your comments about the problem below:</string>
<string name="crash_dialog_ok_toast">Thank you !</string>

</resources>
10 changes: 3 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:4.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -19,8 +15,8 @@ buildscript {

allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}

Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
6 changes: 3 additions & 3 deletions recorder/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 26
compileSdkVersion 30

defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 5
targetSdkVersion 30
versionCode 6
versionName "1.0.2"

}
Expand Down

0 comments on commit 63a095e

Please sign in to comment.