Notepad software based on Android platform (Android Studio project + report + app file)

Mobile Application Development Technology

End-of-term assessment report

Topic : Notepad software based on Android platform                       

student name                            

student number                            

professional                              

class                                 

mentor                          

 

   June    20   , 2022 _ _

 

Table of contents

1. Project source and background... 4

2. Requirements Analysis... 4

2.1 Note function requirements analysis:... 4

2.1.1 Display notes... 4

2.1.2 Add note... 4

2.1.3 Edit notes... 5

2.2 Account Management... 5

2.2.1 Register account... 5

2.2.2 Login... 5

2.2.3 Modify password... 5

2.2.4 Cancel Account... 5

2.3 Database Requirements Analysis... 6

2.4 Interface requirements analysis... 6

3. Overall system design... 7

3.1 Account Management... 7

3.1.1 Login... 7

3.1.2 Registration... 8

3.1.3 Change password... 9

3.1.4 Logout... 10

3.2 Note function... 11

4. Detailed design and implementation... 12

4.1 Note related functions... 12

4.1.1 Display notes... 12

4.1.2 Add note... 14

4.1.3 Edit notes... 15

4.1.4 Account Management... 18

4.2 Database... 21

4.3 Background music... 21

4.4 Interface beautification... 22

4.5 Other Details...23

5. Summary and experience... 23

References... 24

  1. Project source and background

According to accurate data surveys, as of 2021 , the global population is 7.83 billion, and 5.22 billion people worldwide use mobile phones, equivalent to 66.6% of the world's total population . The Internet is occupying the trend of globalization. With the acceleration of the pace of life , the dual pressures of work and life are invading people in an all-round way. How to avoid forgetting many things in work and life and causing adverse consequences is very important. To this end , I developed a simple notepad based on the Android system, which can portablely record many things in life and work , so as to help people manage time in an organized manner.

This system is developed on the Android Studio platform under the Windows system , the code is written in Java language, and the database is a safe and portable SQLite . The configuration used is also a simple BaseAdapter as the basic data adapter, which is simple and efficient for development. Although this project is just a basic diary, the functions and maintainability will be further revised, transformed and perfected in the continuous exploration in the future to meet the needs of various customers.

  1. demand analysis

2.1 Note function requirements analysis:

2.1.1 Display notes

The user must be able to see the content of the notes written before opening the notepad, so after entering the main page, the software should search out all the notes written by the user from the database, and arrange and output them in a certain order.

Notepad notes can add multiple notes (theoretically unlimited, as long as the database can be put down), and what the user sees on the main page should be a list of notes, which stores all the notes written by him. Note content should not be displayed directly in the list, which takes up too much space, so design the title column in the database, display the title title in the list, click the title to enter another interface, and display the detailed note content.

2.1.2 Add notes

Set the entry to add note content, the user clicks to enter and start editing the title and content of the note.

2.1.3 Edit notes

In the notes list on the main interface. Click on a note to edit it, including changing the note (updating) and deleting the note.

2.2 Account Management

In order to better protect the privacy requirements of customers, and to allow different users of the same mobile phone to use the software, the software has a special account management.

The notepad is used by multiple users in this machine, and the design of account management allows multiple users to use the software, and ensures that everyone can only see their own notes. This is equivalent to a lock.

2.2.1 Account registration

The purpose of registering an account is to confirm the password to prevent the user from filling in the wrong password. Although the account is registered, the password is equivalent to being forgotten, which means that the account has just been canceled and becomes invalid. Of course, both the account and password cannot be empty.

2.2.2 Login

When logging in, check the account password, including whether it is empty or not, and whether the account password is correct. Prompt the user according to different errors.

In order to prevent users from having to enter account passwords every time they log in, an option to remember passwords should be added. (Remembering the password also has disadvantages, if another user uses this software in the machine, then he can log in directly)

2.2.3 Modify password

When changing the password, it is necessary to enter the account number, old password, new password and confirm the new password. The four items are indispensable. If any item is empty, the user must be prompted. After the four items are filled in and confirmed by the user, compare the account and password. If the verification is successful, then confirm the new password, and finally change the password.

2.2.4 Cancel account

After the user no longer wants to use the software, he can mainly cancel the account. To cancel the account, delete the note data of the user in the database at the same time.

2.3 Analysis of database requirements

The software is mainly divided into two modules (login and note), so two tables need to be created, namely the user table and the note table

2.4 Analysis of Interface Requirements

The interface is very important in the development of mobile development platforms, and it is also a prerequisite for users to use the software. The notepad software has a total of 8 interfaces, namely login interface, registration interface, password modification interface, logout interface, note list display interface (main interface), add note interface, edit note interface and update note interface.

The background color should be concise and fresh, and try not to make users feel bored.

  1. Overall System Design

3.1 Account Management

3.1.1 Login

3.1.2 Registration

 

3.1.3 Change password

 

3.1.4 Logout

 

3.2 Note function

 

  1. Detailed Design and Implementation

4.1 Note related functions

4.1.1 Display notes

 

After login, the main interface is a list of notes displayed by the Listview component, which displays all the note data of the user, and each note data is displayed on the item only the title and the latest edit time of the note data.

The list of notes is displayed in descending order of the latest editing time, so that the latest added and edited notes of the user can be ranked at the top, which is more humane and convenient.

Since the list of notes on the Notepad interface is displayed using the ListView control, it is necessary to create a data adapter to adapt the data to the ListView control. The specific steps are as follows :

  1. Create the MemoAdapter class

Create a MemoAdapter class that inherits from the BaseAdapter class.

  1. Create the Holder class

Create a Holder class in the MemoAdapter class to initialize the controls in the ltem interface.

BaseAdapter is one of the most versatile and best-used data adapters, BaseAdapter 's

View getView(final int position, View convertView, ViewGroup parent) fills the visual content of each item and returns. The getView method is automatically called back by the system. It will be called whenever an item needs to be refreshed in the visible area, and is used to fill the item content, bind events and other operations. Therefore, the data filling of the ListView content is implemented in this method.

In the Holder class, there are only two TextView parameters, text and textTime , which respectively represent the title of a note and the latest edit time.

The convertView is null when the getView method is called for the first time , so when you first enter the main page, the layout will be instantiated: convertView = LayoutInflater.from(context).inflate(R.layout.list_member, null);

The role of View.inflate is to convert layout_item into a View object. How many items the ListView can display in the interface , how many times getView will be called.

A Holder object holder is instantiated in getView , and the parameters in the holder are instantiated with the corresponding TextView in the display interface, which is equivalent to the holder binding two components in the interface.

Use convertView.setTag(hodler) to store the holder data in convertView .

If convertView is instantiated, then directly use getTag to retrieve the holder data. At this time, the holder is bound to two components in the interface.

setTag() in View means to add an extra data to View , and you can use getTag() to get this data out.

After that, use the cursor to take out the corresponding data (title and latest editing time) in the data, and then copy them to the two corresponding members in the holder (now the TextView component in xml ). This will display the data.

Detailed code see source program.

4.1.2 Add notes

To add a note, just take out the String content in the component and put it into the database.

Data manipulation statement: database.insert(sqliteHelper.tableName, null, values);

When inserting note data into the database, you must also insert the user name, so that when displaying note data, you can accurately query the notes written by a specific user. This requires that after logging in, the user name must be passed between the various Activities , and only need to be passed by Intent .

      1. edit note

 

Editing includes deletion and modification (updating).

Delete according to the id of the note data . The id is the auto-increment column of each note data and is also the primary key. delete(sqliteHelper. tableName, sqliteHelper. id + "=" + pos, null);

In order to avoid accidental deletion, set the prompt:

  1. AlertDialog.Builder builder = new AlertDialog.Builder(OneMemoActivity.this);  
  2.                 builder.setMessage( " Are you sure you want to delete ?" )  
  3.                         .setTitle( " Prompt " )  
  4.                         .setPositiveButton( " OK " ,  
  5.                                 new DialogInterface.OnClickListener() {  
  6.                                     @Override  
  7.                                     public void onClick(DialogInterface dialog, int which) {  
  8.                                         deleteByPos();  
  9.                                         dialog.dismiss();  
  10.                                         finish();  
  11.                                     }  
  12.                                 })  
  13.                         .setNegativeButton( " No , my hand slipped just now " ,  
  14.                                 new DialogInterface.OnClickListener() {  
  15.                                     @Override  
  16.                                     public void onClick(DialogInterface dialog, int which) {  
  17.                                         dialog.dismiss();  
  18.                                     }  
  19.                                 })  
  20.                         .show(); 

The effect is as follows:

The user clicks the edit button to enter the editing interface and modify the memo. After the modification, click OK to complete the modification. The modification is the same as the operation of adding a note. See below:

 

4.1.4 Account Management

              1) Register, change password, logout

Registration, password modification and cancellation are very similar. The difference is that logout also deletes the note data of the logout user in the database.

delete(sqliteHelper.tableName, sqliteHelper.user + "=" + userName, null);

From left to right: register, change password, logout

  1. Log in

In fact, the login mainly involves the verification of the account password, which only needs to use the database statement to query whether there is consistent data of the user name and password from the database.

       The novelty here is that the account remembers the password:

       In order to prevent users from having to enter account passwords every time they log in, an option to remember passwords should be added. (Remembering the password also has disadvantages, if another user uses this software in the machine, then he can log in directly)

4.2 Database

The software is mainly divided into two modules (login and note), so two tables need to be created, namely the user table and the note table

field name

type of data

Is it the primary key

describe

id

integer

yes

serial number

dates

text

no

note content

user

text

no

username

lastModifyTime

text

no

Last edit time

title

text

no

note title

field name

type of data

Is it the primary key

describe

_id

integer

yes

serial number

user_name

text

no

username

user_pwd

text

no

password

The MemoSQLiteOpenHelper class in the project inherits from SQLiteOpenHelper and is used to create Notepad database data tables. The UserDataManager class is a data operation management class, the creation of database data tables, and the codes for adding, deleting, modifying and checking data are all here.

4.3 Background music

Adding background music is also very simple, which is the same as the code done in the experiment. It should be noted that the Service needs to be registered in AndroidManifest.xml . Services that are quickly added by compiling software will actually be registered automatically.

The Service starts running when the main display Activity ( MainActivity ) is started, and when the Activity is destroyed, the Service is also destroyed at the same time. In this way, after the user logs in successfully, the background music will be remembered.

Note: The default Activity of this program is LoginActivity , because the user must log in to enter the software. Modify the default Activity in AndroidManifest.xml .

Background music is stored in the res/raw folder.

4.4 Interface beautification

In order to make the software more beautiful, the software icon is set, and some icons and pictures are added to the interface of the software. The button for adding notes is a floating button, and pictures are also added to the button.

Floating button:

<com.google.android.material.floatingactionbutton.FloatingActionButton

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:id="@+id/add"

            android:layout_gravity="right|bottom"

            android:layout_marginRight="10dp"

            android:layout_marginBottom="10dp"

            android:src="@drawable/add"

            app:borderWidth="0dp"

            app:fabSize="auto"

            app:maxImageSize="56dp"

            app:backgroundTint="#99ccff"

            app:rippleColor="#33728dff"

            app:elevation="8dp"

            app:pressedTranslationZ="16dp"/>

            <!-- app:maxImageSize set image size-

From left to right are APP icon, login interface logo , main interface floating button (add note button)

4.5 Other Details

Music files are stored in the res/raw folder. The background music of this software is Promise.mp3 , which is a stimulating and inspiring song from Silent Hill.

The picture files in the project are placed under the res/drawable file. If you want to change the software icon, you need to change the android:icon="@drawable/applogo" statement in AndroidManifest.xml . It is actually found that the icon file needs to be placed in the res/mipmap folder, otherwise the icon cannot be changed.

The pictures in the project are png pictures downloaded from the webpage , and the user name and password icons are built in the Android Studio project.

Try not to appear Chinese in the program, so you can put all Chinese in the strings.xml file under the res/values ​​folder .

<string name="login">登录</string> 

If you want to use the word login, you can use getString(R.string.login) .

You can also dynamically insert content in strings.xml

<string name="user_login_success"> User: <xliff:g example="tom" id="id2">%1$s</xliff:g> Login, welcome! </string>

Use the statement getString(R.string.name_already_exist, “YTJ”) to let the user YTJ log in, welcome!

in:

The attribute id can be named whatever you want

The attribute example indicates an example, which can be omitted

%n$ms : represents the output is a string, n represents the number of parameters, setting the value of m can place a space before the output

%n$md : It means that the output is an integer, n means the number of parameters, setting the value of m can put a space before the output, or set it to 0m, put m 0s before the output

%n$mf : means that the output is a floating point number, n means the number of parameters, setting the value of m can control the number of decimal places, such as m=2.2 , the output format is 00.00

  1. Summary and experience

Through the practice of this big homework project, the key points in the Android course have been applied, and I have a deeper understanding of knowledge points such as Activity , communication between Activities , SQLite database operations, Service , and ListView , and let myself understand these points. Practical use is more handy.

There are quite a lot of database-related operations in this big job, and my main stuck point is the use of the database. It took a while to query data for certain criteria. For example, when querying whether there is a user named user in the database , you can use

String sql="select * from " + TABLE_NAME + "where " + USER_NAME + "= '" + userName+ "'";

SQLiteDatabase.rawQuery(sql, null)  

or

SQLiteDatabase .query(TABLE_NAME, null, USER_NAME+"="+userName, null, null, null, null);

or

SQLiteDatabase.query(TABLE_NAME, null, USER_NAME + "=?", new String[] { user}, null, null, null);

At the beginning, I used the first two methods, but it showed that the data could not be found. After reading many related problems on the Internet, I couldn’t find out where the problem was. Finally, I found the third method and successfully found the data.

The data display method of ListView is different from that in the book. The BaseAdapter adapter used by most people on the Internet is used. After learning and mastering, it is also a great harvest.

After about a week of improvement in this major assignment, the resulting notepad program has basic note-taking functions, as well as privacy protection functions, and added background music playback (see the program package for detailed functions and codes). However, due to the limitation of time and personal ability, many functions of the software were not considered very well, and the functions did not meet the expected goals. In the future, the functions of the software will continue to be added, plus reminders, cloud backup, etc.

For source code, word report, and apk see resources:  Notepad software based on Android platform (Android Studio project + report + app file) icon-default.png?t=M5H6https://download.csdn.net/download/MckennaGrace/85876972

references

[1] Guo Lin's first line of code - Android ( 2nd Edition) [M]. People's Posts and Telecommunications Press 2016.11

[2] Design and Implementation of Huang Xiaoxian 's Handy Campus Communication System Based on Android [J]. Journal of Kaifeng Institute of Education, 2016, 03:280-281.

[4] Zhang Shengcai based on the development of Android educational information management system [J]. Science and Technology Innovation and Application, 2014,34:72.

[5] Yang Yunjun Android Design and Implementation [M]. Beijing: Machinery Industry Press, 2013:45-49.

[6] About the understanding and implementation of the getView method in BaseAdapter

 

 

Guess you like

Origin blog.csdn.net/MckennaGrace/article/details/125582013