This commit is contained in:
Denis 2015-02-25 13:16:31 +02:00
commit d6f4f3ecab
17 changed files with 382 additions and 302 deletions

View file

@ -1,24 +1,34 @@
<?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="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/current_track"
android:orientation="vertical"
<LinearLayout
android:id="@+id/current_track"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:background="?attr/card_bg"
android:orientation="vertical">
<include android:layout_height="wrap_content"
android:layout_width="match_parent"
layout="@layout/dash_gpx_track_item"/>
<include
layout="@layout/dash_gpx_track_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button android:id="@+id/map_btn"
android:text="@string/back_to_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
</LinearLayout>
<Button
android:id="@+id/map_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background"
android:text="@string/back_to_map"/>
</LinearLayout>
<ExpandableListView
@ -26,11 +36,11 @@
style="@style/OsmandListView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:background="?attr/expandable_list_background"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:background="?attr/expandable_list_background"
android:groupIndicator="@android:color/transparent"/>

View file

@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dashListItemHeight"
android:orientation="vertical">
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/dashNoteIconSize"
android:layout_height="@dimen/dashNoteIconSize"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:layout_marginRight="@dimen/dashFavIconMargin"
tools:src="@drawable/ic_type_audio" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/dashFavNameTextSize"
tools:text="@string/lorem_ipsum" />
<TextView
android:id="@+id/descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textSize="@dimen/showAllButtonTextSize"
android:textColor="?android:textColorSecondary"
tools:text="@string/lorem_ipsum" />
</LinearLayout>
<ImageButton
android:id="@+id/play"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_play_light"/>
</LinearLayout>
</LinearLayout>

View file

@ -77,7 +77,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:textColor="@color/dashboard_descr_colol"
android:textColor="@color/icon_color_light"
android:textSize="@dimen/showAllButtonTextSize"/>
</LinearLayout>

View file

@ -1,73 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dashListItemHeight">
<View android:layout_width="match_parent"
android:background="?attr/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="?android:textColorPrimary"
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"/>
android:layout_height="wrap_content"
android:minHeight="@dimen/dashListItemHeight"
android:orientation="vertical">
<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"/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<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
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/subHeaderMarginLeft"
android:layout_marginRight="@dimen/showAllButtonMarginRight"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
tools:text="@string/validate_gpx_upload_name_pwd"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/points_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_small_point"/>
<TextView
android:id="@+id/points_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/icon_color_light"/>
<ImageView
android:id="@+id/distance_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashPluginMargin"
android:src="@drawable/ic_small_distance"/>
<TextView
android:id="@+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/icon_color_light"/>
<ImageView
android:id="@+id/time_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_small_time"/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/icon_color_light"/>
</LinearLayout>
</LinearLayout>
<ImageButton android:id="@+id/stop"
android:visibility="gone"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageButton
android:id="@+id/stop"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:background="?attr/options_button_background"
android:src="@drawable/ic_action_rec_stop"
android:visibility="gone"
tools:visibility="visible"/>
<ImageButton android:id="@+id/show_on_map"
android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"/>
<ImageButton
android:id="@+id/show_on_map"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:background="?attr/options_button_background"
android:src="@drawable/ic_action_gsave_dark"/>
</LinearLayout>

View file

@ -22,7 +22,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:textColor="@color/dashboard_descr_colol"
android:textColor="@color/icon_color_light"
android:text="@string/loading_data"
android:textSize="@dimen/dashProgressTextSize"/>
</LinearLayout>

View file

@ -84,7 +84,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:textColor="@color/dashboard_descr_colol"
android:textColor="@color/icon_color_light"
android:textSize="@dimen/showAllButtonTextSize"/>
</LinearLayout>

View file

@ -5,63 +5,85 @@
android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/list_content_padding">
<CheckBox
android:id="@+id/check_local_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/local_index_check_right_margin"
android:focusable="false"
android:visibility="gone"/>
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:focusable="false"
android:src="@drawable/ic_sdcard"/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:visibility="gone"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
style="@style/ListText.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/check_local_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
tools:text="@string/app_version"/>
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/local_index_check_right_margin"
android:focusable="false"
android:visibility="gone"/>
<TextView
android:id="@+id/descr"
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="@dimen/download_descr_text_size"
android:maxLines="25"
tools:text="@string/app_mode_aircraft"/>
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/favorites_icon_right_margin"
android:focusable="false"
android:src="@drawable/ic_sdcard"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/name"
style="@style/ListText.Small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
tools:text="@string/app_version"/>
</LinearLayout>
<TextView
android:id="@+id/descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="@dimen/download_descr_text_size"
android:maxLines="25"
tools:text="@string/app_mode_aircraft"/>
</LinearLayout>
<ImageButton
android:id="@+id/options"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="center_vertical"
android:background="?attr/options_button_background"
android:focusable="false"
android:src="?attr/list_settings_icon"/>
<ImageButton
android:id="@+id/play"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dashFavIconMargin"
android:background="?attr/dashboard_button"
android:src="@drawable/ic_play_light"/>
</LinearLayout>
<ImageButton
android:id="@+id/options"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="center_vertical"
android:background="?attr/options_button_background"
android:focusable="false"
android:src="?attr/list_settings_icon"/>
</LinearLayout>

View file

@ -20,7 +20,9 @@
<color name="search_background_dark">#292f33</color>
<color name="dashboard_descr_colol">#727272</color>
<color name="icon_color_light">#727272</color>
<color name="dashboard_gpx_on_map">#448AFF</color>
<color name="dashboard_background">#eaeaea</color>
<color name="dashboard_divider_light">#F0F0F0</color>
<color name="dashboard_divider_dark">#3d474c</color>

View file

@ -9,8 +9,9 @@
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="currently_recording_track">Currently recording track</string>
<string name="rename_failed">Rename failed.</string>
<string name="days_behind">days behind</string>
<string name="currently_recording_track">Currently recording track</string>
<string name="back_to_map">Back to map</string>
<string name="plugin_nautical_descr1">Activating this view changes the map style to Nautical, thus showing all nautical navigation marks and chart symbols.</string>
<string name="plugin_nautical_descr2">A map file containing all nautical symbols globally is available as one single download called \'World seamarks\'.</string>

View file

@ -48,6 +48,7 @@ public abstract class ActionBarPreferenceActivity extends PreferenceActivity {
}
tb.setClickable(true);
Drawable back = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
back.mutate();
back.setColorFilter(0xffffffff, PorterDuff.Mode.MULTIPLY);
tb.setNavigationIcon(back);
tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground)));

View file

@ -37,7 +37,9 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
@ -111,27 +113,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
asyncLoader = new LoadGpxTask();
asyncLoader.execute(getActivity());
}
OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
GpxSelectionHelper.SelectedGpxFile currentTrack = savingTrackHelper.getCurrentTrack();
View v = getView();
if (v == null){
return;
}
if (plugin != null && savingTrackHelper.getCurrentGpx() != null) {
updateCurrentTrack(getView());
v.findViewById(R.id.current_track).setVisibility(View.VISIBLE);
((TextView)v.findViewById(R.id.name)).setText(R.string.currently_recording_track);
String description = GpxUiHelper.getDescription(getMyApplication(), currentTrack.getGpxFile(), null, true);
int startindex = description.indexOf(">");
int endindex = description.indexOf("</font>");
String distnace = description.substring(startindex + 1, endindex);
((TextView)v.findViewById(R.id.distance)).setText(distnace);
v.findViewById(R.id.time_icon).setVisibility(View.GONE);
} else {
v.findViewById(R.id.current_track).setVisibility(View.GONE);
}
//TODO implement updating view of current track
}
@Override
@ -142,6 +126,24 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
}
private void updateCurrentTrack(View v){
if (v == null){
return;
}
OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
GpxSelectionHelper.SelectedGpxFile currentTrack = savingTrackHelper.getCurrentTrack();
if (plugin != null && savingTrackHelper.getCurrentGpx() != null) {
v.findViewById(R.id.current_track).setVisibility(View.VISIBLE);
String description = GpxUiHelper.getDescription(getMyApplication(), currentTrack.getGpxFile(), null, true);
int startindex = description.indexOf(">");
int endindex = description.indexOf("</font>");
String distance = description.substring(startindex + 1, endindex);
((TextView)v.findViewById(R.id.distance)).setText(distance);
} else {
v.findViewById(R.id.current_track).setVisibility(View.GONE);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -150,6 +152,29 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if(this.adapter != null) {
listView.setAdapter(this.adapter);
}
((TextView)v.findViewById(R.id.name)).setText(R.string.currently_recording_track);
v.findViewById(R.id.time_icon).setVisibility(View.GONE);
Drawable icon = getResources().getDrawable(R.drawable.ic_action_rec_stop);
icon.mutate();
boolean light = getMyApplication().getSettings().isLightContent();
if (light){
icon.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
}
ImageButton stop = ((ImageButton)v.findViewById(R.id.stop));
stop.setImageDrawable(icon);
stop.setVisibility(View.VISIBLE);
icon = getResources().getDrawable(R.drawable.ic_action_gsave_dark);
icon.mutate();
if (light) {
icon.setColorFilter(0xff727272, PorterDuff.Mode.MULTIPLY);
}
ImageButton save = ((ImageButton)v.findViewById(R.id.show_on_map));
v.findViewById(R.id.divider).setVisibility(View.GONE);
save.setImageDrawable(icon);
updateCurrentTrack(v);
return v;
}
@ -225,7 +250,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
};
optionsMenuAdapter.item(R.string.show_gpx_route)
.icons(R.drawable.ic_action_map_marker_dark, R.drawable.ic_action_map_marker_dark).listen(listener).reg();
.icons(R.drawable.ic_show_on_map, R.drawable.ic_show_on_map).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_delete)
.icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark).listen(listener).reg();
optionsMenuAdapter.item(R.string.local_index_mi_reload)
@ -532,26 +557,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
}
}
private void showContextMenu(final GpxInfo info) {
Builder builder = new AlertDialog.Builder(getActivity());
final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity());
basicFileOperation(info, adapter);
String[] values = adapter.getItemNames();
builder.setItems(values, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
OnContextMenuClick clk = adapter.getClickAdapter(which);
if (clk != null) {
clk.onContextMenuClick(null, adapter.getElementId(which), which, false);
}
}
});
builder.show();
}
public class LoadGpxTask extends AsyncTask<Activity, GpxInfo, List<GpxInfo>> {
private List<GpxInfo> result;
@ -915,8 +920,13 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
boolean light = getMyApplication().getSettings().isLightContent();
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
Drawable showIcon = getResources().getDrawable(R.drawable.ic_show_on_map);
if (light) {
showIcon.mutate();
showIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
MenuItem item = optionsMenu.getMenu().add(R.string.show_gpx_route)
.setIcon(light ? R.drawable.ic_action_map_marker_light : R.drawable.ic_action_map_marker_dark);
.setIcon(showIcon);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {

View file

@ -38,10 +38,12 @@ public class FavoritesActivity extends TabActivity {
// private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
private static final String TRACKS = "TRACKS";
// private static final String SELECTED_TRACK = "SELECTED_TRACK";
// public static int FAVORITES_TAB = 0;
// public static int GPX_TAB = 1;
// public static int SELECTED_GPX_TAB = 2;
// public static String TAB_PARAM = "TAB_PARAM";
public static int FAVORITES_TAB = 0;
public static int GPX_TAB = 1;
public static int SELECTED_GPX_TAB = 2;
public static int NOTES_TAB = 3;
public static int OSM_EDITS_TAB = 4;
public static String TAB_PARAM = "TAB_PARAM";
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
@Override
@ -78,10 +80,18 @@ public class FavoritesActivity extends TabActivity {
OsmandPlugin.addMyPlacesTabPlugins(this, mTabs, getIntent());
Integer tab = settings.FAVORITES_TAB.get();
if (tab == NOTES_TAB) {
tab = mTabs.size() -1;
} else if (tab == OSM_EDITS_TAB) {
//TODO implement method of counting position for other plugins
}
setViewPagerAdapter(mViewPager, mTabs);
mSlidingTabLayout.setViewPager(mViewPager);
if (tab > mTabs.size() - 1){
tab = 0;
}
mViewPager.setCurrentItem(tab);
updateSelectedTracks();
// setupHomeButton();

View file

@ -67,6 +67,7 @@ import android.media.MediaRecorder;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.Display;
import android.view.KeyEvent;
@ -138,9 +139,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
this.file = f;
}
public File file;
private File file;
private String name;
private double lat;
private double lon;
private long duration = -1;
@ -172,12 +172,26 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
}
public void setName(String name) {
this.name = name;
public File getFile() {
return file;
}
public boolean setName(String name) {
int index = file.getAbsolutePath().lastIndexOf("/") + 1;
if (index < 0){
return false;
}
File directory = new File(file.getAbsolutePath().substring(0, index));
File to = new File(directory, name.trim());
if (file.renameTo(to)){
file = to;
return true;
}
return false;
}
public String getName() {
return name;
return file.getName();
}
public boolean isPhoto() {
@ -289,13 +303,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
public String getSmallDescription(Context ctx) {
String nm = name == null ? "" : name;
String time = AndroidUtils.formatDateTime(ctx,file.lastModified());
if (isPhoto()) {
return ctx.getString(R.string.recording_photo_description, nm, time).trim();
return ctx.getString(R.string.recording_photo_description, "", time).trim();
}
return ctx.getString(R.string.recording_description, nm, "", time).trim();
return ctx.getString(R.string.recording_description, "", "", time).trim();
}
private String getDuration(Context ctx) {
@ -934,7 +947,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (getAllRecordings().size() > 0) {
mTabs.add(favoritesActivity.getTabIndicator(R.string.notes, NotesFragment.class));
if (intent != null && "AUDIO".equals(intent.getStringExtra("TAB"))) {
app.getSettings().FAVORITES_TAB.set(mTabs.size() - 1);
app.getSettings().FAVORITES_TAB.set(FavoritesActivity.NOTES_TAB);
}
}
}

View file

@ -49,6 +49,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
final Intent favorites = new Intent(activity, fa);
favorites.putExtra("TAB", "AUDIO");
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.NOTES_TAB);
activity.startActivity(favorites);
}
});
@ -94,15 +95,23 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
for (final AudioVideoNotesPlugin.Recording recording : notes){
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dash_audio_video_notes_item, null, false);
View view = inflater.inflate(R.layout.note, null, false);
getNoteView(recording, view, getActivity(), plugin);
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.playRecording(getActivity(), recording);
}
});
view.findViewById(R.id.options).setVisibility(View.GONE);
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getMyApplication().getSettings().setMapLocationToShow(recording.getLatitude(), recording.getLongitude(), 15,
new PointDescription(PointDescription.POINT_TYPE_NOTE,
!Algorithms.isEmpty(recording.getName())? recording.getName() : recording.getDescription(getActivity())), true,
(recording.getName() != null) ? recording.getName() : recording.getDescription(getActivity())), true,
recording); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(getActivity());
}
@ -113,29 +122,28 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
public static void getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
final Context ctx, final AudioVideoNotesPlugin plugin) {
if (recording.getName() != null){
((TextView) view.findViewById(R.id.name)).setText(recording.getName());
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
} else {
((TextView) view.findViewById(R.id.name)).setText(recording.getDescription(ctx));
view.findViewById(R.id.descr).setVisibility(View.GONE);
String name = recording.getName();
TextView nameText = ((TextView) view.findViewById(R.id.name));
if (name != null) {
nameText.setText(name);
} else if (recording.isAudio()) {
nameText.setText(R.string.audio);
} else if (recording.isVideo()) {
nameText.setText(R.string.video);
} else if (recording.isPhoto()) {
nameText.setText(R.string.photo);
}
((TextView) view.findViewById(R.id.descr)).setText(recording.getDescription(ctx));
ImageView icon = (ImageView) view.findViewById(R.id.icon);
if (recording.isAudio()){
if (recording.isAudio()) {
icon.setImageResource(R.drawable.ic_type_audio);
} else if (recording.isVideo()){
} else if (recording.isVideo()) {
icon.setImageResource(R.drawable.ic_type_video);
} else {
icon.setImageResource(R.drawable.ic_type_img);
}
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
plugin.playRecording(ctx, recording);
}
});
}
}

View file

@ -28,6 +28,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.dialogs.DirectionsDialogs;
import android.support.v4.app.ListFragment;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
@ -89,27 +90,8 @@ public class NotesFragment extends ListFragment {
}
final AudioVideoNotesPlugin.Recording recording = getItem(position);
String name = recording.getName();
TextView nameText = ((TextView) row.findViewById(R.id.name));
if (name != null) {
nameText.setText(name);
} else if (recording.isAudio()) {
nameText.setText(R.string.audio);
} else if (recording.isVideo()) {
nameText.setText(R.string.video);
} else if (recording.isPhoto()) {
nameText.setText(R.string.photo);
}
((TextView) row.findViewById(R.id.descr)).setText(recording.getDescription(getActivity()));
ImageView icon = (ImageView) row.findViewById(R.id.icon);
if (recording.isAudio()) {
icon.setImageResource(R.drawable.ic_type_audio);
} else if (recording.isVideo()) {
icon.setImageResource(R.drawable.ic_type_video);
} else {
icon.setImageResource(R.drawable.ic_type_img);
}
DashAudioVideoNotesFragment.getNoteView(recording, row, getActivity(), plugin);
row.findViewById(R.id.play).setVisibility(View.GONE);
ImageButton options = (ImageButton) row.findViewById(R.id.options);
options.setOnClickListener(new View.OnClickListener() {
@Override
@ -173,15 +155,15 @@ public class NotesFragment extends ListFragment {
public boolean onMenuItemClick(MenuItem item) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
if (recording.isPhoto()) {
Uri screenshotUri = Uri.parse(recording.file.getAbsolutePath());
Uri screenshotUri = Uri.parse(recording.getFile().getAbsolutePath());
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
} else if (recording.isAudio()) {
Uri audioUri = Uri.parse(recording.file.getAbsolutePath());
Uri audioUri = Uri.parse(recording.getFile().getAbsolutePath());
sharingIntent.setType("audio/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, audioUri);
} else if (recording.isVideo()) {
Uri videoUri = Uri.parse(recording.file.getAbsolutePath());
Uri videoUri = Uri.parse(recording.getFile().getAbsolutePath());
sharingIntent.setType("video/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
}
@ -229,12 +211,23 @@ public class NotesFragment extends ListFragment {
getListView(), false);
final EditText editText = (EditText) v.findViewById(R.id.name);
builder.setView(v);
editText.setText(recording.getName());
String fileName = recording.getName();
int extInd = recording.getName().lastIndexOf(".");
final String extension;
if (extInd >= 0){
extension = fileName.substring(extInd, fileName.length());
} else {
extension = "";
}
editText.setText(recording.getName().substring(0, extInd));
builder.setNegativeButton(R.string.default_buttons_cancel, null);
builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
recording.setName(editText.getText().toString());
if(!recording.setName(editText.getText().toString() + extension)) {
Toast.makeText(getActivity(),R.string.rename_failed,Toast.LENGTH_SHORT).show();
}
recording.setDescription();
listAdapter.notifyDataSetInvalidated();
}

View file

@ -13,6 +13,7 @@ import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.activities.FavoritesActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs;
@ -56,6 +57,7 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.FAVORITES_TAB);
activity.startActivity(favorites);
}
});

View file

@ -4,15 +4,23 @@ import java.io.File;
import java.util.List;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.FavoritesActivity;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashBaseFragment;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.helpers.GpxUiHelper;
import android.app.Activity;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -21,6 +29,7 @@ import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
/**
* Created by Denis
@ -43,6 +52,7 @@ public class DashTrackFragment extends DashBaseFragment {
Activity activity = getActivity();
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
getMyApplication().getSettings().FAVORITES_TAB.set(FavoritesActivity.GPX_TAB);
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites);
}
@ -62,7 +72,7 @@ public class DashTrackFragment extends DashBaseFragment {
final List<String> list = GpxUiHelper.getSortedGPXFilenames(dir);
if (list.size() == 0){
if (list.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
@ -71,32 +81,69 @@ public class DashTrackFragment extends DashBaseFragment {
LinearLayout tracks = (LinearLayout) mainView.findViewById(R.id.items);
tracks.removeAllViews();
if (list.size() > 3){
while (list.size() != 3){
if (list.size() > 3) {
while (list.size() != 3) {
list.remove(3);
}
}
for (String filename : list){
for (String filename : list) {
final File f = new File(dir, filename);
GPXUtilities.GPXFile res = GPXUtilities.loadGPXFile(getMyApplication(), f);
final 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)).
((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)).
((TextView) view.findViewById(R.id.distance)).
setText(distnace);
view.findViewById(R.id.time_icon).setVisibility(View.GONE);
boolean light = getMyApplication().getSettings().isLightContent();
Drawable icon = getResources().getDrawable(R.drawable.ic_show_on_map);
GpxSelectionHelper gpxSelectionHelper = getMyApplication().getSelectedGpxHelper();
boolean isShowingOnMap = gpxSelectionHelper.getSelectedFileByName(filename) != null;
//setting proper icon color
if (isShowingOnMap) {
icon.mutate();
if (light) {
icon.setColorFilter(getResources().getColor(R.color.dashboard_gpx_on_map), PorterDuff.Mode.MULTIPLY);
} else {
icon.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
}
} else if (light) {
icon.mutate();
icon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
final ImageButton showOnMap = (ImageButton) view.findViewById(R.id.show_on_map);
showOnMap.setImageDrawable(icon);
showOnMap.setVisibility(View.VISIBLE);
//view.findViewById(R.id.distance_icon).setVisibility(View.GONE);
view.findViewById(R.id.stop).setVisibility(View.GONE);
((ImageButton)view.findViewById(R.id.show_on_map)).
setImageDrawable(getResources().getDrawable(R.drawable.ic_action_map));
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showOnMap(res);
}
});
tracks.addView(view);
}
}
private void showOnMap(GPXUtilities.GPXFile file){
if (file.isEmpty()) {
AccessibleToast.makeText(getActivity(), R.string.gpx_file_is_empty, Toast.LENGTH_LONG).show();
return;
}
OsmandSettings settings = getMyApplication().getSettings();
settings.setMapLocationToShow(file.getLastPoint().lat, file.getLastPoint().lon, settings.getLastKnownMapZoom());
getMyApplication().getSelectedGpxHelper().setGpxFileToDisplay(file);
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}