Fix errors

This commit is contained in:
Victor Shcherb 2015-03-08 15:05:54 +01:00
parent f577beaae6
commit 62f3a55deb
6 changed files with 111 additions and 113 deletions

View file

@ -5,7 +5,7 @@
/>
<Preference android:key="general_settings" android:title="@string/general_settings_2" android:summary="@string/general_settings_descr"/>
<Preference android:key="routing_settings" android:title="@string/routing_settings_2" android:summary="@string/routing_settings_descr"/>
<Preference android:title="@string/tips_and_tricks" android:summary="@string/tips_and_tricks_descr" android:key="help"
<Preference android:title="@string/shared_string_help" android:summary="@string/tips_and_tricks_descr" android:key="help"
/>
<!-- <Preference android:title="@string/support_new_features" android:summary="@string/support_new_features_descr" android:key="bidforfix"/> -->

View file

@ -38,12 +38,10 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -59,15 +57,14 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
return view;
}
@Override
public void onResume() {
super.onResume();
public void onOpenUpdate() {
if (plugin == null) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
}
setupNotes();
setupNotes();
}
@Override
public void onPause() {

View file

@ -29,9 +29,7 @@ public abstract class DashBaseFragment extends Fragment {
}
}
public void onOpenUpdate() {
// TODO
}
public void onOpenUpdate() {}
public void onLocationCompassChanged(Location l, double compassValue) {

View file

@ -23,59 +23,62 @@ import android.widget.TextView;
*/
public class DashDownloadMapsFragment extends DashBaseFragment {
public static final String TAG = "DASH_DOWNLOAD_MAPS_FRAGMENT";
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
public static final String TAG = "DASH_DOWNLOAD_MAPS_FRAGMENT";
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.dash_download_maps_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
final TextView message =((TextView) view.findViewById(R.id.message));
message.setTypeface(typeface);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.dash_download_maps_fragment, container,
false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
final TextView message = ((TextView) view.findViewById(R.id.message));
message.setTypeface(typeface);
Button local = ((Button) view.findViewById(R.id.local_downloads));
local.setTypeface(typeface);
local.setOnClickListener(new View.OnClickListener() {
Button local = ((Button) view.findViewById(R.id.local_downloads));
local.setTypeface(typeface);
local.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization()
.getDownloadIndexActivity());
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.LOCAL_TAB);
//intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
Button cancelBtn = ((Button) view.findViewById(R.id.download_new_map));
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
//intent.putExtra(DownloadActivity.SINGLE_TAB, true);
// intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
return view;
}
Button cancelBtn = ((Button) view.findViewById(R.id.download_new_map));
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization()
.getDownloadIndexActivity());
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
// intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
return view;
}
@Override
public void onResume() {
super.onResume();
public void onOpenUpdate() {
refreshData();
}
public void refreshData() {
if (getView() == null){
if (getView() == null) {
return;
}
final TextView message =((TextView) getView().findViewById(R.id.message));
final TextView message = ((TextView) getView().findViewById(R.id.message));
final Button local = ((Button) getView().findViewById(R.id.local_downloads));
new AsyncTask<Void, Void, Void>() {
int countMaps = 0;
long size = 0;
@Override
protected Void doInBackground(Void... params) {
updateCount(IndexConstants.MAPS_PATH);
@ -84,8 +87,7 @@ public class DashDownloadMapsFragment extends DashBaseFragment {
}
protected void updateCount(String s) {
if (!DashDownloadMapsFragment.this.isAdded() ||
getMyApplication() == null){
if (!DashDownloadMapsFragment.this.isAdded() || getMyApplication() == null) {
return;
}
File ms = getMyApplication().getAppPath(s);
@ -105,17 +107,15 @@ public class DashDownloadMapsFragment extends DashBaseFragment {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (!DashDownloadMapsFragment.this.isAdded()
|| getMyApplication() == null){
if (!DashDownloadMapsFragment.this.isAdded() || getMyApplication() == null) {
return;
}
if(countMaps > 0) {
if (countMaps > 0) {
long mb = 1 << 20;
long gb = 1 << 30;
String sz = size > gb ?
formatGb.format(new Object[] { (float) size / (gb) }) :
formatMb.format(new Object[] { (float) size / mb }) ;
message.setText(getString(R.string.dash_download_msg, countMaps+"") + " (" + sz +")");
String sz = size > gb ? formatGb.format(new Object[] { (float) size / (gb) }) : formatMb
.format(new Object[] { (float) size / mb });
message.setText(getString(R.string.dash_download_msg, countMaps + "") + " (" + sz + ")");
local.setVisibility(View.VISIBLE);
} else {
message.setText(getString(R.string.dash_download_msg_none));
@ -123,6 +123,6 @@ public class DashDownloadMapsFragment extends DashBaseFragment {
}
}
}.execute((Void)null);
}.execute((Void) null);
}
}

View file

@ -22,63 +22,68 @@ import android.widget.Button;
import android.widget.TextView;
/**
* Created by Denis
* on 02.12.14.
* Created by Denis on 02.12.14.
*/
public class DashErrorFragment extends DashBaseFragment {
public static final String TAG = "DASH_ERROR_FRAGMENT";
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[] { "crash@osmand.net" }); //$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)));
}
});
@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[] { "crash@osmand.net" }); //$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) {
ActionBarActivity dashboardActivity =((ActionBarActivity)getActivity());
if (dashboardActivity != null) {
dashboardActivity.getSupportFragmentManager().beginTransaction().remove(DashErrorFragment.this).commit();
}
}
});
return view;
}
Button cancelBtn = ((Button) view.findViewById(R.id.error_cancel));
cancelBtn.setTypeface(typeface);
cancelBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActionBarActivity dashboardActivity = ((ActionBarActivity) getActivity());
if (dashboardActivity != null) {
dashboardActivity.getSupportFragmentManager().beginTransaction().remove(DashErrorFragment.this)
.commit();
}
}
});
return view;
}
@Override
public void onOpenUpdate() {
}
}

View file

@ -1,23 +1,21 @@
package net.osmand.plus.dashboard;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.views.DirectionDrawable;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.view.WindowManager;
import android.widget.ImageView;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.R;
import net.osmand.plus.views.DirectionDrawable;
import net.osmand.util.MapUtils;
/**
* Created by Denis
* on 26.01.2015.
*/
public class DashLocationFragment extends DashBaseFragment {
public abstract class DashLocationFragment extends DashBaseFragment {
private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_90 = 3;
@ -74,7 +72,7 @@ public class DashLocationFragment extends DashBaseFragment {
direction.setImageDrawable(draw);
}
public boolean updateCompassValue(float value) {
//heading = value;
//updateArrows();