Commit bba765df authored by Lennart Bader's avatar Lennart Bader
Browse files

Added Feedback Page

parent e5989f39
......@@ -17,6 +17,7 @@
<activity android:name=".activities.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.Base"
android:windowSoftInputMode="adjustPan"
android:configChanges="orientation|screenSize">
<intent-filter>
......
......@@ -19,6 +19,7 @@ import de.mytfg.apps.vplan.R;
import de.mytfg.apps.vplan.api.MyTFGApi;
import de.mytfg.apps.vplan.fragments.AboutFragment;
import de.mytfg.apps.vplan.fragments.AuthenticationFragment;
import de.mytfg.apps.vplan.fragments.FeedbackFragment;
import de.mytfg.apps.vplan.fragments.LinksFragment;
import de.mytfg.apps.vplan.fragments.OfficeFragment;
import de.mytfg.apps.vplan.fragments.SettingsFragment;
......@@ -89,6 +90,10 @@ public class MainActivity extends AppCompatActivity {
navi.clear();
navi.navigate(new AboutFragment(), R.id.fragment_container);
return true;
case R.id.mainmenu_feedback:
navi.clear();
navi.navigate(new FeedbackFragment(), R.id.fragment_container);
return true;
// SUBMENU "PARTNERS"
case R.id.mainmenu_partners:
......
package de.mytfg.apps.vplan.fragments;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import org.json.JSONException;
import org.json.JSONObject;
import de.mytfg.apps.vplan.R;
import de.mytfg.apps.vplan.activities.MainActivity;
import de.mytfg.apps.vplan.api.ApiCallback;
import de.mytfg.apps.vplan.api.ApiParams;
import de.mytfg.apps.vplan.api.MyTFGApi;
import de.mytfg.apps.vplan.tools.JsonFileManager;
public class FeedbackFragment extends AuthenticationFragment {
RatingBar ratingBar;
EditText likeText;
EditText improveText;
public FeedbackFragment() {
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_feedback, container, false);
final MainActivity context = (MainActivity)this.getActivity();
setHasOptionsMenu(true);
context.getToolbarManager()
.clear()
.setImage(R.mipmap.feedback_header)
.showBottomScrim()
.setTitle(getString(R.string.menutitle_feedback))
.setExpandable(true, true);
ratingBar = (RatingBar) view.findViewById(R.id.feedback_rating);
likeText = (EditText) view.findViewById(R.id.feedback_like);
improveText = (EditText) view.findViewById(R.id.feedback_improve);
final Button sendButton = (Button) view.findViewById(R.id.feedback_button);
JSONObject savedFeedback = JsonFileManager.read("feedback", context);
if (savedFeedback != null) {
likeText.setText(savedFeedback.optString("like", ""));
improveText.setText(savedFeedback.optString("improve", ""));
ratingBar.setRating((float) savedFeedback.optDouble("rating", 1.0));
}
sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Try login
final ProgressDialog dialog = ProgressDialog.show(view.getContext(),
getString(R.string.please_wait),
getString(R.string.feedback_process),
true);
MyTFGApi api = new MyTFGApi(context);
final int rating = (int) ratingBar.getRating();
String like = likeText.getText().toString();
String improve = improveText.getText().toString();
String version;
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
version = pInfo.versionName;
} catch (PackageManager.NameNotFoundException ex) {
version = "Unknown";
}
ApiParams params = new ApiParams();
params.addParam("rating", "" + rating);
params.addParam("good", like);
params.addParam("bad", improve);
params.addParam("os", "Android");
params.addParam("os_version", Build.VERSION.RELEASE);
params.addParam("app_version", version);
api.call("api_app_feedback", params, new ApiCallback() {
@Override
public void callback(JSONObject result, int responseCode) {
dialog.dismiss();
String message;
switch (responseCode) {
case 200:
message = getString(R.string.feedback_success);
ratingBar.setRating(1.0f);
likeText.setText("");
improveText.setText("");
break;
case 400:
message = getString(R.string.feedback_400);
break;
case 500:
message = getString(R.string.feedback_500);
break;
default:
message = getString(R.string.feedback_error);
break;
}
context.getNavi().snackbar(message);
}
});
}
});
return view;
}
@Override
public void onPause() {
// Save contents to preferences
JSONObject savedFeedback = new JSONObject();
try {
savedFeedback.put("like", likeText.getText().toString());
savedFeedback.put("improve", improveText.getText().toString());
savedFeedback.put("rating", (double) ratingBar.getRating());
JsonFileManager.write(savedFeedback, "feedback", getContext());
} catch (JSONException ignored) {}
super.onPause();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
super.onCreateOptionsMenu(menu, inflater);
}
}
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/colorIcons"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="@dimen/defaultPadding"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:descendantFocusability="beforeDescendants"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/cardview_spacing"
android:layout_marginBottom="@dimen/defaultPadding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/cardview_spacing"
android:background="@color/colorPrimaryLight">
<TextView
android:textSize="@dimen/textTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/feedback_hint_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textDefault"
android:id="@+id/login_text"
android:text="@string/feedback_hint_text" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/cardview_spacing"
android:layout_marginBottom="@dimen/defaultPadding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/cardview_spacing"
android:background="@color/colorPrimaryLight">
<TextView
android:textSize="@dimen/textTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/feedback_form_title" />
<TextView
android:text="@string/feedback_form_stars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textDefault"/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stepSize="1"
android:id="@+id/feedback_rating"
android:rating="1"
android:numStars="5" />
<TextView
android:text="@string/feedback_form_like"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textDefault"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/feedback_form_like"
android:scrollbars="vertical"
android:inputType="textMultiLine"
android:id="@+id/feedback_like"
android:minLines="5"/>
<TextView
android:text="@string/feedback_form_improve"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/textDefault"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/feedback_form_improve"
android:scrollbars="vertical"
android:inputType="textMultiLine"
android:id="@+id/feedback_improve"
android:minLines="5"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:id="@+id/feedback_button"
android:text="@string/feedback_action"
style="@style/AppTheme.Button"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
......@@ -30,5 +30,8 @@
<item android:id="@+id/mainmenu_about"
android:icon="@drawable/ic_menu_about"
android:title="@string/menutitle_about" />
<item android:id="@+id/mainmenu_feedback"
android:icon="@drawable/ic_menu_feedback"
android:title="@string/menutitle_feedback" />
</group>
</menu>
\ No newline at end of file
......@@ -17,6 +17,7 @@
<string name="menutitle_login">Anmelden</string>
<string name="menutitle_about">Über diese App</string>
<string name="menutitle_back">Zurück</string>
<string name="menutitle_feedback">Feedback</string>
<!-- Partner Menu -->
<string name="menutitle_boosters">TFG Förderverein</string>
......@@ -153,6 +154,27 @@
<string name="office_open">Öffnungszeiten</string>
<string name="office_open_val">8:00 bis 16:00 Uhr</string>
<!-- FEEDBACK -->
<string name="feedback_hint_title">Feedback abgeben</string>
<string name="feedback_hint_text">
Diese App befindet sich derzeit noch in der Entwicklung.
\nUm diese App zu verbessern, sind wir auf Ihr Feedback angewiesen.
\nSollten Ihnen Fehler in technischer oder inhaltlicher Hinsicht auffallen,
Sie sich eine weitere Funktion wünschen oder Sie andere Ideen haben, wie man diese App
verbessern könnte, teilen Sie uns dies mit!
\nIhr Feedback wird anonym entgegengenommen und ohne personenbezogene Daten gespeichert.
</string>
<string name="feedback_form_title">Feedback</string>
<string name="feedback_form_stars">Wie würden Sie die App derzeit bewerten?</string>
<string name="feedback_form_like">Was gefällt Ihnen an der App?</string>
<string name="feedback_form_improve">Was sollte Ihrer Meinung nach verbessert werden / welche Fehler treten auf?</string>
<string name="feedback_action">Absenden</string>
<string name="feedback_process">Feedback wird übermittelt</string>
<string name="feedback_success">Vielen Dank für Ihr Feedback</string>
<string name="feedback_400">Feedback konnte nicht übermittelt werden</string>
<string name="feedback_500">Feedback konnte nicht an Entwickler weitergeleitet werden</string>
<string name="feedback_error">Überprüfen Sie Ihre Netzwerkverbindung</string>
<!-- SHOWCASE -->
<string name="hide_showcase">Fertig</string>
<string name="next_showcase">Weiter</string>
......
......@@ -18,6 +18,7 @@
<string name="menutitle_about">About this App</string>
<string name="menutitle_links">Links</string>
<string name="menutitle_back">Back</string>
<string name="menutitle_feedback">Feedback</string>
<!-- Partner Menu -->
<string name="menutitle_boosters">TFG Förderverein</string>
......@@ -169,6 +170,22 @@
<string name="office_open">Opening times</string>
<string name="office_open_val">8am to 4pm</string>
<!-- FEEDBACK -->
<string name="feedback_hint_title">Provide Feedback</string>
<string name="feedback_hint_text">
Please give some feedback.
</string>
<string name="feedback_form_title">Feedback</string>
<string name="feedback_form_stars">How would you rate this App at the moment?</string>
<string name="feedback_form_like">What do you like about this App?</string>
<string name="feedback_form_improve">What would you like us to improve?</string>
<string name="feedback_action">Send Feedback</string>
<string name="feedback_process">Sending Feedback</string>
<string name="feedback_success">Thank you for your Feedback!</string>
<string name="feedback_400">Failed to Submit Feedback - App broken?</string>
<string name="feedback_500">Failed to forward Feedback to developers.</string>
<string name="feedback_error">Feedback could not be sent.</string>
<!-- SHOWCASE -->
<string name="hide_showcase">Hide</string>
<string name="next_showcase">Next</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment