Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
*.iml
.gradle
/local.properties
/.idea/
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
*.apk
*.ap_
*.aab
*.dex
*.class
bin/
gen/
out/
.gradletasknamecache
app/build/
*/build/
gradle-app.setting
!gradle-wrapper.jar
!gradle-wrapper.properties
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
# Android_Note-taking
# Android Note-Taking App

A simple and functional note-taking application for Android that allows users to create, edit, view, and delete notes.

## Features

- **Create Notes**: Add new notes with titles and content
- **View Notes**: Browse all your notes in a clean list view
- **Edit Notes**: Modify existing notes anytime
- **Delete Notes**: Remove notes you no longer need
- **Persistent Storage**: Notes are saved locally using SharedPreferences with Gson serialization
- **Modern UI**: Material Design components with CardView and FloatingActionButton

## Technical Details

- **Minimum SDK**: Android 5.0 (API 21)
- **Target SDK**: Android 13 (API 33)
- **Language**: Java
- **Architecture**: Simple MVC pattern
- **Data Persistence**: SharedPreferences with Gson

## Project Structure

```
app/
├── src/main/
│ ├── java/com/notetaking/app/
│ │ ├── MainActivity.java # Main screen showing list of notes
│ │ ├── NoteEditorActivity.java # Screen for creating/editing notes
│ │ ├── Note.java # Note data model
│ │ ├── NotesAdapter.java # RecyclerView adapter for notes list
│ │ └── NotesManager.java # Handles data persistence
│ ├── res/
│ │ ├── layout/ # XML layouts
│ │ ├── values/ # Strings, colors, themes
│ │ └── menu/ # Menu resources
│ └── AndroidManifest.xml
└── build.gradle
```

## Building the Project

1. Clone the repository:
```bash
git clone https://github.com/Jeffcheung205/Android_Note-taking.git
```

2. Open the project in Android Studio

3. Sync Gradle files

4. Run on an emulator or physical device

## Usage

1. **Add a Note**: Tap the floating action button (+) on the main screen
2. **Edit a Note**: Tap on any note in the list to open and edit it
3. **Save a Note**: Tap the save icon in the editor toolbar
4. **Delete a Note**: Open a note and tap the delete icon in the toolbar

## Dependencies

- AndroidX AppCompat
- Material Components
- RecyclerView
- CardView
- ConstraintLayout
- Gson (for JSON serialization)

## License

This project is open source and available for educational purposes.
37 changes: 37 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
id 'com.android.application'
}

android {
namespace 'com.notetaking.app'
compileSdk 33

defaultConfig {
applicationId "com.notetaking.app"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.code.gson:gson:2.10.1'
}
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Add project specific ProGuard rules here.
25 changes: 25 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.notetaking.app">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.NoteTaking">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NoteEditorActivity"
android:parentActivityName=".MainActivity"
android:exported="false" />
</application>

</manifest>
81 changes: 81 additions & 0 deletions app/src/main/java/com/notetaking/app/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.notetaking.app;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.util.List;

public class MainActivity extends AppCompatActivity implements NotesAdapter.OnNoteClickListener {
private RecyclerView recyclerView;
private TextView emptyTextView;
private NotesAdapter adapter;
private NotesManager notesManager;
private ActivityResultLauncher<Intent> noteEditorLauncher;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

notesManager = new NotesManager(this);

recyclerView = findViewById(R.id.recyclerView);
emptyTextView = findViewById(R.id.emptyTextView);
FloatingActionButton fab = findViewById(R.id.fab);

recyclerView.setLayoutManager(new LinearLayoutManager(this));

List<Note> notes = notesManager.loadNotes();
adapter = new NotesAdapter(notes, this);
recyclerView.setAdapter(adapter);

updateEmptyView();

// Register activity result launcher
noteEditorLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> refreshNotes()
);

fab.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, NoteEditorActivity.class);
noteEditorLauncher.launch(intent);
});
}

@Override
protected void onResume() {
super.onResume();
refreshNotes();
}

private void refreshNotes() {
List<Note> notes = notesManager.loadNotes();
adapter.updateNotes(notes);
updateEmptyView();
}

private void updateEmptyView() {
if (adapter.getItemCount() == 0) {
recyclerView.setVisibility(View.GONE);
emptyTextView.setVisibility(View.VISIBLE);
} else {
recyclerView.setVisibility(View.VISIBLE);
emptyTextView.setVisibility(View.GONE);
}
}

@Override
public void onNoteClick(Note note) {
Intent intent = new Intent(this, NoteEditorActivity.class);
intent.putExtra("note", note);
noteEditorLauncher.launch(intent);
}
}
62 changes: 62 additions & 0 deletions app/src/main/java/com/notetaking/app/Note.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.notetaking.app;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.UUID;

public class Note implements Serializable {
private String id;
private String title;
private String content;
private long timestamp;

public Note() {
this.id = UUID.randomUUID().toString();
this.timestamp = System.currentTimeMillis();
}

public Note(String title, String content) {
this();
this.title = title;
this.content = content;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public long getTimestamp() {
return timestamp;
}

public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}

public String getFormattedDate() {
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy HH:mm", Locale.getDefault());
return sdf.format(new Date(timestamp));
}
}
Loading