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
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 @@
android:label=
"@string/app_name"
android:theme=
"@style/AppTheme"
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"
>
<intent-filter>
...
...
@@ -67,7 +67,7 @@
</provider>
<service
android:name=
"com.sudogeeks.talking_reminder.Read
TheMessag
e"
android:name=
"com.sudogeeks.talking_reminder.Read
ReminderTextServic
e"
android:enabled=
"true"
/>
</application>
...
...
app/src/main/java/com/sudogeeks/talking_reminder/AlarmReceiver.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
...
...
@@ -24,17 +23,12 @@ public class AlarmReceiver extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
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
);
Reminder
reminder
=
rb
.
getReminder
(
mReceivedID
);
String
mTitle
=
reminder
.
getTitle
();
// Create intent to open ReminderEditActivity on notification click
Intent
editIntent
=
new
Intent
(
context
,
ReminderEditActivity
.
class
);
editIntent
.
putExtra
(
ReminderEditActivity
.
EXTRA_REMINDER_ID
,
Integer
.
toString
(
mReceivedID
));
...
...
@@ -54,42 +48,33 @@ public class AlarmReceiver extends BroadcastReceiver {
//
// NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// nManager.notify(mReceivedID, mBuilder.build());
NotificationHelper
notificationHelper
=
new
NotificationHelper
(
context
,
intent
);
NotificationHelper
notificationHelper
=
new
NotificationHelper
(
context
,
intent
);
NotificationCompat
.
Builder
nb
=
notificationHelper
.
getChannelNotification
();
notificationHelper
.
getManager
().
notify
(
mReceivedID
,
nb
.
build
());
// tts
// context.startService(new Intent(context, ReadReminderTextService.class));
// context.startService(new Intent(context, ReadTheMessage.class));
Intent
i
=
new
Intent
(
context
,
ReadTheMessage
.
class
);
Intent
i
=
new
Intent
(
context
,
ReadReminderTextService
.
class
);
i
.
putExtra
(
"MyTitle"
,
mTitle
);
context
.
startService
(
i
);
context
.
startService
(
i
);
context
.
startService
(
i
);
//context.startService(new Intent(context, ReadTheMessage.class));
//context.startService(new Intent(context, ReadReminderTextService.class));
// Intent speechIntent = new Intent();
// speechIntent.setClass(context, Read
TheMessag
e.class);
// speechIntent.setClass(context, Read
ReminderTextServic
e.class);
// speechIntent.putExtra("MESSAGE",mTitle );
// speechIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
// context.startActivity(speechIntent);
////
// Intent speechIntent = new Intent();
// 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 {
// Start alarm using initial notification time and repeat interval time
mAlarmManager
.
setRepeating
(
AlarmManager
.
ELAPSED_REALTIME
,
SystemClock
.
elapsedRealtime
()
+
diffTime
,
RepeatTime
,
mPendingIntent
);
RepeatTime
,
mPendingIntent
);
// Restart alarm if device is rebooted
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
;
import
android.content.BroadcastReceiver
;
...
...
@@ -11,6 +10,12 @@ import java.util.List;
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
mTime
;
private
String
mDate
;
...
...
@@ -22,18 +27,9 @@ public class BootReceiver extends BroadcastReceiver {
private
String
[]
mTimeSplit
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
,
mReceivedID
;
private
long
mRepeatTime
;
private
Calendar
mCalendar
;
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
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
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
;
// Class to create DateTime objects for easy sorting
...
...
@@ -7,12 +6,13 @@ public class DateTimeSorter {
public
String
mDateTime
;
public
DateTimeSorter
(
int
index
,
String
DateTime
){
public
DateTimeSorter
(
int
index
,
String
DateTime
)
{
mIndex
=
index
;
mDateTime
=
DateTime
;
}
public
DateTimeSorter
(){}
public
DateTimeSorter
()
{
}
public
int
getIndex
()
{
...
...
app/src/main/java/com/sudogeeks/talking_reminder/MainActivity.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
import
android.content.Intent
;
...
...
@@ -48,61 +46,8 @@ public class MainActivity extends AppCompatActivity {
private
ReminderDatabase
rb
;
private
MultiSelector
mMultiSelector
=
new
MultiSelector
();
private
AlarmReceiver
mAlarmReceiver
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
// Initialize reminder database
rb
=
new
ReminderDatabase
(
getApplicationContext
());
// Initialize views
mToolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mAddReminderButton
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
add_reminder
);
reminderListView
=
(
RecyclerView
)
findViewById
(
R
.
id
.
reminder_list
);
mNoReminderView
=
(
TextView
)
findViewById
(
R
.
id
.
no_reminder_text
);
// To check is there are saved reminders
// If there are no reminders display a message asking the user to create reminders
List
<
Reminder
>
mTest
=
rb
.
getAllReminders
();
if
(
mTest
.
isEmpty
())
{
mNoReminderView
.
setVisibility
(
View
.
VISIBLE
);
}
// Create recycler view
reminderListView
.
setLayoutManager
(
getLayoutManager
());
registerForContextMenu
(
reminderListView
);
mAdapter
=
new
SimpleAdapter
();
mAdapter
.
setItemCount
(
getDefaultItemCount
());
reminderListView
.
setAdapter
(
mAdapter
);
// Setup toolbar
setSupportActionBar
(
mToolbar
);
mToolbar
.
setTitle
(
R
.
string
.
app_name
);
// On clicking the floating action button
mAddReminderButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
v
.
getContext
(),
ReminderAddActivity
.
class
);
startActivity
(
intent
);
}
});
// Initialize alarm
mAlarmReceiver
=
new
AlarmReceiver
();
}
// Create context menu for long press actions
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenu
.
ContextMenuInfo
menuInfo
)
{
getMenuInflater
().
inflate
(
R
.
menu
.
menu_add_reminder
,
menu
);
}
// Multi select items in recycler view
private
ModalMultiSelectorCallback
mDeleteMode
=
new
ModalMultiSelectorCallback
(
mMultiSelector
)
{
private
ModalMultiSelectorCallback
mDeleteMode
=
new
ModalMultiSelectorCallback
(
mMultiSelector
)
{
@Override
public
boolean
onCreateActionMode
(
ActionMode
actionMode
,
Menu
menu
)
{
...
...
@@ -173,6 +118,58 @@ public class MainActivity extends AppCompatActivity {
}
};
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
// Initialize reminder database
rb
=
new
ReminderDatabase
(
getApplicationContext
());
// Initialize views
mToolbar
=
findViewById
(
R
.
id
.
toolbar
);
mAddReminderButton
=
findViewById
(
R
.
id
.
add_reminder
);
reminderListView
=
findViewById
(
R
.
id
.
reminder_list
);
mNoReminderView
=
findViewById
(
R
.
id
.
no_reminder_text
);
// To check is there are saved reminders
// If there are no reminders display a message asking the user to create reminders
List
<
Reminder
>
mTest
=
rb
.
getAllReminders
();
if
(
mTest
.
isEmpty
())
{
mNoReminderView
.
setVisibility
(
View
.
VISIBLE
);
}
// Create recycler view
reminderListView
.
setLayoutManager
(
getLayoutManager
());
registerForContextMenu
(
reminderListView
);
mAdapter
=
new
SimpleAdapter
();
mAdapter
.
setItemCount
(
getDefaultItemCount
());
reminderListView
.
setAdapter
(
mAdapter
);
// Setup toolbar
setSupportActionBar
(
mToolbar
);
mToolbar
.
setTitle
(
R
.
string
.
app_name
);
// On clicking the floating action button
mAddReminderButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
intent
=
new
Intent
(
v
.
getContext
(),
ReminderAddActivity
.
class
);
startActivity
(
intent
);
}
});
// Initialize alarm
mAlarmReceiver
=
new
AlarmReceiver
();
}
// Create context menu for long press actions
@Override
public
void
onCreateContextMenu
(
ContextMenu
menu
,
View
v
,
ContextMenu
.
ContextMenuInfo
menuInfo
)
{
getMenuInflater
().
inflate
(
R
.
menu
.
menu_add_reminder
,
menu
);
}
// On clicking a reminder item
private
void
selectReminder
(
int
mClickID
)
{
String
mStringClickID
=
Integer
.
toString
(
mClickID
);
...
...
@@ -193,7 +190,7 @@ public class MainActivity extends AppCompatActivity {
// Recreate recycler view
// This is done so that newly created reminders are displayed
@Override
public
void
onResume
(){
public
void
onResume
()
{
super
.
onResume
();
// To check is there are saved reminders
...
...
@@ -250,12 +247,6 @@ public class MainActivity extends AppCompatActivity {
mItems
=
new
ArrayList
<>();
}
public
void
setItemCount
(
int
count
)
{
mItems
.
clear
();
mItems
.
addAll
(
generateData
(
count
));
notifyDataSetChanged
();
}
public
void
onDeleteItem
(
int
count
)
{
mItems
.
clear
();
mItems
.
addAll
(
generateData
(
count
));
...
...
@@ -290,8 +281,72 @@ public class MainActivity extends AppCompatActivity {
return
mItems
.
size
();
}
public
void
setItemCount
(
int
count
)
{
mItems
.
clear
();
mItems
.
addAll
(
generateData
(
count
));
notifyDataSetChanged
();
}
// Generate random test data
public
ReminderItem
generateDummyData
()
{
return
new
ReminderItem
(
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
);
}
// Generate real data for each item
public
List
<
ReminderItem
>
generateData
(
int
count
)
{
ArrayList
<
SimpleAdapter
.
ReminderItem
>
items
=
new
ArrayList
<>();
// Get all reminders from the database
List
<
Reminder
>
reminders
=
rb
.
getAllReminders
();
// Initialize lists
List
<
String
>
Titles
=
new
ArrayList
<>();
List
<
String
>
Repeats
=
new
ArrayList
<>();
List
<
String
>
RepeatNos
=
new
ArrayList
<>();
List
<
String
>
RepeatTypes
=
new
ArrayList
<>();
List
<
String
>
Actives
=
new
ArrayList
<>();
List
<
String
>
DateAndTime
=
new
ArrayList
<>();
List
<
Integer
>
IDList
=
new
ArrayList
<>();
List
<
DateTimeSorter
>
DateTimeSortList
=
new
ArrayList
<>();
// Add details of all reminders in their respective lists
for
(
Reminder
r
:
reminders
)
{
Titles
.
add
(
r
.
getTitle
());
DateAndTime
.
add
(
r
.
getDate
()
+
" "
+
r
.
getTime
());
Repeats
.
add
(
r
.
getRepeat
());
RepeatNos
.
add
(
r
.
getRepeatNo
());
RepeatTypes
.
add
(
r
.
getRepeatType
());
Actives
.
add
(
r
.
getActive
());
IDList
.
add
(
r
.
getID
());
}
int
key
=
0
;
// Add date and time as DateTimeSorter objects
for
(
int
k
=
0
;
k
<
Titles
.
size
();
k
++)
{
DateTimeSortList
.
add
(
new
DateTimeSorter
(
key
,
DateAndTime
.
get
(
k
)));
key
++;
}
// Sort items according to date and time in ascending order
Collections
.
sort
(
DateTimeSortList
,
new
DateTimeComparator
());
int
k
=
0
;
// Add data to each recycler view item
for
(
DateTimeSorter
item
:
DateTimeSortList
)
{
int
i
=
item
.
getIndex
();
items
.
add
(
new
SimpleAdapter
.
ReminderItem
(
Titles
.
get
(
i
),
DateAndTime
.
get
(
i
),
Repeats
.
get
(
i
),
RepeatNos
.
get
(
i
),
RepeatTypes
.
get
(
i
),
Actives
.
get
(
i
)));
IDmap
.
put
(
k
,
IDList
.
get
(
i
));
k
++;
}
return
items
;
}
// Class for recycler view items
public
class
ReminderItem
{
public
class
ReminderItem
{
public
String
mTitle
;
public
String
mDateTime
;
public
String
mRepeat
;
...
...
@@ -314,8 +369,8 @@ public class MainActivity extends AppCompatActivity {
DateFormat
f
=
new
SimpleDateFormat
(
"dd/mm/yyyy hh:mm"
);
public
int
compare
(
Object
a
,
Object
b
)
{
String
o1
=
((
DateTimeSorter
)
a
).
getDateTime
();
String
o2
=
((
DateTimeSorter
)
b
).
getDateTime
();
String
o1
=
((
DateTimeSorter
)
a
).
getDateTime
();
String
o2
=
((
DateTimeSorter
)
b
).
getDateTime
();
try
{
return
f
.
parse
(
o1
).
compareTo
(
f
.
parse
(
o2
));
...
...
@@ -326,10 +381,10 @@ public class MainActivity extends AppCompatActivity {
}
// UI and data class for recycler view items
public
class
VerticalItemHolder
extends
SwappingHolder
public
class
VerticalItemHolder
extends
SwappingHolder
implements
View
.
OnClickListener
,
View
.
OnLongClickListener
{
private
TextView
mTitleText
,
mDateAndTimeText
,
mRepeatInfoText
;
private
ImageView
mActiveImage
,
mThumbnailImage
;
private
ImageView
mActiveImage
,
mThumbnailImage
;
private
ColorGenerator
mColorGenerator
=
ColorGenerator
.
DEFAULT
;
private
TextDrawable
mDrawableBuilder
;
private
SimpleAdapter
mAdapter
;
...
...
@@ -344,11 +399,11 @@ public class MainActivity extends AppCompatActivity {
mAdapter
=
adapter
;
// Initialize views
mTitleText
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
recycle_title
);
mDateAndTimeText
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
recycle_date_time
);
mRepeatInfoText
=
(
TextView
)
itemView
.
findViewById
(
R
.
id
.
recycle_repeat_info
);
mActiveImage
=
(
ImageView
)
itemView
.
findViewById
(
R
.
id
.
active_image
);
mThumbnailImage
=
(
ImageView
)
itemView
.
findViewById
(
R
.
id
.
thumbnail_image
);
mTitleText
=
itemView
.
findViewById
(
R
.
id
.
recycle_title
);
mDateAndTimeText
=
itemView
.
findViewById
(
R
.
id
.
recycle_date_time
);
mRepeatInfoText
=
itemView
.
findViewById
(
R
.
id
.
recycle_repeat_info
);
mActiveImage
=
itemView
.
findViewById
(
R
.
id
.
active_image
);
mThumbnailImage
=
itemView
.
findViewById
(
R
.
id
.
thumbnail_image
);
}
// On clicking a reminder item
...
...
@@ -360,7 +415,7 @@ public class MainActivity extends AppCompatActivity {
int
mReminderClickID
=
IDmap
.
get
(
mTempPost
);
selectReminder
(
mReminderClickID
);
}
else
if
(
mMultiSelector
.
getSelectedPositions
().
isEmpty
())
{
}
else
if
(
mMultiSelector
.
getSelectedPositions
().
isEmpty
())
{
mAdapter
.
setItemCount
(
getDefaultItemCount
());
}
}
...
...
@@ -379,7 +434,7 @@ public class MainActivity extends AppCompatActivity {
mTitleText
.
setText
(
title
);
String
letter
=
"A"
;
if
(
title
!=
null
&&
!
title
.
isEmpty
())
{
if
(
title
!=
null
&&
!
title
.
isEmpty
())
{
letter
=
title
.
substring
(
0
,
1
);
}
...
...
@@ -398,79 +453,21 @@ public class MainActivity extends AppCompatActivity {
// Set repeat views
public
void
setReminderRepeatInfo
(
String
repeat
,
String
repeatNo
,
String
repeatType
)
{
if
(
repeat
.
equals
(
"true"
))
{
if
(
repeat
.
equals
(
"true"
))
{
mRepeatInfoText
.
setText
(
"Every "
+
repeatNo
+
" "
+
repeatType
+
"(s)"
);
}
else
if
(
repeat
.
equals
(
"false"
))
{
}
else
if
(
repeat
.
equals
(
"false"
))
{
mRepeatInfoText
.
setText
(
"Repeat Off"
);
}
}
// Set active image as on or off
public
void
setActiveImage
(
String
active
){
if
(
active
.
equals
(
"true"
))
{
public
void
setActiveImage
(
String
active
)
{
if
(
active
.
equals
(
"true"
))
{
mActiveImage
.
setImageResource
(
R
.
drawable
.
ic_notifications_on_white_24dp
);
}
else
if
(
active
.
equals
(
"false"
))
{
}
else
if
(
active
.
equals
(
"false"
))
{
mActiveImage
.
setImageResource
(
R
.
drawable
.
ic_notifications_off_grey600_24dp
);
}
}
}
// Generate random test data
public
ReminderItem
generateDummyData
()
{
return
new
ReminderItem
(
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
);
}
// Generate real data for each item
public
List
<
ReminderItem
>
generateData
(
int
count
)
{
ArrayList
<
SimpleAdapter
.
ReminderItem
>
items
=
new
ArrayList
<>();
// Get all reminders from the database
List
<
Reminder
>
reminders
=
rb
.
getAllReminders
();
// Initialize lists
List
<
String
>
Titles
=
new
ArrayList
<>();
List
<
String
>
Repeats
=
new
ArrayList
<>();
List
<
String
>
RepeatNos
=
new
ArrayList
<>();
List
<
String
>
RepeatTypes
=
new
ArrayList
<>();
List
<
String
>
Actives
=
new
ArrayList
<>();
List
<
String
>
DateAndTime
=
new
ArrayList
<>();
List
<
Integer
>
IDList
=
new
ArrayList
<>();
List
<
DateTimeSorter
>
DateTimeSortList
=
new
ArrayList
<>();
// Add details of all reminders in their respective lists
for
(
Reminder
r
:
reminders
)
{
Titles
.
add
(
r
.
getTitle
());
DateAndTime
.
add
(
r
.
getDate
()
+
" "
+
r
.
getTime
());
Repeats
.
add
(
r
.
getRepeat
());
RepeatNos
.
add
(
r
.
getRepeatNo
());
RepeatTypes
.
add
(
r
.
getRepeatType
());
Actives
.
add
(
r
.
getActive
());
IDList
.
add
(
r
.
getID
());
}
int
key
=
0
;
// Add date and time as DateTimeSorter objects
for
(
int
k
=
0
;
k
<
Titles
.
size
();
k
++){
DateTimeSortList
.
add
(
new
DateTimeSorter
(
key
,
DateAndTime
.
get
(
k
)));
key
++;
}
// Sort items according to date and time in ascending order
Collections
.
sort
(
DateTimeSortList
,
new
DateTimeComparator
());
int
k
=
0
;
// Add data to each recycler view item
for
(
DateTimeSorter
item:
DateTimeSortList
)
{
int
i
=
item
.
getIndex
();
items
.
add
(
new
SimpleAdapter
.
ReminderItem
(
Titles
.
get
(
i
),
DateAndTime
.
get
(
i
),
Repeats
.
get
(
i
),
RepeatNos
.
get
(
i
),
RepeatTypes
.
get
(
i
),
Actives
.
get
(
i
)));
IDmap
.
put
(
k
,
IDList
.
get
(
i
));
k
++;
}
return
items
;
}
}
}
app/src/main/java/com/sudogeeks/talking_reminder/NotificationHelper.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
//package com.example.application.alarmmanagerproject;
import
androidx.core.app.NotificationCompat
;
import
android.annotation.TargetApi
;
import
android.app.NotificationChannel
;
...
...
@@ -10,10 +9,12 @@ import android.app.PendingIntent;
import
android.content.Context
;
import
android.content.ContextWrapper
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.graphics.BitmapFactory
;
import
android.os.Build
;
import
android.speech.tts.TextToSpeech
;
import
androidx.core.app.NotificationCompat
;
public
class
NotificationHelper
extends
ContextWrapper
{
public
static
final
String
channelID
=
"channelID"
;
...
...
@@ -22,12 +23,13 @@ public class NotificationHelper extends ContextWrapper {
PendingIntent
mClick
;
private
NotificationManager
mManager
;
private
TextToSpeech
t1
;
// public Uri getFileUri(){
// public Uri getFileUri(){
//
//
// return
// }
public
NotificationHelper
(
Context
base
,
Intent
intent
)
{
public
NotificationHelper
(
Context
base
,
Intent
intent
)
{
super
(
base
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
createChannel
();
...
...
@@ -64,27 +66,27 @@ public class NotificationHelper extends ContextWrapper {
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");
return
new
NotificationCompat
.
Builder
(
getApplicationContext
(),
channelID
)
.
setLargeIcon
(
BitmapFactory
.
decodeResource
(
getApplicationContext
().
getResources
(),
R
.
mipmap
.
ic_launcher
))
.
setSmallIcon
(
R
.
drawable
.
ic_alarm_on_white_24dp
)
.
setContentTitle
(
getApplicationContext
().
getResources
().
getString
(
R
.
string
.
app_name
))
.
setTicker
(
mTitle
)
.
setContentText
(
mTitle
)
//.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM))
.
setSmallIcon
(
R
.
drawable
.
ic_alarm_on_white_24dp
)
.
setContentTitle
(
getApplicationContext
().
getResources
().
getString
(
R
.
string
.
app_name
))
.
setTicker
(
mTitle
)
.
setContentText
(
mTitle
)
//.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM))
// .setSound(Uri.fromFile(new File("SDCARD/s1.mp3")))
//.setSound(null)
//.setSound(null)
.
setPriority
(
NotificationManager
.
IMPORTANCE_HIGH
)
.
setContentIntent
(
mClick
)
.
setAutoCancel
(
true
)
.
setOnlyAlertOnce
(
true
);
.
setContentIntent
(
mClick
)
.
setAutoCancel
(
true
)
.
setOnlyAlertOnce
(
true
);
}
public
TextToSpeech
getTextToSpeech
(){
public
TextToSpeech
getTextToSpeech
()
{
return
t1
;
}
}
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReadReminderTextService.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
import
android.app.Service
;
import
android.content.Intent
;
import
android.os.IBinder
;
import
android.speech.tts.TextToSpeech
;
import
android.content.Intent
;
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
String
spokenText
;
...
...
@@ -18,11 +17,11 @@ public class ReadTheMessage extends Service implements TextToSpeech.OnInitListen
public
void
onCreate
()
{
mTts
=
new
TextToSpeech
(
this
,
this
);
// This is a good place to set spokenText
// spokenText="raushan raushan raushan raushan";
// spokenText="raushan raushan raushan raushan";
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
spokenText
=
intent
.
getStringExtra
(
"MyTitle"
);
return
START_STICKY
;
}
...
...
@@ -35,10 +34,6 @@ public class ReadTheMessage extends Service implements TextToSpeech.OnInitListen
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
;
// Reminder class
...
...
@@ -13,7 +12,7 @@ public class Reminder {
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
;
mTitle
=
Title
;
mDate
=
Date
;
...
...
@@ -24,7 +23,7 @@ public class Reminder {
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
;
mDate
=
Date
;
mTime
=
Time
;
...
...
@@ -34,7 +33,8 @@ public class Reminder {
mActive
=
Active
;
}
public
Reminder
(){}
public
Reminder
()
{
}
public
int
getID
()
{
return
mID
;
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderAddActivity.java
View file @
57a1e323
...
...
@@ -40,22 +40,6 @@ import java.util.Calendar;
public
class
ReminderAddActivity
extends
AppCompatActivity
{
private
Toolbar
mToolbar
;
private
EditText
mTitleText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
private
FloatingActionButton
mFAB1
;
private
FloatingActionButton
mFAB2
;
private
Calendar
mCalendar
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
;
private
long
mRepeatTime
;
private
String
mTitle
;
private
String
mTime
;
private
String
mDate
;
private
String
mRepeat
;
private
String
mRepeatNo
;
private
String
mRepeatType
;
private
String
mActive
;
// Values for orientation change
private
static
final
String
KEY_TITLE
=
"title_key"
;
private
static
final
String
KEY_TIME
=
"time_key"
;
...
...
@@ -64,7 +48,6 @@ public class ReminderAddActivity extends AppCompatActivity {
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
;
...
...
@@ -72,6 +55,21 @@ public class ReminderAddActivity extends AppCompatActivity {
private
static
final
long
milWeek
=
604800000L
;
private
static
final
long
milMonth
=
2592000000L
;
private
static
final
int
MY_PERMISSIONS_REQUEST_WRITE_CONTACTS
=
1
;
private
Toolbar
mToolbar
;
private
EditText
mTitleText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
private
FloatingActionButton
mFAB1
;
private
FloatingActionButton
mFAB2
;
private
Calendar
mCalendar
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
;
private
long
mRepeatTime
;
private
String
mTitle
;
private
String
mTime
;
private
String
mDate
;
private
String
mRepeat
;
private
String
mRepeatNo
;
private
String
mRepeatType
;
private
String
mActive
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -79,15 +77,15 @@ public class ReminderAddActivity extends AppCompatActivity {
setContentView
(
R
.
layout
.
activity_add_reminder
);
// Initialize Views
mToolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mTitleText
=
(
EditText
)
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
(
TextView
)
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_type
);
mFAB1
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
starred1
);
mFAB2
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
starred2
);
mToolbar
=
findViewById
(
R
.
id
.
toolbar
);
mTitleText
=
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
findViewById
(
R
.
id
.
set_repeat_type
);
mFAB1
=
findViewById
(
R
.
id
.
starred1
);
mFAB2
=
findViewById
(
R
.
id
.
starred2
);
// Setup Toolbar
setSupportActionBar
(
mToolbar
);
...
...
@@ -115,7 +113,8 @@ public class ReminderAddActivity extends AppCompatActivity {
mTitleText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{}
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
...
...
@@ -124,7 +123,8 @@ public class ReminderAddActivity extends AppCompatActivity {
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{}
public
void
afterTextChanged
(
Editable
s
)
{
}
});
// Setup TextViews using reminder values
...
...
@@ -176,7 +176,7 @@ public class ReminderAddActivity extends AppCompatActivity {
// To save state on device rotation
@Override
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
super
.
onSaveInstanceState
(
outState
);
outState
.
putCharSequence
(
KEY_TITLE
,
mTitleText
.
getText
());
...
...
@@ -189,7 +189,7 @@ public class ReminderAddActivity extends AppCompatActivity {
}
// On clicking Time picker
public
void
setTime
(
View
v
){
public
void
setTime
(
View
v
)
{
Calendar
now
=
Calendar
.
getInstance
();
TimePickerDialog
timePickerDialog
=
new
TimePickerDialog
(
this
,
new
TimePickerDialog
.
OnTimeSetListener
()
{
...
...
@@ -212,7 +212,7 @@ public class ReminderAddActivity extends AppCompatActivity {
}
// On clicking Date picker
public
void
setDate
(
View
v
){
public
void
setDate
(
View
v
)
{
Calendar
now
=
Calendar
.
getInstance
();
DatePickerDialog
datePickerDialog
=
new
DatePickerDialog
(
this
,
new
DatePickerDialog
.
OnDateSetListener
()
{
...
...
@@ -222,7 +222,7 @@ public class ReminderAddActivity extends AppCompatActivity {
int
monthOfYear
,
int
dayOfMonth
)
{
mDay
=
dayOfMonth
;
mMonth
=
monthOfYear
+
1
;
mMonth
=
monthOfYear
+
1
;
mYear
=
year
;
mDate
=
mDay
+
"/"
+
mMonth
+
"/"
+
mYear
;
mDateText
.
setText
(
mDate
);
...
...
@@ -258,18 +258,18 @@ public class ReminderAddActivity extends AppCompatActivity {
// On clicking the active button
public
void
selectFab1
(
View
v
)
{
mFAB1
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
starred1
);
mFAB1
=
findViewById
(
R
.
id
.
starred1
);
mFAB1
.
hide
();
mFAB2
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
starred2
);
mFAB2
=
findViewById
(
R
.
id
.
starred2
);
mFAB2
.
show
();
mActive
=
"true"
;
}
// On clicking the inactive button
public
void
selectFab2
(
View
v
)
{
mFAB2
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
starred2
);
mFAB2
=
findViewById
(
R
.
id
.
starred2
);
mFAB2
.
hide
();
mFAB1
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
starred1
);
mFAB1
=
findViewById
(
R
.
id
.
starred1
);
mFAB1
.
show
();
mActive
=
"false"
;
}
...
...
@@ -287,7 +287,7 @@ public class ReminderAddActivity extends AppCompatActivity {
}
// On clicking repeat type button
public
void
selectRepeatType
(
View
v
){
public
void
selectRepeatType
(
View
v
)
{
final
String
[]
items
=
new
String
[
5
];
items
[
0
]
=
"Minute"
;
...
...
@@ -313,7 +313,7 @@ public class ReminderAddActivity extends AppCompatActivity {
}
// On clicking repeat interval button
public
void
setRepeatNo
(
View
v
){
public
void
setRepeatNo
(
View
v
)
{
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
this
);
alert
.
setTitle
(
"Enter Number"
);
...
...
@@ -329,8 +329,7 @@ public class ReminderAddActivity extends AppCompatActivity {
mRepeatNo
=
Integer
.
toString
(
1
);
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
}
else
{
}
else
{
mRepeatNo
=
input
.
getText
().
toString
().
trim
();
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
...
...
@@ -347,13 +346,11 @@ public class ReminderAddActivity extends AppCompatActivity {
public
boolean
isExternalStorageWritable
()
{
String
state
=
Environment
.
getExternalStorageState
();
if
(
Environment
.
MEDIA_MOUNTED
.
equals
(
state
))
{
return
true
;
}
return
false
;
return
Environment
.
MEDIA_MOUNTED
.
equals
(
state
);
}
//on clicking the send button
public
void
saveReminderToTempStorage
(
String
filename
){
public
void
saveReminderToTempStorage
(
String
filename
)
{
/* mTitleText = (EditText) findViewById(R.id.reminder_title);
mDateText = (TextView) findViewById(R.id.set_date);
mTimeText = (TextView) findViewById(R.id.set_time);
...
...
@@ -361,7 +358,7 @@ public class ReminderAddActivity extends AppCompatActivity {
mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no);
mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type);
*/
Reminder
talkingReminder
=
new
Reminder
();
Reminder
talkingReminder
=
new
Reminder
();
talkingReminder
.
setTitle
(
mTitle
);
talkingReminder
.
setDate
(
mDate
);
talkingReminder
.
setTime
(
mTime
);
...
...
@@ -374,7 +371,7 @@ public class ReminderAddActivity extends AppCompatActivity {
//First write the data to a temporary file
FileOutputStream
outputStream
;
if
(
ContextCompat
.
checkSelfPermission
(
ReminderAddActivity
.
this
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
ContextCompat
.
checkSelfPermission
(
ReminderAddActivity
.
this
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
// Permission is not granted
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
ReminderAddActivity
.
this
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
))
{
// Show an explanation to the user *asynchronously* -- don't block
...
...
@@ -386,24 +383,24 @@ public class ReminderAddActivity extends AppCompatActivity {
}
}
try
{
String
fileContents
=
gson
.
toJson
(
talkingReminder
);
outputStream
=
openFileOutput
(
filename
,
Context
.
MODE_PRIVATE
);
outputStream
.
write
(
fileContents
.
getBytes
());
outputStream
.
close
();
try
{
String
fileContents
=
gson
.
toJson
(
talkingReminder
);
outputStream
=
openFileOutput
(
filename
,
Context
.
MODE_PRIVATE
);
outputStream
.
write
(
fileContents
.
getBytes
());
outputStream
.
close
();
// FileWriter fw = new FileWriter(filename);
// BufferedWriter bw = new BufferedWriter(fw);
// bw.write(content);
// bw.close();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
// On clicking the save button
public
void
saveReminder
(){
public
void
saveReminder
()
{
ReminderDatabase
rb
=
new
ReminderDatabase
(
this
);
// Creating Reminder
...
...
@@ -520,11 +517,11 @@ public class ReminderAddActivity extends AppCompatActivity {
File
filePath
=
context
.
getFilesDir
();
File
fileToSend
=
new
File
(
filePath
,
filename
);
Uri
fileUri
=
FileProvider
.
getUriForFile
(
context
,
"com.sudogeeks.talking_reminder.fileprovider"
,
fileToSend
);
//TODO remove hardcoded dependencies
"com.sudogeeks.talking_reminder.fileprovider"
,
fileToSend
);
//TODO remove hardcoded dependencies
Intent
share
=
new
Intent
();
share
.
setAction
(
Intent
.
ACTION_SEND
);
share
.
putExtra
(
Intent
.
EXTRA_STREAM
,
fileUri
);
share
.
setType
(
"text/"
+
Utility
.
FILE_EXTENSION
);
share
.
setType
(
"text/"
+
Utility
.
FILE_EXTENSION
);
//share.setDataAndType( fileUri, getContentResolver().getType(fileUri));
share
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
//share.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderDatabase.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
import
android.content.ContentValues
;
...
...
@@ -64,15 +63,15 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
// Adding new Reminder
public
int
addReminder
(
Reminder
reminder
){
public
int
addReminder
(
Reminder
reminder
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
();
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_REPEAT_TYPE
,
reminder
.
getRepeatType
());
values
.
put
(
KEY_ACTIVE
,
reminder
.
getActive
());
...
...
@@ -83,7 +82,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
// Getting single Reminder
public
Reminder
getReminder
(
int
id
){
public
Reminder
getReminder
(
int
id
)
{
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
query
(
TABLE_REMINDERS
,
new
String
[]
...
...
@@ -98,7 +97,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
KEY_ACTIVE
},
KEY_ID
+
"=?"
,
new
String
[]
{
String
.
valueOf
(
id
)},
null
,
null
,
null
,
null
);
new
String
[]{
String
.
valueOf
(
id
)},
null
,
null
,
null
,
null
);
if
(
cursor
!=
null
)
cursor
.
moveToFirst
();
...
...
@@ -111,7 +110,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
// Getting all Reminders
public
List
<
Reminder
>
getAllReminders
(){
public
List
<
Reminder
>
getAllReminders
()
{
List
<
Reminder
>
reminderList
=
new
ArrayList
<>();
// Select all Query
...
...
@@ -121,8 +120,8 @@ public class ReminderDatabase extends SQLiteOpenHelper {
Cursor
cursor
=
db
.
rawQuery
(
selectQuery
,
null
);
// Looping through all rows and adding to list
if
(
cursor
.
moveToFirst
())
{
do
{
if
(
cursor
.
moveToFirst
())
{
do
{
Reminder
reminder
=
new
Reminder
();
reminder
.
setID
(
Integer
.
parseInt
(
cursor
.
getString
(
0
)));
reminder
.
setTitle
(
cursor
.
getString
(
1
));
...
...
@@ -141,24 +140,24 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
// Getting Reminders Count
public
int
getRemindersCount
(){
public
int
getRemindersCount
()
{
String
countQuery
=
"SELECT * FROM "
+
TABLE_REMINDERS
;
SQLiteDatabase
db
=
this
.
getReadableDatabase
();
Cursor
cursor
=
db
.
rawQuery
(
countQuery
,
null
);
Cursor
cursor
=
db
.
rawQuery
(
countQuery
,
null
);
cursor
.
close
();
return
cursor
.
getCount
();
}
// Updating single Reminder
public
int
updateReminder
(
Reminder
reminder
){
public
int
updateReminder
(
Reminder
reminder
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
();
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_TITLE
,
reminder
.
getTitle
());
values
.
put
(
KEY_DATE
,
reminder
.
getDate
());
values
.
put
(
KEY_TIME
,
reminder
.
getTime
());
values
.
put
(
KEY_REPEAT
,
reminder
.
getRepeat
());
values
.
put
(
KEY_REPEAT_NO
,
reminder
.
getRepeatNo
());
values
.
put
(
KEY_REPEAT_TYPE
,
reminder
.
getRepeatType
());
values
.
put
(
KEY_ACTIVE
,
reminder
.
getActive
());
...
...
@@ -168,7 +167,7 @@ public class ReminderDatabase extends SQLiteOpenHelper {
}
// Deleting single Reminder
public
void
deleteReminder
(
Reminder
reminder
){
public
void
deleteReminder
(
Reminder
reminder
)
{
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
db
.
delete
(
TABLE_REMINDERS
,
KEY_ID
+
"=?"
,
new
String
[]{
String
.
valueOf
(
reminder
.
getID
())});
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderEditActivity.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
import
android.app.AlertDialog
;
...
...
@@ -30,6 +29,22 @@ import java.util.Calendar;
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
EditText
mTitleText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
...
...
@@ -53,42 +68,22 @@ public class ReminderEditActivity extends AppCompatActivity {
private
ReminderDatabase
rb
;
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
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_add_reminder
);
// Initialize Views
mToolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mTitleText
=
(
EditText
)
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
(
TextView
)
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_type
);
// mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
mToolbar
=
findViewById
(
R
.
id
.
toolbar
);
mTitleText
=
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
findViewById
(
R
.
id
.
set_repeat_type
);
// mFAB1 = (FloatingActionButton) findViewById(R.id.starred1);
//mFAB2 = (FloatingActionButton) findViewById(R.id.starred2);
mRepeatSwitch
=
(
Switch
)
findViewById
(
R
.
id
.
repeat_switch
);
mRepeatSwitch
=
findViewById
(
R
.
id
.
repeat_switch
);
// Setup Toolbar
setSupportActionBar
(
mToolbar
);
...
...
@@ -99,7 +94,8 @@ public class ReminderEditActivity extends AppCompatActivity {
// Setup Reminder Title EditText
mTitleText
.
addTextChangedListener
(
new
TextWatcher
()
{
@Override
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{}
public
void
beforeTextChanged
(
CharSequence
s
,
int
start
,
int
count
,
int
after
)
{
}
@Override
public
void
onTextChanged
(
CharSequence
s
,
int
start
,
int
before
,
int
count
)
{
...
...
@@ -108,7 +104,8 @@ public class ReminderEditActivity extends AppCompatActivity {
}
@Override
public
void
afterTextChanged
(
Editable
s
)
{}
public
void
afterTextChanged
(
Editable
s
)
{
}
});
// Get reminder id from intent
...
...
@@ -125,8 +122,8 @@ public class ReminderEditActivity extends AppCompatActivity {
System.out.println("**********************************");
}
else {*/
// Get reminder id from intent
mReceivedReminder
=
rb
.
getReminder
(
mReceivedID
);
// Get reminder id from intent
mReceivedReminder
=
rb
.
getReminder
(
mReceivedID
);
//}
// Get values from reminder
...
...
@@ -210,7 +207,7 @@ public class ReminderEditActivity extends AppCompatActivity {
// To save state on device rotation
@Override
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
protected
void
onSaveInstanceState
(
Bundle
outState
)
{
super
.
onSaveInstanceState
(
outState
);
outState
.
putCharSequence
(
KEY_TITLE
,
mTitleText
.
getText
());
...
...
@@ -228,7 +225,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
// On clicking Time picker
public
void
setTime
(
View
v
){
public
void
setTime
(
View
v
)
{
Calendar
now
=
Calendar
.
getInstance
();
TimePickerDialog
timePickerDialog
=
new
TimePickerDialog
(
this
,
new
TimePickerDialog
.
OnTimeSetListener
()
{
...
...
@@ -250,7 +247,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
// On clicking Date picker
public
void
setDate
(
View
v
){
public
void
setDate
(
View
v
)
{
Calendar
now
=
Calendar
.
getInstance
();
DatePickerDialog
datePickerDialog
=
new
DatePickerDialog
(
this
,
new
DatePickerDialog
.
OnDateSetListener
()
{
...
...
@@ -259,10 +256,10 @@ public class ReminderEditActivity extends AppCompatActivity {
public
void
onDateSet
(
DatePicker
view
,
int
year
,
int
monthOfYear
,
int
dayOfMonth
)
{
mDay
=
dayOfMonth
;
mMonth
=
monthOfYear
+
1
;
mMonth
=
monthOfYear
+
1
;
mYear
=
year
;
mDate
=
mDay
+
"/"
+
mMonth
+
"/"
+
mYear
;
mDateText
.
setText
(
mDate
);
;
mDateText
.
setText
(
mDate
);
}
},
mYear
,
mMonth
,
mDay
);
datePickerDialog
.
show
();
...
...
@@ -324,7 +321,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
// On clicking repeat type button
public
void
selectRepeatType
(
View
v
){
public
void
selectRepeatType
(
View
v
)
{
final
String
[]
items
=
new
String
[
5
];
items
[
0
]
=
"Minute"
;
...
...
@@ -350,7 +347,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
// On clicking repeat interval button
public
void
setRepeatNo
(
View
v
){
public
void
setRepeatNo
(
View
v
)
{
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
this
);
alert
.
setTitle
(
"Enter Number"
);
...
...
@@ -366,8 +363,7 @@ public class ReminderEditActivity extends AppCompatActivity {
mRepeatNo
=
Integer
.
toString
(
1
);
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
}
else
{
}
else
{
mRepeatNo
=
input
.
getText
().
toString
().
trim
();
mRepeatNoText
.
setText
(
mRepeatNo
);
mRepeatText
.
setText
(
"Every "
+
mRepeatNo
+
" "
+
mRepeatType
+
"(s)"
);
...
...
@@ -383,7 +379,7 @@ public class ReminderEditActivity extends AppCompatActivity {
}
// On clicking the update button
public
void
updateReminder
(){
public
void
updateReminder
()
{
// Set new values in the reminder
mReceivedReminder
.
setTitle
(
mTitle
);
mReceivedReminder
.
setDate
(
mDate
);
...
...
app/src/main/java/com/sudogeeks/talking_reminder/ReminderReceiveActivity.java
View file @
57a1e323
package
com.sudogeeks.talking_reminder
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
...
...
@@ -13,31 +10,31 @@ import android.widget.EditText;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.appcompat.widget.Toolbar
;
import
org.json.JSONObject
;
import
java.io.InputStream
;
import
java.util.Calendar
;
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
EditText
mTitleText
;
private
TextView
mDateText
,
mTimeText
,
mRepeatText
,
mRepeatNoText
,
mRepeatTypeText
;
private
String
mRepeat
;
private
String
mRepeatType
;
private
String
mRepeatType
;
private
String
mRepeatNo
;
private
Calendar
mCalendar
;
private
int
mYear
,
mMonth
,
mHour
,
mMinute
,
mDay
;
private
long
mRepeatTime
;
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
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -54,21 +51,21 @@ public class ReminderReceiveActivity extends AppCompatActivity {
//by default
mActive
=
"true"
;
// Setup Toolbar
mToolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mToolbar
=
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
mToolbar
);
getSupportActionBar
().
setTitle
(
R
.
string
.
activity_add_reminder_label
);
//Get the file from intent
Intent
intent
=
getIntent
();
Uri
fileUri
=
intent
.
getData
();
StringBuilder
reminderJson
=
new
StringBuilder
();
if
(
intent
.
getType
().
equals
(
"text/"
+
Utility
.
FILE_EXTENSION
))
{
StringBuilder
reminderJson
=
new
StringBuilder
();
if
(
intent
.
getType
().
equals
(
"text/"
+
Utility
.
FILE_EXTENSION
))
{
try
{
InputStream
in
=
getContentResolver
().
openInputStream
(
fileUri
);
InputStream
in
=
getContentResolver
().
openInputStream
(
fileUri
);
int
i
;
while
((
i
=
in
.
read
())
!=
-
1
)
reminderJson
.
append
((
char
)
i
);
while
((
i
=
in
.
read
())
!=
-
1
)
reminderJson
.
append
((
char
)
i
);
//System.out.println("******************************************************************");
//System.out.println(sb.toString());
//System.out.println("******************************************************************");
...
...
@@ -79,27 +76,26 @@ public class ReminderReceiveActivity extends AppCompatActivity {
try
{
JSONObject
obj
=
new
JSONObject
(
reminderJson
.
toString
());
//Reminder talkingReminder=new Reminder();
mTitleText
=
(
EditText
)
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
(
TextView
)
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
(
TextView
)
findViewById
(
R
.
id
.
set_repeat_type
);
mTitleText
=
findViewById
(
R
.
id
.
reminder_title
);
mDateText
=
findViewById
(
R
.
id
.
set_date
);
mTimeText
=
findViewById
(
R
.
id
.
set_time
);
mRepeatText
=
findViewById
(
R
.
id
.
set_repeat
);
mRepeatNoText
=
findViewById
(
R
.
id
.
set_repeat_no
);
mRepeatTypeText
=
findViewById
(
R
.
id
.
set_repeat_type
);
mRepeat
=
obj
.
getString
(
"mRepeat"
);
mRepeatType
=
obj
.
getString
(
"mRepeatType"
);
mRepeatNo
=
obj
.
getString
(
"mRepeatNo"
);
mRepeat
=
obj
.
getString
(
"mRepeat"
);
mRepeatType
=
obj
.
getString
(
"mRepeatType"
);
mRepeatNo
=
obj
.
getString
(
"mRepeatNo"
);
mTitleText
.
setText
(
obj
.
getString
(
"mTitle"
));
mDateText
.
setText
(
obj
.
getString
(
"mDate"
));
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"
));
mRepeatTypeText
.
setText
(
obj
.
getString
(
"mRepeatType"
));
}
catch
(
Throwable
t
){
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
}
...
...
@@ -111,7 +107,7 @@ public class ReminderReceiveActivity extends AppCompatActivity {
}
}
public
void
saveSendReminder
(){
public
void
saveSendReminder
()
{
ReminderDatabase
rb
=
new
ReminderDatabase
(
this
);
// Creating Reminder
...
...
app/src/main/res/layout/activity_add_reminder.xml
View file @
57a1e323
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
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_height=
"match_parent"
>
<androidx.appcompat.widget.Toolbar
android:id=
"@+id/toolbar"
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"?attr/colorPrimary"
android:minHeight=
"?attr/actionBarSize"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Light"
app:contentInsetLeft=
"0dp"
app:contentInsetStart=
"16dp"
app:
theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar
"
a
ndroid:background=
"?attr/colorPrimary
"
/>
app:
popupTheme=
"@style/ThemeOverlay.AppCompat.Light
"
a
pp:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar
"
/>
<LinearLayout
android:id=
"@+id/add_reminder_layout_top"
android:layout_width=
"match_parent"
android:layout_height=
"148dp"
android:layout_below=
"@+id/toolbar"
android:theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:id=
"@+id/add_reminder_layout_top"
android:background=
"@color/primary"
android:orientation=
"vertical"
android:
layout_height=
"148dp
"
>
android:
theme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar
"
>
<EditText
android:layout_width=
"match_parent"
android:id=
"@+id/reminder_title"
android:layout_width=
"match_parent"
android:layout_height=
"140dp"
android:layout_marginLeft=
"72dp"
android:layout_marginRight=
"16dp"
android:gravity=
"top|left"
android:hint=
"@string/add_reminder"
android:
textSize=
"25dp
"
android:
inputType=
"textCapWords|textMultiLine
"
android:lines=
"4"
android:minLines=
"4"
android:gravity=
"top|left"
android:textColor=
"@android:color/white"
android:scrollHorizontally=
"false"
android:textColor=
"@android:color/white"
android:textColorHint=
"@color/primary_text_disabled_material_dark"
android:inputType=
"textCapWords|textMultiLine"
android:layout_marginRight=
"16dp"
android:layout_height=
"140dp"
/>
android:textSize=
"25dp"
/>
</LinearLayout>
<ScrollView
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"fill_parent"
android:layout_
below=
"@id/add_reminder_layout_top
"
android:layout_
height=
"fill_parent
"
>
android:layout_
height=
"fill_parent
"
android:layout_
below=
"@id/add_reminder_layout_top
"
>
<LinearLayout
android:layout_width=
"match_parent"
android:
orientation=
"vertical
"
android:
layout_height=
"wrap_content
"
>
android:
layout_height=
"wrap_content
"
android:
orientation=
"vertical
"
>
<TextView
android:id=
"@+id/details"
android:layout_width=
"match_parent"
android:layout_height=
"72dp"
android:layout_marginLeft=
"72dp"
android:layout_marginTop=
"8dp"
android:text=
"@string/details"
android:id=
"@+id/details"
android:textSize=
"15dp"
android:gravity=
"center_vertical"
android:
layout_marginLeft=
"72dp
"
android:
text=
"@string/details
"
android:textColor=
"@color/abc_secondary_text_material_dark"
android:
layout_height=
"72dp"
/>
android:
textSize=
"15dp"
/>
<RelativeLayout
android:layout_width=
"match_parent"
android:clickable=
"true"
android:onClick=
"setDate"
android:id=
"@+id/date"
android:layout_width=
"match_parent"
android:layout_height=
"72dp"
android:background=
"?android:attr/selectableItemBackground"
android:layout_height=
"72dp"
>
android:clickable=
"true"
android:onClick=
"setDate"
>
<ImageView
android:id=
"@+id/date_icon"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"32dp"
android:src=
"@drawable/ic_view_day_grey600_24dp"
android:layout_centerVertical=
"true"
/>
android:src=
"@drawable/ic_view_day_grey600_24dp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:
orientation=
"vertical
"
android:
layout_height=
"wrap_content
"
android:layout_centerVertical=
"true"
android:layout_toRightOf=
"@id/date_icon"
android:
layout_height=
"wrap_content
"
>
android:
orientation=
"vertical
"
>
<TextView
android:id=
"@+id/date_text"
android:textColor=
"@color/abc_primary_text_material_dark"
android:layout_width=
"wrap_content"
android:textSize=
"15dp"
android:layout_height=
"wrap_content"
android:text=
"@string/date"
/>
android:text=
"@string/date"
android:textColor=
"@color/abc_primary_text_material_dark"
android:textSize=
"15dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:id=
"@+id/set_date"
android:textSize=
"15dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/abc_secondary_text_material_dark"
android:
layout_height=
"wrap_content"
/>
android:
textSize=
"15dp"
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:clickable=
"true"
android:onClick=
"setTime"
android:id=
"@+id/time"
android:layout_width=
"match_parent"
android:layout_height=
"72dp"
android:background=
"?android:attr/selectableItemBackground"
android:layout_height=
"72dp"
>
android:clickable=
"true"
android:onClick=
"setTime"
>
<ImageView
android:id=
"@+id/time_icon"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"32dp"
android:src=
"@drawable/ic_access_time_grey600_24dp"
android:layout_centerVertical=
"true"
/>
android:src=
"@drawable/ic_access_time_grey600_24dp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:
orientation=
"vertical
"
android:
layout_height=
"wrap_content
"
android:layout_centerVertical=
"true"
android:layout_toRightOf=
"@id/time_icon"
android:
layout_height=
"wrap_content
"
>
android:
orientation=
"vertical
"
>
<TextView
android:id=
"@+id/time_text"
android:textColor=
"@color/abc_primary_text_material_dark"
android:layout_width=
"wrap_content"
android:textSize=
"15dp"
android:layout_height=
"wrap_content"
android:text=
"@string/time"
/>
android:text=
"@string/time"
android:textColor=
"@color/abc_primary_text_material_dark"
android:textSize=
"15dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:id=
"@+id/set_time"
android:textSize=
"15dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/abc_secondary_text_material_dark"
android:
layout_height=
"wrap_content"
/>
android:
textSize=
"15dp"
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:id=
"@+id/repeat"
android:layout_width=
"match_parent"
android:layout_height=
"72dp"
>
<ImageView
...
...
@@ -164,33 +160,33 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"32dp"
android:src=
"@drawable/ic_sync_grey600_24dp"
android:layout_centerVertical=
"true"
/>
android:src=
"@drawable/ic_sync_grey600_24dp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:orientation=
"vertical"
android:id=
"@+id/repeat_ll"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_toRightOf=
"@id/repeat_icon"
android:
layout_height=
"wrap_content
"
>
android:
orientation=
"vertical
"
>
<TextView
android:id=
"@+id/repeat_text"
android:textColor=
"@color/abc_primary_text_material_dark"
android:layout_width=
"wrap_content"
android:textSize=
"15dp"
android:layout_height=
"wrap_content"
android:text=
"@string/repeat"
/>
android:text=
"@string/repeat"
android:textColor=
"@color/abc_primary_text_material_dark"
android:textSize=
"15dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:id=
"@+id/set_repeat"
android:textSize=
"15dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/abc_secondary_text_material_dark"
android:
layout_height=
"wrap_content"
/>
android:
textSize=
"15dp"
/>
</LinearLayout>
...
...
@@ -198,100 +194,100 @@
android:id=
"@+id/repeat_switch"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerVertical=
"true"
android:layout_alignParentRight=
"true"
android:layout_
marginRight=
"16dp
"
android:layout_
centerVertical=
"true
"
android:layout_marginLeft=
"8dp"
android:
onClick=
"onSwitchRepeat
"
android:
layout_marginRight=
"16dp
"
android:checked=
"true"
android:textOn=
"On"
android:textOff=
"Off"
/>
android:onClick=
"onSwitchRepeat"
android:textOff=
"Off"
android:textOn=
"On"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:id=
"@+id/RepeatNo"
android:
clickable=
"true
"
android:
onClick=
"setRepeatNo
"
android:
layout_width=
"match_parent
"
android:
layout_height=
"72dp
"
android:background=
"?android:attr/selectableItemBackground"
android:layout_height=
"72dp"
>
android:clickable=
"true"
android:onClick=
"setRepeatNo"
>
<ImageView
android:id=
"@+id/repeat_no_icon"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"32dp"
android:src=
"@drawable/ic_unfold_more_grey600_24dp"
android:layout_centerVertical=
"true"
/>
android:src=
"@drawable/ic_unfold_more_grey600_24dp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:
orientation=
"vertical
"
android:
layout_height=
"wrap_content
"
android:layout_centerVertical=
"true"
android:layout_toRightOf=
"@id/repeat_no_icon"
android:
layout_height=
"wrap_content
"
>
android:
orientation=
"vertical
"
>
<TextView
android:id=
"@+id/repeat_no_text"
android:textColor=
"@color/abc_primary_text_material_dark"
android:layout_width=
"wrap_content"
android:textSize=
"15dp"
android:layout_height=
"wrap_content"
android:text=
"@string/repeat_no"
/>
android:text=
"@string/repeat_no"
android:textColor=
"@color/abc_primary_text_material_dark"
android:textSize=
"15dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:id=
"@+id/set_repeat_no"
android:textSize=
"15dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/abc_secondary_text_material_dark"
android:
layout_height=
"wrap_content"
/>
android:
textSize=
"15dp"
/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:id=
"@+id/RepeatType"
android:
clickable=
"true
"
android:
onClick=
"selectRepeatType
"
android:
layout_width=
"match_parent
"
android:
layout_height=
"72dp
"
android:background=
"?android:attr/selectableItemBackground"
android:layout_height=
"72dp"
>
android:clickable=
"true"
android:onClick=
"selectRepeatType"
>
<ImageView
android:id=
"@+id/repeat_type_icon"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"32dp"
android:src=
"@drawable/ic_subject_grey600_24dp"
android:layout_centerVertical=
"true"
/>
android:src=
"@drawable/ic_subject_grey600_24dp"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:
orientation=
"vertical
"
android:
layout_height=
"wrap_content
"
android:layout_centerVertical=
"true"
android:layout_toRightOf=
"@id/repeat_type_icon"
android:
layout_height=
"wrap_content
"
>
android:
orientation=
"vertical
"
>
<TextView
android:id=
"@+id/repeat_type_text"
android:textColor=
"@color/abc_primary_text_material_dark"
android:layout_width=
"wrap_content"
android:textSize=
"15dp"
android:layout_height=
"wrap_content"
android:text=
"@string/repeat_type"
/>
android:text=
"@string/repeat_type"
android:textColor=
"@color/abc_primary_text_material_dark"
android:textSize=
"15dp"
/>
<TextView
android:layout_width=
"wrap_content"
android:id=
"@+id/set_repeat_type"
android:textSize=
"15dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/abc_secondary_text_material_dark"
android:
layout_height=
"wrap_content"
/>
android:
textSize=
"15dp"
/>
</LinearLayout>
...
...
@@ -311,24 +307,24 @@
android:id=
"@+id/starred1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:clickable=
"true"
android:onClick=
"selectFab1"
android:icon=
"@drawable/ic_notifications_off_grey600_24dp"
android:layout_alignParentLeft=
"true"
android:layout_marginTop=
"168dp"
android:layout_centerHorizontal=
"true"
android:layout_marginLeft=
"8dp"
/>
android:layout_marginLeft=
"8dp"
android:layout_marginTop=
"168dp"
android:clickable=
"true"
android:icon=
"@drawable/ic_notifications_off_grey600_24dp"
android:onClick=
"selectFab1"
/>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id=
"@+id/starred2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:clickable=
"true"
android:onClick=
"selectFab2"
android:icon=
"@drawable/ic_notifications_on_white_24dp"
android:layout_alignParentLeft=
"true"
android:layout_marginTop=
"168dp"
android:layout_centerHorizontal=
"true"
android:layout_marginLeft=
"8dp"
/>
android:layout_marginLeft=
"8dp"
android:layout_marginTop=
"168dp"
android:clickable=
"true"
android:icon=
"@drawable/ic_notifications_on_white_24dp"
android:onClick=
"selectFab2"
/>
</RelativeLayout>
app/src/main/res/layout/activity_main.xml
View file @
57a1e323
...
...
@@ -3,7 +3,6 @@
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
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_height=
"match_parent"
tools:context=
".MainActivity"
>
...
...
@@ -15,7 +14,7 @@
android:minHeight=
"?attr/actionBarSize"
app:contentInsetLeft=
"0dp"
app:contentInsetStart=
"16dp"
a
pp:theme=
"@style/ThemeOverlay.AppCompat.Dark.
ActionBar"
a
ndroid:theme=
"@style/AppTheme.No
ActionBar"
android:background=
"?attr/colorPrimary"
/>
<androidx.recyclerview.widget.RecyclerView
...
...
app/src/main/res/values/colors.xml
View file @
57a1e323
<resources>
<color
name=
"primary"
>
#
37474f
</color>
<color
name=
"primary_dark"
>
#
263238
</color>
<color
name=
"accent"
>
#
78909c
</color>
<color
name=
"primary"
>
#
008577
</color>
<color
name=
"primary_dark"
>
#
00574B
</color>
<color
name=
"accent"
>
#
D81B60
</color>
</resources>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
57a1e323
<resources>
<!-- 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"
>
<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