Changed display of route information and its printing.

This commit is contained in:
Taranenko Roman 2014-10-07 20:25:53 +03:00
parent 1574da5dd6
commit 62c8e67a05
8 changed files with 189 additions and 398 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,000 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1,13 +1,58 @@
<?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" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView
android:id="@+id/direction"
android:layout_width="48dp"
android:layout_height="48dp" />
<ImageView android:id="@+id/direction" android:layout_width="48dp" android:layout_height="48dp"/>
<TextView android:text="" android:id="@+id/distance" android:layout_marginLeft ="5dp" android:textSize="23sp"
android:layout_width="70dp" android:layout_height="wrap_content"></TextView>
<TextView android:text="" android:id="@+id/description" android:layout_weight="1" android:textSize="23sp"
android:layout_width="0dp" android:layout_height="wrap_content"></TextView>
<TextView android:text="" android:id="@+id/time" android:layout_marginLeft ="5dp"
android:layout_width="65dp" android:layout_height="wrap_content" android:textSize="23sp"></TextView>
<LinearLayout
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23sp" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23sp" />
</LinearLayout>
<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:textSize="23sp" >
</TextView>
<LinearLayout
android:layout_width="75dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/cumulative_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23sp" />
<TextView
android:id="@+id/cumulative_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23sp" />
</LinearLayout>
</LinearLayout>

View file

@ -1,13 +1,53 @@
<?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" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView
android:id="@+id/direction"
android:layout_width="32dp"
android:layout_height="32dp" />
<ImageView android:id="@+id/direction" android:layout_width="32dp" android:layout_height="32dp" />
<TextView android:text="" android:id="@+id/distance" android:layout_marginLeft ="5dp"
android:layout_width="50dp" android:layout_height="wrap_content"></TextView>
<TextView android:text="" android:id="@+id/description" android:layout_weight="1"
android:layout_width="0dp" android:layout_height="wrap_content"></TextView>
<TextView android:text="" android:id="@+id/time" android:layout_marginLeft ="5dp"
android:layout_width="45dp" android:layout_height="wrap_content"></TextView>
<LinearLayout
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" >
</TextView>
<LinearLayout
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/cumulative_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/cumulative_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View file

@ -6,12 +6,9 @@ package net.osmand.plus.activities;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import net.osmand.IndexConstants;
@ -27,20 +24,10 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.TurnPathHelper;
import net.osmand.plus.views.controls.MapRouteInfoControl;
import net.osmand.util.Algorithms;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.print.PageRange;
import android.print.PrintAttributes;
import android.print.PrintAttributes.Margins;
import android.print.PrintDocumentAdapter;
import android.print.PrintDocumentInfo;
import android.print.PrintManager;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
@ -53,11 +40,6 @@ import android.widget.TextView;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.pdfjet.A4;
import com.pdfjet.CodePage;
import com.pdfjet.Font;
import com.pdfjet.PDF;
import com.pdfjet.Page;
/**
*
@ -68,9 +50,6 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
private static final int SAVE = 0;
private static final int SHARE = 1;
private static final int PRINT = 2;
private final static float PDF_FONT_SIZE = 12f;
private final static float PDF_DERAULT_MARGINS = 36f;
private final static float PDF_TEXT_LEADING = 14f;
private RoutingHelper helper;
private TextView header;
private DisplayMetrics dm;
@ -96,7 +75,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
return true;
}
if (item.getItemId() == SHARE) {
final GPXFile gpx = getMyApplication().getRoutingHelper().generateGPXFileWithRoute();
final GPXFile gpx = helper.generateGPXFileWithRoute();
final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
@ -124,7 +103,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
// large screen
header.setTextSize(dm.scaledDensity * 23);
}
setListAdapter(new RouteInfoAdapter(((OsmandApplication)getApplication()).getRoutingHelper().getRouteDirections()));
setListAdapter(new RouteInfoAdapter(helper.getRouteDirections()));
}
@Override
@ -139,7 +118,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
MapRouteInfoControl.directionInfo = position - 1;
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
settings.setMapLocationToShow(loc.getLatitude(),loc.getLongitude(),
Math.max(13, settings.getLastKnownMapZoom()), null, item.getDescriptionRoute(((OsmandApplication) getApplication())) + " " + getTimeDescription(item), null);
Math.max(13, settings.getLastKnownMapZoom()), null, item.getDescriptionRoutePart() + " " + getTimeDescription(item), null);
MapActivity.launchMapActivityMoveToTop(this);
}
}
@ -159,6 +138,16 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
}
class RouteInfoAdapter extends ArrayAdapter<RouteDirectionInfo> {
public class CumulativeInfo {
public int distance;
public int time;
public CumulativeInfo() {
distance = 0;
time = 0;
}
}
RouteInfoAdapter(List<RouteDirectionInfo> list) {
super(ShowRouteInfoActivity.this, R.layout.route_info_list_item, list);
this.setNotifyOnChange(false);
@ -176,21 +165,34 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
TextView label = (TextView) row.findViewById(R.id.description);
TextView distanceLabel = (TextView) row.findViewById(R.id.distance);
TextView timeLabel = (TextView) row.findViewById(R.id.time);
TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
ImageView icon = (ImageView) row.findViewById(R.id.direction);
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources());
drawable.setRouteType(model.getTurnType());
icon.setImageDrawable(drawable);
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(model.distance, getMyApplication()));
label.setText(model.getDescriptionRoute(((OsmandApplication) getApplication())));
String timeText = getTimeDescription(model);
timeLabel.setText(timeText);
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(
model.distance, getMyApplication()));
timeLabel.setText(getTimeDescription(model));
label.setText(model.getDescriptionRoutePart());
CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position);
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(
cumulativeInfo.distance, getMyApplication()));
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time));
return row;
}
public CumulativeInfo getRouteDirectionCumulativeInfo(int position) {
CumulativeInfo cumulativeInfo = new CumulativeInfo();
for (int i = 0; i < position; i++) {
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) getItem(i);
cumulativeInfo.time += routeDirectionInfo.getExpectedTime();
cumulativeInfo.distance += routeDirectionInfo.distance;
}
return cumulativeInfo;
}
}
private String getTimeDescription(RouteDirectionInfo model) {
@ -198,275 +200,8 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
return Algorithms.formatDuration(timeInSeconds);
}
@SuppressLint("NewApi")
private class RouteInfoPrintDocumentAdapter extends PrintDocumentAdapter {
List<RouteDirectionInfo> list;
String title;
float[] pageSize;
float marginLeft;
float marginRight;
float marginTop;
float marginBottom;
int totalPages;
int linesPerPage;
public RouteInfoPrintDocumentAdapter(List<RouteDirectionInfo> list, String title) {
this.title = title;
this.list = list;
pageSize = new float[2];
marginLeft = 0f;
marginRight = 0f;
marginTop = 0f;
marginBottom = 0f;
totalPages = 0;
linesPerPage = 0;
}
@Override
public void onLayout(PrintAttributes oldAttributes,
PrintAttributes newAttributes,
CancellationSignal cancellationSignal,
LayoutResultCallback callback, Bundle extras) {
if (cancellationSignal.isCanceled()) {
callback.onLayoutCancelled();
return;
}
pageSize[0] = (float) Math.rint(newAttributes.getMediaSize()
.getWidthMils() * 72f / 1000f);
pageSize[1] = (float) Math.rint(newAttributes.getMediaSize()
.getHeightMils() * 72f / 1000f);
Margins margins = newAttributes.getMinMargins();
marginLeft = (float) Math.rint(margins.getLeftMils() * 72 / 1000f);
marginRight = (float) Math.rint(margins.getRightMils() * 72 / 1000f);
marginTop = (float) Math.rint(margins.getTopMils() * 72 / 1000f);
marginBottom = (float) Math.rint(margins.getBottomMils() * 72 / 1000f);
if (marginLeft == 0f) {
marginLeft = PDF_DERAULT_MARGINS;
}
if (marginRight == 0f) {
marginRight = PDF_DERAULT_MARGINS;
}
if (marginTop == 0f) {
marginTop = PDF_DERAULT_MARGINS;
}
if (marginBottom == 0f) {
marginBottom = PDF_DERAULT_MARGINS;
}
linesPerPage = computeLinesPerPage();
totalPages = computePageCount();
if (totalPages > 0) {
PrintDocumentInfo info = new PrintDocumentInfo.Builder(
"print_output.pdf")
.setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
.setPageCount(totalPages).build();
callback.onLayoutFinished(info, true);
} else {
// Otherwise report an error to the print framework
callback.onLayoutFailed("Page count calculation failed.");
}
}
@Override
public void onWrite(PageRange[] pages,
ParcelFileDescriptor destination,
CancellationSignal cancellationSignal,
WriteResultCallback callback) {
ArrayList<Integer> writtenPagesArray = new ArrayList<Integer>();
PDF pdf = null;
InputStream fontInputStream = null;
try {
pdf = new PDF(new BufferedOutputStream(new FileOutputStream(
destination.getFileDescriptor())));
fontInputStream = getAssets().open("fonts/Roboto-Regular.ttf");
Font font = new Font(pdf, fontInputStream, CodePage.UNICODE, true);
font.setSize(PDF_FONT_SIZE);
int totalLinesCount = totalLinesCount();
int shift = 0;
if (!TextUtils.isEmpty(title)) {
shift = 1;
}
for (int i = 0; i < totalPages; i++) {
if (containsPage(pages, i)) {
Page page = new Page(pdf, pageSize);
page.setTextStart();
page.setTextFont(font);
page.setTextLocation(marginLeft, marginTop);
page.setTextLeading(PDF_TEXT_LEADING);
int startLineIndex = i * linesPerPage;
for (int j = startLineIndex; (j < (startLineIndex + linesPerPage)) && (j < totalLinesCount); j++) {
if ((j == 0) && (shift > 0)) {
page.println(title);
} else {
RouteDirectionInfo model = list.get(j - shift);
String distance = OsmAndFormatter.getFormattedDistance(model.distance, getMyApplication());
String description = model.getDescriptionRoute(((OsmandApplication) getApplication()));
String timeText = getTimeDescription(model);
page.println(distance + " " + description + " " + timeText);
}
}
page.setTextEnd();
writtenPagesArray.add(i);
}
}
} catch (Exception e) {
callback.onWriteFailed(e.toString());
return;
} finally {
if (pdf != null) {
try {
pdf.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (fontInputStream != null) {
try {
fontInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
PageRange[] writtenPages = computeWrittenPages(writtenPagesArray);
callback.onWriteFinished(writtenPages);
}
private int computeLinesPerPage() {
int linesPerPage = 0;
if (pageSize[1] > 0) {
float height = pageSize[1];
height -= marginTop;
height -= marginBottom;
linesPerPage = (int)(height / PDF_FONT_SIZE + PDF_TEXT_LEADING);
}
return linesPerPage;
}
private int computePageCount() {
int pageCount = 0;
int totalLinesCount = totalLinesCount();
if ((totalLinesCount > 0) && (linesPerPage > 0)) {
pageCount = totalLinesCount / linesPerPage;
if ((totalLinesCount % linesPerPage) != 0) {
pageCount++;
}
}
return pageCount;
}
private int totalLinesCount() {
int totalLinesCount = list.size();
if (!TextUtils.isEmpty(title)) {
totalLinesCount++;
}
return totalLinesCount;
}
private boolean containsPage(PageRange[] pages, int page) {
boolean contains = false;
for (int i = 0; i < pages.length; i++) {
if (pages[i].equals(PageRange.ALL_PAGES)) {
contains = true;
break;
} else if ((pages[i].getStart() <= page)
&& (page <= pages[i].getEnd())) {
contains = true;
break;
}
}
return contains;
}
private PageRange[] computeWrittenPages(List<Integer> pages) {
ArrayList<PageRange> writtenPagesList = new ArrayList<PageRange>();
int pagesSize = pages.size();
if (pagesSize > 0) {
int start = pages.get(0);
int end = start;
for (int i = 1; i < pagesSize; i++) {
int page = pages.get(i);
if ((page - end) > 1) {
PageRange pageRange = new PageRange(start, end);
writtenPagesList.add(pageRange);
start = page;
}
end = page;
}
PageRange lastPageRange = null;
int writtenPagesListSize = writtenPagesList.size();
if (writtenPagesListSize > 0) {
lastPageRange = writtenPagesList.get(writtenPagesListSize - 1);
}
if (lastPageRange == null) {
writtenPagesList.add(PageRange.ALL_PAGES);
} else {
PageRange pageRange = new PageRange(start, end);
if (!lastPageRange.equals(pageRange)) {
writtenPagesList.add(pageRange);
}
}
} else {
writtenPagesList.add(PageRange.ALL_PAGES);
}
PageRange[] writtenPages = new PageRange[writtenPagesList.size()];
writtenPagesList.toArray(writtenPages);
return writtenPages;
}
}
void print() {
// Just live uncommented preferred printing option pdf or html
// printViaPdf(); // for study the possibilities
printViaHtml();
}
@SuppressLint("NewApi")
void printViaPdf() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // use Android Print Framework
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
// Get a print adapter instance
PrintDocumentAdapter printAdapter = new RouteInfoPrintDocumentAdapter(
((OsmandApplication) getApplication()).getRoutingHelper()
.getRouteDirections(),
helper.getGeneralRouteInformation());
// Create a print job with name and adapter instance
String jobName = "OsmAnd route info";
printManager.print(jobName, printAdapter,
new PrintAttributes.Builder().build());
} else { // just open pdf
File file = generateRouteInfoPdf(
((OsmandApplication) getApplication()).getRoutingHelper()
.getRouteDirections(),
helper.getGeneralRouteInformation());
if (file.exists()) {
Uri uri = Uri.fromFile(file);
Intent intent;
intent = new Intent(Intent.ACTION_VIEW).setDataAndType(
uri, "application/pdf");
startActivity(intent);
}
}
}
@SuppressLint("NewApi")
void printViaHtml() {
File file = generateRouteInfoHtml(
((OsmandApplication) getApplication()).getRoutingHelper()
.getRouteDirections(),
File file = generateRouteInfoHtml((RouteInfoAdapter)getListAdapter(),
helper.getGeneralRouteInformation());
if (file.exists()) {
Uri uri = Uri.fromFile(file);
@ -482,39 +217,78 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
}
}
private File generateRouteInfoHtml(List<RouteDirectionInfo> list, String title) {
final String FILE_NAME = "route_info.html";
private File generateRouteInfoHtml(RouteInfoAdapter routeInfo, String title) {
File file = null;
if (routeInfo == null) {
return file;
}
final String FILE_NAME = "route_info.html";
StringBuilder html = new StringBuilder();
html.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
html.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
html.append("<head>");
html.append("<title>Route info</title>");
html.append("<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />");
html.append("<style>");
html.append("table, th, td {");
html.append("border: 1px solid black;");
html.append("border-collapse: collapse;}");
html.append("th, td {");
html.append("padding: 5px;}");
html.append("</style>");
html.append("</head>");
html.append("<body>");
FileOutputStream fos = null;
try {
if (!TextUtils.isEmpty(title)) {
html.append("<p>");
html.append("<h1>");
html.append(title);
html.append("</p>");
html.append("</h1>");
}
html.append("<table style=\"width:100%\">");
final String NBSP = "&nbsp;";
for (RouteDirectionInfo routeDirectionInfo : list) {
html.append("<p>");
String distance = OsmAndFormatter.getFormattedDistance(routeDirectionInfo.distance, getMyApplication());
final String BR = "<br>";
for (int i = 0; i < routeInfo.getCount(); i++) {
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) routeInfo
.getItem(i);
html.append("<tr>");
StringBuilder sb = new StringBuilder();
sb.append(OsmAndFormatter.getFormattedDistance(
routeDirectionInfo.distance, getMyApplication()));
sb.append(", ");
sb.append(getTimeDescription(routeDirectionInfo));
String distance = sb.toString().replaceAll("\\s", NBSP);
html.append("<td>");
html.append(distance);
html.append(NBSP);
String description = routeDirectionInfo.getDescriptionRoute(((OsmandApplication) getApplication()));
html.append(description);
html.append(NBSP);
String timeText = getTimeDescription(routeDirectionInfo);
html.append(timeText);
html.append("</p>");
html.append("</td>");
String description = routeDirectionInfo
.getDescriptionRoutePart();
html.append("<td>");
html.append(description);
html.append("</td>");
RouteInfoAdapter.CumulativeInfo cumulativeInfo = routeInfo
.getRouteDirectionCumulativeInfo(i);
html.append("<td>");
sb = new StringBuilder();
sb.append(OsmAndFormatter.getFormattedDistance(
cumulativeInfo.distance, getMyApplication()));
sb.append(" - ");
sb.append(OsmAndFormatter.getFormattedDistance(
cumulativeInfo.distance + routeDirectionInfo.distance,
getMyApplication()));
sb.append(BR);
sb.append(Algorithms.formatDuration(cumulativeInfo.time));
sb.append(" - ");
sb.append(Algorithms.formatDuration(cumulativeInfo.time
+ routeDirectionInfo.getExpectedTime()));
String cumulativeTimeAndDistance = sb.toString().replaceAll("\\s", NBSP);
html.append(cumulativeTimeAndDistance);
html.append("</td>");
html.append("</tr>");
}
html.append("</table>");
html.append("</body>");
html.append("</html>");
@ -541,73 +315,5 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
return file;
}
private File generateRouteInfoPdf(List<RouteDirectionInfo> list, String title) {
final String FILE_NAME = "route_info.pdf";
File file = new File(((OsmandApplication) getApplication())
.getAppCustomization().getExternalStorageDir(),
IndexConstants.APP_DIR + FILE_NAME);
PDF pdf = null;
InputStream fontInputStream = null;
try {
pdf = new PDF(new BufferedOutputStream(new FileOutputStream(file)));
fontInputStream = getAssets().open("fonts/Roboto-Regular.ttf");
Font font = new Font(pdf, fontInputStream, CodePage.UNICODE, true);
font.setSize(PDF_FONT_SIZE);
Page page = new Page(pdf, A4.PORTRAIT);
page.setTextStart();
page.setTextFont(font);
page.setTextLocation(PDF_DERAULT_MARGINS, PDF_DERAULT_MARGINS);
page.setTextLeading(PDF_TEXT_LEADING);
float height = page.getHeight() - 2 * PDF_DERAULT_MARGINS;
int linesPerPage = (int)(height / PDF_FONT_SIZE + PDF_TEXT_LEADING);
int lines = 0;
if (!TextUtils.isEmpty(title)) {
page.println(title);
lines++;
}
for (RouteDirectionInfo routeDirectionInfo : list) {
if (lines > linesPerPage) {
page.setTextEnd();
page = new Page(pdf, A4.PORTRAIT);
page.setTextStart();
page.setTextFont(font);
page.setTextLocation(PDF_DERAULT_MARGINS, PDF_DERAULT_MARGINS);
page.setTextLeading(PDF_TEXT_LEADING);
lines = 0;
}
String distance = OsmAndFormatter.getFormattedDistance(
routeDirectionInfo.distance, getMyApplication());
String description = routeDirectionInfo
.getDescriptionRoute(((OsmandApplication) getApplication()));
String timeText = getTimeDescription(routeDirectionInfo);
page.println(distance + " " + description + " " + timeText);
lines++;
}
page.setTextEnd();
} catch (Exception e) {
file = null;
} finally {
if (pdf != null) {
try {
pdf.close();
} catch (Exception e) {
file = null;
e.printStackTrace();
}
}
if (fontInputStream != null) {
try {
fontInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return file;
}
}