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.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
@@ -186,26 +184,6 @@ public class HabitsApplication extends Application implements MainController.Sys
|
|||||||
return deviceInfo + "\n" + logcat;
|
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()
|
public void scheduleReminders()
|
||||||
{
|
{
|
||||||
new BaseTask()
|
new BaseTask()
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
|||||||
|
|
||||||
void refresh(Long refreshKey);
|
void refresh(Long refreshKey);
|
||||||
|
|
||||||
|
void sendFile(String filename);
|
||||||
|
|
||||||
|
void sendEmail(String to, String subject, String content);
|
||||||
|
|
||||||
ProgressBar getProgressBar();
|
ProgressBar getProgressBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface System
|
public interface System
|
||||||
{
|
{
|
||||||
void sendFile(String filename);
|
|
||||||
|
|
||||||
void sendEmail(String to, String subject, String content);
|
|
||||||
|
|
||||||
void scheduleReminders();
|
void scheduleReminders();
|
||||||
|
|
||||||
void updateWidgets();
|
void updateWidgets();
|
||||||
@@ -133,7 +133,7 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
|||||||
@Override
|
@Override
|
||||||
public void onExportCSVFinished(String filename)
|
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);
|
else screen.showMessage(R.string.could_not_export);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ public class MainController implements ImportDataTask.Listener, ExportCSVTask.Li
|
|||||||
@Override
|
@Override
|
||||||
public void onExportDBFinished(String filename)
|
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);
|
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";
|
log += "---------- BUG REPORT ENDS ------------\n";
|
||||||
String to = "dev@loophabits.org";
|
String to = "dev@loophabits.org";
|
||||||
String subject = "Bug Report - Loop Habit Tracker";
|
String subject = "Bug Report - Loop Habit Tracker";
|
||||||
sys.sendEmail(log, to, subject);
|
screen.sendEmail(log, to, subject);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,10 +21,13 @@ package org.isoron.uhabits.ui;
|
|||||||
|
|
||||||
import android.app.backup.BackupManager;
|
import android.app.backup.BackupManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
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.utils.InterfaceUtils;
|
||||||
import org.isoron.uhabits.widgets.WidgetManager;
|
import org.isoron.uhabits.widgets.WidgetManager;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
abstract public class BaseActivity extends AppCompatActivity implements Thread.UncaughtExceptionHandler,
|
abstract public class BaseActivity extends AppCompatActivity implements Thread.UncaughtExceptionHandler,
|
||||||
CommandRunner.Listener
|
CommandRunner.Listener
|
||||||
{
|
{
|
||||||
@@ -178,4 +183,24 @@ abstract public class BaseActivity extends AppCompatActivity implements Thread.U
|
|||||||
}
|
}
|
||||||
}.execute();
|
}.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