Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-01-24 13:12:29 +01:00
commit 4a97b0fe28
43 changed files with 785 additions and 107 deletions

View file

@ -16,7 +16,7 @@
android:text="@string/show_all"
style="@style/DashboardGeneralButton"/>
</LinearLayout>
<LinearLayout android:id="@+id/favorites"
<LinearLayout android:id="@+id/items"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="@dimen/dashListItemHeight">
<View android:layout_width="match_parent"
android:background="@color/dashboard_divider"
android:layout_height="1dp"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/subHeaderMarginLeft"
android:layout_marginRight="@dimen/showAllButtonMarginRight"
android:layout_height="wrap_content">
<TextView android:id="@+id/name"
android:textColor="@color/dashboard_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/points_icon"
android:src="@drawable/ic_small_point"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/points_count"
android:textColor="@color/dashboard_descr_colol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/distance_icon"
android:src="@drawable/ic_small_distance"
android:layout_marginLeft="@dimen/dashPluginMargin"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/distance"
android:textColor="@color/dashboard_descr_colol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/time_icon"
android:src="@drawable/ic_small_time"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/time"
android:textColor="@color/dashboard_descr_colol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<ImageView android:id="@+id/stop"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/show_on_map"
android:layout_gravity="center_vertical"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,76 @@
<?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="match_parent">
<LinearLayout android:id="@+id/header_layout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight">
<TextView android:id="@+id/osmo_text"
android:text="@string/map_widget_av_notes"
style="@style/DashboardSubHeader"/>
<Button android:id="@+id/manage"
android:text="@string/show_all"
style="@style/DashboardGeneralButton"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight">
<TextView android:text="@string/my_location"
style="@style/DashboardSubHeader"
android:layout_weight="1"/>
<Button android:id="@+id/share"
android:text="@string/show_all"
style="@style/DashboardGeneralButton"/>
<include layout="@layout/check_item_rel" />
</LinearLayout>
<View android:background="@color/dashboard_divider"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView android:id="@+id/points_icon"
android:layout_marginLeft="@dimen/subHeaderMarginLeft"
android:src="@drawable/ic_small_point"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/points_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/distance_icon"
android:src="@drawable/ic_small_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/time_icon"
android:src="@drawable/ic_small_time"
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"
android:layout_marginRight="@dimen/showAllButtonMarginRight"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:id="@+id/items"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/dashListItemHeight">
<ImageView android:id="@+id/icon"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:layout_marginRight="@dimen/dashFavIconMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:id="@+id/people_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/people_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView android:id="@+id/direction_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
<ImageButton android:id="@+id/show_on_map"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -56,6 +56,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TracksFragment"
android:name="net.osmand.plus.dashboard.DashTrackFragment"
android:layout_marginTop="@dimen/dashCardMargin"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!--<fragment-->
<!--xmlns:android="http://schemas.android.com/apk/res/android"-->
<!--android:name="net.osmand.plus.dashboard.DashDownloadMapsFragment"-->
@ -63,6 +71,7 @@
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"/>-->
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/UpdateFragment"
@ -82,7 +91,7 @@
<!--To make sure that floating button is always visible-->
<View android:layout_width="match_parent"
android:layout_height="76dp"
android:layout_height="@dimen/dashFABMargin"
android:orientation="vertical"/>
</LinearLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize">
<LinearLayout android:id="@+id/progressContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:gravity="center">
<ProgressBar style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingTop="4dip"
android:singleLine="true" />
</LinearLayout>
<FrameLayout android:id="@+id/listContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false" />
<TextView android:id="@+id/internalEmpty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</FrameLayout>
</FrameLayout>

View file

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">
<TextView
@ -9,12 +10,12 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/select_plugin_to_activate"></TextView>
android:text="@string/select_plugin_to_activate"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_weight="1"
android:layout_height="0dp"
android:layout_marginTop="10dp"></ListView>
android:layout_marginTop="10dp"/>
</LinearLayout>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="dashFABMargin">76dp</dimen>
</resources>

View file

@ -20,6 +20,7 @@
<dimen name="dashAboutTextSize">20sp</dimen>
<dimen name="dashCardMargin">4dp</dimen>
<dimen name="abp__shadow_height">4dp</dimen>
<dimen name="dashFABMargin">0dp</dimen>
<!-- TextSizes -->
<dimen name="showAllButtonTextSize">12sp</dimen>

View file

@ -9,10 +9,16 @@
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="version_settings_descr">Download nightly builds</string>
<string name="version_settings">Builds</string>
<string name="rendering_attr_streetLighting_name">Street lighting</string>
<string name="proxy_pref_title">Proxy</string>
<string name="proxy_pref_descr">Setup a proxy internet communication</string>
<string name="settings_privacy">Privacy</string>
<string name="points">Points</string>
<string name="tracks">Tracks</string>
<string name="my_location">My location</string>
<string name="osm_editing_manage">Manage</string>
<string name="recents">RECENTS</string>
<string name="navigation_over_track">Start navigation over track?</string>
<string name="avoid_roads_msg">You can trigger an alternative route by selecting roads to avoid</string>

View file

@ -24,6 +24,7 @@ import net.osmand.plus.access.AccessibilityMode;
import net.osmand.plus.access.RelativeDirectionStyle;
import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.api.SettingsAPI.SettingsEditor;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
@ -848,7 +849,9 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> AVOID_FERRIES = new BooleanPreference("avoid_ferries", false).makeProfile().cache();
public final OsmandPreference<Boolean> PREFER_MOTORWAYS = new BooleanPreference("prefer_motorways", false).makeProfile().cache();
public final OsmandPreference<Long> LAST_UPDATES_CARD_REFRESH = new LongPreference("last_updates_card_refresh", 0).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Integer> SAVE_TRACK_INTERVAL = new IntPreference("save_track_interval", 5000).makeProfile();
{

View file

@ -79,6 +79,10 @@ public class Version {
Version v = getVersion(ctx);
return v.appVersion;
}
public static String getBuildAppEdition(OsmandApplication ctx){
return ctx.getString(R.string.app_edition);
}
public static String getAppName(OsmandApplication ctx){
Version v = getVersion(ctx);

View file

@ -0,0 +1,33 @@
package net.osmand.plus.activities;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.ProgressBar;
/**
* Created by Denis
* on 23.01.15.
*/
public class ActionBarProgressActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupIntermediateProgressBar();
}
protected void setupIntermediateProgressBar() {
ProgressBar progressBar = new ProgressBar(this);
progressBar.setVisibility(View.GONE);
progressBar.setIndeterminate(true);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(progressBar);
setSupportProgressBarIndeterminateVisibility(false);
}
@Override
public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
getSupportActionBar().getCustomView().setVisibility(visible ? View.VISIBLE : View.GONE);
}
}

View file

@ -184,7 +184,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
for (int j = 0; j < optionsMenuAdapter.length(); j++) {
MenuItem item;
item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
if (optionsMenuAdapter.getImageId(j, isLightActionBar()) != 0) {
item.setIcon(optionsMenuAdapter.getImageId(j, isLightActionBar()));
}
@ -234,8 +234,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
}
private void enableSelectionMode(boolean selectionMode) {
this.selectionMode = selectionMode;
((FavouritesActivity)getActivity()).setToolbarVisibility(!selectionMode);
}
private void openShowOnMapMode() {
selectionMode = true;
enableSelectionMode(true);
selectedItems.clear();
final Set<GpxInfo> originalSelectedItems = listAdapter.getSelectedGpx();
selectedItems.addAll(originalSelectedItems);
@ -243,7 +248,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectionMode = true;
enableSelectionMode(true);
updateSelectionMode(mode);
MenuItem it = menu.add(R.string.show_gpx_route);
it.setIcon(!isLightActionBar() ? R.drawable.ic_action_map_marker_dark : R.drawable.ic_action_map_marker_light);
@ -275,7 +280,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void onDestroyActionMode(ActionMode mode) {
selectionMode = false;
enableSelectionMode(false);
getView().findViewById(R.id.DescriptionText).setVisibility(View.GONE);
runSelection(false);
listAdapter.notifyDataSetChanged();
@ -299,13 +304,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
return;
}
selectionMode = true;
enableSelectionMode(true);
selectedItems.clear();
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectionMode = true;
enableSelectionMode(true);
MenuItem it = menu.add(actionResId);
if (actionIconId != 0) {
it.setIcon(actionIconId);
@ -337,7 +342,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public void onDestroyActionMode(ActionMode mode) {
selectionMode = false;
enableSelectionMode(false);
getView().findViewById(R.id.DescriptionText).setVisibility(View.GONE);
listAdapter.notifyDataSetChanged();
}

View file

@ -16,7 +16,6 @@ import android.widget.*;
import net.osmand.AndroidUtils;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;

View file

@ -34,7 +34,7 @@ import android.widget.TextView;
/**
*
*/
public class FavouritesActivity extends ActionBarActivity {
public class FavouritesActivity extends ActionBarProgressActivity {
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
private static final String TRACKS = "TRACKS";
@ -53,7 +53,6 @@ public class FavouritesActivity extends ActionBarActivity {
//This has to be called before setContentView and you must use the
//class in com.actionbarsherlock.view and NOT android.view
((OsmandApplication) getApplication()).applyTheme(this);
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(icicle);
setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -146,6 +145,10 @@ public class FavouritesActivity extends ActionBarActivity {
return tb;
}
public void setToolbarVisibility(boolean visible){
findViewById(R.id.bottomControls).setVisibility(visible? View.VISIBLE : View.GONE);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();

View file

@ -339,11 +339,11 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
if (!MenuItemCompat.isActionViewExpanded(mi)) {
createMenuItem(menu, SHARE_ID, R.string.share_fav, R.drawable.ic_action_gshare_light,
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
createMenuItem(menu, SELECT_DESTINATIONS_ID, R.string.select_destination_and_intermediate_points, R.drawable.ic_action_flage_light,
R.drawable.ic_action_flage_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
R.drawable.ic_action_flage_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
createMenuItem(menu, DELETE_ID, R.string.default_buttons_delete, R.drawable.ic_action_delete_light,
R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
// createMenuItem(menu, EXPORT_ID, R.string.export_fav, R.drawable.ic_action_gsave_light,
// R.drawable.ic_action_gsave_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM);
@ -363,7 +363,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectionMode = true;
enableSelectionMode(true);
createMenuItem(menu, SELECT_DESTINATIONS_ACTION_MODE_ID, R.string.select_destination_and_intermediate_points,
R.drawable.ic_action_flage_light, R.drawable.ic_action_flage_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
@ -381,7 +381,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
@Override
public void onDestroyActionMode(ActionMode mode) {
selectionMode = false;
enableSelectionMode(false);
favouritesAdapter.notifyDataSetInvalidated();
}
@ -414,11 +414,12 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
}
private void enterDeleteMode() {
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
selectionMode = true;
enableSelectionMode(true);
createMenuItem(menu, DELETE_ACTION_ID, R.string.default_buttons_delete,
R.drawable.ic_action_delete_light, R.drawable.ic_action_delete_dark,
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
@ -436,7 +437,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
@Override
public void onDestroyActionMode(ActionMode mode) {
selectionMode = false;
enableSelectionMode(false);
favouritesAdapter.notifyDataSetInvalidated();
}
@ -452,7 +453,12 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
});
}
private void enableSelectionMode(boolean selectionMode) {
this.selectionMode = selectionMode;
((FavouritesActivity)getActivity()).setToolbarVisibility(!selectionMode);
}
protected void openChangeGroupDialog(final FavoriteGroup group) {
Builder bld = new AlertDialog.Builder(getActivity());
View favEdit = getActivity().getLayoutInflater().inflate(R.layout.fav_group_edit, null);

View file

@ -84,24 +84,30 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
final int headerHeight = imageHeight - getSupportActionBar().getHeight();
final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight;
final int newAlpha = (int) (ratio * 255);
if (headerHeight < t){
int margintop = -(int)(ratio * 60);
Resources r = getResources();
int px = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
margintop,
r.getDisplayMetrics());
int margin = px + defaultMargin;
if (headerHeight < t - margin){
//hiding action bar - showing floating button
//getSupportActionBar().hide();
fabButton.showFloatingActionButton();
if (fabButton != null) {
fabButton.showFloatingActionButton();
}
} else {
//getSupportActionBar().show();
fabButton.hideFloatingActionButton();
if (fabButton != null) {
fabButton.hideFloatingActionButton();
}
//makes other cards to move on top of the map card to make it look like android animations
View fragments = findViewById(R.id.fragments);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int margintop = -(int)(ratio * 60);
Resources r = getResources();
int px = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
margintop,
r.getDisplayMetrics());
params.setMargins(0, px + defaultMargin, 0, 0);
params.setMargins(0, margin, 0, 0);
fragments.setLayoutParams(params);
}
if (newAlpha > START_ALPHA) {
@ -187,8 +193,9 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
startMapActivity();
}
});
fabButton.hideFloatingActionButton();
}
fabButton.hideFloatingActionButton();
getLocationProvider().addCompassListener(this);
getLocationProvider().registerOrUnregisterCompassListener(true);
@ -240,32 +247,10 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
edition = activity.getString(R.string.local_index_installed) + " : \t" + activity.getString(R.string.app_edition);
}
SharedPreferences prefs = app.getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
if (prefs.contains(CONTRIBUTION_VERSION_FLAG) && Version.isDeveloperVersion(app)) {
//Next 7 lines produced bogus Edition dates in many situtations, let us try (see above) to use the BUILD_ID as delivered from builder
//try {
//PackageManager pm = activity.getPackageManager();
//ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
//Date date = new Date(new File(appInfo.sourceDir).lastModified());
//edition = activity.getString(R.string.local_index_installed) + " : \t" + DateFormat.getDateFormat(app).format(date);
//} catch (Exception e) {
//}
SpannableString content = new SpannableString(vt + version + "\n" +
edition + "\n\n" +
activity.getString(R.string.about_content));
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
final Intent mapIntent = new Intent(activity, ContributionVersionActivity.class);
activity.startActivityForResult(mapIntent, 0);
}
}, st, st + version.length(), 0);
tv.setText(content);
} else {
tv.setText(vt + version + "\n" +
edition + "\n\n" +
activity.getString(R.string.about_content));
}
tv.setText(vt + version + "\n" +
edition + "\n\n" +
activity.getString(R.string.about_content));
tv.setPadding(5, 0, 5, 5);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);

View file

@ -16,7 +16,7 @@ import android.view.View;
public abstract class OsmandExpandableListActivity extends
ActionBarActivity {
ActionBarProgressActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {

View file

@ -18,7 +18,7 @@ import android.view.View;
public abstract class OsmandListActivity extends
ActionBarActivity implements AdapterView.OnItemClickListener {
ActionBarProgressActivity implements AdapterView.OnItemClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -62,20 +62,10 @@ public abstract class OsmandListActivity extends
return menuItem;
}
public void fixBackgroundRepeat(View view) {
Drawable bg = view.getBackground();
if (bg != null) {
if (bg instanceof BitmapDrawable) {
BitmapDrawable bmp = (BitmapDrawable) bg;
// bmp.mutate(); // make sure that we aren't sharing state anymore
bmp.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
}
}
}
public void setListAdapter(ListAdapter adapter){
((ListView)findViewById(android.R.id.list)).setAdapter(adapter);
setOnItemClickListener(this);
}
public ListView getListView() {

View file

@ -26,7 +26,7 @@ import android.webkit.WebViewClient;
/**
*
*/
public class PrintDialogActivity extends ActionBarActivity {
public class PrintDialogActivity extends ActionBarProgressActivity {
private WebView webView;
PrintJobId printJobId = null;
@ -35,7 +35,6 @@ public class PrintDialogActivity extends ActionBarActivity {
//This has to be called before setContentView and you must use the
//class in com.actionbarsherlock.view and NOT android.view
((OsmandApplication) getApplication()).applyTheme(this);
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
}

View file

@ -10,6 +10,8 @@ import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import net.osmand.plus.Version;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
public class SettingsActivity extends SettingsBaseActivity {
@ -26,6 +28,7 @@ public class SettingsActivity extends SettingsBaseActivity {
private Preference general;
private Preference routing;
private Preference about;
private Preference version;
@Override
@ -54,6 +57,16 @@ public class SettingsActivity extends SettingsBaseActivity {
startActivity(new Intent(this, SettingsNavigationActivity.class));
}
}
if ((Version.getBuildAppEdition(getMyApplication()).length() > 0
|| Version.isDeveloperVersion(getMyApplication())) &&
OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null){
version = new Preference(this);
version.setOnPreferenceClickListener(this);
version.setSummary(R.string.version_settings_descr);
version.setTitle(R.string.version_settings);
version.setKey("version");
screen.addPreference(version);
}
about = new Preference(this);
about.setOnPreferenceClickListener(this);
about.setSummary(R.string.about_settings_descr);
@ -100,6 +113,9 @@ public class SettingsActivity extends SettingsBaseActivity {
} else if (preference == plugins) {
startActivityForResult(new Intent(this, getMyApplication().getAppCustomization().getPluginsActivity()), PLUGINS_SELECTION_REQUEST);
return true;
} else if (preference == version){
final Intent mapIntent = new Intent(this, ContributionVersionActivity.class);
this.startActivityForResult(mapIntent, 0);
} else {
super.onPreferenceClick(preference);
}

View file

@ -51,12 +51,11 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
ListView lv = new ListView(this);
lv.setId(android.R.id.list);
setContentView(R.layout.default_list_view);
ListView lv = (ListView) findViewById(android.R.id.list);
header = new TextView(this);
helper = ((OsmandApplication)getApplication()).getRoutingHelper();
lv.addHeaderView(header);
setContentView(lv);
dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);

View file

@ -1,6 +1,5 @@
package net.osmand.plus.activities.search;
import java.util.ArrayList;
import java.util.List;
import android.support.v4.app.ListFragment;
@ -11,8 +10,8 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.SearchHistoryHelper;
import net.osmand.plus.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.activities.MapActivityActions;
import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.dialogs.DirectionsDialogs;
@ -20,7 +19,6 @@ import net.osmand.util.MapUtils;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.style.ForegroundColorSpan;
import android.view.View.OnClickListener;

View file

@ -225,13 +225,12 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
@Override
public void onCreate(Bundle icicle) {
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(icicle);
setContentView(R.layout.searchpoi);
getSupportActionBar().setTitle(R.string.searchpoi_activity);
getSupportActionBar().setIcon(R.drawable.tab_search_poi_icon);
//getSherlock().setProgressBarIndeterminateVisibility(false);
setSupportProgressBarIndeterminateVisibility(false);
app = (OsmandApplication)getApplication();

View file

@ -15,7 +15,7 @@ public class SQLiteAPIImpl implements SQLiteAPI {
@Override
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name,
readOnly? SQLiteDatabase.OPEN_READONLY : SQLiteDatabase.OPEN_READWRITE, null);
readOnly? SQLiteDatabase.OPEN_READONLY : (SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING), null);
if(db == null) {
return null;
}

View file

@ -25,7 +25,8 @@ import java.util.ArrayList;
import java.util.List;
/**
* Created by Denis on 15.12.2014.
* Created by Denis
* on 15.12.2014.
*/
public class DashAudioVideoNotesFragment extends DashBaseFragment {
AudioVideoNotesPlugin plugin;

View file

@ -55,7 +55,7 @@ public class DashFavoritesFragment extends DashBaseFragment implements Favourite
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_favorites_fragment, container, false);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.fav_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
@ -132,7 +132,7 @@ public class DashFavoritesFragment extends DashBaseFragment implements Favourite
return (dist - dist2);
}
});
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.favorites);
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
if (points.size() > 3){
while (points.size() != 3){

View file

@ -5,7 +5,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.*;
import android.widget.ImageView;
@ -134,9 +133,13 @@ public class DashMapFragment extends DashBaseFragment implements IMapDownloaderC
private void applicationInitialized(View view) {
updateMapImage();
view.findViewById(R.id.loading).setVisibility(View.GONE);
MainMenuActivity dashboardActivity = ((MainMenuActivity) getActivity());
if (dashboardActivity != null) {
dashboardActivity.updateDownloads();
MainMenuActivity mainMenuActivity = ((MainMenuActivity) getActivity());
if (mainMenuActivity != null) {
if (System.currentTimeMillis() - getMyApplication().getSettings().LAST_UPDATES_CARD_REFRESH.get()
> 12*60*60*1000 ) {
getMyApplication().getSettings().LAST_UPDATES_CARD_REFRESH.set(System.currentTimeMillis());
mainMenuActivity.updateDownloads();
}
view.findViewById(R.id.map_image).setVisibility(View.VISIBLE);
}
}

View file

@ -0,0 +1,58 @@
package net.osmand.plus.dashboard;
import android.graphics.Typeface;
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.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.osmedit.OsmEditingPlugin;
/**
* Created by Denis
* on 20.01.2015.
*/
public class DashOsmEditsFragment extends DashBaseFragment {
OsmEditingPlugin plugin;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
TextView header = ((TextView) view.findViewById(R.id.notes_text));
header.setTypeface(typeface);
header.setText(R.string.osm_settings);
Button manage = ((Button) view.findViewById(R.id.show_all));
manage.setTypeface(typeface);
manage.setText(R.string.osm_editing_manage);
return view;
}
@Override
public void onResume() {
super.onResume();
if (plugin == null) {
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
}
setupEditings();
}
private void setupEditings() {
View mainView = getView();
if (plugin == null){
mainView.setVisibility(View.GONE);
return;
}
}
}

View file

@ -0,0 +1,34 @@
package net.osmand.plus.dashboard;
import android.graphics.Typeface;
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.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.osmo.OsMoPlugin;
/**
* Created by Denis
* on 20.01.2015.
*/
public class DashOsmoFragment extends DashBaseFragment {
OsMoPlugin plugin;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_osmo_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.osmo_text)).setTypeface(typeface);
Button manage = (Button) view.findViewById(R.id.manage);
return view;
}
}

View file

@ -0,0 +1,97 @@
package net.osmand.plus.dashboard;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.IndexConstants;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.helpers.GpxUiHelper;
import java.io.File;
import java.util.List;
/**
* Created by Denis
* on 21.01.2015.
*/
public class DashTrackFragment extends DashBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
TextView header = (TextView) view.findViewById(R.id.fav_text);
header.setTypeface(typeface);
header.setText(R.string.tracks);
((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) {
Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites);
}
});
return view;
}
@Override
public void onResume() {
super.onResume();
setupGpxFiles();
}
private void setupGpxFiles() {
View mainView = getView();
final File dir = getMyApplication().getAppPath(IndexConstants.GPX_INDEX_DIR);
final List<String> list = GpxUiHelper.getSortedGPXFilenames(dir);
if (list.size() == 0){
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
LinearLayout tracks = (LinearLayout) mainView.findViewById(R.id.items);
tracks.removeAllViews();
if (list.size() > 3){
while (list.size() != 3){
list.remove(3);
}
}
for (String filename : list){
final File f = new File(dir, filename);
GPXUtilities.GPXFile res = GPXUtilities.loadGPXFile(getMyApplication(), f);
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_gpx_track_item, null, false);
((TextView)view.findViewById(R.id.name)).setText(filename);
((TextView)view.findViewById(R.id.points_count)).
setText(res.points.size() + " " + getActivity().getString(R.string.points));
String description = GpxUiHelper.getDescription(getMyApplication(), res, f, true);
int startindex = description.indexOf(">");
int endindex = description.indexOf("</font>");
String distnace = description.substring(startindex + 1, endindex);
((TextView)view.findViewById(R.id.distance)).
setText(distnace);
view.findViewById(R.id.time_icon).setVisibility(View.GONE);
//view.findViewById(R.id.distance_icon).setVisibility(View.GONE);
tracks.addView(view);
}
}
}

View file

@ -20,6 +20,7 @@ import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.helpers.DownloadFrequencyHelper;
import net.osmand.plus.helpers.FontCache;
/**
@ -70,6 +71,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
cancelButton = null;
}
updatedDownloadsList(BaseDownloadActivity.downloadListIndexThread.getItemsToUpdate());
}
public void updatedDownloadsList(List<IndexItem> list) {
@ -77,7 +79,8 @@ public class DashUpdatesFragment extends DashBaseFragment {
Collections.sort(itemList, new Comparator<IndexItem>() {
@Override
public int compare(IndexItem indexItem, IndexItem t1) {
return (int)(t1.getTimestamp() - indexItem.getTimestamp());
DownloadFrequencyHelper helper = BaseDownloadActivity.downloadListIndexThread.getDbHelper();
return (int)(helper.getCount(t1.getBasename()) - helper.getCount(indexItem.getBasename()));
}
});
View mainView = getView();

View file

@ -22,6 +22,7 @@ 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.ActionBarProgressActivity;
import net.osmand.plus.activities.MainMenuActivity;
import net.osmand.plus.activities.SettingsGeneralActivity;
import net.osmand.plus.base.BasicProgressAsyncTask;
@ -34,9 +35,10 @@ import android.widget.Toast;
import net.osmand.plus.base.SuggestExternalDirectoryDialog;
/**
* Created by Denis on 25.11.2014.
* Created by Denis
* on 25.11.2014.
*/
public class BaseDownloadActivity extends ActionBarActivity {
public class BaseDownloadActivity extends ActionBarProgressActivity {
protected DownloadActivityType type = DownloadActivityType.NORMAL_FILE;
protected OsmandSettings settings;
public static DownloadIndexesThread downloadListIndexThread;

View file

@ -62,16 +62,16 @@ public class DownloadActivity extends BaseDownloadActivity {
public static final String SINGLE_TAB = "SINGLE_TAB";
private List<DownloadActivityType> downloadTypes = new ArrayList<DownloadActivityType>();
@Override
protected void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setupIntermediateProgressBar();
updateDownloads();
setSupportProgressBarIndeterminateVisibility(false);
setContentView(R.layout.tab_content);
findViewById(R.id.bottomControls).setVisibility(View.GONE);
singleTab = getIntent() != null && getIntent().getBooleanExtra(SINGLE_TAB, false);
int currentTab = 0;
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
@ -161,6 +161,7 @@ public class DownloadActivity extends BaseDownloadActivity {
public Map<String, String> getIndexActivatedFileNames() {
return downloadListIndexThread != null ? downloadListIndexThread.getIndexActivatedFileNames() : null;
}

View file

@ -24,6 +24,7 @@ import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
import net.osmand.plus.helpers.DownloadFrequencyHelper;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.Algorithms;
@ -57,14 +58,20 @@ public class DownloadIndexesThread {
private java.text.DateFormat dateFormat;
private List<IndexItem> itemsToUpdate = new ArrayList<IndexItem>();
DownloadFrequencyHelper dbHelper;
public DownloadIndexesThread(Context ctx) {
this.ctx = ctx;
app = (OsmandApplication) ctx.getApplicationContext();
downloadFileHelper = new DownloadFileHelper(app);
dateFormat = app.getResourceManager().getDateFormat();
dbHelper = new DownloadFrequencyHelper(app);
}
public DownloadFrequencyHelper getDbHelper(){
return dbHelper;
}
public void clear() {
indexFiles = null;
}
@ -146,12 +153,25 @@ public class DownloadIndexesThread {
if (uiActivity != null) {
uiActivity.downloadListUpdated();
uiActivity.updateDownloadButton(false);
DownloadEntry item = (DownloadEntry)o;
String name = item.item.getBasename();
long count = dbHelper.getCount(name) + 1;
DownloadFrequencyHelper.HistoryEntry entry = new DownloadFrequencyHelper.HistoryEntry(name,count);
if (count == 1) {
dbHelper.add(entry);
} else {
dbHelper.update(entry);
}
}
} else if (o instanceof IndexItem) {
entriesToDownload.remove(o);
if (uiActivity != null) {
uiActivity.downloadListUpdated();
uiActivity.updateDownloadButton(false);
IndexItem item = (IndexItem)o;
long count = dbHelper.getCount(item.getBasename()) + 1;
dbHelper.add(new DownloadFrequencyHelper.HistoryEntry(item.getBasename(), count));
}
} else if (o instanceof String) {
String message = (String) o;

View file

@ -478,6 +478,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
if (!this.isAdded()) {
return;
}
//fixes issue when local files not shown after switching tabs
//Next line throws NPE in some circumstances when called from dashboard and listAdpater=null is not checked for. (Checking !this.isAdded above is not sufficient!)
if (listAdapter != null && listAdapter.getGroupCount() == 0 && getDownloadActivity().getLocalIndexInfos().size() > 0) {
@ -722,7 +723,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
if ( getDownloadActivity() == null) {
return;
}
getDownloadActivity().setProgressBarIndeterminateVisibility(false);
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
if (!warnings.isEmpty()) {
final StringBuilder b = new StringBuilder();
boolean f = true;
@ -744,7 +745,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
@Override
protected void onPreExecute() {
super.onPreExecute();
getDownloadActivity().setProgressBarIndeterminateVisibility(true);
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true);
}
@Override
protected List<String> doInBackground(Void... params) {

View file

@ -0,0 +1,170 @@
package net.osmand.plus.helpers;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.api.SQLiteAPI;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Denis
* on 23.01.15.
*/
public class DownloadFrequencyHelper {
private static final String DB_NAME = "download_history"; //$NON-NLS-1$
private static final int DB_VERSION = 1;
private static final String HISTORY_TABLE_NAME = "history"; //$NON-NLS-1$
private static final String HISTORY_COL_NAME = "name"; //$NON-NLS-1$
private static final String HISTORY_COL_COUNT = "count"; //$NON-NLS-1$
private static final String HISTORY_TABLE_CREATE = "CREATE TABLE " + HISTORY_TABLE_NAME + " (" + //$NON-NLS-1$ //$NON-NLS-2$
HISTORY_COL_NAME + " TEXT, " + HISTORY_COL_COUNT + " long);"; //$NON-NLS-1$ //$NON-NLS-2$
private OsmandApplication app;
public static class HistoryEntry {
long count;
String name;
public HistoryEntry(String name, long count){
this.count = count;
this.name = name;
}
public String getName() {
return name;
}
public long getCount() {
return count;
}
}
public DownloadFrequencyHelper(OsmandApplication context) {
app = context;
}
private SQLiteAPI.SQLiteConnection openConnection(boolean readonly) {
SQLiteAPI.SQLiteConnection conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) {
if (readonly) {
conn.close();
conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, true);
}
if (conn.getVersion() == 0) {
conn.setVersion(DB_VERSION);
onCreate(conn);
} else {
onUpgrade(conn, conn.getVersion(), DB_VERSION);
}
}
return conn;
}
public void onCreate(SQLiteAPI.SQLiteConnection db) {
db.execSQL(HISTORY_TABLE_CREATE);
}
public void onUpgrade(SQLiteAPI.SQLiteConnection db, int oldVersion, int newVersion) {
}
public boolean remove(HistoryEntry e){
SQLiteAPI.SQLiteConnection db = openConnection(false);
if(db != null){
try {
db.execSQL("DELETE FROM " + HISTORY_TABLE_NAME + " WHERE " + HISTORY_COL_NAME + " = ?", new Object[] { e.getName() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} finally {
db.close();
}
return true;
}
return false;
}
public boolean removeAll(){
SQLiteAPI.SQLiteConnection db = openConnection(false);
if(db != null){
try {
db.execSQL("DELETE FROM " + HISTORY_TABLE_NAME); //$NON-NLS-1$
} finally {
db.close();
}
return true;
}
return false;
}
public boolean update(HistoryEntry e){
SQLiteAPI.SQLiteConnection db = openConnection(false);
if(db != null){
try {
db.execSQL(
"UPDATE " + HISTORY_TABLE_NAME + " SET " + HISTORY_COL_COUNT + " = ? WHERE " + HISTORY_COL_NAME + " = ?", new Object[] { e.getCount(), e.getName() }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} finally {
db.close();
}
return true;
}
return false;
}
public boolean add(HistoryEntry e){
SQLiteAPI.SQLiteConnection db = openConnection(false);
if(db != null){
try {
db.execSQL(
"INSERT INTO " + HISTORY_TABLE_NAME + " VALUES (?, ?)", new Object[] { e.getName(), e.getCount()}); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
db.close();
}
return true;
}
return false;
}
public long getCount(String name) {
SQLiteAPI.SQLiteConnection db = openConnection(true);
long count = 0;
if(db != null){
try {
SQLiteAPI.SQLiteCursor query = db.rawQuery(
"SELECT " + HISTORY_COL_COUNT + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
HISTORY_TABLE_NAME + " WHERE " + HISTORY_COL_NAME + "='" + name + "'", null); //$NON-NLS-1$//$NON-NLS-2$
if (query.moveToFirst()) {
do {
count = query.getInt(0);
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
}
return count;
}
public List<HistoryEntry> getEntries(){
List<HistoryEntry> entries = new ArrayList<HistoryEntry>();
SQLiteAPI.SQLiteConnection db = openConnection(true);
if(db != null){
try {
SQLiteAPI.SQLiteCursor query = db.rawQuery(
"SELECT " + HISTORY_COL_NAME + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
HISTORY_TABLE_NAME + " ORDER BY " + HISTORY_COL_COUNT + " DESC", null); //$NON-NLS-1$//$NON-NLS-2$
if (query.moveToFirst()) {
do {
HistoryEntry e = new HistoryEntry(query.getString(0), query.getInt(1));
entries.add(e);
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
}
return entries;
}
}

View file

@ -389,7 +389,7 @@ public class GpxUiHelper {
}
}
}
private static List<String> getSortedGPXFilenames(File dir) {
public static List<String> getSortedGPXFilenames(File dir) {
return getSortedGPXFilenames(dir, null);
}

View file

@ -1,8 +1,9 @@
package net.osmand.plus;
package net.osmand.plus.helpers;
import java.util.ArrayList;
import java.util.List;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;

View file

@ -63,7 +63,6 @@ public class LocalOpenstreetmapActivity extends OsmandListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setContentView(R.layout.local_openstreetmap);
getSupportActionBar().setTitle(R.string.download_files);

View file

@ -126,8 +126,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
@Override
public void onCreate(Bundle icicle) {
// This has to be called before setContentView and you must use the
// class in com.actionbarsherlock.view and NOT android.view
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
//TODO: remove this deprecated code with toolbar
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
}

View file

@ -51,7 +51,6 @@ public class RoutePointsActivity extends OsmandListActivity {
protected void onCreate(Bundle savedInstanceState) {
this.app = (OsmandApplication) getApplication();
plugin = OsmandPlugin.getEnabledPlugin(RoutePointsPlugin.class);
supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setTitle(R.string.route_points_activity);