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

Commit

Permalink
Merge branch 'release/4.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaswenz committed Dec 8, 2016
2 parents 67b1f43 + f933267 commit 4daf056
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 34 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[![Build Status](https://travis-ci.org/bitstadium/HockeySDK-Android.svg?branch=develop)](https://travis-ci.org/bitstadium/HockeySDK-Android)
[![Slack Status](https://slack.hockeyapp.net/badge.svg)](https://slack.hockeyapp.net)

## Version 4.1.1
## Version 4.1.2

## Introduction

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

The following features are currently supported:

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.
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.

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).

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

```groovy
compile 'net.hockeyapp.android:HockeySDK:4.1.1'
compile 'net.hockeyapp.android:HockeySDK:4.1.2'
```

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

public class YourActivity extends Activitiy {
public class YourActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -314,7 +314,7 @@ If you don't want to use Gradle or Maven dependency management you can also down
4. Configure your development tools to use the .aar/.jar file.
5. In Android Studio, create a new module via `File > New > New Module`
6. Select **Import .JAR/.AAR Package** and click **Next**.
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.
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.
8. Make sure Android Studio added the necessary code to integrate the HockeySDK:

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

```groovy
include ':app', ':HockeySDK-4.1.1'
include ':app', ':HockeySDK-4.1.2'
```

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

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

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

<a id="troubleshooting"></a>
## 6.Troubleshooting
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {

ext {
ARTIFACT_ID = 'HockeySDK'
VERSION_NAME = '4.1.1'
VERSION_NAME = '4.1.2'
VERSION_CODE = 10
SITE_URL = 'https://github.com/bitstadium/hockeysdk-android'
GIT_URL = 'https://github.com/bitstadium/HockeySDK-Android.git'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public class FeedbackActivity extends Activity implements OnClickListener {
*/
public static final String EXTRA_URL = "url";

/**
* Optional extra that can be passed as {@code true} to force a new feedback message thread.
*/
public static final String EXTRA_FORCE_NEW_THREAD = "forceNewThread";

/**
* Extra for initial username to set for the feedback message.
*/
Expand Down Expand Up @@ -165,6 +170,12 @@ public class FeedbackActivity extends Activity implements OnClickListener {
**/
private boolean mInSendFeedback;

/**
* Indicates if a new thread should be created for each new feedback message as opposed to
* the default resume thread behaviour.
*/
private boolean mForceNewThread;

/**
* True when the view was initialized
**/
Expand Down Expand Up @@ -193,6 +204,7 @@ public void onCreate(Bundle savedInstanceState) {
Bundle extras = getIntent().getExtras();
if (extras != null) {
mUrl = extras.getString(EXTRA_URL);
mForceNewThread = extras.getBoolean(EXTRA_FORCE_NEW_THREAD);
initialUserName = extras.getString(EXTRA_INITIAL_USER_NAME);
initialUserEmail = extras.getString(EXTRA_INITIAL_USER_EMAIL);

Expand Down Expand Up @@ -316,8 +328,8 @@ public void onClick(View v) {
openContextMenu(v);
}
} else if (viewId == R.id.button_add_response) {
configureFeedbackView(false);
mInSendFeedback = true;
configureFeedbackView(false);
} else if (viewId == R.id.button_refresh) {
sendFetchFeedback(mUrl, null, null, null, null, null, PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext), mFeedbackHandler, true);
}
Expand Down Expand Up @@ -494,7 +506,7 @@ protected void configureFeedbackView(boolean haveToken) {
mNameInput.setText(nameEmailSubjectArray[0]);
mEmailInput.setText(nameEmailSubjectArray[1]);

if (nameEmailSubjectArray.length >= 3) {
if (!mForceNewThread && nameEmailSubjectArray.length >= 3) {
mSubjectInput.setText(nameEmailSubjectArray[2]);
mTextInput.requestFocus();
} else {
Expand All @@ -518,11 +530,14 @@ protected void configureFeedbackView(boolean haveToken) {
mFeedbackViewInitialized = true;
}

mNameInput.setVisibility(FeedbackManager.getRequireUserName() == FeedbackUserDataElement.DONT_SHOW ? View.GONE : View.VISIBLE);
mEmailInput.setVisibility(FeedbackManager.getRequireUserEmail() == FeedbackUserDataElement.DONT_SHOW ? View.GONE : View.VISIBLE);

/** Reset the remaining fields if previously populated */
mTextInput.setText("");

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

private void configureAppropriateView() {
/** Try to retrieve the Feedback Token from {@link SharedPreferences} */
mToken = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(this);
if ((mToken == null) || (mInSendFeedback)) {
if (!mForceNewThread || mInSendFeedback) {
mToken = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(this);
}

if (mToken == null || mInSendFeedback) {
/** If Feedback Token is NULL, show the usual feedback view */
configureFeedbackView(false);
} else {
Expand Down Expand Up @@ -705,7 +723,7 @@ private void sendFeedback() {
enableDisableSendFeedbackButton(false);
hideKeyboard();

String token = PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext);
String token = mForceNewThread && !mInSendFeedback ? null : PrefsUtil.getInstance().getFeedbackTokenFromPrefs(mContext);

String name = mNameInput.getText().toString().trim();
String email = mEmailInput.getText().toString().trim();
Expand Down Expand Up @@ -791,10 +809,10 @@ public void handleMessage(Message msg) {
String responseString = bundle.getString(SendFeedbackTask.BUNDLE_FEEDBACK_RESPONSE);
String statusCode = bundle.getString(SendFeedbackTask.BUNDLE_FEEDBACK_STATUS);
String requestType = bundle.getString(SendFeedbackTask.BUNDLE_REQUEST_TYPE);
if ((requestType.equals("send") && ((responseString == null) || (Integer.parseInt(statusCode) != 201)))) {
if ("send".equals(requestType) && (responseString == null || Integer.parseInt(statusCode) != 201)) {
// Send feedback went wrong if response is empty or status code != 201
error.setMessage(feedbackActivity.getString(R.string.hockeyapp_feedback_send_generic_error));
} else if ((requestType.equals("fetch") && (statusCode != null) && ((Integer.parseInt(statusCode) == 404) || (Integer.parseInt(statusCode) == 422)))) {
} else if ("fetch".equals(requestType) && statusCode != null && (Integer.parseInt(statusCode) == 404 || Integer.parseInt(statusCode) == 422)) {
// Fetch feedback went wrong if status code is 404 or 422
feedbackActivity.resetFeedbackView();
success = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public class FeedbackManager {
/**
* Whether the user's name is required.
*/
private static FeedbackUserDataElement requireUserName;
private static FeedbackUserDataElement requireUserName = FeedbackUserDataElement.REQUIRED;

/**
* Whether the user's email is required.
*/
private static FeedbackUserDataElement requireUserEmail;
private static FeedbackUserDataElement requireUserEmail = FeedbackUserDataElement.REQUIRED;

private static String userName;

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

Intent intent = new Intent();
if (extras != null && !extras.isEmpty()) {
Expand All @@ -191,6 +192,7 @@ public static void showFeedbackActivity(Context context, Bundle extras, Uri... a
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(context, activityClass);
intent.putExtra(FeedbackActivity.EXTRA_URL, getURLString(context));
intent.putExtra(FeedbackActivity.EXTRA_FORCE_NEW_THREAD, forceNewThread);
intent.putExtra(FeedbackActivity.EXTRA_INITIAL_USER_NAME, userName);
intent.putExtra(FeedbackActivity.EXTRA_INITIAL_USER_EMAIL, userEmail);
intent.putExtra(FeedbackActivity.EXTRA_INITIAL_ATTACHMENTS, attachments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ public Class<? extends FeedbackActivity> getFeedbackActivityClass() {
* and false if not and a notification should be fired.
*/
public abstract boolean feedbackAnswered(FeedbackMessage latestMessage);

/**
* Called when posting a new feedback message.
* @return Whether a new feedback thread should be created or not. Defaults to false.
*/
public boolean shouldCreateNewFeedbackThread() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,13 @@ protected boolean isFreeSpaceAvailable() {
// TODO Check for available disk space as well.
synchronized (LOCK) {
Context context = getContext();
if ((context.getFilesDir()) != null) {
if (context.getFilesDir() != null) {
File filesDir = context.getFilesDir();
String path = filesDir.getAbsolutePath() + BIT_TELEMETRY_DIRECTORY;
if (!TextUtils.isEmpty(path)) {
File dir = new File(path);
return (dir.listFiles().length < MAX_FILE_COUNT);
File[] files = dir.listFiles();
return files != null && files.length < MAX_FILE_COUNT;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,16 @@ protected void updateScreenResolution() {
Context.WINDOW_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Point size = new Point();
wm.getDefaultDisplay().getRealSize(size);
width = size.x;
height = size.y;
Display d = wm.getDefaultDisplay();
if (d != null) {
d.getRealSize(size);
width = size.x;
height = size.y;
} else {
width = 0;
height = 0;
}

} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
try {
//We have to use undocumented API here. Android 4.0 introduced soft buttons for
Expand All @@ -250,9 +257,15 @@ protected void updateScreenResolution() {
height = (Integer) mGetRawH.invoke(display);
} catch (Exception ex) {
Point size = new Point();
wm.getDefaultDisplay().getSize(size);
width = size.x;
height = size.y;
Display d = wm.getDefaultDisplay();
if (d != null) {
d.getRealSize(size);
width = size.x;
height = size.y;
} else {
width = 0;
height = 0;
}
HockeyLog.debug(TAG, "Couldn't determine screen resolution: " + ex.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ public void onClick(DialogInterface dialog, int which) {
}
});

builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
cleanUp();
if (null != listener) {
listener.onCancel();
}
}
});

builder.setPositiveButton(R.string.hockeyapp_update_dialog_positive_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (getCachingEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private static Bundle getBundle(Context context) {
}

public static boolean isConnectedToNetwork(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnected();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@

<Button
android:id="@+id/button_update"
android:layout_width="120dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/label_version"
android:layout_margin="20dp"
android:background="@drawable/hockeyapp_btn_background"
android:minWidth="120dp"
android:text="@string/hockeyapp_update_button"
android:textColor="@color/hockeyapp_text_white"
android:textSize="16sp" />
android:textSize="16sp"/>


</RelativeLayout>
Expand Down
5 changes: 3 additions & 2 deletions hockeysdk/src/main/res/layout/hockeyapp_activity_update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,20 @@

<Button
android:id="@+id/button_update"
android:layout_width="120dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/label_version"
android:layout_margin="20dp"
android:background="@drawable/hockeyapp_btn_background"
android:minWidth="120dp"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:text="@string/hockeyapp_update_button"
android:textColor="@color/hockeyapp_text_white"
android:textSize="16sp" />
android:textSize="16sp"/>

</RelativeLayout>

Expand Down
Loading

0 comments on commit 4daf056

Please sign in to comment.