Commit 57a1e323 authored by PANKAJ KUMAR's avatar PANKAJ KUMAR

Further Cleanup

parent 630d3e89
...@@ -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.ReadTheMessage"></activity> <activity android:name="com.sudogeeks.talking_reminder.ReadReminderTextService"></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.ReadTheMessage" android:name="com.sudogeeks.talking_reminder.ReadReminderTextService"
android:enabled="true" /> android:enabled="true" />
</application> </application>
......
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, ReadTheMessage.class); // speechIntent.setClass(context, ReadReminderTextService.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.");
// ReadTheMessage.enqueueWork(context, speechIntent); // ReadReminderTextService.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);
......
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")) {
......
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() {
......
package com.sudogeeks.talking_reminder; package com.sudogeeks.talking_reminder;
import android.content.Intent; import android.content.Intent;
...@@ -48,61 +46,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -48,61 +46,8 @@ public class MainActivity extends AppCompatActivity {
private ReminderDatabase rb; private ReminderDatabase rb;
private MultiSelector mMultiSelector = new MultiSelector(); private MultiSelector mMultiSelector = new MultiSelector();
private AlarmReceiver mAlarmReceiver; 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 // Multi select items in recycler view
private ModalMultiSelectorCallback mDeleteMode = new ModalMultiSelectorCallback(mMultiSelector) { private ModalMultiSelectorCallback mDeleteMode = new ModalMultiSelectorCallback(mMultiSelector) {
@Override @Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
...@@ -173,6 +118,58 @@ public class MainActivity extends AppCompatActivity { ...@@ -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 // On clicking a reminder item
private void selectReminder(int mClickID) { private void selectReminder(int mClickID) {
String mStringClickID = Integer.toString(mClickID); String mStringClickID = Integer.toString(mClickID);
...@@ -193,7 +190,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -193,7 +190,7 @@ public class MainActivity extends AppCompatActivity {
// Recreate recycler view // Recreate recycler view
// This is done so that newly created reminders are displayed // This is done so that newly created reminders are displayed
@Override @Override
public void onResume(){ public void onResume() {
super.onResume(); super.onResume();
// To check is there are saved reminders // To check is there are saved reminders
...@@ -250,12 +247,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -250,12 +247,6 @@ public class MainActivity extends AppCompatActivity {
mItems = new ArrayList<>(); mItems = new ArrayList<>();
} }
public void setItemCount(int count) {
mItems.clear();
mItems.addAll(generateData(count));
notifyDataSetChanged();
}
public void onDeleteItem(int count) { public void onDeleteItem(int count) {
mItems.clear(); mItems.clear();
mItems.addAll(generateData(count)); mItems.addAll(generateData(count));
...@@ -290,8 +281,72 @@ public class MainActivity extends AppCompatActivity { ...@@ -290,8 +281,72 @@ public class MainActivity extends AppCompatActivity {
return mItems.size(); 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 // Class for recycler view items
public class ReminderItem { public class ReminderItem {
public String mTitle; public String mTitle;
public String mDateTime; public String mDateTime;
public String mRepeat; public String mRepeat;
...@@ -314,8 +369,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -314,8 +369,8 @@ public class MainActivity extends AppCompatActivity {
DateFormat f = new SimpleDateFormat("dd/mm/yyyy hh:mm"); DateFormat f = new SimpleDateFormat("dd/mm/yyyy hh:mm");
public int compare(Object a, Object b) { public int compare(Object a, Object b) {
String o1 = ((DateTimeSorter)a).getDateTime(); String o1 = ((DateTimeSorter) a).getDateTime();
String o2 = ((DateTimeSorter)b).getDateTime(); String o2 = ((DateTimeSorter) b).getDateTime();
try { try {
return f.parse(o1).compareTo(f.parse(o2)); return f.parse(o1).compareTo(f.parse(o2));
...@@ -326,10 +381,10 @@ public class MainActivity extends AppCompatActivity { ...@@ -326,10 +381,10 @@ public class MainActivity extends AppCompatActivity {
} }
// UI and data class for recycler view items // UI and data class for recycler view items
public class VerticalItemHolder extends SwappingHolder public class VerticalItemHolder extends SwappingHolder
implements View.OnClickListener, View.OnLongClickListener { implements View.OnClickListener, View.OnLongClickListener {
private TextView mTitleText, mDateAndTimeText, mRepeatInfoText; private TextView mTitleText, mDateAndTimeText, mRepeatInfoText;
private ImageView mActiveImage , mThumbnailImage; private ImageView mActiveImage, mThumbnailImage;
private ColorGenerator mColorGenerator = ColorGenerator.DEFAULT; private ColorGenerator mColorGenerator = ColorGenerator.DEFAULT;
private TextDrawable mDrawableBuilder; private TextDrawable mDrawableBuilder;
private SimpleAdapter mAdapter; private SimpleAdapter mAdapter;
...@@ -344,11 +399,11 @@ public class MainActivity extends AppCompatActivity { ...@@ -344,11 +399,11 @@ public class MainActivity extends AppCompatActivity {
mAdapter = adapter; mAdapter = adapter;
// Initialize views // Initialize views
mTitleText = (TextView) itemView.findViewById(R.id.recycle_title); mTitleText = itemView.findViewById(R.id.recycle_title);
mDateAndTimeText = (TextView) itemView.findViewById(R.id.recycle_date_time); mDateAndTimeText = itemView.findViewById(R.id.recycle_date_time);
mRepeatInfoText = (TextView) itemView.findViewById(R.id.recycle_repeat_info); mRepeatInfoText = itemView.findViewById(R.id.recycle_repeat_info);
mActiveImage = (ImageView) itemView.findViewById(R.id.active_image); mActiveImage = itemView.findViewById(R.id.active_image);
mThumbnailImage = (ImageView) itemView.findViewById(R.id.thumbnail_image); mThumbnailImage = itemView.findViewById(R.id.thumbnail_image);
} }
// On clicking a reminder item // On clicking a reminder item
...@@ -360,7 +415,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -360,7 +415,7 @@ public class MainActivity extends AppCompatActivity {
int mReminderClickID = IDmap.get(mTempPost); int mReminderClickID = IDmap.get(mTempPost);
selectReminder(mReminderClickID); selectReminder(mReminderClickID);
} else if(mMultiSelector.getSelectedPositions().isEmpty()){ } else if (mMultiSelector.getSelectedPositions().isEmpty()) {
mAdapter.setItemCount(getDefaultItemCount()); mAdapter.setItemCount(getDefaultItemCount());
} }
} }
...@@ -379,7 +434,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -379,7 +434,7 @@ public class MainActivity extends AppCompatActivity {
mTitleText.setText(title); mTitleText.setText(title);
String letter = "A"; String letter = "A";
if(title != null && !title.isEmpty()) { if (title != null && !title.isEmpty()) {
letter = title.substring(0, 1); letter = title.substring(0, 1);
} }
...@@ -398,79 +453,21 @@ public class MainActivity extends AppCompatActivity { ...@@ -398,79 +453,21 @@ public class MainActivity extends AppCompatActivity {
// Set repeat views // Set repeat views
public void setReminderRepeatInfo(String repeat, String repeatNo, String repeatType) { public void setReminderRepeatInfo(String repeat, String repeatNo, String repeatType) {
if(repeat.equals("true")){ if (repeat.equals("true")) {
mRepeatInfoText.setText("Every " + repeatNo + " " + repeatType + "(s)"); mRepeatInfoText.setText("Every " + repeatNo + " " + repeatType + "(s)");
}else if (repeat.equals("false")) { } else if (repeat.equals("false")) {
mRepeatInfoText.setText("Repeat Off"); mRepeatInfoText.setText("Repeat Off");
} }
} }
// Set active image as on or off // Set active image as on or off
public void setActiveImage(String active){ public void setActiveImage(String active) {
if(active.equals("true")){ if (active.equals("true")) {
mActiveImage.setImageResource(R.drawable.ic_notifications_on_white_24dp); 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); 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;
}
} }
} }
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;
} }
} }
......
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 ReadTheMessage extends Service implements TextToSpeech.OnInitListener, TextToSpeech.OnUtteranceCompletedListener { public class ReadReminderTextService 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);
} }
} }
} }
......
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;
......
...@@ -40,22 +40,6 @@ import java.util.Calendar; ...@@ -40,22 +40,6 @@ import java.util.Calendar;
public class ReminderAddActivity extends AppCompatActivity { 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 // Values for orientation change
private static final String KEY_TITLE = "title_key"; private static final String KEY_TITLE = "title_key";
private static final String KEY_TIME = "time_key"; private static final String KEY_TIME = "time_key";
...@@ -64,7 +48,6 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -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_NO = "repeat_no_key";
private static final String KEY_REPEAT_TYPE = "repeat_type_key"; private static final String KEY_REPEAT_TYPE = "repeat_type_key";
private static final String KEY_ACTIVE = "active_key"; private static final String KEY_ACTIVE = "active_key";
// Constant values in milliseconds // Constant values in milliseconds
private static final long milMinute = 60000L; private static final long milMinute = 60000L;
private static final long milHour = 3600000L; private static final long milHour = 3600000L;
...@@ -72,6 +55,21 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -72,6 +55,21 @@ public class ReminderAddActivity extends AppCompatActivity {
private static final long milWeek = 604800000L; private static final long milWeek = 604800000L;
private static final long milMonth = 2592000000L; private static final long milMonth = 2592000000L;
private static final int MY_PERMISSIONS_REQUEST_WRITE_CONTACTS = 1; 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 @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -79,15 +77,15 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -79,15 +77,15 @@ public class ReminderAddActivity extends AppCompatActivity {
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 = findViewById(R.id.starred1);
mFAB2 = (FloatingActionButton) findViewById(R.id.starred2); mFAB2 = findViewById(R.id.starred2);
// Setup Toolbar // Setup Toolbar
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
...@@ -115,7 +113,8 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -115,7 +113,8 @@ public class ReminderAddActivity extends AppCompatActivity {
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) {
...@@ -124,7 +123,8 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -124,7 +123,8 @@ public class ReminderAddActivity extends AppCompatActivity {
} }
@Override @Override
public void afterTextChanged(Editable s) {} public void afterTextChanged(Editable s) {
}
}); });
// Setup TextViews using reminder values // Setup TextViews using reminder values
...@@ -176,7 +176,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -176,7 +176,7 @@ public class ReminderAddActivity 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());
...@@ -189,7 +189,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -189,7 +189,7 @@ public class ReminderAddActivity 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() {
...@@ -212,7 +212,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -212,7 +212,7 @@ public class ReminderAddActivity 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() {
...@@ -222,7 +222,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -222,7 +222,7 @@ public class ReminderAddActivity extends AppCompatActivity {
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);
...@@ -258,18 +258,18 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -258,18 +258,18 @@ public class ReminderAddActivity extends AppCompatActivity {
// On clicking the active button // On clicking the active button
public void selectFab1(View v) { public void selectFab1(View v) {
mFAB1 = (FloatingActionButton) findViewById(R.id.starred1); mFAB1 = findViewById(R.id.starred1);
mFAB1.hide(); mFAB1.hide();
mFAB2 = (FloatingActionButton) findViewById(R.id.starred2); mFAB2 = findViewById(R.id.starred2);
mFAB2.show(); mFAB2.show();
mActive = "true"; mActive = "true";
} }
// On clicking the inactive button // On clicking the inactive button
public void selectFab2(View v) { public void selectFab2(View v) {
mFAB2 = (FloatingActionButton) findViewById(R.id.starred2); mFAB2 = findViewById(R.id.starred2);
mFAB2.hide(); mFAB2.hide();
mFAB1 = (FloatingActionButton) findViewById(R.id.starred1); mFAB1 = findViewById(R.id.starred1);
mFAB1.show(); mFAB1.show();
mActive = "false"; mActive = "false";
} }
...@@ -287,7 +287,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -287,7 +287,7 @@ public class ReminderAddActivity 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";
...@@ -313,7 +313,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -313,7 +313,7 @@ public class ReminderAddActivity 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");
...@@ -329,8 +329,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -329,8 +329,7 @@ public class ReminderAddActivity 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)");
...@@ -347,13 +346,11 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -347,13 +346,11 @@ public class ReminderAddActivity extends AppCompatActivity {
public boolean isExternalStorageWritable() { public boolean isExternalStorageWritable() {
String state = Environment.getExternalStorageState(); String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) { return Environment.MEDIA_MOUNTED.equals(state);
return true;
}
return false;
} }
//on clicking the send button //on clicking the send button
public void saveReminderToTempStorage(String filename){ public void saveReminderToTempStorage(String filename) {
/* mTitleText = (EditText) findViewById(R.id.reminder_title); /* mTitleText = (EditText) findViewById(R.id.reminder_title);
mDateText = (TextView) findViewById(R.id.set_date); mDateText = (TextView) findViewById(R.id.set_date);
mTimeText = (TextView) findViewById(R.id.set_time); mTimeText = (TextView) findViewById(R.id.set_time);
...@@ -361,7 +358,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -361,7 +358,7 @@ public class ReminderAddActivity extends AppCompatActivity {
mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no); mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no);
mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type); mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type);
*/ */
Reminder talkingReminder=new Reminder(); Reminder talkingReminder = new Reminder();
talkingReminder.setTitle(mTitle); talkingReminder.setTitle(mTitle);
talkingReminder.setDate(mDate); talkingReminder.setDate(mDate);
talkingReminder.setTime(mTime); talkingReminder.setTime(mTime);
...@@ -374,7 +371,7 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -374,7 +371,7 @@ public class ReminderAddActivity extends AppCompatActivity {
//First write the data to a temporary file //First write the data to a temporary file
FileOutputStream outputStream; 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 // Permission is not granted
if (ActivityCompat.shouldShowRequestPermissionRationale(ReminderAddActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { if (ActivityCompat.shouldShowRequestPermissionRationale(ReminderAddActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// Show an explanation to the user *asynchronously* -- don't block // Show an explanation to the user *asynchronously* -- don't block
...@@ -386,24 +383,24 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -386,24 +383,24 @@ public class ReminderAddActivity extends AppCompatActivity {
} }
} }
try { try {
String fileContents = gson.toJson(talkingReminder); String fileContents = gson.toJson(talkingReminder);
outputStream = openFileOutput(filename, Context.MODE_PRIVATE); outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(fileContents.getBytes()); outputStream.write(fileContents.getBytes());
outputStream.close(); outputStream.close();
// FileWriter fw = new FileWriter(filename); // FileWriter fw = new FileWriter(filename);
// BufferedWriter bw = new BufferedWriter(fw); // BufferedWriter bw = new BufferedWriter(fw);
// bw.write(content); // bw.write(content);
// bw.close(); // bw.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
// On clicking the save button // On clicking the save button
public void saveReminder(){ public void saveReminder() {
ReminderDatabase rb = new ReminderDatabase(this); ReminderDatabase rb = new ReminderDatabase(this);
// Creating Reminder // Creating Reminder
...@@ -520,11 +517,11 @@ public class ReminderAddActivity extends AppCompatActivity { ...@@ -520,11 +517,11 @@ public class ReminderAddActivity extends AppCompatActivity {
File filePath = context.getFilesDir(); File filePath = context.getFilesDir();
File fileToSend = new File(filePath, filename); File fileToSend = new File(filePath, filename);
Uri fileUri = FileProvider.getUriForFile(context, 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(); Intent share = new Intent();
share.setAction(Intent.ACTION_SEND); share.setAction(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, fileUri); 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.setDataAndType( fileUri, getContentResolver().getType(fileUri));
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//share.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); //share.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
......
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())});
......
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);
......
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
......
<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: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">
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:contentInsetLeft="0dp" app:contentInsetLeft="0dp"
app:contentInsetStart="16dp" app:contentInsetStart="16dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="?attr/colorPrimary" /> app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<LinearLayout <LinearLayout
android:id="@+id/add_reminder_layout_top"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="148dp"
android:layout_below="@+id/toolbar" android:layout_below="@+id/toolbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:id="@+id/add_reminder_layout_top"
android:background="@color/primary" android:background="@color/primary"
android:orientation="vertical" android:orientation="vertical"
android:layout_height="148dp"> android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<EditText <EditText
android:layout_width="match_parent"
android:id="@+id/reminder_title" android:id="@+id/reminder_title"
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_marginLeft="72dp" android:layout_marginLeft="72dp"
android:layout_marginRight="16dp"
android:gravity="top|left"
android:hint="@string/add_reminder" android:hint="@string/add_reminder"
android:textSize="25dp" android:inputType="textCapWords|textMultiLine"
android:lines="4" android:lines="4"
android:minLines="4" android:minLines="4"
android:gravity="top|left"
android:textColor="@android:color/white"
android:scrollHorizontally="false" android:scrollHorizontally="false"
android:textColor="@android:color/white"
android:textColorHint="@color/primary_text_disabled_material_dark" android:textColorHint="@color/primary_text_disabled_material_dark"
android:inputType="textCapWords|textMultiLine" android:textSize="25dp" />
android:layout_marginRight="16dp"
android:layout_height="140dp"/>
</LinearLayout> </LinearLayout>
<ScrollView <ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/details"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginLeft="72dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/details"
android:id="@+id/details"
android:textSize="15dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_marginLeft="72dp" android:text="@string/details"
android:textColor="@color/abc_secondary_text_material_dark" android:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="72dp"/> android:textSize="15dp" />
<RelativeLayout <RelativeLayout
android:layout_width="match_parent"
android:clickable="true"
android:onClick="setDate"
android:id="@+id/date" android:id="@+id/date"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:layout_height="72dp"> android:clickable="true"
android:onClick="setDate">
<ImageView <ImageView
android:id="@+id/date_icon" android:id="@+id/date_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:src="@drawable/ic_view_day_grey600_24dp" android:src="@drawable/ic_view_day_grey600_24dp" />
android:layout_centerVertical="true" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/date_icon" android:layout_toRightOf="@id/date_icon"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/date_text" android:id="@+id/date_text"
android:textColor="@color/abc_primary_text_material_dark"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textSize="15dp"
android:layout_height="wrap_content" 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 <TextView
android:layout_width="wrap_content"
android:id="@+id/set_date" 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:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="wrap_content"/> android:textSize="15dp" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent"
android:clickable="true"
android:onClick="setTime"
android:id="@+id/time" android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:layout_height="72dp"> android:clickable="true"
android:onClick="setTime">
<ImageView <ImageView
android:id="@+id/time_icon" android:id="@+id/time_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:src="@drawable/ic_access_time_grey600_24dp" android:src="@drawable/ic_access_time_grey600_24dp" />
android:layout_centerVertical="true" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/time_icon" android:layout_toRightOf="@id/time_icon"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/time_text" android:id="@+id/time_text"
android:textColor="@color/abc_primary_text_material_dark"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textSize="15dp"
android:layout_height="wrap_content" 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 <TextView
android:layout_width="wrap_content"
android:id="@+id/set_time" 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:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="wrap_content"/> android:textSize="15dp" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent"
android:id="@+id/repeat" android:id="@+id/repeat"
android:layout_width="match_parent"
android:layout_height="72dp"> android:layout_height="72dp">
<ImageView <ImageView
...@@ -164,33 +160,33 @@ ...@@ -164,33 +160,33 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:src="@drawable/ic_sync_grey600_24dp" android:src="@drawable/ic_sync_grey600_24dp" />
android:layout_centerVertical="true" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content"
android:orientation="vertical"
android:id="@+id/repeat_ll" android:id="@+id/repeat_ll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/repeat_icon" android:layout_toRightOf="@id/repeat_icon"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/repeat_text" android:id="@+id/repeat_text"
android:textColor="@color/abc_primary_text_material_dark"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textSize="15dp"
android:layout_height="wrap_content" 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 <TextView
android:layout_width="wrap_content"
android:id="@+id/set_repeat" 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:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="wrap_content"/> android:textSize="15dp" />
</LinearLayout> </LinearLayout>
...@@ -198,100 +194,100 @@ ...@@ -198,100 +194,100 @@
android:id="@+id/repeat_switch" android:id="@+id/repeat_switch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginRight="16dp" android:layout_centerVertical="true"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:onClick="onSwitchRepeat" android:layout_marginRight="16dp"
android:checked="true" android:checked="true"
android:textOn="On" android:onClick="onSwitchRepeat"
android:textOff="Off"/> android:textOff="Off"
android:textOn="On" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent"
android:id="@+id/RepeatNo" android:id="@+id/RepeatNo"
android:clickable="true" android:layout_width="match_parent"
android:onClick="setRepeatNo" android:layout_height="72dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:layout_height="72dp"> android:clickable="true"
android:onClick="setRepeatNo">
<ImageView <ImageView
android:id="@+id/repeat_no_icon" android:id="@+id/repeat_no_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:src="@drawable/ic_unfold_more_grey600_24dp" android:src="@drawable/ic_unfold_more_grey600_24dp" />
android:layout_centerVertical="true" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/repeat_no_icon" android:layout_toRightOf="@id/repeat_no_icon"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/repeat_no_text" android:id="@+id/repeat_no_text"
android:textColor="@color/abc_primary_text_material_dark"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textSize="15dp"
android:layout_height="wrap_content" 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 <TextView
android:layout_width="wrap_content"
android:id="@+id/set_repeat_no" 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:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="wrap_content"/> android:textSize="15dp" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent"
android:id="@+id/RepeatType" android:id="@+id/RepeatType"
android:clickable="true" android:layout_width="match_parent"
android:onClick="selectRepeatType" android:layout_height="72dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:layout_height="72dp"> android:clickable="true"
android:onClick="selectRepeatType">
<ImageView <ImageView
android:id="@+id/repeat_type_icon" android:id="@+id/repeat_type_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:src="@drawable/ic_subject_grey600_24dp" android:src="@drawable/ic_subject_grey600_24dp" />
android:layout_centerVertical="true" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_toRightOf="@id/repeat_type_icon" android:layout_toRightOf="@id/repeat_type_icon"
android:layout_height="wrap_content"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/repeat_type_text" android:id="@+id/repeat_type_text"
android:textColor="@color/abc_primary_text_material_dark"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:textSize="15dp"
android:layout_height="wrap_content" 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 <TextView
android:layout_width="wrap_content"
android:id="@+id/set_repeat_type" 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:textColor="@color/abc_secondary_text_material_dark"
android:layout_height="wrap_content"/> android:textSize="15dp" />
</LinearLayout> </LinearLayout>
...@@ -311,24 +307,24 @@ ...@@ -311,24 +307,24 @@
android:id="@+id/starred1" android:id="@+id/starred1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="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_alignParentLeft="true"
android:layout_marginTop="168dp"
android:layout_centerHorizontal="true" 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 <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/starred2" android:id="@+id/starred2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="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_alignParentLeft="true"
android:layout_marginTop="168dp"
android:layout_centerHorizontal="true" 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> </RelativeLayout>
...@@ -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"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:theme="@style/AppTheme.NoActionBar"
android:background="?attr/colorPrimary" /> android:background="?attr/colorPrimary" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
......
<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
<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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment