Commit d6e5f365 authored by PANKAJ KUMAR's avatar PANKAJ KUMAR

Writing to memory and reading from memory.

parent f5455b81
......@@ -11,7 +11,9 @@
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:icon,android:theme">
<activity android:name=".SendReminder"></activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name">
......@@ -21,15 +23,25 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ReminderAddActivity"
android:label="@string/title_activity_add_reminder" />
android:label="@string/title_activity_add_reminder">
<intent-filter>
<action
android:name="android.intent.action.PICK"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.OPENABLE"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity
android:name=".ReminderEditActivity"
android:label="@string/title_activity_edit_reminder" />
<activity
android:name=".LicencesActivity"
android:label="@string/title_activity_licenses" />
<receiver android:name=".AlarmReceiver" />
<receiver android:name=".BootReceiver">
......@@ -38,9 +50,17 @@
</intent-filter>
</receiver>
<service
android:name=".AlarmService"
android:enabled="true" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.blanyal.remindme.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<!-- ressource file to create -->
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths">
</meta-data>
</provider>
</application>
</manifest>
\ No newline at end of file
......@@ -42,8 +42,6 @@ import com.bignerdranch.android.multiselector.MultiSelector;
import com.bignerdranch.android.multiselector.SwappingHolder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.bignerdranch.android.multiselector.ModalMultiSelectorCallback;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -55,7 +53,7 @@ import java.util.List;
public class MainActivity extends AppCompatActivity {
private RecyclerView mList;
private RecyclerView reminderListView;
private SimpleAdapter mAdapter;
private Toolbar mToolbar;
private TextView mNoReminderView;
......@@ -77,7 +75,7 @@ public class MainActivity extends AppCompatActivity {
// Initialize views
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mAddReminderButton = (FloatingActionButton) findViewById(R.id.add_reminder);
mList = (RecyclerView) findViewById(R.id.reminder_list);
reminderListView = (RecyclerView) findViewById(R.id.reminder_list);
mNoReminderView = (TextView) findViewById(R.id.no_reminder_text);
// To check is there are saved reminders
......@@ -89,11 +87,11 @@ public class MainActivity extends AppCompatActivity {
}
// Create recycler view
mList.setLayoutManager(getLayoutManager());
registerForContextMenu(mList);
reminderListView.setLayoutManager(getLayoutManager());
registerForContextMenu(reminderListView);
mAdapter = new SimpleAdapter();
mAdapter.setItemCount(getDefaultItemCount());
mList.setAdapter(mAdapter);
reminderListView.setAdapter(mAdapter);
// Setup toolbar
setSupportActionBar(mToolbar);
......@@ -371,7 +369,7 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onClick(View v) {
if (!mMultiSelector.tapSelection(this)) {
mTempPost = mList.getChildAdapterPosition(v);
mTempPost = reminderListView.getChildAdapterPosition(v);
int mReminderClickID = IDmap.get(mTempPost);
selectReminder(mReminderClickID);
......
......@@ -67,7 +67,7 @@ public class NotificationHelper extends ContextWrapper {
.setContentTitle(getApplicationContext().getResources().getString(R.string.app_name))
.setTicker(mTitle)
.setContentText(mTitle)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM))
.setContentIntent(mClick)
.setAutoCancel(true)
.setOnlyAlertOnce(true);
......
......@@ -20,11 +20,16 @@ package com.blanyal.remindme;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
......@@ -37,9 +42,15 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ShareCompat;
import androidx.core.content.FileProvider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Calendar;
......@@ -423,9 +434,8 @@ public class ReminderAddActivity extends AppCompatActivity {
case R.id.save_reminder:
mTitleText.setText(mTitle);
if (mTitleText.getText().toString().length() == 0)
if (mTitleText.getText().toString().trim().length() == 0)
mTitleText.setError("Reminder Title cannot be blank!");
else {
saveReminder();
}
......@@ -440,6 +450,42 @@ public class ReminderAddActivity extends AppCompatActivity {
onBackPressed();
return true;
// On clicking send reminder button
// Initiate sender routine
case R.id.send_reminder:
Context context = this;
//First write the data to a temporary file
String filename = "myfile.txt";
String fileContents = "Hello world!";
FileOutputStream outputStream;
try {
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(fileContents.getBytes());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
//Pick the written file and send
File filePath = context.getFilesDir();
File fileToSend = new File(filePath, filename);
Uri fileUri = FileProvider.getUriForFile(context,
"com.blanyal.remindme.fileprovider", fileToSend);
Intent share = new Intent();
share.setAction(Intent.ACTION_SEND);
share.setDataAndType( fileUri, getContentResolver().getType(fileUri));
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
//share.setType("text/ovpn");
//share.putExtra(MediaStore.)
Intent shareIntent = Intent.createChooser(share, null);
startActivity(shareIntent);
default:
return super.onOptionsItemSelected(item);
}
......
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<root-path
name="root"
path="." />
<external-path
name="external"
path="." />
<external-files-path
name="external_files"
path="." />
<cache-path
name="cache"
path="." />
<external-cache-path
name="external_cache"
path="." />
<files-path
name="files"
path="." />
</paths>
\ No newline at end of file
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