commit
9196416c3a
14 changed files with 340 additions and 199 deletions
37
OsmAnd/res/layout/dash_error_fragment.xml
Normal file
37
OsmAnd/res/layout/dash_error_fragment.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/bg_cardui"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView android:id="@+id/error_header"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
android:layout_width="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:textColor="@color/dashboard_black"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
<View android:layout_width="match_parent"
|
||||
android:background="@color/dashboard_divider"
|
||||
android:layout_height="1dp"/>
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="40dp">
|
||||
<Button android:id="@+id/error_btn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/send_report"
|
||||
style="@style/DashboardGeneralButton"/>
|
||||
<View android:layout_width="1dp"
|
||||
android:background="@color/dashboard_divider"
|
||||
android:layout_height="match_parent"/>
|
||||
<Button android:id="@+id/error_cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/default_buttons_cancel"
|
||||
style="@style/DashboardGeneralButton"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -18,13 +18,25 @@
|
|||
</LinearLayout>
|
||||
|
||||
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
|
||||
<ProgressBar android:id="@+id/map_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
style="@android:style/Widget.ProgressBar.Small"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateOnly="true"/>
|
||||
<LinearLayout android:id="@+id/loading"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="110dp"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/ProgressBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ProgressMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="3"
|
||||
android:text="@string/loading_data"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.views.OsmAndMapSurfaceView
|
||||
android:id="@+id/MapView"
|
||||
|
|
|
@ -6,22 +6,22 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="6dp" >
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
</LinearLayout>
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<LinearLayout
|
||||
<LinearLayout android:id="@+id/credentials"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="6dp" >
|
||||
android:visibility="gone"
|
||||
android:padding="6dp"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -33,7 +33,7 @@
|
|||
android:id="@+id/About"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|bottom"
|
||||
android:layout_gravity="start|bottom"
|
||||
android:text="@string/about_settings"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
|
@ -48,17 +48,17 @@
|
|||
android:id="@+id/Copyright"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:gravity="right"
|
||||
android:layout_gravity="end"
|
||||
android:gravity="end"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/OpenStreetMaps"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="5dp"
|
||||
android:gravity="right"
|
||||
android:gravity="end"
|
||||
android:text="@string/openstreetmap_copyright"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="everything_up_to_date">Everything up to date</string>
|
||||
<string name="use_opengl_render">Use opengl rendering</string>
|
||||
<string name="use_opengl_render_descr">Use hardware accelerated opengl rendering (may not work on some device)</string>
|
||||
<string name="error_avoid_specific_road">Nearest road was not found</string>
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
|
@ -16,15 +17,12 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.dashboard.DashFavoritesFragment;
|
||||
import net.osmand.plus.dashboard.DashMapFragment;
|
||||
import net.osmand.plus.dashboard.DashPluginsFragment;
|
||||
import net.osmand.plus.dashboard.DashSearchFragment;
|
||||
import net.osmand.plus.dashboard.DashUpdatesFragment;
|
||||
import net.osmand.plus.dashboard.*;
|
||||
import net.osmand.plus.download.BaseDownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.sherpafy.SherpafyLoadingFragment;
|
||||
import net.osmand.plus.sherpafy.TourViewActivity;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -74,9 +72,8 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
private static final int HELP_ID = 0;
|
||||
private static final int SETTINGS_ID = 1;
|
||||
private static final int EXIT_ID = 2;
|
||||
private ProgressDialog startProgressDialog;
|
||||
private OsmAndLocationProvider lp;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getMyApplication().applyTheme(this);
|
||||
|
@ -103,10 +100,8 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
getSupportActionBar().setBackgroundDrawable(color);
|
||||
getSupportActionBar().setIcon(android.R.color.transparent);
|
||||
|
||||
setupContributionVersion();
|
||||
addFragments();
|
||||
initApp(this, getMyApplication());
|
||||
|
||||
addFragments();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,6 +113,7 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
}
|
||||
|
||||
protected void setupContributionVersion() {
|
||||
findViewById(R.id.credentials).setVisibility(View.VISIBLE);
|
||||
final TextView textVersionView = (TextView) findViewById(R.id.Copyright);
|
||||
final Calendar inst = Calendar.getInstance();
|
||||
inst.setTime(new Date());
|
||||
|
@ -154,7 +150,7 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
about.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
private void addFragments() {
|
||||
public void addFragments() {
|
||||
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
|
||||
android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
//after rotation list of fragments in fragment transaction is not cleared
|
||||
|
@ -179,6 +175,16 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
DashPluginsFragment pluginsFragment = new DashPluginsFragment();
|
||||
fragmentTransaction.add(R.id.content, pluginsFragment, DashPluginsFragment.TAG).commit();
|
||||
}
|
||||
setupContributionVersion();
|
||||
}
|
||||
|
||||
private void addErrorFragment(){
|
||||
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
|
||||
android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
if (manager.findFragmentByTag(DashErrorFragment.TAG) == null){
|
||||
DashErrorFragment errorFragment = new DashErrorFragment();
|
||||
fragmentTransaction.add(R.id.content, errorFragment, DashErrorFragment.TAG).commit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showAboutDialog(final Activity activity, final OsmandApplication app) {
|
||||
|
@ -235,9 +241,6 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
startActivityForResult(mapIndent, 0);
|
||||
return;
|
||||
}
|
||||
startProgressDialog = new ProgressDialog(this);
|
||||
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
boolean dialogShown = false;
|
||||
boolean firstTime = false;
|
||||
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
||||
boolean appVersionChanged = false;
|
||||
|
@ -252,7 +255,6 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
|
||||
if (firstTime) {
|
||||
applicationInstalledFirstTime();
|
||||
dialogShown = true;
|
||||
} else {
|
||||
int i = pref.getInt(TIPS_SHOW, 0);
|
||||
if (i < 7) {
|
||||
|
@ -263,48 +265,23 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
|
||||
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
|
||||
dlg.show();
|
||||
dialogShown = true;
|
||||
} else {
|
||||
if(appVersionChanged) {
|
||||
final Intent helpIntent = new Intent(activity, HelpActivity.class);
|
||||
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
|
||||
helpIntent.putExtra(HelpActivity.URL, "changes-1.9.html");
|
||||
activity.startActivity(helpIntent);
|
||||
dialogShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!dialogShown && appCustomization.checkBasemapDownloadedOnStart()) {
|
||||
if (startProgressDialog.isShowing()) {
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
checkVectorIndexesDownloaded();
|
||||
// Do some action on close
|
||||
// FIXME uncomment
|
||||
// app.getResourceManager().getRenderer().clearCache();
|
||||
// mapView.refreshMap(true);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
checkVectorIndexesDownloaded();
|
||||
}
|
||||
}
|
||||
if(appCustomization.checkExceptionsOnStart() && !dialogShown){
|
||||
|
||||
if(appCustomization.checkExceptionsOnStart()){
|
||||
checkPreviousRunsForExceptions(firstTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if(id == OsmandApplication.PROGRESS_DIALOG){
|
||||
return startProgressDialog;
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
private void applicationInstalledFirstTime() {
|
||||
boolean netOsmandWasInstalled = false;
|
||||
try {
|
||||
|
@ -341,38 +318,7 @@ public class DashboardActivity extends BaseDownloadActivity {
|
|||
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
|
||||
if (file.exists() && file.length() > 0) {
|
||||
if (size != file.length() && !firstTime) {
|
||||
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
|
||||
Builder builder = new AccessibleAlertBuilder(DashboardActivity.this);
|
||||
builder.setMessage(msg).setNeutralButton(getString(R.string.close), null);
|
||||
builder.setPositiveButton(R.string.send_report, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osmand.app+crash@gmail.com" }); //$NON-NLS-1$
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
||||
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("\nDevice : ").append(Build.DEVICE); //$NON-NLS-1$
|
||||
text.append("\nBrand : ").append(Build.BRAND); //$NON-NLS-1$
|
||||
text.append("\nModel : ").append(Build.MODEL); //$NON-NLS-1$
|
||||
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
|
||||
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
|
||||
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
|
||||
text.append("\nApp Version : ").append(Version.getAppName(app)); //$NON-NLS-1$
|
||||
try {
|
||||
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
if (info != null) {
|
||||
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
}
|
||||
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
|
||||
}
|
||||
|
||||
});
|
||||
builder.show();
|
||||
addErrorFragment();
|
||||
}
|
||||
getPreferences(MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
|
||||
} else {
|
||||
|
|
83
OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java
Normal file
83
OsmAnd/src/net/osmand/plus/dashboard/DashErrorFragment.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.DashboardActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* Created by dummy on 02.12.14.
|
||||
*/
|
||||
public class DashErrorFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_ERROR_FRAGMENT";
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_error_fragment, container, false);
|
||||
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
|
||||
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||
TextView message =((TextView) view.findViewById(R.id.error_header));
|
||||
message.setTypeface(typeface);
|
||||
message.setText(msg);
|
||||
Button errorBtn = ((Button) view.findViewById(R.id.error_btn));
|
||||
errorBtn.setTypeface(typeface);
|
||||
errorBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osmand.app+crash@gmail.com" }); //$NON-NLS-1$
|
||||
File file = getMyApplication().getAppPath(OsmandApplication.EXCEPTION_PATH);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
||||
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append("\nDevice : ").append(Build.DEVICE); //$NON-NLS-1$
|
||||
text.append("\nBrand : ").append(Build.BRAND); //$NON-NLS-1$
|
||||
text.append("\nModel : ").append(Build.MODEL); //$NON-NLS-1$
|
||||
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
|
||||
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
|
||||
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
|
||||
text.append("\nApp Version : ").append(Version.getAppName(getMyApplication())); //$NON-NLS-1$
|
||||
try {
|
||||
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
|
||||
if (info != null) {
|
||||
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
|
||||
}
|
||||
});
|
||||
|
||||
Button cancelBtn = ((Button) view.findViewById(R.id.error_cancel));
|
||||
cancelBtn.setTypeface(typeface);
|
||||
cancelBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
DashboardActivity dashboardActivity =((DashboardActivity)getSherlockActivity());
|
||||
if (dashboardActivity != null) {
|
||||
dashboardActivity.getSupportFragmentManager().beginTransaction().remove(DashErrorFragment.this).commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
}
|
|
@ -9,12 +9,15 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.map.MapTileDownloader.DownloadRequest;
|
||||
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.DashboardActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityActions;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
|
@ -31,7 +34,7 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
|
||||
public static final String TAG = "DASH_MAP_FRAGMENT";
|
||||
private OsmandMapTileView osmandMapTileView;
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
@ -51,11 +54,10 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_map_fragment, container, false);
|
||||
setupMapView(view);
|
||||
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||
((TextView) view.findViewById(R.id.map_text)).setTypeface(typeface);
|
||||
((Button) view.findViewById(R.id.show_map)).setTypeface(typeface);
|
||||
|
||||
setupMapView(view);
|
||||
(view.findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -64,7 +66,6 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
|
||||
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,33 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloader
|
|||
osmandMapTileView.setComplexZoom(zm, osmandMapTileView.getSettingsZoomScale());
|
||||
osmandMapTileView.refreshMap(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
view.findViewById(R.id.MapView).setVisibility(View.GONE);
|
||||
if(getMyApplication().isApplicationInitializing()) {
|
||||
getMyApplication().checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage),
|
||||
(ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
applicationInitialized(view);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
applicationInitialized(view);
|
||||
}
|
||||
}
|
||||
|
||||
private void applicationInitialized(View view) {
|
||||
view.findViewById(R.id.loading).setVisibility(View.GONE);
|
||||
DashboardActivity dashboardActivity =((DashboardActivity)getSherlockActivity());
|
||||
if (dashboardActivity != null){
|
||||
dashboardActivity.updateDownloads();
|
||||
view.findViewById(R.id.MapView).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tileDownloaded(DownloadRequest request) {
|
||||
if(request != null && !request.error && request.fileToSave != null){
|
||||
|
|
|
@ -75,13 +75,14 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
|||
downloadButtons.clear();
|
||||
mainView.findViewById(R.id.main_progress).setVisibility(View.GONE);
|
||||
((TextView) mainView.findViewById(R.id.update_count)).setText(String.valueOf(list.size()));
|
||||
if (list.size() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
|
||||
updates.removeAllViews();
|
||||
|
||||
if (list.size() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
final IndexItem item = list.get(i);
|
||||
if (i > 2) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
|
@ -7,11 +8,18 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.DashboardActivity;
|
||||
import net.osmand.plus.activities.SettingsGeneralActivity;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -20,6 +28,7 @@ import android.support.v4.app.Fragment;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import net.osmand.plus.base.SuggestExternalDirectoryDialog;
|
||||
|
||||
/**
|
||||
* Created by Denis on 25.11.2014.
|
||||
|
@ -38,8 +47,12 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
|
|||
if(downloadListIndexThread == null) {
|
||||
downloadListIndexThread = new DownloadIndexesThread(this);
|
||||
}
|
||||
prepareDownloadDirectory();
|
||||
}
|
||||
|
||||
public void updateDownloads() {
|
||||
if (downloadListIndexThread.getCachedIndexFiles() != null && downloadListIndexThread.isDownloadedFromInternet()) {
|
||||
downloadListIndexThread.runCategorization(type);
|
||||
downloadListIndexThread.runCategorization(DownloadActivityType.NORMAL_FILE);
|
||||
} else {
|
||||
downloadListIndexThread.runReloadIndexFiles();
|
||||
}
|
||||
|
@ -196,5 +209,96 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
|
|||
bld.setNegativeButton(R.string.default_buttons_no, null);
|
||||
bld.show();
|
||||
}
|
||||
|
||||
private void prepareDownloadDirectory() {
|
||||
if(getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) {
|
||||
boolean showedDialog = false;
|
||||
if(Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
SuggestExternalDirectoryDialog.showDialog(this, null, null);
|
||||
}
|
||||
if(!showedDialog) {
|
||||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
} else {
|
||||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
final String currentStorage = settings.getExternalStorageDirectory().getAbsolutePath();
|
||||
String primaryStorage = settings.getDefaultExternalStorageLocation();
|
||||
if (!currentStorage.startsWith(primaryStorage)) {
|
||||
// secondary storage
|
||||
boolean currentDirectoryNotWritable = true;
|
||||
for (String writeableDirectory : settings.getWritableSecondaryStorageDirectorys()) {
|
||||
if (currentStorage.startsWith(writeableDirectory)) {
|
||||
currentDirectoryNotWritable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentDirectoryNotWritable) {
|
||||
currentDirectoryNotWritable = !OsmandSettings.isWritable(settings.getExternalStorageDirectory());
|
||||
}
|
||||
if (currentDirectoryNotWritable) {
|
||||
final String newLoc = settings.getMatchingExternalFilesDir(currentStorage);
|
||||
if (newLoc != null && newLoc.length() != 0) {
|
||||
AccessibleAlertBuilder ab = new AccessibleAlertBuilder(this);
|
||||
ab.setMessage(getString(R.string.android_19_location_disabled,
|
||||
settings.getExternalStorageDirectory()));
|
||||
ab.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
copyFilesForAndroid19(newLoc);
|
||||
}
|
||||
});
|
||||
ab.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
ab.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showDialogOfFreeDownloadsIfNeeded() {
|
||||
if (Version.isFreeVersion(getMyApplication())) {
|
||||
AlertDialog.Builder msg = new AlertDialog.Builder(this);
|
||||
msg.setTitle(R.string.free_version_title);
|
||||
String m = getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "", "") + "\n";
|
||||
m += getString(R.string.available_downloads_left, MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get());
|
||||
msg.setMessage(m);
|
||||
if (Version.isMarketEnabled(getMyApplication())) {
|
||||
msg.setNeutralButton(R.string.install_paid, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication()) + "net.osmand.plus"));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
msg.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
msg.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void copyFilesForAndroid19(final String newLoc) {
|
||||
SettingsGeneralActivity.MoveFilesToDifferentDirectory task =
|
||||
new SettingsGeneralActivity.MoveFilesToDifferentDirectory(this,
|
||||
new File(settings.getExternalStorageDirectory(), IndexConstants.APP_DIR),
|
||||
new File(newLoc, IndexConstants.APP_DIR)) {
|
||||
protected Boolean doInBackground(Void[] params) {
|
||||
Boolean result = super.doInBackground(params);
|
||||
if(result) {
|
||||
settings.setExternalStorageDirectory(newLoc);
|
||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||
getMyApplication().getResourceManager().reloadIndexes(progress) ;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
task.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getMyApplication().applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
updateDownloads();
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
|
||||
|
@ -144,54 +145,7 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
if (tab.equals(DOWNLOAD_TAB)){
|
||||
tabHost.setCurrentTab(1);
|
||||
} else if (tab.equals(UPDATES_TAB)){
|
||||
tabHost.setCurrentTab(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) {
|
||||
boolean showedDialog = false;
|
||||
if(Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
SuggestExternalDirectoryDialog.showDialog(this, null, null);
|
||||
}
|
||||
if(!showedDialog) {
|
||||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
} else {
|
||||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
|
||||
|
||||
if (Build.VERSION.SDK_INT >= OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
final String currentStorage = settings.getExternalStorageDirectory().getAbsolutePath();
|
||||
String primaryStorage = settings.getDefaultExternalStorageLocation();
|
||||
if (!currentStorage.startsWith(primaryStorage)) {
|
||||
// secondary storage
|
||||
boolean currentDirectoryNotWritable = true;
|
||||
for (String writeableDirectory : settings.getWritableSecondaryStorageDirectorys()) {
|
||||
if (currentStorage.startsWith(writeableDirectory)) {
|
||||
currentDirectoryNotWritable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentDirectoryNotWritable) {
|
||||
currentDirectoryNotWritable = !OsmandSettings.isWritable(settings.getExternalStorageDirectory());
|
||||
}
|
||||
if (currentDirectoryNotWritable) {
|
||||
final String newLoc = settings.getMatchingExternalFilesDir(currentStorage);
|
||||
if (newLoc != null && newLoc.length() != 0) {
|
||||
AccessibleAlertBuilder ab = new AccessibleAlertBuilder(this);
|
||||
ab.setMessage(getString(R.string.android_19_location_disabled,
|
||||
settings.getExternalStorageDirectory()));
|
||||
ab.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
copyFilesForAndroid19(newLoc);
|
||||
}
|
||||
});
|
||||
ab.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
ab.show();
|
||||
}
|
||||
tabHost.setCurrentTab(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +154,8 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Map<String, String> getIndexActivatedFileNames() {
|
||||
return downloadListIndexThread != null ? downloadListIndexThread.getIndexActivatedFileNames() : null;
|
||||
}
|
||||
|
@ -252,30 +208,6 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
(getMyApplication()).setDownloadActivity(null);
|
||||
}
|
||||
|
||||
public void showDialogOfFreeDownloadsIfNeeded() {
|
||||
if (Version.isFreeVersion(getMyApplication())) {
|
||||
AlertDialog.Builder msg = new AlertDialog.Builder(this);
|
||||
msg.setTitle(R.string.free_version_title);
|
||||
String m = getString(R.string.free_version_message, MAXIMUM_AVAILABLE_FREE_DOWNLOADS + "", "") + "\n";
|
||||
m += getString(R.string.available_downloads_left, MAXIMUM_AVAILABLE_FREE_DOWNLOADS - settings.NUMBER_OF_FREE_DOWNLOADS.get());
|
||||
msg.setMessage(m);
|
||||
if (Version.isMarketEnabled(getMyApplication())) {
|
||||
msg.setNeutralButton(R.string.install_paid, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication()) + "net.osmand.plus"));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
msg.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
msg.show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(boolean updateOnlyProgress) {
|
||||
BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
|
||||
|
@ -422,25 +354,6 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
}
|
||||
|
||||
|
||||
private void copyFilesForAndroid19(final String newLoc) {
|
||||
SettingsGeneralActivity.MoveFilesToDifferentDirectory task =
|
||||
new SettingsGeneralActivity.MoveFilesToDifferentDirectory(this,
|
||||
new File(settings.getExternalStorageDirectory(), IndexConstants.APP_DIR),
|
||||
new File(newLoc, IndexConstants.APP_DIR)) {
|
||||
protected Boolean doInBackground(Void[] params) {
|
||||
Boolean result = super.doInBackground(params);
|
||||
if(result) {
|
||||
settings.setExternalStorageDirectory(newLoc);
|
||||
getMyApplication().getResourceManager().resetStoreDirectory();
|
||||
getMyApplication().getResourceManager().reloadIndexes(progress) ;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
task.execute();
|
||||
}
|
||||
|
||||
|
||||
public Map<String,String> getIndexFileNames() {
|
||||
return downloadListIndexThread != null ? downloadListIndexThread.getIndexFileNames() : null;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,15 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
||||
List<IndexItem> indexItems = new ArrayList<IndexItem>();
|
||||
if (BaseDownloadActivity.downloadListIndexThread != null) {
|
||||
indexItems = DownloadActivity.downloadListIndexThread.getItemsToUpdate();
|
||||
indexItems = new ArrayList<IndexItem>(DownloadActivity.downloadListIndexThread.getItemsToUpdate());
|
||||
}
|
||||
createListView(indexItems);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
private void createListView(List<IndexItem> indexItems) {
|
||||
if (indexItems.size() == 0){
|
||||
indexItems.add(new IndexItem(getString(R.string.everything_up_to_date),"",0,"",0,0, null));
|
||||
}
|
||||
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
|
||||
listAdapter.sort(new Comparator<IndexItem>() {
|
||||
|
@ -53,7 +61,6 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
}
|
||||
});
|
||||
setListAdapter(listAdapter);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,8 +72,8 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
if(listAdapter == null){
|
||||
return;
|
||||
}
|
||||
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, items);
|
||||
setListAdapter(listAdapter);
|
||||
|
||||
createListView(new ArrayList<IndexItem>(items));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -201,14 +208,22 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
|||
|
||||
TextView name = (TextView) v.findViewById(R.id.download_item);
|
||||
TextView description = (TextView) v.findViewById(R.id.download_descr);
|
||||
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
|
||||
IndexItem e = items.get(position);
|
||||
if (e.getFileName() == getString(R.string.everything_up_to_date)){
|
||||
name.setText(e.getFileName());
|
||||
description.setText("");
|
||||
ch.setVisibility(View.INVISIBLE);
|
||||
return v;
|
||||
} else {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
}
|
||||
String eName = DownloadActivity.getFullName(e, getMyApplication(), osmandRegions);
|
||||
|
||||
name.setText(eName.trim()); //$NON-NLS-1$
|
||||
String d = e.getDate(format) + "\n" + e.getSizeDescription(getMyApplication());
|
||||
description.setText(d);
|
||||
|
||||
final CheckBox ch = (CheckBox) v.findViewById(R.id.check_download_item);
|
||||
ch.setChecked(getDownloadActivity().getEntriesToDownload().containsKey(e));
|
||||
ch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -45,6 +45,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.SearchByNameFilter;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.download.BaseDownloadActivity;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
import net.osmand.plus.resources.AsyncLoadingThread.MapLoadRequest;
|
||||
|
@ -402,7 +403,8 @@ public class ResourceManager {
|
|||
}
|
||||
return cacheOfImages.get(req.tileId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////// Working with indexes ////////////////////////////////////////////////
|
||||
|
||||
public List<String> reloadIndexes(IProgress progress){
|
||||
|
|
|
@ -20,7 +20,7 @@ public class SherpafyLoadingFragment extends SherlockFragment {
|
|||
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
view = inflater.inflate(R.layout.sherpafy_loading, container, false);
|
||||
view = inflater.inflate(R.layout.loading, container, false);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue