mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Move sendFile and sendEmail to Screen
This commit is contained in:
@@ -21,8 +21,6 @@ package org.isoron.uhabits;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -186,26 +184,6 @@ public class HabitsApplication extends Application implements MainController.Sys
|
||||
return deviceInfo + "\n" + logcat;
|
||||
}
|
||||
|
||||
public void sendFile(@NonNull String archiveFilename)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.setType("application/zip");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(archiveFilename)));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void sendEmail(String to, String subject, String content)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.setType("message/rfc822");
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {to});
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, content);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void scheduleReminders()
|
||||
{
|
||||
new BaseTask()
|
||||
|
||||
@@ -41,15 +41,15 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
||||
|
||||
void refresh(Long refreshKey);
|
||||
|
||||
void sendFile(String filename);
|
||||
|
||||
void sendEmail(String to, String subject, String content);
|
||||
|
||||
ProgressBar getProgressBar();
|
||||
}
|
||||
|
||||
public interface System
|
||||
{
|
||||
void sendFile(String filename);
|
||||
|
||||
void sendEmail(String to, String subject, String content);
|
||||
|
||||
void scheduleReminders();
|
||||
|
||||
void updateWidgets();
|
||||
@@ -133,7 +133,7 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
||||
@Override
|
||||
public void onExportCSVFinished(String filename)
|
||||
{
|
||||
if(filename != null) sys.sendFile(filename);
|
||||
if(filename != null) screen.sendFile(filename);
|
||||
else screen.showMessage(R.string.could_not_export);
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
||||
@Override
|
||||
public void onExportDBFinished(String filename)
|
||||
{
|
||||
if(filename != null) sys.sendFile(filename);
|
||||
if(filename != null) screen.sendFile(filename);
|
||||
else screen.showMessage(R.string.could_not_export);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
||||
log += "---------- BUG REPORT ENDS ------------\n";
|
||||
String to = "dev@loophabits.org";
|
||||
String subject = "Bug Report - Loop Habit Tracker";
|
||||
sys.sendEmail(log, to, subject);
|
||||
screen.sendEmail(log, to, subject);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
||||
@@ -21,10 +21,13 @@ package org.isoron.uhabits.ui;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
@@ -43,6 +46,8 @@ import org.isoron.uhabits.utils.ColorUtils;
|
||||
import org.isoron.uhabits.utils.InterfaceUtils;
|
||||
import org.isoron.uhabits.widgets.WidgetManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
abstract public class BaseActivity extends AppCompatActivity implements Thread.UncaughtExceptionHandler,
|
||||
CommandRunner.Listener
|
||||
{
|
||||
@@ -178,4 +183,24 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
public void sendFile(@NonNull String archiveFilename)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.setType("application/zip");
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(archiveFilename)));
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void sendEmail(String to, String subject, String content)
|
||||
{
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.setType("message/rfc822");
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {to});
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, content);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user