Skip to content

Commit

Permalink
Issue #272 beta app feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed Dec 3, 2017
1 parent 0cf0592 commit a2a2f31
Show file tree
Hide file tree
Showing 19 changed files with 196 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.github.yeriomin.yalpstore.fragment.details;

import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.github.yeriomin.playstoreapi.GooglePlayAPI;
import com.github.yeriomin.yalpstore.ContextUtil;
import com.github.yeriomin.yalpstore.DetailsActivity;
import com.github.yeriomin.yalpstore.PlayStoreApiAuthenticator;
import com.github.yeriomin.yalpstore.R;
import com.github.yeriomin.yalpstore.model.App;
import com.github.yeriomin.yalpstore.task.playstore.BetaToggleTask;
import com.github.yeriomin.yalpstore.task.playstore.PlayStorePayloadTask;

import java.io.IOException;

public class Beta extends Abstract {

Expand Down Expand Up @@ -36,9 +43,33 @@ public void draw() {
initExpandableGroup(R.id.beta_header, R.id.beta_container);
setText(R.id.beta_header, app.isTestingProgramOptedIn() ? R.string.testing_program_section_opted_in_title : R.string.testing_program_section_opted_out_title);
setText(R.id.beta_message, app.isTestingProgramOptedIn() ? R.string.testing_program_section_opted_in_message : R.string.testing_program_section_opted_out_message);
setText(R.id.beta_button, app.isTestingProgramOptedIn() ? R.string.testing_program_opt_out : R.string.testing_program_opt_in);
setText(R.id.beta_subscribe_button, app.isTestingProgramOptedIn() ? R.string.testing_program_opt_out : R.string.testing_program_opt_in);
setText(R.id.beta_email, app.getTestingProgramEmail());
activity.findViewById(R.id.beta_button).setOnClickListener(new BetaOnClickListener((TextView) activity.findViewById(R.id.beta_message), app));
activity.findViewById(R.id.beta_feedback).setVisibility(app.isTestingProgramOptedIn() ? View.VISIBLE : View.GONE);
activity.findViewById(R.id.beta_subscribe_button).setOnClickListener(new BetaOnClickListener((TextView) activity.findViewById(R.id.beta_message), app));
activity.findViewById(R.id.beta_submit_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initBetaTask(new BetaFeedbackSubmitTask()).execute();
}
});
activity.findViewById(R.id.beta_delete_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initBetaTask(new BetaFeedbackDeleteTask()).execute();
}
});
if (null != app.getUserReview() && !TextUtils.isEmpty(app.getUserReview().getComment())) {
((EditText) activity.findViewById(R.id.beta_comment)).setText(app.getUserReview().getComment());
activity.findViewById(R.id.beta_delete_button).setVisibility(View.VISIBLE);
}
}

private BetaFeedbackTask initBetaTask(BetaFeedbackTask task) {
task.setPackageName(app.getPackageName());
task.setEditText((EditText) activity.findViewById(R.id.beta_comment));
task.setDeleteButton(activity.findViewById(R.id.beta_delete_button));
return task;
}

static class BetaOnClickListener implements View.OnClickListener {
Expand All @@ -58,4 +89,61 @@ public void onClick(View view) {
new BetaToggleTask(app).execute();
}
}

static abstract private class BetaFeedbackTask extends PlayStorePayloadTask<Void> {

protected String packageName;
protected EditText editText;
protected View deleteButton;

public void setPackageName(String packageName) {
this.packageName = packageName;
}

public void setEditText(EditText editText) {
this.editText = editText;
setContext(editText.getContext());
}

public void setDeleteButton(View deleteButton) {
this.deleteButton = deleteButton;
}
}

static private class BetaFeedbackSubmitTask extends BetaFeedbackTask {

@Override
protected Void getResult(GooglePlayAPI api, String... arguments) throws IOException {
api.betaFeedback(packageName, editText.getText().toString());
return null;
}

@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (success()) {
ContextUtil.toastShort(context, context.getString(R.string.done));
deleteButton.setVisibility(View.VISIBLE);
}
}
}

static private class BetaFeedbackDeleteTask extends BetaFeedbackTask {

@Override
protected Void getResult(GooglePlayAPI api, String... arguments) throws IOException {
api.deleteBetaFeedback(packageName);
return null;
}

@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (success()) {
editText.setText("");
ContextUtil.toastShort(context, context.getString(R.string.done));
deleteButton.setVisibility(View.GONE);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public void onClick(View v) {
}

private boolean isReviewable(App app) {
return app.isInstalled() && !PreferenceManager.getDefaultSharedPreferences(activity)
.getBoolean(PlayStoreApiAuthenticator.PREFERENCE_APP_PROVIDED_EMAIL, false)
return app.isInstalled()
&& !app.isTestingProgramOptedIn()
&& !PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(PlayStoreApiAuthenticator.PREFERENCE_APP_PROVIDED_EMAIL, false)
;
}

Expand Down
44 changes: 39 additions & 5 deletions app/src/main/res/layout/details_activity_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -532,25 +532,59 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<LinearLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/beta_button"
android:id="@+id/beta_subscribe_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/beta_email"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="email"
android:layout_gravity="bottom|end"
android:gravity="bottom|end"
android:layout_gravity="center_vertical|end"
android:gravity="center_vertical|end"
android:textAlignment="textEnd"/>

</FrameLayout>

<LinearLayout
android:id="@+id/beta_feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<EditText
android:id="@+id/beta_comment"
android:hint="@string/testing_program_review_dialog_content_hint"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<Button
android:id="@+id/beta_submit_button"
android:text="@string/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<Button
android:id="@+id/beta_delete_button"
android:visibility="gone"
android:text="@string/delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</LinearLayout>

</LinearLayout>

</LinearLayout>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@
<string name="testing_program_section_opted_out_title">"الانضمام إلى مختبِري الإصدار التجريبي"</string>
<string name="notification_not_privileged">"Install permission not granted"</string>
<string name="about_paypal_label">"التبرع"</string>
<string name="testing_program_review_dialog_content_hint">إدخال تعليقات حول التطبيق</string>
<string name="delete">حذف</string>
<string name="submit">إرسال</string>
<string name="done">تم</string>
<string name="availability_restriction_carrier">لا يتاح هذا العنصر لدى مشغل شبكة الجوال.</string>
<string name="availability_restriction_country">هذا العنصر غير متاح في بلدك.</string>
<string name="availability_restriction_country_or_carrier">هذا العنصر غير متوفر في بلدك أو لدى مشغل شبكة الجوال.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Pokračovat?"</string>
<string name="testing_program_section_opted_out_title">"Staňte se testerem beta verze"</string>
<string name="notification_not_privileged">"Install permission not granted"</string>
<string name="about_paypal_label">"Přispět:"</string>
<string name="testing_program_review_dialog_content_hint">Zadejte zpětnou vazbu k aplikaci</string>
<string name="delete">Smazat</string>
<string name="submit">Odeslat</string>
<string name="done">Hotovo</string>
<string name="availability_restriction_carrier">Tato položka není u vašeho operátora dostupná.</string>
<string name="availability_restriction_country">Tato položka není ve vaší zemi dostupná.</string>
<string name="availability_restriction_country_or_carrier">Tato položka není ve vaší zemi nebo u vašeho operátora dostupná.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ Fortfahren?"</string>
<string name="pref_download_deltas">"Delta-Aktualisierungen"</string>
<string name="pref_download_deltas_summary_off">"Die gesamte apk wird jedes Mal heruntergeladen"</string>
<string name="pref_download_deltas_summary_on">"Beim Aktualisieren werden nur Änderungen heruntergeladen"</string>
<string name="testing_program_review_dialog_content_hint">Feedback zur App eingeben</string>
<string name="delete">Löschen</string>
<string name="submit">Senden</string>
<string name="done">Fertig</string>
<string name="availability_restriction_carrier">Dieser Artikel ist für deinen Mobilfunkanbieter nicht verfügbar.</string>
<string name="availability_restriction_country">Dieser Artikel ist in deinem Land nicht verfügbar.</string>
<string name="availability_restriction_country_or_carrier">Dieser Artikel ist in deinem Land bzw. für deinen Mobilfunkanbieter nicht verfügbar.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@
<string name="testing_program_section_opted_out_title">"Γίνε δοκιμαστής της beta"</string>
<string name="notification_not_privileged">"Δεν έχουν παραχωρηθεί δικαιώματα εγκατάστασης"</string>
<string name="about_paypal_label">"Δωρεά Paypal:"</string>
<string name="testing_program_review_dialog_content_hint">Εισάγετε σχόλια σχετικά με την εφαρμογή</string>
<string name="delete">Διαγραφή</string>
<string name="submit">Υποβολή</string>
<string name="done">Τέλος</string>
<string name="availability_restriction_carrier">Αυτό το αντικείμενο δεν είναι διαθέσιμο στην εταιρεία κινητής τηλεφωνίας σας.</string>
<string name="availability_restriction_country">Αυτό το στοιχείο δεν είναι διαθέσιμο στη χώρα σας.</string>
<string name="availability_restriction_country_or_carrier">Αυτό το αντικείμενο δεν είναι διαθέσιμο στη χώρα σας ή στην εταιρεία κινητής τηλεφωνίας σας.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ El proceso de conversión es imperfecto y específico para cada marca, así que
<string name="pref_download_deltas">"Actualizaciones Delta"</string>
<string name="pref_download_deltas_summary_off">"Descarga completa del apk cada vez"</string>
<string name="pref_download_deltas_summary_on">"Solo los cambios son descargados durante las actualizaciones."</string>
<string name="testing_program_review_dialog_content_hint">Danos tu opinión sobre la aplicación</string>
<string name="delete">Eliminar</string>
<string name="submit">Enviar</string>
<string name="done">Listo</string>
<string name="availability_restriction_carrier">Este elemento no está disponible para tu operador.</string>
<string name="availability_restriction_country">Este elemento no está disponible en tu país.</string>
<string name="availability_restriction_country_or_carrier">Este elemento no está disponible en tu país o para tu operador.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Jarraitu?"</string>
<string name="notification_not_privileged">"Ez da eman instalatzeko baimena"</string>
<string name="about_paypal_label">"Egin dohaintza:"</string>
<string name="pref_download_directory">"Deskargen direktorioa"</string>
<string name="testing_program_review_dialog_content_hint">Eman iritzia aplikazioari buruz</string>
<string name="delete">Ezabatu</string>
<string name="submit">Bidali</string>
<string name="done">Eginda</string>
<string name="availability_restriction_carrier">Elementu hau ez dago operadorean eskuragarri.</string>
<string name="availability_restriction_country">Elementua ez dago zure herrialdean erabilgarri.</string>
<string name="availability_restriction_country_or_carrier">Elementua ez dago erabilgarri zure herrialdean edo zure operadorearekin.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@
<string name="pref_download_deltas">"Mise à jour delta"</string>
<string name="pref_download_deltas_summary_off">"L'intégralité de l'apk est téléchargée à chaque fois"</string>
<string name="pref_download_deltas_summary_on">"Seules les modifications sont téléchargées pendant les mises à jour"</string>
<string name="testing_program_review_dialog_content_hint">"Saisir des commentaires à propos de l'application"</string>
<string name="delete">Supprimer</string>
<string name="done">OK</string>
<string name="submit">Envoyer</string>
<string name="availability_restriction_carrier">"Cet article n'est pas compatible avec votre opérateur."</string>
<string name="availability_restriction_country">"Cet article n'est pas disponible dans votre pays."</string>
<string name="availability_restriction_country_or_carrier">"Cet article n'est pas disponible dans votre pays ni compatible avec votre opérateur."</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ Il processo non è perfetto o specifico per produttore: potrebbe non funzionare.
<string name="testing_program_section_opted_out_title">"Diventa un beta tester"</string>
<string name="notification_not_privileged">"Install permission not granted"</string>
<string name="about_paypal_label">"Dona:"</string>
<string name="testing_program_review_dialog_content_hint">"Inserisci il feedback sull'app"</string>
<string name="done">Fine</string>
<string name="submit">Invia</string>
<string name="delete">Elimina</string>
<string name="availability_restriction_carrier">Questo articolo non è disponibile per il tuo operatore.</string>
<string name="availability_restriction_country">Questo prodotto non è disponibile nel tuo Paese.</string>
<string name="availability_restriction_country_or_carrier">Questo articolo non è disponibile nel tuo Paese o per il tuo operatore.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ Google Play ストアでは、任意のバージョンのアプリをダウン
<string name="pref_download_deltas">"デルタアップデート"</string>
<string name="pref_download_deltas_summary_off">"毎回すべての apk をダウンロードします"</string>
<string name="pref_download_deltas_summary_on">"更新の際、変更のみダウンロードします"</string>
<string name="testing_program_review_dialog_content_hint">アプリに関するフィードバックを入力</string>
<string name="delete">削除</string>
<string name="submit">送信</string>
<string name="done">完了</string>
<string name="availability_restriction_carrier">お使いの携帯通信会社ではこのアイテムはご利用いただけません。</string>
<string name="availability_restriction_country">このアイテムはお住まいの国でご利用いただけません</string>
<string name="availability_restriction_country_or_carrier">このアイテムはお住まいの国またはご利用の携帯通信会社に対応していません。</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ Nu doen?"</string>
<string name="pref_download_deltas">"Delta updates"</string>
<string name="pref_download_deltas_summary_off">"De volledige apk wordt bij iedere update gedownload"</string>
<string name="pref_download_deltas_summary_on">"Alleen de veranderingen aan de app worden gedownload"</string>
<string name="testing_program_review_dialog_content_hint">Geef feedback over de app</string>
<string name="delete">Verwijderen</string>
<string name="done">Gereed</string>
<string name="submit">Indienen</string>
<string name="availability_restriction_carrier">Dit item is niet beschikbaar bij jouw provider.</string>
<string name="availability_restriction_country">Dit item is niet beschikbaar in je land.</string>
<string name="availability_restriction_country_or_carrier">Dit item is niet beschikbaar in jouw land of bij jouw provider.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ Nie rób tego z ciekawości. Może to zepsuć urządzenie. Zrób kopię zapasow
<string name="pref_download_deltas">"Aktualizacje delta"</string>
<string name="pref_download_deltas_summary_off">"Pełny plik .apk jest pobierany za każdym razem"</string>
<string name="pref_download_deltas_summary_on">"Tylko zmiany są pobierane podczas aktualizacji"</string>
<string name="testing_program_review_dialog_content_hint">Napisz opinię o aplikacji</string>
<string name="delete">Usuń</string>
<string name="submit">Prześlij</string>
<string name="done">Gotowe</string>
<string name="availability_restriction_carrier">Ten element nie jest dostępny u Twojego operatora.</string>
<string name="availability_restriction_country">Produkt jest niedostępny w Twoim kraju.</string>
<string name="availability_restriction_country_or_carrier">Ten element nie jest dostępny w Twoim kraju lub sieci operatora.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ Prosseguir mesmo assim?"</string>
<string name="pref_download_deltas">"Atualizações Delta"</string>
<string name="pref_download_deltas_summary_off">"Aplicação completa será transferida sempre"</string>
<string name="pref_download_deltas_summary_on">"Apenas modificações serão transferidas durante atualizações"</string>
<string name="testing_program_review_dialog_content_hint">Insira comentários sobre o app</string>
<string name="delete">Excluir</string>
<string name="submit">Enviar</string>
<string name="done">Concluído</string>
<string name="availability_restriction_carrier">Este item não está disponível em sua operadora.</string>
<string name="availability_restriction_country">Este item não está disponível em seu país.</string>
<string name="availability_restriction_country_or_carrier">Este item não está disponível em seu país ou sua operadora.</string>
Expand Down
Loading

0 comments on commit a2a2f31

Please sign in to comment.