image size in description for tour now will always be smaller than screen to fix scaling problem. Fixed bug when after downloading tour user coulnd see SelectTour btn

This commit is contained in:
unknown 2014-06-06 17:30:21 +03:00
parent d4922341f2
commit 92b8e60814
2 changed files with 39 additions and 6 deletions

View file

@ -691,7 +691,7 @@ public class OsmandApplication extends Application {
} }
public void showToastMessage(String msg) { public void showToastMessage(String msg) {
AccessibleToast.makeText(this, msg, Toast.LENGTH_LONG).show(); //AccessibleToast.makeText(this, msg, Toast.LENGTH_LONG).show();
} }
public SQLiteAPI getSQLiteAPI() { public SQLiteAPI getSQLiteAPI() {

View file

@ -1,11 +1,14 @@
package net.osmand.plus.sherpafy; package net.osmand.plus.sherpafy;
import java.io.File; import java.io.File;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Html; import android.text.Html;
import android.view.Display;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
@ -61,9 +64,12 @@ public class TourViewActivity extends SherlockFragmentActivity {
TextView fullDescription; TextView fullDescription;
RadioGroup stages; RadioGroup stages;
private ToggleButton collapser; private ToggleButton collapser;
Point size;
private boolean afterDownload = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if (!(getMyApplication().getAppCustomization() instanceof SherpafyCustomization)) { if (!(getMyApplication().getAppCustomization() instanceof SherpafyCustomization)) {
getMyApplication().setAppCustomization(new SherpafyCustomization()); getMyApplication().setAppCustomization(new SherpafyCustomization());
} }
@ -79,6 +85,9 @@ public class TourViewActivity extends SherlockFragmentActivity {
getSupportActionBar().setTitle(R.string.sherpafy_app_name); getSupportActionBar().setTitle(R.string.sherpafy_app_name);
setContentView(R.layout.sherpafy_loading); setContentView(R.layout.sherpafy_loading);
size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
if (state == STATE_LOADING) { if (state == STATE_LOADING) {
getMyApplication().checkApplicationIsBeingInitialized(this, (TextView) findViewById(R.id.ProgressMessage), getMyApplication().checkApplicationIsBeingInitialized(this, (TextView) findViewById(R.id.ProgressMessage),
(ProgressBar) findViewById(R.id.ProgressBar), new Runnable() { (ProgressBar) findViewById(R.id.ProgressBar), new Runnable() {
@ -101,6 +110,22 @@ public class TourViewActivity extends SherlockFragmentActivity {
} }
@Override
protected void onResume() {
super.onResume();
if (afterDownload){
if (customization.getTourInformations().isEmpty()){
customization.onIndexingFiles(IProgress.EMPTY_PROGRESS,new LinkedHashMap<String, String>());
}
if (!customization.getTourInformations().isEmpty() && customization.getSelectedTour() == null){
setTourSelectionContentView();
state = STATE_SELECT_TOUR;
}
}
}
private void setTourInfoContent() { private void setTourInfoContent() {
setContentView(R.layout.sherpafy_tour_info); setContentView(R.layout.sherpafy_tour_info);
@ -149,10 +174,16 @@ public class TourViewActivity extends SherlockFragmentActivity {
description.setText(Html.fromHtml(st.getDescription(), new Html.ImageGetter() { description.setText(Html.fromHtml(st.getDescription(), new Html.ImageGetter() {
@Override @Override
public Drawable getDrawable(String s) { public Drawable getDrawable(String s) {
Bitmap file = customization.getSelectedTour().getImageBitmapFromPath(s); Bitmap file = customization.getSelectedTour().getImageBitmapFromPath(s);
Drawable bmp = new BitmapDrawable(getResources(),file); Drawable bmp = new BitmapDrawable(getResources(),file);
bmp.setBounds(0,0, bmp.getIntrinsicHeight(), bmp.getIntrinsicHeight()); int imagewidth = bmp.getIntrinsicWidth();
if (size.x-1 > imagewidth) {
bmp.setBounds(0,0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
}
else {
double scale = (double)(size.x-1)/imagewidth;
bmp.setBounds(0,0, (int)(scale*bmp.getIntrinsicWidth()), (int)(scale*bmp.getIntrinsicHeight()));
}
return bmp; return bmp;
} }
@ -347,6 +378,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
if(customization.getAccessCode().length() == 0) { if(customization.getAccessCode().length() == 0) {
openAccessCode(true); openAccessCode(true);
} else { } else {
startDownloadActivity(); startDownloadActivity();
} }
} }
@ -385,6 +417,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
private void startDownloadActivity() { private void startDownloadActivity() {
final Intent download = new Intent(this, DownloadIndexActivity.class); final Intent download = new Intent(this, DownloadIndexActivity.class);
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
afterDownload = true;
startActivity(download); startActivity(download);
} }