Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-03-26 17:20:03 +01:00
commit 1cdc365618
10 changed files with 290 additions and 61 deletions

View file

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_distance"
android:orientation="vertical"
android:paddingBottom="@dimen/list_content_padding"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingTop="@dimen/list_content_padding">
<TextView
android:id="@+id/velcome_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/list_header_bottom_margin"
android:text="@string/welcome_header"
android:textColor="@color/color_white"
android:textSize="@dimen/welcome_header_text_size"/>
<TextView
android:id="@+id/welcome_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/welcome_text"
android:textColor="@color/color_white"
android:textSize="@dimen/dash_parking_big_text_size"/>
</LinearLayout>
<LinearLayout
android:id="@+id/select_region"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"
android:paddingLeft="@dimen/list_content_padding">
<ImageView
android:id="@+id/car_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/list_content_padding"
tools:src="@drawable/ic_action_car_dark"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/welcome_select_region"/>
<TextView
android:id="@+id/region"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="@string/driving_region"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal">
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/hide"
style="?attr/dashboardGeneralButtonStyle"
android:text="@string/rendering_category_hide"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/download_map"
style="?attr/dashboardGeneralButtonStyle"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/welmode_download_maps"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="app_mode_icon_color">#33B4E4</color>
<color name="parking_outdated_color">#f41a34</color>
<color name="osmo_header_dark">#2d383d</color>
<color name="osmo_header_light">#b36d12</color>

View file

@ -97,4 +97,5 @@
<dimen name="dashParkingTextSize">24sp</dimen>
<dimen name="dash_parking_big_text_size">18sp</dimen>
<dimen name="dash_parking_small_text_size">14sp</dimen>
<dimen name="welcome_header_text_size">22sp</dimen>
</resources>

View file

@ -9,6 +9,10 @@
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="welmode_download_maps">Download maps</string>
<string name="welcome_select_region">Select your region</string>
<string name="welcome_text">OsmAnd allows you to use maps and offline navigation!</string>
<string name="welcome_header">Welcome</string>
<string name="current_route">Current route</string>
<string name="osm_changes_added_to_local_edits">OSM changes added to local changes</string>
<string name="mark_to_delete">Mark to delete</string>

View file

@ -1,14 +1,14 @@
package net.osmand.plus;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@ -39,15 +39,16 @@ import net.osmand.util.Algorithms;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import btools.routingapp.BRouterServiceConnection;
/**
@ -123,9 +124,9 @@ public class AppInitializer implements IProgress {
initSettings = true;
}
public boolean isFirstTime(Activity a) {
initUiVars(a);
return firstTime;
public boolean isFirstTime(Activity activity) {
SharedPreferences pref = activity.getPreferences(Context.MODE_WORLD_WRITEABLE);
return !pref.contains(FIRST_TIME_APP_RUN);
}
public boolean checkAppVersionChanged(Activity activity) {

View file

@ -101,6 +101,8 @@ public class MapActivity extends AccessibleActivity {
private OsmandApplication app;
private OsmandSettings settings;
boolean firstTime;
private Dialog progressDlg = null;
private List<DialogProvider> dialogProviders = new ArrayList<DialogProvider>(2);
@ -123,6 +125,16 @@ public class MapActivity extends AccessibleActivity {
return notification;
}
public boolean isFirstTime(){
return firstTime;
}
public void userClosedWelcomeCard(){
firstTime = false;
dashboardOnMap.refreshDashboardFragments();
}
@Override
public void onCreate(Bundle savedInstanceState) {
long tm = System.currentTimeMillis();
@ -141,6 +153,7 @@ public class MapActivity extends AccessibleActivity {
if (mapViewTrackingUtilities == null) {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
}
firstTime = app.getAppInitializer().isFirstTime(this);
dashboardOnMap.createDashboardView();
checkAppInitialization();
parseLaunchIntentLocation();
@ -191,6 +204,7 @@ public class MapActivity extends AccessibleActivity {
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
mapView.refreshMap(true);
}
private void checkAppInitialization() {

View file

@ -253,7 +253,7 @@ public class AppModeDialog {
tb.setTextOn("");
tb.setTextOff("");
tb.setContentDescription(mode.toHumanString(ctx));
tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.dashboard_blue), null, null);
tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
tb.setPadding(0, padding, 0, 0);
LayoutParams lp = new LinearLayout.LayoutParams(metrics, metrics);
lp.setMargins(left, 0, 0, 0);

View file

@ -22,7 +22,8 @@ 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 {

View file

@ -0,0 +1,91 @@
package net.osmand.plus.dashboard;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity;
/**
* Created by Denis on
* 26.03.2015.
*/
public class DashFirstTimeFragment extends DashBaseFragment {
public static final String TAG = "DASH_FIRST_TIME_FRAGMENT";
@Override
public void onOpenDash() {
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_first_time, container, false);
view.findViewById(R.id.select_region).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final OsmandSettings.DrivingRegion[] drs = OsmandSettings.DrivingRegion.values();
final OsmandSettings.DrivingRegion currentRegion = getMyApplication().getSettings().DRIVING_REGION.get();
String[] entries = new String[drs.length];
int currentIndex = 0;
for (int i = 0; i < entries.length; i++) {
if (currentRegion.equals(drs[i])){
currentIndex = i;
}
entries[i] = getString(drs[i].name); // + " (" + drs[i].defMetrics.toHumanString(this) +")" ;
}
builder.setSingleChoiceItems(entries, currentIndex, null);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int selectedPosition = ((AlertDialog)dialog).getListView().getCheckedItemPosition();
getMyApplication().getSettings().DRIVING_REGION.set(drs[selectedPosition]);
updateCurrentRegion(getView());
}
});
builder.show();
}
});
view.findViewById(R.id.hide).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((MapActivity)getActivity()).userClosedWelcomeCard();
}
});
view.findViewById(R.id.download_map).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), DownloadActivity.class);
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
getActivity().startActivity(intent);
}
});
updateCurrentRegion(view);
((ImageView)view.findViewById(R.id.car_icon)).setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_car_dark));
return view;
}
private void updateCurrentRegion(View view) {
((TextView) view.findViewById(R.id.region)).setText(getMyApplication().getSettings().DRIVING_REGION.get().name);
}
}

View file

@ -1,41 +1,9 @@
package net.osmand.plus.dashboard;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
import net.osmand.plus.development.DashSimulateFragment;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.monitoring.DashTrackFragment;
import net.osmand.plus.osmedit.DashOsmEditsFragment;
import net.osmand.plus.osmo.DashOsMoFragment;
import net.osmand.plus.parkingpoint.DashParkingFragment;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.app.Fragment;
@ -67,6 +35,38 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCal
import com.github.ksoichiro.android.observablescrollview.ScrollState;
import com.software.shell.fab.ActionButton;
import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
import net.osmand.plus.development.DashSimulateFragment;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.ScreenOrientationHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.monitoring.DashTrackFragment;
import net.osmand.plus.osmedit.DashOsmEditsFragment;
import net.osmand.plus.osmo.DashOsMoFragment;
import net.osmand.plus.parkingpoint.DashParkingFragment;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
/**
*/
public class DashboardOnMap implements ObservableScrollViewCallbacks {
@ -373,6 +373,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
public void setDashboardVisibility(boolean visible, DashboardType type, boolean animation) {
setDashboardVisibility(visible, type, this.visible ? visibleType : null, animation);
}
public void refreshDashboardFragments(){
addOrUpdateDashboardFragments(mapActivity.isFirstTime());
}
public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation) {
if(visible == this.visible && type == visibleType) {
return;
@ -395,7 +400,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll);
if(visibleType == DashboardType.DASHBOARD) {
addOrUpdateDashboardFragments();
addOrUpdateDashboardFragments(mapActivity.isFirstTime());
scrollView.setVisibility(View.VISIBLE);
listViewLayout.setVisibility(View.GONE);
updateTopButton(scrollView.getScrollY());
@ -614,15 +619,15 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
private void addOrUpdateDashboardFragments() {
private void addOrUpdateDashboardFragments(boolean firstTime) {
// boolean showCards = mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get();
boolean showCards = true;
boolean showCards = !firstTime;
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = manager.beginTransaction();
showFragment(manager, fragmentTransaction, DashFirstTimeFragment.TAG, DashFirstTimeFragment.class, firstTime);
showFragment(manager, fragmentTransaction, DashErrorFragment.TAG, DashErrorFragment.class,
mapActivity.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(mapActivity) && showCards);