Skip to content

Commit 16c3059

Browse files
committed
created a way to send feedback
1 parent 6515694 commit 16c3059

17 files changed

+245
-8
lines changed
Binary file not shown.
Binary file not shown.
750 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
136 Bytes
Binary file not shown.
46.8 KB
Binary file not shown.
209 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

.idea/navEditor.xml

+14-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
package com.josh.trackcovid19v2;
2+
3+
import android.app.Activity;
4+
import android.app.AlertDialog;
5+
import android.content.DialogInterface;
6+
import android.content.Intent;
7+
import android.os.Build;
8+
import android.os.Bundle;
9+
10+
import androidx.fragment.app.Fragment;
11+
12+
import android.util.DisplayMetrics;
13+
import android.view.InflateException;
14+
import android.view.LayoutInflater;
15+
import android.view.View;
16+
import android.view.ViewGroup;
17+
import android.widget.Button;
18+
import android.widget.EditText;
19+
import android.widget.TextView;
20+
import android.widget.Toast;
21+
22+
23+
/**
24+
* A simple {@link Fragment} subclass.
25+
* Use the {@link SendFeedbackFragment#newInstance} factory method to
26+
* create an instance of this fragment.
27+
*/
28+
public class SendFeedbackFragment extends Fragment {
29+
// TODO: Rename parameter arguments, choose names that match
30+
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
31+
private static final String ARG_PARAM1 = "param1";
32+
private static final String ARG_PARAM2 = "param2";
33+
34+
// TODO: Rename and change types of parameters
35+
private String mParam1;
36+
private String mParam2;
37+
38+
public SendFeedbackFragment() {
39+
// Required empty public constructor
40+
}
41+
42+
/**
43+
* Use this factory method to create a new instance of
44+
* this fragment using the provided parameters.
45+
*
46+
* @param param1 Parameter 1.
47+
* @param param2 Parameter 2.
48+
* @return A new instance of fragment SendFeedbackFragment.
49+
*/
50+
// TODO: Rename and change types and number of parameters
51+
public static SendFeedbackFragment newInstance(String param1, String param2) {
52+
SendFeedbackFragment fragment = new SendFeedbackFragment();
53+
Bundle args = new Bundle();
54+
args.putString(ARG_PARAM1, param1);
55+
args.putString(ARG_PARAM2, param2);
56+
fragment.setArguments(args);
57+
return fragment;
58+
}
59+
60+
@Override
61+
public void onCreate(Bundle savedInstanceState) {
62+
super.onCreate(savedInstanceState);
63+
if (getArguments() != null) {
64+
mParam1 = getArguments().getString(ARG_PARAM1);
65+
mParam2 = getArguments().getString(ARG_PARAM2);
66+
}
67+
}
68+
69+
@Override
70+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
71+
Bundle savedInstanceState) {
72+
// Inflate the layout for this fragment
73+
View view = inflater.inflate(R.layout.fragment_send_feedback, container, false);
74+
final TextView to = (TextView) view.findViewById(R.id.sendTo);
75+
final EditText message = (EditText) view.findViewById(R.id.EmailText);
76+
final EditText subject = (EditText) view.findViewById(R.id.subject);
77+
78+
Button sendE = (Button) view.findViewById(R.id.sendEmail);
79+
sendE.setOnClickListener(new View.OnClickListener() {
80+
@Override
81+
public void onClick(android.view.View v) {
82+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
83+
84+
builder.setTitle("Data");
85+
builder.setMessage("We will need to take some data from your device to fix the report. Is this okay with you?");
86+
87+
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
88+
89+
public void onClick(DialogInterface dialog, int which) {
90+
91+
String toS = "[email protected]";
92+
String subS = subject.getText().toString();
93+
String mesS = message.getText().toString();
94+
String system = System.getProperty("os.version");
95+
Integer API = Build.VERSION.SDK_INT;
96+
String device = Build.DEVICE;
97+
String model = Build.MODEL;
98+
String product = Build.PRODUCT;
99+
String display = Build.DISPLAY;
100+
String type = Build.TYPE;
101+
String user = Build.USER;
102+
DisplayMetrics displayMetrics = new DisplayMetrics();
103+
((Activity) getContext()).getWindowManager()
104+
.getDefaultDisplay()
105+
.getMetrics(displayMetrics);
106+
int height = displayMetrics.heightPixels + getNavigationBarHeight();
107+
int width = displayMetrics.widthPixels;
108+
Intent email = new Intent(Intent.ACTION_SEND);
109+
110+
email.putExtra(Intent.EXTRA_EMAIL , new String [] {toS});
111+
email.putExtra(Intent.EXTRA_SUBJECT , subS);
112+
email.putExtra(Intent.EXTRA_TEXT , mesS + "\n\n\n\n\n\n" + "\nAPI: " + API + "\nDevice: "
113+
+ device + "\nModel: "+ model +"\nType:" + type +"\nUser:" + user +
114+
"\nDisplay height: " + height + "\nDisplay width: " + width);
115+
116+
email.setType("message/rfc822");
117+
startActivity(Intent.createChooser(email, "Choose an app to send the email with"));
118+
dialog.dismiss();
119+
}
120+
});
121+
122+
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
123+
124+
@Override
125+
public void onClick(DialogInterface dialog, int which) {
126+
127+
Toast.makeText(getActivity(), "Canceled", Toast.LENGTH_SHORT).show();
128+
dialog.dismiss();
129+
}
130+
});
131+
132+
AlertDialog alert = builder.create();
133+
alert.show();
134+
}
135+
});
136+
return view;
137+
}
138+
private int getNavigationBarHeight() {
139+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
140+
DisplayMetrics metrics = new DisplayMetrics();
141+
((Activity) getContext()).getWindowManager()
142+
.getDefaultDisplay()
143+
.getMetrics(metrics);
144+
int usableHeight = metrics.heightPixels;
145+
((Activity) getContext()).getWindowManager()
146+
.getDefaultDisplay()
147+
.getRealMetrics(metrics);
148+
int realHeight = metrics.heightPixels;
149+
if (realHeight > usableHeight)
150+
return realHeight - usableHeight;
151+
else
152+
return 0;
153+
}
154+
return 0;
155+
}
156+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".SendFeedbackFragment">
8+
9+
<TextView
10+
android:id="@+id/sendTo"
11+
android:layout_width="0dp"
12+
android:layout_height="wrap_content"
13+
android:ems="10"
14+
android:inputType="textEmailAddress"
15+
android:text="[email protected]"
16+
app:layout_constraintBottom_toBottomOf="parent"
17+
app:layout_constraintEnd_toEndOf="parent"
18+
app:layout_constraintHorizontal_bias="0.5"
19+
app:layout_constraintStart_toStartOf="parent"
20+
app:layout_constraintTop_toTopOf="parent"
21+
app:layout_constraintVertical_bias="0.122"
22+
app:layout_constraintWidth_percent=".7" />
23+
24+
<EditText
25+
android:id="@+id/subject"
26+
android:layout_width="0dp"
27+
android:layout_height="wrap_content"
28+
android:ems="10"
29+
android:hint="Enter a subject for the email here"
30+
android:inputType="textPersonName"
31+
app:layout_constraintBottom_toBottomOf="parent"
32+
app:layout_constraintEnd_toEndOf="parent"
33+
app:layout_constraintHorizontal_bias="0.5"
34+
app:layout_constraintStart_toStartOf="parent"
35+
app:layout_constraintTop_toTopOf="parent"
36+
app:layout_constraintVertical_bias="0.284"
37+
app:layout_constraintWidth_percent=".90" />
38+
39+
<EditText
40+
android:id="@+id/EmailText"
41+
android:layout_width="0dp"
42+
android:layout_height="wrap_content"
43+
android:ems="10"
44+
android:gravity="start|top"
45+
android:hint="Please highlight what the bug was."
46+
android:inputType="textMultiLine"
47+
app:layout_constraintBottom_toBottomOf="parent"
48+
app:layout_constraintEnd_toEndOf="parent"
49+
app:layout_constraintHorizontal_bias="0.5"
50+
app:layout_constraintStart_toStartOf="parent"
51+
app:layout_constraintTop_toTopOf="parent"
52+
app:layout_constraintVertical_bias="0.6"
53+
app:layout_constraintWidth_percent=".95" />
54+
55+
<Button
56+
android:id="@+id/sendEmail"
57+
android:layout_width="wrap_content"
58+
android:layout_height="wrap_content"
59+
android:text="Send"
60+
app:layout_constraintBottom_toBottomOf="parent"
61+
app:layout_constraintEnd_toEndOf="parent"
62+
app:layout_constraintHorizontal_bias="0.5"
63+
app:layout_constraintStart_toStartOf="parent"
64+
app:layout_constraintTop_toTopOf="parent"
65+
app:layout_constraintVertical_bias=".9" />
66+
67+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/layout/fragment_settings.xml

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
android:layout_height="match_parent"
66
tools:context="com.josh.trackcovid19v2.SettingsFragment">
77

8-
<!-- TODO: Update blank fragment layout -->
9-
<TextView
10-
android:layout_width="match_parent"
11-
android:layout_height="match_parent"
12-
android:text="@string/hello_blank_fragment" />
8+
139

1410
</FrameLayout>

app/src/main/res/menu/activity_main_drawer.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
<group
2828
android:id="@+id/menu_bottom"
2929
android:checkableBehavior="none">
30-
30+
<!--
3131
<item
3232
android:id="@+id/nav_yoursettings"
3333
android:icon="@drawable/ic_action_name"
3434
android:title="@string/item" />
35+
-->
3536
<item
3637
android:id="@+id/nav_sendFeedback"
3738
android:icon="@drawable/ic_action_name2"

app/src/main/res/navigation/mobile_navigation.xml

+5
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@
3030
android:name="com.josh.trackcovid19v2.SettingsActivity$SettingsFragment"
3131
android:label="@string/menu_yoursettings"
3232
tools:layout="@layout/fragment_settings" />
33+
<fragment
34+
android:id="@+id/nav_sendFeedback"
35+
android:name="com.josh.trackcovid19v2.SendFeedbackFragment"
36+
android:label="@string/send_feedback"
37+
tools:layout="@layout/fragment_send_feedback" />
3338
</navigation>

0 commit comments

Comments
 (0)