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;

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();
        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();
            }
        }
    }
}
