Commit c905ca41 authored by Grigory Fedorov's avatar Grigory Fedorov

TranslationDialog added: if current locale is not translated (and not English)...

TranslationDialog added: if current locale is not translated (and not English) - user is suggested to help with translations.
parent 4fbba9f7
......@@ -519,6 +519,14 @@ public class SettingsManager implements OnInitializedListener,
setBoolean(R.string.contact_integration_suggested_key, true);
}
public static boolean isTranslationSuggested() {
return getBoolean(R.string.translation_suggested_key, false);
}
public static void setTranslationSuggested() {
setBoolean(R.string.translation_suggested_key, true);
}
/**
* @return Common status mode for all accounts or
* {@link StatusMode#available} if mode was not set.
......
......@@ -62,6 +62,7 @@ import com.xabber.android.ui.dialog.AccountChooseDialogFragment;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener;
import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
import com.xabber.android.ui.dialog.StartAtBootDialogFragment;
import com.xabber.android.ui.dialog.TranslationDialog;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.AboutViewer;
......@@ -73,6 +74,7 @@ import com.xabber.xmpp.uri.XMPPUri;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Locale;
/**
* Main application activity.
......@@ -310,6 +312,14 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
}
if (Application.getInstance().doNotify()) {
if (!SettingsManager.isTranslationSuggested()) {
Locale currentLocale = getResources().getConfiguration().locale;
if (!currentLocale.getLanguage().equals("en") && !getResources().getBoolean(R.bool.is_translated)) {
new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG");
SettingsManager.setTranslationSuggested();
}
}
if (SettingsManager.bootCount() > 2 && !SettingsManager.connectionStartAtBoot()
&& !SettingsManager.startAtBootSuggested()) {
StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
......
package com.xabber.android.ui.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.xabber.android.R;
public class TranslationDialog extends DialogFragment implements DialogInterface.OnClickListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.translation_unavailable)
.setMessage(R.string.translation_unavailable_message)
.setNegativeButton(R.string.help_translate_xabber, this)
.setPositiveButton(android.R.string.no, this)
.setCancelable(false)
.create();
}
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case Dialog.BUTTON_NEGATIVE:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(getString(R.string.translation_url)));
startActivity(i);
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_translated">true</bool>
</resources>
\ No newline at end of file
......@@ -11,4 +11,10 @@
<string name="about_license">License: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Open source software</a></string>
<string name="about_open_source_xmpp_client">open source XMPP client</string>
<string name="translation_unavailable">Translation unavailable</string>
<string name="translation_unavailable_message">Unfortunately, Xabber does not have a translation to your language, but you can help us fix that.\nXabber is open-source, and all translations are provided by community, and it is easy to join.</string>
<string name="help_translate_xabber">Help translate Xabber</string>
<string name="translation_url">https://crowdin.com/project/xabber</string>
</resources>
\ No newline at end of file
......@@ -501,6 +501,7 @@
<string name="boot_count_key">boot_count</string>
<string name="start_at_boot_suggested_key">start_at_boot_suggested</string>
<string name="contact_integration_suggested_key">contact_integration_suggested</string>
<string name="translation_suggested_key">translation_suggested</string>
<string name="sync_account_type">@string/application_package</string>
<string name="contact_viewer_mime_type">vnd.android.cursor.item/vnd.com.xabber.view</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="is_translated">false</bool>
</resources>
\ No newline at end of file
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