Mp3 Music Player Application Development Using Android
Mp3 Music Player Application Development Using Android
By
Tan Siang Kian
A REPORT
SUBMITTED TO
Universiti Tunku Abdul Rahman
in partial fulfillment of the requirements
for the degree of
BACHELOR OF INFORMATION TECHNOLOGY (HONS)
COMPUTER ENGINEERING
Faculty of Information and Communication Technology
(Kampar Campus)
JAN 2020
UNIVERSITI TUNKU ABDUL RAHMAN
Verified by,
_________________________ _________________________
(Author’s signature) (Supervisor’s signature)
Address:
7,JALAN ROS MERAH 3/19,
TAMAN JOHOR JAYA, Ooi Chek Yee
81100 JOHOR BAHRU, JOHOR. Supervisor’s name
A REPORT
SUBMITTED TO
Universiti Tunku Abdul Rahman
in partial fulfillment of the requirements
for the degree of
BACHELOR OF INFORMATION TECHNOLOGY (HONS)
COMPUTER ENGINEERING
Faculty of Information and Communication Technology
(Kampar Campus)
JAN 2020
i
DECLARATION OF ORIGINALITY
I declare that this report entitled “MP3 Music Player Application Development using
Android” is my own work except as cited in the references. The report has not been
accepted for any degree and is not being submitted concurrently in candidature for any
degree or other award.
Signature : _________________________
Date : 20/04/2020
ii
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
ACKNOWLEDGEMENT
I would like to express my sincere thanks to all those individuals who assisted me in
completing this Final Year Project. The project could not be going smoothly without
the help of these people.
First of all, I would like to express my appreciation to my supervisor, Ts Dr. Ooi Chek
Yee. Dr. Ooi who has given me this bright opportunity to engage in this MP3 Music
Player app project that is very suitable for fresher developers to enhance my own skill,
I feel a million thanks to you. It is the first time to establish an Android application
project in my life. You are my enlightenment mentor, and I will never forget your help
to me in the future.
Furthermore, I would like to thanks to my moderator, Ts Dr. Khor Siak Wang. Dr. Khor
has given me valuable advice to learn from my mistakes and improve on them. His
valuable advice made me have more ideas for improvement after Final Year Project 1.
Finally, I must say thanks to my whole family especially my parents for their love,
comfort, support, and encouragement for me to keep moving forward in the face of
obstacles in my university life.
iii
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
ABSTRACT
This project is about the mp3 music player application development using Android.
The biggest difference between the music player and existing applications is that it is
completely free for users to use. It will integrate the advantages of existing music
players on the market, as far as possible to mining out the existing music players'
function, and then do the filtering in order to eliminate function that not practical or low
cost-effective. Also, it will be keep improved based on user feedback.
In addition, depending on the user's usage scenario, the music player will also add
some modes, such as driving mode and night mode, to allow users to use the application
in any situation or environment. Moreover, the music player will have audio trim
features, allowing users to trim the best part of their favorite song into phone ringtone
or alarm. On the other hand, the existing music players pay less attention to the control
of gestures. Therefore, the music player will solve the limitation by adding more
gestures and shake the phone feature for media control to make it more user-friendly
and humanity.
In a nutshell, the methodology for developing the mp3 music application used in
this project is the agile development cycle. The agile development cycle consists of six
phases, which is requirements analysis, planning, design, implementation or
development, testing, and deployment. Due to the iterative and flexible nature of this
approach, it is able to effectively adapt to users with changing requirements.
iv
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
TABLE OF CONTENTS
TITLE PAGE …………………………………………………………………………………….. .i
DECLARATION OF ORIGINALITY ....................................................................................... ii
ACKNOWLEDGEMENT ............................................................................................................ iii
ABSTRACT ....................................................................................................................................iv
TABLE OF CONTENTS …………………………………………………………………………v
LIST OF TABLES ..........................................................................................................................ix
LIST OF FIGURES.........................................................................................................................x
LIST OF ABBREVIATIONS ...................................................................................................... xii
Chapter 1 Introduction ...................................................................................................................1
1.1 Problem Statement ..............................................................................................................1
1.2 Background Information and Motivation ............................................................................2
1.3 Objectives ............................................................................................................................3
1.4 Proposed Approach/Study ...................................................................................................4
1.5 Highlight of What Have Been Achieved .............................................................................5
1.6 Report Organization ............................................................................................................5
Chapter 2 Literature Review..........................................................................................................6
2.1 Review on existing application ...........................................................................................6
2.1.1 Review on YY Music ...............................................................................................6
2.1.2 Review on Xiami Music .........................................................................................14
2.1.3 Review on JOOX Music.........................................................................................20
2.2 Critical Remarks of previous works ..................................................................................27
2.2.1 Strength and Weaknesses of previous works ..........................................................27
2.2.2 Application Comparison .........................................................................................28
Chapter 3 System Design ..............................................................................................................29
3.1 Site Map ............................................................................................................................29
3.2 Use Case Diagram .............................................................................................................30
3.2.1 Use Case Description .............................................................................................31
3.3 Activity Diagram ...............................................................................................................36
3.3.1 Listen to music .......................................................................................................36
3.3.2 Audio Trim .............................................................................................................37
3.3.3 Sleep timer..............................................................................................................38
3.3.4 Night mode .............................................................................................................39
3.3.5 Change theme .........................................................................................................40
3.3.6 Download song.......................................................................................................41
3.4 System Wireframe .............................................................................................................42
Chapter 4 Methodology and Tools ...............................................................................................55
4.1 Design Specifications ........................................................................................................55
v
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
4.1.1 Methodology ..........................................................................................................55
4.2 Tool to use .........................................................................................................................57
4.2.1 Software Requirement ............................................................................................57
4.2.2 Hardware Requirement...........................................................................................57
4.3 User requirements .............................................................................................................58
4.4 System Performance Definition ........................................................................................59
4.5 Timeline.............................................................................................................................60
Chapter 5 Implementation and Testing .......................................................................................61
5.1 Implementation..................................................................................................................61
5.2 Testing ...............................................................................................................................62
Chapter 6 Conclusion....................................................................................................................68
6.1 Project Review, Discussions and Conclusion ....................................................................68
6.1.1 Project Achievement...............................................................................................69
6.1.2 Problem Encountered .............................................................................................70
6.2 Future Work .......................................................................................................................70
BIBLIOGRAPHY .........................................................................................................................71
APPENDICES A......................................................................................................................... A-1
A.1 MusicAdapter.java ......................................................................................................... A-1
A.2 MusicPagerAdapter.java................................................................................................ A-4
A.3MyApplication.java ........................................................................................................ A-5
A.4 ActivityScope.java ......................................................................................................... A-7
A.5 AppComponent.java ...................................................................................................... A-7
A.6 AppModule.java ............................................................................................................ A-8
A.7 BaseActivity.java ........................................................................................................... A-9
A.8 BaseFragment.java .......................................................................................................A-11
A.9 BasePresenter.java ....................................................................................................... A-13
A.10 IBaseView.java .......................................................................................................... A-13
A.11 EasyRecyclerViewAdapter.java................................................................................. A-14
A.12 CommonConstant.java .............................................................................................. A-18
A.13 FFTData.java ............................................................................................................. A-18
A.14 AudioData.java .......................................................................................................... A-18
A.15 CommonDialog.java.................................................................................................. A-19
A.16 CircleBarRenderer.java ............................................................................................. A-24
A.17 Renderer.java ............................................................................................................. A-27
A.18 VisualizerView.java ................................................................................................... A-29
A.19 DensityUtils.java ....................................................................................................... A-34
A.20 LogUtils.java ............................................................................................................. A-34
A.21 FileUtils.java ............................................................................................................. A-35
vi
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.22 Md5Utils.java ............................................................................................................ A-37
A.23 Mp3ScanUtils.java .................................................................................................... A-38
A.24 ScreenUtils.java ......................................................................................................... A-39
A.25 RingTools.java ........................................................................................................... A-40
A.26 Music.java ................................................................................................................. A-43
A.27 DetectSwipeGestureDriver ........................................................................................ A-44
A.28 DetectSwipeGestureListener ..................................................................................... A-45
A.29 FileInfo.java .............................................................................................................. A-46
A.30 FileChooseComponent.java....................................................................................... A-47
A.31 HomeComponent.java ............................................................................................... A-47
A.32 MusicInfo.java ........................................................................................................... A-48
A.33 HomeModule.java ..................................................................................................... A-52
A.34 FileChooseModule.java ............................................................................................. A-52
A.35 FileChooseContract.java ........................................................................................... A-53
A.36 HomeContract.java .................................................................................................... A-54
A.37 FileChoosePresenter.java .......................................................................................... A-56
A.38 HomePresenter .......................................................................................................... A-58
A.39 CutFragment.java ...................................................................................................... A-66
A.40 FileChooserActivity.java ........................................................................................... A-76
A.41 Mp3NameConvertUtils.java ...................................................................................... A-81
A.42 Mp3InfoUtils.java ..................................................................................................... A-82
A.43 Mp3CutLogic.java ..................................................................................................... A-84
A.44 AllFragment.java ....................................................................................................... A-88
A.45 DriverMusicActivity.java .......................................................................................... A-97
A.46 MainActivity.java .................................................................................................... A-104
A.47 MusicActivity.java ...................................................................................................A-117
A.48 ThemeEnum.java ..................................................................................................... A-128
A.49 MusicFragment.java ................................................................................................ A-129
A.50 RootActivity.java ..................................................................................................... A-132
A.51 ThemeColor.java ..................................................................................................... A-133
A.52 SplashActivity.java .................................................................................................. A-134
A.53 ShakeListener.java ................................................................................................... A-139
A.54 ShakeService.java.................................................................................................... A-142
A.55 ThemeColorAdapter.java......................................................................................... A-144
A.56 BasePreference.java ................................................................................................ A-145
A.57 ThemeColorSelectDialog.java................................................................................. A-146
A.58 AppPreference.java.................................................................................................. A-148
A.59 AuxiliaryPreference.java ......................................................................................... A-150
vii
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.60 BroadcastManager.java ........................................................................................... A-151
A.61 ThemeChangeable.java ........................................................................................... A-152
A.62 Common.java .......................................................................................................... A-152
A.63 PeriodicTask.java .................................................................................................... A-153
A.64 Utils.java ................................................................................................................. A-154
A.65 TimeSleepActivity.java ........................................................................................... A-155
A.66 AnimationUtils.java ................................................................................................. A-164
A.67 BlurUtil.java ............................................................................................................ A-165
A.68 ColorUtils.java ........................................................................................................ A-171
A.69 MergeImage.java ..................................................................................................... A-175
A.70 activity_driver.xml .................................................................................................. A-176
A.71 activity_filechooser_show.xml ................................................................................ A-178
A.72 activity_main.xml .................................................................................................... A-180
A.73 activity_music.xml .................................................................................................. A-181
A.74 activity_splash.xml .................................................................................................. A-185
A.75 activity_time_sleep.xml........................................................................................... A-190
A.76 dialog_common.xml ................................................................................................ A-191
A.77 dialog_theme_color.xml .......................................................................................... A-193
A.78 fragment_all.xml ..................................................................................................... A-194
A.79 fragment_cut.xml .................................................................................................... A-196
A.80 fragment_music.xml ................................................................................................ A-199
A.81 item_musicfile.xml .................................................................................................. A-201
A.82 item_theme_color.xml ............................................................................................. A-202
A.83 music_item.xml ....................................................................................................... A-203
A.84 time_sleep_content.xml ........................................................................................... A-205
A.85 time_sleep_content_picker.xml ................................................................................A-211
POSTER
PLAGIARISM CHECK RESULT
viii
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
LIST OF TABLES
ix
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
LIST OF FIGURES
x
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Figure 3-4-4-1 Others Song Playlist 42
Figure 3-4-5-1 Filtering Song Using the Search Bar and Alphabet 44
-Quick Scrollbar
Figure 3-4-6-1 Song Playing Page 45
Figure 3-4-7-1 Song Playback Mode 46
Figure 3-4-8-1 Driver Mode 47
Figure 3-4-9-1 Audio Trim Feature 48
Figure 3-4-10- Select Music Page 48
Figure 3-4-11- The Process of Cut Song 49
Figure 3-4-12- Set the Trimmed Song as Ringtone 50
Figure 3-4-13- Generated Trimmed Song 50
Figure 3-4-14- Enable Sleep Timer 51
Figure 3-4-15- Disable Sleep Timer 52
Figure 3-4-16- Enable Night Mode 53
Figure 3-4-17- Change Theme Color of Toolbar 54
Figure 3-4-18- Download Song 54
Figure 4-1-1-1 Agile Development Cycle (Devcrew.io, 2017) 55
Figure 4-5-1- Gantt chart for FYP1 60
Figure 4-5-2- Gantt chart for FYP2 60
xi
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
LIST OF ABBREVIATIONS
Apps Applications
CPU Central processing unit
IOS iPhone Operating System
MV Music Video
MP3 MPEG 1 Audio Layer 3
MP4 MPEG LAYER 4
UI User interface
UTAR Universiti Tunku Abdul Rahman
VIP Very Important Person
XML Full extensible markup language
APK Android Application Package
xii
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 1 Introduction
Chapter 1 Introduction
In modern society, people live a fast-paced life, and pressure is constantly present
in lives. Due to the wide use of mobile phones, music has become the daily essential
spiritual food, everyone's mobile phone inside there must be a music player. An
application like MP3 music players is used to balance stress and happiness. It
accompanies people anytime, anywhere and anyplace such as when people taking the
bus and exercising.
The mobile MP3 music player application is designed to allow users to listen to
music in a more convenient and comfortable way without too much restriction.
Moreover, it can play the music properly without interference from advertisements and
offline.
Since many developers realize that modern urbanites are living in a stressful
situation, they have captured the commercial opportunity, therefore many similar
applications have emerged in the market. These applications have easy-to-use interfaces
and features that make the user experience better.
However, these existing music players blindly pursue fancy appearance and huge
features, resulting in the high utilization rate of users' mobile phones, such as CPU and
memory. Whereas, for most normal users, these kind of huge and many features are
meaningless. Therefore, this project is designed to dedicate to MP3 music player based
on the Android mobile phone platform to optimize performance and simplify to meet
user needs.
2
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 1 Introduction
1.3 Objectives
3
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 1 Introduction
Figure 1-1 shows the system flowchart of the mp3 music player. When the user
starts the application, they can select two types of the main action of the application.
The main action is divided into the music player and mp3 cutter. The first case is a
music player, where users can select a song they want to listen to under the "My music"
fragment and click it to play. In the music playing interface, users have a variety of
options for action which are playing as driver mode, media control with shaking, media
control with the gesture, media control with the icon button. The second case is an mp3
cutter. After the user selects the song he or she wants to trim, the application will start
to trim the music and save it to the mobile device. At this point, the application will ask
the user if they want to set the trimmed audio to ringtone and then finish the action.
After the completion of the action, the user can choose whether to exit the application
or not, if "no" back to select action interface, if "yes" terminate the application.
4
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 1 Introduction
The main highlight of the project is to make the proposed application become a high
learnability application without too many complex features, enhance the interaction
between the user and the media control so that the user can have a better experience to
achieve real pressure relief. It is worth mentioning that the music player has the audio
trim function. Users can trim the best parts of the audio by setting the starting and
ending points of the audio, which can be used as a ringtone. In addition, the ability to
enhance the interaction between users and media control is that the application can skip
songs by shaking the phone under the lock screen status of the phone. Also, the
application utilizes the gesture controls to get rid of its reliance on touch buttons. For
example, a song can be switched when the user slides left or right on the music playing
interface.
The project report is divided into six chapters. Chapter 1 is about the background and
motivation of the proposed application, the problem statement, and objectives to solve
the problem statement, proposed approach or study, and highlighting of proposed
applications that have been achieved. Chapter 2 contains a review of the three existing
music player applications on the market, along with comparisons, strengths, and
weaknesses of each. Chapter 3 is the system design including the site map, use case
diagram, activity diagram, and system wireframe which is the user interface of the
proposed application. Chapter 4 is about software design methodology, tools used,
requirements, system performance definitions, and timelines. Chapter 5 is about
implementation and testing. Chapter 6 is the project review, discussion, and conclusion,
the achievements of the project, the problems encountered in the development process
and the future improvement.
5
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
YY Music is a free music player that can play all music on YouTube, support
background playing music, and download the song into local storage for free. Its music
library is extremely powerful that covers almost all songs, such as English, Chinese,
Cantonese, Japanese and even Korean songs. It performs extremely well in terms of
functionality and interaction between users and application.
6
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In addition, the discovery page will also be a display variety of popular artists and
playlists (Figure 2-1-1-2), allowing users to quickly listen to favorite artists' music.
When the user clicks into the playlist, all the songs will be listed for the user's reference.
If the user is satisfied with all the songs in the playlist, just click "Play All" on the top
right to start listening to all the songs in the playlist.
7
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
8
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In the playback control interface (Figure 2-1-1-4), the top is music video playback.
However, it is not supported by playing the music only, but there is a "Save traffic" on
the top right. Below is the playlist of songs, if users prefer to the particular music, it is
allowing to download the song by clicking "Download" button which next to the song
title and selecting the file format. There are two formats can be chosen, which are MP3
and MP4. The downloaded MP4 files can be viewed offline. However, the MP4 only
support to be download 360p resolution, but it is enough to satisfy most of the users.
Figure 2-1-1-4 Music playback control interface and download song option
9
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
There is an option which is the 'Add' button next to the song title, it represents to
add the song to the playlist created by users. In "My Music" page (Figure 2-1-1-5),
users can create their own music world by adding favorite songs into the playlist. All
playlists are free to create and unlimited in number. In the meantime, users can decide
on the cover page of the playlist by placing the particular song on the first ordering.
Unfortunately, local songs in the storage of the phone cannot be added in the playlist,
only songs downloaded from YY Music can be added.
Figure 2-1-1-5 Music play control interface and download song option
10
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
11
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In YY Music setting (Figure 2-1-1-7), users can choose whether to enable the
floating window display features. The floating window is achieved by covering the top
of all applications, so no matter on the desktop or running any applications, the MV
screen of music will be displayed, and the position can be dragged arbitrarily.
12
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In addition, there is a timer feature (Figure 2-1-1-8) that allows users to fall asleep
while playing their favorite songs without worrying about the huge amount of cellular
data that might be consumed by continuous playing the whole night.
13
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
Xiami music main page (Figure 2-1-2-1) is to adopt the frameless and blank-
leaving design looks very comfortable.
Four categories are found at the top of Xiami music main page, which are a library,
discover, video and news (Figure 2-1-2-2). The different genres in a music library are
categorized clearly, which makes people feel the professionalism and dedication of
Xiami music team. It's almost like an encyclopedia of the music genre, there are even
several subcategories for each genre.
Figure 2-1-2-2 Four categories of the main page and subcategories for each genre
15
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
However, as we see that Figure 2-1-2-3 due to the recommended content occupies
too much space of screen so that users need to constantly swipe down to see more
content, which makes filtering content less efficient. Hence, it can be improved by
narrowing the space of each content. For example, there is around two or three new
content on a discovery page, so users can explore and access more music libraries, and
can find what they want more quickly and conveniently.
16
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In addition, video page (Figure 2-1-2-4) is about music video of popular artists.
This is because the short video clips are popular now, therefore, it is a feature that
launched to meet some users. Finally, the news page (Figure 2-1-2-4) is about some
famous stories of some composers and singers as well as the latest news in the music
field.
17
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
The feature which is driving mode (Figure 2-1-2-5) and night mode in Xiami music
is noteworthy. When the user enabled driving mode, the buttons in the playback control
screen will become very large, which allows the driver to control the music player
without distraction while driving and more convenience. In addition, there are three
song lists can be chosen in this mode that is the radio station, recently played songs and
the local music.
18
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
Moreover. night mode (Figure 2-1-2-6) is about the background color of the music
player interface will be changed to black, which is to meet the bad habit of modern
people still playing mobile phone after turning off the light, so that when they use the
music player in the dark environment, the light in the phone will not be so dazzling.
19
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
The JOOX user interface (Figure 2-1-3-1) is simple and grouped into three groups
which is me, discovery and live. On top of each interface, there will be a search bar,
allowing users to search favorite songs at any time, has a good interactive.
20
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In the "ME" page (Figure 2-1-3-2), users can create a new playlist to manage played
and downloaded songs. In addition, JOOX will automatically import song on the user's
device.
Moreover, one of JOOX's features, "My Karaoke" (Figure 2-1-3-3), is a boon for
karaoke fans. My karaoke features are very comprehensive after users record their nice
songs, they are allowed to preview just recorded songs before saving. Also, users are
allowed to edit the recorded songs such as sound offset, vocal or music volume and add
effects.
21
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
22
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
Next, users can search for their favorite songs through various categories on the
discovery page. In the artists and playlists (Figure 2-1-3-4) under the discovery page,
the categories are detailed classification and the layout is neat, just like users stay in a
real karaoke room, allowing users to immerse themselves in the music world.
23
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In the radio page (Figure 2-1-3-5), there are around more than 50 theme stations
classified according to different song styles, and users can play songs by only one click.
Also, the live page is about some artist' interview, live, and their music video.
24
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
In addition, the music playback control page with basic functions that users
generally need. The layout of the interface is easy to understand and the operation is
very simple, which can be mastered immediately after the first use. From Figure 2-1-3-
6 show that users can share their favorite songs with their friends at any time. But it has
a flaw that users can't rewind and fast-forward freely (Figure 2-1-3-7) when playing
popular songs because of it is a VIP's privilege.
Figure 2-1-3-6 Music playback control page and sharing song features
25
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
The biggest drawback of JOOX is that many operations require to become VIP,
such as downloading or listening to most of the songs. With so many apps out there that
offer free downloads or listen to songs that could drive some users away. So, JOOX can
introduce some tasks or mission features to relieve the limit once they have done the
tasks so that allows users to gain VIP's privileges within a limited time.
26
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
27
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 2 Literature Review
Criteria Application
Sleep Timer √ √ √ √
Shake phone to X X X √
switch songs
Touch gesture X X X √
to switch songs
Background Play √ √ √ √
Driving Mode X √ X √
Night Mode X √ X √
√: Yes X: No
Table 2-2-2-1 Comparison among reviewed and proposed application
28
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Under the "My music" page as the home page, the user can select a song from the
playlist to play and then turn into the “Playing music” interface. On this page, the user
is allowed to switch to the driver mode to play the song.
Next, under the “Audio Trim”, the user can cut the mp3 after selecting the song
file. In addition, users can change the layout into a dark color under “Night mode”.
In addition, the user is free to change the theme color of the toolbar under the
“theme”. Moreover, users can download songs under the “Download” page. Lastly,
users who want to terminate the application can simply click “Exit”.
29
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
30
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
31
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Precondition: -
Precondition: -
32
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
33
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
34
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
35
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
The user starts the application and then it will go to the home page which is the "My
music" page. The application will read the device's local songs and generate a playlist.
After that, the user selects the song and plays it, the page will jump into the playing
music interface, where the user is allowed to control the music. Playing modes are
allowed to control music play orders which are shuffle playback, single cycle, and
normal playback. Moreover, the user can also skip to the next song, back to the previous
song and play or pause the current music to control music. Lastly, the user can enable
the driver mode to play the song.
36
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Figure 3-3-2-1 Activity Diagram for User Using Audio Trim Feature
In order to cut the MP3 song, the user needs to select an MP3 song to be trim after
entering the audio trim page. After that, the user can drag the progress bar to set the
start and end times. A dialog box will pop up after successfully trimmed the song to ask
the user whether to set the trimmed song as the ringtone. If the user agrees, the app will
successfully set the ringtone and end the activity. If users don't want to be set as a
ringtone, they can click on "No" to end the activity.
37
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Users can start it by clicking on the "Sleep timer" in the left navigation bar. After that,
the user should set the countdown time, and the countdown will begin after it enabled.
The countdown timer will be updated in real-time, the user can check the remaining
time in the left navigation bar. When the countdown timer is over, the application will
terminate.
38
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Users can enable night mode by clicking the "Night Mode" button in the left navigation
bar. When it is enabled, the moon icon will change to a sun icon, and the layout of each
page will update to dark color background.
39
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Figure 3-3-5-1 Activity Diagram for User to Change Theme of Tool Bar
In order to change the theme color of the toolbar, the user can click "Theme" in the left
navigation bar. At this movement, a theme setting dialog box will pop up, which
provides eight colors for users to select. The selected color will be updated to the
background of the toolbar.
40
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Users can download songs by clicking "Download" in the left navigation bar. The
application will open the mobile browser and direct it to a website that downloads MP3
songs. Users can search the song by entering song, album and artist names.
41
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Once the user starts the application, the first screen will be a splash screen (Figure 3-4-
1) to show out. Then, figure 3-4-2 which is the home page, set to "My music" by default,
reads songs from the local device and generates a playlist.
42
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Figure 3-4-3 English Song Playlist Figure 3-4-4 Others Song Playlist
The song playlists are divided into three categories which are the first is all songs, the
second is English songs, and the third is other songs which including Japanese, Chinese
and so on. Song playlists are primarily categorized by the first word of the song name.
43
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Figure 3-4-5 Filtering Song Using the Search Bar and Alphabet Quick Scrollbar
From figure 3-4-5, the user can quickly find the song by entering the song name in the
search bar at the top. In addition, when the right side alphabet quick scrollbar is being
clicked, the top search bar also will be updated. For example, if the user drags to the 'P'
character, the search bar at the top will also be updated to 'P'. In fact, filtering song is
according to the song name, as long as the song name contains the user input
information, then the result will be displayed.
44
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
As the song begins to play, the disk in the center of the screen will begin to rotate and
the button on bottom center will be updated to pause button. The pause button will be
updated to the play button if the song stops playing. In addition, the user can control
the progress of the song by dragging the progress bar.
45
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
The user can switch the song playback mode by clicking the button at the bottom left.
There are three modes of playback. The first one is the shuffle playback. When the song
is completed to play, the next song will be selected randomly from the playlist. The
second is a single cycle, where the current song is completed to play and the same song
will be playing again. The third is the normal playback. It means that the application
will continue to play the songs in the playlist in sequence until the user moves on to the
next action.
46
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Users can click the car icon at the bottom right side in Figure 3-4-7 to enable the driver
playing mode, where all buttons and size of song names will be enlarged, the output
will be like Figure 3-4-8.
47
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
48
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
The user can set the start time by dragging the left progress bar and the end time by
dragging the right progress bar. After setting the start and end time, click on the green
background color icon. At this time, a dialog box will pop up asking the user to enter
the new name of the trimmed song. Click "Yes" to start the trim, and "No" to cancel the
action.
49
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
In order to enable sleep timer, users can click on the left navigation bar and select "sleep
timer". In the sleep timer setting, the user can start to set the countdown time after
clicking enable. The countdown times provide some option to let the user choose which
are 10 minutes, 20 minutes, 30 minutes, 45 minutes, and 60 minutes. Also, users are
allowed to customize the countdown times. After setting the countdown time, the user
will return to the previous page and a toast message will pop up to let the user know
that the sleep timer is enabled and set up successfully. In addition, users can click on
the left navigation bar to see how much countdown time is left. When the countdown
time left 20 seconds, the toast message will pop up again to inform the user that the app
will be closed after 20 seconds.
51
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Moreover, users are allowed to disable the feature after they set up the sleep timer. Users
can simply go back to the sleep timer settings, drag to the left and click the "Save"
button on the upper right side then successfully cancel the sleep timer.
52
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
Night mode can be enabled from the left navigation bar by clicking on the moon icon
which also called "Night mode". When enabled, the moon icon will update to the sun
icon and change its name to "Daily mode", then the user can click again to cancel the
night mode. When night mode is enabled, the background color of the layout in "My
music", "Audio trim" and sleep timer settings will be changed to dark color.
53
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 3 System Design
4.1.1 Methodology
In this project, the agile development cycle will be used to guide the development
process. The reason for using agile methods is that mobile applications have a short
software life cycle and rapidly changing technologies, so users will constantly change
their requirement and needs in response to technological changes. Therefore, the agile
development cycle are more suitable for android application development because of
iterative and flexible, so it can adapt effectively to changing customers.
The agile development cycle contains 6 phrase which is requirement analysis, planning,
design, implementation or development, testing, and deployment.
55
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 4 Methodology and Tools
Requirement analysis
At this stage, we will review existing MP3 music players on the market. After the
review, we will find out what current users need and idea to improve the existing music
players and collect their comments and suggestions for further analysis.
Planning
In the planning stage, we should first try to explore out the features that the music player
can have. Next, we will eliminate the features that users feel no really useful or low
cost-effective. Finally, each feature is prioritized and assigned to an iteration.
Design
The design stage is prepared according to the requirements of users. Since there are
many details and problems encountered during development to be considered for each
feature. Therefore, we will discuss and formulate solutions and test strategies to verify
the product at this stage.
Implementation or Development
During the development phase, we will iteratively implement each of the features listed
during the planning phase. At this stage, there will be many setbacks and obstacle, so
the team needs to constantly overcome these obstacles. Moreover, we will prioritize the
most important features and need to make intelligent trade-offs between the depth of
completeness of a single feature and the breadth of implementation of multiple features.
Testing
In this stage, we will test the performance of each feature in order to check whether it
meets the requirements of users. For example, we will test whether the application can
be properly installed and run on a real device, and check whether any errors occur in
the running process and each feature is up to standard.
56
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 4 Methodology and Tools
Deployment
In this final phase, we will begin to deliver this application to the customer. For instance,
we will upload this MP3 music player application in the Google Play Store, or posting
download links on Utar Confession which is on Facebook in order to allow UTAR
students to use it. In addition, we will anticipate that users will encounter unpredictable
problems when using the player in this process, so we will solve these problems in a
future version.
1. Android Studio
2. Java SE 8
3. Visual Paradigm
1. Laptop
- Processor: Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz 2.40 GHz
- RAM: 12.00 GB
- Graphic Card: NVIDIA GeForce GT 740M
- Hard Disk storage: 1TB
- Operating System: Windows 10 Professional Edition
2. Smartphone device
- Processor make: Qualcomm Snapdragon 652 (MSM8976)
- RAM: 4.0 GB
- Phone Storage: 64 GB
- Operating System: Android version 5.1.1 (Lollipop)
57
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 4 Methodology and Tools
Functional Requirements:
Able to import the MP3 format files on the device into the music player
Able to play audio files smoothly
Able to download or listen to the song by searching for the name of the song, album,
or artist
Driving mode
Night mode
Songs in playlists can be quickly searched and filtered through the alphabet and
search bar
Non-functional Requirements:
Simplify user interface
Optimize the design to display the information in a better ways
58
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 4 Methodology and Tools
To achieve targeted system performance for this project, there are criteria’s must be
achieved as the list shown below:
1. Hardware/Software Variation
The MP3 music player application needs to ensure the application can work and
installed properly and smoothly on different devices. For example, the hardware
and operating system of each phone will be different, just like Oppo and Huawei
phone is ColorOS and EMUI based on android respectively, so need to test on
different devices. In addition, the application should adapt to different devices to
ensure that no errors occur during execution to avoid different results on different
devices (Guru99, n.d.).
2. App in background
Since this project is developing a music player, the running state of this application
in the background is very important. If it does not work properly in the background,
this will cause the user to have to input data from scratch or restart the application
when retrieving the application, resulting in data loss and so on (Guru99, n.d.).
59
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 4 Methodology and Tools
4.5 Timeline
60
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
5.1 Implementation
The proposed application completed the debugging task during the testing phase, then
it should enter the deployment phase. In the deployment phase, the developer needs to
publish the application's installation package which is the "APK" file, to a platform
such as Google PlayStore for users to download. However, due to the number of users
are limit so far and the proposed application is not in the final public version, there are
still many modules that should be improved and updated. Therefore, it will be uploaded
to the relevant platform to promote to users after the final public version is released. In
addition, users can execute the app in a non-network state, but the "download" module
requires an Internet connection to open the relevant web page to download the song.
Below are the steps to describe how a new user will execute the proposed application:
1. The user first execute the application, he or she needs to give the proposed
application the permissions it needs to read local songs on the phone and load them
into the song playlist.
2. Users can play a song by clicking on one of the songs on the playlist.
3. In the song playback interface, the user is allowed to drag the progress bar, as well
as perform media control through the icon buttons, gesture and shaking the phone.
4. Back on the home page, users can click on the left navigation bar to select the
"Audio Trim" module to trim music.
5. The user clicks the "open" icon button in the upper right corner and selects a song
to begin trimming the song.
6. The user can use the progress bar to set the start and end times and click the start
trim button.
61
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
7. After trimmed successfully, the user can decide to set the trimmed song to the
ringtone or not.
8. In addition, users can click on the left navigation bar to enable "sleep timer," "night
mode," "change theme color," and "download" features.
5.2 Testing
Output
Click "All" in the category The song playlist under All category was successfully Pass
Click "English" in the The song playlist under the English category has been Pass
Click "Others" in the The song playlist under the category of Others was Pass
Choose any song from the Enter the song playing interface, the song can be Pass
Play any song and click Songs still playing in the background Pass
background
62
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
Output
Click the song playback When the current song finished playing, and it will Pass
mode to switch to shuffle randomly choose a song from the playlist to play,
playback rather than playing the song in the order of the playlist
Click the song playback When the current song finished playing, just repeat the Pass
single cycle
Click the song playback When the current song finished playing, play the song Pass
playback
Click the pause button Stop play the song, the pause button is updated to the Pass
play button
Click the play button Start play the song and update play the button to pause Pass
button
Click the next button to Switch to the next song, the song name, album name, Pass
switch to the next song and artist name are also successfully updated to the
Click the previous button Switch to the previous song, the song name, album Pass
to return to the previous name, and artist name are also successfully updated to
Click the driver play mode Enter into driver play mode interface Pass
button
Click the back button Stop playing the song and return to the home page "my Pass
music"
Table 5-2-2 Unit Testing of Media Icon Button Playback Control Module
63
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
Output
Click driver mode button Successfully switch to the driver mode interface, and Pass
interface information
Output
Swipe left in the song Successfully switch to the next song and update the Pass
Swipe right in the song Successfully switch to the previous song and update Pass
Swipe left in driver mode Successfully switch to the next song and update the Pass
Swipe right in the driver Successfully switch to the previous song and update Pass
64
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
Output
Shake the phone in the Successfully switch to the next song and Pass
interface
Output
Click the "Select Music" The playlist under "Select music" interface Pass
Select any song file and set Successful trim and a dialog box pops up asking for Pass
the start and end time before entering the name of the new song file
Click "Yes" to set the Successfully set the trimmed song as ringtone Pass
Click "Cancel" to refuse to Failed set the trimmed song as ringtone and remains Pass
ringtone
Click the icon button to start Invalid trim and pop up toast message prompt Pass
Click the icon button to start Invalid play and pop up toast message prompt Pass
65
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
Output
Click the "Sleep timer" icon Successfully enter the sleep timer setting interface Pass
bar
Click the Enable button Allows the user to proceed to the next step, such as Pass
Set the countdown time Update the prompt message "Stop playing after x Pass
After enabled sleep timer The toast message prompts that the sleep timer has Pass
and setting the countdown been set successfully, the remaining time can be
time, click the "Save" checked in the left navigation bar, and the
time ends
After successfully setting Successfully disable sleep timer, cancel the Pass
the sleep timer, go back to countdown time and pop up the toast message "Sleep
button
66
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 5 Implementation and Testing
Output
Enable night mode Icon button updated to the sun icon, "My music", Pass
Disable night mode Icon button update back to the moon icon, "My Pass
Output
Choose one out of eight Successfully updated the theme color of the toolbar Pass
“Confirm” button
67
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 6 Conclusion
Chapter 6 Conclusion
In a nutshell, when users hold the mentality of venting and relaxation to expect the
music player to bring them relief pressure, in result the application with a dazzling and
complex interface, a variety of multifarious functions, from time to time prompt out of
the advertising, as well as the function that requires be a members to use, which will
only make users feel more depressed and feel the pressure.
Moreover, most people who use a music player, usually don't leave the music
player open in the foreground, but start playing music and then go on to do something
else at hand such as take a break, read a book and news, or play a game. As a result,
they can't focus on the various functions and buttons in the app's interface. For instance,
users who are lying down to take a break and tried to switch to the next song but they
need lots of action like unlocking the phone, open the app again in the background and
look for the switch button.
In addition, the specific song is overwhelmed by a large number of songs and cause
information overload, users can only spend more energy and time to find it. For example,
searching for a book in the library, and realize that there is no library catalog is mean
to looking for a needle in a haystack.
In short, the proposed application will combine the strengths of most music players
on the existing market and eliminate some unrealistic features, allowing users to focus
on listening to music rather than store, communities or various VIP packages or features.
The proposed MP3 music player will focus on improving the experience of users of the
music player experience.
68
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 6 Conclusion
Firstly, the proposed music player had achieved its first objective, which is to make
the music player become a simple, easy-to-use, and well-run application. The proposed
application had become faster startup, smaller size, and less memory usage by
eliminating some unrealistic features. The application also adding some useful features
like audio trim.
Next, the proposed music player achieves a second objective which is to reduce the
use of button controls and enhance the way the app interacts with the user, such as using
gestures and shaking controls. Using gestures, the user doesn't have to pay full attention
to the phone, but simply swipes right or left at any place in the playing interface to
switch the songs. In addition, if the app is running on the lock screen or in the
background, users can successfully switch to the next song by simply shaking the phone,
completely eliminating the use of buttons.
Lastly, the proposed music player achieves a third objective which is a quick search.
The application will use the search bar and the alphabet fast scroll, allowing users to
quickly traverse the song playlist and find the songs they want, which is an efficient
way. For example, if a user wants to search the playlist for a song called "Lemon", he
or she just enters a character that is 'm' into the search bar and the result appears. This
is because the name of the song contains the characters entered in the search bar.
69
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Chapter 6 Conclusion
The main problem encounter in this project is the structure of code which the structure
no build well at first and led to keep modification during developing night mode. Since
the layout interface of each activity is not build as uniformly managed and updated at
the beginning, only one layout is updated to the dark color after the night mode is
enabled, and the layout of the other remains unchanged. Fortunately, these problems
were solved in the final development stage, but the solution is informal and no
efficiently, as it is achieved by using a lot of duplicate coding to solve.
I. Enhanced interactivity, allowing users to open song playlist when they swipe up
from the music playing interface
II. Implement of the in-app download of songs, rather than the current use of a
specific website as a hyperlink
III. Refactoring code, rebuild the coding structure to make the coding look cleaner,
easier to understand and perform efficiently
IV. Cross-platform, running the app on IOS, not only Android
70
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
BIBLIOGRAPHY
Guru99.com. (2019). Mobile App Performance Testing: CheckList, Tools (Andriod &
iOS). [online] Available at: https://www.guru99.com/mobile-app-performance-testing-
strategy-tools.html#1 [Accessed 15 Jul. 2019].
Kr-asia.com. (2019). Spotify facing growth pains in Asia, where Tencent’s Joox is more
popular – KrASIA. [online] Available at: https://kr-asia.com/spotify-facing-growth-
issue-in-asia-where-tencents-joox-is-more-popular [Accessed 29 Jun. 2019].
Mehul, R. (2018). Top Reasons Why Your Mobile App is Slow and How to Fix it. [online]
Available at: https://www.freecodecamp.org/news/top-reasons-why-your-mobile-app-
is-slow-and-how-to-fix-it-f0f7ce524934/ [Accessed 19 Mar. 2020].
71
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Scacca, S. (2020). When to Design with Gestures vs. Buttons. [online] Available at:
https://www.telerik.com/blogs/when-to-design-with-gestures-vs-buttons [Accessed
19 Mar. 2020].
72
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
APPENDICES A
A.1 MusicAdapter.java
package com.example.fyp2_tsk.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.fyp2_tsk.utils.Common;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.entity.Music;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
//Inherit the BaseAdapter to implement a custom adapter and rewrite the code of BaseAdapter
public class MusicAdapter extends BaseAdapter{
private Context context;
private List<Music> musicList;
private ArrayList<Music> MusicarrayList;
@Override
public int getCount() {
return Common.musicList.size();
}
@Override
public Object getItem(int position) {
return null;
}
A-1
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
ViewHolder viewHolder = new ViewHolder();
//Cache principle,to determine whether convertView is empty
if (convertView == null) {
//binding layout file
view = LayoutInflater.from(context).inflate(R.layout.music_item, null);
viewHolder.titleTv.setText(Common.musicList.get(position).title);
viewHolder.artistTv.setText(Common.musicList.get(position).artist + "-" +
Common.musicList.get(position).album);
if (Common.musicList.get(position).isPlaying) {
viewHolder.isPlayingView.setVisibility(View.VISIBLE);
} else {
viewHolder.isPlayingView.setVisibility(View.INVISIBLE);
}
return view;
}
A-2
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
else {
for (Music music : MusicarrayList){
if (music.getTitle().toLowerCase(Locale.getDefault())
.contains(charText)){
Common.musicList.add(music);
}
}
}
notifyDataSetChanged();
}
A-3
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.2 MusicPagerAdapter.java
package com.example.fyp2_tsk.adapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import java.util.List;
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentList.size();
}
}
A-4
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.3MyApplication.java
package com.example.fyp2_tsk.common.app;
import android.app.Application;
import com.example.fyp2_tsk.common.utils.LogUtils;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.umeng.analytics.MobclickAgent;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.common.app.di.AppModule;
import com.example.fyp2_tsk.common.app.di.DaggerAppComponent;
import com.example.fyp2_tsk.home.bean.MyObjectBox;
import io.objectbox.BoxStore;
import skin.support.SkinCompatManager;
import skin.support.design.app.SkinMaterialViewInflater;
//logger
if(LogUtils.isApkDebugable(this)) {
Logger.addLogAdapter(new AndroidLogAdapter());
}
//umeng analytics
MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
A-6
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.4 ActivityScope.java
package com.example.fyp2_tsk.common.app.di;
import java.lang.annotation.Retention;
import javax.inject.Scope;
import static java.lang.annotation.RetentionPolicy. RUNTIME;
@Scope
@Retention(RUNTIME)
public @interface ActivityScope {
}
A.5 AppComponent.java
package com.example.fyp2_tsk.common.app.di;
import javax.inject.Singleton;
import dagger.Component;
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
A-7
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.6 AppModule.java
package com.example.fyp2_tsk.common.app.di;
import android.app.Application;
import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
@Module
public class AppModule {
private Application mApplication;
public AppModule(Application application) {
this.mApplication = application;
}
@Singleton
@Provides
public Application provideApplication() {
return mApplication;
}
}
A-8
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.7 BaseActivity.java
package com.example.fyp2_tsk.common.base;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.umeng.analytics.MobclickAgent;
import com.example.fyp2_tsk.common.app.MyApplication;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import javax.inject.Inject;
//Dependency Injection
protected abstract void ComponentInject(AppComponent appComponent);
protected abstract int initLayoutResId();
protected abstract void initData(Bundle savedInstanceState);
@Inject
public T mPresenter;
protected B mDataBinding;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mDataBinding = DataBindingUtil.setContentView(this, initLayoutResId());
myApplication = (MyApplication) getApplication();
ComponentInject(myApplication.getAppComponent());//Dependency Injection
initData(savedInstanceState);
}
@Override
public Context getContext(){
return this;
}
@Override
A-9
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
protected void onResume() {
super.onResume();
MobclickAgent.onResume(this);
}
@Override
protected void onPause() {
super.onPause();
MobclickAgent.onPause(this);
}
}
A-10
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.8 BaseFragment.java
package com.example.fyp2_tsk.common.base;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.fyp2_tsk.common.app.MyApplication;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import javax.inject.Inject;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (view != null){
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null){
parent.removeView(view);
}
return view;
}
myApplication = (MyApplication)getActivity().getApplication();
ComponentInject(myApplication.getAppComponent());
init(view);
return view;
A-11
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
@Override
public Context getContext() {
return super.getContext();
}
A-12
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.9 BasePresenter.java
package com.example.fyp2_tsk.common.base;
A.10 IBaseView.java
package com.example.fyp2_tsk.common.base;
import android.content.Context;
A-13
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.11 EasyRecyclerViewAdapter.java
package com.example.fyp2_tsk.common.base;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
public EasyRecyclerViewAdapter() {
}
@Override
public int getItemViewType(int position) {
if (mFooterView == null && mHeaderView == null) {
return TYPE_BODY;
}
if (mHeaderView != null && position == 0) {
return TYPE_HEAD;
}
A-14
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if (mFooterView != null && mHeaderView == null && position == mDatas.size()) {
return TYPE_FOOT;
}
if (mFooterView != null && mHeaderView != null && position == mDatas.size() + 1) {
return TYPE_FOOT;
}
return TYPE_BODY;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == TYPE_HEAD) {
return new EasyViewHolder(mHeaderView);
}
if (viewType == TYPE_FOOT) {
return new EasyViewHolder(mFooterView);
}
return onCreate(parent, viewType);//get resources file
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (getItemViewType(position) == TYPE_HEAD || getItemViewType(position) ==
TYPE_FOOT) {
return;
}
if (mItemClickListener != null) {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mItemClickListener.OnItemClick(v, dataPosition, data);
}
});
}
if (mItemLongClickListener != null) {
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
A-15
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mItemLongClickListener.OnItemLongClick(v, dataPosition, data);
return true;
}
});
}
@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
final RecyclerView.LayoutManager layoutParams = recyclerView.getLayoutManager();
if (layoutParams instanceof GridLayoutManager) {
((GridLayoutManager) layoutParams).setSpanSizeLookup(new
GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {
int type = getItemViewType(position);
if (type == TYPE_HEAD || type == TYPE_FOOT)
return ((GridLayoutManager) layoutParams).getSpanCount();
return 1;
}
});
}
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
super.onViewAttachedToWindow(holder);
ViewGroup.LayoutParams layoutParams = holder.itemView.getLayoutParams();
if (layoutParams instanceof StaggeredGridLayoutManager.LayoutParams) {
StaggeredGridLayoutManager.LayoutParams params =
(StaggeredGridLayoutManager.LayoutParams) layoutParams;
if (mHeaderView != null && holder.getLayoutPosition() == 0) {
params.setFullSpan(true);
} else if (mFooterView != null && holder.getLayoutPosition() ==
getFooterPosition()) {
params.setFullSpan(true);
} else {
params.setFullSpan(false);
}
}
}
A-16
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public int getDataPosition(RecyclerView.ViewHolder holder) {
int position = holder.getLayoutPosition();
return mHeaderView == null ? position : position - 1;
}
@Override
public int getItemCount() {
if (mFooterView != null && mHeaderView != null) {
return mDatas.size() + 2;
} else if (mFooterView != null || mHeaderView != null) {
return mDatas.size() + 1;
}
return mDatas.size();
}
A-17
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
interface OnItemLongClickListener<T> {
public void OnItemLongClick(View view, int position, T data);
}
}
A.12 CommonConstant.java
package com.example.fyp2_tsk.common.constant;
A.13 FFTData.java
package com.example.fyp2_tsk.common.ui.view.visualizer;
// Data class to explicitly indicate that these bytes are the FFT of audio data
public class FFTData {
public byte[] bytes;
public FFTData() {
}
A.14 AudioData.java
package com.example.fyp2_tsk.common.ui.view.visualizer;
A-18
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
// Data class to explicitly indicate that these bytes are raw audio data
public class AudioData {
public byte[] bytes;
public AudioData() {
}
A.15 CommonDialog.java
package com.example.fyp2_tsk.common.ui.view;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.example.fyp2_tsk.R;
A-19
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
private int mCancelColor;// = Color.parseColor("#009688");
public OnDialogClickListener mOnClickListener;
A-20
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mContentTv.setVisibility(View.GONE);
}
if (mRightTextColor != 0) {
this.mConfirmTv.setTextColor(mRightTextColor);
}
if (mCancelColor != 0) {
this.mCancelTv.setTextColor(this.mCancelColor);
}
if (mIsShowOne) {
this.mCancelTv.setVisibility(View.GONE);
} else {
this.mCancelTv.setVisibility(View.VISIBLE);
}
if (mIsShowInput) {
this.mInputEt.setVisibility(View.VISIBLE);
this.mInputEt.setHint(mHintContent);
this.mInputEt.setInputType(mIsPasswordInput ?
InputType.TYPE_TEXT_VARIATION_PASSWORD :
InputType.TYPE_CLASS_TEXT);
} else {
this.mInputEt.setVisibility(View.GONE);
}
this.setDataAndListener();
}
(CommonDialog.this.mOnClickListener).doOk(CommonDialog.this.getEditText());
}
}
}
});
this.mCancelTv.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CommonDialog.this.close();
if (CommonDialog.this.mOnClickListener != null) {
A-21
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
CommonDialog.this.mOnClickListener.doCancle();
}
}
});
}
}
});
}
A-22
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
private boolean isShowInput;
private String hintContent;
private boolean isPasswordInput;
private boolean canCancel = true;
private OnDialogClickListener mOnDialogClickListener;
public Builder() {
}
A-23
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.16 CircleBarRenderer.java
package com.example.fyp2_tsk.common.ui.view.visualizer.renderer;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import com.example.fyp2_tsk.common.ui.view.visualizer.AudioData;
import com.example.fyp2_tsk.common.ui.view.visualizer.FFTData;
/**
* Renders the FFT data onto a pulsing, rotating circle
* @param paint - Paint to draw lines with
*/
public CircleBarRenderer(Paint paint, int divisions) {
this(paint, divisions, false);
}
/**
* Renders the audio data onto a pulsing circle
* @param
* @param paint - Paint to draw lines with
* @param divisions - must be a power of 2. Controls how many lines to draw
* @param cycleColor - If true the color will change on each frame
*/
public CircleBarRenderer(Paint paint, int divisions, boolean cycleColor) {
super();
mPaint = paint;
mDivisions = divisions;
mCycleColor = cycleColor;
}
@Override
public void onRender(Canvas canvas, AudioData data, Rect rect) {
// Do nothing, we only display FFT data
}
@Override
A-24
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public void onRender(Canvas canvas, FFTData data, Rect rect) {
if (mCycleColor) {
cycleColor();
}
float[] cartPoint = {
(float) (i * mDivisions) / (data.bytes.length - 1),
rect.height() / 2 - dbValue / 4
};
float[] cartPoint2 = {
(float) (i * mDivisions) / (data.bytes.length - 1),
rect.height() / 2 + dbValue
};
canvas.drawLines(mFFTPoints, mPaint);
float modulation = 0;
float modulationStrength = 0.4f; // 0-1
float angleModulation = 0;
float aggresive = 0.4f;
A-25
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
double cX = rect.width() / 2;
double cY = rect.height() / 2;
double angle = (cartesian[0]) * 2 * Math.PI;
double radius = ((rect.width() / 2) * (1 - aggresive) + aggresive * cartesian[1] /
2) * ((1 - modulationStrength) + modulationStrength * (1 + Math.sin(modulation)) / 2);
float[] out = {
(float) (cX + radius * Math.sin(angle + angleModulation)),
(float) (cY + radius * Math.cos(angle + angleModulation))
};
return out;
}
A-26
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.17 Renderer.java
package com.example.fyp2_tsk.common.ui.view.visualizer.renderer;
import android.graphics.Canvas;
import android.graphics.Rect;
import com.example.fyp2_tsk.common.ui.view.visualizer.AudioData;
import com.example.fyp2_tsk.common.ui.view.visualizer.FFTData;
public Renderer() {
}
/**
* Implement this method to render the FFT audio data onto the canvas
* @param canvas - Canvas to draw on
* @param data - Data to render
* @param rect - Rect to render into
*/
abstract public void onRender(Canvas canvas, FFTData data, Rect rect);
/**
* Render the FFT data onto the canvas
* @param canvas - Canvas to draw on
* @param data - Data to render
* @param rect - Rect to render into
*/
final public void render(Canvas canvas, FFTData data, Rect rect) {
if (mFFTPoints == null || mFFTPoints.length < data.bytes.length * 4) {
mFFTPoints = new float[data.bytes.length * 4];
}
onRender(canvas, data, rect);
}
}
A-28
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.18 VisualizerView.java
package com.example.fyp2_tsk.common.ui.view.visualizer;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.media.MediaPlayer;
import android.media.audiofx.Visualizer;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.example.fyp2_tsk.common.ui.view.visualizer.renderer.Renderer;
import java.util.HashSet;
import java.util.Set;
/**
* A class that draws visualizations of data received from a
* {@link Visualizer.OnDataCaptureListener#onWaveFormDataCapture } and
* {@link Visualizer.OnDataCaptureListener#onFftDataCapture }
*/
public class VisualizerView extends View {
private byte[] mBytes;
private byte[] mFFTBytes;
private Rect mRect = new Rect();
private Visualizer mVisualizer;
private Set<Renderer> mRenderers;
private Paint mFlashPaint = new Paint();
private Paint mFadePaint = new Paint();
AudioData mAudioData = new AudioData();
FFTData mFftData = new FFTData();
A-29
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public VisualizerView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
/**
* Links the visualizer to a player
*
* @param player - MediaPlayer instance to link to
*/
@SuppressLint("NewApi")
public void link(MediaPlayer player) {
if (player == null) {
throw new NullPointerException("Cannot link to null MediaPlayer");
}
mVisualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
@Override
public void
onWaveFormDataCapture(Visualizer visualizer, byte[] bytes, int samplingRate) {
updateVisualizer(bytes);
A-30
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
@Override
public void onFftDataCapture(Visualizer
visualizer, byte[] bytes, int samplingRate) {
updateVisualizerFFT(bytes);
}
},
Visualizer.getMaxCaptureRate() / 2, true, true);
// Enabled Visualizer and disable when we're done with the stream
//mVisualizer.setEnabled(false);
player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
//mVisualizer.setEnabled(false);
}
});
} catch (UnsupportedOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressLint("NewApi")
public void setEnabled(boolean enabled) {
if (mVisualizer == null)
return;
mVisualizer.setEnabled(enabled);
}
A-31
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mRenderers.clear();
}
/**
* Pass data to the visualizer. Typically this will be obtained from the
* Android Visualizer.OnDataCaptureListener call back. See
* {@link Visualizer.OnDataCaptureListener#onWaveFormDataCapture }
*
* @param bytes
*/
public void updateVisualizer(byte[] bytes) {
mBytes = bytes;
invalidate();
}
/**
* Pass FFT data to the visualizer. Typically this will be obtained from the
* Android Visualizer.OnDataCaptureListener call back. See
* {@link Visualizer.OnDataCaptureListener#onFftDataCapture }
*
* @param bytes
*/
public void updateVisualizerFFT(byte[] bytes) {
mFFTBytes = bytes;
invalidate();
}
Bitmap mCanvasBitmap;
Canvas mCanvas;
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {
}
// Create canvas once we're ready to draw
mRect.set(0, 0, getWidth(), getHeight());
if (mCanvasBitmap == null) {
mCanvasBitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(),
Config.ARGB_8888);
}
A-32
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if (mCanvas == null) {
mCanvas = new Canvas(mCanvasBitmap);
}
if (mBytes != null) {
// Render all audio renderers
mAudioData.setBytes(mBytes);
for (Renderer r : mRenderers) {
r.render(mCanvas, mAudioData, mRect);
}
}
if (mFFTBytes != null) {
// Render all FFT renderers
mFftData.setBytes(mFFTBytes);
for (Renderer r : mRenderers) {
r.render(mCanvas, mFftData, mRect);
}
}
canvas.drawBitmap(mCanvasBitmap, 0, 0, null);
}
}
A-33
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.19 DensityUtils.java
package com.example.fyp2_tsk.common.utils;
import android.content.Context;
A.20 LogUtils.java
package com.example.fyp2_tsk.common.utils;
import android.content.Context;
import android.content.pm.ApplicationInfo;
}
return false;
}
}
A-34
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.21 FileUtils.java
package com.example.fyp2_tsk.common.utils;
import android.text.TextUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.text.DecimalFormat;
import java.util.List;
A-36
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.22 Md5Utils.java
package com.example.fyp2_tsk.common.utils;
import java.security.MessageDigest;
A-37
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.23 Mp3ScanUtils.java
package com.example.fyp2_tsk.common.utils;
import com.example.fyp2_tsk.mp3cut.logic.Mp3InfoUtils;
import com.example.fyp2_tsk.home.bean.FileInfo;
import com.example.fyp2_tsk.home.bean.MusicInfo;
import java.io.File;
import java.util.List;
A.24 ScreenUtils.java
package com.example.fyp2_tsk.common.utils;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;
A-39
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.25 RingTools.java
package com.example.fyp2_tsk.common.utils;
import android.app.Activity;
import android.content.ContentValues;
import android.database.Cursor;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.provider.Settings;
import android.widget.Toast;
import com.orhanobut.logger.Logger;
import com.example.fyp2_tsk.R;
import java.io.File;
/**
* set ringtone
* @param type RingtoneManager.TYPE_RINGTONE is phone ringtone
* RingtoneManager.TYPE_NOTIFICATION is Notification ringtone
* RingtoneManager.TYPE_ALARM is alarm ringtone
* @param path Download down the mp3 full path
*/
public static void setRing(Activity context, int type, String path) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// check whether have WRITE_SETTINGS permission or not
if (!Settings.System.canWrite(context)) {
Toast.makeText(context,
context.getResources().getString(R.string.homefragment_systemsetting_denied),
Toast.LENGTH_SHORT).show();
} else {
setRingHasPermission(context, type, path);
}
} else {
setRingHasPermission(context, type, path);
}
}
context.getContentResolver().delete(uri,
MediaStore.MediaColumns.DATA + "=\"" + sdfile.getAbsolutePath() + "\"",
null);
newUri = context.getContentResolver().insert(uri, values);
} catch (Exception e) {
e.printStackTrace();
}
if (newUri != null) {
String ringStoneId = "";
String notificationId = "";
String alarmId = "";
if (null != oldRingtoneUri) {
ringStoneId = oldRingtoneUri.getLastPathSegment();
}
if (null != oldNotification) {
notificationId = oldNotification.getLastPathSegment();
}
if (null != oldAlarm) {
A-41
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
alarmId = oldAlarm.getLastPathSegment();
}
Uri setRingStoneUri;
Uri setNotificationUri;
Uri setAlarmUri;
if (type == RingtoneManager.TYPE_RINGTONE || ringStoneId.equals(deleteId)) {
setRingStoneUri = newUri;
} else {
setRingStoneUri = oldRingtoneUri;
}
if (type == RingtoneManager.TYPE_NOTIFICATION ||
notificationId.equals(deleteId)) {
setNotificationUri = newUri;
} else {
setNotificationUri = oldNotification;
}
if (type == RingtoneManager.TYPE_ALARM || alarmId.equals(deleteId)) {
setAlarmUri = newUri;
} else {
setAlarmUri = oldAlarm;
}
RingtoneManager.setActualDefaultRingtoneUri(context,
RingtoneManager.TYPE_RINGTONE, setRingStoneUri);
RingtoneManager.setActualDefaultRingtoneUri(context,
RingtoneManager.TYPE_NOTIFICATION, setNotificationUri);
RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_ALARM,
setAlarmUri);
switch (type) {
case RingtoneManager.TYPE_RINGTONE:
Toast.makeText(context.getApplicationContext(), "Ringer set up
successfully!", Toast.LENGTH_SHORT).show();
break;
case RingtoneManager.TYPE_NOTIFICATION:
Toast.makeText(context.getApplicationContext(), "Set notification ring
successfully!", Toast.LENGTH_SHORT).show();
break;
case RingtoneManager.TYPE_ALARM:
Toast.makeText(context.getApplicationContext(), "Alarm set
successfully!", Toast.LENGTH_SHORT).show();
break;
}
}
}
}
A-42
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.26 Music.java
package com.example.fyp2_tsk.entity;
import android.graphics.Bitmap;
A-43
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.27 DetectSwipeGestureDriver
package com.example.fyp2_tsk.Gesture;
import android.view.GestureDetector;
import android.view.MotionEvent;
import com.example.fyp2_tsk.other.DriverMusicActivity;
import com.example.fyp2_tsk.other.MusicActivity;
A-44
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.28 DetectSwipeGestureListener
package com.example.fyp2_tsk.Gesture;
import android.view.GestureDetector;
import android.view.MotionEvent;
import com.example.fyp2_tsk.other.DriverMusicActivity;
import com.example.fyp2_tsk.other.MusicActivity;
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
{
float deltaX = e1.getX() - e2.getX();
float deltaXAbs = Math.abs(deltaX);
A-45
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.29 FileInfo.java
package com.example.fyp2_tsk.home.bean;
import java.util.ArrayList;
@Override
public String toString() {
A-46
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
return "FileInfo [fileType=" + fileType + ", fileName=" + fileName
+ ", filePath=" + filePath + "]";
}
static {
MUSIC_SUFFIX.add(".mp3");
}
enum FileType {
FILE, DIRECTORY
}
}
A.30 FileChooseComponent.java
import com.example.fyp2_tsk.common.app.di.ActivityScope;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.home.ui.FileChooserActivity;
import dagger.Component;
@ActivityScope
@Component(modules = FileChooseModule.class, dependencies = AppComponent.class)
public interface FileChooseComponent {
void inject(FileChooserActivity activity);
}
A.31 HomeComponent.java
package com.example.fyp2_tsk.home.di;
import com.example.fyp2_tsk.common.app.di.ActivityScope;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.home.ui.CutFragment;
import dagger.Component;
@ActivityScope
@Component(modules = HomeModule.class, dependencies = AppComponent.class)
public interface HomeComponent {
void inject(CutFragment fragment);
}
A-47
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.32 MusicInfo.java
package com.example.fyp2_tsk.home.bean;
import android.os.Parcel;
import android.os.Parcelable;
import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;
@Entity
public class MusicInfo implements Parcelable, Cloneable {
@Id()
private Long id = null;
private String filepath;
private String filename;
private long fileSize;
private int storageType;
private String coverPath;
private String album;
private String artist;
private String title; //Music title
public MusicInfo() {
}
A-49
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public String getTitle() {
return title;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(this.id);
dest.writeString(this.filepath);
dest.writeString(this.filename);
dest.writeLong(this.fileSize);
dest.writeInt(this.storageType);
dest.writeString(this.coverPath);
dest.writeString(this.album);
dest.writeString(this.title);
dest.writeString(this.artist);
}
A-50
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
this.title = in.readString();
this.artist = in.readString();
}
@Override
public MusicInfo[] newArray(int size) {
return new MusicInfo[size];
}
};
@Override
public Object clone() throws CloneNotSupportedException {
MusicInfo musicInfo = null;
try{
musicInfo = (MusicInfo) super.clone();
}
catch(CloneNotSupportedException e) {
e.printStackTrace();
}
return musicInfo;
}
}
A-51
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.33 HomeModule.java
package com.example.fyp2_tsk.home.di;
import com.example.fyp2_tsk.home.presenter.HomeContract;
import dagger.Module;
import dagger.Provides;
@Module
public class HomeModule {
private HomeContract.View view;
public HomeModule(HomeContract.View view){
this.view = view;
}
@Provides
public HomeContract.View providerHomeView(){
return this.view;
}
}
A.34 FileChooseModule.java
package com.example.fyp2_tsk.home.di;
import com.example.fyp2_tsk.home.presenter.FileChooseContract;
import dagger.Module;
import dagger.Provides;
@Module
public class FileChooseModule {
private FileChooseContract.View view;
public FileChooseModule(FileChooseContract.View view){
this.view = view;
}
@Provides
public FileChooseContract.View providerHomeView(){
return this.view;
}
}
A-52
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.35 FileChooseContract.java
package com.example.fyp2_tsk.home.presenter;
import com.example.fyp2_tsk.common.base.IBaseView;
import com.example.fyp2_tsk.home.bean.MusicInfo;
import java.util.List;
A-53
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.36 HomeContract.java
package com.example.fyp2_tsk.home.presenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import com.example.fyp2_tsk.common.base.IBaseView;
float getSeekBarAbsoluteMaxValue();
//Gets the corresponding value for the seekbar min thumb slider
int getSeekbarSelectedMinValue();
//Gets the corresponding value for the seekbar Max thumb slider
int getSeekbarSelectedMaxValue();
//set the background of the play button according to the play status
void setPlayBtnWithStatus(boolean isPlayingStatus);
//Seekbar sets whether the seekbar slider is available (it can be slid)
void setSeekBarEnable(boolean isEnable);
//trim successful
void doCutterSucc(String path);
A-54
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
//trim failed
void doCutterFail();
interface Presenter{
//switch between play and pause
void playToggle(Activity activity);
void pause();
void onDestroy();
A-55
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.37 FileChoosePresenter.java
package com.example.fyp2_tsk.home.presenter;
import android.os.Environment;
import com.example.fyp2_tsk.common.app.MyApplication;
import com.example.fyp2_tsk.common.base.BasePresenter;
import com.example.fyp2_tsk.common.utils.Mp3ScanUtils;
import com.example.fyp2_tsk.home.bean.MusicInfo;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import io.objectbox.Box;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
//Force rescan and update the database, if the database has the data then update from
the existing database
public void loadFile(final boolean isforceScan){
Observable.create(new ObservableOnSubscribe() {
@Override
public void subscribe(ObservableEmitter e) throws Exception {
A-56
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
List<MusicInfo> datas = mBox.getAll();
if(datas==null||datas.size()<=0||isforceScan) {
datas = new ArrayList<>();
}
if(isforceScan) {
addDataToDB(datas);
}
else{
if(datas.size()<=0)
addDataToDB(datas);
}
e.onNext(datas);
}
}).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.newThread())
.subscribe(new Consumer<List<MusicInfo>>() {
@Override
public void accept(List<MusicInfo> datas) throws Exception {
if(mView!=null)
mView.getMusicList(datas);
}
});
}
A-57
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.38 HomePresenter
package com.example.fyp2_tsk.home.presenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.text.TextUtils;
import android.widget.Toast;
import com.example.fyp2_tsk.common.app.MyApplication;
import com.example.fyp2_tsk.common.base.BasePresenter;
import com.example.fyp2_tsk.common.constant.CommonConstant;
import com.example.fyp2_tsk.common.utils.FileUtils;
import com.example.fyp2_tsk.home.bean.MusicInfo;
import com.example.fyp2_tsk.home.ui.CutFragment;
import com.example.fyp2_tsk.home.ui.FileChooserActivity;
import com.example.fyp2_tsk.mp3cut.logic.Mp3CutLogic;
import com.example.fyp2_tsk.mp3cut.logic.Mp3InfoUtils;
import com.example.fyp2_tsk.mp3cut.util.Mp3NameConvertUtils;
import com.example.fyp2_tsk.R;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
@Inject
public HomePresenter(HomeContract.View view) {
super(view);
init();
}
A-59
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mDisposable = null;
}
}
//trim music
@Override
public void doCutter(final String mp3Title, final long minValue, final long maxValue) {
Observable.create(new ObservableOnSubscribe() {
@Override
public void subscribe(ObservableEmitter e) throws Exception {
Mp3CutLogic helper = new Mp3CutLogic(new File(mSelMp3Path));
if (FileUtils.bFolder(CommonConstant.RING_FOLDER)) {
if (!TextUtils.isEmpty(mp3Title)) {
String targetMp3FilePath = CommonConstant.RING_FOLDER + "/" +
mp3Title + ".mp3";
try {
helper.generateNewMp3ByTime(targetMp3FilePath, minValue,
maxValue);
addMp3ToDb(mp3Title, targetMp3FilePath);
e.onNext(targetMp3FilePath);
} catch (Exception e1) {
e.onError(e1);
}
}
}
}
}).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.newThread())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
@Override
public void onNext(String value) {
String cutterPath = value;
if (mView != null) {
mView.doCutterSucc(cutterPath);
}
}
@Override
public void onError(Throwable e) {
A-60
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if (mView != null) {
mView.doCutterFail();
}
}
@Override
public void onComplete() {
}
});
}
@Override
public void playToggle(Activity activity) {
if (isPlaying()) {
pause();
} else {
play(activity);
}
@Override
public void pause() {
if (isPlaying()) {
mMediaPlayer.pause();
A-61
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mView.setPlayBtnWithStatus(false);
mView.setVisualizerViewEnaled(false);
cancelUpdateProgress();
}
}
@Override
public void play(Activity activity) {
if (TextUtils.isEmpty(mSelMp3Path)) {
Toast.makeText(activity, activity.getString(R.string.dialog_cutter_warning_sel),
Toast.LENGTH_SHORT).show();
return;
}
mMediaPlayer.start();
mView.setPlayBtnWithStatus(true);
mView.setVisualizerViewEnaled(true);
seekToForIsMin();
//start the progress rx polling event
mDisposable = mUpdateProgressObservable.observeOn(AndroidSchedulers.mainThread()).
subscribe(mUpdateProgressConsumer);
}
A-62
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
@Override
public void seekToForIsMin(boolean isMinBar) {
if (judgeIsPlayingThumb(isMinBar)) {
int curValue;
if (isMinBar) {
A-63
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
curValue = mView.getSeekbarSelectedMinValue();
} else {
curValue = mView.getSeekbarSelectedMaxValue();
}
seekTo(curValue);
}
}
/**
* //determines whether the sliding slider is the currently playing slider
* @param isMinBar Sliding slider true: min false: max
*/
A-64
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
reset();
setDataSource(mSelMp3Path);
prepare();
mView.setSeekBarMaxValue(getDuration());
mView.checkRecordPermission(getMediaPlayer());
mView.addBarGraphRenderers();
}
} catch (IllegalArgumentException e) { // Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {// Auto-generated catch block
e.printStackTrace();
}
}
}
@Override
public void onDestroy() {
if (mDisposable != null) {
mDisposable.dispose();
mDisposable = null;
}
}
@Override
public void setStreamVolume(int progress) {
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC progress, 0);
}
@Override
public int getStreamMaxVolume() {
return mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
}
@Override
public int getStreamVolume() {
return mAudioManager
.getStreamVolume(AudioManager.STREAM_MUSIC);
}
}
A-65
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.39 CutFragment.java
package com.example.fyp2_tsk.home.ui;
import android.Manifest;
import android.app.ActivityOptions;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Paint;
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.os.Build;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Toast;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.common.base.BaseFragment;
import com.example.fyp2_tsk.common.constant.CommonConstant;
import com.example.fyp2_tsk.common.ui.view.CommonDialog;
import com.example.fyp2_tsk.common.ui.view.visualizer.renderer.CircleBarRenderer;
import com.example.fyp2_tsk.common.utils.FileUtils;
import com.example.fyp2_tsk.common.utils.RingTools;
import com.example.fyp2_tsk.databinding.FragmentCutBinding;
import com.example.fyp2_tsk.home.di.DaggerHomeComponent;
import com.example.fyp2_tsk.home.di.HomeModule;
import com.example.fyp2_tsk.home.presenter.HomeContract;
import com.zyl.customrangeseekbar.CustomRangeSeekBar;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.home.presenter.HomePresenter;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnNeverAskAgain;
import permissions.dispatcher.OnPermissionDenied;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
A-66
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
import permissions.dispatcher.RuntimePermissions;
@RuntimePermissions
public class CutFragment extends BaseFragment<HomeContract.View, HomePresenter,
FragmentCutBinding> implements HomeContract.View, View.OnClickListener {
public static final int REQUEST_CODE = 1010;
private ProgressDialog mProgressDialog;
private SharedPreferences mPreferences;
private SharedPreferences.Editor mEditor;
String status;
// Music slider event
private CustomRangeSeekBar.ThumbListener mThumbListener = new
CustomRangeSeekBar.ThumbListener() {
@Override
public void onClickMinThumb(Number max, Number min) {
}
@Override
public void onClickMaxThumb() {
}
@Override
public void onMinMove(Number max, Number min) {
mPresenter.seekToForIsMin(true);
}
@Override
public void onMaxMove(Number max, Number min) {
mPresenter.seekToForIsMin(false);
}
@Override
public void onUpMinThumb(Number max, Number min) {
}
@Override
public void onUpMaxThumb() {
}
};
A-67
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
CutFragmentPermissionsDispatcher.setRingWithPermissionCheck(CutFragment.this, path);
}
})
.build().show();
}
@NeedsPermission(Manifest.permission.WRITE_SETTINGS)
public void setRing(final String path) {
if (FileUtils.bFolder(CommonConstant.RING_FOLDER)) {
RingTools.setRing(getActivity(), RingtoneManager.TYPE_RINGTONE, path);
}
}
A-68
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onDestroy() {
super.onDestroy();
mPresenter.onDestroy();
}
@Override
protected void ComponentInject(AppComponent appComponent) {
DaggerHomeComponent
.builder()
.appComponent(appComponent)
.homeModule(new HomeModule(this))
.build()
.inject(this);
}
@Override
protected void init(View view) {
mPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
mEditor = mPreferences.edit();
init();
initListener();
}
@Override
protected int initLayoutResId() {
return R.layout.fragment_cut;
}
A-69
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mDataBinding.rangeSeekbar.setEnabled(false);
mDataBinding.voiceSeekbar.setOnSeekBarChangeListener(mVoiceChangeListener);
}
@Override
public void setVisualizerViewEnaled(boolean enabled) {
mDataBinding.visualView.setEnabled(enabled);
}
@Override
public void checkRecordPermission(MediaPlayer mediaPlayer) {
CutFragmentPermissionsDispatcher.linkMediaPlayerForVisualViewWithPermissionCheck (this,
mediaPlayer);
}
@Override
public int getSeekbarSelectedMaxValue() {
Number number = mDataBinding.rangeSeekbar.getSelectedAbsoluteMaxValue();
return number.intValue();
}
@Override
public float getSeekBarAbsoluteMaxValue() {
return mDataBinding.rangeSeekbar.getAbsoluteMaxValue();
}
@Override
public int getSeekbarSelectedMinValue() {
Number number = mDataBinding.rangeSeekbar.getSelectedAbsoluteMinValue();
return number.intValue();
}
@Override
public void setPlayBtnWithStatus(boolean isPlayingStatus) {
if (isPlayingStatus) {
mDataBinding.btnPlay.setBackgroundResource(R.drawable.selector_pause_btn);
} else {
mDataBinding.btnPlay.setBackgroundResource(R.drawable.selector_play_btn);
}
}
A-70
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
@NeedsPermission(Manifest.permission.RECORD_AUDIO)
public void linkMediaPlayerForVisualView(MediaPlayer player) {
mDataBinding.visualView.link(player);
}
@Override
public boolean setSeekBarProgressValue(int value, boolean isMin) {
if (isMin) {
return mDataBinding.rangeSeekbar.setSelectedAbsoluteMinValue(value);
} else {
return mDataBinding.rangeSeekbar.setSelectedAbsoluteMaxValue(value);
}
}
@Override
public void setSeekBarMaxValue(int value) {
mDataBinding.rangeSeekbar.setAbsoluteMaxValue(value);
}
@Override
public void doCutterSucc(final String path) {
Observable.timer(2000, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
A-71
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
.subscribe(new Consumer<Long>() {
@Override
public void accept(Long aLong) throws Exception {
if (mProgressDialog != null && getActivity() != null
&& !getActivity().isFinishing()) {
mProgressDialog.dismiss();
showCutterSuccessDialog(path);
}
}
});
@Override
public void doCutterFail() {
if (mProgressDialog != null && getActivity() != null
&& !getActivity().isFinishing()) {
mProgressDialog.dismiss();
}
Toast.makeText(getActivity(),
getResources().getString(R.string.homefragment_cut_fail), Toast.LENGTH_LONG).show();
}
/**
* Prompt out dialog box while trimming audio
*/
public void showCutterPromptDialog() {
final Number minNumber = mDataBinding.rangeSeekbar.getSelectedAbsoluteMinValue();
final Number maxNumber = mDataBinding.rangeSeekbar.getSelectedAbsoluteMaxValue();
if (maxNumber.intValue() <= minNumber.longValue()) {
Toast.makeText(getActivity(),
getString(R.string.dialog_cutter_warning_length),
Toast.LENGTH_LONG).show();
return;
}
mPresenter.pause();
new
CommonDialog.Builder().setContext(getActivity()).setContentStr(getString(R.string. dialog_cut
ter_msg))
.setIsShowInput(true)
.setOnDialogListener(new CommonDialog.OnDialogClickListener() {
@Override
public void doOk(String filename) {
mProgressDialog = ProgressDialog.show(getActivity(),
A-72
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
getResources().getString(R.string.homefragment_cutting_tip),
getResources().getString(R.string.homefragment_cutting));
mPresenter.doCutter(filename, minNumber.longValue(),
maxNumber.longValue());
}
})
.build().show();
}
@Override
public void onStop() {
super.onStop();
mPresenter.pause();
setPlayBtnWithStatus(false);
}
@OnShowRationale(Manifest.permission.RECORD_AUDIO)
void showRationaleForRecord(final PermissionRequest request) {
new CommonDialog.Builder().setContext(getActivity()).setContentStr(
getResources().getString(R.string.homefragment_permission_prompt))
.setOnDialogListener(new CommonDialog.OnDialogClickListener() {
@Override
public void doOk() {
request.proceed();
}
}).setIsShowOne(true).build().show();
}
@OnPermissionDenied(Manifest.permission.RECORD_AUDIO)
void showRecordDenied() {
Toast.makeText(getActivity(),
getResources().getString(R.string.homefragment_permission_denied),
Toast.LENGTH_LONG).show();
}
@OnNeverAskAgain(Manifest.permission.RECORD_AUDIO)
void onRecordNeverAskAgain() {
}
@Override
A-73
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// NOTE: delegate the permission handling to generated method
CutFragmentPermissionsDispatcher.onRequestPermissionsResult(this, requestCode,
grantResults);
}
@Override
public boolean shouldShowRequestPermissionRationale(@NonNull String permission) {
return super.shouldShowRequestPermissionRationale(permission);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.btn_play:
mPresenter.playToggle(getActivity());
break;
case R.id.btn_cutter_sure:
if (mPresenter.isSelectedMp3(getActivity()))
showCutterPromptDialog();
break;
default:
break;
}
}
A-74
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
R.string.sdcard_unmonted_hint, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onResume() {
super.onResume();
status = mPreferences.getString(getString(R.string.statusNightMode), "false");
if (status.equals("true"))
updateUI(status);
else
updateUI(status);
}
}
A-75
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.40 FileChooserActivity.java
package com.example.fyp2_tsk.home.ui;
import android.Manifest;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.text.TextUtils;
import android.transition.TransitionInflater;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.common.base.BaseActivity;
import com.example.fyp2_tsk.common.utils.DensityUtils;
import com.example.fyp2_tsk.common.utils.FileUtils;
import com.example.fyp2_tsk.common.utils.ScreenUtils;
import com.example.fyp2_tsk.databinding.ActivityFilechooserShowBinding;
import com.example.fyp2_tsk.home.di.DaggerFileChooseComponent;
import com.example.fyp2_tsk.home.presenter.FileChoosePresenter;
import com.jaeger.library.StatusBarUtil;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.home.bean.MusicInfo;
import com.example.fyp2_tsk.home.di.FileChooseModule;
import com.example.fyp2_tsk.home.presenter.FileChooseContract;
import java.util.ArrayList;
import java.util.List;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnNeverAskAgain;
import permissions.dispatcher.RuntimePermissions;
import skin.support.widget.SkinCompatToolbar;
A-76
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@RuntimePermissions
public class FileChooserActivity extends BaseActivity<FileChooseContract.View,
FileChoosePresenter, ActivityFilechooserShowBinding> implements OnClickListener,
FileChooseContract.View{
private CommonAdapter mAdapter;
private ArrayList<MusicInfo> mMusicList = new ArrayList<>();
public static final String EXTRA_FILEPATH_CHOOSER = "filepath_chooser";
public static final String EXTRA_FILE_CHOOSER = "file_chooser";
private ObjectAnimator mMoveAnim;
private int mUpdateBtnLeft;
StatusBarUtil.setColor(this, Color.TRANSPARENT);
mDataBinding.btnUpdate.setOnClickListener(this);
mDataBinding.btnUpdate.measure(0, 0);
mUpdateBtnLeft = ScreenUtils.getScreenSize(this)[0] -
mDataBinding.btnUpdate.getMeasuredWidth() - DensityUtils.dp2px(this ,10);
initToolbar();
mDataBinding.rlMusice.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new CommonAdapter<MusicInfo>(this, R.layout.item_musicfile, mMusicList) {
@Override
protected void convert(ViewHolder holder, final MusicInfo musicInfo, int
position) {
holder.setText(R.id.tv_name, musicInfo.getTitle());
holder.setText(R.id.tv_size,
FileUtils.formetFileSize(musicInfo.getFileSize()));
if(TextUtils.isEmpty(musicInfo.getCoverPath())){
holder.setImageDrawable(R.id.iv_icon,
getResources().getDrawable(R.mipmap.music_icon));
}
else {
RequestOptions options = new
RequestOptions().placeholder(R.mipmap.music_icon);
Glide.with(FileChooserActivity.this).load(musicInfo.getCoverPath())
.apply(options).into((ImageView) holder.getView(R.id.iv_icon));
A-77
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
holder.itemView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
clickItem(musicInfo);
}
});
}
};
mDataBinding.rlMusice.setAdapter(mAdapter);
mDataBinding.rlMusice.addItemDecoration(new DividerItemDecoration(this,
DividerItemDecoration.VERTICAL));
FileChooserActivityPermissionsDispatcher. refreshDataWithPermissionCheck(this,
false);
}
@Override
protected void ComponentInject(AppComponent appComponent) {
DaggerFileChooseComponent
.builder()
.appComponent(appComponent)
.fileChooseModule(new FileChooseModule(this))
.build()
.inject(this);
}
@Override
protected int initLayoutResId() {
return R.layout.activity_filechooser_show;
}
@Override
protected void initData(Bundle savedInstanceState) {
A-78
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
private void initToolbar() {
SkinCompatToolbar toolbar = (SkinCompatToolbar) findViewById(R.id. toolbar);
toolbar.setBackgroundResource(R.color.theme_color);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE})
void refreshData(final boolean isforce) {
if (mDataBinding.aviLoading.isShown())
return;
startLoadingAnim();
mPresenter.loadFile(isforce);
}
A-79
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public void backProcess() {
setResult(RESULT_CANCELED);
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.btn_update:
FileChooserActivityPermissionsDispatcher.refreshDataWithPermissionCheck(this, true);
break;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
FileChooserActivityPermissionsDispatcher. onRequestPermissionsResult(this,
requestCode, grantResults);
}
@OnNeverAskAgain({Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE})
void onRecordNeverAskAgain() {
Toast.makeText(FileChooserActivity.this,
getResources().getString(R.string.filechoose_permission_denied),
Toast.LENGTH_SHORT).show();
}
@Override
public void getMusicList(List<MusicInfo> musiclist) {
mMusicList.clear();
mMusicList.addAll(musiclist);
stopLoadingAnim();
if (mAdapter != null) {
A-80
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mAdapter.notifyDataSetChanged();
}
}
}
A.41 Mp3NameConvertUtils.java
package com.example.fyp2_tsk.mp3cut.util;
A-81
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.42 Mp3InfoUtils.java
package com.example.fyp2_tsk.mp3cut.logic;
import com.example.fyp2_tsk.common.app.MyApplication;
import com.example.fyp2_tsk.common.utils.Md5Utils;
import org.jaudiotagger.audio.mp3.MP3File;
import org.jaudiotagger.tag.id3.AbstractID3v2Frame;
import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
import org.jaudiotagger.tag.id3.framebody.FrameBodyAPIC;
import java.io.File;
import java.io.FileOutputStream;
//If it is in non-overlay mode, the image will be returned directly (no longer
created)
if (!cover) {
File tempFile = new File(mp3ImageFullPath);
if (tempFile.exists()) {
return mp3ImageFullPath;
}
}
A-83
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.43 Mp3CutLogic.java
package com.example.fyp2_tsk.mp3cut.logic;
import com.example.fyp2_tsk.common.utils.FileUtils;
import org.jaudiotagger.audio.mp3.MP3AudioHeader;
import org.jaudiotagger.audio.mp3.MP3File;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
//Generate new mp3 files according to time (support VBR and CBR respectively)
public void generateNewMp3ByTime(String targetFileStr, long beginTime, long endTime)
throws Exception {
MP3File mp3 = new MP3File(this.mSourceMp3File);
MP3AudioHeader header = (MP3AudioHeader) mp3.getAudioHeader();
if (header.isVariableBitRate()) {
generateMp3ByTimeAndVBR(header, targetFileStr, beginTime, endTime);
} else {
generateMp3ByTimeAndCBR(header, targetFileStr, beginTime, endTime);
}
}
//Generate MP3 files based on time and source files (source file mp3 bit rate is vbr
variable bit rate)
private void generateMp3ByTimeAndVBR(MP3AudioHeader header, String targetFileStr, long
beginTime, long endTime) throws IOException {
long frameCount = header.getNumberOfFrames();
int sampleRate = header.getSampleRateAsNumber();
int sampleCount = 1152;//header.getNoOfSample();
int paddingLength = header.isPadding() ? 1 : 0;
//Frame size = (number of samples per frame × bit rate (bit / s) ÷ 8 ÷ sampling
rate) + Padding
//getBitRateAsNumber The returned is kbps, so * 1000
float frameSize = sampleCount * header.getBitRateAsNumber() / 8f / sampleRate * 1000
A-84
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
+ paddingLength;
//Generate MP3 files based on time and source files (source file mp3 bit rate is cbr
constant bit rate)
private void generateMp3ByTimeAndCBR(MP3AudioHeader header, String targetFileStr, long
beginTime, long endTime) throws IOException {
//Get audio track duration
int trackLengthMs = header.getTrackLength() * 1000;
long bitRateKbps = header.getBitRateAsNumber();
//Get the byte position of the file where the start time is
long beginByte = firstFrameByte + beginBitRateBpm;
A-85
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
private void generateTargetMp3File(String targetFileStr, long beginByte, long endByte,
long firstFrameByte) throws IOException {
File file = new File(targetFileStr);
//Delete if it exists
FileUtils.checkAndDelFile(file);
RandomAccessFile targetMp3File = null;
RandomAccessFile sourceFile = null;
try {
targetMp3File = new RandomAccessFile(targetFileStr, "rw");
sourceFile = new RandomAccessFile(mSourceMp3File, "rw");
//write mp3 header info
writeSourceToTargetFileWithBuffer(targetMp3File, sourceFile, firstFrameByte, 0);
//write mp3 frame info
int size = (int) (endByte - beginByte);
writeSourceToTargetFileWithBuffer(targetMp3File, sourceFile, size, beginByte);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (sourceFile != null)
sourceFile.close();
if (targetMp3File != null)
targetMp3File.close();
}
}
//KBPS kilobytes per second convert into BPM bytes per millisecond
private long convertKbpsToBpm(long bitRate) {
return bitRate * 1024L / 8L / 1000L;
}
//Write source file to target file in cache according to file and size
private static void writeSourceToTargetFileWithBuffer(RandomAccessFile targetFile,
RandomAccessFile sourceFile, long totalSize, long offset) throws Exception {
//buffer size, each time the specified data is written to prevent memory leaks
int buffersize = BUFFER_SIZE;
long count = totalSize / buffersize;
if (count <= 1) {
//The total file length is less than the buffer size
writeSourceToTargetFile(targetFile, sourceFile, new byte[(int) totalSize],
offset);
} else {
// Size remaining after writing count
long remainSize = totalSize % buffersize;
byte data[] = new byte[buffersize];
A-86
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
//The offset of seek when a file is read in
for (int i = 0; i < count; i++) {
writeSourceToTargetFile(targetFile, sourceFile, data, offset);
offset += BUFFER_SIZE;
}
if (remainSize > 0) {
writeSourceToTargetFile(targetFile, sourceFile, new byte[(int) remainSize],
offset);
}
}
}
A-87
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.44 AllFragment.java
package com.example.fyp2_tsk.other;
import android.Manifest;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.Toast;
import com.lwkandroid.widget.indexbar.IndexBar;
import com.example.fyp2_tsk.utils.Common;
import com.master.permissionhelper.PermissionHelper;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.adapter.MusicAdapter;
import com.example.fyp2_tsk.entity.Music;
import java.util.List;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_all, container, false);
//Create a View object and return to the view
@Override
public void onIndividualPermissionGranted(String[] grantedPermission) {
Log.d(TAG, "onIndividualPermissionGranted() called with: grantedPermission =
[" + TextUtils.join(",", grantedPermission) + "]");
}
@Override
public void onPermissionDenied() {
Log.d(TAG, "onPermissionDenied() called");
}
@Override
public void onPermissionDeniedBySystem() {
Log.d(TAG, "onPermissionDeniedBySystem() called");
}
});
A-89
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
for (Music m : Common.musicList) {
m.isPlaying = false;
}
Common.musicList.get(position).isPlaying = true;
//update UI
adapter.notifyDataSetChanged();
//filter
svSearch = (SearchView) view.findViewById(R.id.edSearch);
svSearch.setQueryHint("Search here");
svSearch.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
if (TextUtils.isEmpty(s)){
adapter.filter("");
listView.clearTextFilter();
}
else {
adapter.filter(s);
}
return true;
}
});
int searchCloseButtonId =
svSearch.getContext().getResources().getIdentifier("android:id/search_close_btn", null,
null);
ImageView closeButton = (ImageView) view.findViewById(searchCloseButtonId);
A-90
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
svSearch.onActionViewCollapsed();
}
});
@Override
public void onLetterChanged(CharSequence indexChar, int index, float y)
{
// TODO will call back when the index letter changes
svSearch.setQuery(indexChar,false);
svSearch.onActionViewExpanded();
}
});
// permission
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (permissionHelper != null) {
permissionHelper.onRequestPermissionsResult(requestCode, permissions,
grantResults);
}
}
A-91
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
//Create the cursor MediaStore.Audio.Media.EXTERNAL_CONTENT_URI to get the audio
file, the latter is about selecting the filter conditions, fill in null here.
Cursor cursor = resolver.query(MediaStore.Audio.Media. EXTERNAL_CONTENT_URI, null,
null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
if(cursor.moveToFirst()){
do {
String title =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. TITLE));
String artist =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. ARTIST));
String album =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM));
int albumID =
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
int length =
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
String path =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. DATA));
Common.musicList.add(music);
Common.musicList_backup.add(music);
} while (cursor.moveToNext());
}
else {
Toast.makeText(getActivity(), "No local music", Toast.LENGTH_SHORT).show();
}
cursor.close();
}
A-92
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
String album_art = null;
if (cur.getCount() > 0 && cur.getColumnCount() > 0) {
cur.moveToNext();
album_art = cur.getString(0);
}
cur.close();
Bitmap bm = null;
if (album_art != null) {
bm = BitmapFactory.decodeFile(album_art);
} else {
bm = BitmapFactory.decodeResource(getResources(), R.mipmap.touxiang1);
}
return bm;
}
@Override
public void onResume() {
super.onResume();
adapter.notifyDataSetChanged();
}
if(cursor.moveToFirst()){
do {
String title =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
String artist =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. ARTIST));
String album =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. ALBUM));
int albumID =
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
int length =
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
String path =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media.DATA));
A-93
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Music music = new Music();
music.length = length;
music.title = title;
music.artist = artist;
music.album = album;
music.path = path;
music.albumBip = getAlbumArt(albumID);
A-94
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if(cursor.moveToFirst()){
do {
String title =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. TITLE));
String artist =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. ARTIST));
String album =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. ALBUM));
int albumID =
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
int length =
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media.DURATION));
String path =
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Media. DATA));
if (!firstC.equals("A")
&& !firstC.equals("B")&& !firstC.equals("C")&& !firstC.equals("D")&& !firstC.equals("E")&& !
firstC.equals("F")
A-95
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
firstC.equals("o")&& !firstC.equals("p")
&& !firstC.equals("q")&& !firstC.equals("r")&& !firstC.equals("s")&& !firstC.equals("t")&& !
firstC.equals("u")&& !firstC.equals("v")
&& !firstC.equals("w")&& !firstC.equals("x")&& !firstC.equals("y")&& !firstC.equals("z")){
Common.musicList.add(music);
Common.musicList_backup.add(music);
}
else ;
} while (cursor.moveToNext());
}else {
Toast.makeText(getActivity(), "Local No Music", Toast.LENGTH_SHORT).show();
}
cursor.close();
adapter = new MusicAdapter(getActivity(), musicList);
listView.setAdapter(adapter);
}
A-96
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.45 DriverMusicActivity.java
package com.example.fyp2_tsk.other;
import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.fyp2_tsk.Gesture.DetectSwipeGestureDriver;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.entity.Music;
import com.example.fyp2_tsk.utils.BlurUtil;
import com.example.fyp2_tsk.utils.Common;
import java.io.IOException;
A-97
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//create full screen Activity
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.F
LAG_FULLSCREEN);
setContentView(R.layout.activity_driver);
bingID();
if (Common.musicList.get(position).albumBip != null) {
Bitmap bgbm = BlurUtil.doBlur(Common.musicList.get(position).albumBip, 10,
A-98
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
5);//Blur the album pic
bgImgvDriver.setImageBitmap(bgbm);//Set the blurred album picture as background
} else {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.mipmap.touxiang1);
bgImgvDriver.setImageBitmap(bitmap);
}
try {
mediaPlayer.setDataSource(path);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onCompletion(MediaPlayer mp) {
if (!mediaPlayer.isPlaying()) {
setPlayMode();
}
}
});
} catch (IllegalArgumentException | SecurityException | IllegalStateException
| IOException e) {
e.printStackTrace();
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void setPlayMode() {
//Loop all in orderly
if (playMode == 0) {
if (position == Common.musicList.size() - 1)//Loop by default
{
position = 0;// first song
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
} else {
position++;
mediaPlayer.reset();
A-99
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
prevAndnextplaying(Common.musicList.get(position).path);
}
}
//single cycle
else if (playMode == 1){
//position no need to change
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setBtnMode() {
if (playMode == 0)//Loop all in orderly
{
if (position == Common.musicList.size() - 1)//Loop by default
{
if (buttonWitch == 1) {
position--;
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
} else if (buttonWitch == 2) {
position = 0;
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
}
} else if (position == 0) {
if (buttonWitch == 1) {
position = Common.musicList.size() - 1;
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
} else if (buttonWitch == 2) {
position++;
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
A-100
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
} else {
if (buttonWitch == 1) {
position--;
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
} else if (buttonWitch == 2) {
position++;
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
}
}
}
mediaPlayer.reset();
prevAndnextplaying(Common.musicList.get(position).path);
}
A-101
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.music_prev_imgv_driver:
buttonWitch = 1;
setBtnMode();
break;
case R.id.music_next_imgv_driver:
buttonWitch = 2;
setBtnMode();
break;
case R.id.music_pause_imgv_driver:
if (mediaPlayer.isPlaying()) {
mediaPlayer.pause();
pauseImgvDriver.setImageResource(R.mipmap.ic_play_btn_play);
} else {
mediaPlayer.start();
pauseImgvDriver.setImageResource(R.mipmap.ic_play_btn_pause);
}
break;
case R.id.music_down_imgv_driver:
this.finish();
Intent intent = new Intent(DriverMusicActivity.this, MusicActivity.class);
intent.putExtra("position", position);
startActivity(intent);
break;
default: break;
}
}
@Override
protected void onPause() {
super.onPause();
for (Music music : Common.musicList) {
music.isPlaying = false;
}
Common.musicList.get(position).isPlaying = true;
}
@Override
protected void onStop() {
A-102
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
i = 0;
isStopDriver = false;
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
if (mediaPlayer != null) {
mediaPlayer.stop();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
gestureDetectorCompat.onTouchEvent(event);
return true;
}
}
A-103
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.46 MainActivity.java
package com.example.fyp2_tsk.other;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.SleepTimer.AppPreference;
import com.example.fyp2_tsk.SleepTimer.AuxiliaryPreference;
import com.example.fyp2_tsk.SleepTimer.BroadcastManager;
import com.example.fyp2_tsk.SleepTimer.PeriodicTask;
import com.example.fyp2_tsk.SleepTimer.ThemeChangeable;
import com.example.fyp2_tsk.SleepTimer.ThemeEnum;
import com.example.fyp2_tsk.SleepTimer.TimeSleepActivity;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.common.base.BaseActivity;
import com.example.fyp2_tsk.common.base.BasePresenter;
import com.example.fyp2_tsk.common.base.IBaseView;
import com.example.fyp2_tsk.databinding.ActivityMainBinding;
import com.example.fyp2_tsk.skin.ThemeColorSelectDialog;
import com.example.fyp2_tsk.utils.ColorUtils;
import com.jaeger.library.StatusBarUtil;
import com.orhanobut.logger.Logger;
A-104
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
import com.example.fyp2_tsk.home.ui.CutFragment;
//shared preferences
private SharedPreferences mPreferences;
private SharedPreferences.Editor mEditor;
Bundle b;
Boolean nightFlag = false;
String statusFlag;
@Override
protected void ComponentInject(AppComponent appComponent) {
@Override
protected int initLayoutResId() {
//create full screen Activity
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
return R.layout.activity_main;
}
@Override
protected void initData(Bundle savedInstanceState) {
A-105
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
initView();
mCutFragment = new CutFragment();
mMusicFragment = new MusicFragment();
switchToMusic();
StatusBarUtil.setColorForDrawerLayout(MainActivity.this, mDataBinding.drawerlayout,
Color.TRANSPARENT);
auxiliaryPreference = new AuxiliaryPreference(this);
}
b = new Bundle();
broadcastManager = BroadcastManager.getInstance();
appPreference = new AppPreference(this); // to get theme color for night mode
feature
checkTheme(); // use appPreference to decide show white or black color background
//register broadcast
initBroadcastReceivers();
initToolBar();
initDrawer();
initNavigationView();
}
setSupportActionBar(mDataBinding.toolbar);
}
A-106
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
case R.id.item_cut:
switchToCutPage();
break;
case R.id.item_download:
switchToDownload();
break;
case R.id.item_music:
switchToMusic();
break;
case R.id.item_sleeptimer:
startActivity(new Intent(MainActivity.this,
TimeSleepActivity.class));
break;
case R.id.item_night_mode:
handleModeSwitch();
break;
case R.id.item_exit:
android.os.Process.killProcess(android.os.Process.myPid());
finish();
break;
A-107
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
invalidateOptionsMenu();
menuItem.setChecked(isNeedChecked);
mDataBinding.drawerlayout.closeDrawers();
return true;
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (mCurFragment instanceof CutFragment) {
menu.findItem(R.id.home_item_open).setVisible(true);
A-108
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
} else {
menu.findItem(R.id.home_item_open).setVisible(false);
}
Logger.d("onPrepareOptionsMenu: visible" + (mCurFragment instanceof CutFragment));
return super.onPrepareOptionsMenu(menu);
}
A-109
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
BroadcastManager.Countdown.STOP_COUNTDOWN);
if (status == BroadcastManager.Countdown.STOP_COUNTDOWN) {
stopQuitCountdown(true);
} else {
startQuitCountdown();
}
}
};
//nighmode
appThemeChangeAutomaticReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
int va =
intent.getIntExtra(BroadcastManager.APP_THEME_CHANGE_AUTOMATIC_TOKEN,
BroadcastManager.APP_THEME_CHANGE_AUTOMATIC_WHITE);
ThemeEnum theme = va == BroadcastManager.APP_THEME_CHANGE_AUTOMATIC_WHITE ?
ThemeEnum.WHITE : ThemeEnum.DARK;
appPreference.updateTheme(theme);
switchThemeMode(theme);
}
};
broadcastManager.registerBroadReceiver(this, appQuitTimeCountdownReceiver,
BroadcastManager.FILTER_APP_QUIT_TIME_COUNTDOWN);
broadcastManager.registerBroadReceiver(this, appThemeChangeAutomaticReceiver,
BroadcastManager.FILTER_APP_THEME_CHANGE_AUTOMATIC);
}
A-110
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
auxiliaryPreference.setTimeSleepDisable();
if (resetText) {
resetText();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver();
}
public CountDownTask() {
reset();
A-111
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
item = null;
title = "";
}
}
@Override
public void execute() {
if (dur >= 0 && item != null) {
if (dur == 0) {
if (sec == 0) {
countDownFinish(false);
} else if (sec == 23) { // count down 23 second and then notice user
mDataBinding.navigationView.post(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Mp3 Music Player will
terminate after 20 second.", Toast.LENGTH_SHORT).show();
}
});
}
}
if (sec == 0) {
sec = 59;
dur--;
} else {
sec--;
}
countDown();
} else {
countDownFinish(false);
}
}
A-112
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Toast.LENGTH_LONG).show();
}
/**
* Switch to daily mode and night mode
*/
protected void checkTheme() {
ThemeEnum themeEnum = appPreference.getTheme();
A-113
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if (themeEnum == ThemeEnum.DARK) {
this.setTheme(R.style.Theme_DARK);
} else {
this.setTheme(R.style.Theme_WHITE);
}
}
appPreference.updateTheme(theme);
switchThemeMode(theme);
}
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {
ThemeEnum th = appPreference.getTheme();
int[] cs = ColorUtils.get10ThemeColors(MainActivity.this, th);
int mainBC = cs[3];
int mainTC = cs[5];
int accentC = cs[2];
mDataBinding.navigationView.setItemTextColor(ColorStateList.valueOf(mainTC));
mDataBinding.navigationView.setBackgroundColor(mainBC);
updateSwitchMenuIconAndText();
A-114
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
}
}
Drawable icon;
String title;
A-115
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
title = MainActivity.this.getString(R.string.setting_daytime_mode);
nightFlag = true;
statusFlag = nightFlag.toString();
mEditor.putString(getString(R.string.statusNightMode),statusFlag);
mEditor.commit();
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.detach(mCurFragment);
ft.attach(mCurFragment);
ft.commit();
}
item.setIcon(icon);
item.setTitle(title);
}
}
A-116
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.47 MusicActivity.java
package com.example.fyp2_tsk.other;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.RequiresApi;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.example.fyp2_tsk.Gesture.DetectSwipeGestureListener;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.ShakeControl.ShakeListener;
import com.example.fyp2_tsk.entity.Music;
import com.example.fyp2_tsk.utils.BlurUtil;
import com.example.fyp2_tsk.utils.Common;
import com.example.fyp2_tsk.utils.MergeImage;
import java.io.IOException;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//create full screen Activity
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_music);
bingID();
A-118
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
//Swipe gesture control
DetectSwipeGestureListener swipeGestureListener = new DetectSwipeGestureListener();
swipeGestureListener.setActivity(this);
gestureDetectorCompat = new GestureDetectorCompat(this, swipeGestureListener);
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
A-119
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
buttonWitch = 2;
setBtnMode();
}
if (Common.musicList.get(position).albumBip != null) {
Bitmap bgbm = BlurUtil.doBlur(Common.musicList.get(position).albumBip, 10,
5);//Blur the album image
bgImgv.setImageBitmap(bgbm); //set it as bg
Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(),
R.mipmap.play_page_disc);//BitmapFactory.decodeResource is used to parse and create a Bitmap
object from the specified resource file according to the given resource ID
Bitmap bm = MergeImage.mergeThumbnailBitmap(bitmap1,
Common.musicList.get(position).albumBip);//put bg image on disc
discImagv.setImageBitmap(bm);
} else {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.mipmap.touxiang1);
bgImgv.setImageBitmap(bitmap);
Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(),
R.mipmap.play_page_disc);
Bitmap bm = MergeImage.mergeThumbnailBitmap(bitmap1, bitmap);
discImagv.setImageBitmap(bm);
}
try {
mediaPlayer.setDataSource(path);
mediaPlayer.prepare();
mediaPlayer.start();
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onCompletion(MediaPlayer mp) {
A-120
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if (!mediaPlayer.isPlaying()) {
setPlayMode();
}
}
});
} catch (IllegalArgumentException | SecurityException | IllegalStateException
| IOException e) {
e.printStackTrace();
}
totalTv.setText(formatTime(Common.musicList.get(position).length));
seekBar.setMax(Common.musicList.get(position).length);
A-121
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
rotateAnimation2.setRepeatCount(0);
rotateAnimation2.setFillAfter(true);
needleImagv.setAnimation(rotateAnimation2);
rotateAnimation2.cancel();
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void setPlayMode() {
//All repeat
if (playMode == 0) {
if (position == Common.musicList.size() - 1)//last song position
{
position = 0;// first song
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
} else {
position++;
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
}
//Single cycle
else if (playMode == 1) {
//position no nid to change
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
else if (playMode == 2)//Shuffle playback
{
position = (int) (Math.random() * Common.musicList.size()); //generate random
number
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
}
A-122
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setBtnMode() {
//Repeat playlist
if (playMode == 0) {
// if current play is last song in playlist
if (position == Common.musicList.size() - 1) {
//skip to previous song
if (buttonWitch == 1) {
position--;
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
//skip next song which is first song
else if (buttonWitch == 2) {
position = 0;// First song
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
} else if (position == 0) {
if (buttonWitch == 1) {
position = Common.musicList.size() - 1;
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
} else if (buttonWitch == 2) {
position++;
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
} else {
if (buttonWitch == 1) {
position--;
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
A-123
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
} else if (buttonWitch == 2) {
position++;
mediaPlayer.reset();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
prevAndnextplaying(Common.musicList.get(position).path);
}
}
}
A-124
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
nextImgv = (ImageView) findViewById(R.id.music_next_imgv);
discImagv = (ImageView) findViewById(R.id.music_disc_imagv);
needleImagv = (ImageView) findViewById(R.id.music_needle_imag);
pauseImgv = (ImageView) findViewById(R.id.music_pause_imgv);
downImg = (ImageView) findViewById(R.id.music_down_imgv);
seekBar = (SeekBar) findViewById(R.id.music_seekbar);
styleImg = (ImageView) findViewById(R.id.music_play_btn_loop_img);
driveMode = (ImageView) findViewById(R.id.driver_Mode);
pauseImgv.setOnClickListener(this);
prevImgv.setOnClickListener(this);
nextImgv.setOnClickListener(this);
downImg.setOnClickListener(this);
styleImg.setOnClickListener(this);
driveMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MusicActivity.this, DriverMusicActivity.class);
intent.putExtra("position", position);
startActivity(intent);
MusicActivity.this.finish();
}
});
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.music_prev_imgv:
buttonWitch = 1;
setBtnMode();
break;
case R.id.music_next_imgv:
buttonWitch = 2;
setBtnMode();
break;
case R.id.music_pause_imgv:
if (mediaPlayer.isPlaying()) {
mediaPlayer.pause();
objectAnimator.pause();
needleImagv.startAnimation(rotateAnimation2);
pauseImgv.setImageResource(R.mipmap.ic_play_btn_play);
A-125
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
} else {
mediaPlayer.start();
objectAnimator.resume();
needleImagv.startAnimation(rotateAnimation);
pauseImgv.setImageResource(R.mipmap.ic_play_btn_pause);
}
break;
case R.id.music_play_btn_loop_img:
i++;
if (i % 3 == 1) {
Toast.makeText(MusicActivity.this, "Single cycle",
Toast.LENGTH_SHORT).show();
playMode = 1;
styleImg.setImageResource(R.mipmap.ic_play_btn_one);
}
if (i % 3 == 2) {
Toast.makeText(MusicActivity.this, "Shuffle Playback",
Toast.LENGTH_SHORT).show();
playMode = 2;
styleImg.setImageResource(R.mipmap.ic_play_btn_shuffle);
}
if (i % 3 == 0) {
Toast.makeText(MusicActivity.this, "Normal playback",
Toast.LENGTH_SHORT).show();
playMode = 0;
styleImg.setImageResource(R.mipmap.ic_play_btn_loop);
}
break;
case R.id.music_down_imgv:
this.finish();
break;
default:
break;
}
}
@Override
protected void onPause() {
super.onPause();
for (Music music : Common.musicList
) {
music.isPlaying = false;
}
A-126
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Common.musicList.get(position).isPlaying = true;
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
i = 0;
isStop = false;
if (mediaPlayer.isPlaying()) {
mediaPlayer.stop();
}
if (mediaPlayer != null) {
mediaPlayer.stop();
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
gestureDetectorCompat.onTouchEvent(event);
return true;
}
}
A-127
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.48 ThemeEnum.java
package com.example.fyp2_tsk.SleepTimer;
DARK,
A-128
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.49 MusicFragment.java
package com.example.fyp2_tsk.other;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.view.View;
import com.example.fyp2_tsk.adapter.MusicPagerAdapter;
import com.example.fyp2_tsk.common.app.di.AppComponent;
import com.example.fyp2_tsk.common.base.BaseFragment;
import com.example.fyp2_tsk.common.base.BasePresenter;
import com.example.fyp2_tsk.common.base.IBaseView;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.databinding.FragmentMusicBinding;
import java.util.ArrayList;
import java.util.List;
public MusicFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void ComponentInject(AppComponent appComponent) {
@Override
A-129
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
protected void init(View view) {
init();
}
fragmentList.add(allFragment);
mDataBinding.engLogicTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
allFragment.updateEnglish();
mDataBinding.mainLogicTv.setTextColor(getResources().getColor(R.color. white_60P));
mDataBinding.engLogicTv.setTextColor(getResources().getColor(R.color.white));
mDataBinding.chineseLogicTv.setTextColor(getResources().getColor(R.color.white_60P));
}
});
mDataBinding.chineseLogicTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mDataBinding.mainLogicTv.setTextColor(getResources().getColor(R.color. white_60P));
mDataBinding.engLogicTv.setTextColor(getResources().getColor(R.color.white_60P));
mDataBinding.chineseLogicTv.setTextColor(getResources().getColor(R.color.white));
allFragment.updateOthers();
}
});
A-130
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
mDataBinding.mainLogicTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mDataBinding.mainLogicTv.setTextColor(getResources().getColor(R.color. white));
mDataBinding.engLogicTv.setTextColor(getResources().getColor(R.color.white_60P));
mDataBinding.chineseLogicTv.setTextColor(getResources().getColor(R.color.white_60P));
allFragment.updateAll();
}
});
}
@Override
protected int initLayoutResId() { return R.layout.fragment_music;}
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onDestroy() {super.onDestroy();}
@Override
public void onResume() {
super.onResume();
status = mPreferences.getString(getString(R.string.statusNightMode),"false");
if (!firstTime) {
if (status.equals("true"))
allFragment.updateUI(status);
else
allFragment.updateUI(status);
}
firstTime = false;
}
}
A-131
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.50 RootActivity.java
package com.example.fyp2_tsk.other;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.SleepTimer.AppPreference;
import com.example.fyp2_tsk.SleepTimer.AuxiliaryPreference;
import com.example.fyp2_tsk.SleepTimer.ThemeEnum;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
checkTheme();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onResume() {
super.onResume();
}
A-132
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
@Override
protected void onPause() {
super.onPause();
}
}
A.51 ThemeColor.java
package com.example.fyp2_tsk.skin;
A-133
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.52 SplashActivity.java
package com.example.fyp2_tsk.other;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.fyp2_tsk.databinding.ActivitySplashBinding;
import com.example.fyp2_tsk.utils.Utils;
import com.jaeger.library.StatusBarUtil;
import com.example.fyp2_tsk.R;
import java.util.Random;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//create full screen Activity
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
StatusBarUtil.setColor(this, Color.TRANSPARENT);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_splash);
A-134
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
initViews();
}
tv = new TextView[]{
(TextView) findViewById(R.id.splash_m),
(TextView) findViewById(R.id.splash_u),
(TextView) findViewById(R.id.splash_s),
(TextView) findViewById(R.id.splash_i),
(TextView) findViewById(R.id.splash_c),
(TextView) findViewById(R.id.splash_p),
(TextView) findViewById(R.id.splash_l),
(TextView) findViewById(R.id.splash_a),
(TextView) findViewById(R.id.splash_y),
(TextView) findViewById(R.id.splash_e),
(TextView) findViewById(R.id.splash_r)
};
tv[0].post(new Runnable() {
@Override
public void run() {
for (TextView t : tv) {
t.setVisibility(View.VISIBLE);
startTextInAnim(t);
}
}
A-135
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
});
}
@Override
public void onAnimationEnd(Animator animation) {
startFinalAnim();
}
@Override
public void onAnimationCancel(Animator animation) {
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
set.start();
}
A-136
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
private void startFinalAnim() {
final ImageView image = (ImageView) findViewById(R.id. splash_logo);
final TextView name = (TextView) findViewById(R.id.splash_name);
@Override
public void onAnimationEnd(Animator animation) {
runOnUiThread(new Runnable() {
@Override
public void run() {
goToMainActivity();
}
});
}
@Override
public void onAnimationCancel(Animator animation) {
@Override
public void onAnimationRepeat(Animator animation) {
}
});
A-137
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
set.setInterpolator(new LinearInterpolator());
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
image.setVisibility(View.VISIBLE);
name.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
@Override
public void onAnimationCancel(Animator animation) {
@Override
public void onAnimationRepeat(Animator animation) {
}
});
set.play(alpha).with(alphaN).with(tranY).before(wait);
set.start();
}
}
A-138
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.53 ShakeListener.java
package com.example.fyp2_tsk.ShakeControl;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
start();
}
sensor=sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
}
A-139
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
if(sensor!=null){
@Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
long currentUpdateTime=System.currentTimeMillis();
long timeInterval=currentUpdateTime-lastUpdateTime;
if(timeInterval<UPTATE_INTERVAL_TIME){
return;
}
lastUpdateTime=currentUpdateTime;
float x=event.values[0];
float y=event.values[1];
float z=event.values[2];
float deltaX=x-lastX;
float deltaY=y-lastY;
float deltaZ=z-lastZ;
lastX=x;
lastY=y;
lastZ=z;
double
speed=Math.sqrt(deltaX*deltaX+deltaY*deltaY*deltaZ*deltaZ)/timeInterval*10000;
if(speed>SPEED_SHAKEHOLD){
onShakeListener.onShake();
A-140
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
A-141
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.54 ShakeService.java
package com.example.fyp2_tsk.ShakeControl;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.Vibrator;
import android.util.Log;
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
@Override
public void onShake() {
// TODO Auto-generated method stub
mShakeListener.stop();
startVibrator();
//vibrator.cancel();
mShakeListener.start();
}
} );
}
void startVibrator(){
Log.i(TAG,"shake");
vibrator.vibrate(500);
}
@Override
A-142
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
mShakeListener.start();
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
mShakeListener.stop();
}
}
A-143
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.55 ThemeColorAdapter.java
package com.example.fyp2_tsk.skin;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.example.fyp2_tsk.common.base.EasyRecyclerViewAdapter;
import com.example.fyp2_tsk.R;
import de.hdodenhof.circleimageview.CircleImageView;
@Override
public RecyclerView.ViewHolder onCreate(ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_theme_color, parent, false);
return new ThemeColorViewHolder(view);
}
@Override
public void onBind(final RecyclerView.ViewHolder viewHolder, final int RealPosition,
ThemeColor data) {
((ThemeColorViewHolder)
viewHolder).them_color.setImageResource(data.getDrawableResId());
if (data.isChosen()) {
((ThemeColorViewHolder) viewHolder).chosen.setVisibility(View.VISIBLE);
position=RealPosition;
} else {
((ThemeColorViewHolder) viewHolder).chosen.setVisibility(View.GONE);
}
}
A.56 BasePreference.java
package com.example.fyp2_tsk.SleepTimer;
import android.content.Context;
import android.content.SharedPreferences;
A-145
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.57 ThemeColorSelectDialog.java
package com.example.fyp2_tsk.skin;
import android.content.res.TypedArray;
import android.databinding.DataBindingUtil;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.GridLayoutManager;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import com.example.fyp2_tsk.common.base.EasyRecyclerViewAdapter;
import com.example.fyp2_tsk.common.utils.DensityUtils;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.databinding.DialogThemeColorBinding;
import java.util.ArrayList;
import skin.support.SkinCompatManager;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
final Window window = getDialog().getWindow();
final DisplayMetrics metrics = getResources().getDisplayMetrics();
final DialogThemeColorBinding binding = DataBindingUtil.inflate(inflater,
R.layout.dialog_theme_color, ((ViewGroup) window.findViewById(android.R.id.content)),
false);
init(binding);
initListener(binding);
A-146
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//注意此处
window.setLayout(metrics.widthPixels - DensityUtils.dp2px(getContext(), 30), -2);
return binding.getRoot();
}
A-147
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.58 AppPreference.java
package com.example.fyp2_tsk.SleepTimer;
import android.content.Context;
import android.os.Build;
import android.support.annotation.ColorInt;
import com.example.fyp2_tsk.R;
@ColorInt
public int getActionbarColor() {
int deC;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
deC = context.getColor(R.color.colorPrimary);
} else {
deC = context.getResources().getColor(R.color.colorPrimary);
}
return preferences.getInt(KEY_THEME_ACTIONBAR_COLOR, deC);
}
@ColorInt
public int getStatusBarColor() {
int deC;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
deC = context.getColor(R.color.colorPrimary);
} else {
deC = context.getResources().getColor(R.color.colorPrimary);
A-148
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
return preferences.getInt(KEY_THEME_STATUS_BAR_COLOR, deC);
}
@ColorInt
public int getAccentColor() {
int deC;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
deC = context.getColor(R.color.colorPrimary);
} else {
deC = context.getResources().getColor(R.color.colorPrimary);
}
return preferences.getInt(KEY_THEME_ACCENT_COLOR, deC);
}
editor = preferences.edit();
editor.putString(KEY_THEME, themeEnum.name());
editor.apply();
}
}
A-149
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.59 AuxiliaryPreference.java
package com.example.fyp2_tsk.SleepTimer;
import android.content.Context;
public class AuxiliaryPreference extends BasePreference{
public AuxiliaryPreference(Context context) {
super(context, Preference.AUXILIARY_PREFERENCE);
}
//used as terminate the application regularly
private class TimeSleep {
static final String TIME_SLEEP_ENABLE = "time_sleep_enable";
static final String TIME_SLEEP_START_TIME = "time_sleep_start_time";
static final String TIME_SLEEP_DURATION = "time_sleep_duration";
}
//update the countdown time in real time
public void updateTimeSleep(int duration) {
editor = preferences.edit();
editor.putBoolean(TimeSleep.TIME_SLEEP_ENABLE, true);
editor.putInt(TimeSleep.TIME_SLEEP_DURATION, duration);
editor.putLong(TimeSleep.TIME_SLEEP_START_TIME, System.currentTimeMillis());
editor.apply();
}
//call when countdown time end to set sleep time into disable status
public void setTimeSleepDisable() {
editor = preferences.edit();
editor.putBoolean(TimeSleep.TIME_SLEEP_ENABLE, false);
editor.putInt(TimeSleep.TIME_SLEEP_DURATION, -1);
editor.putLong(TimeSleep.TIME_SLEEP_START_TIME, System.currentTimeMillis());
editor.apply();
}
A-150
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.60 BroadcastManager.java
package com.example.fyp2_tsk.SleepTimer;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.annotation.Nullable;
// Theme change
public static final String FILTER_APP_THEME_CHANGE_AUTOMATIC =
"filter_app_theme_change_automatic";
public static final String APP_THEME_CHANGE_AUTOMATIC_TOKEN =
"filter_app_theme_change_automatic_token";
public static final int APP_THEME_CHANGE_AUTOMATIC_WHITE = 1;
}
A.61 ThemeChangeable.java
package com.example.fyp2_tsk.SleepTimer;
A.62 Common.java
package com.example.fyp2_tsk.utils;
import com.example.fyp2_tsk.entity.Music;
import java.util.ArrayList;
import java.util.List;
A-152
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.63 PeriodicTask.java
package com.example.fyp2_tsk.SleepTimer;
import java.util.Timer;
import java.util.TimerTask;
if (progressUpdateTask != null) {
progressUpdateTask.cancel();
isSchedule = false;
}
}
A.64 Utils.java
package com.example.fyp2_tsk.utils;
import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.Display;
A-154
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.65 TimeSleepActivity.java
package com.example.fyp2_tsk.SleepTimer;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.NumberPicker;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.other.RootActivity;
import com.example.fyp2_tsk.utils.AnimationUtils;
import com.example.fyp2_tsk.utils.ColorUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_time_sleep);
initToolbar();
@Override
protected void onDestroy() {
super.onDestroy();
viewHolder = null;
A-155
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
numberPickerHolder = null;
}
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
viewHolder.initViews();
themeChange(null, null);
initData();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_save, menu);
return super.onCreateOptionsMenu(menu);
A-156
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
case R.id.action_save:
if (time == 0) {
String msg =
getString(R.string.error_time_sleep_time_must_more_then_zero);
Toast.makeText(TimeSleepActivity.this, msg, Toast.LENGTH_SHORT).show();
} else {
if (enable) {
handleSave();
} else {
handleCancelIfEnableBefore();
}
}
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
A-157
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
String ti = getString(R.string.replace_time_sleep_app_quit_at);
String re;
if (time > 60) {
re = time / 60 + " " + getString(R.string.hour) + " " + time % 60 + " " +
getString(R.string.minute);
} else {
re = time + " " + getString(R.string.minute);
}
String str = ti.replace("*", re);
Toast.makeText(this, str, Toast.LENGTH_LONG).show();
Bundle bundle = new Bundle();
bundle.putInt(BroadcastManager.Countdown. APP_QUIT_TIME_COUNTDOWN_STATUS,
BroadcastManager.Countdown.START_COUNTDOWN);
BroadcastManager.getInstance()
.sendBroadcast(this, BroadcastManager.FILTER_APP_QUIT_TIME_COUNTDOWN,
bundle);
finish();
}
@Override
public void themeChange(ThemeEnum themeEnum, int[] colors) {
A-158
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
Switch cwitch;
TextView m10;
TextView m20;
TextView m30;
TextView m45;
TextView m60;
Button custom;
TextView show;
View line;
View[] vs;
public ViewHolder() {
color = ColorUtils.getAccentColor(TimeSleepActivity.this);
}
updateCurrentTimeText();
updateSelected();
}
};
void initViews() {
status = (TextView) findViewById(R.id.time_sleep_status);
A-159
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
cwitch = (Switch) findViewById(R.id.time_sleep_status_switch);
m10 = (TextView) findViewById(R.id.time_sleep_10m);
m20 = (TextView) findViewById(R.id.time_sleep_20m);
m30 = (TextView) findViewById(R.id.time_sleep_30m);
m45 = (TextView) findViewById(R.id.time_sleep_45m);
m60 = (TextView) findViewById(R.id.time_sleep_60m);
custom = (Button) findViewById(R.id.time_sleep_custom);
show = (TextView) findViewById(R.id.time_sleep_custom_show);
line = findViewById(R.id.time_sleep_line);
vs = new View[]{
m10,
m20,
m30,
m45,
m60,
};
cwitch.setOnCheckedChangeListener(this);
m10.setOnClickListener(checkListener);
m20.setOnClickListener(checkListener);
m30.setOnClickListener(checkListener);
m45.setOnClickListener(checkListener);
m60.setOnClickListener(checkListener);
custom.setOnClickListener(customListener);
A-160
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
setEnable(enable);
}
if (numberPickerHolder.custom) {
numberPickerHolder.setEnable(enable);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
enable = isChecked;
setEnable(isChecked);
}
A-161
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
void updateCurrentTimeText() {
String txt = getString(R.string.replace_time_sleep);
String s = txt.replace("*", String.valueOf(time));
show.setText(s);
}
int tagToInt(View v) {
String tag = (String) v.getTag();
int r = 0;
if (tag != null && !TextUtils.isEmpty(tag)) {
r = Integer.valueOf(tag);
}
return r;
}
}
TextView tHour;
TextView tMinute;
NumberPicker minute;
NumberPicker hour;
void init() {
custom = true;
View v = findViewById(R.id.time_sleep_pickers);
v.setVisibility(View.VISIBLE);
initTheme();
initPickersData();
}
A-162
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
minute.setMinValue(0);
hour.setMinValue(0);
minute.setMaxValue(59);
hour.setMaxValue(5);
hour.setValue(0);
minute.setValue(time);
}
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
int min = minute.getValue();
int hou = hour.getValue();
time = hou * 60 + min;
viewHolder.updateCurrentTimeText();
}
A-163
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.66 AnimationUtils.java
package com.example.fyp2_tsk.utils;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.animation.OvershootInterpolator;
public class AnimationUtils {
public static void startAlphaAnim(@NonNull final View view, int duration, @Nullable
Animator.AnimatorListener listener, float... values) {
ValueAnimator alphaAnim = ObjectAnimator. ofFloat(values);
alphaAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float alpha = (float) animation.getAnimatedValue();
view.setAlpha(alpha);
}
});
if (listener != null) {
alphaAnim.addListener(listener);
}
alphaAnim.setDuration(duration);
alphaAnim.start();
}
package com.example.fyp2_tsk.utils;
import android.graphics.Bitmap;
Bitmap bitmap;
if (canReuseInBitmap) {
bitmap = sentBitmap;
} else {
bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
}
if (radius < 1) {
return (null);
}
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int wm = w - 1;
int hm = h - 1;
int wh = w * h;
int div = radius + radius + 1;
yw = yi = 0;
r[yi] = dv[rsum];
g[yi] = dv[gsum];
A-166
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
b[yi] = dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (y == 0) {
vmin[x] = Math.min(x + radius + 1, wm);
}
p = pix[yw + vmin[x]];
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi++;
}
yw += w;
A-167
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
}
for (x = 0; x < w; x++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
yp = -radius * w;
for (i = -radius; i <= radius; i++) {
yi = Math.max(0, yp) + x;
sir[0] = r[yi];
sir[1] = g[yi];
sir[2] = b[yi];
rbs = r1 - Math.abs(i);
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
if (i < hm) {
yp += w;
}
}
yi = x;
stackpointer = radius;
for (y = 0; y < h; y++) {
// Preserve alpha channel: ( 0xff000000 & pix[yi] )
pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) |
dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
A-168
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (x == 0) {
vmin[y] = Math.min(y + r1, hm) * w;
}
p = x + vmin[y];
sir[0] = r[p];
sir[1] = g[p];
sir[2] = b[p];
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi += w;
}
}
bitmap.setPixels(pix, 0, w, 0, 0, w, h);
return (bitmap);
}
A-169
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public static Bitmap doBlur(Bitmap originBitmap, int scaleRatio, int blurRadius){
Bitmap scaledBitmap = Bitmap.createScaledBitmap(originBitmap,
originBitmap.getWidth() / scaleRatio,
originBitmap.getHeight() / scaleRatio,
false);
Bitmap blurBitmap = doBlur(scaledBitmap, blurRadius, false);
scaledBitmap.recycle();
return blurBitmap;
}
}
A-170
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.68 ColorUtils.java
package com.example.fyp2_tsk.utils;
import android.content.Context;
import android.os.Build;
import com.example.fyp2_tsk.R;
import com.example.fyp2_tsk.SleepTimer.AppPreference;
import com.example.fyp2_tsk.SleepTimer.ThemeEnum;
int actionColor;
int statusColor;
if (preference.getTheme() != ThemeEnum.DARK) {
actionColor = preference.getActionbarColor();
statusColor = preference.getStatusBarColor();
} else {
statusColor = context.getResources().getColor(R.color. theme_dark_primary);
actionColor = context.getResources().getColor(R.color. theme_dark_primary_dark);
}
return colors;
}
/**
* 0 Status bar background color <br>
* 1 Background color of title bar <br>
* 2 Preferred color of controls <br>
* 3 main background color <br>
* 4 auxiliary background color <br>
* 5 main font color <br>
* 6 auxiliary font color <br>
* 7 bottom navigation background color <br>
* 8 Main font color of title bar <br>
* 9 Supplementary font color of title bar <br>
*/
A-172
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public static int[] get10ThemeColors(Context context, ThemeEnum themeEnum) {
if (themeEnum == ThemeEnum.WHITE || themeEnum == ThemeEnum.VARYING) {
return get10WhiteThemeColors(context);
} else {
return get10DarkThemeColors(context);
}
}
//Day mode
public static int[] get10WhiteThemeColors(Context context) {
int[] colors = new int[10];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_white_primary);
colors[1] = context.getColor(R.color.theme_white_primary_dark);
colors[2] = context.getColor(R.color.theme_white_accent);
colors[3] = context.getColor(R.color.theme_white_main_bg);
colors[4] = context.getColor(R.color.theme_white_vic_bg);
colors[5] = context.getColor(R.color.theme_white_main_text);
colors[6] = context.getColor(R.color.theme_white_vic_text);
colors[7] = context.getColor(R.color.theme_white_nav);
colors[8] = context.getColor(R.color.theme_white_toolbar_main_text);
colors[9] = context.getColor(R.color.theme_white_toolbar_vic_text);
} else {
colors[0] = context.getResources().getColor(R.color.theme_white_primary);
colors[1] = context.getResources().getColor(R.color. theme_white_primary_dark);
colors[2] = context.getResources().getColor(R.color. theme_white_accent);
colors[3] = context.getResources().getColor(R.color. theme_white_main_bg);
colors[4] = context.getResources().getColor(R.color. theme_white_vic_bg);
colors[5] = context.getResources().getColor(R.color. theme_white_main_text);
colors[6] = context.getResources().getColor(R.color. theme_white_vic_text);
colors[7] = context.getResources().getColor(R.color. theme_white_nav);
colors[8] =
context.getResources().getColor(R.color.theme_white_toolbar_main_text);
colors[9] =
context.getResources().getColor(R.color.theme_white_toolbar_vic_text);
}
return colors;
}
//Night Mode
A-173
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
public static int[] get10DarkThemeColors(Context context) {
int[] colors = new int[10];
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
colors[0] = context.getColor(R.color.theme_dark_primary);
colors[1] = context.getColor(R.color.theme_dark_primary_dark);
colors[2] = context.getColor(R.color.theme_dark_accent);
colors[3] = context.getColor(R.color.theme_dark_main_bg);
colors[4] = context.getColor(R.color.theme_dark_vic_bg);
colors[5] = context.getColor(R.color.theme_dark_main_text);
colors[6] = context.getColor(R.color.theme_dark_vic_text);
colors[7] = context.getColor(R.color.theme_dark_nav);
colors[8] = context.getColor(R.color.theme_dark_toolbar_main_text);
colors[9] = context.getColor(R.color.theme_dark_toolbar_vic_text);
} else {
colors[0] = context.getResources().getColor(R.color. theme_dark_primary);
colors[1] = context.getResources().getColor(R.color.theme_dark_primary_dark);
colors[2] = context.getResources().getColor(R.color. theme_dark_accent);
colors[3] = context.getResources().getColor(R.color. theme_dark_main_bg);
colors[4] = context.getResources().getColor(R.color. theme_dark_vic_bg);
colors[5] = context.getResources().getColor(R.color. theme_dark_main_text);
colors[6] = context.getResources().getColor(R.color. theme_dark_vic_text);
colors[7] = context.getResources().getColor(R.color. theme_dark_nav);
colors[8] =
context.getResources().getColor(R.color.theme_dark_toolbar_main_text);
colors[9] =
context.getResources().getColor(R.color.theme_dark_toolbar_vic_text);
}
return colors;
}
}
A-174
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.69 MergeImage.java
package com.example.fyp2_tsk.utils;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
A-175
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.70 activity_driver.xml
<ImageView
android:id="@+id/music_bg_imgv_driver"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/touxiang1" />
<RelativeLayout
android:id="@+id/music_relativelayout_driver"
android:layout_width="match_parent"
android:layout_height="50dp">
<ImageView
android:id="@+id/music_down_imgv_driver"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:src="@mipmap/ic_arrow_down" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/music_relativelayout"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<TextView
android:id="@+id/music_title_tv_driver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
A-176
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:text="周杰伦"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="25dp" />
<TextView
android:id="@+id/music_artist_tv_driver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/music_title_tv_driver"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="告白气球"
android:textColor="#ffffff"
android:textSize="20dp" />
<ImageView
android:id="@+id/music_prev_imgv_driver"
android:layout_width="125dp"
android:layout_height="200dp"
android:layout_centerVertical="true"
android:src="@drawable/seach_btn_pre" />
<ImageView
android:id="@+id/music_pause_imgv_driver"
android:layout_width="150dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/seach_btn_pause" />
<ImageView
android:id="@+id/music_next_imgv_driver"
android:layout_width="175dp"
android:layout_height="200dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/music_pause_imgv_driver"
android:src="@drawable/seach_btn_next" />
</RelativeLayout>
</RelativeLayout>
A-177
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.71 activity_filechooser_show.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<skin.support.widget.SkinCompatToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="@mipmap/toolbar_back"
app:title="Select Music"
app:titleTextColor="#ffffff" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="5.0dip">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_alignParentBottom="true"
android:id="@+id/fl_main">
<com.wang.avi.AVLoadingIndicatorView
android:id="@+id/avi_loading"
style="@style/AVLoadingIndicatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_centerVertical="true"
app:indicatorColor="@color/cutter_theme_black"
app:indicatorName="PacmanIndicator"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/btn_update"
A-178
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@mipmap/btn_update" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rl_musice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:columnWidth="90dp"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"
android:layout_above="@id/fl_main"/>
</RelativeLayout>
</LinearLayout>
</layout>
A-179
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.72 activity_main.xml
<!--Toolbar-->
<skin.support.widget.SkinCompatToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
<!--DrawerLayout-->
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--MainLayout-->
<FrameLayout
android:id="@+id/frame_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appbar"
android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#ffffff"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
</android.support.design.widget.AppBarLayout>
</layout>
A-180
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.73 activity_music.xml
<ImageView
android:id="@+id/music_bg_imgv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@mipmap/touxiang1" />
<RelativeLayout
android:id="@+id/music_relativelayout"
android:layout_width="match_parent"
android:layout_height="50dp">
<ImageView
android:id="@+id/music_down_imgv"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:src="@mipmap/ic_arrow_down" />
<TextView
android:id="@+id/music_title_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/music_down_imgv"
android:text="周杰伦"
android:textColor="#ffffff"
android:textSize="13dp" />
<TextView
android:id="@+id/music_artist_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
A-181
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_below="@+id/music_title_tv"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/music_down_imgv"
android:text="告白气球"
android:textColor="#ffffff"
android:textSize="10dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="350dp"
android:layout_height="500dp"
android:layout_above="@+id/music_linlayout"
android:layout_below="@+id/music_relativelayout"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true">
<ImageView
android:id="@+id/music_disc_imagv"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_marginTop="100dp"
android:src="@mipmap/play_page_disc" />
<ImageView
android:id="@+id/music_needle_imag"
android:layout_width="150dp"
android:layout_height="159dp"
android:layout_marginLeft="132dp"
android:src="@mipmap/play_page_needle" />
</RelativeLayout>
<LinearLayout
android:id="@+id/music_linlayout"
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:orientation="horizontal">
A-182
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/music_current_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:text="00:00"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/music_total_tv"
android:layout_toRightOf="@+id/music_current_tv">
<SeekBar
android:id="@+id/music_seekbar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<TextView
android:id="@+id/music_total_tv"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentRight="true"
android:text="00:00"
android:textColor="#ffffff" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
A-183
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_height="0dp"
android:layout_weight="10">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/music_play_btn_loop_img"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="@mipmap/ic_play_btn_loop" />
<ImageView
android:id="@+id/music_prev_imgv"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/music_play_btn_loop_img"
android:src="@drawable/seach_btn_pre" />
<ImageView
android:id="@+id/music_pause_imgv"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/seach_btn_pause" />
<ImageView
android:id="@+id/music_next_imgv"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerVertical="true"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@id/music_pause_imgv"
android:src="@drawable/seach_btn_next" />
<ImageView
android:id="@+id/driver_Mode"
android:layout_width="40dp"
android:layout_height="40dp"
A-184
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/music_next_imgv"
android:src="@drawable/ic_drive_mode_white_24dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
A.74 activity_splash.xml
<TextView
android:id="@+id/splash_m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="2dp"
android:text="M"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_u"
app:layout_constraintRight_toLeftOf="@+id/splash_u"
app:layout_constraintTop_toTopOf="@+id/splash_u"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_i"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="i"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
A-185
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
app:layout_constraintBottom_toTopOf="@+id/guideline20"
app:layout_constraintHorizontal_bias="0.418"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/splash_c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="c"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_i"
app:layout_constraintLeft_toRightOf="@+id/splash_i"
app:layout_constraintTop_toTopOf="@+id/splash_i"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_p"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:padding="2dp"
android:text="P"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_c"
app:layout_constraintLeft_toRightOf="@+id/splash_c"
app:layout_constraintTop_toTopOf="@+id/splash_c"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_l"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="l"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_p"
A-186
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
app:layout_constraintLeft_toRightOf="@+id/splash_p"
app:layout_constraintTop_toTopOf="@+id/splash_p"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="a"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_l"
app:layout_constraintLeft_toRightOf="@+id/splash_l"
app:layout_constraintTop_toTopOf="@+id/splash_l"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_y"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="y"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_a"
app:layout_constraintLeft_toRightOf="@+id/splash_a"
app:layout_constraintTop_toTopOf="@+id/splash_a"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_e"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="e"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_y"
app:layout_constraintLeft_toRightOf="@+id/splash_y"
app:layout_constraintTop_toTopOf="@+id/splash_y"
A-187
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_r"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="r"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_e"
app:layout_constraintLeft_toRightOf="@+id/splash_e"
app:layout_constraintTop_toTopOf="@+id/splash_e"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="s"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_i"
app:layout_constraintRight_toLeftOf="@+id/splash_i"
app:layout_constraintTop_toTopOf="@+id/splash_i"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/splash_u"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
android:text="u"
android:textColor="@color/white"
android:textSize="26sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/splash_s"
app:layout_constraintRight_toLeftOf="@+id/splash_s"
app:layout_constraintTop_toTopOf="@+id/splash_s"
app:layout_constraintVertical_bias="0.0" />
A-188
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
<TextView
android:id="@+id/splash_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:text="@string/app_name"
android:textColor="@color/white_d_d_d"
android:textSize="16sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ImageView
android:id="@+id/splash_logo"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginBottom="0dp"
android:src="@drawable/img_0"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@+id/splash_i"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<android.support.constraint.Guideline
android:id="@+id/guideline19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
<android.support.constraint.Guideline
android:id="@+id/guideline20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.61" />
</android.support.constraint.ConstraintLayout>
</layout>
A-189
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.75 activity_time_sleep.xml
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/time_sleep_toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
A-190
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.76 dialog_common.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="20dip"
android:background="@drawable/commondialog_bg"
android:orientation="vertical">
<TextView
android:id="@+id/tv_dialog_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:textColor="#202020"
android:textSize="18dp"
android:visibility="gone" />
<TextView
android:id="@+id/tv_dialog_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="18dp"
android:layout_marginTop="12dp"
android:textColor="#202020"
android:textSize="15dp" />
<EditText
android:id="@+id/et_dialog_input"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="12dp"
android:background="@mipmap/commondialog_et_bg"
android:inputType="textPassword"
android:maxLength="20"
android:maxLines="1"
android:paddingLeft="15dp"
android:textColor="#000000"
A-191
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:textColorHint="#ACB3BF"
android:textSize="13dp"
android:visibility="gone" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_marginTop="12dp">
<TextView
android:id="@+id/tv_dialog_confirm"
android:layout_width="75dp"
android:layout_height="36dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:gravity="center"
android:text="@string/dialog_btn_sure"
android:textColor="#009688"
android:textSize="14dp" />
<TextView
android:id="@+id/tv_dialog_cancle"
android:layout_width="75dp"
android:layout_height="36dp"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:layout_toLeftOf="@id/tv_dialog_confirm"
android:gravity="center"
android:text="@string/dialog_btn_cancel"
android:textColor="#009688"
android:textSize="14dp" />
</RelativeLayout>
</LinearLayout>
A-192
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.77 dialog_theme_color.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.fyp2_tsk.other.AllFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bg_listview"
android:orientation="vertical">
<SearchView
android:id="@+id/edSearch"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:hint="Search" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="32dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent">
A-194
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
<com.lwkandroid.widget.indexbar.IndexBar
android:id="@+id/indexBar"
android:layout_width="40dp"
android:layout_height="match_parent"
app:bg_color_normal="@android:color/transparent"
app:bg_color_pressed="#10000000"
app:text_color_normal="#3c3c3c"
app:text_color_pressed="#000093"
app:text_size_normal="14sp"
android:layout_gravity="end"
app:text_size_pressed="16sp" />
</FrameLayout>
A-195
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.79 fragment_cut.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:rangeseekbar="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/rl_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<ImageView
android:id="@+id/iv_player_min_voice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dip"
android:background="@mipmap/volume_min" />
<ImageView
android:id="@+id/iv_player_max_voice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:background="@mipmap/volume_max" />
<SeekBar
android:id="@+id/voice_seekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@id/iv_player_max_voice"
A-196
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_toRightOf="@id/iv_player_min_voice" />
</RelativeLayout>
<ImageButton
android:id="@+id/btn_play"
android:layout_width="80dp"
android:layout_height="55dp"
android:layout_weight="1"
android:background="@drawable/selector_play_btn" />
<ImageButton
android:id="@+id/btn_cutter_sure"
android:layout_width="114dp"
android:layout_height="67dp"
android:layout_weight="1"
android:background="@drawable/selector_sure_btn" />
</LinearLayout>
<ImageView
android:id="@+id/topborder"
android:layout_width="fill_parent"
android:layout_height="1dp"
A-197
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_alignParentTop="true"
android:background="@mipmap/border_bg" />
<RelativeLayout
android:id="@+id/rl_playerbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topborder">
<com.zyl.customrangeseekbar.CustomRangeSeekBar
android:id="@+id/range_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
rangeseekbar:progressBarBg="@mipmap/seekbar_bg"
rangeseekbar:progressBarSelBg="@mipmap/seekbar_sel_bg"
rangeseekbar:thumbImage="@mipmap/btn_seekbar_normal"
rangeseekbar:progressTextSize="16dp"
rangeseekbar:progressTextFormat="timeFormat"
rangeseekbar:startMinPercent="0"
rangeseekbar:startMaxPercent="1"
/>
</RelativeLayout>
<ImageView
android:id="@+id/bottomborder"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@id/rl_playerbar"
android:background="@mipmap/border_bg" />
</RelativeLayout>
<com.example.fyp2_tsk.common.ui.view.visualizer.VisualizerView
android:id="@+id/visual_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/rl_player_center"/>
</RelativeLayout>
</layout>
A-198
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.80 fragment_music.xml
<LinearLayout
android:id="@+id/main_top_linlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<TextView
android:id="@+id/main_logic_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="All"
android:textColor="@color/white"
android:layout_marginLeft="60dp"
android:textSize="15dp" />
<TextView
android:id="@+id/eng_logic_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="English"
android:layout_marginLeft="75dp"
android:layout_toRightOf="@+id/main_logic_tv"
android:textColor="@color/white_60P"
android:textSize="15dp" />
<TextView
android:id="@+id/chinese_logic_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="Others"
A-199
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_marginLeft="75dp"
android:textAlignment="center"
android:textColor="@color/white_60P"
android:layout_toRightOf="@+id/eng_logic_tv"
android:textSize="15dp" />
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/main_vp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cutter_theme_white"></android.support.v4.view.ViewPager>
</LinearLayout>
</layout>
A-200
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.81 item_musicfile.xml
<ImageView
android:id="@+id/iv_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/music_icon"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"/>
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:maxLines="1"
android:ellipsize="end"
android:textColor="#000000"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@id/iv_icon"
android:layout_alignTop="@id/iv_icon"/>
<TextView
android:id="@+id/tv_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:maxLines="1"
android:ellipsize="end"
android:textColor="#808080"
android:layout_alignLeft="@id/tv_name"
android:layout_alignBottom="@id/iv_icon" />
</RelativeLayout>
A-201
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.82 item_theme_color.xml
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/them_color"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_margin="4dp" />
<ImageView
android:id="@+id/choose"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="@mipmap/ic_done_white_36dp"
android:visibility="gone" />
</FrameLayout>
</layout>
A-202
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.83 music_item.xml
<View
android:id="@+id/musicitem_playing_v"
android:layout_width="3dp"
android:layout_height="50dp"
android:visibility="invisible"
android:background="@color/colorAccent"
/>
<ImageView
android:id="@+id/musicitem_album_imgv"
android:layout_marginLeft="3dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:src="@mipmap/music_icon"/>
<TextView
android:id="@+id/musicitem_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/musicitem_album_imgv"
android:textSize="13dp"
android:text="成都"/>
<TextView
android:id="@+id/musicitem_artist_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11dp"
android:layout_toRightOf="@+id/musicitem_album_imgv"
android:layout_below="@+id/musicitem_title_tv"
android:layout_marginLeft="20dp"
android:layout_gravity="bottom"
android:text="赵雷"/>
<View
A-203
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_width="match_parent"
android:layout_height="1sp"
android:layout_toRightOf="@+id/musicitem_album_imgv"
android:background="#cccccc"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
A-204
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.84 time_sleep_content.xml
<TextView
android:id="@+id/time_sleep_status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="8dp"
android:layout_marginTop="0dp"
android:gravity="start|center_vertical"
android:padding="16dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/time_sleep_status_switch"
app:layout_constraintTop_toTopOf="parent" />
<Switch
android:id="@+id/time_sleep_status_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:paddingRight="16dp"
app:layout_constraintBottom_toBottomOf="@+id/time_sleep_status"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/time_sleep_status" />
<View
android:id="@+id/time_sleep_line"
android:layout_width="0dp"
android:layout_height="1px"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="0dp"
android:background="#41000000"
A-205
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time_sleep_status" />
<TextView
android:id="@+id/time_sleep_10m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:padding="8dp"
android:tag="10"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/guideline14"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline11"
app:layout_constraintTop_toTopOf="@+id/guideline13" />
<TextView
android:id="@+id/time_sleep_20m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:padding="8dp"
android:tag="20"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/guideline14"
app:layout_constraintLeft_toLeftOf="@+id/guideline11"
app:layout_constraintRight_toLeftOf="@+id/guideline9"
app:layout_constraintTop_toTopOf="@+id/guideline13" />
<TextView
android:id="@+id/time_sleep_30m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
A-206
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:padding="8dp"
android:tag="30"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/guideline14"
app:layout_constraintLeft_toLeftOf="@+id/guideline9"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline13" />
<TextView
android:id="@+id/time_sleep_45m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:padding="8dp"
android:tag="45"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/guideline12"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline11"
app:layout_constraintTop_toTopOf="@+id/guideline14" />
<TextView
android:id="@+id/time_sleep_60m"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:clickable="true"
android:padding="8dp"
android:tag="60"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/guideline12"
app:layout_constraintLeft_toLeftOf="@+id/guideline11"
app:layout_constraintRight_toLeftOf="@+id/guideline9"
app:layout_constraintTop_toTopOf="@+id/guideline14" />
A-207
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
<Button
android:id="@+id/time_sleep_custom"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:padding="15dp"
android:text="@string/custom"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/guideline15"
app:layout_constraintHorizontal_bias="0.466"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline11"
app:layout_constraintTop_toTopOf="@+id/guideline12" />
<TextView
android:id="@+id/time_sleep_custom_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="56dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="#22000000"
android:clickable="false"
android:gravity="center_vertical|start"
android:padding="3dp"
app:layout_constraintBottom_toTopOf="@+id/guideline15"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline12" />
<include
android:id="@+id/time_sleep_pickers"
layout="@layout/time_sleep_content_pickers"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
A-208
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_marginTop="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline15" />
<android.support.constraint.Guideline
android:id="@+id/guideline9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.66" />
<android.support.constraint.Guideline
android:id="@+id/guideline11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.33" />
<android.support.constraint.Guideline
android:id="@+id/guideline12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.42" />
<android.support.constraint.Guideline
android:id="@+id/guideline15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.56" />
<android.support.constraint.Guideline
android:id="@+id/guideline14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.28" />
<android.support.constraint.Guideline
A-209
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:id="@+id/guideline13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.14" />
</android.support.constraint.ConstraintLayout>
A-210
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
A.85 time_sleep_content_picker.xml
<NumberPicker
android:id="@+id/time_sleep_custom_num_left"
style="30sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/time_sleep_custom_num_left_t"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/time_sleep_custom_num_left_t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:text="Hour"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline18"
app:layout_constraintTop_toTopOf="parent" />
<NumberPicker
android:id="@+id/time_sleep_custom_num_right"
style="30sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
A-211
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/guideline18"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/time_sleep_custom_num_right_t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text="Minutes"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@+id/time_sleep_custom_num_right"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="@+id/guideline18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
</android.support.constraint.ConstraintLayout>
A-212
BIS (Hons) Information Systems Engineering
Faculty of Information and Communication Technology (Kampar Campus), UTAR.
POSTER
Similarity by source
Internet Sources: 0 %
Publications: 1 %
Student Papers: 3 %
Note Supervisor/Candidate(s) is/are required to provide softcopy of full set of the originality report to
Faculty/Institute
Based on the above results, I hereby declare that I am satisfied with the originality of the Final
Year Project Report submitted by my student(s) as named above.
______________________________ __________________________________
Signature of Supervisor Signature of Co-Supervisor
Student Id 16ACB05288
Student Name TAN SIANG KIAN
Supervisor Name DR. OOI CHEK YEE
I, the author, have checked and confirmed Supervisor verification. Report with
all the items listed in the table are included incorrect format can get 5 mark (1 grade)
in my report. reduction.
______________________ ______________________
(Signature of Student) (Signature of Supervisor)
Date: 20/04/2020 Date: 20/04/2020
1. WORK DONE
[Please write the details of the work done in the last fortnight.]
Review the FYP1 report and improve some chapters that need improvement.
2. WORK TO BE DONE
3. PROBLEMS ENCOUNTERED
Not familiar with how to make a black vinyl disc into a rotating animation in the
music playing interface
1. WORK DONE
[Please write the details of the work done in the last fortnight.]
2. WORK TO BE DONE
Driver mode
Shaking the phone's media control is not sensitive enough, and it takes a lot of effort
to switch songs
1. WORK DONE
[Please write the details of the work done in the last fortnight.]
2. WORK TO BE DONE
Sleep timer
Audio trim
Night mode
3. PROBLEMS ENCOUNTERED
Only change to a dark background color in a single layout interface when night mode
is enabled
1. WORK DONE
[Please write the details of the work done in the last fortnight.]
Chapter 1, 2, 3, 4, and 5
The main module is totally completed
2. WORK TO BE DONE
Chapter 6 – Conclusion
Documentation
3. PROBLEMS ENCOUNTERED