Reduced font size for chart type

This commit is contained in:
Alexey Kulish 2017-03-09 21:32:55 +03:00
parent 724f57859f
commit 57d0bda78d
5 changed files with 68 additions and 54 deletions

View file

@ -123,7 +123,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_desc_text_size"
tools:text="@string/altitude"/> tools:text="@string/altitude"/>
<ImageView <ImageView
@ -167,7 +167,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_desc_text_size"
tools:text="@string/map_widget_speed"/> tools:text="@string/map_widget_speed"/>
<ImageView <ImageView

View file

@ -190,6 +190,14 @@
android:focusable="false" android:focusable="false"
android:gravity="center_vertical"/> android:gravity="center_vertical"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/toggle_checkbox_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -52,7 +52,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_desc_text_size"
tools:text="@string/altitude"/> tools:text="@string/altitude"/>
<ImageView <ImageView
@ -96,7 +96,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_desc_text_size"
tools:text="@string/distance"/> tools:text="@string/distance"/>
<ImageView <ImageView

View file

@ -64,7 +64,7 @@ public class GpxSelectionHelper {
} }
File file = new File(selectedGPXFiles.get(0).getGpxFile().path); File file = new File(selectedGPXFiles.get(0).getGpxFile().path);
return Algorithms.getFileNameWithoutExtension(file); return Algorithms.getFileNameWithoutExtension(file).replace('_', ' ');
} else if (selectedGPXFiles.size() == 0) { } else if (selectedGPXFiles.size() == 0) {
return null; return null;
} else { } else {

View file

@ -16,6 +16,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatCheckBox;
import android.support.v7.widget.ListPopupWindow; import android.support.v7.widget.ListPopupWindow;
import android.support.v7.widget.SwitchCompat; import android.support.v7.widget.SwitchCompat;
import android.text.SpannableString; import android.text.SpannableString;
@ -57,6 +58,7 @@ import net.osmand.CallbackWithObject;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.GPXDatabase;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.Elevation; import net.osmand.plus.GPXUtilities.Elevation;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
@ -78,6 +80,7 @@ import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem; import net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem;
import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter; import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRulesStorage; import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -418,8 +421,7 @@ public class GpxUiHelper {
final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity); final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity);
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
final int layout = R.layout.list_item_with_checkbox; final int layout = R.layout.dash_gpx_track_item;
final int switchLayout = R.layout.list_item_with_switch;
final Map<String, String> gpxAppearanceParams = new HashMap<>(); final Map<String, String> gpxAppearanceParams = new HashMap<>();
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layout, R.id.title, final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layout, R.id.title,
@ -439,14 +441,14 @@ public class GpxUiHelper {
public View getView(final int position, View convertView, ViewGroup parent) { public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View // User super class to create the View
View v = convertView; View v = convertView;
boolean checkLayout = getItemViewType(position) == 0;
if (v == null) { if (v == null) {
if (getItemViewType(position) == 0) { v = activity.getLayoutInflater().inflate(layout, null);
v = activity.getLayoutInflater().inflate(layout, null);
} else {
v = activity.getLayoutInflater().inflate(switchLayout, null);
}
} }
GPXInfo info = list.get(position);
AvailableGPXFragment.udpateGpxInfoView(v, info, app, false);
TextView tv = (TextView) v.findViewById(R.id.title); TextView tv = (TextView) v.findViewById(R.id.title);
TextView dv = (TextView) v.findViewById(R.id.description); TextView dv = (TextView) v.findViewById(R.id.description);
final ContextMenuItem item = adapter.getItem(position); final ContextMenuItem item = adapter.getItem(position);
@ -467,57 +469,61 @@ public class GpxUiHelper {
} }
tv.setText(item.getTitle().replace("/", "")); tv.setText(item.getTitle().replace("/", ""));
GPXInfo info = list.get(position); GPXInfo info = list.get(position);
GPXDatabase.GpxDataItem dataItem = app.getGpxDatabase().getItem(new File(info.fileName));
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (info.getLastModified() > 0) { if (dataItem != null && dataItem.getAnalysis() != null) {
sb.append(dateFormat.format(info.getLastModified()));
} } else {
if (info.getFileSize() >= 0) { if (info.getLastModified() > 0) {
if (sb.length() > 0) { sb.append(dateFormat.format(info.getLastModified()));
sb.append("");
} }
long fileSizeKB = info.getFileSize() / 1000; if (info.getFileSize() >= 0) {
if (info.getFileSize() < 5000) { if (sb.length() > 0) {
sb.append(info.getFileSize()).append(" B"); sb.append("");
} else if (fileSizeKB > 100) { }
sb.append(formatMb.format(new Object[]{(float) fileSizeKB / (1 << 10)})); long fileSizeKB = info.getFileSize() / 1000;
} else { if (info.getFileSize() < 5000) {
sb.append(fileSizeKB).append(" kB"); sb.append(info.getFileSize()).append(" B");
} else if (fileSizeKB > 100) {
sb.append(formatMb.format(new Object[]{(float) fileSizeKB / (1 << 10)}));
} else {
sb.append(fileSizeKB).append(" kB");
}
} }
} }
dv.setText(sb.toString()); dv.setText(sb.toString());
/*
final ArrayAdapter<String> arrayAdapter = this;
iconView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int nline = item.getTitle().indexOf('\n');
if (nline == -1) {
String fileName = list.get(position).getFileName();
setDescripionInDialog(arrayAdapter, adapter, activity, dir, fileName, position);
} else {
item.setTitle(item.getTitle().substring(0, nline));
arrayAdapter.notifyDataSetInvalidated();
}
}
});
*/
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
if (item.getSelected() == null) { if (item.getSelected() == null) {
ch.setVisibility(View.INVISIBLE); v.findViewById(R.id.check_item).setVisibility(View.GONE);
} else { } else {
ch.setOnCheckedChangeListener(null); if (checkLayout) {
ch.setChecked(item.getSelected()); final AppCompatCheckBox ch = ((AppCompatCheckBox) v.findViewById(R.id.toggle_checkbox_item));
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() { ch.setVisibility(View.VISIBLE);
@Override v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ch.setOnCheckedChangeListener(null);
item.setSelected(isChecked); ch.setChecked(item.getSelected());
} ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
}); @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
item.setSelected(isChecked);
}
});
} else {
final SwitchCompat ch = ((SwitchCompat) v.findViewById(R.id.toggle_item));
ch.setVisibility(View.VISIBLE);
v.findViewById(R.id.toggle_checkbox_item).setVisibility(View.GONE);
ch.setOnCheckedChangeListener(null);
ch.setChecked(item.getSelected());
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
item.setSelected(isChecked);
}
});
}
v.findViewById(R.id.check_item).setVisibility(View.VISIBLE);
} }
return v; return v;
} }