Merge branch 'master' of ssh://github.com/osmandapp/Osmand into LiveNowUiImprovements
This commit is contained in:
commit
82987dd237
7 changed files with 44 additions and 6 deletions
|
@ -90,7 +90,7 @@ object AndroidUtils {
|
|||
val paint = Paint().apply { textSize = txtSize.toFloat() }
|
||||
val maxTextWidth = titles.map { paint.measureText(it) }.max()
|
||||
if (maxTextWidth != null) {
|
||||
val maxItemWidth = maxTextWidth.toInt() + AndroidUtils.dpToPx(ctx, 33f)
|
||||
val maxItemWidth = maxTextWidth.toInt() + AndroidUtils.dpToPx(ctx, 34f)
|
||||
val minWidth = AndroidUtils.dpToPx(ctx, 100f)
|
||||
return maxOf(minWidth, maxItemWidth)
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ object OsmandFormatter {
|
|||
fun getFormattedDuration(ctx: Context, seconds: Int, short: Boolean = false): String {
|
||||
val hours = seconds / (60 * 60)
|
||||
val minutes = seconds / 60 % 60
|
||||
val secs = seconds - minutes * 60
|
||||
if (short) {
|
||||
return String.format(SHORT_TIME_FORMAT, hours, minutes)
|
||||
}
|
||||
|
@ -47,7 +48,13 @@ object OsmandFormatter {
|
|||
}
|
||||
res
|
||||
}
|
||||
minutes > 0 -> "$minutes ${ctx.getString(R.string.shared_string_minute_short)}"
|
||||
minutes > 0 -> {
|
||||
var res = "$minutes ${ctx.getString(R.string.shared_string_minute_short)}"
|
||||
if (secs > 0) {
|
||||
res += " $secs ${ctx.getString(R.string.shared_string_second_short)}"
|
||||
}
|
||||
res
|
||||
}
|
||||
else -> "$seconds ${ctx.getString(R.string.shared_string_second_short)}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.content.res.Configuration;
|
|||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -69,6 +70,7 @@ import java.util.Locale;
|
|||
import java.util.Random;
|
||||
|
||||
import btools.routingapp.BRouterServiceConnection;
|
||||
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
|
||||
|
@ -84,6 +86,8 @@ public class AppInitializer implements IProgress {
|
|||
public static final int VERSION_2_2 = 22;
|
||||
// 23 - 2.3
|
||||
public static final int VERSION_2_3 = 23;
|
||||
// 32 - 3.2
|
||||
public static final int VERSION_3_2 = 32;
|
||||
|
||||
|
||||
public static final boolean TIPS_AND_TRICKS = false;
|
||||
|
@ -164,7 +168,7 @@ public class AppInitializer implements IProgress {
|
|||
firstTime = true;
|
||||
startPrefs.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
|
||||
} else if (!Version.getFullVersion(app).equals(startPrefs.getString(VERSION_INSTALLED, ""))) {
|
||||
prevAppVersion = startPrefs.getInt(VERSION_INSTALLED_NUMBER, 0);
|
||||
if(prevAppVersion < VERSION_2_2) {
|
||||
|
@ -175,6 +179,9 @@ public class AppInitializer implements IProgress {
|
|||
}
|
||||
if(prevAppVersion < VERSION_2_3) {
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_2_3).commit();
|
||||
} else if (prevAppVersion < VERSION_3_2) {
|
||||
app.getResourceManager().copyMissingJSAssets();
|
||||
startPrefs.edit().putInt(VERSION_INSTALLED_NUMBER, VERSION_3_2).commit();
|
||||
}
|
||||
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
|
||||
appVersionChanged = true;
|
||||
|
|
|
@ -67,6 +67,9 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
useJSVoiceGuidanceListener = new StateChangedListener<Boolean>() {
|
||||
@Override
|
||||
public void stateChanged(Boolean change) {
|
||||
if (change) {
|
||||
getMyApplication().getResourceManager().copyMissingJSAssets();
|
||||
}
|
||||
getMyApplication().getDownloadThread().runReloadIndexFilesSilent();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -251,7 +251,7 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
|
|||
addButton(ll, "Roundabouts: prepareTurn, makeTurnIn, turn:", builder(p));
|
||||
addButton(ll, "\u25BA (5.1) After 1250m enter a roundabout", !isJS ? builder(p).prepareRoundAbout(1250, 3, street(p,"", "I 15", "Los Angeles")) :
|
||||
jsBuilder(p).prepareRoundAbout(1250, 3, jsStreet(p,"", "I 15", "Los Angeles")));
|
||||
addButton(ll, "\u25BA (5.2) In 450m enter the roundabout and take the 1st exit onto 'I 15' toward 'Los Angeles'", isJS ? builder(p).roundAbout(450, 0, 1, street(p,"", "I 15", "Los Angeles")) :
|
||||
addButton(ll, "\u25BA (5.2) In 450m enter the roundabout and take the 1st exit onto 'I 15' toward 'Los Angeles'", !isJS ? builder(p).roundAbout(450, 0, 1, street(p,"", "I 15", "Los Angeles")) :
|
||||
jsBuilder(p).roundAbout(450, 0, 1, jsStreet(p,"", "I 15", "Los Angeles")));
|
||||
addButton(ll, "\u25BA (5.3) Roundabout: Take the 2nd exit onto 'Highway 60'", !isJS ? builder(p).roundAbout(0, 2, street(p, "Highway 60")) :
|
||||
jsBuilder(p).roundAbout(0, 2, jsStreet(p, "Highway 60")));
|
||||
|
|
|
@ -124,7 +124,7 @@ public class DownloadOsmandIndexesHelper {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, String> assetMapping(AssetManager assetManager) throws XmlPullParserException, IOException {
|
||||
public static Map<String, String> assetMapping(AssetManager assetManager) throws XmlPullParserException, IOException {
|
||||
XmlPullParser xmlParser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
InputStream isBundledAssetsXml = assetManager.open("bundled_assets.xml");
|
||||
xmlParser.setInput(isBundledAssetsXml, "UTF-8");
|
||||
|
@ -141,7 +141,7 @@ public class DownloadOsmandIndexesHelper {
|
|||
return assets;
|
||||
}
|
||||
|
||||
private static void listVoiceAssets(IndexFileList result, AssetManager amanager, PackageManager pm,
|
||||
private static void listVoiceAssets(IndexFileList result, AssetManager amanager, PackageManager pm,
|
||||
OsmandSettings settings) {
|
||||
try {
|
||||
String ext = DownloadActivityType.addVersionToExt(IndexConstants.TTSVOICE_INDEX_EXT_ZIP, IndexConstants.TTSVOICE_VERSION);
|
||||
|
|
|
@ -68,6 +68,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static net.osmand.plus.download.DownloadOsmandIndexesHelper.assetMapping;
|
||||
|
||||
/**
|
||||
* Resource manager is responsible to work with all resources
|
||||
* that could consume memory (especially with file resources).
|
||||
|
@ -418,6 +420,25 @@ public class ResourceManager {
|
|||
}
|
||||
return warnings;
|
||||
}
|
||||
|
||||
public void copyMissingJSAssets() {
|
||||
try {
|
||||
Map<String, String> mapping = assetMapping(context.getAssets());
|
||||
File appPath = context.getAppPath(null);
|
||||
if (appPath.canWrite()) {
|
||||
for (Map.Entry<String,String> entry : mapping.entrySet()) {
|
||||
File jsFile = new File(appPath, entry.getValue());
|
||||
if (jsFile.getParentFile().exists() && !jsFile.exists()) {
|
||||
ResourceManager.copyAssets(context.getAssets(), entry.getKey(), jsFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (XmlPullParserException e) {
|
||||
log.error("Error while loading tts files from assets", e);
|
||||
} catch (IOException e) {
|
||||
log.error("Error while loading tts files from assets", e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> checkAssets(IProgress progress, boolean forceUpdate) {
|
||||
String fv = Version.getFullVersion(context);
|
||||
|
|
Loading…
Reference in a new issue