Skip to content

Commit

Permalink
update the file name from Notes to Taaveez
Browse files Browse the repository at this point in the history
  • Loading branch information
Suryansh1720001 committed Aug 3, 2023
1 parent c911a1e commit c5c855d
Show file tree
Hide file tree
Showing 39 changed files with 664 additions and 603 deletions.
10 changes: 8 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.itssuryansh.taaveez">
<!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> -->

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
android:name=".NotesApp"
android:name=".TaaveezApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/com/itssuryansh/taaveez/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ package com.itssuryansh.taaveez

object Constants {

const val POEM_TOPIC: String = "poem_topic"
const val POEM_DES : String = "poem_des"
const val TAAVEEZ_CONTENT_TOPIC: String = "taaveez_content_topic"
const val TAAVEEZ_CONTENT_DESCRIPTION : String = "taaveez_content_description"
const val CREATED_DATE : String ="created_date"
const val UPDATED_DATE : String ="updated_date"
const val MyPrefs : String = "MyPrefss"
const val introShown : String = "introShown"
const val LINK : String = "link"
const val NORMAL_VIEW : String = "Normal_View"
const val DETAILED_VIEW: String = "Detailed_View"
const val ID = "id"
var Theme : String = "0"


}
10 changes: 0 additions & 10 deletions app/src/main/java/com/itssuryansh/taaveez/NotesApp.kt

This file was deleted.

24 changes: 0 additions & 24 deletions app/src/main/java/com/itssuryansh/taaveez/NotesDao.kt

This file was deleted.

15 changes: 0 additions & 15 deletions app/src/main/java/com/itssuryansh/taaveez/NotesEntity.kt

This file was deleted.

10 changes: 10 additions & 0 deletions app/src/main/java/com/itssuryansh/taaveez/TaaveezApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.itssuryansh.taaveez

import android.app.Application
import com.itssuryansh.taaveez.database.TaaveezDatabase

class TaaveezApp:Application() {
val db by lazy {
TaaveezDatabase.getInstance(this)
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/itssuryansh/taaveez/TaaveezDao.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.itssuryansh.taaveez

import androidx.room.*
import kotlinx.coroutines.flow.Flow

@Dao
interface TaaveezDao {

@Insert
suspend fun insert(TaaveezEntity : TaaveezEntity)

@Update
suspend fun update(TaaveezEntity : TaaveezEntity)

@Delete
suspend fun delete(TaaveezEntity : TaaveezEntity)

@Query("select * from `Taaveez-table`")
fun fetchAllContents(): Flow<List<TaaveezEntity>>

@Query("select * from `Taaveez-table` where id=:id")
fun fetchContentsById(id:Int):Flow<TaaveezEntity>

}
18 changes: 18 additions & 0 deletions app/src/main/java/com/itssuryansh/taaveez/TaaveezEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.itssuryansh.taaveez

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "Taaveez-table")
data class TaaveezEntity(
@PrimaryKey(autoGenerate = true)
val id: Int =0,
val Topic: String="",
val Content: String="",
val Date:String="",
val CreatedDate:String="",
val favorite:Boolean=false,
val SmallDes : String?=null,
val image : String?=null

)
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDelegate
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
import com.itssuryansh.taaveez.NotesApp
import com.itssuryansh.taaveez.NotesDao
import com.itssuryansh.taaveez.NotesEntity
import com.itssuryansh.taaveez.TaaveezApp
import com.itssuryansh.taaveez.TaaveezDao
import com.itssuryansh.taaveez.TaaveezEntity
import com.itssuryansh.taaveez.R
import com.itssuryansh.taaveez.databinding.ActivityAddNewContentBinding
import com.itssuryansh.taaveez.databinding.DialogBackAddNewContentBinding
Expand All @@ -35,7 +35,9 @@ import java.util.*
class Add_New_Content : AppCompatActivity() {

private var binding: ActivityAddNewContentBinding? = null
private val IMAGE_PICKER_REQUEST_CODE = 1001 // or any other unique value




@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -47,18 +49,48 @@ class Add_New_Content : AppCompatActivity() {
setContentView(binding?.root)

setupActionBar()
val NotesDao = (application as NotesApp).db.NotesDao()
val NotesDao = (application as TaaveezApp).db.TaaveezDao()
AddContent(NotesDao)
binding?.tvAddImage?.setOnClickListener{
val pictureDialog = android.app.AlertDialog.Builder(this)
pictureDialog.setTitle("Select Action")
val pickerDialogItem = arrayOf("Select photo from Gallery",
"Capture photo from camera")

pictureDialog.setItems(pickerDialogItem){
dialog,which->
when(which){
0 -> choosePhotoFromGallery()
1 -> choosePhotoFromGallery()

}
}
pictureDialog.show()
}
}

private fun takePhotoFromCamera() {
Toast.makeText(this@Add_New_Content,"Choose photo from camera",Toast.LENGTH_LONG).show()
}

private fun choosePhotoFromGallery() {
// requestStoragePermission()
Toast.makeText(this@Add_New_Content,"Choose photo from gallery",Toast.LENGTH_LONG).show()

}






override fun onBackPressed() {
// Call your desired method here
BackData()
}
@SuppressLint("ResourceType")

fun AddContent(NotesDao: NotesDao) {
fun AddContent(TaaveezDao: TaaveezDao) {

// bacground color change of richeditor
val typedValue = TypedValue()
Expand Down Expand Up @@ -139,28 +171,38 @@ class Add_New_Content : AppCompatActivity() {
binding?.saveContent?.setOnClickListener {
var itemTopic: String = binding?.idTopic?.text.toString()
val htmlContentPoemDes= PoemDes?.html.toString()
var smalldes :String?=null
// setup the date

val c = Calendar.getInstance()
val dateTime = c.time
Log.e("Date: ", "" + dateTime)
val sdf = SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.getDefault())
val date = sdf.format(dateTime)
Log.e("Formatted Date: ", "" + date)

// add new line here on 29 july
if(htmlContentPoemDes.length <= 20){
smalldes = htmlContentPoemDes + "..."
}else{
smalldes = "..."
}
Toast.makeText(this,"$smalldes",Toast.LENGTH_LONG).show()

if (PoemDes?.html!!.isNotEmpty()) {
if (!(TextUtils.isEmpty(itemTopic.trim { it <= ' ' }))) {
lifecycleScope.launch {
NotesDao.insert(NotesEntity(Topic = itemTopic, Poem = htmlContentPoemDes, Date = date, CreatedDate = date))
TaaveezDao.insert(TaaveezEntity(Topic = itemTopic, Content = htmlContentPoemDes, Date = date, CreatedDate = date, SmallDes = smalldes))
Toast.makeText(applicationContext,
getString(R.string.Record_saved),
Toast.LENGTH_LONG).show()
}
} else {
itemTopic = "दुआ"
lifecycleScope.launch {
NotesDao.insert(
NotesEntity(Topic = itemTopic, Poem = htmlContentPoemDes, Date = date,
CreatedDate = date )
TaaveezDao.insert(
TaaveezEntity(Topic = itemTopic, Content = htmlContentPoemDes, Date = date,
CreatedDate = date, SmallDes = smalldes )
)
Toast.makeText(applicationContext,
getString(R.string.Record_saved),
Expand Down
28 changes: 19 additions & 9 deletions app/src/main/java/com/itssuryansh/taaveez/activity/Edit_Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import java.util.*

class Edit_Content : AppCompatActivity() {
private var binding:ActivityEditContentBinding?=null
private lateinit var NotesDao: NotesDao
private lateinit var TaaveezDao: TaaveezDao


var CreatedDate:String=""
Expand All @@ -51,7 +51,7 @@ class Edit_Content : AppCompatActivity() {
setContentView(binding?.root)
setupActionBar()

NotesDao = (application as NotesApp).db.NotesDao()
TaaveezDao = (application as TaaveezApp).db.TaaveezDao()



Expand Down Expand Up @@ -107,12 +107,13 @@ class Edit_Content : AppCompatActivity() {
// setUP the content in the editview and richeditor from the Database
lifecycleScope.launch {

NotesDao.fetchNotesById(id!!).collect {
TaaveezDao.fetchContentsById(id!!).collect {
if (it != null) {
binding?.etPoemTopic?.setText(it.Topic)
binding?.etUpdatePoem?.setHtml(it.Poem)
binding?.etUpdatePoem?.setHtml(it.Content)
CreatedDate = it.CreatedDate


}
}

Expand Down Expand Up @@ -165,9 +166,10 @@ class Edit_Content : AppCompatActivity() {

private fun updateData() {
var Topic = binding?.etPoemTopic?.text.toString()
var Poem = binding?.etUpdatePoem?.html

var Description = binding?.etUpdatePoem?.html

var smalldes :String?=null
// setup the date

val c = Calendar.getInstance()
val dateTime = c.time
Expand All @@ -176,11 +178,19 @@ class Edit_Content : AppCompatActivity() {
val date = sdf.format(dateTime)
Log.e("Formatted Date: ", "" + date)

// add new line here on 29 july
if(Description.toString().length <=20){
smalldes = Description + "..."
}else{
smalldes = "..."
}
Toast.makeText(this,"$smalldes",Toast.LENGTH_LONG).show()


if (!(Poem!!.isEmpty())) {
if (!(Description!!.isEmpty())) {
if (!(TextUtils.isEmpty(Topic.trim { it <= ' ' }))) {
lifecycleScope.launch {
NotesDao.update(NotesEntity(id!!, Topic, Poem, date,CreatedDate))
TaaveezDao.update(TaaveezEntity(id!!, Topic, Description, date,CreatedDate, favorite=false,smalldes))
Toast.makeText(applicationContext, "Record Updated", Toast.LENGTH_LONG)
.show()
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
Expand All @@ -189,7 +199,7 @@ class Edit_Content : AppCompatActivity() {
} else {
Topic = "दुआ"
lifecycleScope.launch {
NotesDao.update(NotesEntity(id!!, Topic, Poem, date, CreatedDate))
TaaveezDao.update(TaaveezEntity(id!!, Topic, Description, date, CreatedDate, favorite=false,smalldes))
Toast.makeText(applicationContext, "Record Updated", Toast.LENGTH_LONG)
.show()
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
Expand Down
Loading

0 comments on commit c5c855d

Please sign in to comment.