Skip to content

Commit

Permalink
Merge pull request #77 from ibm-bluemix-mobile-services/inapp2
Browse files Browse the repository at this point in the history
Fix setUserIdentity issue and Change TextInputLayout to TextEdit
  • Loading branch information
mohlogan committed Mar 20, 2018
2 parents 691aebc + 19a1ae5 commit 21933f3
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 22 deletions.
3 changes: 1 addition & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply from: 'jacoco.gradle'

ext {
ANALYTICS_VERSION_VAR_NAME = 'BMS_ANALYTICS_SDK_VERSION'
ANALYTICS_SDK_VERSION = '1.2.7-SNAPSHOT'
ANALYTICS_SDK_VERSION = '1.2.8-SNAPSHOT'

}

Expand Down Expand Up @@ -68,7 +68,6 @@ dependencies {
testCompile 'com.squareup.okhttp3:mockwebserver:3.9.0'
testCompile 'org.json:json:20160810'
provided 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.android.support:design:24.0.0'
}

task createPropertiesFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,22 @@ private static void setUserIdentity(final String user, boolean isInitialCtx) {
logger.debug("JSONException encountered logging change in user context: " + e.getMessage());
}

MFPInAppFeedBackListner.setUserIdentity(hashedUserID);
MFPInAppFeedBackListner.setUserIdentity(user);
log(metadata);
}

/**
* Invoke feedback mode
*/
public static void triggerFeedbackMode(){
MFPInAppFeedBackListner.triggerFeedbackMode(currentActivity);
BMSAnalytics.triggerFeedbackMode(currentActivity);
}

/**
* Invoke feedback mode
*/
public static void triggerFeedbackMode(Activity userActivity){
MFPInAppFeedBackListner.triggerFeedbackMode(userActivity);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
Expand Down Expand Up @@ -43,6 +47,7 @@ public class EditFeedback extends Activity{
private ImageButton commentButton;
private EditText editText;
private TextView commentTextLable;
private TextView countTextLable;
private View editGroup;

private Bitmap bitmapMaster;
Expand All @@ -67,6 +72,11 @@ public class EditFeedback extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.edit_feedback);

Button sendButton;
Expand All @@ -87,6 +97,7 @@ protected void onCreate(Bundle savedInstanceState) {
commentButton = (ImageButton) findViewById(R.id.commentButton);
editText = (EditText) findViewById(R.id.edit_text);
commentTextLable = (TextView) findViewById(R.id.comment_text);
countTextLable = (TextView) findViewById(R.id.count_text);
editGroup = findViewById(R.id.textLayout);

editGroup.setVisibility(View.GONE);
Expand All @@ -97,7 +108,6 @@ protected void onCreate(Bundle savedInstanceState) {
int width = dm.widthPixels;
int height = dm.heightPixels;

//getWindow().setLayout((int)(width*0.9),(int)(height*0.9));
getWindow().setLayout(width,height);

imageView.getLayoutParams().height = (int)(getWindowManager().getDefaultDisplay().getHeight() * 0.90);
Expand All @@ -119,6 +129,8 @@ protected void onCreate(Bundle savedInstanceState) {
paintBlur.setColor(Color.parseColor("#7998a8"));
paintBlur.setStrokeWidth(50);

editText.setHorizontallyScrolling(false);
editText.setMaxLines(Integer.MAX_VALUE);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener(){
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Expand All @@ -137,6 +149,41 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
}
});

editText.addTextChangedListener(new TextWatcher(){
/**
* Intentionally method not implemented since nothing to implement
* @param s
* @param start
* @param before
* @param count
*/
@Override
public void onTextChanged(CharSequence s, int start, int before, int count){
//Nothing to implement
}

/**
* Intentionally method not implemented since nothing to implement
* @param s
* @param start
* @param count
* @param aft
*/
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int aft){
//Nothing to implement
}

/**
* Method adds character count
* @param text
*/
@Override
public void afterTextChanged(Editable text){
countTextLable.setText(""+text.toString().length() + "/120" );
}
});

sendButton = (Button) findViewById(R.id.sendButton);
sendButton.setText("Send");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.util.Log;
import android.view.View;

public class MFPInAppFeedBackListner {

private static Activity currentActivity = null;

protected static final String LOG_TAG_NAME = MFPInAppFeedBackListner.class.getName();
private static Context context = null;
private static String userIdentity = "undefined";

Expand All @@ -34,9 +36,15 @@ public static Context getContext(){

public static void triggerFeedbackMode(final Activity activity){

if(null != MFPInAppFeedBackListner.context) {
if(null != MFPInAppFeedBackListner.context && null != activity) {
currentActivity = activity;
callFeedbackEditScreenActivity();
}else {
if(null == MFPInAppFeedBackListner.context ) {
Log.d(LOG_TAG_NAME, "Failed to invoke feedback mode since application Context is null. Please initialise Analytics to invoke Feedback mode.");
}else {
Log.d(LOG_TAG_NAME, "Failed to invoke feedback mode since current activity object is not available.");
}
}
}

Expand Down
39 changes: 25 additions & 14 deletions lib/src/main/res/layout/edit_feedback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<RelativeLayout
android:id="@+id/textLayout"
android:layout_width="match_parent"
android:layout_height="150sp"
android:layout_height="250sp"
android:layout_above="@id/imageLayout"
android:background="#FFFFFF"
>
Expand All @@ -85,23 +85,34 @@
android:id="@+id/comment_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="@android:color/black"
android:text="COMMENT"
/>

<android.support.design.widget.TextInputLayout
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="120">
android:hint="Add Your Feedback"
android:textColorHint="#B0BEC5"
android:inputType="text"
android:imeOptions="actionGo"
android:maxLength="120"
android:paddingLeft="8dp"
android:paddingRight="6dp"
android:layout_below="@id/comment_text"
android:textColor="@android:color/black" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="120"
android:inputType="text"
android:imeOptions="actionGo"
android:id="@+id/edit_text"
android:layout_below="@id/comment_text"
/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/count_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:textColor="@android:color/black"
android:text="0/120"
android:layout_below="@id/edit_text"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
</RelativeLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public void testSetUserIdentity() throws Exception{
public void testTriggerFeedbackMode() throws Exception{
try{
MFPInAppFeedBackListner.triggerFeedbackMode(null);
fail();
}catch(Exception e){

fail();
}
}

Expand Down

0 comments on commit 21933f3

Please sign in to comment.