diff --git a/MyApplication_f/.gitignore b/MyApplication_f/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/MyApplication_f/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/MyApplication_f/.idea/.gitignore b/MyApplication_f/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/MyApplication_f/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/MyApplication_f/.idea/.name b/MyApplication_f/.idea/.name new file mode 100644 index 0000000..b3405b3 --- /dev/null +++ b/MyApplication_f/.idea/.name @@ -0,0 +1 @@ +My Application \ No newline at end of file diff --git a/MyApplication_f/.idea/compiler.xml b/MyApplication_f/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/MyApplication_f/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MyApplication_f/.idea/gradle.xml b/MyApplication_f/.idea/gradle.xml new file mode 100644 index 0000000..fdb4743 --- /dev/null +++ b/MyApplication_f/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/.idea/misc.xml b/MyApplication_f/.idea/misc.xml new file mode 100644 index 0000000..bdd9278 --- /dev/null +++ b/MyApplication_f/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/11.puml b/MyApplication_f/11.puml new file mode 100644 index 0000000..4f1f9f8 --- /dev/null +++ b/MyApplication_f/11.puml @@ -0,0 +1,11 @@ +@startuml +class com.example.music.SongsFragment { +~ RecyclerView recyclerView +~ MusicAdapter musicAdapter ++ <> SongsFragment() ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} + + +androidx.fragment.app.Fragment <|-- com.example.music.SongsFragment +@enduml \ No newline at end of file diff --git a/MyApplication_f/111.puml b/MyApplication_f/111.puml new file mode 100644 index 0000000..2709e92 --- /dev/null +++ b/MyApplication_f/111.puml @@ -0,0 +1,10 @@ +@startuml +class com.example.music.AlbumsFragment { +~ RecyclerView recyclerView +~ AlbumAdapter albumAdapter ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} + + +androidx.fragment.app.Fragment <|-- com.example.music.AlbumsFragment +@enduml \ No newline at end of file diff --git a/MyApplication_f/2.puml b/MyApplication_f/2.puml new file mode 100644 index 0000000..605afe8 --- /dev/null +++ b/MyApplication_f/2.puml @@ -0,0 +1,10 @@ +@startuml +class com.example.music.SongsFragment { +~ RecyclerView recyclerView +~ MusicAdapter musicAdapter ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} + + +androidx.fragment.app.Fragment <|-- com.example.music.SongsFragment +@enduml \ No newline at end of file diff --git a/MyApplication_f/build.gradle b/MyApplication_f/build.gradle new file mode 100644 index 0000000..0114b27 --- /dev/null +++ b/MyApplication_f/build.gradle @@ -0,0 +1,5 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id 'com.android.application' version '7.4.1' apply false + id 'com.android.library' version '7.4.1' apply false +} \ No newline at end of file diff --git a/MyApplication_f/eee.puml b/MyApplication_f/eee.puml new file mode 100644 index 0000000..98a86c9 --- /dev/null +++ b/MyApplication_f/eee.puml @@ -0,0 +1,47 @@ +@startuml +class com.example.music.MusicAdapter { +- Context mContext +- ArrayList mFiles +~ <> MusicAdapter(Context,ArrayList) ++ MyVieHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyVieHolder,int) +- void deleteFlie(int,View) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.MusicAdapter$MyVieHolder { +~ TextView file_name +~ ImageView album_art ++ <> MyVieHolder(View) +} +class com.example.music.AlbumAdapter { +- Context mContext +- ArrayList albumFiles +~ View view ++ <> AlbumAdapter(Context,ArrayList) ++ MyHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyHolder,int) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.AlbumAdapter$MyHolder { +~ ImageView album_image +~ TextView album_name ++ <> MyHolder(View) +} +class com.example.music.PagerAdapter { +- int tabsNumber ++ <> PagerAdapter(FragmentManager,int,int) ++ Fragment getItem(int) ++ int getCount() +} + + +com.example.music.Adapter <|-- com.example.music.MusicAdapter +com.example.music.MusicAdapter +.. com.example.music.MusicAdapter$MyVieHolder +com.example.music.ViewHolder <|-- com.example.music.MusicAdapter$MyVieHolder +com.example.music.Adapter <|-- com.example.music.AlbumAdapter +com.example.music.AlbumAdapter +.. com.example.music.AlbumAdapter$MyHolder +com.example.music.ViewHolder <|-- com.example.music.AlbumAdapter$MyHolder +androidx.fragment.app.FragmentPagerAdapter <|-- com.example.music.PagerAdapter +@enduml \ No newline at end of file diff --git a/MyApplication_f/gradle.properties b/MyApplication_f/gradle.properties new file mode 100644 index 0000000..57fae1d --- /dev/null +++ b/MyApplication_f/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# 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 +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true +android.enableJetifier=true +org.gradle.unsafe.configuration-cache=true \ No newline at end of file diff --git a/MyApplication_f/gradle/wrapper/gradle-wrapper.jar b/MyApplication_f/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/MyApplication_f/gradle/wrapper/gradle-wrapper.jar differ diff --git a/MyApplication_f/gradle/wrapper/gradle-wrapper.properties b/MyApplication_f/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..83bc56c --- /dev/null +++ b/MyApplication_f/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Mar 13 18:03:20 CST 2023 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/MyApplication_f/gradlew b/MyApplication_f/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/MyApplication_f/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/MyApplication_f/gradlew.bat b/MyApplication_f/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/MyApplication_f/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/MyApplication_f/l.puml b/MyApplication_f/l.puml new file mode 100644 index 0000000..36a73de --- /dev/null +++ b/MyApplication_f/l.puml @@ -0,0 +1,20 @@ +@startuml +class com.example.music.AlbumAdapter { +- Context mContext +- ArrayList albumFiles +~ View view ++ MyHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyHolder,int) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.AlbumAdapter$MyHolder { +~ ImageView album_image +~ TextView album_name +} + + +com.example.music.Adapter <|-- com.example.music.AlbumAdapter +com.example.music.AlbumAdapter +.. com.example.music.AlbumAdapter$MyHolder +com.example.music.ViewHolder <|-- com.example.music.AlbumAdapter$MyHolder +@enduml \ No newline at end of file diff --git a/MyApplication_f/lei.puml b/MyApplication_f/lei.puml new file mode 100644 index 0000000..5172508 --- /dev/null +++ b/MyApplication_f/lei.puml @@ -0,0 +1,24 @@ +@startuml +class com.example.music.MainActivity { +~ DrawerLayout drawerLayout +~ ActionBarDrawerToggle toggle +~ NavigationView navigationView +~ ViewPager pager +~ TabLayout mTabLayout +~ TabItem songs +~ PagerAdapter pagerAdapter ++ {static} int REQUEST_CODE +~ {static} ArrayList musicFiles +~ {static} boolean shuffleBoolean +# void onCreate(Bundle) +- void initViewPager() +- void permission() ++ void onRequestPermissionsResult(int,String[],int[]) ++ boolean onNavigationItemSelected(MenuItem) ++ {static} ArrayList getAllAudio(Context) +} + + +com.example.music.OnNavigationItemSelectedListener <|.. com.example.music.MainActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.MainActivity +@enduml \ No newline at end of file diff --git a/MyApplication_f/lei1.puml b/MyApplication_f/lei1.puml new file mode 100644 index 0000000..36a73de --- /dev/null +++ b/MyApplication_f/lei1.puml @@ -0,0 +1,20 @@ +@startuml +class com.example.music.AlbumAdapter { +- Context mContext +- ArrayList albumFiles +~ View view ++ MyHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyHolder,int) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.AlbumAdapter$MyHolder { +~ ImageView album_image +~ TextView album_name +} + + +com.example.music.Adapter <|-- com.example.music.AlbumAdapter +com.example.music.AlbumAdapter +.. com.example.music.AlbumAdapter$MyHolder +com.example.music.ViewHolder <|-- com.example.music.AlbumAdapter$MyHolder +@enduml \ No newline at end of file diff --git a/MyApplication_f/leitu.puml b/MyApplication_f/leitu.puml new file mode 100644 index 0000000..c198f8f --- /dev/null +++ b/MyApplication_f/leitu.puml @@ -0,0 +1,159 @@ +@startuml +class com.example.music.Adapter.MusicAdapter { +- Context mContext +- ArrayList mFiles ++ MyVieHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyVieHolder,int) +- void deleteFlie(int,View) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.Adapter.MusicAdapter$MyVieHolder { +~ TextView file_name +~ ImageView album_art +} +class com.example.music.Activity.PlayerActivity { +~ TextView song_name +~ ImageView cover_art +~ FloatingActionButton playPauseBtn +~ SeekBar seekBar +~ int position +~ {static} ArrayList listSongs +~ {static} Uri uri +~ {static} MediaPlayer mediaPlayer +- Handler handler +- Thread playThread +# void onCreate(Bundle) +# void onResume() +- void prevThreadBtn() +- void prevBtnClicked() +- void nextThreadBtn() +- void nextBtnClicked() +- int getRandom(int) +- void playThreadBtn() +- void playPauseBtnClicked() +- String formattedTime(int) +- void getIntentMethod() +- void initView() +- void metaData(Uri) ++ void ImageAnimation(Context,ImageView,Bitmap) ++ void onCompletion(MediaPlayer) +} +class com.example.music.databases.DaBa { +- {static} int VERSION +- {static} String DBNAME +- Context mContext ++ void onCreate(SQLiteDatabase) ++ void onUpgrade(SQLiteDatabase,int,int) +} +class com.example.music.Activity.RegisterActivity { +~ Button button_submit +~ DaBa daBa +~ EditText index_username +~ EditText index_password +~ SQLiteDatabase sqLiteDatabase +# void onCreate(Bundle) +} +class com.example.music.Adapter.AlbumAdapter { +- Context mContext +- ArrayList albumFiles +~ View view ++ MyHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyHolder,int) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.Adapter.AlbumAdapter$MyHolder { +~ ImageView album_image +~ TextView album_name +} +class com.example.music.Fragment.AlbumsFragment { +~ RecyclerView recyclerView +~ AlbumAdapter albumAdapter ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} +class com.example.music.Activity.LoginActivity { +~ EditText usernameInput +~ EditText passwordInput +~ Button button_login +~ Button button_index +~ Context that +- CheckBox RePassword +- CheckBox AutoLogin +- String Tag +- String SP_Name +- String SP_Password +- String SP_IsRemember +- SharedPreferences sharedPreferences +- boolean status +# void onCreate(Bundle) +- void initData() +- void initUI() +} +class com.example.music.MusicFiles { +- String path +- String title +- String artist +- String album +- String duration +- String id ++ String getPath() ++ void setPath(String) ++ String getTitle() ++ void setTitle(String) ++ String getArtist() ++ void setArtist(String) ++ String getAlbum() ++ void setAlbum(String) ++ String getDuration() ++ void setDuration(String) ++ String getId() ++ void setId(String) +} +class com.example.music.Adapter.PagerAdapter { +- int tabsNumber ++ Fragment getItem(int) ++ int getCount() +} +class com.example.music.Activity.MainActivity { +~ DrawerLayout drawerLayout +~ ActionBarDrawerToggle toggle +~ NavigationView navigationView +~ ViewPager pager +~ TabLayout mTabLayout +~ TabItem songs +~ PagerAdapter pagerAdapter ++ {static} int REQUEST_CODE +~ {static} ArrayList musicFiles +~ {static} boolean shuffleBoolean +# void onCreate(Bundle) +- void initViewPager() +- void permission() ++ void onRequestPermissionsResult(int,String[],int[]) ++ boolean onNavigationItemSelected(MenuItem) ++ {static} ArrayList getAllAudio(Context) +} +class com.example.music.Fragment.SongsFragment { +~ RecyclerView recyclerView +~ MusicAdapter musicAdapter ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} + + +com.example.music.Adapter.Adapter <|-- com.example.music.Adapter.MusicAdapter +com.example.music.Adapter.MusicAdapter +.. com.example.music.Adapter.MusicAdapter$MyVieHolder +com.example.music.Adapter.ViewHolder <|-- com.example.music.Adapter.MusicAdapter$MyVieHolder +com.example.music.Activity.OnCompletionListener <|.. com.example.music.Activity.PlayerActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.Activity.PlayerActivity +android.database.sqlite.SQLiteOpenHelper <|-- com.example.music.databases.DaBa +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.Activity.RegisterActivity +com.example.music.Adapter.Adapter <|-- com.example.music.Adapter.AlbumAdapter +com.example.music.Adapter.AlbumAdapter +.. com.example.music.Adapter.AlbumAdapter$MyHolder +com.example.music.Adapter.ViewHolder <|-- com.example.music.Adapter.AlbumAdapter$MyHolder +androidx.fragment.app.Fragment <|-- com.example.music.Fragment.AlbumsFragment +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.Activity.LoginActivity +androidx.fragment.app.FragmentPagerAdapter <|-- com.example.music.Adapter.PagerAdapter +com.example.music.Activity.OnNavigationItemSelectedListener <|.. com.example.music.Activity.MainActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.Activity.MainActivity +androidx.fragment.app.Fragment <|-- com.example.music.Fragment.SongsFragment +@enduml \ No newline at end of file diff --git a/MyApplication_f/q.puml b/MyApplication_f/q.puml new file mode 100644 index 0000000..308342f --- /dev/null +++ b/MyApplication_f/q.puml @@ -0,0 +1,13 @@ +@startuml +class com.example.music.databases.DaBa { +- {static} int VERSION +- {static} String DBNAME +- Context mContext ++ <> DaBa(Context) ++ void onCreate(SQLiteDatabase) ++ void onUpgrade(SQLiteDatabase,int,int) +} + + +android.database.sqlite.SQLiteOpenHelper <|-- com.example.music.databases.DaBa +@enduml \ No newline at end of file diff --git a/MyApplication_f/qq.puml b/MyApplication_f/qq.puml new file mode 100644 index 0000000..d6befff --- /dev/null +++ b/MyApplication_f/qq.puml @@ -0,0 +1,17 @@ +@startuml +class com.example.music.AlbumsFragment { +~ RecyclerView recyclerView +~ AlbumAdapter albumAdapter ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} +class com.example.music.SongsFragment { +~ RecyclerView recyclerView +~ MusicAdapter musicAdapter ++ <> SongsFragment() ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} + + +androidx.fragment.app.Fragment <|-- com.example.music.AlbumsFragment +androidx.fragment.app.Fragment <|-- com.example.music.SongsFragment +@enduml \ No newline at end of file diff --git a/MyApplication_f/qqq.puml b/MyApplication_f/qqq.puml new file mode 100644 index 0000000..931087b --- /dev/null +++ b/MyApplication_f/qqq.puml @@ -0,0 +1,81 @@ +@startuml +class com.example.music.PlayerActivity { +~ TextView song_name +~ ImageView cover_art +~ FloatingActionButton playPauseBtn +~ SeekBar seekBar +~ int position +~ {static} ArrayList listSongs +~ {static} Uri uri +~ {static} MediaPlayer mediaPlayer +- Handler handler +- Thread playThread +# void onCreate(Bundle) +# void onResume() +- void prevThreadBtn() +- void prevBtnClicked() +- void nextThreadBtn() +- void nextBtnClicked() +- int getRandom(int) +- void playThreadBtn() +- void playPauseBtnClicked() +- String formattedTime(int) +- void getIntentMethod() +- void initView() +- void metaData(Uri) ++ void ImageAnimation(Context,ImageView,Bitmap) ++ void onCompletion(MediaPlayer) +} +class com.example.music.RegisterActivity { +~ Button button_submit +~ DaBa daBa +~ EditText index_username +~ EditText index_password +~ SQLiteDatabase sqLiteDatabase +# void onCreate(Bundle) +} +class com.example.music.LoginActivity { +~ EditText usernameInput +~ EditText passwordInput +~ Button button_login +~ Button button_index +~ Context that +- CheckBox RePassword +- CheckBox AutoLogin +- String Tag +- String SP_Name +- String SP_Password +- String SP_IsRemember +- SharedPreferences sharedPreferences +- boolean status +# void onCreate(Bundle) +- void initData() +- void initUI() +} +class com.example.music.MainActivity { +~ DrawerLayout drawerLayout +~ ActionBarDrawerToggle toggle +~ NavigationView navigationView +~ ViewPager pager +~ TabLayout mTabLayout +~ TabItem songs +~ PagerAdapter pagerAdapter ++ {static} int REQUEST_CODE +~ {static} ArrayList musicFiles +~ {static} boolean shuffleBoolean +# void onCreate(Bundle) +- void initViewPager() +- void permission() ++ void onRequestPermissionsResult(int,String[],int[]) ++ boolean onNavigationItemSelected(MenuItem) ++ {static} ArrayList getAllAudio(Context) +} + + +com.example.music.OnCompletionListener <|.. com.example.music.PlayerActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.PlayerActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.RegisterActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.LoginActivity +com.example.music.OnNavigationItemSelectedListener <|.. com.example.music.MainActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.MainActivity +@enduml \ No newline at end of file diff --git a/MyApplication_f/qqqq.puml b/MyApplication_f/qqqq.puml new file mode 100644 index 0000000..5172508 --- /dev/null +++ b/MyApplication_f/qqqq.puml @@ -0,0 +1,24 @@ +@startuml +class com.example.music.MainActivity { +~ DrawerLayout drawerLayout +~ ActionBarDrawerToggle toggle +~ NavigationView navigationView +~ ViewPager pager +~ TabLayout mTabLayout +~ TabItem songs +~ PagerAdapter pagerAdapter ++ {static} int REQUEST_CODE +~ {static} ArrayList musicFiles +~ {static} boolean shuffleBoolean +# void onCreate(Bundle) +- void initViewPager() +- void permission() ++ void onRequestPermissionsResult(int,String[],int[]) ++ boolean onNavigationItemSelected(MenuItem) ++ {static} ArrayList getAllAudio(Context) +} + + +com.example.music.OnNavigationItemSelectedListener <|.. com.example.music.MainActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.MainActivity +@enduml \ No newline at end of file diff --git a/MyApplication_f/qqqqqq.puml b/MyApplication_f/qqqqqq.puml new file mode 100644 index 0000000..5172508 --- /dev/null +++ b/MyApplication_f/qqqqqq.puml @@ -0,0 +1,24 @@ +@startuml +class com.example.music.MainActivity { +~ DrawerLayout drawerLayout +~ ActionBarDrawerToggle toggle +~ NavigationView navigationView +~ ViewPager pager +~ TabLayout mTabLayout +~ TabItem songs +~ PagerAdapter pagerAdapter ++ {static} int REQUEST_CODE +~ {static} ArrayList musicFiles +~ {static} boolean shuffleBoolean +# void onCreate(Bundle) +- void initViewPager() +- void permission() ++ void onRequestPermissionsResult(int,String[],int[]) ++ boolean onNavigationItemSelected(MenuItem) ++ {static} ArrayList getAllAudio(Context) +} + + +com.example.music.OnNavigationItemSelectedListener <|.. com.example.music.MainActivity +androidx.appcompat.app.AppCompatActivity <|-- com.example.music.MainActivity +@enduml \ No newline at end of file diff --git a/MyApplication_f/settings.gradle b/MyApplication_f/settings.gradle new file mode 100644 index 0000000..c481944 --- /dev/null +++ b/MyApplication_f/settings.gradle @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} +rootProject.name = "My Application" +include ':app' +include ':testmusic' diff --git a/MyApplication_f/testmusic/.gitignore b/MyApplication_f/testmusic/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/MyApplication_f/testmusic/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/MyApplication_f/testmusic/.idea/.gitignore b/MyApplication_f/testmusic/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/MyApplication_f/testmusic/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/MyApplication_f/testmusic/.idea/gradle.xml b/MyApplication_f/testmusic/.idea/gradle.xml new file mode 100644 index 0000000..a333341 --- /dev/null +++ b/MyApplication_f/testmusic/.idea/gradle.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/.idea/misc.xml b/MyApplication_f/testmusic/.idea/misc.xml new file mode 100644 index 0000000..3f4f701 --- /dev/null +++ b/MyApplication_f/testmusic/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/.idea/modules.xml b/MyApplication_f/testmusic/.idea/modules.xml new file mode 100644 index 0000000..a3d4a73 --- /dev/null +++ b/MyApplication_f/testmusic/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/build.gradle b/MyApplication_f/testmusic/build.gradle new file mode 100644 index 0000000..c4b2102 --- /dev/null +++ b/MyApplication_f/testmusic/build.gradle @@ -0,0 +1,55 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.0" + + defaultConfig { + applicationId "com.example.music" + minSdkVersion 22 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'androidx.palette:palette:1.0.0' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + + + // Material design + implementation 'com.google.android.material:material:1.3.0-alpha01' + + //Rounded Image View + implementation 'com.makeramen:roundedimageview:2.3.0' + + //Navigation Component + implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2' + implementation 'androidx.navigation:navigation-ui-ktx:2.2.2' + + //noinspection GradleCompatible + implementation 'com.android.support:design:27.1.1' + //noinspection GradleCompatible + implementation 'com.android.support:support-v4:27.1.1' + androidTestImplementation 'androidx.test:rules:1.3.0-rc01' + + //glide + implementation 'com.github.bumptech.glide:glide:4.11.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' +} \ No newline at end of file diff --git a/MyApplication_f/testmusic/proguard-rules.pro b/MyApplication_f/testmusic/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/MyApplication_f/testmusic/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/androidTest/java/com/example/music/ExampleInstrumentedTest.java b/MyApplication_f/testmusic/src/androidTest/java/com/example/music/ExampleInstrumentedTest.java new file mode 100644 index 0000000..977dd5f --- /dev/null +++ b/MyApplication_f/testmusic/src/androidTest/java/com/example/music/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.example.music; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.example.music", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/AndroidManifest.xml b/MyApplication_f/testmusic/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8844b07 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/AlbumAdapter.java b/MyApplication_f/testmusic/src/main/java/com/example/music/AlbumAdapter.java new file mode 100644 index 0000000..ac86ecb --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/AlbumAdapter.java @@ -0,0 +1,72 @@ +package com.example.music; + +import android.content.Context; +import android.media.MediaMetadataRetriever; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.Glide; + +import java.util.ArrayList; + +public class AlbumAdapter extends RecyclerView.Adapter { + private Context mContext; + private ArrayList albumFiles; + View view; + + public AlbumAdapter(Context mContext, ArrayList albumFiles) { + this.mContext = mContext; + this.albumFiles = albumFiles; + } + + @NonNull + @Override + public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + view= LayoutInflater.from(mContext).inflate(R.layout.album_items,parent,false); + return new MyHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull MyHolder holder, int position) { + holder.album_name.setText(albumFiles.get(position).getAlbum()); + byte[] image=getAlbumArt(albumFiles.get(position).getPath()); + if (image!=null){ + Glide.with(mContext).asBitmap() + .load(image) + .into(holder.album_image); + }else { + Glide.with(mContext) + .load(R.drawable.customer) + .into(holder.album_image); + } + } + + @Override + public int getItemCount() { + return albumFiles.size(); + } + + public class MyHolder extends RecyclerView.ViewHolder { + ImageView album_image; + TextView album_name; + public MyHolder(@NonNull View itemView) { + super(itemView); + album_image=itemView.findViewById(R.id.album_image); + album_name=itemView.findViewById(R.id.album_name); + } + } + + private byte[] getAlbumArt(String uri){ + MediaMetadataRetriever retriever=new MediaMetadataRetriever(); + retriever.setDataSource(uri); + byte[] art=retriever.getEmbeddedPicture(); + retriever.release(); + return art; + } +} diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/AlbumsFragment.java b/MyApplication_f/testmusic/src/main/java/com/example/music/AlbumsFragment.java new file mode 100644 index 0000000..6ad0c0a --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/AlbumsFragment.java @@ -0,0 +1,35 @@ +package com.example.music; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import static com.example.music.MainActivity.musicFiles; + +public class AlbumsFragment extends Fragment { + + RecyclerView recyclerView; + AlbumAdapter albumAdapter; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view=inflater.inflate(R.layout.fragment_albums, container, false); + recyclerView=view.findViewById(R.id.recyclerView); + recyclerView.setHasFixedSize(true); + if (!(musicFiles.size()<1)){ + albumAdapter=new AlbumAdapter(getContext(),musicFiles); + recyclerView.setAdapter(albumAdapter); + recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2)); + } + return view; + } +} \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/LoginActivity.java b/MyApplication_f/testmusic/src/main/java/com/example/music/LoginActivity.java new file mode 100644 index 0000000..4703171 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/LoginActivity.java @@ -0,0 +1,188 @@ +package com.example.music; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +public class LoginActivity extends AppCompatActivity { + + EditText usernameInput; + EditText passwordInput; + Button button_login; + Button button_index; + Context that = this; + private CheckBox RePassword; + private CheckBox AutoLogin; + private String Tag = "Page1Activity"; + private String SP_Name = "sp_name"; + private String SP_Password = "sp_password"; + private String SP_IsRemember = "sp_isremember"; + private SharedPreferences sharedPreferences; + private boolean status = false; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_login); + usernameInput = findViewById(R.id.act_login_username); + passwordInput = findViewById(R.id.act_login_password); + button_login = findViewById(R.id.act_login_button); + button_index = findViewById(R.id.act_index_button); + + button_index.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent= new Intent(LoginActivity.this, RegisterActivity.class); + startActivity(intent); + } + }); + SQLiteDatabase database = openOrCreateDatabase("EndHomework.db", MODE_PRIVATE, null); + button_login.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String username = usernameInput.getText().toString(); + String password = passwordInput.getText().toString(); + +/* if (username.equals("0001") && password.equals("0001")) { + Toast.makeText(that, "管理员登录", Toast.LENGTH_SHORT).show(); + Intent intent= new Intent(that, AdminActivity.class); + intent.putExtra("username", username); + startActivity(intent); + + } else if (username.equals("0000") && password.equals("0000")) { + Toast.makeText(that, "服务员登录", Toast.LENGTH_SHORT).show(); + Intent intent= new Intent(that, MainActivity.class); + intent.putExtra("username", username); + startActivity(intent); + + } else { + Toast.makeText(that, "用户账号或密码错误", Toast.LENGTH_SHORT).show(); + + }*/ + if (username.equals(" ")||password.equals(" ")){ + Toast.makeText(that, "账号或密码为空", Toast.LENGTH_SHORT).show(); + } + Cursor cursor = database.query("user", new String[]{"name,password"}, null, null, null, null, null); + if (cursor.getCount() == 0) { + Toast.makeText(LoginActivity.this, "请先注册账号!", Toast.LENGTH_SHORT).show(); + }else { + while (cursor.moveToNext()){ + if (username.equals(cursor.getString(cursor.getColumnIndex("name"))) && password.equals(cursor.getString(cursor.getColumnIndex("password")))) { + Toast.makeText(LoginActivity.this, "登录成功", Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(LoginActivity.this, MainActivity.class); + startActivity(intent); + break; + }else { + Toast.makeText(that, "账号或密码错误", Toast.LENGTH_SHORT).show(); + } + } + } + } + }); + //初始化控件 + initUI(); + //初始化数据 + initData(); + } + private void initData(){ + //实例化 + if (sharedPreferences == null){ + sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE); + } + //回显数据 + usernameInput.setText(sharedPreferences.getString(SP_Name,"")); + passwordInput.setText(sharedPreferences.getString(SP_Password,"")); + status = sharedPreferences.getBoolean(SP_IsRemember,false); + RePassword.setChecked(status); + + } + private void initUI(){ + usernameInput = (EditText) findViewById(R.id.act_login_username); + passwordInput.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (RePassword.isChecked()){ + //文本改变之后记录用户名 + //如果为空实例化SharedPreferences对象 + if (sharedPreferences == null){ + sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE); + } + //实例化SharedPreferences的编辑者对象 + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(SP_Name,usernameInput.getText().toString()); + editor.commit(); + } + } + }); + passwordInput= (EditText) findViewById(R.id.act_login_password); + passwordInput.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (RePassword.isChecked()){ + //文本改变之后记录密码 + //如果为空实例化SharedPreferences对象 + if (sharedPreferences == null){ + sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE); + } + //实例化SharedPreferences的编辑者对象 + SharedPreferences.Editor editor = sharedPreferences.edit(); + editor.putString(SP_Password,passwordInput.getText().toString()); + editor.commit(); + } + } + }); + + RePassword = findViewById(R.id.remember_password); + RePassword.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (RePassword.isChecked()){ + //如果为空实例化SharedPreferences对象 + if (sharedPreferences == null){ + sharedPreferences = getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE); + } + //实例化SharedPreferences的编辑者对象 + SharedPreferences.Editor editor = sharedPreferences.edit(); + //存储数据 + editor.putString(SP_Name,usernameInput.getText().toString()); + editor.putString(SP_Password,passwordInput.getText().toString()); + editor.putBoolean(SP_IsRemember,RePassword.isChecked()); + editor.commit(); + } + } + }); + } + +} diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/MainActivity.java b/MyApplication_f/testmusic/src/main/java/com/example/music/MainActivity.java new file mode 100644 index 0000000..c41ba31 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/MainActivity.java @@ -0,0 +1,164 @@ +package com.example.music; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; + +import android.Manifest; +import android.content.Context; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.provider.MediaStore; +import android.util.Log; +import android.view.MenuItem; + + +import com.google.android.material.navigation.NavigationView; +import com.google.android.material.tabs.TabItem; +import com.google.android.material.tabs.TabLayout; + +import java.net.URL; +import java.security.Permission; +import java.util.ArrayList; + +public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { + + DrawerLayout drawerLayout; + ActionBarDrawerToggle toggle; + NavigationView navigationView; + ViewPager pager; + TabLayout mTabLayout; + TabItem songs,album; + PagerAdapter pagerAdapter; + + public static final int REQUEST_CODE=1; + static ArrayList musicFiles; + static boolean shuffleBoolean=false,repeatBoolean=false; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + permission(); //调用获取权限的方法 + } + + //界面显示和控件绑定 + private void initViewPager() { + Toolbar toolbar=findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + pager=findViewById(R.id.viewPager); + mTabLayout=findViewById(R.id.tabLayout); + + songs=findViewById(R.id.songs); + album=findViewById(R.id.album); + + drawerLayout=findViewById(R.id.drawer); + navigationView=findViewById(R.id.nav_view); + //添加监听事件 + navigationView.setNavigationItemSelectedListener(this); + + toggle=new ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.open,R.string.close); + drawerLayout.addDrawerListener(toggle); + toggle.setDrawerIndicatorEnabled(true); + toggle.syncState(); + + //创建适配器并设置 + pagerAdapter=new PagerAdapter(getSupportFragmentManager(), FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT,mTabLayout.getTabCount()); + pager.setAdapter(pagerAdapter); + //tab 选择监听事件 + mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + @Override + public void onTabSelected(TabLayout.Tab tab) { + pager.setCurrentItem(tab.getPosition()); + } + + @Override + public void onTabUnselected(TabLayout.Tab tab) { + + } + + @Override + public void onTabReselected(TabLayout.Tab tab) { + + } + }); + pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout)); + } + + //获取权限 + private void permission() { + if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){ + ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_CODE); + }else { + musicFiles=getAllAudio(this); + initViewPager(); + } + } + + //请求权限返回的结果事件 + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode==REQUEST_CODE){ + if (grantResults[0]==PackageManager.PERMISSION_GRANTED){ + //Do whatever you want permission related + musicFiles=getAllAudio(this); + initViewPager(); + }else { + ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},REQUEST_CODE); + } + } + } + + //菜单栏点击事件 + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + drawerLayout.closeDrawer(GravityCompat.START); + + return false; + } + + //获取手机上的歌曲信息 + public static ArrayList getAllAudio(Context context){ + ArrayList tempAudioList=new ArrayList<>(); + Uri uri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; + String[] projection={ + MediaStore.Audio.Media.ALBUM, + MediaStore.Audio.Media.TITLE, + MediaStore.Audio.Media.DURATION, + MediaStore.Audio.Media.DATA, //FOR PATH + MediaStore.Audio.Media.ARTIST, + MediaStore.Audio.Media._ID + + }; + Cursor cursor=context.getContentResolver().query(uri,projection,null,null,null); + if (cursor!=null){ + while (cursor.moveToNext()){ + String album=cursor.getString(0); + String title=cursor.getString(1); + String duration=cursor.getString(2); + String path=cursor.getString(3); + String artist=cursor.getString(4); + String id=cursor.getString(5); + + MusicFiles musicFiles=new MusicFiles(path,title,artist,album,duration,id); + //take log.e check + Log.e("PATH:"+path,"Album:"+album); + tempAudioList.add(musicFiles); + } + cursor.close(); + } + return tempAudioList; + } + +} \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/MusicAdapter.java b/MyApplication_f/testmusic/src/main/java/com/example/music/MusicAdapter.java new file mode 100644 index 0000000..6f70964 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/MusicAdapter.java @@ -0,0 +1,132 @@ +package com.example.music; + +import android.content.ContentUris; +import android.content.Context; +import android.content.Intent; +import android.media.MediaMetadataRetriever; +import android.net.Uri; +import android.provider.MediaStore; +import android.support.v4.media.MediaMetadataCompat; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.PopupMenu; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.bumptech.glide.Glide; +import com.google.android.material.snackbar.Snackbar; + +import java.io.File; +import java.lang.reflect.Field; +import java.util.ArrayList; + +public class MusicAdapter extends RecyclerView.Adapter { + + private Context mContext; + private ArrayList mFiles; + + MusicAdapter(Context mContext,ArrayList mFiles){ + this.mFiles=mFiles; + this.mContext=mContext; + } + + @NonNull + @Override + public MyVieHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view= LayoutInflater.from(mContext).inflate(R.layout.music_items,parent,false); + return new MyVieHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull MyVieHolder holder, final int position) { + holder.file_name.setText(mFiles.get(position).getTitle()); + byte[] image=getAlbumArt(mFiles.get(position).getPath()); + if (image!=null){ + Glide.with(mContext).asBitmap() + .load(image) + .into(holder.album_art); + }else { + Glide.with(mContext) + .load(R.drawable.customer) + .into(holder.album_art); + } + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent=new Intent(mContext,PlayerActivity.class); + intent.putExtra("position",position); + mContext.startActivity(intent); + } + }); + holder.menuMore.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(final View view) { + PopupMenu popupMenu=new PopupMenu(mContext,view); + popupMenu.getMenuInflater().inflate(R.menu.popup,popupMenu.getMenu()); + popupMenu.show(); + popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + switch (item.getItemId()){ + case R.id.delete: + Toast.makeText(mContext,"Delete Clicked!",Toast.LENGTH_SHORT).show(); + deleteFlie(position,view); + break; + } + return true; + } + }); + } + }); + } + + private void deleteFlie(int position,View v){ + Uri contentUri= ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, + Long.parseLong(mFiles.get(position).getId())); //content + File file=new File(mFiles.get(position).getPath()); + boolean deleted=file.delete();//delete your file + if (deleted){ + mContext.getContentResolver().delete(contentUri,null,null); + mFiles.remove(position); + notifyItemRemoved(position); + notifyItemRangeChanged(position,mFiles.size()); + Snackbar.make(v,"File Deleted :",Snackbar.LENGTH_LONG).show(); + }else { + //may be file in sd card + Snackbar.make(v,"Can't be Deleted :",Snackbar.LENGTH_LONG).show(); + } + } + + @Override + public int getItemCount() { + return mFiles.size(); + } + + public class MyVieHolder extends RecyclerView.ViewHolder{ + + TextView file_name; + ImageView album_art,menuMore; + + public MyVieHolder(@NonNull View itemView) { + super(itemView); + file_name=itemView.findViewById(R.id.music_file_name);; + album_art=itemView.findViewById(R.id.music_img); + menuMore=itemView.findViewById(R.id.menuMore); + } + } + + private byte[] getAlbumArt(String uri){ + MediaMetadataRetriever retriever=new MediaMetadataRetriever(); + retriever.setDataSource(uri); + byte[] art=retriever.getEmbeddedPicture(); + retriever.release(); + return art; + } +} diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/MusicFiles.java b/MyApplication_f/testmusic/src/main/java/com/example/music/MusicFiles.java new file mode 100644 index 0000000..49d14e3 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/MusicFiles.java @@ -0,0 +1,70 @@ +package com.example.music; + +public class MusicFiles { + private String path; + private String title; + private String artist; + private String album; + private String duration; + private String id; + + public MusicFiles() { + } + + public MusicFiles(String path, String title, String artist, String album, String duration,String id) { + this.path = path; + this.title = title; + this.artist = artist; + this.album = album; + this.duration = duration; + this.id=id; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getArtist() { + return artist; + } + + public void setArtist(String artist) { + this.artist = artist; + } + + public String getAlbum() { + return album; + } + + public void setAlbum(String album) { + this.album = album; + } + + public String getDuration() { + return duration; + } + + public void setDuration(String duration) { + this.duration = duration; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/PagerAdapter.java b/MyApplication_f/testmusic/src/main/java/com/example/music/PagerAdapter.java new file mode 100644 index 0000000..1a24647 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/PagerAdapter.java @@ -0,0 +1,31 @@ +package com.example.music; + +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; + +public class PagerAdapter extends FragmentPagerAdapter { + private int tabsNumber; + public PagerAdapter(@NonNull FragmentManager fm, int behavior,int tabs) { + super(fm, behavior); + this.tabsNumber=tabs; + } + + @NonNull + @Override + public Fragment getItem(int position) { + switch (position){ + case 0: + return new SongsFragment(); + case 1: + return new AlbumsFragment(); + default: return null; + } + } + + @Override + public int getCount() { + return tabsNumber; + } +} diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/PlayerActivity.java b/MyApplication_f/testmusic/src/main/java/com/example/music/PlayerActivity.java new file mode 100644 index 0000000..f913b2d --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/PlayerActivity.java @@ -0,0 +1,490 @@ +package com.example.music; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.palette.graphics.Palette; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.graphics.drawable.GradientDrawable; +import android.media.MediaMetadata; +import android.media.MediaMetadataRetriever; +import android.media.MediaParser; +import android.media.MediaPlayer; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationUtils; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.SeekBar; +import android.widget.TextView; + +import com.bumptech.glide.Glide; +import com.google.android.material.floatingactionbutton.FloatingActionButton; + +import java.util.ArrayList; +import java.util.Random; + +import static com.example.music.MainActivity.musicFiles; +import static com.example.music.MainActivity.repeatBoolean; +import static com.example.music.MainActivity.shuffleBoolean; + +public class PlayerActivity extends AppCompatActivity implements MediaPlayer.OnCompletionListener { + + TextView song_name,artist_name,duration_player,duration_total; + ImageView cover_art,nextBtn,prevBtn,backBtn,shuffleBtn,repeatBtn; + FloatingActionButton playPauseBtn; + SeekBar seekBar; + + int position=-1; + static ArrayList listSongs=new ArrayList<>(); + static Uri uri; + static MediaPlayer mediaPlayer; + private Handler handler=new Handler(); + private Thread playThread,prevThread,nextThread; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_player); + + //绑定控件 + initView(); + //获取歌曲信息播放并绑定到 seekBar + getIntentMethod(); + + song_name.setText(listSongs.get(position).getTitle()); + artist_name.setText(listSongs.get(position).getArtist()); + + mediaPlayer.setOnCompletionListener(this); + //seekBar 变化监听事件 + seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + if (mediaPlayer!=null && fromUser){ + mediaPlayer.seekTo(progress * 1000); + } + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + duration_player.setText(formattedTime(mCurrentPosition)); + } + handler.postDelayed(this,1000); + } + }); + shuffleBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (shuffleBoolean){ + shuffleBoolean=false; + shuffleBtn.setImageResource(R.drawable.ic_shuffle_off); + }else { + shuffleBoolean=true; + shuffleBtn.setImageResource(R.drawable.ic_shuffle_on); + } + } + }); + repeatBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (repeatBoolean){ + repeatBoolean=false; + repeatBtn.setImageResource(R.drawable.ic_repeat_off); + }else { + repeatBoolean=true; + repeatBtn.setImageResource(R.drawable.ic_repeat_on); + } + } + }); + } + + @Override + protected void onResume() { + playThreadBtn(); + prevThreadBtn(); + nextThreadBtn(); + super.onResume(); + } + + //上一个按钮线程事件 + private void prevThreadBtn() { + prevThread=new Thread(){ + @Override + public void run() { + super.run(); + prevBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + prevBtnClicked(); + } + }); + } + }; + prevThread.start(); + } + //上一个按钮点击事件 + private void prevBtnClicked() { + if (mediaPlayer.isPlaying()){ + mediaPlayer.stop(); + mediaPlayer.release(); + if (shuffleBoolean && !repeatBoolean){ + position=getRandom(listSongs.size() - 1); + }else if(!shuffleBoolean && !repeatBoolean){ + position=((position - 1) < 0 ? (listSongs.size() - 1 ) : (position - 1)); + } + uri=Uri.parse(listSongs.get(position).getPath()); + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + metaData(uri); + song_name.setText(listSongs.get(position).getTitle()); + artist_name.setText(listSongs.get(position).getArtist()); + seekBar.setMax(mediaPlayer.getDuration() / 1000); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + } + handler.postDelayed(this,1000); + } + }); + mediaPlayer.setOnCompletionListener(this); + playPauseBtn.setBackgroundResource(R.drawable.ic_pause); + mediaPlayer.start(); + }else { + mediaPlayer.stop(); + mediaPlayer.release(); + if (shuffleBoolean && !repeatBoolean){ + position=getRandom(listSongs.size() - 1); + }else if(!shuffleBoolean && !repeatBoolean){ + position=((position - 1) < 0 ? (listSongs.size() - 1 ) : (position - 1)); + } + uri=Uri.parse(listSongs.get(position).getPath()); + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + metaData(uri); + song_name.setText(listSongs.get(position).getTitle()); + artist_name.setText(listSongs.get(position).getArtist()); + seekBar.setMax(mediaPlayer.getDuration() / 1000); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + } + handler.postDelayed(this,1000); + } + }); + mediaPlayer.setOnCompletionListener(this); + playPauseBtn.setBackgroundResource(R.drawable.ic_play); + } + } + + //下一个按钮线程事件 + private void nextThreadBtn() { + nextThread=new Thread(){ + @Override + public void run() { + super.run(); + nextBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + nextBtnClicked(); + } + }); + } + }; + nextThread.start(); + } + //下一个按钮点击事件 + private void nextBtnClicked() { + if (mediaPlayer.isPlaying()){ + mediaPlayer.stop(); + mediaPlayer.release(); + if (shuffleBoolean && !repeatBoolean){ + position=getRandom(listSongs.size() - 1); + }else if(!shuffleBoolean && !repeatBoolean){ + position=((position + 1) % listSongs.size()); + } + //else position will be position .. + uri=Uri.parse(listSongs.get(position).getPath()); + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + metaData(uri); + song_name.setText(listSongs.get(position).getTitle()); + artist_name.setText(listSongs.get(position).getArtist()); + seekBar.setMax(mediaPlayer.getDuration() / 1000); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + } + handler.postDelayed(this,1000); + } + }); + mediaPlayer.setOnCompletionListener(this); + playPauseBtn.setBackgroundResource(R.drawable.ic_pause); + mediaPlayer.start(); + }else { + mediaPlayer.stop(); + mediaPlayer.release(); + if (shuffleBoolean && !repeatBoolean){ + position=getRandom(listSongs.size() - 1); + }else if(!shuffleBoolean && !repeatBoolean){ + position=((position + 1) % listSongs.size()); + } + uri=Uri.parse(listSongs.get(position).getPath()); + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + metaData(uri); + song_name.setText(listSongs.get(position).getTitle()); + artist_name.setText(listSongs.get(position).getArtist()); + seekBar.setMax(mediaPlayer.getDuration() / 1000); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + } + handler.postDelayed(this,1000); + } + }); + mediaPlayer.setOnCompletionListener(this); + playPauseBtn.setBackgroundResource(R.drawable.ic_play); + } + } + + private int getRandom(int i) { + Random random=new Random(); + return random.nextInt(i + 1); + } + + //播放暂停按钮线程事件 + private void playThreadBtn() { + playThread=new Thread(){ + @Override + public void run() { + super.run(); + playPauseBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + playPauseBtnClicked(); + } + }); + } + }; + playThread.start(); + } + //播放暂停按钮点击事件 + private void playPauseBtnClicked() { + if (mediaPlayer.isPlaying()){ + playPauseBtn.setImageResource(R.drawable.ic_play); + mediaPlayer.pause(); + seekBar.setMax(mediaPlayer.getDuration() / 1000); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + } + handler.postDelayed(this,1000); + } + }); + }else { + playPauseBtn.setImageResource(R.drawable.ic_pause); + mediaPlayer.start(); + seekBar.setMax(mediaPlayer.getDuration() / 1000); + PlayerActivity.this.runOnUiThread(new Runnable() { + @Override + public void run() { + if (mediaPlayer !=null){ + int mCurrentPosition=mediaPlayer.getCurrentPosition() / 1000; + seekBar.setProgress(mCurrentPosition); + } + handler.postDelayed(this,1000); + } + }); + } + } + + //时间的初始化 + private String formattedTime(int mCurrentPosition) { + String totalout =""; + String totalNew =""; + String seconds =String.valueOf(mCurrentPosition % 60); + String minutes=String.valueOf(mCurrentPosition / 60); + totalout=minutes+":"+seconds; + totalNew=minutes+":0"+seconds; + if (seconds.length()==1){ + return totalNew; + }else { + return totalout; + } + } + + private void getIntentMethod() { + position=getIntent().getIntExtra("position",-1); + listSongs=musicFiles; + if (listSongs!=null){ + playPauseBtn.setImageResource(R.drawable.ic_pause); + uri=Uri.parse(listSongs.get(position).getPath()); + } + if (mediaPlayer!=null){ + mediaPlayer.stop(); + mediaPlayer.release(); + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + mediaPlayer.start(); + }else { + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + mediaPlayer.start(); + } + seekBar.setMax(mediaPlayer.getDuration() / 1000); + metaData(uri); + } + + //UI 组件绑定 + private void initView() { + song_name=findViewById(R.id.song_name); + artist_name=findViewById(R.id.song_artist); + duration_player=findViewById(R.id.durationPlayed); + duration_total=findViewById(R.id.durationTotal); + cover_art=findViewById(R.id.cover_art); + nextBtn=findViewById(R.id.id_next); + prevBtn=findViewById(R.id.id_prev); + backBtn=findViewById(R.id.back_btn); + shuffleBtn=findViewById(R.id.id_shuffle); + repeatBtn=findViewById(R.id.id_repeat); + playPauseBtn=findViewById(R.id.play_pause); + seekBar=findViewById(R.id.seekBar); + } + + private void metaData(Uri uri) { + MediaMetadataRetriever retriever=new MediaMetadataRetriever(); + retriever.setDataSource(uri.toString()); + int durationTotal=Integer.parseInt(listSongs.get(position).getDuration()) / 1000; + duration_total.setText(formattedTime(durationTotal)); + byte[] art=retriever.getEmbeddedPicture(); + Bitmap bitmap; + if (art!=null){ + bitmap= BitmapFactory.decodeByteArray(art,0,art.length); + ImageAnimation(this,cover_art,bitmap); + //更换背景色 + Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() { + @Override + public void onGenerated(@Nullable Palette palette) { + Palette.Swatch swatch=palette.getDominantSwatch(); + if(swatch !=null){ + ImageView gredient=findViewById(R.id.imageViewGredient); + RelativeLayout mContainer=findViewById(R.id.mContainer); + gredient.setBackgroundResource(R.drawable.gredient_bg); + mContainer.setBackgroundResource(R.drawable.main_bg); + GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, + new int[]{swatch.getRgb(),0x00000000}); + gredient.setBackground(gradientDrawable); + GradientDrawable gradientDrawableBg = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, + new int[]{swatch.getRgb(),swatch.getRgb()}); + mContainer.setBackground(gradientDrawableBg); + song_name.setTextColor(swatch.getTitleTextColor()); + artist_name.setTextColor(swatch.getBodyTextColor()); + }else { + ImageView gredient=findViewById(R.id.imageViewGredient); + RelativeLayout mContainer=findViewById(R.id.mContainer); + gredient.setBackgroundResource(R.drawable.gredient_bg); + mContainer.setBackgroundResource(R.drawable.main_bg); + GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, + new int[]{0xff000000,0x00000000}); + gredient.setBackground(gradientDrawable); + GradientDrawable gradientDrawableBg = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, + new int[]{0xff000000,0xff000000}); + mContainer.setBackground(gradientDrawableBg); + song_name.setTextColor(Color.WHITE); + artist_name.setTextColor(Color.DKGRAY); + } + } + }); + }else { + Glide.with(this) + .asBitmap() + .load(R.drawable.customer) + .into(cover_art); + ImageView gredient=findViewById(R.id.imageViewGredient); + RelativeLayout mContainer=findViewById(R.id.mContainer); + gredient.setBackgroundResource(R.drawable.gredient_bg); + mContainer.setBackgroundResource(R.drawable.main_bg); + song_name.setTextColor(Color.WHITE); + artist_name.setTextColor(Color.DKGRAY); + } + } + + //设置图片显示方式 + public void ImageAnimation(final Context context, final ImageView imageView, final Bitmap bitmap){ + Animation animOut= AnimationUtils.loadAnimation(context,android.R.anim.fade_out); + final Animation animIn= AnimationUtils.loadAnimation(context,android.R.anim.fade_in); + animOut.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + Glide.with(context).load(bitmap).into(imageView); + animIn.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + imageView.startAnimation(animIn); + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }); + imageView.startAnimation(animOut); + } + + //切换下一个歌曲的事件 + @Override + public void onCompletion(MediaPlayer mp) { + nextBtnClicked(); + if (mediaPlayer !=null){ + mediaPlayer=MediaPlayer.create(getApplicationContext(),uri); + mediaPlayer.start(); + mediaPlayer.setOnCompletionListener(this); + } + } +} \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/RegisterActivity.java b/MyApplication_f/testmusic/src/main/java/com/example/music/RegisterActivity.java new file mode 100644 index 0000000..6ae4161 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/RegisterActivity.java @@ -0,0 +1,51 @@ +package com.example.music; + +import android.content.ContentValues; +import android.content.Intent; +import android.database.sqlite.SQLiteDatabase; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import com.example.music.databases.DaBa; + + +public class RegisterActivity extends AppCompatActivity { + Button button_submit; + DaBa daBa = null; + EditText index_username; + EditText index_password; + SQLiteDatabase sqLiteDatabase; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_index); + button_submit = (Button) findViewById(R.id.submit_button); + index_username = (EditText) findViewById(R.id.index_username); + index_password = (EditText) findViewById(R.id.index_password); + + button_submit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String userName; + String password; + daBa = new DaBa(RegisterActivity.this); + sqLiteDatabase = daBa.getWritableDatabase(); + userName = String.valueOf(index_username.getText()); + password = String.valueOf(index_password.getText()); + ContentValues values = new ContentValues(); + values.put("name",userName); + values.put("password",password); + sqLiteDatabase.insert("user",null,values); + Toast.makeText(RegisterActivity.this, "用户添加成功!", Toast.LENGTH_SHORT).show(); + Intent intent= new Intent(RegisterActivity.this,LoginActivity.class); + startActivity(intent); + } + }); + } + +} diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/SongsFragment.java b/MyApplication_f/testmusic/src/main/java/com/example/music/SongsFragment.java new file mode 100644 index 0000000..5a3b61b --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/SongsFragment.java @@ -0,0 +1,40 @@ +package com.example.music; + +import android.os.Bundle; + +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + + +import static com.example.music.MainActivity.musicFiles; + + +public class SongsFragment extends Fragment { + + RecyclerView recyclerView; + MusicAdapter musicAdapter; + public SongsFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + View view=inflater.inflate(R.layout.fragment_songs, container, false); + recyclerView=view.findViewById(R.id.recyclerView); + recyclerView.setHasFixedSize(true); + if (!(musicFiles.size()<1)){ + musicAdapter=new MusicAdapter(getContext(),musicFiles); + recyclerView.setAdapter(musicAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL,false)); + } + return view; + } +} \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/java/com/example/music/databases/DaBa.java b/MyApplication_f/testmusic/src/main/java/com/example/music/databases/DaBa.java new file mode 100644 index 0000000..00c3e4f --- /dev/null +++ b/MyApplication_f/testmusic/src/main/java/com/example/music/databases/DaBa.java @@ -0,0 +1,29 @@ +package com.example.music.databases; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteOpenHelper; + +public class DaBa extends SQLiteOpenHelper { + private static final int VERSION=1; + private static final String DBNAME="EndHomework.db"; + private Context mContext; + + public DaBa(Context context){ + super(context,DBNAME,null,VERSION); + mContext = context; + } + public void onCreate(SQLiteDatabase db){ + + db.execSQL("create table user(id integer primary key autoincrement, " + + " name varchar(10),password varchar(50))"); +// db.execSQL("create table "); + } + + public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion) + { + + db.execSQL("drop table if exists user"); + onCreate(db); + } +} diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/clock.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/clock.png new file mode 100644 index 0000000..68d1ff7 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/clock.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/follow.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/follow.png new file mode 100644 index 0000000..8fb86e3 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/follow.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/friend.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/friend.png new file mode 100644 index 0000000..f0bb8e4 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/friend.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/gift.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/gift.png new file mode 100644 index 0000000..2cd412f Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/gift.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/home.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/home.png new file mode 100644 index 0000000..41b1a2b Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/home.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/ic_launcher_foreground.xml b/MyApplication_f/testmusic/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/location.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/location.png new file mode 100644 index 0000000..fa6bfa6 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/location.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/scan.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/scan.png new file mode 100644 index 0000000..a8f0918 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/scan.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/setting.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/setting.png new file mode 100644 index 0000000..e215719 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/setting.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable-v24/ticket.png b/MyApplication_f/testmusic/src/main/res/drawable-v24/ticket.png new file mode 100644 index 0000000..30e9884 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable-v24/ticket.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg1.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg1.webp new file mode 100644 index 0000000..1a70b26 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg1.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg2.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg2.webp new file mode 100644 index 0000000..4ae340f Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg2.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg3.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg3.webp new file mode 100644 index 0000000..9bba633 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg3.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg4.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg4.webp new file mode 100644 index 0000000..fd53ce6 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg4.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg5.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg5.webp new file mode 100644 index 0000000..6df6226 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg5.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg6.png b/MyApplication_f/testmusic/src/main/res/drawable/bg6.png new file mode 100644 index 0000000..274fd1d Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg6.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg7.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg7.webp new file mode 100644 index 0000000..cfe94b5 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg7.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg8.png b/MyApplication_f/testmusic/src/main/res/drawable/bg8.png new file mode 100644 index 0000000..fe1d564 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg8.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/bg9.webp b/MyApplication_f/testmusic/src/main/res/drawable/bg9.webp new file mode 100644 index 0000000..da4cab5 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/bg9.webp differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/customer.png b/MyApplication_f/testmusic/src/main/res/drawable/customer.png new file mode 100644 index 0000000..68d548c Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/drawable/customer.png differ diff --git a/MyApplication_f/testmusic/src/main/res/drawable/gredient_bg.xml b/MyApplication_f/testmusic/src/main/res/drawable/gredient_bg.xml new file mode 100644 index 0000000..e9d0fda --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/gredient_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/drawable/gredient_bg_top.xml b/MyApplication_f/testmusic/src/main/res/drawable/gredient_bg_top.xml new file mode 100644 index 0000000..cb5cc11 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/gredient_bg_top.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_baseline_more.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_baseline_more.xml new file mode 100644 index 0000000..34b93ec --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_baseline_more.xml @@ -0,0 +1,10 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_chevron_left.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_chevron_left.xml new file mode 100644 index 0000000..b72ce4b --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_chevron_left.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_launcher_background.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_menu.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_menu.xml new file mode 100644 index 0000000..35d7441 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_menu.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_pause.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_pause.xml new file mode 100644 index 0000000..13d6d2e --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_pause.xml @@ -0,0 +1,10 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_play.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_play.xml new file mode 100644 index 0000000..a522ba0 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_play.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_repeat_off.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_repeat_off.xml new file mode 100644 index 0000000..0848288 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_repeat_off.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_repeat_on.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_repeat_on.xml new file mode 100644 index 0000000..7f3a198 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_repeat_on.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_shuffle_off.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_shuffle_off.xml new file mode 100644 index 0000000..3978e36 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_shuffle_off.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_shuffle_on.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_shuffle_on.xml new file mode 100644 index 0000000..0bf60dd --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_shuffle_on.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_skip_next.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_skip_next.xml new file mode 100644 index 0000000..0be0f61 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_skip_next.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/ic_skip_previous.xml b/MyApplication_f/testmusic/src/main/res/drawable/ic_skip_previous.xml new file mode 100644 index 0000000..938c464 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/ic_skip_previous.xml @@ -0,0 +1,9 @@ + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/main_bg.xml b/MyApplication_f/testmusic/src/main/res/drawable/main_bg.xml new file mode 100644 index 0000000..bda6bb7 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/main_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/drawable/shape1.xml b/MyApplication_f/testmusic/src/main/res/drawable/shape1.xml new file mode 100644 index 0000000..9a05994 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/shape1.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/MyApplication_f/testmusic/src/main/res/drawable/shape2.xml b/MyApplication_f/testmusic/src/main/res/drawable/shape2.xml new file mode 100644 index 0000000..91e9ce1 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/drawable/shape2.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/MyApplication_f/testmusic/src/main/res/layout/activity_index.xml b/MyApplication_f/testmusic/src/main/res/layout/activity_index.xml new file mode 100644 index 0000000..6b57f9f --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/activity_index.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MyApplication_f/testmusic/src/main/res/layout/activity_login.xml b/MyApplication_f/testmusic/src/main/res/layout/activity_login.xml new file mode 100644 index 0000000..8bb5dc8 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/activity_login.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MyApplication_f/testmusic/src/main/res/layout/activity_main.xml b/MyApplication_f/testmusic/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..d3c1fcd --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/activity_main.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/activity_player.xml b/MyApplication_f/testmusic/src/main/res/layout/activity_player.xml new file mode 100644 index 0000000..c53c58e --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/activity_player.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/album_items.xml b/MyApplication_f/testmusic/src/main/res/layout/album_items.xml new file mode 100644 index 0000000..07b332a --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/album_items.xml @@ -0,0 +1,36 @@ + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/content_main.xml b/MyApplication_f/testmusic/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..aa4839c --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/content_main.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/fragment_albums.xml b/MyApplication_f/testmusic/src/main/res/layout/fragment_albums.xml new file mode 100644 index 0000000..48c243b --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/fragment_albums.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/fragment_songs.xml b/MyApplication_f/testmusic/src/main/res/layout/fragment_songs.xml new file mode 100644 index 0000000..f0231cd --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/fragment_songs.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/music_items.xml b/MyApplication_f/testmusic/src/main/res/layout/music_items.xml new file mode 100644 index 0000000..c24f149 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/music_items.xml @@ -0,0 +1,32 @@ + + + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/layout/nav_header.xml b/MyApplication_f/testmusic/src/main/res/layout/nav_header.xml new file mode 100644 index 0000000..4be458e --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/layout/nav_header.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + diff --git a/MyApplication_f/testmusic/src/main/res/menu/nav_menu.xml b/MyApplication_f/testmusic/src/main/res/menu/nav_menu.xml new file mode 100644 index 0000000..35e561f --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/menu/nav_menu.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/menu/popup.xml b/MyApplication_f/testmusic/src/main/res/menu/popup.xml new file mode 100644 index 0000000..976bec2 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/menu/popup.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/MyApplication_f/testmusic/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/MyApplication_f/testmusic/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-hdpi/ic_launcher.png b/MyApplication_f/testmusic/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-hdpi/ic_launcher_round.png b/MyApplication_f/testmusic/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-mdpi/ic_launcher.png b/MyApplication_f/testmusic/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-mdpi/ic_launcher_round.png b/MyApplication_f/testmusic/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-xhdpi/ic_launcher.png b/MyApplication_f/testmusic/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/MyApplication_f/testmusic/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-xxhdpi/ic_launcher.png b/MyApplication_f/testmusic/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/MyApplication_f/testmusic/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/MyApplication_f/testmusic/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/MyApplication_f/testmusic/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/MyApplication_f/testmusic/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c Binary files /dev/null and b/MyApplication_f/testmusic/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/MyApplication_f/testmusic/src/main/res/values/colors.xml b/MyApplication_f/testmusic/src/main/res/values/colors.xml new file mode 100644 index 0000000..79f7f13 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/values/colors.xml @@ -0,0 +1,9 @@ + + + #006BEE + #0057B3 + #03DAC5 + #FFFFFF + #32CD32 + #1E1E1E + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/values/strings.xml b/MyApplication_f/testmusic/src/main/res/values/strings.xml new file mode 100644 index 0000000..1756a28 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/values/strings.xml @@ -0,0 +1,20 @@ + + Music + others + setting + verified + home + friend + follow + ticket + gift + clock + location + scan + album + + Hello blank fragment + open + close + 人人都是彭于晏 + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/main/res/values/styles.xml b/MyApplication_f/testmusic/src/main/res/values/styles.xml new file mode 100644 index 0000000..f99e3c7 --- /dev/null +++ b/MyApplication_f/testmusic/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/MyApplication_f/testmusic/src/test/java/com/example/music/ExampleUnitTest.java b/MyApplication_f/testmusic/src/test/java/com/example/music/ExampleUnitTest.java new file mode 100644 index 0000000..a2c8e49 --- /dev/null +++ b/MyApplication_f/testmusic/src/test/java/com/example/music/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.example.music; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/MyApplication_f/w.puml b/MyApplication_f/w.puml new file mode 100644 index 0000000..d6667c1 --- /dev/null +++ b/MyApplication_f/w.puml @@ -0,0 +1,20 @@ +@startuml +class com.example.music.MusicAdapter { +- Context mContext +- ArrayList mFiles ++ MyVieHolder onCreateViewHolder(ViewGroup,int) ++ void onBindViewHolder(MyVieHolder,int) +- void deleteFlie(int,View) ++ int getItemCount() +- byte[] getAlbumArt(String) +} +class com.example.music.MusicAdapter$MyVieHolder { +~ TextView file_name +~ ImageView album_art +} + + +com.example.music.Adapter <|-- com.example.music.MusicAdapter +com.example.music.MusicAdapter +.. com.example.music.MusicAdapter$MyVieHolder +com.example.music.ViewHolder <|-- com.example.music.MusicAdapter$MyVieHolder +@enduml \ No newline at end of file diff --git a/MyApplication_f/ww.puml b/MyApplication_f/ww.puml new file mode 100644 index 0000000..4f1f9f8 --- /dev/null +++ b/MyApplication_f/ww.puml @@ -0,0 +1,11 @@ +@startuml +class com.example.music.SongsFragment { +~ RecyclerView recyclerView +~ MusicAdapter musicAdapter ++ <> SongsFragment() ++ View onCreateView(LayoutInflater,ViewGroup,Bundle) +} + + +androidx.fragment.app.Fragment <|-- com.example.music.SongsFragment +@enduml \ No newline at end of file