From efc76e7d043154eb7cc2d08d652f836123e7f18b Mon Sep 17 00:00:00 2001 From: Steven Mulder Date: Wed, 22 Nov 2017 11:15:33 +0100 Subject: [PATCH 1/7] Remove `android:supportsRtl` attribute from AndroidManifest The resources in the SDK might support RTL layouts, but the consuming app might not. In fact, when they explicitly set `supportsRtl` to `false` on their application, this causes a conflict when creating the merged manifest, causing the build to fail. So it is probably best not to set the attribute and ignore the lint warning. Fixes #334. --- hockeysdk/build.gradle | 2 +- hockeysdk/src/main/AndroidManifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hockeysdk/build.gradle b/hockeysdk/build.gradle index 85a59eb34..2b3ab412d 100644 --- a/hockeysdk/build.gradle +++ b/hockeysdk/build.gradle @@ -18,7 +18,7 @@ android { } } lintOptions { - disable 'GoogleAppIndexingWarning' + disable 'GoogleAppIndexingWarning','RtlEnabled' textReport true } } diff --git a/hockeysdk/src/main/AndroidManifest.xml b/hockeysdk/src/main/AndroidManifest.xml index 2b2c19f2d..e59dcfcee 100644 --- a/hockeysdk/src/main/AndroidManifest.xml +++ b/hockeysdk/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ - + From 3970f5b7e71320f05ec4bba0f583050b6b3283fb Mon Sep 17 00:00:00 2001 From: Ivan Matkov Date: Fri, 1 Dec 2017 12:42:41 +0300 Subject: [PATCH 2/7] Add missing JavaDoc --- .../android/metrics/MetricsManager.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/metrics/MetricsManager.java b/hockeysdk/src/main/java/net/hockeyapp/android/metrics/MetricsManager.java index 6fd31bc22..a3cd8dc21 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/metrics/MetricsManager.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/metrics/MetricsManager.java @@ -433,14 +433,40 @@ private static Data createData(TelemetryData telemetryData) { return data; } + /** + * This method allows to track an event that happened in your app. + * Remember to choose meaningful event names to have the best experience when diagnosing your app + * in the HockeyApp web portal. + * + * @param eventName The event's name as a string. + */ + @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) public static void trackEvent(final String eventName) { trackEvent(eventName, null); } + /** + * This method allows to track an event that happened in your app. + * Remember to choose meaningful event names to have the best experience when diagnosing your app + * in the web portal. + * + * @param eventName the name of the event, which should be tracked. + * @param properties key value pairs with additional info about the event. + */ + @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) public static void trackEvent(final String eventName, final Map properties) { trackEvent(eventName, properties, null); } + /** + * This method allows to track an event that happened in your app. + * Remember to choose meaningful event names to have the best experience when diagnosing your app + * in the web portal. + * + * @param eventName the name of the event, which should be tracked. + * @param properties key value pairs with additional info about the event. + * @param measurements key value pairs, which contain custom metrics. + */ @SuppressLint("StaticFieldLeak") public static void trackEvent(final String eventName, final Map properties, final Map measurements) { if (TextUtils.isEmpty(eventName)) { From 5acca36eaac4ae85adf55f615301a86888316750 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Mon, 11 Dec 2017 13:38:06 +0300 Subject: [PATCH 3/7] setUserId method added to FeedbackManager --- .../hockeyapp/android/FeedbackActivity.java | 21 ++++++++++++++----- .../hockeyapp/android/FeedbackManager.java | 16 +++++++++++--- .../android/tasks/SendFeedbackTask.java | 11 ++++++++-- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackActivity.java b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackActivity.java index 4eb43f6d2..33d4c0edc 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackActivity.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackActivity.java @@ -99,6 +99,11 @@ public class FeedbackActivity extends Activity implements OnClickListener, View. */ public static final String EXTRA_INITIAL_ATTACHMENTS = "initialAttachments"; + /** + * Extra for user id to be send with the feedback message. + */ + public static final String EXTRA_USER_ID = "userId"; + /** * Number of attachments allowed per message. **/ @@ -126,6 +131,11 @@ public class FeedbackActivity extends Activity implements OnClickListener, View. */ private String mInitialUserSubject; + /** + * User id to be send with the feedback message + */ + private String mUserId; + /** * Initial attachment uris */ @@ -213,6 +223,7 @@ public void onCreate(Bundle savedInstanceState) { mInitialUserName = extras.getString(EXTRA_INITIAL_USER_NAME); mInitialUserEmail = extras.getString(EXTRA_INITIAL_USER_EMAIL); mInitialUserSubject = extras.getString(EXTRA_INITIAL_USER_SUBJECT); + mUserId = extras.getString(EXTRA_USER_ID); Parcelable[] initialAttachmentsArray = extras.getParcelableArray(EXTRA_INITIAL_ATTACHMENTS); if (initialAttachmentsArray != null) { @@ -354,7 +365,7 @@ public void onClick(View v) { mInSendFeedback = true; configureFeedbackView(false); } else if (viewId == R.id.button_refresh) { - sendFetchFeedback(mUrl, null, null, null, null, null, mToken, mFeedbackHandler, true); + sendFetchFeedback(mUrl, null, null, null, null, null, null, mToken, mFeedbackHandler, true); } } @@ -601,7 +612,7 @@ private void configureAppropriateView() { } else { /** If Feedback Token is NOT NULL, show the Add Response Button and fetch the feedback messages */ configureFeedbackView(true); - sendFetchFeedback(mUrl, null, null, null, null, null, mToken, mFeedbackHandler, true); + sendFetchFeedback(mUrl, null, null, null, null, null, null, mToken, mFeedbackHandler, true); } } @@ -764,7 +775,7 @@ protected Object doInBackground(Void... voids) { List attachmentUris = mAttachmentListView.getAttachments(); /** Start the Send Feedback {@link AsyncTask} */ - sendFetchFeedback(mUrl, name, email, subject, text, attachmentUris, token, mFeedbackHandler, false); + sendFetchFeedback(mUrl, name, email, subject, text, mUserId, attachmentUris, token, mFeedbackHandler, false); hideKeyboard(); } @@ -795,8 +806,8 @@ public void run() { * @param feedbackHandler Handler to handle the response * @param isFetchMessages Set true to fetch messages, false to send one */ - private void sendFetchFeedback(String url, String name, String email, String subject, String text, List attachmentUris, String token, Handler feedbackHandler, boolean isFetchMessages) { - mSendFeedbackTask = new SendFeedbackTask(mContext, url, name, email, subject, text, attachmentUris, token, feedbackHandler, isFetchMessages); + private void sendFetchFeedback(String url, String name, String email, String subject, String text, String userId, List attachmentUris, String token, Handler feedbackHandler, boolean isFetchMessages) { + mSendFeedbackTask = new SendFeedbackTask(mContext, url, name, email, subject, text, userId, attachmentUris, token, feedbackHandler, isFetchMessages); AsyncTaskUtils.execute(mSendFeedbackTask); } diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java index 169f235a6..06438df67 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java @@ -13,8 +13,6 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.os.Handler; -import android.os.Message; import android.view.View; import android.widget.Toast; @@ -108,6 +106,8 @@ public class FeedbackManager { private static String userEmail; + private static String userId; + /** * Last listener instance. */ @@ -237,6 +237,7 @@ protected Intent doInBackground(Void... voids) { intent.putExtra(FeedbackActivity.EXTRA_INITIAL_USER_EMAIL, userEmail); intent.putExtra(FeedbackActivity.EXTRA_INITIAL_USER_SUBJECT, userSubject); intent.putExtra(FeedbackActivity.EXTRA_INITIAL_ATTACHMENTS, getInitialAttachments(attachments)); + intent.putExtra(FeedbackActivity.EXTRA_USER_ID, FeedbackManager.userId); return intent; } @@ -293,7 +294,7 @@ public static void checkForAnswersAndNotify(final Context context) { int lastMessageId = context.getSharedPreferences(ParseFeedbackTask.PREFERENCES_NAME, 0) .getInt(ParseFeedbackTask.ID_LAST_MESSAGE_SEND, -1); - SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(context), null, null, null, null, null, token, null, true) { + SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(context), null, null, null, null, null, null, token, null, true) { @Override protected void onPostExecute(HashMap result) { @@ -385,6 +386,15 @@ public static void setUserEmail(String userEmail) { FeedbackManager.userEmail = userEmail; } + /** + * Sets the user id to send as additional data + * + * @param userId user id + */ + public static void setUserId(String userId) { + FeedbackManager.userId = userId; + } + /** * Stores a reference to the given activity to be used for taking a screenshot of it. * Reference is cleared only when method unsetCurrentActivityForScreenshot is called. diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/tasks/SendFeedbackTask.java b/hockeysdk/src/main/java/net/hockeyapp/android/tasks/SendFeedbackTask.java index 881da1284..362683440 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/tasks/SendFeedbackTask.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/tasks/SendFeedbackTask.java @@ -47,6 +47,7 @@ public class SendFeedbackTask extends ConnectionTask mAttachmentUris; private String mToken; private boolean mIsFetchMessages; @@ -76,7 +77,7 @@ public class SendFeedbackTask extends ConnectionTask attachmentUris, String token, + String subject,String text, String userId, List attachmentUris, String token, Handler handler, boolean isFetchMessages) { this.mContext = context; @@ -85,6 +86,7 @@ public SendFeedbackTask(Context context, String urlString, String name, String e this.mEmail = email; this.mSubject = subject; this.mText = text; + this.mUserId = userId; this.mAttachmentUris = attachmentUris; this.mToken = token; this.mHandler = handler; @@ -242,6 +244,9 @@ private HashMap doPostPut() { parameters.put("oem", Constants.PHONE_MANUFACTURER); parameters.put("model", Constants.PHONE_MODEL); parameters.put("sdk_version", Constants.SDK_VERSION); + if (mUserId != null) { + parameters.put("user_string", mUserId); + } if (mToken != null) { mUrlString += mToken + "/"; @@ -290,7 +295,9 @@ private HashMap doPostPutWithAttachments() { parameters.put("oem", Constants.PHONE_MANUFACTURER); parameters.put("model", Constants.PHONE_MODEL); parameters.put("sdk_version", Constants.SDK_VERSION); - + if (mUserId != null) { + parameters.put("user_string", mUserId); + } if (mToken != null) { mUrlString += mToken + "/"; } From b7259964b74ee20871690040480ba4d9a9088891 Mon Sep 17 00:00:00 2001 From: Ivan Matkov Date: Mon, 11 Dec 2017 14:31:23 +0300 Subject: [PATCH 4/7] Fix available files check --- .../net/hockeyapp/android/metrics/PersistenceTests.java | 5 +++++ .../java/net/hockeyapp/android/metrics/Persistence.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hockeysdk/src/androidTest/java/net/hockeyapp/android/metrics/PersistenceTests.java b/hockeysdk/src/androidTest/java/net/hockeyapp/android/metrics/PersistenceTests.java index 3abe2b788..1fa3954dd 100644 --- a/hockeysdk/src/androidTest/java/net/hockeyapp/android/metrics/PersistenceTests.java +++ b/hockeysdk/src/androidTest/java/net/hockeyapp/android/metrics/PersistenceTests.java @@ -87,6 +87,11 @@ public void testNextFileRequestReturnsUnreservedFile() { servedFiles.add(mockFile1); sut.mServedFiles = servedFiles; + // Test hasFilesAvailable + assertTrue(sut.hasFilesAvailable()); + assertTrue(!sut.mServedFiles.contains(mockFile2)); + assertTrue(sut.hasFilesAvailable()); + // Test one unreserved file left File result = sut.nextAvailableFileInDirectory(); assertEquals(mockFile2, result); diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/metrics/Persistence.java b/hockeysdk/src/main/java/net/hockeyapp/android/metrics/Persistence.java index 218e02172..baa379fa8 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/metrics/Persistence.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/metrics/Persistence.java @@ -193,7 +193,11 @@ String load(File file) { */ @SuppressWarnings("WeakerAccess") protected boolean hasFilesAvailable() { - return nextAvailableFileInDirectory() != null; + File file = nextAvailableFileInDirectory(); + + // Don't change availability on checking + makeAvailable(file); + return file != null; } /** From 26fa3271fdd506c05bef12a973331b2875491d5a Mon Sep 17 00:00:00 2001 From: Ivan Matkov Date: Mon, 11 Dec 2017 15:33:35 +0300 Subject: [PATCH 5/7] Add readable error if FeedbackManager register call is missed --- .../hockeyapp/android/FeedbackManager.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java index 169f235a6..8b4a866a1 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java @@ -13,8 +13,6 @@ import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.os.Handler; -import android.os.Message; import android.view.View; import android.widget.Toast; @@ -201,6 +199,10 @@ public static void showFeedbackActivity(Context context, Uri... attachments) { */ @SuppressLint("StaticFieldLeak") public static void showFeedbackActivity(final Context context, final Bundle extras, final Uri... attachments) { + if (urlString == null || identifier == null) { + HockeyLog.error("FeedbackManager hasn't been registered."); + return; + } if (context != null) { final Class activityClass = lastListener != null ? lastListener.getFeedbackActivityClass() : null; final boolean forceNewThread = lastListener != null && lastListener.shouldCreateNewFeedbackThread(); @@ -214,7 +216,7 @@ protected Intent doInBackground(Void... voids) { } intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClass(context, activityClass != null ? activityClass : FeedbackActivity.class); - intent.putExtra(FeedbackActivity.EXTRA_URL, getURLString(context)); + intent.putExtra(FeedbackActivity.EXTRA_URL, getURLString()); String token = !forceNewThread ? PrefsUtil.getInstance().getFeedbackTokenFromPrefs(context) : null; intent.putExtra(FeedbackActivity.EXTRA_TOKEN, token); intent.putExtra(FeedbackActivity.EXTRA_FORCE_NEW_THREAD, forceNewThread); @@ -285,6 +287,10 @@ public boolean accept(File dir, String name) { */ @SuppressLint("StaticFieldLeak") public static void checkForAnswersAndNotify(final Context context) { + if (urlString == null || identifier == null) { + HockeyLog.error("FeedbackManager hasn't been registered."); + return; + } String token = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(context); if (token == null) { return; @@ -293,7 +299,7 @@ public static void checkForAnswersAndNotify(final Context context) { int lastMessageId = context.getSharedPreferences(ParseFeedbackTask.PREFERENCES_NAME, 0) .getInt(ParseFeedbackTask.ID_LAST_MESSAGE_SEND, -1); - SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(context), null, null, null, null, null, token, null, true) { + SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(), null, null, null, null, null, token, null, true) { @Override protected void onPostExecute(HashMap result) { @@ -302,7 +308,7 @@ protected void onPostExecute(HashMap result) { String responseString = result.get("response"); if (responseString != null) { ParseFeedbackTask task = new ParseFeedbackTask(context, responseString, null, "fetch"); - task.setUrlString(getURLString(context)); + task.setUrlString(getURLString()); AsyncTaskUtils.execute(task); } } @@ -324,10 +330,13 @@ public static FeedbackManagerListener getLastListener() { /** * Populates the URL String with the appIdentifier * - * @param context {@link Context} object * @return URL String with the appIdentifier */ - private static String getURLString(Context context) { + private static String getURLString() { + if (urlString == null || identifier == null) { + HockeyLog.error("FeedbackManager hasn't been registered."); + return null; + } return urlString + "api/2/apps/" + identifier + "/feedback/"; } From 6e700e1c02f9ca7578944091eb0ef6d22e74c352 Mon Sep 17 00:00:00 2001 From: Murat Baysangurov Date: Wed, 13 Dec 2017 10:16:32 +0300 Subject: [PATCH 6/7] Fix merge issues --- .../src/main/java/net/hockeyapp/android/FeedbackManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java index 6bac91fbc..60f6b2320 100644 --- a/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java +++ b/hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java @@ -302,7 +302,7 @@ public static void checkForAnswersAndNotify(final Context context) { int lastMessageId = context.getSharedPreferences(ParseFeedbackTask.PREFERENCES_NAME, 0) .getInt(ParseFeedbackTask.ID_LAST_MESSAGE_SEND, -1); - SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(context), null, null, null, null, null, null, token, null, true) { + SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(), null, null, null, null, null, null, token, null, true) { @Override protected void onPostExecute(HashMap result) { From 80ffb9345378238b16377a36885dfa8aaa8ee67f Mon Sep 17 00:00:00 2001 From: "Benjamin Scholtysik (Reimold)" Date: Wed, 10 Jan 2018 15:15:43 -0800 Subject: [PATCH 7/7] Use latest gradle pluding (3.0.1), use SDK 27 as compile_SDK and bump version to 5.1.0 --- README.md | 4 ++-- build.gradle | 8 ++++---- hockeysdk/build.gradle | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4ae2777da..359e8357f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Build Status](https://www.bitrise.io/app/562949a18404dad6/status.svg?token=IZE4w-D2xii7QjqvJVc51A&branch=master)](https://www.bitrise.io/app/562949a18404dad6) [![Slack Status](https://slack.hockeyapp.net/badge.svg)](https://slack.hockeyapp.net) -## Version 5.0.4 +## Version 5.1.0 HockeySDK-Android implements support for using HockeyApp in your Android applications. @@ -26,7 +26,7 @@ It is super easy to use HockeyApp in your Android app. Have a look at our [docum Please visit [our landing page](https://support.hockeyapp.net/kb/client-integration-android) as a starting point for all of our documentation. -Please check out our [getting started documentation](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk), [change log](https://github.com/bitstadium/HockeySDK-Android/releases/tag/5.0.4), [java doc](https://www.hockeyapp.net/help/sdk/android/5.0.4/index.html) as well as our [troubleshooting section](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk#troubleshooting). +Please check out our [getting started documentation](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk), [change log](https://github.com/bitstadium/HockeySDK-Android/releases/tag/5.1.0), [java doc](https://www.hockeyapp.net/help/sdk/android/5.1.0/index.html) as well as our [troubleshooting section](https://support.hockeyapp.net/kb/client-integration-android/hockeyapp-for-android-sdk#troubleshooting). ## 3. Contributing diff --git a/build.gradle b/build.gradle index 2f9be99b1..131ea1131 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.novoda:bintray-release:0.5.0' } } @@ -37,13 +37,13 @@ allprojects { ext { ARTIFACT_ID = 'HockeySDK' - VERSION_NAME = '5.0.4' - VERSION_CODE = 18 + VERSION_NAME = '5.1.0' + VERSION_CODE = 19 SITE_URL = 'https://github.com/bitstadium/hockeysdk-android' GIT_URL = 'https://github.com/bitstadium/HockeySDK-Android.git' BINTRAY_USER = HOCKEYAPP_BINTRAY_USER GROUP_NAME = 'net.hockeyapp.android' - COMPILE_SDK = 26 + COMPILE_SDK = 27 IS_UPLOADING = project.getGradle().startParameter.taskNames.any{it.contains('bintrayUpload')} DESCRIPTION = 'HockeySDK-Android implements support for using HockeyApp in your Android application. The following features are currently supported:\n' + '\n' + diff --git a/hockeysdk/build.gradle b/hockeysdk/build.gradle index 2b3ab412d..5991114dc 100644 --- a/hockeysdk/build.gradle +++ b/hockeysdk/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { minSdkVersion 15 - targetSdkVersion 26 + targetSdkVersion 27 versionCode VERSION_CODE versionName VERSION_NAME testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"