Skip to content

Commit

Permalink
Merge branch 'remove-external-storage'
Browse files Browse the repository at this point in the history
  • Loading branch information
caarmen committed Feb 19, 2017
2 parents ce44191 + 6f8b057 commit 6a2518e
Show file tree
Hide file tree
Showing 54 changed files with 258 additions and 979 deletions.
16 changes: 8 additions & 8 deletions networkmonitor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* /___/
* repository.
*
* Copyright (C) 2015 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2015-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,7 @@ android {
android.buildTypes.release.signingConfig = null
}
compileSdkVersion 25
buildToolsVersion "25.0.1"
buildToolsVersion "25.0.2"
dataBinding {
enabled = true
}
Expand All @@ -65,8 +65,8 @@ android {
applicationId "ca.rmen.android.networkmonitor"
minSdkVersion 9
targetSdkVersion 25
versionName "1.28.10"
versionCode 12810
versionName "1.28.11"
versionCode 12811
archivesBaseName += "-" + versionName
}

Expand Down Expand Up @@ -99,10 +99,10 @@ android {
dependencies {

compile 'de.psdev.licensesdialog:licensesdialog:1.8.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:preference-v7:25.0.1'
compile 'com.android.support:preference-v14:25.0.1'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:preference-v7:25.1.1'
compile 'com.android.support:preference-v14:25.1.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile ('net.sourceforge.jexcelapi:jxl:2.6.12') {
exclude group: "log4j"
Expand Down
32 changes: 11 additions & 21 deletions networkmonitor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This source is part of the
repository.
Copyright (C) 2013 Benoit 'BoD' Lubek (BoD@JRAF.org)
Copyright (C) 2013-2016 Carmen Alvarez (c@rmen.ca)
Copyright (C) 2013-2017 Carmen Alvarez (c@rmen.ca)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,8 +40,6 @@ limitations under the License.
<uses-permission-sdk-23 android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- system permissions -->
<uses-permission-sdk-23 android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
Expand Down Expand Up @@ -250,7 +248,7 @@ limitations under the License.
<activity
android:name=".app.savetostorage.SaveToStorageActivity"
android:excludeFromRecents="true"
android:exported="true"
android:enabled="@bool/sdkLevel19"
android:icon="@drawable/ic_device_sd_storage"
android:label="@string/export_save_to_external_storage"
android:theme="@style/NetMonNoDisplayTheme" >
Expand All @@ -263,23 +261,6 @@ limitations under the License.
<data android:mimeType="message/rfc822" />
</intent-filter>
</activity>
<activity
android:name=".app.dialog.filechooser.FileChooserActivity"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@drawable/ic_device_sd_storage"
android:label="@string/file_chooser_sdcard"
android:theme="@style/NetMonNoDisplayTheme" >
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.OPENABLE" />

<data android:mimeType="*/*" />
</intent-filter>
</activity>

<receiver android:name=".app.service.BootReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
Expand All @@ -290,6 +271,15 @@ limitations under the License.
android:name=".app.dbops.backend.DBOpIntentService"
android:exported="false" >
</service>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* repository.
*
* Copyright (C) 2013 Benoit 'BoD' Lubek (BoD@JRAF.org)
* Copyright (C) 2013-2016 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2013-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -27,7 +27,6 @@
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.IdRes;
Expand All @@ -41,12 +40,11 @@
import android.view.View;
import android.widget.TextView;

import java.io.File;

import ca.rmen.android.networkmonitor.BuildConfig;
import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.Theme;
import ca.rmen.android.networkmonitor.app.dbops.ui.Share;
import ca.rmen.android.networkmonitor.util.Log;
import de.psdev.licensesdialog.LicensesDialogFragment;

Expand Down Expand Up @@ -125,9 +123,7 @@ protected Boolean doInBackground(Void... params) {
//sendIntent.setData(Uri.fromParts("mailto", getString(R.string.send_logs_to), null));
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.support_send_debug_logs_subject));
String messageBody = getString(R.string.support_send_debug_logs_body);
File f = new File(getExternalFilesDir(null), Log.FILE);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + f.getAbsolutePath()));
sendIntent.setType("message/rfc822");
Share.addFileToShareIntent(AboutActivity.this, sendIntent, Log.FILE);
sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.support_send_debug_logs_to) });
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.action_share)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package ca.rmen.android.networkmonitor.app.dbops.backend;

import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
Expand Down Expand Up @@ -54,7 +53,6 @@
import ca.rmen.android.networkmonitor.app.dbops.backend.export.HTMLExport;
import ca.rmen.android.networkmonitor.app.dbops.backend.export.kml.KMLExport;
import ca.rmen.android.networkmonitor.app.dbops.backend.imp0rt.DBImport;
import ca.rmen.android.networkmonitor.app.main.MainActivity;
import ca.rmen.android.networkmonitor.util.Log;

/**
Expand Down Expand Up @@ -283,15 +281,10 @@ private void handleActionExport(ExportFormat exportFileFormat, Bundle extras) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

// Start the summary report
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
Notification almostDoneNotification =
prepareFileExportNotification(R.drawable.ic_stat_db_op_export, getString(R.string.export_notif_progress_title), getString(R.string.export_progress_finalizing_export), pendingIntent, false).build();
notificationManager.notify(FileExport.class.hashCode(), almostDoneNotification);

Intent shareIntent = FileExport.getShareIntent(this, file);

// All done
pendingIntent = PendingIntent.getActivity(this, 0, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Builder notificationBuilder;
if (fileExport != null && fileExport.isCanceled()) {
notificationBuilder = prepareFileExportNotification(R.drawable.ic_stat_action_done, getString(R.string.export_notif_canceled_title), getString(R.string.export_notif_canceled_content), pendingIntent, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* /___/
* repository.
*
* Copyright (C) 2013-2015 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2013-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,14 +23,14 @@
*/
package ca.rmen.android.networkmonitor.app.dbops.backend.export;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

import android.content.Context;
import android.text.TextUtils;

import ca.rmen.android.networkmonitor.app.dbops.backend.export.FormatterFactory.FormatterStyle;
import ca.rmen.android.networkmonitor.app.dbops.ui.Share;

/**
* Export the Network Monitor data to a CSV file.
Expand All @@ -40,7 +40,7 @@ public class CSVExport extends TableFileExport {
private PrintWriter mPrintWriter;

public CSVExport(Context context) {
super(context, new File(context.getExternalFilesDir(null), CSV_FILE), FormatterStyle.DEFAULT);
super(context, Share.getExportFile(context, CSV_FILE), FormatterStyle.DEFAULT);
}

@Override
Expand Down Expand Up @@ -71,4 +71,4 @@ void writeFooter() throws IOException {
mPrintWriter.flush();
mPrintWriter.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* /___/
* repository.
*
* Copyright (C) 2013-2015 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2013-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,6 +35,7 @@
import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.dbops.ProgressListener;
import ca.rmen.android.networkmonitor.app.dbops.ui.Share;
import ca.rmen.android.networkmonitor.provider.NetMonDatabase;
import ca.rmen.android.networkmonitor.util.Log;

Expand All @@ -45,7 +46,7 @@ public class DBExport extends FileExport {
private static final String TAG = Constants.TAG + DBExport.class.getSimpleName();

public DBExport(Context context) {
super(context, new File(context.getExternalFilesDir(null), NetMonDatabase.DATABASE_NAME));
super(context, Share.getExportFile(context, NetMonDatabase.DATABASE_NAME));
}

@Override
Expand All @@ -70,7 +71,7 @@ public void execute(ProgressListener listener) {
if(isCanceled()) {
listener.onError(mContext.getString(R.string.export_notif_canceled_content));
} else {
listener.onComplete(mContext.getString(R.string.export_save_to_external_storage_success));
listener.onComplete(mContext.getString(R.string.export_save_to_external_storage_success, mFile.getName()));
}
}
} catch (IOException e) {
Expand All @@ -79,4 +80,4 @@ public void execute(ProgressListener listener) {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* /___/
* repository.
*
* Copyright (C) 2013-2015 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2013-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,10 +23,10 @@
*/
package ca.rmen.android.networkmonitor.app.dbops.backend.export;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

import ca.rmen.android.networkmonitor.app.dbops.ui.Share;
import jxl.CellView;
import jxl.JXLException;
import jxl.Workbook;
Expand Down Expand Up @@ -67,7 +67,7 @@ public class ExcelExport extends TableFileExport {
private int mColumnCount;

public ExcelExport(Context context) {
super(context, new File(context.getExternalFilesDir(null), EXCEL_FILE), FormatterStyle.DEFAULT);
super(context, Share.getExportFile(context, EXCEL_FILE), FormatterStyle.DEFAULT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* /___/
* repository.
*
* Copyright (C) 2013-2015 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2013-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,6 @@

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -34,6 +33,7 @@
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.dbops.ProgressListener;
import ca.rmen.android.networkmonitor.app.dbops.backend.DBOperation;
import ca.rmen.android.networkmonitor.app.dbops.ui.Share;
import ca.rmen.android.networkmonitor.util.Log;

/**
Expand Down Expand Up @@ -84,8 +84,7 @@ public static Intent getShareIntent(Context context, File exportedFile) {

String messageBody = context.getString(R.string.export_message_text, dateRange);
if (exportedFile != null && exportedFile.exists()) {
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + exportedFile.getAbsolutePath()));
sendIntent.setType("message/rfc822");
Share.addFileToShareIntent(context, sendIntent, exportedFile.getName());
messageBody += context.getString(R.string.export_message_text_file_attached);
} else {
sendIntent.setType("text/plain");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* /___/
* repository.
*
* Copyright (C) 2015 Carmen Alvarez (c@rmen.ca)
* Copyright (C) 2015-2017 Carmen Alvarez (c@rmen.ca)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -28,7 +28,6 @@
import android.net.Uri;
import android.text.TextUtils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
Expand All @@ -39,6 +38,7 @@
import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.dbops.ProgressListener;
import ca.rmen.android.networkmonitor.app.dbops.ui.Share;
import ca.rmen.android.networkmonitor.app.prefs.FilterPreferences;
import ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
Expand All @@ -61,7 +61,7 @@ public class GnuplotExport extends FileExport {
private final SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);

public GnuplotExport(Context context) {
super(context, new File(context.getExternalFilesDir(null), GNUPLOT_FILE));
super(context, Share.getExportFile(context, GNUPLOT_FILE));
NetMonPreferences prefs = NetMonPreferences.getInstance(mContext);
mSeriesField = prefs.getExportGnuplotSeriesField();
mYAxisField = prefs.getExportGnuplotYAxisField();
Expand Down Expand Up @@ -202,4 +202,4 @@ private void printSeriesDefinitions() {
}
}

}
}
Loading

0 comments on commit 6a2518e

Please sign in to comment.