diff --git a/app/src/main/java/org/solovyev/android/calculator/StartupHelper.java b/app/src/main/java/org/solovyev/android/calculator/StartupHelper.java index 23b8a6e5..d70197c8 100644 --- a/app/src/main/java/org/solovyev/android/calculator/StartupHelper.java +++ b/app/src/main/java/org/solovyev/android/calculator/StartupHelper.java @@ -1,15 +1,15 @@ package org.solovyev.android.calculator; -import android.content.Context; +import android.content.ActivityNotFoundException; +import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; -import android.text.method.LinkMovementMethod; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; + import org.solovyev.android.Android; import org.solovyev.android.calculator.wizard.CalculatorWizards; import org.solovyev.android.wizard.Wizard; @@ -20,7 +20,9 @@ import javax.inject.Named; import javax.inject.Singleton; import static org.solovyev.android.calculator.release.ReleaseNotes.hasReleaseNotes; -import static org.solovyev.android.wizard.WizardUi.*; +import static org.solovyev.android.wizard.WizardUi.continueWizard; +import static org.solovyev.android.wizard.WizardUi.createLaunchIntent; +import static org.solovyev.android.wizard.WizardUi.startWizard; @Singleton public class StartupHelper { @@ -47,7 +49,7 @@ public class StartupHelper { editor.apply(); } - private void handleOnMainActivityOpened(@NonNull AppCompatActivity activity, @NonNull SharedPreferences.Editor editor, int opened) { + private void handleOnMainActivityOpened(@NonNull final AppCompatActivity activity, @NonNull SharedPreferences.Editor editor, int opened) { final int currentVersion = Android.getAppVersionCode(activity); final Wizards wizards = App.getWizards(); final Wizard wizard = wizards.getWizard(CalculatorWizards.FIRST_TIME_WIZARD); @@ -72,17 +74,28 @@ public class StartupHelper { } } - if (opened > 30 && !UiPreferences.rateUsShown.getPreference(uiPreferences)) { - final LayoutInflater layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - final View view = layoutInflater.inflate(R.layout.feedback, null); - - final TextView feedbackTextView = (TextView) view.findViewById(R.id.feedbackText); - feedbackTextView.setMovementMethod(LinkMovementMethod.getInstance()); - - final AlertDialog.Builder builder = new AlertDialog.Builder(activity, App.getTheme().alertDialogTheme).setView(view); - builder.setPositiveButton(android.R.string.ok, null); + if (shouldShowRateUsDialog(opened)) { + final AlertDialog.Builder builder = new AlertDialog.Builder(activity, App.getTheme().alertDialogTheme); + builder.setPositiveButton(R.string.cpp_rateus_ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + try { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://market.android.com/details?id=org.solovyev.android.calculator")); + activity.startActivity(intent); + } catch (ActivityNotFoundException ignored) { + } + } + }); + builder.setNegativeButton(R.string.cpp_rateus_cancel, null); + builder.setMessage(activity.getString(R.string.cpp_rateus_message, activity.getString(R.string.c_app_name))); + builder.setTitle(activity.getString(R.string.cpp_rateus_title, activity.getString(R.string.c_app_name))); builder.create().show(); UiPreferences.rateUsShown.putPreference(editor, true); } } + + private boolean shouldShowRateUsDialog(int opened) { + return opened > 30 && !UiPreferences.rateUsShown.getPreference(uiPreferences); + } } diff --git a/app/src/main/res/layout/feedback.xml b/app/src/main/res/layout/feedback.xml deleted file mode 100644 index eb4615e9..00000000 --- a/app/src/main/res/layout/feedback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-ar/text_imported.xml b/app/src/main/res/values-ar/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-ar/text_imported.xml rename to app/src/main/res/values-ar/text_imported_aosp.xml diff --git a/app/src/main/res/values-ar/text_imported_other.xml b/app/src/main/res/values-ar/text_imported_other.xml new file mode 100644 index 00000000..449f7932 --- /dev/null +++ b/app/src/main/res/values-ar/text_imported_other.xml @@ -0,0 +1,7 @@ + + + تقييم %1$s + إذا كنت تستمتع بـ %1$s، يرجى أن تستغرق لحظة وتعطينا تقييمًا بخمس نجوم في Google Play. + ضع تقييمًا الآن + لا، شكرًا + \ No newline at end of file diff --git a/app/src/main/res/values-cs/text_imported.xml b/app/src/main/res/values-cs/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-cs/text_imported.xml rename to app/src/main/res/values-cs/text_imported_aosp.xml diff --git a/app/src/main/res/values-cs/text_imported_other.xml b/app/src/main/res/values-cs/text_imported_other.xml new file mode 100644 index 00000000..4792be0b --- /dev/null +++ b/app/src/main/res/values-cs/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Ohodnotit aplikaci %1$s + Pokud se vám aplikace %1$s líbí, prosím věnujte nám okamžik a udělte nám pětihvězdičkové hodnocení na Google Play. + Ohodnotit nyní + Ne, díky + \ No newline at end of file diff --git a/app/src/main/res/values-de/text_imported.xml b/app/src/main/res/values-de/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-de/text_imported.xml rename to app/src/main/res/values-de/text_imported_aosp.xml diff --git a/app/src/main/res/values-de/text_imported_other.xml b/app/src/main/res/values-de/text_imported_other.xml new file mode 100644 index 00000000..84ece937 --- /dev/null +++ b/app/src/main/res/values-de/text_imported_other.xml @@ -0,0 +1,7 @@ + + + %1$s bewerten + Wenn Ihnen %1$s gefällt, würden wir uns über Ihre Fünf-Sterne-Bewertung in Google Play freuen. + Jetzt bewerten + Nein danke + \ No newline at end of file diff --git a/app/src/main/res/values-es/text_imported.xml b/app/src/main/res/values-es/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-es/text_imported.xml rename to app/src/main/res/values-es/text_imported_aosp.xml diff --git a/app/src/main/res/values-es/text_imported_other.xml b/app/src/main/res/values-es/text_imported_other.xml new file mode 100644 index 00000000..784700cc --- /dev/null +++ b/app/src/main/res/values-es/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Califica %1$s + Si disfrutas usar %1$s, por favor dedica un instante y regálanos una calificación de cinco estrellas en Google Play. + Danos tu calificación + No, gracias + \ No newline at end of file diff --git a/app/src/main/res/values-fi/text_imported.xml b/app/src/main/res/values-fi/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-fi/text_imported.xml rename to app/src/main/res/values-fi/text_imported_aosp.xml diff --git a/app/src/main/res/values-fi/text_imported_other.xml b/app/src/main/res/values-fi/text_imported_other.xml new file mode 100644 index 00000000..67a2cab6 --- /dev/null +++ b/app/src/main/res/values-fi/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Arvostele %1$s + Jos pidät %1$s -sovelluksesta, anna meille viiden tähden arvostelu Google Play -palvelussa. + Arvostele nyt + Ei kiitos + \ No newline at end of file diff --git a/app/src/main/res/values-fr/text_imported.xml b/app/src/main/res/values-fr/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-fr/text_imported.xml rename to app/src/main/res/values-fr/text_imported_aosp.xml diff --git a/app/src/main/res/values-fr/text_imported_other.xml b/app/src/main/res/values-fr/text_imported_other.xml new file mode 100644 index 00000000..28cc4800 --- /dev/null +++ b/app/src/main/res/values-fr/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Noter %1$s + Si vous appréciez %1$s, prenez un moment et donnez nous 5 étoiles dans Google Play. + Noter maintenant + Non, merci + \ No newline at end of file diff --git a/app/src/main/res/values-it/text_imported.xml b/app/src/main/res/values-it/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-it/text_imported.xml rename to app/src/main/res/values-it/text_imported_aosp.xml diff --git a/app/src/main/res/values-it/text_imported_other.xml b/app/src/main/res/values-it/text_imported_other.xml new file mode 100644 index 00000000..0c5fbced --- /dev/null +++ b/app/src/main/res/values-it/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Valuta %1$s + Se ti piace %1$s, per favore dedica un minuto del tuo tempo per attribuirci 5 stelle su Google Play. + Vota adesso + No, grazie + \ No newline at end of file diff --git a/app/src/main/res/values-ja/text_imported.xml b/app/src/main/res/values-ja/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-ja/text_imported.xml rename to app/src/main/res/values-ja/text_imported_aosp.xml diff --git a/app/src/main/res/values-ja/text_imported_other.xml b/app/src/main/res/values-ja/text_imported_other.xml new file mode 100644 index 00000000..295c4909 --- /dev/null +++ b/app/src/main/res/values-ja/text_imported_other.xml @@ -0,0 +1,7 @@ + + + %1$s を評価する + %1$s を楽しまれている場合には、Google Play での評価にご協力ください。 + 今すぐ評価する + 今回はしない + \ No newline at end of file diff --git a/app/src/main/res/values-nl/text_imported.xml b/app/src/main/res/values-nl/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-nl/text_imported.xml rename to app/src/main/res/values-nl/text_imported_aosp.xml diff --git a/app/src/main/res/values-nl/text_imported_other.xml b/app/src/main/res/values-nl/text_imported_other.xml new file mode 100644 index 00000000..4fdfb597 --- /dev/null +++ b/app/src/main/res/values-nl/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Waardeer %1$s + Als je %1$s leuk vindt, neem dan even de tijd en geef ons een beoordeling van vijf sterren bij Google Play. + Nu beoordelen + Nee, bedankt + \ No newline at end of file diff --git a/app/src/main/res/values-pl/text_imported.xml b/app/src/main/res/values-pl/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-pl/text_imported.xml rename to app/src/main/res/values-pl/text_imported_aosp.xml diff --git a/app/src/main/res/values-pl/text_imported_other.xml b/app/src/main/res/values-pl/text_imported_other.xml new file mode 100644 index 00000000..51d48fa8 --- /dev/null +++ b/app/src/main/res/values-pl/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Oceń program %1$s + Jeśli podoba Ci się %1$s, poświęć chwilę i daj nam pięć gwiazdek w usłudze Google Play. + Oceń ją teraz + Nie, dziękuję + \ No newline at end of file diff --git a/app/src/main/res/values-pt-rBR/text_imported.xml b/app/src/main/res/values-pt-rBR/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-pt-rBR/text_imported.xml rename to app/src/main/res/values-pt-rBR/text_imported_aosp.xml diff --git a/app/src/main/res/values-pt-rBR/text_imported_other.xml b/app/src/main/res/values-pt-rBR/text_imported_other.xml new file mode 100644 index 00000000..c29703c0 --- /dev/null +++ b/app/src/main/res/values-pt-rBR/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Avaliar o %1$s + Se você gosta do %1$s, atribua a classificação de cinco estrelas no Google Play. + Classificar agora + Não, obrigado + \ No newline at end of file diff --git a/app/src/main/res/values-pt-rPT/text_imported.xml b/app/src/main/res/values-pt-rPT/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-pt-rPT/text_imported.xml rename to app/src/main/res/values-pt-rPT/text_imported_aosp.xml diff --git a/app/src/main/res/values-pt-rPT/text_imported_other.xml b/app/src/main/res/values-pt-rPT/text_imported_other.xml new file mode 100644 index 00000000..60f8ed7c --- /dev/null +++ b/app/src/main/res/values-pt-rPT/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Avalie %1$s + Se gosta de %1$s, por favor avalie-nos com cinco estrelas na Google Play. + Avaliar agora + Não, obrigado + \ No newline at end of file diff --git a/app/src/main/res/values-ru/text_imported.xml b/app/src/main/res/values-ru/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-ru/text_imported.xml rename to app/src/main/res/values-ru/text_imported_aosp.xml diff --git a/app/src/main/res/values-ru/text_imported_other.xml b/app/src/main/res/values-ru/text_imported_other.xml new file mode 100644 index 00000000..bddcabe4 --- /dev/null +++ b/app/src/main/res/values-ru/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Оцените %1$s + Если вам нравится %1$s, отвлекитесь на минутку и поставьте нам 5 звездочек в Google Play. + Оценить + Нет, спасибо + \ No newline at end of file diff --git a/app/src/main/res/values-tr/text_imported.xml b/app/src/main/res/values-tr/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-tr/text_imported.xml rename to app/src/main/res/values-tr/text_imported_aosp.xml diff --git a/app/src/main/res/values-tr/text_imported_other.xml b/app/src/main/res/values-tr/text_imported_other.xml new file mode 100644 index 00000000..7f835195 --- /dev/null +++ b/app/src/main/res/values-tr/text_imported_other.xml @@ -0,0 +1,7 @@ + + + %1$s\'yi değerlendir + %1$s\'yı sevdiyseniz, lütfen birkaç dakikanızı ayırın ve bize Google Play\'de beş yıldızlı bir puan verin. + Hemen değerlendirin + Hayır, teşekkürler + \ No newline at end of file diff --git a/app/src/main/res/values-vi/text_imported.xml b/app/src/main/res/values-vi/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-vi/text_imported.xml rename to app/src/main/res/values-vi/text_imported_aosp.xml diff --git a/app/src/main/res/values-vi/text_imported_other.xml b/app/src/main/res/values-vi/text_imported_other.xml new file mode 100644 index 00000000..03929500 --- /dev/null +++ b/app/src/main/res/values-vi/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Xếp hạng %1$s + Nếu bạn thích %1$s, vui lòng dành thời gian và xếp hạng chúng tôi 5 sao trong Google Play. + Xếp hạng nó bây giờ + Không, cảm ơn + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/text_imported.xml b/app/src/main/res/values-zh-rCN/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-zh-rCN/text_imported.xml rename to app/src/main/res/values-zh-rCN/text_imported_aosp.xml diff --git a/app/src/main/res/values-zh-rCN/text_imported_other.xml b/app/src/main/res/values-zh-rCN/text_imported_other.xml new file mode 100644 index 00000000..bd661b13 --- /dev/null +++ b/app/src/main/res/values-zh-rCN/text_imported_other.xml @@ -0,0 +1,7 @@ + + + 给 %1$s 评分 + 如果您喜欢 %1$s,请抽出片刻在 Google Play 中给我们五星评分。 + 立即给它评分 + 忍泪拒绝 + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/text_imported.xml b/app/src/main/res/values-zh-rTW/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values-zh-rTW/text_imported.xml rename to app/src/main/res/values-zh-rTW/text_imported_aosp.xml diff --git a/app/src/main/res/values-zh-rTW/text_imported_other.xml b/app/src/main/res/values-zh-rTW/text_imported_other.xml new file mode 100644 index 00000000..270ed184 --- /dev/null +++ b/app/src/main/res/values-zh-rTW/text_imported_other.xml @@ -0,0 +1,7 @@ + + + 為 %1$s 評分 + 如果你喜歡 %1$s,請花點時間在 Google Play 上給我們五顆星評價。 + 現在就去評分 + 不用了,謝謝 + \ No newline at end of file diff --git a/app/src/main/res/values/text_imported.xml b/app/src/main/res/values/text_imported_aosp.xml similarity index 100% rename from app/src/main/res/values/text_imported.xml rename to app/src/main/res/values/text_imported_aosp.xml diff --git a/app/src/main/res/values/text_imported_other.xml b/app/src/main/res/values/text_imported_other.xml new file mode 100644 index 00000000..ffa04df2 --- /dev/null +++ b/app/src/main/res/values/text_imported_other.xml @@ -0,0 +1,7 @@ + + + Rate %1$s + If you enjoy %1$s, please take a moment and give us a five-star rating in Google Play. + Rate it now + No, thanks + \ No newline at end of file diff --git a/translations/src/main/java/org/solovyev/android/translations/Android.java b/translations/src/main/java/org/solovyev/android/translations/Android.java index 4fbdf8a7..f16d55dc 100644 --- a/translations/src/main/java/org/solovyev/android/translations/Android.java +++ b/translations/src/main/java/org/solovyev/android/translations/Android.java @@ -49,6 +49,8 @@ public class Android { public static void main(String... args) throws Exception { final Options options = new Options(); options.addOption(Option.builder("aosp").hasArg().desc("Local location of aosp project").required().build()); + options.addOption(Option.builder("project").hasArg().desc("Local location of Android project").build()); + options.addOption(Option.builder("resources").hasArg().desc("String identifiers to be copied").build()); final CommandLineParser parser = new DefaultParser(); final CommandLine commandLine = parser.parse(options, args); @@ -59,19 +61,43 @@ public class Android { final File aospContacts = makeInputDirectory(aosp + "/platform/packages/apps/contacts"); final File aospCalculator = makeInputDirectory(aosp + "/platform/packages/apps/calculator"); + final File project; + if (commandLine.hasOption("project")) { + project = makeInputDirectory(commandLine.getOptionValue("project")); + } else { + project = null; + } + final List projectLinks = new ArrayList<>(); + if (commandLine.hasOption("resources")) { + for (String resource : commandLine.getOptionValue("resources").split(",")) { + final int i = resource.indexOf("-"); + if(i >= 0) { + projectLinks.add(new TranslationLink(resource.substring(0, i), "cpp_" + resource.substring(i + 1, resource.length()))); + } else { + projectLinks.add(new TranslationLink(resource, "cpp_" + resource)); + } + } + } + final File outDir = new File("build/translations/res"); Utils.delete(outDir); outDir.mkdirs(); + translate(outDir, "aosp", new TranslationDef(aospSettings, settingsLinks), new TranslationDef(aospCalendar, calendarLinks), new TranslationDef(aospContacts, contactsLinks), new TranslationDef(aospCalculator, calculatorLinks)); + if (project != null) { + translate(outDir, "other", new TranslationDef(project, projectLinks)); + } + } + + private static void translate(File outDir, String outPostfix, TranslationDef... translationDefs) throws Exception { List languageLocales = new ArrayList<>(Utils.languageLocales); languageLocales.add(""); for (String languageLocale : languageLocales) { Resources translations = new Resources(); - translate(readResources(aospSettings, languageLocale), translations, settingsLinks); - translate(readResources(aospCalendar, languageLocale), translations, calendarLinks); - translate(readResources(aospContacts, languageLocale), translations, contactsLinks); - translate(readResources(aospCalculator, languageLocale), translations, calculatorLinks); - Utils.saveTranslations(translations, languageLocale, outDir, "text_imported.xml"); + for (TranslationDef def : translationDefs) { + translate(readResources(def.project, languageLocale), translations, def.links); + } + Utils.saveTranslations(translations, languageLocale, outDir, "text_imported_" + outPostfix + ".xml"); } } @@ -124,6 +150,15 @@ public class Android { return null; } + private static class TranslationDef { + public final File project; + public final List links; + + private TranslationDef(File project, List links) { + this.project = project; + this.links = links; + } + } private static class TranslationLink { public final String inName; public final String outName;