Commit 2b030c7b authored by PANKAJ KUMAR's avatar PANKAJ KUMAR

Receive reminder feature

Able to read File. Parsing and putting it in the view is pending.
parent 85eb5c58
......@@ -49,7 +49,6 @@ dependencies {
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.google.code.gson:gson:2.8.6'
// Lombok Dependencies
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
......
/*
* Copyright 2015 Blanyal D'Souza.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.blanyal.remindme;
import android.Manifest;
......@@ -23,11 +6,11 @@ import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.SyncStateContract;
import android.os.Environment;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
......@@ -41,26 +24,21 @@ import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.os.Environment;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import androidx.core.content.FileProvider;
import java.util.Calendar;
import com.google.gson.Gson;
import android.Manifest.permission;
public class ReminderAddActivity extends AppCompatActivity {
private Toolbar mToolbar;
......@@ -376,7 +354,7 @@ public class ReminderAddActivity extends AppCompatActivity {
return false;
}
//on clicking the send button
public void sendReminder(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);
......@@ -525,22 +503,22 @@ public class ReminderAddActivity extends AppCompatActivity {
Context context = this;
String filename = Utility.FILE_NAME_PREFIX + "." + Utility.FILE_EXTENSION; //TODO Consecutive filenames should be unique
sendReminder(filename);
// //Check the if the file was written correctly.. Should be printed on console
FileInputStream fi = null;
try {
fi = context.openFileInput(filename);
int i;
StringBuilder sb = new StringBuilder();
while ((i=fi.read()) != -1)
sb.append((char)i);
System.out.println("******************************************************************");
System.out.println(sb.toString());
System.out.println("******************************************************************");
} catch (Exception e) {
e.printStackTrace();
}
saveReminderToTempStorage(filename);
//Check the if the file was written correctly.. Should be printed on console
// FileInputStream fi = null;
// try {
// fi = context.openFileInput(filename);
// int i;
// StringBuilder sb = new StringBuilder();
// while ((i=fi.read()) != -1)
// sb.append((char)i);
// System.out.println("******************************************************************");
// System.out.println(sb.toString());
// System.out.println("******************************************************************");
// } catch (Exception e) {
// e.printStackTrace();
// }
//Pick the written file and send
File filePath = context.getFilesDir();
......
package com.blanyal.remindme;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;
public class ReminderReceiveActivity extends AppCompatActivity {
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class ReminderReceiveActivity extends AppCompatActivity {
private Toolbar mToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_reminder);
Context context = this;
// Setup Toolbar
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle(R.string.activity_add_reminder_label);
//Get the file from intent
Intent intent = getIntent();
Toast.makeText(this, "Reminder Received", Toast.LENGTH_LONG);
Uri fileUri = intent.getData();
if (intent.getType().equals("text/"+Utility.FILE_EXTENSION)) {
try {
InputStream in = getContentResolver().openInputStream(fileUri);
int i;
StringBuilder sb = new StringBuilder();
while ((i=in.read()) != -1)
sb.append((char)i);
System.out.println("******************************************************************");
System.out.println(sb.toString());
System.out.println("******************************************************************");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
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