Skip to content
2 changes: 2 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-android-extensions'
}


android {
compileSdk 32

Expand All @@ -22,6 +25,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -52,4 +58,11 @@ dependencies {
implementation 'com.github.Miihir79:DrawingCanvas:1.1.2'
implementation 'com.github.DonghanX:Draw:v1.0.3'

// dependencies for Api integration | Retrofit 2
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'

}
14 changes: 9 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -19,6 +20,10 @@
android:supportsRtl="true"
android:theme="@style/Theme.ENotes"
tools:targetApi="31">
<activity
android:name=".OpenImage"
android:exported="false" />

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/map_key" />
Expand All @@ -44,15 +49,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".BroadcastService"

<receiver
android:name=".BroadcastService"
android:exported="true">
<intent-filter>
<action android:name="com.myaction.com">
</action>
<action android:name="com.myaction.com"></action>
</intent-filter>

</receiver>

</application>

</manifest>
28 changes: 22 additions & 6 deletions app/src/main/java/com/example/enotes/BroadcastService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package com.example.enotes
import android.R
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.core.app.NotificationCompat

import android.os.Build
import androidx.core.app.NotificationManagerCompat


Expand All @@ -29,11 +29,21 @@ class BroadcastService : BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {

var time= intent.getStringExtra("time")
val time= intent.getStringExtra("time")
Toast.makeText(context, "Successful", Toast.LENGTH_SHORT).show()
val title= intent.getStringExtra("title")


createNotificationChannel(context)
notifyNotification(context,time)
val notificationIntent = Intent(context, MainActivity::class.java)
notificationIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP

val pendingIntent = PendingIntent.getActivity(
context, 0, notificationIntent,
PendingIntent.FLAG_UPDATE_CURRENT
)

notifyNotification(context,time, title,pendingIntent)


if (time != null) {
Expand All @@ -54,12 +64,18 @@ class BroadcastService : BroadcastReceiver() {
}
}

private fun notifyNotification(context: Context, time: String?) {
private fun notifyNotification(
context: Context,
time: String?,
title: String?,
pendingIntent: PendingIntent
) {
with(NotificationManagerCompat.from(context)) {
val build = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
.setContentTitle(time)
.setContentText("Alarm.")
.setContentText(title)
.setSmallIcon(R.drawable.ic_lock_idle_alarm)
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)

notify(NOTIFICATION_ID, build.build())
Expand Down
52 changes: 45 additions & 7 deletions app/src/main/java/com/example/enotes/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,72 @@ package com.example.enotes

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.enotes.api.ApiClientSignupLogin
import com.example.enotes.models.request.LoginRequest
import com.example.enotes.models.response.LoginResponse
import com.example.enotes.models.response.RegisterResponse
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class Login : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)

val email = findViewById<EditText>(R.id.email)
val password = findViewById<EditText>(R.id.password)
val login_btn = findViewById<Button>(R.id.login_btn)
val forget_pswrd = findViewById<TextView>(R.id.forget_password)
val dont_have_accnt = findViewById<TextView>( R.id.signup)
val dont_have_accnt = findViewById<TextView>(R.id.signup)

login_btn.setOnClickListener {

val et_email = email.text.toString()
val et_pass = password.text.toString()

if (et_email.isNotEmpty() && et_pass.isNotEmpty()) {
loginUser(et_email, et_pass)
}
}

dont_have_accnt.setOnClickListener {
val intent = Intent(this@Login, MainActivity::class.java)
startActivity(intent)
finish()
}
}

private fun loginUser(email: String, password: String) {

val loginRequest = LoginRequest(email, password)
val apiCall = ApiClientSignupLogin.getApiService().loninUser(loginRequest)
apiCall.enqueue(object : Callback<LoginResponse> {
override fun onResponse(
call: Call<LoginResponse>,
response: Response<LoginResponse>
) {
if (response.isSuccessful) {
Toast.makeText(applicationContext, "this is toast message", Toast.LENGTH_LONG)
.show()
val intent = Intent(this@Login, MainActivity::class.java)
startActivity(intent)
finish()
}
}

dont_have_accnt.setOnClickListener{
val intent = Intent(this@Login, MainActivity::class.java)
startActivity(intent)
finish()
override fun onFailure(call: Call<LoginResponse>, t: Throwable) {
Toast.makeText(applicationContext, "" + t.localizedMessage, Toast.LENGTH_LONG)
.show()
Log.e("abc", "" + t.localizedMessage)
}
})
}
}
78 changes: 38 additions & 40 deletions app/src/main/java/com/example/enotes/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.example.enotes.databasehelper.DbHelper
import com.example.enotes.models.create_note
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.navigation.NavigationView
import kotlinx.android.synthetic.main.activity_main.*


class MainActivity : AppCompatActivity() {
Expand All @@ -26,93 +27,90 @@ class MainActivity : AppCompatActivity() {
lateinit var adapter: All_notes_adapter
lateinit var notesList: ArrayList<create_note>


fun getAllNotesFromDatabase() {
val db = DbHelper(this)
val show_notes = findViewById<RecyclerView>(R.id.show_notes)
show_notes.layoutManager= GridLayoutManager(this,2)

notesList = ArrayList()
notesList.addAll(db.viewnote())
adapter = All_notes_adapter(notesList, this)
show_notes.adapter = adapter

}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val db = DbHelper(this)
val notesList : ArrayList<create_note> = ArrayList()

notesList.addAll(db.viewnote())

show_notes.layoutManager = GridLayoutManager(this, 2)

// val show_notes = findViewById<RecyclerView>(R.id.show_notes)
// val adapter = All_notes_adapter(notesList,this)
// show_notes.adapter = adapter
// show_notes.layoutManager= GridLayoutManager(this,2)
// adapter.notifyDataSetChanged()



val add_notes = findViewById<FloatingActionButton>(R.id.add_notes)
add_notes.setOnClickListener{
add_notes.setOnClickListener {

val intent = Intent(this, Text_note::class.java)
startActivity(intent)

}




val dehaze = findViewById<ImageView>(R.id.dehaze)

val drawerlayout = findViewById<DrawerLayout>(R.id.my_drawer_layout)
val navView = findViewById<NavigationView>(R.id.navview)

dehaze.setOnClickListener {
drawerlayout.openDrawer(GravityCompat.START)
my_drawer_layout.openDrawer(GravityCompat.START)
}


toggle= ActionBarDrawerToggle(this,drawerlayout,R.string.open,R.string.close)
toggle = ActionBarDrawerToggle(this, my_drawer_layout, R.string.open, R.string.close)

drawerlayout.addDrawerListener(toggle)
my_drawer_layout.addDrawerListener(toggle)
toggle.syncState()

navview.itemIconTintList= null

supportActionBar?.setDisplayHomeAsUpEnabled(true)

navView.setNavigationItemSelectedListener {
when(it.itemId){
navview.setNavigationItemSelectedListener {
when (it.itemId) {
R.id.nav_allnotes ->
Toast.makeText(applicationContext,"all notes",Toast.LENGTH_SHORT).show()


Toast.makeText(applicationContext, "all notes", Toast.LENGTH_SHORT).show()
}
true
when(it.itemId){
R.id.nav_reminders ->
Toast.makeText(applicationContext,"all reminders",Toast.LENGTH_SHORT).show()


when (it.itemId) {
R.id.nav_travel ->
Toast.makeText(applicationContext, "all travels", Toast.LENGTH_SHORT).show()
}
when (it.itemId) {
R.id.nav_untag ->
Toast.makeText(applicationContext, "all untags", Toast.LENGTH_SHORT).show()
}
when (it.itemId) {
R.id.nav_life ->
Toast.makeText(applicationContext, "all lifes", Toast.LENGTH_SHORT).show()
}
when (it.itemId) {
R.id.nav_birthdays ->
Toast.makeText(applicationContext, "all birthdays", Toast.LENGTH_SHORT).show()
}
when (it.itemId) {
R.id.nav_peronal ->
Toast.makeText(applicationContext, "all personals", Toast.LENGTH_SHORT).show()
}
when (it.itemId) {
R.id.nav_work ->
Toast.makeText(applicationContext, "all works", Toast.LENGTH_SHORT).show()
}
true
}


}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (toggle.onOptionsItemSelected(item)){
if (toggle.onOptionsItemSelected(item)) {
return true
}
return super.onOptionsItemSelected(item)
}

override fun onResume() {
super.onResume()

getAllNotesFromDatabase()
}

}
Loading