Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TalkingReminder
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
PANKAJ KUMAR
TalkingReminder
Commits
2b030c7b
Commit
2b030c7b
authored
Nov 04, 2019
by
PANKAJ KUMAR
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Receive reminder feature
Able to read File. Parsing and putting it in the view is pending.
parent
85eb5c58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
51 deletions
+56
-51
app/build.gradle
app/build.gradle
+0
-1
app/src/main/java/com/blanyal/remindme/ReminderAddActivity.java
...c/main/java/com/blanyal/remindme/ReminderAddActivity.java
+26
-48
app/src/main/java/com/blanyal/remindme/ReminderReceiveActivity.java
...in/java/com/blanyal/remindme/ReminderReceiveActivity.java
+30
-2
No files found.
app/build.gradle
View file @
2b030c7b
...
...
@@ -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'
...
...
app/src/main/java/com/blanyal/remindme/ReminderAddActivity.java
View file @
2b030c7b
/*
* 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.SyncStateContrac
t
;
import
android.
os.Environmen
t
;
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
s
endReminder
(
String
filename
){
public
void
s
aveReminderToTempStorage
(
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
s
endReminder
(
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
();
}
s
aveReminderToTempStorage
(
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
();
...
...
app/src/main/java/com/blanyal/remindme/ReminderReceiveActivity.java
View file @
2b030c7b
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
();
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment