Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #305 from bmourat/fix/lint-warnings
Browse files Browse the repository at this point in the history
Fix lint warnings
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Oct 4, 2017
2 parents fe020b8 + 7675cee commit 238b962
Show file tree
Hide file tree
Showing 36 changed files with 78 additions and 64 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
Expand All @@ -13,6 +14,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}

tasks.withType(Javadoc) {
Expand Down
9 changes: 3 additions & 6 deletions hockeysdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ publish {

dependencies {
// Mocking
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.crittercism.dexmaker:dexmaker:1.4'
androidTestCompile 'com.crittercism.dexmaker:dexmaker-dx:1.4'
androidTestCompile 'com.crittercism.dexmaker:dexmaker-mockito:1.4'
androidTestCompile 'com.linkedin.dexmaker:dexmaker-mockito:2.2.0'

testCompile 'org.powermock:powermock-api-mockito:1.6.6'
testCompile 'org.powermock:powermock-module-junit4:1.6.6'
Expand All @@ -64,6 +61,6 @@ dependencies {
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'junit:junit:4.12'

androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test:rules:1.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,40 @@
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import junit.framework.TestCase;

import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.File;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
* <h3>Description</h3>
*
* This class provides testing for the environment features, such as the SDK wide constants.
*/
@RunWith(AndroidJUnit4.class)
public class EnvironmentTest extends TestCase {
public class EnvironmentTest {

/*
* This test is disabled since it is always failing on emulators with API under 18. The problem
* is that emulators start with external storage being in removed state and necessary directory
* can not be created.
*
* TODO: Uncomment test in case emulators with API under 18 start supporting external storage
*/
/**
* Test to verify basic creation of the external storage directory works.
*/
@Test
//@Test
public void basicStorageDirTest() {
File storageDir = Constants.getHockeyAppStorageDir(InstrumentationRegistry.getTargetContext());

assertNotNull(storageDir);
assertTrue(storageDir.exists());
}

@Test
public void dummyTestMethod() {}
}
2 changes: 1 addition & 1 deletion hockeysdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

<application>
<application android:supportsRtl="true">

<activity android:name=".UpdateActivity" />
<activity android:name=".FeedbackActivity" android:windowSoftInputMode="adjustResize|stateVisible" />
Expand Down
2 changes: 2 additions & 0 deletions hockeysdk/src/main/java/net/hockeyapp/android/Constants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -185,6 +186,7 @@ private static int loadBuildNumber(Context context, PackageManager packageManage
*
* @param context the context to use. Usually your Activity object.
*/
@SuppressLint("StaticFieldLeak")
private static void loadIdentifiers(final Context context) {
if (Constants.DEVICE_IDENTIFIER != null) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
Expand Down Expand Up @@ -204,6 +205,7 @@ public static void initialize(Context context, String urlString, String appIdent
* @param context The context to use. Usually your Activity object.
* @param listener Implement for callback functions.
*/
@SuppressLint("StaticFieldLeak")
public static void execute(Context context, final CrashManagerListener listener) {
final WeakReference<Context> weakContext = new WeakReference<>(context);
AsyncTaskUtils.execute(new AsyncTask<Void, Object, Integer>() {
Expand Down Expand Up @@ -503,6 +505,7 @@ public static void deleteStackTraces(final WeakReference<Context> weakContext) {
* @see CrashMetaData
* @see CrashManagerListener
*/
@SuppressLint("StaticFieldLeak")
@SuppressWarnings("WeakerAccess")
public static boolean handleUserInput(final CrashManagerUserInput userInput,
final CrashMetaData userProvidedMetaData, final CrashManagerListener listener,
Expand Down Expand Up @@ -634,6 +637,7 @@ private static String getAlertTitle(Context context) {
* Starts thread to send crashes to HockeyApp, then registers the exception
* handler.
*/
@SuppressLint("StaticFieldLeak")
private static void sendCrashes(final WeakReference<Context> weakContext, final CrashManagerListener listener, final boolean ignoreDefaultHandler, final CrashMetaData crashMetaData) {
registerHandler(listener, ignoreDefaultHandler);
Context context = weakContext != null ? weakContext.get() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ private void loadFeedbackMessages(final FeedbackResponse feedbackResponse) {
}
}

@SuppressLint("StaticFieldLeak")
private void resetFeedbackView() {
mToken = null;
AsyncTaskUtils.execute(new AsyncTask<Void, Object, Object>() {
Expand All @@ -722,6 +723,7 @@ protected Object doInBackground(Void... voids) {
/**
* Send feedback to HockeyApp.
*/
@SuppressLint("StaticFieldLeak")
private void sendFeedback() {
if (!Util.isConnectedToNetwork(this)) {
Toast errorToast = Toast.makeText(this, R.string.hockeyapp_error_no_network_message, Toast.LENGTH_LONG);
Expand Down Expand Up @@ -873,6 +875,7 @@ private static class ParseFeedbackHandler extends Handler {
mWeakFeedbackActivity = new WeakReference<>(feedbackActivity);
}

@SuppressLint("StaticFieldLeak")
@Override
public void handleMessage(Message msg) {
boolean success = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.app.PendingIntent;
Expand Down Expand Up @@ -198,6 +199,7 @@ public static void showFeedbackActivity(Context context, Uri... attachments) {
* @param attachments the optional attachment {@link Uri}s
* @param extras a bundle to be added to the Intent that starts the FeedbackActivity instance
*/
@SuppressLint("StaticFieldLeak")
public static void showFeedbackActivity(final Context context, final Bundle extras, final Uri... attachments) {
if (context != null) {
final Class<?> activityClass = lastListener != null ? lastListener.getFeedbackActivityClass() : null;
Expand Down Expand Up @@ -281,6 +283,7 @@ public boolean accept(File dir, String name) {
*
* @param context the context to use
*/
@SuppressLint("StaticFieldLeak")
public static void checkForAnswersAndNotify(final Context context) {
String token = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(context);
if (token == null) {
Expand Down Expand Up @@ -417,6 +420,7 @@ public static void unsetCurrentActivityForScreenshot(Activity activity) {
*
* @param context toast messages will be displayed using this context
*/
@SuppressLint("StaticFieldLeak")
public static void takeScreenshot(final Context context) {
final Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -175,6 +176,7 @@ public static void register(final Context context, String appIdentifier, String
* @param context The activity from which this method is called.
* @param intent The intent that the activity has been created with.
*/
@SuppressLint("StaticFieldLeak")
public static void verifyLogin(final Activity context, Intent intent) {
//Don't verify anything if we're in LOGIN_MODE_ANONYMOUS
if (context == null || mode == LOGIN_MODE_ANONYMOUS) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class PaintActivity extends Activity {
private PaintView mPaintView;
private Uri mImageUri;

@SuppressLint("StaticFieldLeak")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -177,6 +179,7 @@ private void showPaintView() {
toast.show();
}

@SuppressLint("StaticFieldLeak")
private void makeResult() {
mPaintView.setDrawingCacheEnabled(true);
final Bitmap bitmap = mPaintView.getDrawingCache();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.metrics;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
Expand Down Expand Up @@ -423,6 +424,7 @@ private void updateSession() {
}
}

@SuppressLint("StaticFieldLeak")
private void renewSession() {
final String sessionId = UUID.randomUUID().toString();
try {
Expand Down Expand Up @@ -478,6 +480,7 @@ public static void trackEvent(final String eventName, final Map<String, String>
trackEvent(eventName, properties, null);
}

@SuppressLint("StaticFieldLeak")
public static void trackEvent(final String eventName, final Map<String, String> properties, final Map<String, Double> measurements) {
if (TextUtils.isEmpty(eventName)) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.metrics;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.AsyncTask;

Expand Down Expand Up @@ -95,6 +96,7 @@ protected void persist(String[] data) {
}
}

@SuppressLint("StaticFieldLeak")
void sendAvailable() {
AsyncTaskUtils.execute(new AsyncTask<Void, Object, Object>() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.metrics;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.AsyncTask;
import android.os.Build;
Expand Down Expand Up @@ -74,6 +75,7 @@ protected Sender() {
* for available data, if the max amount of concurrent requests is not reached yet.
* Does nothing, if the maximum number of concurrent requests is already reached or exceeded.
*/
@SuppressLint("StaticFieldLeak")
protected void triggerSending() {
if (requestCount() < MAX_REQUEST_COUNT) {
try {
Expand All @@ -95,6 +97,7 @@ protected Void doInBackground(Void... params) {
}
}

@SuppressLint("StaticFieldLeak")
protected void triggerSendingForTesting(final HttpURLConnection connection, final File file, final String persistedData) {
if (requestCount() < MAX_REQUEST_COUNT) {
mRequestCount.getAndIncrement();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.metrics;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Point;
Expand Down Expand Up @@ -105,6 +106,7 @@ private TelemetryContext() {
* @param context the context for this telemetryContext
* @param appIdentifier the app identifier for this application
*/
@SuppressLint("StaticFieldLeak")
TelemetryContext(Context context, String appIdentifier) {
this();
mWeakContext = new WeakReference<>(context);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.tasks;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.AsyncTask;
Expand Down Expand Up @@ -143,6 +144,7 @@ boolean consumeRetry() {
/**
* The AsyncTask that downloads the image and the updates the view.
*/
@SuppressLint("StaticFieldLeak")
private static class DownloadTask extends AsyncTask<Void, Integer, Boolean> {

private final DownloadJob downloadJob;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.tasks;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
Expand Down Expand Up @@ -33,6 +34,7 @@
* it on external storage. If the download was successful, the file
* is then opened to trigger the installation.
**/
@SuppressLint("StaticFieldLeak")
public class DownloadFileTask extends AsyncTask<Void, Integer, Long> {
protected static final int MAX_REDIRECTS = 6;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.tasks;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
Expand All @@ -25,6 +26,7 @@
* Perform the authentication process.
*
**/
@SuppressLint("StaticFieldLeak")
public class LoginTask extends ConnectionTask<Void, Void, Boolean> {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.tasks;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
Expand Down Expand Up @@ -28,6 +29,7 @@
* {@link AsyncTask} that parses the Feedback JSON response
*
*/
@SuppressLint("StaticFieldLeak")
public class ParseFeedbackTask extends AsyncTask<Void, Void, FeedbackResponse> {

public static final String PREFERENCES_NAME = "net.hockeyapp.android.feedback";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.hockeyapp.android.tasks;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
Expand Down Expand Up @@ -29,6 +30,7 @@
* Internal helper class. Sends feedback to server.
*
**/
@SuppressLint("StaticFieldLeak")
public class SendFeedbackTask extends ConnectionTask<Void, Void, HashMap<String, String>> {

public static final String BUNDLE_FEEDBACK_RESPONSE = "feedback_response";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class AttachmentView extends FrameLayout {

private int mOrientation;

@SuppressLint("StaticFieldLeak")
public AttachmentView(Context context, ViewGroup parent, Uri attachmentUri, boolean removable) {
super(context);

Expand Down
Loading

0 comments on commit 238b962

Please sign in to comment.