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

Commit 4daf056

Browse files
committed
Merge branch 'release/4.1.2'
2 parents 67b1f43 + f933267 commit 4daf056

13 files changed

+277
-34
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[![Build Status](https://travis-ci.org/bitstadium/HockeySDK-Android.svg?branch=develop)](https://travis-ci.org/bitstadium/HockeySDK-Android)
22
[![Slack Status](https://slack.hockeyapp.net/badge.svg)](https://slack.hockeyapp.net)
33

4-
## Version 4.1.1
4+
## Version 4.1.2
55

66
## Introduction
77

88
HockeySDK-Android implements support for using HockeyApp in your Android application.
99

1010
The following features are currently supported:
1111

12-
1. **Crash Reports:** If your app crashes, a crash log is written to the device's storage. If the user starts the app again, they will be asked asked to submit the crash report to HockeyApp. This works for both beta and live apps, i.e. those submitted to Google Play or other app stores. Crash logs contain viable information for you to help resolve the issue. Furthermore, you as a developer can add additional information to the report as well.
12+
1. **Crash Reports:** If your app crashes, a crash log is written to the device's storage. If the user starts the app again, they will be asked to submit the crash report to HockeyApp. This works for both beta and live apps, i.e. those submitted to Google Play or other app stores. Crash logs contain viable information for you to help resolve the issue. Furthermore, you as a developer can add additional information to the report as well.
1313

1414
2. **User Metrics:** Understand user behavior to improve your app. Track usage through daily and monthly active users, monitor crash impacted users, as well as customer engagement through session count. User Metrics requires a minimum API level of 14 (Android 4.x Ice Cream Sandwich).
1515

@@ -75,7 +75,7 @@ Please see the "[How to create a new app](http://support.hockeyapp.net/kb/about-
7575
Add the SDK to your app module's dependencies in Android Studio by adding the following line to your `dependencies { ... }` configuration:
7676

7777
```groovy
78-
compile 'net.hockeyapp.android:HockeySDK:4.1.1'
78+
compile 'net.hockeyapp.android:HockeySDK:4.1.2'
7979
```
8080

8181
<a id="integrate-sdk"></a>
@@ -231,7 +231,7 @@ This will add the ability for your users to provide feedback from right inside y
231231
```java
232232
import net.hockeyapp.android.FeedbackManager;
233233

234-
public class YourActivity extends Activitiy {
234+
public class YourActivity extends Activity {
235235

236236
@Override
237237
public void onCreate(Bundle savedInstanceState) {
@@ -314,7 +314,7 @@ If you don't want to use Gradle or Maven dependency management you can also down
314314
4. Configure your development tools to use the .aar/.jar file.
315315
5. In Android Studio, create a new module via `File > New > New Module`
316316
6. Select **Import .JAR/.AAR Package** and click **Next**.
317-
7. In the next menu select the .aar/.jar file you just copied to the libs folder. You can rename the module to whatever you want, but we in general recommend leaving it as is. If you don't rename the module, it will match the name of the .aar/.jar file, in this case **HockeySDK-4.1.1**. This way you'll quickly know which version of the SDK you are using in the future.
317+
7. In the next menu select the .aar/.jar file you just copied to the libs folder. You can rename the module to whatever you want, but we in general recommend leaving it as is. If you don't rename the module, it will match the name of the .aar/.jar file, in this case **HockeySDK-4.1.2**. This way you'll quickly know which version of the SDK you are using in the future.
318318
8. Make sure Android Studio added the necessary code to integrate the HockeySDK:
319319

320320
Head over to your app's `build.gradle` to verify the dependency was added correctly. It should look like this:
@@ -324,19 +324,19 @@ dependencies {
324324
//your other dependencies
325325
//...
326326
327-
compile project(':HockeySDK-4.1.1')
327+
compile project(':HockeySDK-4.1.2')
328328
}
329329
```
330330
Next, make sure your `settings.gradle` contains the new module:
331331

332332
```groovy
333-
include ':app', ':HockeySDK-4.1.1'
333+
include ':app', ':HockeySDK-4.1.2'
334334
```
335335

336336
Finally, check the `build.gradle` of the newly added module:
337337
```groovy
338338
configurations.maybeCreate("default")
339-
artifacts.add("default", file('HockeySDK-4.1.1.aar'))
339+
artifacts.add("default", file('HockeySDK-4.1.2.aar'))
340340
```
341341

342342
Once you have verified that everything necessary has been added, proceed with [SDK integration](#integrate-sdk).
@@ -527,7 +527,7 @@ However, if you provide a custom user interface fragment for the update distribu
527527
<a id="documentation"></a>
528528
## 5. Documentation
529529

530-
Our documentation can be found on [HockeyApp](http://hockeyapp.net/help/sdk/android/4.1.1/index.html).
530+
Our documentation can be found on [HockeyApp](http://hockeyapp.net/help/sdk/android/4.1.2/index.html).
531531

532532
<a id="troubleshooting"></a>
533533
## 6.Troubleshooting

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ allprojects {
3535

3636
ext {
3737
ARTIFACT_ID = 'HockeySDK'
38-
VERSION_NAME = '4.1.1'
38+
VERSION_NAME = '4.1.2'
3939
VERSION_CODE = 10
4040
SITE_URL = 'https://github.com/bitstadium/hockeysdk-android'
4141
GIT_URL = 'https://github.com/bitstadium/HockeySDK-Android.git'

hockeysdk/src/main/java/net/hockeyapp/android/FeedbackActivity.java

+27-9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public class FeedbackActivity extends Activity implements OnClickListener {
6767
*/
6868
public static final String EXTRA_URL = "url";
6969

70+
/**
71+
* Optional extra that can be passed as {@code true} to force a new feedback message thread.
72+
*/
73+
public static final String EXTRA_FORCE_NEW_THREAD = "forceNewThread";
74+
7075
/**
7176
* Extra for initial username to set for the feedback message.
7277
*/
@@ -165,6 +170,12 @@ public class FeedbackActivity extends Activity implements OnClickListener {
165170
**/
166171
private boolean mInSendFeedback;
167172

173+
/**
174+
* Indicates if a new thread should be created for each new feedback message as opposed to
175+
* the default resume thread behaviour.
176+
*/
177+
private boolean mForceNewThread;
178+
168179
/**
169180
* True when the view was initialized
170181
**/
@@ -193,6 +204,7 @@ public void onCreate(Bundle savedInstanceState) {
193204
Bundle extras = getIntent().getExtras();
194205
if (extras != null) {
195206
mUrl = extras.getString(EXTRA_URL);
207+
mForceNewThread = extras.getBoolean(EXTRA_FORCE_NEW_THREAD);
196208
initialUserName = extras.getString(EXTRA_INITIAL_USER_NAME);
197209
initialUserEmail = extras.getString(EXTRA_INITIAL_USER_EMAIL);
198210

@@ -316,8 +328,8 @@ public void onClick(View v) {
316328
openContextMenu(v);
317329
}
318330
} else if (viewId == R.id.button_add_response) {
319-
configureFeedbackView(false);
320331
mInSendFeedback = true;
332+
configureFeedbackView(false);
321333
} else if (viewId == R.id.button_refresh) {
322334
sendFetchFeedback(mUrl, null, null, null, null, null, PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext), mFeedbackHandler, true);
323335
}
@@ -494,7 +506,7 @@ protected void configureFeedbackView(boolean haveToken) {
494506
mNameInput.setText(nameEmailSubjectArray[0]);
495507
mEmailInput.setText(nameEmailSubjectArray[1]);
496508

497-
if (nameEmailSubjectArray.length >= 3) {
509+
if (!mForceNewThread && nameEmailSubjectArray.length >= 3) {
498510
mSubjectInput.setText(nameEmailSubjectArray[2]);
499511
mTextInput.requestFocus();
500512
} else {
@@ -518,11 +530,14 @@ protected void configureFeedbackView(boolean haveToken) {
518530
mFeedbackViewInitialized = true;
519531
}
520532

533+
mNameInput.setVisibility(FeedbackManager.getRequireUserName() == FeedbackUserDataElement.DONT_SHOW ? View.GONE : View.VISIBLE);
534+
mEmailInput.setVisibility(FeedbackManager.getRequireUserEmail() == FeedbackUserDataElement.DONT_SHOW ? View.GONE : View.VISIBLE);
535+
521536
/** Reset the remaining fields if previously populated */
522537
mTextInput.setText("");
523538

524-
/** Check to see if the Feedback Token is availabe */
525-
if (PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext) != null) {
539+
/** Check to see if the Feedback Token is available */
540+
if ((!mForceNewThread || mInSendFeedback) && PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext) != null) {
526541
/** If Feedback Token is available, hide the Subject Input field */
527542
mSubjectInput.setVisibility(View.GONE);
528543
} else {
@@ -583,8 +598,11 @@ private boolean addAttachment(int request) {
583598

584599
private void configureAppropriateView() {
585600
/** Try to retrieve the Feedback Token from {@link SharedPreferences} */
586-
mToken = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(this);
587-
if ((mToken == null) || (mInSendFeedback)) {
601+
if (!mForceNewThread || mInSendFeedback) {
602+
mToken = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(this);
603+
}
604+
605+
if (mToken == null || mInSendFeedback) {
588606
/** If Feedback Token is NULL, show the usual feedback view */
589607
configureFeedbackView(false);
590608
} else {
@@ -705,7 +723,7 @@ private void sendFeedback() {
705723
enableDisableSendFeedbackButton(false);
706724
hideKeyboard();
707725

708-
String token = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext);
726+
String token = mForceNewThread && !mInSendFeedback ? null : PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext);
709727

710728
String name = mNameInput.getText().toString().trim();
711729
String email = mEmailInput.getText().toString().trim();
@@ -791,10 +809,10 @@ public void handleMessage(Message msg) {
791809
String responseString = bundle.getString(SendFeedbackTask.BUNDLE_FEEDBACK_RESPONSE);
792810
String statusCode = bundle.getString(SendFeedbackTask.BUNDLE_FEEDBACK_STATUS);
793811
String requestType = bundle.getString(SendFeedbackTask.BUNDLE_REQUEST_TYPE);
794-
if ((requestType.equals("send") && ((responseString == null) || (Integer.parseInt(statusCode) != 201)))) {
812+
if ("send".equals(requestType) && (responseString == null || Integer.parseInt(statusCode) != 201)) {
795813
// Send feedback went wrong if response is empty or status code != 201
796814
error.setMessage(feedbackActivity.getString(R.string.hockeyapp_feedback_send_generic_error));
797-
} else if ((requestType.equals("fetch") && (statusCode != null) && ((Integer.parseInt(statusCode) == 404) || (Integer.parseInt(statusCode) == 422)))) {
815+
} else if ("fetch".equals(requestType) && statusCode != null && (Integer.parseInt(statusCode) == 404 || Integer.parseInt(statusCode) == 422)) {
798816
// Fetch feedback went wrong if status code is 404 or 422
799817
feedbackActivity.resetFeedbackView();
800818
success = true;

hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManager.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public class FeedbackManager {
8181
/**
8282
* Whether the user's name is required.
8383
*/
84-
private static FeedbackUserDataElement requireUserName;
84+
private static FeedbackUserDataElement requireUserName = FeedbackUserDataElement.REQUIRED;
8585

8686
/**
8787
* Whether the user's email is required.
8888
*/
89-
private static FeedbackUserDataElement requireUserEmail;
89+
private static FeedbackUserDataElement requireUserEmail = FeedbackUserDataElement.REQUIRED;
9090

9191
private static String userName;
9292

@@ -183,6 +183,7 @@ public static void showFeedbackActivity(Context context, Bundle extras, Uri... a
183183
if (activityClass == null) {
184184
activityClass = FeedbackActivity.class;
185185
}
186+
boolean forceNewThread = lastListener != null && lastListener.shouldCreateNewFeedbackThread();
186187

187188
Intent intent = new Intent();
188189
if (extras != null && !extras.isEmpty()) {
@@ -191,6 +192,7 @@ public static void showFeedbackActivity(Context context, Bundle extras, Uri... a
191192
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
192193
intent.setClass(context, activityClass);
193194
intent.putExtra(FeedbackActivity.EXTRA_URL, getURLString(context));
195+
intent.putExtra(FeedbackActivity.EXTRA_FORCE_NEW_THREAD, forceNewThread);
194196
intent.putExtra(FeedbackActivity.EXTRA_INITIAL_USER_NAME, userName);
195197
intent.putExtra(FeedbackActivity.EXTRA_INITIAL_USER_EMAIL, userEmail);
196198
intent.putExtra(FeedbackActivity.EXTRA_INITIAL_ATTACHMENTS, attachments);

hockeysdk/src/main/java/net/hockeyapp/android/FeedbackManagerListener.java

+8
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ public Class<? extends FeedbackActivity> getFeedbackActivityClass() {
2626
* and false if not and a notification should be fired.
2727
*/
2828
public abstract boolean feedbackAnswered(FeedbackMessage latestMessage);
29+
30+
/**
31+
* Called when posting a new feedback message.
32+
* @return Whether a new feedback thread should be created or not. Defaults to false.
33+
*/
34+
public boolean shouldCreateNewFeedbackThread() {
35+
return false;
36+
}
2937
}

hockeysdk/src/main/java/net/hockeyapp/android/metrics/Persistence.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,13 @@ protected boolean isFreeSpaceAvailable() {
269269
// TODO Check for available disk space as well.
270270
synchronized (LOCK) {
271271
Context context = getContext();
272-
if ((context.getFilesDir()) != null) {
272+
if (context.getFilesDir() != null) {
273273
File filesDir = context.getFilesDir();
274274
String path = filesDir.getAbsolutePath() + BIT_TELEMETRY_DIRECTORY;
275275
if (!TextUtils.isEmpty(path)) {
276276
File dir = new File(path);
277-
return (dir.listFiles().length < MAX_FILE_COUNT);
277+
File[] files = dir.listFiles();
278+
return files != null && files.length < MAX_FILE_COUNT;
278279
}
279280
}
280281
return false;

hockeysdk/src/main/java/net/hockeyapp/android/metrics/TelemetryContext.java

+19-6
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,16 @@ protected void updateScreenResolution() {
235235
Context.WINDOW_SERVICE);
236236
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
237237
Point size = new Point();
238-
wm.getDefaultDisplay().getRealSize(size);
239-
width = size.x;
240-
height = size.y;
238+
Display d = wm.getDefaultDisplay();
239+
if (d != null) {
240+
d.getRealSize(size);
241+
width = size.x;
242+
height = size.y;
243+
} else {
244+
width = 0;
245+
height = 0;
246+
}
247+
241248
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
242249
try {
243250
//We have to use undocumented API here. Android 4.0 introduced soft buttons for
@@ -250,9 +257,15 @@ protected void updateScreenResolution() {
250257
height = (Integer) mGetRawH.invoke(display);
251258
} catch (Exception ex) {
252259
Point size = new Point();
253-
wm.getDefaultDisplay().getSize(size);
254-
width = size.x;
255-
height = size.y;
260+
Display d = wm.getDefaultDisplay();
261+
if (d != null) {
262+
d.getRealSize(size);
263+
width = size.x;
264+
height = size.y;
265+
} else {
266+
width = 0;
267+
height = 0;
268+
}
256269
HockeyLog.debug(TAG, "Couldn't determine screen resolution: " + ex.toString());
257270
}
258271

hockeysdk/src/main/java/net/hockeyapp/android/tasks/CheckUpdateTaskWithUI.java

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ public void onClick(DialogInterface dialog, int which) {
9696
}
9797
});
9898

99+
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
100+
@Override
101+
public void onCancel(DialogInterface dialog) {
102+
cleanUp();
103+
if (null != listener) {
104+
listener.onCancel();
105+
}
106+
}
107+
});
108+
99109
builder.setPositiveButton(R.string.hockeyapp_update_dialog_positive_button, new DialogInterface.OnClickListener() {
100110
public void onClick(DialogInterface dialog, int which) {
101111
if (getCachingEnabled()) {

hockeysdk/src/main/java/net/hockeyapp/android/utils/Util.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private static Bundle getBundle(Context context) {
264264
}
265265

266266
public static boolean isConnectedToNetwork(Context context) {
267-
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
267+
ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
268268
if (connectivityManager != null) {
269269
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
270270
return activeNetwork != null && activeNetwork.isConnected();

hockeysdk/src/main/res/layout-land/hockeyapp_activity_update.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@
5353

5454
<Button
5555
android:id="@+id/button_update"
56-
android:layout_width="120dp"
56+
android:layout_width="wrap_content"
5757
android:layout_height="wrap_content"
5858
android:layout_alignParentLeft="true"
5959
android:layout_below="@id/label_version"
6060
android:layout_margin="20dp"
6161
android:background="@drawable/hockeyapp_btn_background"
62+
android:minWidth="120dp"
6263
android:text="@string/hockeyapp_update_button"
6364
android:textColor="@color/hockeyapp_text_white"
64-
android:textSize="16sp" />
65+
android:textSize="16sp"/>
6566

6667

6768
</RelativeLayout>

hockeysdk/src/main/res/layout/hockeyapp_activity_update.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@
5656

5757
<Button
5858
android:id="@+id/button_update"
59-
android:layout_width="120dp"
59+
android:layout_width="wrap_content"
6060
android:layout_height="wrap_content"
6161
android:layout_alignParentLeft="true"
6262
android:layout_below="@id/label_version"
6363
android:layout_margin="20dp"
6464
android:background="@drawable/hockeyapp_btn_background"
65+
android:minWidth="120dp"
6566
android:paddingBottom="10dp"
6667
android:paddingLeft="20dp"
6768
android:paddingRight="20dp"
6869
android:paddingTop="10dp"
6970
android:text="@string/hockeyapp_update_button"
7071
android:textColor="@color/hockeyapp_text_white"
71-
android:textSize="16sp" />
72+
android:textSize="16sp"/>
7273

7374
</RelativeLayout>
7475

0 commit comments

Comments
 (0)