Add language

This commit is contained in:
vshcherb 2013-08-28 09:41:43 +02:00
parent 44d2c694ee
commit b24dd5541a
3 changed files with 30 additions and 16 deletions

View file

@ -4,6 +4,8 @@ package net.osmand.plus.activities;
import java.io.File;
import java.util.Date;
import android.content.SharedPreferences;
import android.widget.ScrollView;
import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
@ -35,6 +37,7 @@ public class SettingsActivity extends SettingsBaseActivity {
public static final int SCREEN_NAVIGATION_SETTINGS = 2;
private static final int PLUGINS_SELECTION_REQUEST = 1;
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
private Preference bidforfix;
@ -127,17 +130,22 @@ public class SettingsActivity extends SettingsBaseActivity {
private void showAboutDialog() {
Builder bld = new AlertDialog.Builder(this);
bld.setTitle(R.string.about_settings);
ScrollView sv = new ScrollView(this);
TextView tv = new TextView(this);
sv.addView(tv);
String version = Version.getFullVersion(getMyApplication());
String vt = getString(R.string.about_version) +"\t";
int st = vt.length();
String edition = "";
SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
if (prefs.contains(CONTRIBUTION_VERSION_FLAG)) {
try {
PackageManager pm = getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
Date date = new Date(new File(appInfo.sourceDir).lastModified());
edition = getString(R.string.local_index_installed) +" :\t" + DateFormat.getDateFormat(getApplicationContext()).format(date);
} catch(Exception e) {
edition = getString(R.string.local_index_installed) + " :\t" + DateFormat.getDateFormat(getApplicationContext()).format(date);
} catch (Exception e) {
}
}
SpannableString content = new SpannableString(vt + version +"\n" +
edition +"\n\n"+
@ -154,7 +162,7 @@ public class SettingsActivity extends SettingsBaseActivity {
tv.setPadding(5, 0, 5, 5);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
tv.setMovementMethod(LinkMovementMethod.getInstance());
bld.setView(tv);
bld.setView(sv);
bld.setPositiveButton(R.string.default_buttons_ok, null);
bld.show();

View file

@ -51,9 +51,10 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
/** Must be sorted array! */
private final int[] sortedVoiceVersions;
private AudioFocusHelper mAudioFocusHelper;
protected String language = "";
protected int streamType;
T
protected AbstractPrologCommandPlayer(ClientContext ctx, String voiceProvider, String configFile, int[] sortedVoiceVersions)
throws CommandPlayerException
{
@ -72,7 +73,17 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer {
}
this.streamType = ctx.getSettings().AUDIO_STREAM_GUIDANCE.get();
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(){
return new String[] { "alice.tuprolog.lib.BasicLibrary",

View file

@ -64,16 +64,11 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
private static final Log log = PlatformUtil.getLog(TTSCommandPlayerImpl.class);
private TextToSpeech mTts;
private Context mTtsContext;
private String language;
private HashMap<String, String> params = new HashMap<String, String>();
protected TTSCommandPlayerImpl(Activity ctx, String voiceProvider)
throws CommandPlayerException {
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)) {
throw new CommandPlayerException(
ctx.getString(R.string.voice_data_corrupted));