Prepare contribution version
This commit is contained in:
parent
5dc9afc2de
commit
167469f450
12 changed files with 320 additions and 16 deletions
|
@ -17,6 +17,8 @@
|
|||
<activity android:name=".activities.DownloadIndexActivity" android:configChanges="keyboardHidden|orientation"></activity>
|
||||
<activity android:name=".activities.ShowRouteInfoActivity"></activity>
|
||||
<activity android:name=".activities.FavouritesActivity" android:label="@string/favourites_activity"></activity>
|
||||
<activity android:name=".activities.ContributionVersionActivity" android:label="@string/contribution_activity"></activity>
|
||||
|
||||
|
||||
<activity android:name=".activities.search.SearchPOIActivity" android:label="@string/searchpoi_activity"></activity>
|
||||
<activity android:name=".activities.search.SearchPoiFilterActivity"></activity>
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
android:background="@drawable/headliner" android:orientation="horizontal" android:id="@+id/Headliner" >
|
||||
<ImageView android:src="@drawable/headline_osmand_icon"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="15dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/AppName"
|
||||
android:layout_marginLeft="0dp" android:layout_weight="1" android:layout_marginTop="5dp"
|
||||
android:text="OsmAnd" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
android:text="OsmAnd+" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="0.5.1 beta(b6)" android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion"
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
android:background="@drawable/headliner" android:orientation="horizontal" android:id="@+id/Headliner" >
|
||||
<ImageView android:src="@drawable/headline_osmand_icon"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="20dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/AppName"
|
||||
android:layout_marginLeft="0dp" android:layout_weight="1" android:layout_marginTop="8dp"
|
||||
android:text="OsmAnd" android:textColor="#000000" android:typeface="serif" android:textSize="30sp"/>
|
||||
android:text="OsmAnd+" android:textColor="#000000" android:typeface="serif" android:textSize="30sp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="0.5.1 beta(b6)" android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion"
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
android:background="@drawable/headliner" android:orientation="horizontal" android:id="@+id/Headliner" >
|
||||
<ImageView android:src="@drawable/headline_osmand_icon"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="5dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/AppName"
|
||||
android:layout_marginLeft="0dp" android:layout_weight="1" android:layout_marginTop="8dp"
|
||||
android:text="OsmAnd" android:textColor="#000000" android:typeface="serif" android:textSize="22sp"/>
|
||||
android:text="OsmAnd+" android:textColor="#000000" android:typeface="serif" android:textSize="22sp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="0.5.1 beta(b6)" android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion"
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:background="@drawable/headliner" android:orientation="horizontal" android:id="@+id/Headliner" >
|
||||
<ImageView android:src="@drawable/headline_osmand_icon"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="5dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="8dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/AppName"
|
||||
android:layout_marginLeft="0dp" android:layout_weight="1" android:layout_marginTop="5dp"
|
||||
android:text="OsmAnd" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
android:text="OsmAnd+" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="0.5.1 beta(b6)" android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion"
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
android:background="@drawable/headliner" android:orientation="horizontal" android:id="@+id/Headliner" >
|
||||
<ImageView android:src="@drawable/headline_osmand_icon"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="5dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/AppName"
|
||||
android:layout_marginLeft="0dp" android:layout_weight="1" android:layout_marginTop="5dp"
|
||||
android:text="OsmAnd" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
android:text="OsmAnd+" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="0.5.1 beta(b6)" android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion"
|
||||
|
|
11
OsmAnd/res/layout/download_build_list_item.xml
Normal file
11
OsmAnd/res/layout/download_build_list_item.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/download_tag" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:layout_weight="1" android:textSize="18sp"></TextView>
|
||||
|
||||
<TextView android:id="@+id/download_descr" android:layout_marginLeft="3dp" android:gravity="center_vertical" android:layout_width="105dp"
|
||||
android:layout_height="wrap_content" android:textSize="18sp" ></TextView>
|
||||
|
||||
</LinearLayout>
|
13
OsmAnd/res/layout/download_builds.xml
Normal file
13
OsmAnd/res/layout/download_builds.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:orientation="vertical">
|
||||
|
||||
<TextView android:id="@+id/Label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/select_build_to_install"></TextView>
|
||||
|
||||
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" ></ListView>
|
||||
<Button android:id="@+id/DownloadButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/download_files"
|
||||
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp" android:visibility="gone"/>
|
||||
</LinearLayout>
|
|
@ -11,9 +11,9 @@
|
|||
android:background="@drawable/headliner" android:orientation="horizontal" android:id="@+id/Headliner" >
|
||||
<ImageView android:src="@drawable/headline_osmand_icon"
|
||||
android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="5dp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/AppName"
|
||||
android:layout_marginLeft="0dp" android:layout_weight="1" android:layout_marginTop="5px"
|
||||
android:text="OsmAnd" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
android:text="OsmAnd+" android:textColor="#000000" android:typeface="serif" android:textSize="20sp"/>
|
||||
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content"
|
||||
android:layout_marginTop="5px"
|
||||
android:text="0.5.1 beta(b6)" android:textColor="#000000" android:typeface="serif" android:id="@+id/TextVersion"
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="loading_builds_failed">Retrieving list of OsmAnd builds was failed.</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="contribution_activity">Special activity for contribution version</string>
|
||||
|
||||
<string name="gps_status_app_not_found">GPS status application not installed. Search in Market?</string>
|
||||
|
||||
<string name="voice_is_not_available_msg">Voice guidance is not available. Please go to settings, choose preferrable voice data or download it.</string>
|
||||
|
|
|
@ -0,0 +1,246 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ContributionVersionActivity extends ListActivity {
|
||||
|
||||
private static ContributionVersionActivityThread thread = new ContributionVersionActivityThread();
|
||||
private static final int DOWNLOAD_BUILDS_LIST = 1;
|
||||
private static final String URL_TO_RETRIEVE_BUILDS = "http://download.osmand.net/builds.php";
|
||||
private static final String CONTRIBUTION_INSTALL_APP_DATE = "CONTRIBUTION_INSTALL_APP_DATE";
|
||||
private ProgressDialog progressFileDlg;
|
||||
private Date currentInstalledDate;
|
||||
|
||||
private List<OsmAndBuild> downloadedBuilds = new ArrayList<OsmAndBuild>();
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.download_builds);
|
||||
|
||||
String installDate = OsmandSettings.getPrefs(this).getString(CONTRIBUTION_INSTALL_APP_DATE, null);
|
||||
if(installDate != null){
|
||||
try {
|
||||
currentInstalledDate = dateFormat.parse(installDate);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
}
|
||||
|
||||
downloadedBuilds.clear();
|
||||
startThreadOperation(DOWNLOAD_BUILDS_LIST, getString(R.string.loading_builds));
|
||||
}
|
||||
|
||||
private void startThreadOperation(int operationId, String message) {
|
||||
progressFileDlg = ProgressDialog.show(this, getString(R.string.loading), message);
|
||||
// progressFileDlg.setCancelable(false);
|
||||
if(thread.getState() == Thread.State.TERMINATED || thread.getOperationId() != operationId){
|
||||
thread = new ContributionVersionActivityThread();
|
||||
thread.setOperationId(operationId);
|
||||
}
|
||||
thread.setActivity(this);
|
||||
if(thread.getState() == Thread.State.NEW){
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
protected void endThreadOperation(int operationId, Exception e){
|
||||
if(progressFileDlg != null){
|
||||
progressFileDlg.dismiss();
|
||||
progressFileDlg = null;
|
||||
}
|
||||
if(operationId == DOWNLOAD_BUILDS_LIST){
|
||||
if(e != null){
|
||||
Toast.makeText(this, R.string.loading_builds_failed + " : " + e.getMessage(), Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
} else {
|
||||
setListAdapter(new OsmandBuildsAdapter(downloadedBuilds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void executeThreadOperation(int operationId) throws Exception {
|
||||
if(operationId == DOWNLOAD_BUILDS_LIST){
|
||||
URLConnection connection = new URL(URL_TO_RETRIEVE_BUILDS).openConnection();
|
||||
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
|
||||
parser.setInput(connection.getInputStream(), "UTF-8");
|
||||
int next;
|
||||
while((next = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
if(next == XmlPullParser.START_TAG && parser.getName().equals("build")) { //$NON-NLS-1$
|
||||
if ("osmand".equalsIgnoreCase(parser.getAttributeValue(null, "type"))) {
|
||||
|
||||
String path = parser.getAttributeValue(null, "path"); //$NON-NLS-1$
|
||||
String size = parser.getAttributeValue(null, "size"); //$NON-NLS-1$
|
||||
String date = parser.getAttributeValue(null, "date"); //$NON-NLS-1$
|
||||
String tag = parser.getAttributeValue(null, "tag"); //$NON-NLS-1$
|
||||
Date d = null;
|
||||
if (date != null) {
|
||||
try {
|
||||
d = dateFormat.parse(date);
|
||||
} catch (ParseException e) {
|
||||
}
|
||||
}
|
||||
OsmAndBuild build = new OsmAndBuild(path, size, d, tag);
|
||||
downloadedBuilds.add(build);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
super.onListItemClick(l, v, position, id);
|
||||
OsmAndBuild item = (OsmAndBuild) getListAdapter().getItem(position);
|
||||
// TODO
|
||||
Toast.makeText(this, "Install " + item.path, Toast.LENGTH_LONG).show();
|
||||
OsmandSettings.getPrefs(this).edit().putString(CONTRIBUTION_INSTALL_APP_DATE, dateFormat.format(item.date)).commit();
|
||||
currentInstalledDate = item.date;
|
||||
getListAdapter().notifyDataSetInvalidated();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public OsmandBuildsAdapter getListAdapter() {
|
||||
return (OsmandBuildsAdapter) super.getListAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
thread.setActivity(null);
|
||||
if(progressFileDlg != null){
|
||||
progressFileDlg.dismiss();
|
||||
progressFileDlg = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected class OsmandBuildsAdapter extends ArrayAdapter<OsmAndBuild> implements Filterable {
|
||||
|
||||
|
||||
public OsmandBuildsAdapter(List<OsmAndBuild> builds) {
|
||||
super(ContributionVersionActivity.this, R.layout.download_build_list_item, builds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
v = inflater.inflate(net.osmand.plus.R.layout.download_build_list_item, parent, false);
|
||||
}
|
||||
final View row = v;
|
||||
OsmAndBuild build = getItem(position);
|
||||
TextView tagView = (TextView) row.findViewById(R.id.download_tag);
|
||||
tagView.setText(build.tag);
|
||||
|
||||
TextView description = (TextView) row.findViewById(R.id.download_descr);
|
||||
StringBuilder format = new StringBuilder();
|
||||
format.append(dateFormat.format(build.date))/*.append(" : ").append(build.size).append(" MB")*/;
|
||||
description.setText(format.toString());
|
||||
|
||||
if(currentInstalledDate != null){
|
||||
if(currentInstalledDate.after(build.date)){
|
||||
tagView.setTextColor(Color.BLUE);
|
||||
} else {
|
||||
tagView.setTextColor(Color.GREEN);
|
||||
}
|
||||
} else {
|
||||
tagView.setTextColor(Color.WHITE);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class ContributionVersionActivityThread extends Thread {
|
||||
private ContributionVersionActivity activity;
|
||||
private int operationId;
|
||||
|
||||
public void setActivity(ContributionVersionActivity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int operationId) {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Exception ex= null;
|
||||
try {
|
||||
if(this.activity != null){
|
||||
this.activity.executeThreadOperation(operationId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ex = e;
|
||||
}
|
||||
final Exception e = ex;
|
||||
if(this.activity != null){
|
||||
this.activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
activity.endThreadOperation(operationId, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class OsmAndBuild {
|
||||
public String path;
|
||||
public String size;
|
||||
public Date date;
|
||||
public String tag;
|
||||
|
||||
public OsmAndBuild(String path, String size, Date date, String tag) {
|
||||
super();
|
||||
this.path = path;
|
||||
this.size = size;
|
||||
this.date = date;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.text.MessageFormat;
|
||||
|
||||
import net.osmand.Version;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
|
@ -19,6 +20,11 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
@ -39,7 +45,7 @@ public class MainMenuActivity extends Activity {
|
|||
private View favouritesButton;
|
||||
private View closeButton;
|
||||
|
||||
|
||||
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
|
||||
|
||||
|
||||
public void checkPreviousRunsForExceptions() {
|
||||
|
@ -116,8 +122,29 @@ public class MainMenuActivity extends Activity {
|
|||
rightview = (View) findViewById(R.id.SearchButton);
|
||||
rightview.startAnimation(getAnimation(1, 0));
|
||||
|
||||
final TextView textView = (TextView) findViewById(R.id.TextVersion);
|
||||
textView.setText(Version.APP_VERSION+ " "+ Version.APP_DESCRIPTION); //$NON-NLS-1$
|
||||
String textVersion = Version.APP_VERSION+ " "+ Version.APP_DESCRIPTION;
|
||||
final TextView textVersionView = (TextView) findViewById(R.id.TextVersion);
|
||||
textVersionView.setText(textVersion);
|
||||
SharedPreferences prefs = OsmandSettings.getPrefs(this);
|
||||
|
||||
// only one commit should be with contribution version flag
|
||||
// prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
|
||||
if (prefs.contains(CONTRIBUTION_VERSION_FLAG)) {
|
||||
final TextView appName = (TextView) findViewById(R.id.AppName);
|
||||
appName.setText("OsmAnd!+");
|
||||
SpannableString content = new SpannableString(textVersion);
|
||||
content.setSpan(new ClickableSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
final Intent mapIndent = new Intent(MainMenuActivity.this, ContributionVersionActivity.class);
|
||||
startActivityForResult(mapIndent, 0);
|
||||
}
|
||||
}, 0, content.length(), 0);
|
||||
textVersionView.setText(content);
|
||||
textVersionView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
|
||||
showMap = findViewById(R.id.MapButton);
|
||||
showMap.setOnClickListener(new OnClickListener() {
|
||||
|
|
Loading…
Reference in a new issue