Translations + rate us dialog
This commit is contained in:
parent
6f685f4a2a
commit
6427c91953
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2013 serso aka se.solovyev
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ Contact details
|
||||
~
|
||||
~ Email: se.solovyev@gmail.com
|
||||
~ Site: http://se.solovyev.org
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent">
|
||||
|
||||
<TextView
|
||||
a:id="@+id/feedbackText"
|
||||
style="@style/CppText.About"
|
||||
a:layout_width="fill_parent"
|
||||
a:layout_height="fill_parent"
|
||||
a:text="@string/c_feedback_text" />
|
||||
|
||||
</LinearLayout>
|
7
app/src/main/res/values-ar/text_imported_other.xml
Normal file
7
app/src/main/res/values-ar/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">تقييم %1$s</string>
|
||||
<string name="cpp_rateus_message">إذا كنت تستمتع بـ %1$s، يرجى أن تستغرق لحظة وتعطينا تقييمًا بخمس نجوم في Google Play.</string>
|
||||
<string name="cpp_rateus_ok">ضع تقييمًا الآن</string>
|
||||
<string name="cpp_rateus_cancel">لا، شكرًا</string>
|
||||
</resources>
|
7
app/src/main/res/values-cs/text_imported_other.xml
Normal file
7
app/src/main/res/values-cs/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Ohodnotit aplikaci %1$s</string>
|
||||
<string name="cpp_rateus_message">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.</string>
|
||||
<string name="cpp_rateus_ok">Ohodnotit nyní</string>
|
||||
<string name="cpp_rateus_cancel">Ne, díky</string>
|
||||
</resources>
|
7
app/src/main/res/values-de/text_imported_other.xml
Normal file
7
app/src/main/res/values-de/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">%1$s bewerten</string>
|
||||
<string name="cpp_rateus_message">Wenn Ihnen %1$s gefällt, würden wir uns über Ihre Fünf-Sterne-Bewertung in Google Play freuen.</string>
|
||||
<string name="cpp_rateus_ok">Jetzt bewerten</string>
|
||||
<string name="cpp_rateus_cancel">Nein danke</string>
|
||||
</resources>
|
7
app/src/main/res/values-es/text_imported_other.xml
Normal file
7
app/src/main/res/values-es/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Califica %1$s</string>
|
||||
<string name="cpp_rateus_message">Si disfrutas usar %1$s, por favor dedica un instante y regálanos una calificación de cinco estrellas en Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Danos tu calificación</string>
|
||||
<string name="cpp_rateus_cancel">No, gracias</string>
|
||||
</resources>
|
7
app/src/main/res/values-fi/text_imported_other.xml
Normal file
7
app/src/main/res/values-fi/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Arvostele %1$s</string>
|
||||
<string name="cpp_rateus_message">Jos pidät %1$s -sovelluksesta, anna meille viiden tähden arvostelu Google Play -palvelussa.</string>
|
||||
<string name="cpp_rateus_ok">Arvostele nyt</string>
|
||||
<string name="cpp_rateus_cancel">Ei kiitos</string>
|
||||
</resources>
|
7
app/src/main/res/values-fr/text_imported_other.xml
Normal file
7
app/src/main/res/values-fr/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Noter %1$s</string>
|
||||
<string name="cpp_rateus_message">Si vous appréciez %1$s, prenez un moment et donnez nous 5 étoiles dans Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Noter maintenant</string>
|
||||
<string name="cpp_rateus_cancel">Non, merci</string>
|
||||
</resources>
|
7
app/src/main/res/values-it/text_imported_other.xml
Normal file
7
app/src/main/res/values-it/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Valuta %1$s</string>
|
||||
<string name="cpp_rateus_message">Se ti piace %1$s, per favore dedica un minuto del tuo tempo per attribuirci 5 stelle su Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Vota adesso</string>
|
||||
<string name="cpp_rateus_cancel">No, grazie</string>
|
||||
</resources>
|
7
app/src/main/res/values-ja/text_imported_other.xml
Normal file
7
app/src/main/res/values-ja/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">%1$s を評価する</string>
|
||||
<string name="cpp_rateus_message">%1$s を楽しまれている場合には、Google Play での評価にご協力ください。</string>
|
||||
<string name="cpp_rateus_ok">今すぐ評価する</string>
|
||||
<string name="cpp_rateus_cancel">今回はしない</string>
|
||||
</resources>
|
7
app/src/main/res/values-nl/text_imported_other.xml
Normal file
7
app/src/main/res/values-nl/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Waardeer %1$s</string>
|
||||
<string name="cpp_rateus_message">Als je %1$s leuk vindt, neem dan even de tijd en geef ons een beoordeling van vijf sterren bij Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Nu beoordelen</string>
|
||||
<string name="cpp_rateus_cancel">Nee, bedankt</string>
|
||||
</resources>
|
7
app/src/main/res/values-pl/text_imported_other.xml
Normal file
7
app/src/main/res/values-pl/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Oceń program %1$s</string>
|
||||
<string name="cpp_rateus_message">Jeśli podoba Ci się %1$s, poświęć chwilę i daj nam pięć gwiazdek w usłudze Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Oceń ją teraz</string>
|
||||
<string name="cpp_rateus_cancel">Nie, dziękuję</string>
|
||||
</resources>
|
7
app/src/main/res/values-pt-rBR/text_imported_other.xml
Normal file
7
app/src/main/res/values-pt-rBR/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Avaliar o %1$s</string>
|
||||
<string name="cpp_rateus_message">Se você gosta do %1$s, atribua a classificação de cinco estrelas no Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Classificar agora</string>
|
||||
<string name="cpp_rateus_cancel">Não, obrigado</string>
|
||||
</resources>
|
7
app/src/main/res/values-pt-rPT/text_imported_other.xml
Normal file
7
app/src/main/res/values-pt-rPT/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Avalie %1$s</string>
|
||||
<string name="cpp_rateus_message">Se gosta de %1$s, por favor avalie-nos com cinco estrelas na Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Avaliar agora</string>
|
||||
<string name="cpp_rateus_cancel">Não, obrigado</string>
|
||||
</resources>
|
7
app/src/main/res/values-ru/text_imported_other.xml
Normal file
7
app/src/main/res/values-ru/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Оцените %1$s</string>
|
||||
<string name="cpp_rateus_message">Если вам нравится %1$s, отвлекитесь на минутку и поставьте нам 5 звездочек в Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Оценить</string>
|
||||
<string name="cpp_rateus_cancel">Нет, спасибо</string>
|
||||
</resources>
|
7
app/src/main/res/values-tr/text_imported_other.xml
Normal file
7
app/src/main/res/values-tr/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">%1$s\'yi değerlendir</string>
|
||||
<string name="cpp_rateus_message">%1$s\'yı sevdiyseniz, lütfen birkaç dakikanızı ayırın ve bize Google Play\'de beş yıldızlı bir puan verin.</string>
|
||||
<string name="cpp_rateus_ok">Hemen değerlendirin</string>
|
||||
<string name="cpp_rateus_cancel">Hayır, teşekkürler</string>
|
||||
</resources>
|
7
app/src/main/res/values-vi/text_imported_other.xml
Normal file
7
app/src/main/res/values-vi/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Xếp hạng %1$s</string>
|
||||
<string name="cpp_rateus_message">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.</string>
|
||||
<string name="cpp_rateus_ok">Xếp hạng nó bây giờ</string>
|
||||
<string name="cpp_rateus_cancel">Không, cảm ơn</string>
|
||||
</resources>
|
7
app/src/main/res/values-zh-rCN/text_imported_other.xml
Normal file
7
app/src/main/res/values-zh-rCN/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">给 %1$s 评分</string>
|
||||
<string name="cpp_rateus_message">如果您喜欢 %1$s,请抽出片刻在 Google Play 中给我们五星评分。</string>
|
||||
<string name="cpp_rateus_ok">立即给它评分</string>
|
||||
<string name="cpp_rateus_cancel">忍泪拒绝</string>
|
||||
</resources>
|
7
app/src/main/res/values-zh-rTW/text_imported_other.xml
Normal file
7
app/src/main/res/values-zh-rTW/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">為 %1$s 評分</string>
|
||||
<string name="cpp_rateus_message">如果你喜歡 %1$s,請花點時間在 Google Play 上給我們五顆星評價。</string>
|
||||
<string name="cpp_rateus_ok">現在就去評分</string>
|
||||
<string name="cpp_rateus_cancel">不用了,謝謝</string>
|
||||
</resources>
|
7
app/src/main/res/values/text_imported_other.xml
Normal file
7
app/src/main/res/values/text_imported_other.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="cpp_rateus_title">Rate %1$s</string>
|
||||
<string name="cpp_rateus_message">If you enjoy %1$s, please take a moment and give us a five-star rating in Google Play.</string>
|
||||
<string name="cpp_rateus_ok">Rate it now</string>
|
||||
<string name="cpp_rateus_cancel">No, thanks</string>
|
||||
</resources>
|
@ -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<TranslationLink> 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<String> 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 <TranslationLink> links;
|
||||
|
||||
private TranslationDef(File project, List<TranslationLink> links) {
|
||||
this.project = project;
|
||||
this.links = links;
|
||||
}
|
||||
}
|
||||
private static class TranslationLink {
|
||||
public final String inName;
|
||||
public final String outName;
|
||||
|
Loading…
Reference in New Issue
Block a user