Skip to content

Commit

Permalink
Merge branch 'code-cleanup'
Browse files Browse the repository at this point in the history
  • Loading branch information
caarmen committed Aug 15, 2017
2 parents 28f7182 + 4ae3c94 commit 6b2efeb
Show file tree
Hide file tree
Showing 191 changed files with 244 additions and 906 deletions.
3 changes: 3 additions & 0 deletions networkmonitor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ android {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
disable 'GoogleAppIndexingWarning'
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@

import android.app.Application;

import ca.rmen.android.networkmonitor.util.Log;

public class NetMonApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
Theme.setThemeFromSettings(this);
Log.init(this, 1000000, true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,20 @@
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.design.widget.Snackbar;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
import android.view.Menu;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

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;

public class AboutActivity extends AppCompatActivity {
Expand All @@ -66,8 +61,8 @@ protected void onCreate(Bundle savedInstanceState) {
throw new AssertionError(e);
}

((TextView) findViewById(R.id.txtVersion)).setText(getString(R.string.app_name) + " v" + versionName);
TextView tvLibraries = (TextView) findViewById(R.id.tv_about_libraries);
((TextView) findViewById(R.id.txtVersion)).setText(getString(R.string.about_version, getString(R.string.app_name), versionName));
TextView tvLibraries = findViewById(R.id.tv_about_libraries);
SpannableString content = new SpannableString(getString(R.string.about_libraries));
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
tvLibraries.setText(content);
Expand All @@ -86,58 +81,15 @@ protected void onCreate(Bundle savedInstanceState) {

private void tintCompoundDrawables(@IdRes int... textViewIds) {
for (int textViewId : textViewIds) {
Theme.tintCompoundDrawables(this, (TextView) findViewById(textViewId));
Theme.tintCompoundDrawables(this, findViewById(textViewId));
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.about, menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem itemSendLogs = menu.findItem(R.id.action_send_logs);
itemSendLogs.setVisible(BuildConfig.DEBUG);
return super.onPrepareOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
case R.id.action_send_logs:
new AsyncTask<Void, Void, Boolean>() {

@Override
protected Boolean doInBackground(Void... params) {
if (!Log.prepareLogFile(getApplicationContext())) {
return false;
}
// Bring up the chooser to share the file.
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
//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);
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)));
return true;
}

@Override
protected void onPostExecute(Boolean result) {
if (!result) Snackbar.make(getWindow().getDecorView().getRootView(), R.string.support_error, Snackbar.LENGTH_LONG).show();
}


}.execute();
return true;
if (item.getItemId() == android.R.id.home) {
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.JobIntentService;
Expand All @@ -55,7 +54,7 @@
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.service.NetMonNotification;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

public class DBOpIntentService extends JobIntentService {

Expand Down Expand Up @@ -256,7 +255,7 @@ private void handleActionExport(ExportFormat exportFileFormat, Bundle extras) {
fileExport = new ExcelExport(this);
break;
case HTML:
fileExport = new HTMLExport(this, true);
fileExport = new HTMLExport(this);
break;
case KML:
String placemarkColumnName = extras.getString(EXTRA_EXPORT_KML_PLACEMARK_COLUMN_NAME);
Expand Down Expand Up @@ -285,23 +284,23 @@ private void handleActionExport(ExportFormat exportFileFormat, Bundle extras) {
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);
notificationBuilder = prepareFileExportNotification(getString(R.string.export_notif_canceled_title), getString(R.string.export_notif_canceled_content), pendingIntent);
} else {
notificationBuilder = prepareFileExportNotification(R.drawable.ic_stat_action_done, getString(R.string.export_notif_complete_title), getString(R.string.export_notif_complete_content), pendingIntent, true);
notificationBuilder = prepareFileExportNotification(getString(R.string.export_notif_complete_title), getString(R.string.export_notif_complete_content), pendingIntent);
}
notificationBuilder.addAction(R.drawable.ic_pref_share, getString(R.string.action_share), pendingIntent);
notificationManager.notify(FileExport.class.hashCode(), notificationBuilder.build());
}

private NotificationCompat.Builder prepareFileExportNotification(@DrawableRes int iconId, String titleText, String contentText, PendingIntent pendingIntent, boolean autoCancel) {
private NotificationCompat.Builder prepareFileExportNotification(String titleText, String contentText, PendingIntent pendingIntent) {
return new NotificationCompat.Builder(this, NetMonNotification.createOngoingNotificationChannel(this))
.setSmallIcon(iconId)
.setSmallIcon(R.drawable.ic_stat_action_done)
.setTicker(titleText)
.setContentTitle(titleText)
.setContentText(contentText)
.setStyle(new NotificationCompat.BigTextStyle().bigText(contentText))
.setAutoCancel(autoCancel)
.setOngoing(!autoCancel)
.setAutoCancel(true)
.setOngoing(false)
.setContentIntent(pendingIntent)
.setColor(ActivityCompat.getColor(this, R.color.netmon_color));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import ca.rmen.android.networkmonitor.app.dbops.ProgressListener;
import ca.rmen.android.networkmonitor.app.main.MainActivity;
import ca.rmen.android.networkmonitor.app.service.NetMonNotification;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Displays task progress in a system notification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import ca.rmen.android.networkmonitor.app.dbops.ProgressListener;
import ca.rmen.android.networkmonitor.app.dbops.backend.DBOperation;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Reduces groups of 3 or more consecutive rows with identical data (except the timestamp) into a single row.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import ca.rmen.android.networkmonitor.app.dbops.backend.DBOperation;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.provider.NetMonProvider;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Only keep the most recent X records: where X is determined by the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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;
import android.util.Log;

/**
* Export the Network Monitor DB file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.dbops.backend.export.FormatterFactory.FormatterStyle;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Export the Network Monitor data to an Excel file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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;
import android.util.Log;

/**
* Export the Network Monitor data from the DB to a file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences;
import ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences.CellIdFormat;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Create the appropriate Formatter instance depending on the formatter style.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.provider.UniqueValuesColumns;
import ca.rmen.android.networkmonitor.util.IoUtil;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Export the Network Monitor data to a gnuplot file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import ca.rmen.android.networkmonitor.app.prefs.SortPreferences;
import ca.rmen.android.networkmonitor.app.prefs.SortPreferences.SortOrder;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Export the Network Monitor data to an HTML file. The HTML file includes CSS specified in the strings XML file.
Expand All @@ -58,10 +58,9 @@ public class HTMLExport extends TableFileExport {
private final String mFixedTableHeight;

/**
* @param external if true, the file will be exported to the sd card. Otherwise it will written to the application's internal storage.
*/
public HTMLExport(Context context, boolean external) {
this(context, external, TABLE_HEIGHT_FILE_EXPORT);
public HTMLExport(Context context) {
this(context, true, TABLE_HEIGHT_FILE_EXPORT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.provider.ConnectionTestStatsColumns;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

public class SummaryExport {
private static final String TAG = Constants.TAG + SummaryExport.class.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import ca.rmen.android.networkmonitor.app.prefs.SortPreferences;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.provider.NetMonProvider;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Export the Network Monitor data from the DB to a file in a table format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import ca.rmen.android.networkmonitor.app.prefs.FilterPreferences.Selection;
import ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Export the Network Monitor data to a KML file. The KML file placemark icon label and color depend on the field the user chose to export.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.provider.NetMonProvider;
import ca.rmen.android.networkmonitor.util.IoUtil;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Replace the contents of the current database with the contents of another database.
Expand Down Expand Up @@ -114,8 +114,8 @@ private void importDB(File importDb, ProgressListener listener) throws RemoteExc
/**
* Read all cells from the given table from the dbImport database, and add corresponding insert operations to the operations parameter.
*
* @throws OperationApplicationException
* @throws RemoteException
* @throws OperationApplicationException if the database couldn't insert the data.
* @throws RemoteException if the database couldn't insert the data.
*/
private void buildInsertOperations(SQLiteDatabase dbImport, Uri uri, ArrayList<ContentProviderOperation> operations, ProgressListener listener)
throws RemoteException, OperationApplicationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import ca.rmen.android.networkmonitor.app.prefs.NetMonPreferenceFragmentCompat;
import ca.rmen.android.networkmonitor.app.prefs.NetMonPreferences;
import ca.rmen.android.networkmonitor.provider.NetMonColumns;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

public class GnuplotSettingsActivity extends AppCompatActivity {
private static final String TAG = Constants.TAG + GnuplotSettingsActivity.class.getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.dbops.backend.DBOpIntentService;
import ca.rmen.android.networkmonitor.app.dialog.PreferenceDialog;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import android.support.v7.app.AlertDialog;

import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* A dialog fragment with a list of choices.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import android.support.v7.app.AlertDialog;

import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* A dialog fragment with a title, message, ok and cancel buttons. This is based on ConfirmDialogFragment from the scrum chatter project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import ca.rmen.android.networkmonitor.R;
import ca.rmen.android.networkmonitor.app.dialog.ChoiceDialogFragment.DialogItemListener;
import ca.rmen.android.networkmonitor.app.dialog.ConfirmDialogFragment.DialogButtonListener;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Create different types of dialog fragments (edit text input, information, choice, confirmation, progress).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import android.widget.TextView;

import ca.rmen.android.networkmonitor.Constants;
import ca.rmen.android.networkmonitor.util.Log;
import android.util.Log;

/**
* Shows a dialog with a title, message, and a single button to dismiss the dialog.
Expand Down Expand Up @@ -72,7 +72,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
final Dialog dialog = builder.create();
if (getActivity() instanceof OnDismissListener) dialog.setOnDismissListener((OnDismissListener) getActivity());
dialog.setOnShowListener(dialogInterface -> {
TextView messageTextView = (TextView) ((Dialog) dialogInterface).findViewById(android.R.id.message);
TextView messageTextView = ((Dialog) dialogInterface).findViewById(android.R.id.message);
if (messageTextView != null)
messageTextView.setMovementMethod(LinkMovementMethod.getInstance());
});
Expand Down
Loading

0 comments on commit 6b2efeb

Please sign in to comment.