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 #254 from bitstadium/release/4.1.5
Browse files Browse the repository at this point in the history
Release/4.1.5
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Jun 23, 2017
2 parents 54f5b05 + 0c41978 commit f360ba5
Show file tree
Hide file tree
Showing 31 changed files with 450 additions and 739 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ android:
components:
# Use the latest platform tools
- tools
- tools
- platform-tools

# Use the desired build tools
- build-tools-25.0.3
- build-tools-26.0.0

# Project target SDK
- android-25
- android-26

# Project extra configuration
- extra-google-m2repository
Expand All @@ -38,4 +37,4 @@ before_script:
- adb shell input keyevent 82 &

script:
- ./gradlew clean build connectedAndroidTest
- ./gradlew clean build connectedAndroidTest
555 changes: 19 additions & 536 deletions README.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
Expand Down Expand Up @@ -35,14 +35,14 @@ allprojects {

ext {
ARTIFACT_ID = 'HockeySDK'
VERSION_NAME = '4.1.4'
VERSION_CODE = 11
VERSION_NAME = '4.1.5'
VERSION_CODE = 12
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 = 25
BUILD_TOOLS = '25.0.3'
COMPILE_SDK = 26
BUILD_TOOLS = '26.0.0'
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
3 changes: 2 additions & 1 deletion hockeysdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {

defaultConfig {
minSdkVersion 9
targetSdkVersion 25
targetSdkVersion 26
versionCode VERSION_CODE
versionName VERSION_NAME
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -22,6 +22,7 @@ android {
}
lintOptions {
disable 'GoogleAppIndexingWarning'
textReport true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void testInstanceInitialisation() {
@Test
public void testLoggingItemAddsToQueue() {
Data<Domain> data = new Data<Domain>();
Channel.mMaxBatchCount = 3;
Assert.assertEquals(0, sut.mQueue.size());

sut.enqueueData(data);
Expand All @@ -85,14 +84,12 @@ public void testLoggingItemAddsToQueue() {

@Test
public void testQueueFlushesWhenMaxBatchCountReached() {
PublicChannel.mMaxBatchCount = 3;
Assert.assertEquals(0, sut.mQueue.size());

sut.enqueueData(new Data<Domain>());
Assert.assertEquals(1, sut.mQueue.size());

sut.enqueueData(new Data<Domain>());
Assert.assertEquals(2, sut.mQueue.size());
for (int i = 1; i < Channel.getMaxBatchCount(); i++) {
sut.enqueueData(new Data<Domain>());
Assert.assertEquals(i, sut.mQueue.size());
}

sut.enqueueData(new Data<Domain>());
Assert.assertEquals(0, sut.mQueue.size());
Expand Down
98 changes: 86 additions & 12 deletions hockeysdk/src/main/java/net/hockeyapp/android/FeedbackActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Parcelable;
import android.text.TextUtils;
Expand All @@ -26,6 +27,7 @@
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
Expand All @@ -47,19 +49,24 @@
import net.hockeyapp.android.views.AttachmentView;

import java.lang.ref.WeakReference;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;

import static java.text.DateFormat.SHORT;

/**
* <h3>Description</h3>
*
* Activity to show the feedback form.
**/
public class FeedbackActivity extends Activity implements OnClickListener {
public class FeedbackActivity extends Activity implements OnClickListener, View.OnFocusChangeListener {

/**
* The URL of the feedback endpoint for this app.
Expand Down Expand Up @@ -230,9 +237,22 @@ public void onCreate(Bundle savedInstanceState) {

initFeedbackHandler();
initParseFeedbackHandler();
restoreSendFeedbackTask();
configureAppropriateView();
}

private void restoreSendFeedbackTask() {
Object object = getLastNonConfigurationInstance();
if (object != null && object instanceof SendFeedbackTask) {
mSendFeedbackTask = (SendFeedbackTask) object;
/**
* We are restoring mSendFeedbackTask object and we need to replace old handler
* with newly created, so that task could send messages to right handler.
*/
mSendFeedbackTask.setHandler(mFeedbackHandler);
}
}

/**
* Restore all attachments.
*/
Expand Down Expand Up @@ -267,10 +287,17 @@ protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}

@Override
protected void onStart() {
super.onStart();
if (mSendFeedbackTask != null){
mSendFeedbackTask.attach(this);
}
}

@Override
protected void onStop() {
super.onStop();

if (mSendFeedbackTask != null) {
mSendFeedbackTask.detach();
}
Expand Down Expand Up @@ -321,8 +348,7 @@ public void onClick(View v) {
} else if (viewId == R.id.button_attachment) {
ViewGroup attachments = (ViewGroup) findViewById(R.id.wrapper_attachments);
if (attachments.getChildCount() >= MAX_ATTACHMENTS_PER_MSG) {
//TODO should we add some more text here?
Toast.makeText(this, String.valueOf(MAX_ATTACHMENTS_PER_MSG), Toast.LENGTH_SHORT).show();
Toast.makeText(this, String.format(getString(R.string.hockeyapp_feedback_max_attachments_allowed), MAX_ATTACHMENTS_PER_MSG), Toast.LENGTH_SHORT).show();
} else {
openContextMenu(v);
}
Expand All @@ -334,6 +360,18 @@ public void onClick(View v) {
}
}

@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (v instanceof EditText) {
showKeyboard(v);
}
else if (v instanceof Button || v instanceof ImageButton) {
hideKeyboard();
}
}
}

/**
* Called when context menu is needed (on add attachment button).
*/
Expand Down Expand Up @@ -415,6 +453,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (uri != null) {
final ViewGroup attachments = (ViewGroup) findViewById(R.id.wrapper_attachments);
attachments.addView(new AttachmentView(this, attachments, uri, true));
Util.announceForAccessibility(attachments, getString(R.string.hockeyapp_feedback_attachment_added));
}

} else if (requestCode == ATTACH_PICTURE) {
Expand All @@ -440,9 +479,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (uri != null) {
final ViewGroup attachments = (ViewGroup) findViewById(R.id.wrapper_attachments);
attachments.addView(new AttachmentView(this, attachments, uri, true));
Util.announceForAccessibility(attachments, getString(R.string.hockeyapp_feedback_attachment_added));
}

} else return;
}
}

@SuppressLint("InflateParams")
Expand Down Expand Up @@ -482,18 +522,24 @@ protected void configureFeedbackView(boolean haveToken) {

mAddResponseButton = (Button) findViewById(R.id.button_add_response);
mAddResponseButton.setOnClickListener(this);
mAddResponseButton.setOnFocusChangeListener(this);

mRefreshButton = (Button) findViewById(R.id.button_refresh);
mRefreshButton.setOnClickListener(this);
mRefreshButton.setOnFocusChangeListener(this);
} else {
/** if the token doesn't exist, the feedback details inputs to be sent need to be displayed */
mWrapperLayoutFeedbackAndMessages.setVisibility(View.GONE);
mFeedbackScrollview.setVisibility(View.VISIBLE);

mNameInput = (EditText) findViewById(R.id.input_name);
mNameInput.setOnFocusChangeListener(this);
mEmailInput = (EditText) findViewById(R.id.input_email);
mEmailInput.setOnFocusChangeListener(this);
mSubjectInput = (EditText) findViewById(R.id.input_subject);
mSubjectInput.setOnFocusChangeListener(this);
mTextInput = (EditText) findViewById(R.id.input_message);
mTextInput.setOnFocusChangeListener(this);

configureHints();

Expand Down Expand Up @@ -559,10 +605,12 @@ protected void configureFeedbackView(boolean haveToken) {
/** Use of context menu needs to be enabled explicitly */
mAddAttachmentButton = (Button) findViewById(R.id.button_attachment);
mAddAttachmentButton.setOnClickListener(this);
mAddAttachmentButton.setOnFocusChangeListener(this);
registerForContextMenu(mAddAttachmentButton);

mSendFeedbackButton = (Button) findViewById(R.id.button_send);
mSendFeedbackButton.setOnClickListener(this);
mAddAttachmentButton.setOnFocusChangeListener(this);
}
}

Expand Down Expand Up @@ -633,6 +681,11 @@ private void createParseFeedbackTask(String feedbackResponseString, String reque
mParseFeedbackTask = new ParseFeedbackTask(this, feedbackResponseString, mParseFeedbackHandler, requestType);
}

private void showKeyboard(View view) {
InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
manager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}

private void hideKeyboard() {
if (mTextInput != null) {
InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
Expand Down Expand Up @@ -667,9 +720,6 @@ private void loadFeedbackMessages(final FeedbackResponse feedbackResponse) {
public void run() {
configureFeedbackView(true);

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
SimpleDateFormat formatNew = new SimpleDateFormat("d MMM h:mm a");

Date date = null;
if (feedbackResponse != null && feedbackResponse.getFeedback() != null &&
feedbackResponse.getFeedback().getMessages() != null && feedbackResponse.
Expand All @@ -681,8 +731,15 @@ public void run() {

/** Set the lastUpdatedTextView text as the date of the latest feedback message */
try {
date = format.parse(mFeedbackMessages.get(0).getCreatedAt());
mLastUpdatedTextView.setText(String.format(getString(R.string.hockeyapp_feedback_last_updated_text), formatNew.format(date)));
/** An ISO 8601 format */
DateFormat dateFormatIn = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
dateFormatIn.setTimeZone(TimeZone.getTimeZone("UTC"));

/** Localized short format */
DateFormat dateFormatOut = DateFormat.getDateTimeInstance(SHORT, SHORT);

date = dateFormatIn.parse(mFeedbackMessages.get(0).getCreatedAt());
mLastUpdatedTextView.setText(String.format(getString(R.string.hockeyapp_feedback_last_updated_text), dateFormatOut.format(date)));
mLastUpdatedTextView.setContentDescription(mLastUpdatedTextView.getText());
mLastUpdatedTextView.setVisibility(View.VISIBLE);
} catch (ParseException e1) {
Expand Down Expand Up @@ -734,7 +791,6 @@ private void sendFeedback() {
}

enableDisableSendFeedbackButton(false);
hideKeyboard();

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

Expand Down Expand Up @@ -764,11 +820,21 @@ private void sendFeedback() {

/** Start the Send Feedback {@link AsyncTask} */
sendFetchFeedback(mUrl, name, email, subject, text, attachmentUris, token, mFeedbackHandler, false);

hideKeyboard();
}
}

private void setError(EditText inputField, int feedbackStringId) {
private void setError(final EditText inputField, int feedbackStringId) {
inputField.setError(getString(feedbackStringId));

// requestFocus and showKeyboard on next frame to read error message via talkback
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
inputField.requestFocus();
}
});
enableDisableSendFeedbackButton(true);
}

Expand Down Expand Up @@ -831,6 +897,14 @@ public void handleMessage(Message msg) {
success = true;
} else if (responseString != null) {
feedbackActivity.startParseFeedbackTask(responseString, requestType);
if ("send".equals(requestType)) {
feedbackActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(feedbackActivity, R.string.hockeyapp_feedback_sent_toast, Toast.LENGTH_LONG).show();
}
});
}
success = true;
} else {
error.setMessage(feedbackActivity.getString(R.string.hockeyapp_feedback_send_network_error));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
intent.putExtra(LoginManager.LOGIN_EXIT_KEY, true);
startActivity(intent);
}
return true;
}
return true;
}

return super.onKeyDown(keyCode, event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.widget.Toast;

import net.hockeyapp.android.utils.HockeyLog;
import net.hockeyapp.android.utils.ImageUtils;
import net.hockeyapp.android.views.PaintView;

import java.io.File;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void onCreate(Bundle savedInstanceState) {
int currentOrientation = displayWidth > displayHeight ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE :
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;

int desiredOrientation = PaintView.determineOrientation(getContentResolver(), imageUri);
int desiredOrientation = ImageUtils.determineOrientation(this, imageUri);
//noinspection ResourceType
setRequestedOrientation(desiredOrientation);

Expand Down
Loading

0 comments on commit f360ba5

Please sign in to comment.