add contribution version changes
This commit is contained in:
parent
167469f450
commit
66634c0c8b
13 changed files with 166 additions and 51 deletions
|
@ -15,3 +15,6 @@
|
||||||
# 'key.alias' for the name of the key to use.
|
# 'key.alias' for the name of the key to use.
|
||||||
# The password will be asked during the build when you use the 'release' target.
|
# The password will be asked during the build when you use the 'release' target.
|
||||||
jar.libs.dir=lib
|
jar.libs.dir=lib
|
||||||
|
|
||||||
|
key.store=../../osmand_key
|
||||||
|
key.alias=osmand
|
||||||
|
|
12
OsmAnd/local.properties
Normal file
12
OsmAnd/local.properties
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must *NOT* be checked in Version Control Systems,
|
||||||
|
# as it contains information specific to your local configuration.
|
||||||
|
|
||||||
|
# location of the SDK. This is only used by Ant
|
||||||
|
# For customization when using a Version Control System, please read the
|
||||||
|
# header note.
|
||||||
|
sdk.dir=/home/victor/Projects/android-sdk-linux_86
|
||||||
|
FTP_USER=osmand
|
||||||
|
FTP_PWD=
|
|
@ -316,7 +316,6 @@
|
||||||
<string name="settings_activity">Nastavení</string>
|
<string name="settings_activity">Nastavení</string>
|
||||||
<string name="show_gps_coordinates_text">Ukázat GPS souřadnice na mapě</string>
|
<string name="show_gps_coordinates_text">Ukázat GPS souřadnice na mapě</string>
|
||||||
<string name="use_internet_to_download_tile">Stahovat chybějící části mapy z internetu</string>
|
<string name="use_internet_to_download_tile">Stahovat chybějící části mapy z internetu</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Navigační aplikace</string>
|
<string name="app_description">Navigační aplikace</string>
|
||||||
|
|
||||||
<string name="exit_Button">Konec</string>
|
<string name="exit_Button">Konec</string>
|
||||||
|
|
|
@ -243,7 +243,6 @@ See osmand.net.</string>
|
||||||
<string name="settings_activity">Einstellungen</string>
|
<string name="settings_activity">Einstellungen</string>
|
||||||
<string name="show_gps_coordinates_text">GPS-Koordinaten auf der Karte anzeigen</string>
|
<string name="show_gps_coordinates_text">GPS-Koordinaten auf der Karte anzeigen</string>
|
||||||
<string name="use_internet_to_download_tile">Fehlende Kartenteile aus dem Internet nachladen</string>
|
<string name="use_internet_to_download_tile">Fehlende Kartenteile aus dem Internet nachladen</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Navigationsanwendung OsmAnd</string>
|
<string name="app_description">Navigationsanwendung OsmAnd</string>
|
||||||
|
|
||||||
<string name="exit_Button">Beenden</string>
|
<string name="exit_Button">Beenden</string>
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
<string name="app_mode_car">Auto</string>
|
<string name="app_mode_car">Auto</string>
|
||||||
<string name="app_mode_default">Predeterminado</string>
|
<string name="app_mode_default">Predeterminado</string>
|
||||||
<string name="app_mode_pedestrian">Peatón</string>
|
<string name="app_mode_pedestrian">Peatón</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_settings">Configuraciones</string>
|
<string name="app_settings">Configuraciones</string>
|
||||||
<string name="arrived_at_destination">Llegó a su destino</string>
|
<string name="arrived_at_destination">Llegó a su destino</string>
|
||||||
<string name="auth_failed"> Fallo de autorización</string>
|
<string name="auth_failed"> Fallo de autorización</string>
|
||||||
|
|
|
@ -322,7 +322,6 @@
|
||||||
<string name="settings_activity">Paramètres</string>
|
<string name="settings_activity">Paramètres</string>
|
||||||
<string name="show_gps_coordinates_text">Afficher les coordonnées GPS sur la carte</string>
|
<string name="show_gps_coordinates_text">Afficher les coordonnées GPS sur la carte</string>
|
||||||
<string name="use_internet_to_download_tile">Utiliser internet pour télécharger les carreaux manquantes</string>
|
<string name="use_internet_to_download_tile">Utiliser internet pour télécharger les carreaux manquantes</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Application de navigation</string>
|
<string name="app_description">Application de navigation</string>
|
||||||
<string name="exit_Button">Quitter</string>
|
<string name="exit_Button">Quitter</string>
|
||||||
<string name="map_Button">Carte</string>
|
<string name="map_Button">Carte</string>
|
||||||
|
|
|
@ -321,7 +321,6 @@
|
||||||
<string name="settings_activity">Beállítások</string>
|
<string name="settings_activity">Beállítások</string>
|
||||||
<string name="show_gps_coordinates_text">GPS koordináták mutatása a térképen</string>
|
<string name="show_gps_coordinates_text">GPS koordináták mutatása a térképen</string>
|
||||||
<string name="use_internet_to_download_tile">Internet használata a hiányzó térképszeletek letöltésére</string>
|
<string name="use_internet_to_download_tile">Internet használata a hiányzó térképszeletek letöltésére</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Navigációs alkalmazás</string>
|
<string name="app_description">Navigációs alkalmazás</string>
|
||||||
|
|
||||||
<string name="exit_Button">Kilép</string>
|
<string name="exit_Button">Kilép</string>
|
||||||
|
|
|
@ -257,7 +257,6 @@
|
||||||
<string name="settings_activity">Impostazioni</string>
|
<string name="settings_activity">Impostazioni</string>
|
||||||
<string name="show_gps_coordinates_text">Visualizzare coordinate gps sulla mappa</string>
|
<string name="show_gps_coordinates_text">Visualizzare coordinate gps sulla mappa</string>
|
||||||
<string name="use_internet_to_download_tile">Utilizzare internet per scaricare i tasselli mancanti</string>
|
<string name="use_internet_to_download_tile">Utilizzare internet per scaricare i tasselli mancanti</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Applicazione di navicazione</string>
|
<string name="app_description">Applicazione di navicazione</string>
|
||||||
|
|
||||||
<string name="exit_Button">Uscita</string>
|
<string name="exit_Button">Uscita</string>
|
||||||
|
|
|
@ -322,7 +322,6 @@
|
||||||
<string name="settings_activity">Настройки</string>
|
<string name="settings_activity">Настройки</string>
|
||||||
<string name="show_gps_coordinates_text">Показать gps координаты на карте</string>
|
<string name="show_gps_coordinates_text">Показать gps координаты на карте</string>
|
||||||
<string name="use_internet_to_download_tile">Использовать Интернет для загрузки недостающих частей карты</string>
|
<string name="use_internet_to_download_tile">Использовать Интернет для загрузки недостающих частей карты</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Навигационное приложение</string>
|
<string name="app_description">Навигационное приложение</string>
|
||||||
|
|
||||||
<string name="exit_Button">Выход</string>
|
<string name="exit_Button">Выход</string>
|
||||||
|
|
|
@ -326,7 +326,6 @@
|
||||||
<string name="settings_activity">Nastavenia</string>
|
<string name="settings_activity">Nastavenia</string>
|
||||||
<string name="show_gps_coordinates_text">Zobraziť GPS súradnice na mape</string>
|
<string name="show_gps_coordinates_text">Zobraziť GPS súradnice na mape</string>
|
||||||
<string name="use_internet_to_download_tile">Použiť internet na stiahnutie chýbajúcich dlaždíc</string>
|
<string name="use_internet_to_download_tile">Použiť internet na stiahnutie chýbajúcich dlaždíc</string>
|
||||||
<string name="app_name">OsmAnd</string>
|
|
||||||
<string name="app_description">Navigačná aplikácia</string>
|
<string name="app_description">Navigačná aplikácia</string>
|
||||||
|
|
||||||
<string name="exit_Button">Skončiť</string>
|
<string name="exit_Button">Skončiť</string>
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="loading_builds_failed">Retrieving list of OsmAnd builds was failed.</string>
|
<string name="osmand_net_previously_installed">You have installed previous OsmAnd version. All offline data will be supported by new application. Favorite points should be exported in old application and imported.</string>
|
||||||
|
<string name="build_installed">Build {0} successfully installed ({1}).</string>
|
||||||
|
<string name="downloading_build">Downloading build...</string>
|
||||||
|
<string name="install_selected_build">Are you sure to install OsmAnd - {0} from {1} {2} MB.</string>
|
||||||
|
<string name="loading_builds_failed">Retrieving list of OsmAnd builds was failed </string>
|
||||||
<string name="loading_builds">Loading OsmAnd builds...</string>
|
<string name="loading_builds">Loading OsmAnd builds...</string>
|
||||||
<string name="select_build_to_install">Select one of the OsmAnd build to install</string>
|
<string name="select_build_to_install">Select one of the OsmAnd build to install</string>
|
||||||
<string name="contribution_activity">Special activity for contribution version</string>
|
<string name="contribution_activity">Special activity for contribution version</string>
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -9,24 +13,29 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.ProgressDialogImplementation;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.ResourceManager;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.pm.PackageInfo;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Filterable;
|
import android.widget.Filterable;
|
||||||
import android.widget.ListAdapter;
|
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
@ -35,13 +44,21 @@ public class ContributionVersionActivity extends ListActivity {
|
||||||
|
|
||||||
private static ContributionVersionActivityThread thread = new ContributionVersionActivityThread();
|
private static ContributionVersionActivityThread thread = new ContributionVersionActivityThread();
|
||||||
private static final int DOWNLOAD_BUILDS_LIST = 1;
|
private static final int DOWNLOAD_BUILDS_LIST = 1;
|
||||||
|
private static final int INSTALL_BUILD = 2;
|
||||||
|
private static final int ACTIVITY_TO_INSTALL = 23;
|
||||||
|
|
||||||
private static final String URL_TO_RETRIEVE_BUILDS = "http://download.osmand.net/builds.php";
|
private static final String URL_TO_RETRIEVE_BUILDS = "http://download.osmand.net/builds.php";
|
||||||
|
private static final String URL_GET_BUILD = "http://download.osmand.net/";
|
||||||
private static final String CONTRIBUTION_INSTALL_APP_DATE = "CONTRIBUTION_INSTALL_APP_DATE";
|
private static final String CONTRIBUTION_INSTALL_APP_DATE = "CONTRIBUTION_INSTALL_APP_DATE";
|
||||||
private ProgressDialog progressFileDlg;
|
|
||||||
|
private ProgressDialog progressDlg;
|
||||||
private Date currentInstalledDate;
|
private Date currentInstalledDate;
|
||||||
|
|
||||||
private List<OsmAndBuild> downloadedBuilds = new ArrayList<OsmAndBuild>();
|
private List<OsmAndBuild> downloadedBuilds = new ArrayList<OsmAndBuild>();
|
||||||
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
private File pathToDownload = new File(Environment.getExternalStorageDirectory(), ResourceManager.APP_DIR + "osmandToInstall.apk");
|
||||||
|
private OsmAndBuild currentSelectedBuild = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -58,11 +75,22 @@ public class ContributionVersionActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadedBuilds.clear();
|
downloadedBuilds.clear();
|
||||||
startThreadOperation(DOWNLOAD_BUILDS_LIST, getString(R.string.loading_builds));
|
startThreadOperation(DOWNLOAD_BUILDS_LIST, getString(R.string.loading_builds), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startThreadOperation(int operationId, String message) {
|
private void startThreadOperation(int operationId, String message, int total) {
|
||||||
progressFileDlg = ProgressDialog.show(this, getString(R.string.loading), message);
|
|
||||||
|
progressDlg = new ProgressDialog(this);
|
||||||
|
progressDlg.setTitle(getString(R.string.loading));
|
||||||
|
progressDlg.setMessage(message);
|
||||||
|
if(total != -1){
|
||||||
|
progressDlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||||
|
progressDlg.setMax(total);
|
||||||
|
progressDlg.setProgress(0);
|
||||||
|
} else {
|
||||||
|
progressDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||||
|
}
|
||||||
|
progressDlg.show();
|
||||||
// progressFileDlg.setCancelable(false);
|
// progressFileDlg.setCancelable(false);
|
||||||
if(thread.getState() == Thread.State.TERMINATED || thread.getOperationId() != operationId){
|
if(thread.getState() == Thread.State.TERMINATED || thread.getOperationId() != operationId){
|
||||||
thread = new ContributionVersionActivityThread();
|
thread = new ContributionVersionActivityThread();
|
||||||
|
@ -75,17 +103,48 @@ public class ContributionVersionActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endThreadOperation(int operationId, Exception e){
|
protected void endThreadOperation(int operationId, Exception e){
|
||||||
if(progressFileDlg != null){
|
if(progressDlg != null){
|
||||||
progressFileDlg.dismiss();
|
progressDlg.dismiss();
|
||||||
progressFileDlg = null;
|
progressDlg = null;
|
||||||
}
|
}
|
||||||
if(operationId == DOWNLOAD_BUILDS_LIST){
|
if(operationId == DOWNLOAD_BUILDS_LIST){
|
||||||
if(e != null){
|
if(e != null){
|
||||||
Toast.makeText(this, R.string.loading_builds_failed + " : " + e.getMessage(), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getString(R.string.loading_builds_failed) + " : " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
setListAdapter(new OsmandBuildsAdapter(downloadedBuilds));
|
setListAdapter(new OsmandBuildsAdapter(downloadedBuilds));
|
||||||
}
|
}
|
||||||
|
} else if(operationId == INSTALL_BUILD){
|
||||||
|
if(currentSelectedBuild != null){
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(Uri.fromFile(pathToDownload), "application/vnd.android.package-archive");
|
||||||
|
startActivityForResult(intent, ACTIVITY_TO_INSTALL);
|
||||||
|
//startActivity(intent);
|
||||||
|
//updateLastInstalledBuild(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if(ACTIVITY_TO_INSTALL == requestCode && resultCode == RESULT_OK){
|
||||||
|
updateLastInstalledBuild(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLastInstalledBuild(boolean showMessage) {
|
||||||
|
if (currentSelectedBuild != null) {
|
||||||
|
if (showMessage) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
MessageFormat.format(getString(R.string.build_installed), currentSelectedBuild.tag, dateFormat
|
||||||
|
.format(currentSelectedBuild.date)), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
OsmandSettings.getPrefs(this).edit().putString(CONTRIBUTION_INSTALL_APP_DATE, dateFormat.format(currentSelectedBuild.date))
|
||||||
|
.commit();
|
||||||
|
currentInstalledDate = currentSelectedBuild.date;
|
||||||
|
getListAdapter().notifyDataSetInvalidated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +174,26 @@ public class ContributionVersionActivity extends ListActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(operationId == INSTALL_BUILD){
|
||||||
|
URLConnection connection = new URL(URL_GET_BUILD + currentSelectedBuild.path).openConnection();
|
||||||
|
if(pathToDownload.exists()){
|
||||||
|
pathToDownload.delete();
|
||||||
|
}
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
InputStream is = connection.getInputStream();
|
||||||
|
FileOutputStream fout = new FileOutputStream(pathToDownload);
|
||||||
|
try {
|
||||||
|
int totalRead = 0;
|
||||||
|
int read;
|
||||||
|
while((read = is.read(buffer, 0, 1024)) != -1){
|
||||||
|
fout.write(buffer, 0, read);
|
||||||
|
totalRead += read;
|
||||||
|
progressDlg.setProgress(totalRead / 1024);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
fout.close();
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -124,12 +201,21 @@ public class ContributionVersionActivity extends ListActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
super.onListItemClick(l, v, position, id);
|
super.onListItemClick(l, v, position, id);
|
||||||
OsmAndBuild item = (OsmAndBuild) getListAdapter().getItem(position);
|
final OsmAndBuild item = (OsmAndBuild) getListAdapter().getItem(position);
|
||||||
// TODO
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
Toast.makeText(this, "Install " + item.path, Toast.LENGTH_LONG).show();
|
builder.setMessage(MessageFormat.format(getString(R.string.install_selected_build), item.tag, dateFormat.format(item.date), item.size));
|
||||||
OsmandSettings.getPrefs(this).edit().putString(CONTRIBUTION_INSTALL_APP_DATE, dateFormat.format(item.date)).commit();
|
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||||
currentInstalledDate = item.date;
|
|
||||||
getListAdapter().notifyDataSetInvalidated();
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
currentSelectedBuild = item;
|
||||||
|
int kb = (int) (Double.parseDouble(item.size) * 1024);
|
||||||
|
startThreadOperation(INSTALL_BUILD, getString(R.string.downloading_build), kb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.setNegativeButton(R.string.default_buttons_no, null);
|
||||||
|
builder.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,9 +228,9 @@ public class ContributionVersionActivity extends ListActivity {
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
thread.setActivity(null);
|
thread.setActivity(null);
|
||||||
if(progressFileDlg != null){
|
if(progressDlg != null){
|
||||||
progressFileDlg.dismiss();
|
progressDlg.dismiss();
|
||||||
progressFileDlg = null;
|
progressDlg = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ import android.app.AlertDialog.Builder;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -23,8 +25,6 @@ import android.os.Environment;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.text.style.URLSpan;
|
|
||||||
import android.text.style.UnderlineSpan;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
@ -33,6 +33,7 @@ import android.view.animation.AccelerateInterpolator;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.TranslateAnimation;
|
import android.view.animation.TranslateAnimation;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class MainMenuActivity extends Activity {
|
public class MainMenuActivity extends Activity {
|
||||||
|
|
||||||
|
@ -48,11 +49,11 @@ public class MainMenuActivity extends Activity {
|
||||||
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
|
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
|
||||||
|
|
||||||
|
|
||||||
public void checkPreviousRunsForExceptions() {
|
public void checkPreviousRunsForExceptions(boolean firstTime) {
|
||||||
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
|
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
|
||||||
final File file = new File(Environment.getExternalStorageDirectory(), OsmandApplication.EXCEPTION_PATH);
|
final File file = new File(Environment.getExternalStorageDirectory(), OsmandApplication.EXCEPTION_PATH);
|
||||||
if (file.exists() && file.length() > 0) {
|
if (file.exists() && file.length() > 0) {
|
||||||
if (size != file.length()) {
|
if (size != file.length() && !firstTime) {
|
||||||
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
|
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
|
||||||
Builder builder = new AlertDialog.Builder(MainMenuActivity.this);
|
Builder builder = new AlertDialog.Builder(MainMenuActivity.this);
|
||||||
builder.setMessage(msg).setNeutralButton(getString(R.string.close), null);
|
builder.setMessage(msg).setNeutralButton(getString(R.string.close), null);
|
||||||
|
@ -85,9 +86,8 @@ public class MainMenuActivity extends Activity {
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
getPreferences(MODE_WORLD_READABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
|
|
||||||
}
|
}
|
||||||
|
getPreferences(MODE_WORLD_READABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
|
||||||
} else {
|
} else {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
getPreferences(MODE_WORLD_READABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit();
|
getPreferences(MODE_WORLD_READABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit();
|
||||||
|
@ -191,11 +191,28 @@ public class MainMenuActivity extends Activity {
|
||||||
|
|
||||||
|
|
||||||
((OsmandApplication)getApplication()).checkApplicationIsBeingInitialized(this);
|
((OsmandApplication)getApplication()).checkApplicationIsBeingInitialized(this);
|
||||||
checkPreviousRunsForExceptions();
|
|
||||||
|
|
||||||
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
||||||
|
boolean firstTime = false;
|
||||||
if(!pref.contains(FIRST_TIME_APP_RUN)){
|
if(!pref.contains(FIRST_TIME_APP_RUN)){
|
||||||
|
firstTime = true;
|
||||||
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
|
||||||
|
|
||||||
|
boolean netOsmandWasInstalled = false;
|
||||||
|
try {
|
||||||
|
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("net.osmand", PackageManager.GET_META_DATA);
|
||||||
|
netOsmandWasInstalled = applicationInfo != null;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
netOsmandWasInstalled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(netOsmandWasInstalled){
|
||||||
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setMessage(R.string.osmand_net_previously_installed);
|
||||||
|
builder.setPositiveButton(R.string.default_buttons_ok, null);
|
||||||
|
builder.show();
|
||||||
|
} else {
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setMessage(R.string.first_time_msg);
|
builder.setMessage(R.string.first_time_msg);
|
||||||
builder.setPositiveButton(R.string.first_time_download, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.first_time_download, new DialogInterface.OnClickListener() {
|
||||||
|
@ -207,10 +224,11 @@ public class MainMenuActivity extends Activity {
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.first_time_continue, null);
|
builder.setNegativeButton(R.string.first_time_continue, null);
|
||||||
|
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkPreviousRunsForExceptions(firstTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue