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 #346 from bitstadium/release/5.1.0
Browse files Browse the repository at this point in the history
Version 5.1.0
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Jan 11, 2018
2 parents db4c38a + 80ffb93 commit c56d057
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down Expand Up @@ -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' +
Expand Down
4 changes: 2 additions & 2 deletions hockeysdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
targetSdkVersion 27
versionCode VERSION_CODE
versionName VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -18,7 +18,7 @@ android {
}
}
lintOptions {
disable 'GoogleAppIndexingWarning'
disable 'GoogleAppIndexingWarning','RtlEnabled'
textReport true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
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 android:supportsRtl="true">
<application>

<activity android:name=".UpdateActivity" />
<activity android:name=".FeedbackActivity" android:windowSoftInputMode="adjustResize|stateVisible" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
**/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -764,7 +775,7 @@ protected Object doInBackground(Void... voids) {
List<Uri> 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();
}
Expand Down Expand Up @@ -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<Uri> 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<Uri> attachmentUris, String token, Handler feedbackHandler, boolean isFetchMessages) {
mSendFeedbackTask = new SendFeedbackTask(mContext, url, name, email, subject, text, userId, attachmentUris, token, feedbackHandler, isFetchMessages);
AsyncTaskUtils.execute(mSendFeedbackTask);
}

Expand Down
35 changes: 28 additions & 7 deletions hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -108,6 +106,8 @@ public class FeedbackManager {

private static String userEmail;

private static String userId;

/**
* Last listener instance.
*/
Expand Down Expand Up @@ -201,6 +201,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();
Expand All @@ -214,7 +218,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);
Expand All @@ -237,6 +241,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;
}

Expand Down Expand Up @@ -285,6 +290,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;
Expand All @@ -293,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, token, null, true) {
SendFeedbackTask sendFeedbackTask = new SendFeedbackTask(context, getURLString(), null, null, null, null, null, null, token, null, true) {

@Override
protected void onPostExecute(HashMap<String, String> result) {
Expand All @@ -302,7 +311,7 @@ protected void onPostExecute(HashMap<String, String> 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);
}
}
Expand All @@ -324,10 +333,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/";
}

Expand Down Expand Up @@ -385,6 +397,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,40 @@ private static Data<Domain> 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<String, String> 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<String, String> properties, final Map<String, Double> measurements) {
if (TextUtils.isEmpty(eventName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class SendFeedbackTask extends ConnectionTask<Void, Void, HashMap<String,
private String mEmail;
private String mSubject;
private String mText;
private String mUserId;
private List<Uri> mAttachmentUris;
private String mToken;
private boolean mIsFetchMessages;
Expand Down Expand Up @@ -76,7 +77,7 @@ public class SendFeedbackTask extends ConnectionTask<Void, Void, HashMap<String,
* feedback message
*/
public SendFeedbackTask(Context context, String urlString, String name, String email,
String subject,String text, List<Uri> attachmentUris, String token,
String subject,String text, String userId, List<Uri> attachmentUris, String token,
Handler handler, boolean isFetchMessages) {

this.mContext = context;
Expand All @@ -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;
Expand Down Expand Up @@ -242,6 +244,9 @@ private HashMap<String, String> 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 + "/";
Expand Down Expand Up @@ -290,7 +295,9 @@ private HashMap<String, String> 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 + "/";
}
Expand Down

0 comments on commit c56d057

Please sign in to comment.