Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Talking Reminder
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
RAUSHAN RAJ
Talking Reminder
Commits
57a1e323
Commit
57a1e323
authored
Nov 25, 2019
by
PANKAJ KUMAR
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further Cleanup
parent
630d3e89
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
441 additions
and
478 deletions
+441
-478
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-2
app/src/main/java/com/sudogeeks/talking_reminder/AlarmReceiver.java
...in/java/com/sudogeeks/talking_reminder/AlarmReceiver.java
+8
-23
app/src/main/java/com/sudogeeks/talking_reminder/BootReceiver.java
...ain/java/com/sudogeeks/talking_reminder/BootReceiver.java
+6
-10
app/src/main/java/com/sudogeeks/talking_reminder/DateTimeSorter.java
...n/java/com/sudogeeks/talking_reminder/DateTimeSorter.java
+3
-3
app/src/main/java/com/sudogeeks/talking_reminder/MainActivity.java
...ain/java/com/sudogeeks/talking_reminder/MainActivity.java
+135
-138
app/src/main/java/com/sudogeeks/talking_reminder/NotificationHelper.java
...va/com/sudogeeks/talking_reminder/NotificationHelper.java
+18
-16
app/src/main/java/com/sudogeeks/talking_reminder/ReadReminderTextService.java
...m/sudogeeks/talking_reminder/ReadReminderTextService.java
+5
-10
app/src/main/java/com/sudogeeks/talking_reminder/Reminder.java
...rc/main/java/com/sudogeeks/talking_reminder/Reminder.java
+4
-4
app/src/main/java/com/sudogeeks/talking_reminder/ReminderAddActivity.java
...a/com/sudogeeks/talking_reminder/ReminderAddActivity.java
+55
-58
app/src/main/java/com/sudogeeks/talking_reminder/ReminderDatabase.java
...java/com/sudogeeks/talking_reminder/ReminderDatabase.java
+20
-21
app/src/main/java/com/sudogeeks/talking_reminder/ReminderEditActivity.java
.../com/sudogeeks/talking_reminder/ReminderEditActivity.java
+40
-44
app/src/main/java/com/sudogeeks/talking_reminder/ReminderReceiveActivity.java
...m/sudogeeks/talking_reminder/ReminderReceiveActivity.java
+28
-32
app/src/main/res/layout/activity_add_reminder.xml
app/src/main/res/layout/activity_add_reminder.xml
+107
-111
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-2
app/src/main/res/values/colors.xml
app/src/main/res/values/colors.xml
+3
-3
app/src/main/res/values/styles.xml
app/src/main/res/values/styles.xml
+6
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
57a1e323
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:theme=
"@style/AppTheme"
android:theme=
"@style/AppTheme"
tools:replace=
"android:icon,android:theme"
>
tools:replace=
"android:icon,android:theme"
>
<activity
android:name=
"com.sudogeeks.talking_reminder.Read
TheMessag
e"
></activity>
<activity
android:name=
"com.sudogeeks.talking_reminder.Read
ReminderTextServic
e"
></activity>
<activity
android:name=
"com.sudogeeks.talking_reminder.ReminderReceiveActivity"
>
<activity
android:name=
"com.sudogeeks.talking_reminder.ReminderReceiveActivity"
>
<intent-filter>
<intent-filter>
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
</provider>
</provider>
<service
<service
android:name=
"com.sudogeeks.talking_reminder.Read
TheMessag
e"
android:name=
"com.sudogeeks.talking_reminder.Read
ReminderTextServic
e"
android:enabled=
"true"
/>
android:enabled=
"true"
/>
</application>
</application>
...
...
app/src/main/java/com/sudogeeks/talking_reminder/AlarmReceiver.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
...
@@ -24,17 +23,12 @@ public class AlarmReceiver extends BroadcastReceiver {
...
@@ -24,17 +23,12 @@ public class AlarmReceiver extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
int
mReceivedID
=
Integer
.
parseInt
(
intent
.
getStringExtra
(
ReminderEditActivity
.
EXTRA_REMINDER_ID
));
int
mReceivedID
=
Integer
.
parseInt
(
intent
.
getStringExtra
(
ReminderEditActivity
.
EXTRA_REMINDER_ID
));
//Get notification title from Reminder Database
//
//Get notification title from Reminder Database
ReminderDatabase
rb
=
new
ReminderDatabase
(
context
);
ReminderDatabase
rb
=
new
ReminderDatabase
(
context
);
Reminder
reminder
=
rb
.
getReminder
(
mReceivedID
);
Reminder
reminder
=
rb
.
getReminder
(
mReceivedID
);
String
mTitle
=
reminder
.
getTitle
();
String
mTitle
=
reminder
.
getTitle
();
// Create intent to open ReminderEditActivity on notification click
// Create intent to open ReminderEditActivity on notification click
Intent
editIntent
=
new
Intent
(
context
,
ReminderEditActivity
.
class
);
Intent
editIntent
=
new
Intent
(
context
,
ReminderEditActivity
.
class
);
editIntent
.
putExtra
(
ReminderEditActivity
.
EXTRA_REMINDER_ID
,
Integer
.
toString
(
mReceivedID
));
editIntent
.
putExtra
(
ReminderEditActivity
.
EXTRA_REMINDER_ID
,
Integer
.
toString
(
mReceivedID
));
...
@@ -54,42 +48,33 @@ public class AlarmReceiver extends BroadcastReceiver {
...
@@ -54,42 +48,33 @@ public class AlarmReceiver extends BroadcastReceiver {
//
//
// NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// nManager.notify(mReceivedID, mBuilder.build());
// nManager.notify(mReceivedID, mBuilder.build());
NotificationHelper
notificationHelper
=
new
NotificationHelper
(
context
,
intent
);
NotificationHelper
notificationHelper
=
new
NotificationHelper
(
context
,
intent
);
NotificationCompat
.
Builder
nb
=
notificationHelper
.
getChannelNotification
();
NotificationCompat
.
Builder
nb
=
notificationHelper
.
getChannelNotification
();
notificationHelper
.
getManager
().
notify
(
mReceivedID
,
nb
.
build
());
notificationHelper
.
getManager
().
notify
(
mReceivedID
,
nb
.
build
());
// tts
// tts
// context.startService(new Intent(context, ReadReminderTextService.class));
// context.startService(new Intent(context, ReadTheMessage.class));
Intent
i
=
new
Intent
(
context
,
ReadReminderTextService
.
class
);
Intent
i
=
new
Intent
(
context
,
ReadTheMessage
.
class
);
i
.
putExtra
(
"MyTitle"
,
mTitle
);
i
.
putExtra
(
"MyTitle"
,
mTitle
);
context
.
startService
(
i
);
context
.
startService
(
i
);
context
.
startService
(
i
);
context
.
startService
(
i
);
context
.
startService
(
i
);
context
.
startService
(
i
);
//context.startService(new Intent(context, ReadReminderTextService.class));
//context.startService(new Intent(context, ReadTheMessage.class));
// Intent speechIntent = new Intent();
// Intent speechIntent = new Intent();
// speechIntent.setClass(context, Read
TheMessag
e.class);
// speechIntent.setClass(context, Read
ReminderTextServic
e.class);
// speechIntent.putExtra("MESSAGE",mTitle );
// speechIntent.putExtra("MESSAGE",mTitle );
// speechIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
// speechIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
// context.startActivity(speechIntent);
// context.startActivity(speechIntent);
////
// Intent speechIntent = new Intent();
// Intent speechIntent = new Intent();
// speechIntent.putExtra("MESSAGE", "Bluetooth is on.");
// speechIntent.putExtra("MESSAGE", "Bluetooth is on.");
// Read
TheMessag
e.enqueueWork(context, speechIntent);
// Read
ReminderTextServic
e.enqueueWork(context, speechIntent);
//
//
...
@@ -137,7 +122,7 @@ public class AlarmReceiver extends BroadcastReceiver {
...
@@ -137,7 +122,7 @@ public class AlarmReceiver extends BroadcastReceiver {
// Start alarm using initial notification time and repeat interval time
// Start alarm using initial notification time and repeat interval time
mAlarmManager
.
setRepeating
(
AlarmManager
.
ELAPSED_REALTIME
,
mAlarmManager
.
setRepeating
(
AlarmManager
.
ELAPSED_REALTIME
,
SystemClock
.
elapsedRealtime
()
+
diffTime
,
SystemClock
.
elapsedRealtime
()
+
diffTime
,
RepeatTime
,
mPendingIntent
);
RepeatTime
,
mPendingIntent
);
// Restart alarm if device is rebooted
// Restart alarm if device is rebooted
ComponentName
receiver
=
new
ComponentName
(
context
,
BootReceiver
.
class
);
ComponentName
receiver
=
new
ComponentName
(
context
,
BootReceiver
.
class
);
...
...
app/src/main/java/com/sudogeeks/talking_reminder/BootReceiver.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
...
@@ -11,6 +10,12 @@ import java.util.List;
...
@@ -11,6 +10,12 @@ import java.util.List;
public
class
BootReceiver
extends
BroadcastReceiver
{
public
class
BootReceiver
extends
BroadcastReceiver
{
// Constant values in milliseconds
private
static
final
long
milMinute
=
60000L
;
private
static
final
long
milHour
=
3600000L
;
private
static
final
long
milDay
=
86400000L
;
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
private
String
mTitle
;
private
String
mTitle
;
private
String
mTime
;
private
String
mTime
;
private
String
mDate
;
private
String
mDate
;
...
@@ -22,18 +27,9 @@ public class BootReceiver extends BroadcastReceiver {
...
@@ -22,18 +27,9 @@ public class BootReceiver extends BroadcastReceiver {
private
String
[]
mTimeSplit
;
private
String
[]
mTimeSplit
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
,
mReceivedID
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
,
mReceivedID
;
private
long
mRepeatTime
;
private
long
mRepeatTime
;
private
Calendar
mCalendar
;
private
Calendar
mCalendar
;
private
AlarmReceiver
mAlarmReceiver
;
private
AlarmReceiver
mAlarmReceiver
;
// Constant values in milliseconds
private
static
final
long
milMinute
=
60000L
;
private
static
final
long
milHour
=
3600000L
;
private
static
final
long
milDay
=
86400000L
;
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
@Override
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
if
(
intent
.
getAction
().
equals
(
"android.intent.action.BOOT_COMPLETED"
))
{
if
(
intent
.
getAction
().
equals
(
"android.intent.action.BOOT_COMPLETED"
))
{
...
...
app/src/main/java/com/sudogeeks/talking_reminder/DateTimeSorter.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
// Class to create DateTime objects for easy sorting
// Class to create DateTime objects for easy sorting
...
@@ -7,12 +6,13 @@ public class DateTimeSorter {
...
@@ -7,12 +6,13 @@ public class DateTimeSorter {
public
String
mDateTime
;
public
String
mDateTime
;
public
DateTimeSorter
(
int
index
,
String
DateTime
){
public
DateTimeSorter
(
int
index
,
String
DateTime
)
{
mIndex
=
index
;
mIndex
=
index
;
mDateTime
=
DateTime
;
mDateTime
=
DateTime
;
}
}
public
DateTimeSorter
(){}
public
DateTimeSorter
()
{
}
public
int
getIndex
()
{
public
int
getIndex
()
{
...
...
app/src/main/java/com/sudogeeks/talking_reminder/MainActivity.java
View file @
57a1e323
This diff is collapsed.
Click to expand it.
app/src/main/java/com/sudogeeks/talking_reminder/NotificationHelper.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
//package com.example.application.alarmmanagerproject;
//package com.example.application.alarmmanagerproject;
import
androidx.core.app.NotificationCompat
;
import
android.annotation.TargetApi
;
import
android.annotation.TargetApi
;
import
android.app.NotificationChannel
;
import
android.app.NotificationChannel
;
...
@@ -10,10 +9,12 @@ import android.app.PendingIntent;
...
@@ -10,10 +9,12 @@ import android.app.PendingIntent;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.ContextWrapper
;
import
android.content.ContextWrapper
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.graphics.BitmapFactory
;
import
android.graphics.BitmapFactory
;
import
android.os.Build
;
import
android.speech.tts.TextToSpeech
;
import
android.speech.tts.TextToSpeech
;
import
androidx.core.app.NotificationCompat
;
public
class
NotificationHelper
extends
ContextWrapper
{
public
class
NotificationHelper
extends
ContextWrapper
{
public
static
final
String
channelID
=
"channelID"
;
public
static
final
String
channelID
=
"channelID"
;
...
@@ -22,12 +23,13 @@ public class NotificationHelper extends ContextWrapper {
...
@@ -22,12 +23,13 @@ public class NotificationHelper extends ContextWrapper {
PendingIntent
mClick
;
PendingIntent
mClick
;
private
NotificationManager
mManager
;
private
NotificationManager
mManager
;
private
TextToSpeech
t1
;
private
TextToSpeech
t1
;
// public Uri getFileUri(){
// public Uri getFileUri(){
//
//
//
//
// return
// return
// }
// }
public
NotificationHelper
(
Context
base
,
Intent
intent
)
{
public
NotificationHelper
(
Context
base
,
Intent
intent
)
{
super
(
base
);
super
(
base
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
createChannel
();
createChannel
();
...
@@ -64,27 +66,27 @@ public class NotificationHelper extends ContextWrapper {
...
@@ -64,27 +66,27 @@ public class NotificationHelper extends ContextWrapper {
public
NotificationCompat
.
Builder
getChannelNotification
()
{
public
NotificationCompat
.
Builder
getChannelNotification
()
{
//t1.speak(mTitle, TextToSpeech.QUEUE_FLUSH, null);
//t1.speak(mTitle, TextToSpeech.QUEUE_FLUSH, null);
// t1.synthesizeToFile(mTitle, null, "/SDCARD/speak1.wav");
// t1.synthesizeToFile(mTitle, null, "/SDCARD/speak1.wav");
//Uri alarmSound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/sample");
//Uri alarmSound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/sample");
return
new
NotificationCompat
.
Builder
(
getApplicationContext
(),
channelID
)
return
new
NotificationCompat
.
Builder
(
getApplicationContext
(),
channelID
)
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
getApplicationContext
().
getResources
(),
R
.
mipmap
.
ic_launcher
))
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
getApplicationContext
().
getResources
(),
R
.
mipmap
.
ic_launcher
))
.
setSmallIcon
(
R
.
drawable
.
ic_alarm_on_white_24dp
)
.
setSmallIcon
(
R
.
drawable
.
ic_alarm_on_white_24dp
)
.
setContentTitle
(
getApplicationContext
().
getResources
().
getString
(
R
.
string
.
app_name
))
.
setContentTitle
(
getApplicationContext
().
getResources
().
getString
(
R
.
string
.
app_name
))
.
setTicker
(
mTitle
)
.
setTicker
(
mTitle
)
.
setContentText
(
mTitle
)
.
setContentText
(
mTitle
)
//.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM))
//.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM))
// .setSound(Uri.fromFile(new File("SDCARD/s1.mp3")))
// .setSound(Uri.fromFile(new File("SDCARD/s1.mp3")))
//.setSound(null)
//.setSound(null)
.
setPriority
(
NotificationManager
.
IMPORTANCE_HIGH
)
.
setPriority
(
NotificationManager
.
IMPORTANCE_HIGH
)
.
setContentIntent
(
mClick
)
.
setContentIntent
(
mClick
)
.
setAutoCancel
(
true
)
.
setAutoCancel
(
true
)
.
setOnlyAlertOnce
(
true
);
.
setOnlyAlertOnce
(
true
);
}
}
public
TextToSpeech
getTextToSpeech
(){
public
TextToSpeech
getTextToSpeech
()
{
return
t1
;
return
t1
;
}
}
}
}
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReadReminderTextService.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
import
android.app.Service
;
import
android.app.Service
;
import
android.content.Intent
;
import
android.os.IBinder
;
import
android.os.IBinder
;
import
android.speech.tts.TextToSpeech
;
import
android.speech.tts.TextToSpeech
;
import
android.content.Intent
;
import
java.util.Locale
;
import
java.util.Locale
;
public
class
Read
TheMessag
e
extends
Service
implements
TextToSpeech
.
OnInitListener
,
TextToSpeech
.
OnUtteranceCompletedListener
{
public
class
Read
ReminderTextServic
e
extends
Service
implements
TextToSpeech
.
OnInitListener
,
TextToSpeech
.
OnUtteranceCompletedListener
{
private
TextToSpeech
mTts
;
private
TextToSpeech
mTts
;
private
String
spokenText
;
private
String
spokenText
;
...
@@ -18,11 +17,11 @@ public class ReadTheMessage extends Service implements TextToSpeech.OnInitListen
...
@@ -18,11 +17,11 @@ public class ReadTheMessage extends Service implements TextToSpeech.OnInitListen
public
void
onCreate
()
{
public
void
onCreate
()
{
mTts
=
new
TextToSpeech
(
this
,
this
);
mTts
=
new
TextToSpeech
(
this
,
this
);
// This is a good place to set spokenText
// This is a good place to set spokenText
// spokenText="raushan raushan raushan raushan";
// spokenText="raushan raushan raushan raushan";
}
}
@Override
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
spokenText
=
intent
.
getStringExtra
(
"MyTitle"
);
spokenText
=
intent
.
getStringExtra
(
"MyTitle"
);
return
START_STICKY
;
return
START_STICKY
;
}
}
...
@@ -35,10 +34,6 @@ public class ReadTheMessage extends Service implements TextToSpeech.OnInitListen
...
@@ -35,10 +34,6 @@ public class ReadTheMessage extends Service implements TextToSpeech.OnInitListen
mTts
.
speak
(
spokenText
,
TextToSpeech
.
QUEUE_ADD
,
null
);
mTts
.
speak
(
spokenText
,
TextToSpeech
.
QUEUE_ADD
,
null
);
}
}
}
}
}
}
...
...
app/src/main/java/com/sudogeeks/talking_reminder/Reminder.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
// Reminder class
// Reminder class
...
@@ -13,7 +12,7 @@ public class Reminder {
...
@@ -13,7 +12,7 @@ public class Reminder {
private
String
mActive
;
private
String
mActive
;
public
Reminder
(
int
ID
,
String
Title
,
String
Date
,
String
Time
,
String
Repeat
,
String
RepeatNo
,
String
RepeatType
,
String
Active
){
public
Reminder
(
int
ID
,
String
Title
,
String
Date
,
String
Time
,
String
Repeat
,
String
RepeatNo
,
String
RepeatType
,
String
Active
)
{
mID
=
ID
;
mID
=
ID
;
mTitle
=
Title
;
mTitle
=
Title
;
mDate
=
Date
;
mDate
=
Date
;
...
@@ -24,7 +23,7 @@ public class Reminder {
...
@@ -24,7 +23,7 @@ public class Reminder {
mActive
=
Active
;
mActive
=
Active
;
}
}
public
Reminder
(
String
Title
,
String
Date
,
String
Time
,
String
Repeat
,
String
RepeatNo
,
String
RepeatType
,
String
Active
){
public
Reminder
(
String
Title
,
String
Date
,
String
Time
,
String
Repeat
,
String
RepeatNo
,
String
RepeatType
,
String
Active
)
{
mTitle
=
Title
;
mTitle
=
Title
;
mDate
=
Date
;
mDate
=
Date
;
mTime
=
Time
;
mTime
=
Time
;
...
@@ -34,7 +33,8 @@ public class Reminder {
...
@@ -34,7 +33,8 @@ public class Reminder {
mActive
=
Active
;
mActive
=
Active
;
}
}
public
Reminder
(){}
public
Reminder
()
{
}
public
int
getID
()
{
public
int
getID
()
{
return
mID
;
return
mID
;
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderAddActivity.java
View file @
57a1e323
This diff is collapsed.
Click to expand it.
app/src/main/java/com/sudogeeks/talking_reminder/ReminderDatabase.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
import
android.content.ContentValues
;
import
android.content.ContentValues
;
...
@@ -64,15 +63,15 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -64,15 +63,15 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
}
// Adding new Reminder
// Adding new Reminder
public
int
addReminder
(
Reminder
reminder
){
public
int
addReminder
(
Reminder
reminder
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
();
ContentValues
values
=
new
ContentValues
();
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_REPEAT_TYPE
,
reminder
.
getRepeatType
());
values
.
put
(
KEY_REPEAT_TYPE
,
reminder
.
getRepeatType
());
values
.
put
(
KEY_ACTIVE
,
reminder
.
getActive
());
values
.
put
(
KEY_ACTIVE
,
reminder
.
getActive
());
...
@@ -83,7 +82,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -83,7 +82,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
}
// Getting single Reminder
// Getting single Reminder
public
Reminder
getReminder
(
int
id
){
public
Reminder
getReminder
(
int
id
)
{
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
query
(
TABLE_REMINDERS
,
new
String
[]
Cursor
cursor
=
db
.
query
(
TABLE_REMINDERS
,
new
String
[]
...
@@ -98,7 +97,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -98,7 +97,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
KEY_ACTIVE
KEY_ACTIVE
},
KEY_ID
+
"=?"
,
},
KEY_ID
+
"=?"
,
new
String
[]
{
String
.
valueOf
(
id
)},
null
,
null
,
null
,
null
);
new
String
[]{
String
.
valueOf
(
id
)},
null
,
null
,
null
,
null
);
if
(
cursor
!=
null
)
if
(
cursor
!=
null
)
cursor
.
moveToFirst
();
cursor
.
moveToFirst
();
...
@@ -111,7 +110,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -111,7 +110,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
}
// Getting all Reminders
// Getting all Reminders
public
List
<
Reminder
>
getAllReminders
(){
public
List
<
Reminder
>
getAllReminders
()
{
List
<
Reminder
>
reminderList
=
new
ArrayList
<>();
List
<
Reminder
>
reminderList
=
new
ArrayList
<>();
// Select all Query
// Select all Query
...
@@ -121,8 +120,8 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -121,8 +120,8 @@ public class ReminderDatabase extends SQLiteOpenHelper {
Cursor
cursor
=
db
.
rawQuery
(
selectQuery
,
null
);
Cursor
cursor
=
db
.
rawQuery
(
selectQuery
,
null
);
// Looping through all rows and adding to list
// Looping through all rows and adding to list
if
(
cursor
.
moveToFirst
())
{
if
(
cursor
.
moveToFirst
())
{
do
{
do
{
Reminder
reminder
=
new
Reminder
();
Reminder
reminder
=
new
Reminder
();
reminder
.
setID
(
Integer
.
parseInt
(
cursor
.
getString
(
0
)));
reminder
.
setID
(
Integer
.
parseInt
(
cursor
.
getString
(
0
)));
reminder
.
setTitle
(
cursor
.
getString
(
1
));
reminder
.
setTitle
(
cursor
.
getString
(
1
));
...
@@ -141,24 +140,24 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -141,24 +140,24 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
}
// Getting Reminders Count
// Getting Reminders Count
public
int
getRemindersCount
(){
public
int
getRemindersCount
()
{
String
countQuery
=
"SELECT * FROM "
+
TABLE_REMINDERS
;
String
countQuery
=
"SELECT * FROM "
+
TABLE_REMINDERS
;
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
countQuery
,
null
);
Cursor
cursor
=
db
.
rawQuery
(
countQuery
,
null
);
cursor
.
close
();
cursor
.
close
();
return
cursor
.
getCount
();
return
cursor
.
getCount
();
}
}
// Updating single Reminder
// Updating single Reminder
public
int
updateReminder
(
Reminder
reminder
){
public
int
updateReminder
(
Reminder
reminder
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
();
ContentValues
values
=
new
ContentValues
();
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_REPEAT_TYPE
,
reminder
.
getRepeatType
());
values
.
put
(
KEY_REPEAT_TYPE
,
reminder
.
getRepeatType
());
values
.
put
(
KEY_ACTIVE
,
reminder
.
getActive
());
values
.
put
(
KEY_ACTIVE
,
reminder
.
getActive
());
...
@@ -168,7 +167,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
...
@@ -168,7 +167,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
}
// Deleting single Reminder
// Deleting single Reminder
public
void
deleteReminder
(
Reminder
reminder
){
public
void
deleteReminder
(
Reminder
reminder
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
delete
(
TABLE_REMINDERS
,
KEY_ID
+
"=?"
,
db
.
delete
(
TABLE_REMINDERS
,
KEY_ID
+
"=?"
,
new
String
[]{
String
.
valueOf
(
reminder
.
getID
())});
new
String
[]{
String
.
valueOf
(
reminder
.
getID
())});
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderEditActivity.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
import
android.app.AlertDialog
;
import
android.app.AlertDialog
;
...
@@ -30,6 +29,22 @@ import java.util.Calendar;
...
@@ -30,6 +29,22 @@ import java.util.Calendar;
public
class
ReminderEditActivity
extends
AppCompatActivity
{
public
class
ReminderEditActivity
extends
AppCompatActivity
{
// Constant Intent String
public
static
final
String
EXTRA_REMINDER_ID
=
"Reminder_ID"
;
// Values for orientation change
private
static
final
String
KEY_TITLE
=
"title_key"
;
private
static
final
String
KEY_TIME
=
"time_key"
;
private
static
final
String
KEY_DATE
=
"date_key"
;
private
static
final
String
KEY_REPEAT
=
"repeat_key"
;
private
static
final
String
KEY_REPEAT_NO
=
"repeat_no_key"
;
private
static
final
String
KEY_REPEAT_TYPE
=
"repeat_type_key"
;
private
static
final
String
KEY_ACTIVE
=
"active_key"
;
// Constant values in milliseconds
private
static
final
long
milMinute
=
60000L
;
private
static
final
long
milHour
=
3600000L
;
private
static
final
long
milDay
=
86400000L
;
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
private
Toolbar
mToolbar
;
private
Toolbar
mToolbar
;
private
EditText
mTitleText
;
private
EditText
mTitleText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
...
@@ -53,42 +68,22 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -53,42 +68,22 @@ public class ReminderEditActivity extends AppCompatActivity {
private
ReminderDatabase
rb
;
private
ReminderDatabase
rb
;
private
AlarmReceiver
mAlarmReceiver
;
private
AlarmReceiver
mAlarmReceiver
;
// Constant Intent String
public
static
final
String
EXTRA_REMINDER_ID
=
"Reminder_ID"
;
// Values for orientation change
private
static
final
String
KEY_TITLE
=
"title_key"
;
private
static
final
String
KEY_TIME
=
"time_key"
;
private
static
final
String
KEY_DATE
=
"date_key"
;
private
static
final
String
KEY_REPEAT
=
"repeat_key"
;
private
static
final
String
KEY_REPEAT_NO
=
"repeat_no_key"
;
private
static
final
String
KEY_REPEAT_TYPE
=
"repeat_type_key"
;
private
static
final
String
KEY_ACTIVE
=
"active_key"
;
// Constant values in milliseconds
private
static
final
long
milMinute
=
60000L
;
private
static
final
long
milHour
=
3600000L
;
private
static
final
long
milDay
=
86400000L
;
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_add_reminder
);
setContentView
(
R
.
layout
.
activity_add_reminder
);
// Initialize Views
// Initialize Views
mToolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mToolbar
=
findViewById
(
R
.
id
.
toolbar
);
mTitleText
=
(
EditText
)
findViewById
(
R
.
id
.
reminder_title
);
mTitleText
=
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
(
TextView
)
findViewById
(
R
.
id
.
set_date
);
mDateText
=
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_time
);
mTimeText
=
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat
);
mRepeatText
=
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatNoText
=
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_type
);
mRepeatTypeText
=
findViewById
(
R
.
id
.
set_repeat_type
);
// mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
// mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
//mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
//mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
mRepeatSwitch
=
(
Switch
)
findViewById
(
R
.
id
.
repeat_switch
);
mRepeatSwitch
=
findViewById
(
R
.
id
.
repeat_switch
);
// Setup Toolbar
// Setup Toolbar
setSupportActionBar
(
mToolbar
);
setSupportActionBar
(
mToolbar
);
...
@@ -99,7 +94,8 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -99,7 +94,8 @@ public class ReminderEditActivity extends AppCompatActivity {
// Setup Reminder Title EditText
// Setup Reminder Title EditText
mTitleText
.
addTextChangedListener
(
new
TextWatcher
()
{
mTitleText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{}
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
...
@@ -108,7 +104,8 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -108,7 +104,8 @@ public class ReminderEditActivity extends AppCompatActivity {
}
}
@Override
@Override
public
void
afterTextChanged
(
Editable
s
)
{}
public
void
afterTextChanged
(
Editable
s
)
{
}
});
});
// Get reminder id from intent
// Get reminder id from intent
...
@@ -125,8 +122,8 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -125,8 +122,8 @@ public class ReminderEditActivity extends AppCompatActivity {
System.out.println("**********************************");
System.out.println("**********************************");
}
}
else {*/
else {*/
// Get reminder id from intent
// Get reminder id from intent
mReceivedReminder
=
rb
.
getReminder
(
mReceivedID
);
mReceivedReminder
=
rb
.
getReminder
(
mReceivedID
);
//}
//}
// Get values from reminder
// Get values from reminder
...
@@ -210,7 +207,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -210,7 +207,7 @@ public class ReminderEditActivity extends AppCompatActivity {
// To save state on device rotation
// To save state on device rotation
@Override
@Override
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
super
.
onSaveInstanceState
(
outState
);
super
.
onSaveInstanceState
(
outState
);
outState
.
putCharSequence
(
KEY_TITLE
,
mTitleText
.
getText
());
outState
.
putCharSequence
(
KEY_TITLE
,
mTitleText
.
getText
());
...
@@ -228,7 +225,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -228,7 +225,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
}
// On clicking Time picker
// On clicking Time picker
public
void
setTime
(
View
v
){
public
void
setTime
(
View
v
)
{
Calendar
now
=
Calendar
.
getInstance
();
Calendar
now
=
Calendar
.
getInstance
();
TimePickerDialog
timePickerDialog
=
new
TimePickerDialog
(
this
,
TimePickerDialog
timePickerDialog
=
new
TimePickerDialog
(
this
,
new
TimePickerDialog
.
OnTimeSetListener
()
{
new
TimePickerDialog
.
OnTimeSetListener
()
{
...
@@ -250,7 +247,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -250,7 +247,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
}
// On clicking Date picker
// On clicking Date picker
public
void
setDate
(
View
v
){
public
void
setDate
(
View
v
)
{
Calendar
now
=
Calendar
.
getInstance
();
Calendar
now
=
Calendar
.
getInstance
();
DatePickerDialog
datePickerDialog
=
new
DatePickerDialog
(
this
,
DatePickerDialog
datePickerDialog
=
new
DatePickerDialog
(
this
,
new
DatePickerDialog
.
OnDateSetListener
()
{
new
DatePickerDialog
.
OnDateSetListener
()
{
...
@@ -259,10 +256,10 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -259,10 +256,10 @@ public class ReminderEditActivity extends AppCompatActivity {
public
void
onDateSet
(
DatePicker
view
,
int
year
,
public
void
onDateSet
(
DatePicker
view
,
int
year
,
int
monthOfYear
,
int
dayOfMonth
)
{
int
monthOfYear
,
int
dayOfMonth
)
{
mDay
=
dayOfMonth
;
mDay
=
dayOfMonth
;
mMonth
=
monthOfYear
+
1
;
mMonth
=
monthOfYear
+
1
;
mYear
=
year
;
mYear
=
year
;
mDate
=
mDay
+
"/"
+
mMonth
+
"/"
+
mYear
;
mDate
=
mDay
+
"/"
+
mMonth
+
"/"
+
mYear
;
mDateText
.
setText
(
mDate
);
;
mDateText
.
setText
(
mDate
);
}
}
},
mYear
,
mMonth
,
mDay
);
},
mYear
,
mMonth
,
mDay
);
datePickerDialog
.
show
();
datePickerDialog
.
show
();
...
@@ -324,7 +321,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -324,7 +321,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
}
// On clicking repeat type button
// On clicking repeat type button
public
void
selectRepeatType
(
View
v
){
public
void
selectRepeatType
(
View
v
)
{
final
String
[]
items
=
new
String
[
5
];
final
String
[]
items
=
new
String
[
5
];
items
[
0
]
=
"Minute"
;
items
[
0
]
=
"Minute"
;
...
@@ -350,7 +347,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -350,7 +347,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
}
// On clicking repeat interval button
// On clicking repeat interval button
public
void
setRepeatNo
(
View
v
){
public
void
setRepeatNo
(
View
v
)
{
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
this
);
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
this
);
alert
.
setTitle
(
"Enter Number"
);
alert
.
setTitle
(
"Enter Number"
);
...
@@ -366,8 +363,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -366,8 +363,7 @@ public class ReminderEditActivity extends AppCompatActivity {
mRepeatNo
=
Integer
.
toString
(
1
);
mRepeatNo
=
Integer
.
toString
(
1
);
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
}
}
else
{
else
{
mRepeatNo
=
input
.
getText
().
toString
().
trim
();
mRepeatNo
=
input
.
getText
().
toString
().
trim
();
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
...
@@ -383,7 +379,7 @@ public class ReminderEditActivity extends AppCompatActivity {
...
@@ -383,7 +379,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
}
// On clicking the update button
// On clicking the update button
public
void
updateReminder
(){
public
void
updateReminder
()
{
// Set new values in the reminder
// Set new values in the reminder
mReceivedReminder
.
setTitle
(
mTitle
);
mReceivedReminder
.
setTitle
(
mTitle
);
mReceivedReminder
.
setDate
(
mDate
);
mReceivedReminder
.
setDate
(
mDate
);
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderReceiveActivity.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
package
com.sudogeeks.talking_reminder
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.net.Uri
;
...
@@ -13,31 +10,31 @@ import android.widget.EditText;
...
@@ -13,31 +10,31 @@ import android.widget.EditText;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Calendar
;
import
java.util.Calendar
;
public
class
ReminderReceiveActivity
extends
AppCompatActivity
{
public
class
ReminderReceiveActivity
extends
AppCompatActivity
{
private
static
final
long
milMinute
=
60000L
;
private
static
final
long
milHour
=
3600000L
;
private
static
final
long
milDay
=
86400000L
;
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
private
Toolbar
mToolbar
;
private
Toolbar
mToolbar
;
private
EditText
mTitleText
;
private
EditText
mTitleText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
private
String
mRepeat
;
private
String
mRepeat
;
private
String
mRepeatType
;
private
String
mRepeatType
;
private
String
mRepeatNo
;
private
String
mRepeatNo
;
private
Calendar
mCalendar
;
private
Calendar
mCalendar
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
;
private
long
mRepeatTime
;
private
long
mRepeatTime
;
private
String
mActive
;
private
String
mActive
;
private
static
final
long
milMinute
=
60000L
;
private
static
final
long
milHour
=
3600000L
;
private
static
final
long
milDay
=
86400000L
;
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -54,21 +51,21 @@ public class ReminderReceiveActivity extends AppCompatActivity {
...
@@ -54,21 +51,21 @@ public class ReminderReceiveActivity extends AppCompatActivity {
//by default
//by default
mActive
=
"true"
;
mActive
=
"true"
;
// Setup Toolbar
// Setup Toolbar
mToolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mToolbar
=
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
mToolbar
);
setSupportActionBar
(
mToolbar
);
getSupportActionBar
().
setTitle
(
R
.
string
.
activity_add_reminder_label
);
getSupportActionBar
().
setTitle
(
R
.
string
.
activity_add_reminder_label
);
//Get the file from intent
//Get the file from intent
Intent
intent
=
getIntent
();
Intent
intent
=
getIntent
();
Uri
fileUri
=
intent
.
getData
();
Uri
fileUri
=
intent
.
getData
();
StringBuilder
reminderJson
=
new
StringBuilder
();
StringBuilder
reminderJson
=
new
StringBuilder
();
if
(
intent
.
getType
().
equals
(
"text/"
+
Utility
.
FILE_EXTENSION
))
{
if
(
intent
.
getType
().
equals
(
"text/"
+
Utility
.
FILE_EXTENSION
))
{
try
{
try
{
InputStream
in
=
getContentResolver
().
openInputStream
(
fileUri
);
InputStream
in
=
getContentResolver
().
openInputStream
(
fileUri
);
int
i
;
int
i
;
while
((
i
=
in
.
read
())
!=
-
1
)
while
((
i
=
in
.
read
())
!=
-
1
)
reminderJson
.
append
((
char
)
i
);
reminderJson
.
append
((
char
)
i
);
//System.out.println("******************************************************************");
//System.out.println("******************************************************************");
//System.out.println(sb.toString());
//System.out.println(sb.toString());
//System.out.println("******************************************************************");
//System.out.println("******************************************************************");
...
@@ -79,27 +76,26 @@ public class ReminderReceiveActivity extends AppCompatActivity {
...
@@ -79,27 +76,26 @@ public class ReminderReceiveActivity extends AppCompatActivity {
try
{
try
{
JSONObject
obj
=
new
JSONObject
(
reminderJson
.
toString
());
JSONObject
obj
=
new
JSONObject
(
reminderJson
.
toString
());
//Reminder talkingReminder=new Reminder();
//Reminder talkingReminder=new Reminder();
mTitleText
=
(
EditText
)
findViewById
(
R
.
id
.
reminder_title
);
mTitleText
=
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
(
TextView
)
findViewById
(
R
.
id
.
set_date
);
mDateText
=
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_time
);
mTimeText
=
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat
);
mRepeatText
=
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatNoText
=
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_type
);
mRepeatTypeText
=
findViewById
(
R
.
id
.
set_repeat_type
);
mRepeat
=
obj
.
getString
(
"mRepeat"
);
mRepeat
=
obj
.
getString
(
"mRepeat"
);
mRepeatType
=
obj
.
getString
(
"mRepeatType"
);
mRepeatType
=
obj
.
getString
(
"mRepeatType"
);
mRepeatNo
=
obj
.
getString
(
"mRepeatNo"
);
mRepeatNo
=
obj
.
getString
(
"mRepeatNo"
);
mTitleText
.
setText
(
obj
.
getString
(
"mTitle"
));
mTitleText
.
setText
(
obj
.
getString
(
"mTitle"
));
mDateText
.
setText
(
obj
.
getString
(
"mDate"
));
mDateText
.
setText
(
obj
.
getString
(
"mDate"
));
mTimeText
.
setText
(
obj
.
getString
(
"mTime"
));
mTimeText
.
setText
(
obj
.
getString
(
"mTime"
));
mRepeatText
.
setText
(
"Every "
+
obj
.
getString
(
"mRepeatNo"
)+
" "
+
obj
.
getString
(
"mRepeatType"
)+
"(s)"
);
mRepeatText
.
setText
(
"Every "
+
obj
.
getString
(
"mRepeatNo"
)
+
" "
+
obj
.
getString
(
"mRepeatType"
)
+
"(s)"
);
mRepeatNoText
.
setText
(
obj
.
getString
(
"mRepeatNo"
));
mRepeatNoText
.
setText
(
obj
.
getString
(
"mRepeatNo"
));
mRepeatTypeText
.
setText
(
obj
.
getString
(
"mRepeatType"
));
mRepeatTypeText
.
setText
(
obj
.
getString
(
"mRepeatType"
));
}
}
catch
(
Throwable
t
)
{
catch
(
Throwable
t
){
t
.
printStackTrace
();
t
.
printStackTrace
();
}
}
...
@@ -111,7 +107,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
...
@@ -111,7 +107,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
}
}
}
}
public
void
saveSendReminder
(){
public
void
saveSendReminder
()
{
ReminderDatabase
rb
=
new
ReminderDatabase
(
this
);
ReminderDatabase
rb
=
new
ReminderDatabase
(
this
);
// Creating Reminder
// Creating Reminder
...
...
app/src/main/res/layout/activity_add_reminder.xml
View file @
57a1e323
This diff is collapsed.
Click to expand it.
app/src/main/res/layout/activity_main.xml
View file @
57a1e323
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:fab=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".MainActivity"
>
tools:context=
".MainActivity"
>
...
@@ -15,7 +14,7 @@
...
@@ -15,7 +14,7 @@
android:minHeight=
"?attr/actionBarSize"
android:minHeight=
"?attr/actionBarSize"
app:contentInsetLeft=
"0dp"
app:contentInsetLeft=
"0dp"
app:contentInsetStart=
"16dp"
app:contentInsetStart=
"16dp"
a
pp:theme=
"@style/ThemeOverlay.AppCompat.Dark.
ActionBar"
a
ndroid:theme=
"@style/AppTheme.No
ActionBar"
android:background=
"?attr/colorPrimary"
/>
android:background=
"?attr/colorPrimary"
/>
<androidx.recyclerview.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
...
...
app/src/main/res/values/colors.xml
View file @
57a1e323
<resources>
<resources>
<color
name=
"primary"
>
#
37474f
</color>
<color
name=
"primary"
>
#
008577
</color>
<color
name=
"primary_dark"
>
#
263238
</color>
<color
name=
"primary_dark"
>
#
00574B
</color>
<color
name=
"accent"
>
#
78909c
</color>
<color
name=
"accent"
>
#
D81B60
</color>
</resources>
</resources>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
57a1e323
<resources>
<resources>
<!-- Base application theme. -->
<!-- Base application theme. -->
<style
name=
"AppTheme"
parent=
"AppTheme.Base"
/>
<style
name=
"AppTheme"
parent=
"AppTheme.Base"
/>
<style
name=
"AppTheme.NoActionBar"
>
<item
name=
"windowActionBar"
>
false
</item>
<item
name=
"windowNoTitle"
>
true
</item>
</style>
<style
name=
"AppTheme.Base"
parent=
"Theme.AppCompat.NoActionBar"
>
<style
name=
"AppTheme.Base"
parent=
"Theme.AppCompat.NoActionBar"
>
<item
name=
"colorPrimary"
>
@color/primary
</item>
<item
name=
"colorPrimary"
>
@color/primary
</item>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment