added modal asking for user data for bug/feedback report

This commit is contained in:
Marcin Jedynski 2018-11-12 00:51:35 +01:00
parent 1323c02b30
commit c9b4548f45
3 changed files with 114 additions and 11 deletions

View File

@ -4,6 +4,7 @@ import android.Manifest;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
@ -17,16 +18,26 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.annimon.stream.Stream;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
import com.uam.wmi.findmytutor.utils.ActiveFragment;
import com.uam.wmi.findmytutor.utils.PrefUtils;
@ -35,6 +46,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
@ -103,11 +118,9 @@ public abstract class BaseActivity
startActivity(i);
finish();
} else if (itemName.equals(getResources().getString(R.string.navigation_item_feedback))) {
sendFeedback(getApplicationContext());
showNoteDialog(BaseActivity.this, R.string.email_subject_feedback);
} else if (itemName.equals(getResources().getString(R.string.navigation_item_bug))) {
showNoteDialog(BaseActivity.this, R.string.email_subject_bug);
}
sideDrawer.closeDrawers();
@ -362,22 +375,68 @@ public abstract class BaseActivity
* Appends the necessary device information to email body
* useful when providing support
*/
static public void sendFeedback(Context context) {
private void sendFeedback(Context context, int subject, String mode) {
String appVersion = null;
String body = null;
try {
body = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
appVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
if( mode == "full"){
body = "\n\n-----------------------------\nPlease don't remove this information\n Device OS: Android \n Device OS version: " +
Build.VERSION.RELEASE + "\n App Version: " + body + "\n Device Brand: " + Build.BRAND +
Build.VERSION.RELEASE + "\n App Version: " + appVersion + "\n Device Brand: " + Build.BRAND +
"\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER + "\n Marian Kowalski!!!";
} else if ( mode == "anonymous"){
body = "\n\n-----------------------------\nPlease don't remove this information\n Device OS: Android \n Device OS version: " +
Build.VERSION.RELEASE + "\n App Version: " + appVersion + "\n Device Brand: " + Build.BRAND +
"\n Device Model: " + Build.MODEL + "\n Device Manufacturer: " + Build.MANUFACTURER;
}
} catch (PackageManager.NameNotFoundException e) {
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"team@findmytutor.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Query from android app");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{context.getString(R.string.fmt_email)});
intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(subject));
intent.putExtra(Intent.EXTRA_TEXT, body);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_email_client)));
}
private void showNoteDialog(Context context, int subject) {
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(BaseActivity.this);
//View view = layoutInflaterAndroid.inflate(R.layout.feedback_modal, null);
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(BaseActivity.this);
//alertDialogBuilderUserInput.setView(view);
alertDialogBuilderUserInput.setNegativeButton(R.string.cancel, (dialog, id) -> {
// User cancelled the dialog
});
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE,"OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Write your code here to execute after dialog
// closed
Toast.makeText(getApplicationContext(),
"You clicked on OK", Toast.LENGTH_SHORT).show();
}
});
/* Button yes = (Button) alertDialog.findViewById(R.id.feedback_modal_yes);
Button no = (Button) alertDialog.findViewById(R.id.feedback_modal_no);*/
/* yes.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
sendFeedback(context,subject,"full");
}
});
no.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
sendFeedback(context,subject,"anonymous");
}
});*/
alertDialog.show();
}
abstract int getNavigationMenuItemId();

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/feedback_modal_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:text="Do you want to send it anonymously?" />
<Button
android:id="@+id/feedback_modal_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="69dp"
android:layout_toStartOf="@+id/feedback_modal_question"
android:text="Yes" />
<Button
android:id="@+id/feedback_modal_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/feedback_modal_yes"
android:layout_toEndOf="@+id/feedback_modal_question"
android:text="No" />
</RelativeLayout>

View File

@ -17,6 +17,12 @@
<string name="navigation_item_settings">Settings</string>
<string name="navigation_item_profile">Profile</string>
<string name="navigation_item_logout">Log out</string>
<!--Feedback/Bug report-->
<string name="email_subject_feedback">Find My Tutor - feedback</string>
<string name="email_subject_bug">Find My Tutor - bug report</string>
<!-- Tutors list -->
<string name="action_settings">Settings</string>
<string name="activity_title_home">Notes</string>
@ -36,6 +42,7 @@
<string name="action_white_list">White List</string>
<string name="title_activity_settings">Settings</string>
<string name="fmt_email">findmytutorwmi@gmail.com</string>