Add language
This commit is contained in:
parent
44d2c694ee
commit
b24dd5541a
3 changed files with 30 additions and 16 deletions
|
@ -4,6 +4,8 @@ package net.osmand.plus.activities;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
@ -35,6 +37,7 @@ public class SettingsActivity extends SettingsBaseActivity {
|
||||||
public static final int SCREEN_NAVIGATION_SETTINGS = 2;
|
public static final int SCREEN_NAVIGATION_SETTINGS = 2;
|
||||||
|
|
||||||
private static final int PLUGINS_SELECTION_REQUEST = 1;
|
private static final int PLUGINS_SELECTION_REQUEST = 1;
|
||||||
|
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
|
||||||
|
|
||||||
|
|
||||||
private Preference bidforfix;
|
private Preference bidforfix;
|
||||||
|
@ -127,17 +130,22 @@ public class SettingsActivity extends SettingsBaseActivity {
|
||||||
private void showAboutDialog() {
|
private void showAboutDialog() {
|
||||||
Builder bld = new AlertDialog.Builder(this);
|
Builder bld = new AlertDialog.Builder(this);
|
||||||
bld.setTitle(R.string.about_settings);
|
bld.setTitle(R.string.about_settings);
|
||||||
|
ScrollView sv = new ScrollView(this);
|
||||||
TextView tv = new TextView(this);
|
TextView tv = new TextView(this);
|
||||||
|
sv.addView(tv);
|
||||||
String version = Version.getFullVersion(getMyApplication());
|
String version = Version.getFullVersion(getMyApplication());
|
||||||
String vt = getString(R.string.about_version) +"\t";
|
String vt = getString(R.string.about_version) +"\t";
|
||||||
int st = vt.length();
|
int st = vt.length();
|
||||||
String edition = "";
|
String edition = "";
|
||||||
|
SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
|
||||||
|
if (prefs.contains(CONTRIBUTION_VERSION_FLAG)) {
|
||||||
try {
|
try {
|
||||||
PackageManager pm = getPackageManager();
|
PackageManager pm = getPackageManager();
|
||||||
ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
|
ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
|
||||||
Date date = new Date(new File(appInfo.sourceDir).lastModified());
|
Date date = new Date(new File(appInfo.sourceDir).lastModified());
|
||||||
edition = getString(R.string.local_index_installed) +" :\t" + DateFormat.getDateFormat(getApplicationContext()).format(date);
|
edition = getString(R.string.local_index_installed) + " :\t" + DateFormat.getDateFormat(getApplicationContext()).format(date);
|
||||||
} catch(Exception e) {
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SpannableString content = new SpannableString(vt + version +"\n" +
|
SpannableString content = new SpannableString(vt + version +"\n" +
|
||||||
edition +"\n\n"+
|
edition +"\n\n"+
|
||||||
|
@ -154,7 +162,7 @@ public class SettingsActivity extends SettingsBaseActivity {
|
||||||
tv.setPadding(5, 0, 5, 5);
|
tv.setPadding(5, 0, 5, 5);
|
||||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
|
||||||
tv.setMovementMethod(LinkMovementMethod.getInstance());
|
tv.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
bld.setView(tv);
|
bld.setView(sv);
|
||||||
bld.setPositiveButton(R.string.default_buttons_ok, null);
|
bld.setPositiveButton(R.string.default_buttons_ok, null);
|
||||||
bld.show();
|
bld.show();
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,10 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
|
||||||
/** Must be sorted array! */
|
/** Must be sorted array! */
|
||||||
private final int[] sortedVoiceVersions;
|
private final int[] sortedVoiceVersions;
|
||||||
private AudioFocusHelper mAudioFocusHelper;
|
private AudioFocusHelper mAudioFocusHelper;
|
||||||
|
protected String language = "";
|
||||||
|
|
||||||
protected int streamType;
|
protected int streamType;
|
||||||
|
T
|
||||||
protected AbstractPrologCommandPlayer(ClientContext ctx, String voiceProvider, String configFile, int[] sortedVoiceVersions)
|
protected AbstractPrologCommandPlayer(ClientContext ctx, String voiceProvider, String configFile, int[] sortedVoiceVersions)
|
||||||
throws CommandPlayerException
|
throws CommandPlayerException
|
||||||
{
|
{
|
||||||
|
@ -72,7 +73,17 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
|
||||||
}
|
}
|
||||||
this.streamType = ctx.getSettings().AUDIO_STREAM_GUIDANCE.get();
|
this.streamType = ctx.getSettings().AUDIO_STREAM_GUIDANCE.get();
|
||||||
init(voiceProvider, ctx.getSettings(), configFile);
|
init(voiceProvider, ctx.getSettings(), configFile);
|
||||||
|
final Term langVal = solveSimplePredicate("language");
|
||||||
|
if (langVal instanceof Struct) {
|
||||||
|
language = ((Struct) langVal).getName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String[] getLibraries(){
|
public String[] getLibraries(){
|
||||||
return new String[] { "alice.tuprolog.lib.BasicLibrary",
|
return new String[] { "alice.tuprolog.lib.BasicLibrary",
|
||||||
|
|
|
@ -64,16 +64,11 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
||||||
private static final Log log = PlatformUtil.getLog(TTSCommandPlayerImpl.class);
|
private static final Log log = PlatformUtil.getLog(TTSCommandPlayerImpl.class);
|
||||||
private TextToSpeech mTts;
|
private TextToSpeech mTts;
|
||||||
private Context mTtsContext;
|
private Context mTtsContext;
|
||||||
private String language;
|
|
||||||
private HashMap<String, String> params = new HashMap<String, String>();
|
private HashMap<String, String> params = new HashMap<String, String>();
|
||||||
|
|
||||||
protected TTSCommandPlayerImpl(Activity ctx, String voiceProvider)
|
protected TTSCommandPlayerImpl(Activity ctx, String voiceProvider)
|
||||||
throws CommandPlayerException {
|
throws CommandPlayerException {
|
||||||
super((OsmandApplication) ctx.getApplicationContext(), voiceProvider, CONFIG_FILE, TTS_VOICE_VERSION);
|
super((OsmandApplication) ctx.getApplicationContext(), voiceProvider, CONFIG_FILE, TTS_VOICE_VERSION);
|
||||||
final Term langVal = solveSimplePredicate("language");
|
|
||||||
if (langVal instanceof Struct) {
|
|
||||||
language = ((Struct) langVal).getName();
|
|
||||||
}
|
|
||||||
if (Algorithms.isEmpty(language)) {
|
if (Algorithms.isEmpty(language)) {
|
||||||
throw new CommandPlayerException(
|
throw new CommandPlayerException(
|
||||||
ctx.getString(R.string.voice_data_corrupted));
|
ctx.getString(R.string.voice_data_corrupted));
|
||||||
|
|
Loading…
Reference in a new issue