Updated local indexes design

This commit is contained in:
Bars107 2015-02-17 17:08:30 +02:00
parent e7865effac
commit 50e0932586
2 changed files with 46 additions and 34 deletions

View file

@ -43,7 +43,15 @@ public class LocalIndexHelper {
public String getInstalledDate(File f){
return getInstalledDate(f.lastModified(), null);
return getInstalledDateEdition(f.lastModified(), null);
}
public String getInstalledDateEdition(long t, TimeZone timeZone){
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
if(timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
return app.getString(R.string.local_index_installed) + " : " + dateFormat.format(new Date(t));
}
public String getInstalledDate(long t, TimeZone timeZone){
@ -51,7 +59,7 @@ public class LocalIndexHelper {
if(timeZone != null) {
dateFormat.setTimeZone(timeZone);
}
return app.getString(R.string.local_index_installed) + " : " + dateFormat.format(new Date(t));
return dateFormat.format(new Date(t));
}
public void updateDescription(LocalIndexInfo info){

View file

@ -60,6 +60,7 @@ import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -103,7 +104,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
listView.setAdapter(listAdapter);
expandAllGroups();
setListView(listView);
//getDownloadActivity().getSupportActionBar().setLogo(R.drawable.tab_download_screen_icon);
descriptionText = (TextView) view.findViewById(R.id.memory_size);
sizeProgress = (ProgressBar) view.findViewById(R.id.memory_progress);
updateDescriptionTextWithSize();
@ -288,6 +288,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
protected void onProgressUpdate(LocalIndexInfo... values) {
for (LocalIndexInfo v : values) {
listAdapter.addLocalIndexInfo(v);
descriptionLoader = new LoadLocalIndexDescriptionTask();
descriptionLoader.execute(v);
}
listAdapter.notifyDataSetChanged();
expandAllGroups();
@ -300,6 +302,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
} else {
for (LocalIndexInfo v : result) {
listAdapter.addLocalIndexInfo(v);
descriptionLoader = new LoadLocalIndexDescriptionTask();
descriptionLoader.execute(v);
}
listAdapter.notifyDataSetChanged();
expandAllGroups();
@ -464,15 +468,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (!selectionMode){
return true;
}
LocalIndexInfo item = listAdapter.getChild(groupPosition, childPosition);
item.setExpanded(!item.isExpanded());
if (item.isExpanded()) {
descriptionLoader = new LoadLocalIndexDescriptionTask();
descriptionLoader.execute(item);
}
if(selectionMode){
selectedItems.add(item);
}
listAdapter.notifyDataSetInvalidated();
return true;
}
@ -705,7 +705,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
if (itemId == R.string.local_index_mi_reload) {
reloadIndexes();
} else if (itemId == R.string.local_index_mi_delete) {
openSelectionMode(itemId, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light,
openSelectionMode(itemId, R.drawable.ic_action_delete_dark,
new DialogInterface.OnClickListener() {
@Override
@ -714,7 +714,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
}
}, null, null);
} else if (itemId == R.string.local_index_mi_backup) {
openSelectionMode(itemId, R.drawable.ic_action_undo_dark, R.drawable.ic_action_undo_light,
openSelectionMode(itemId, R.drawable.ic_type_archive,
new DialogInterface.OnClickListener() {
@Override
@ -723,7 +723,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
}
}, Boolean.FALSE, LocalIndexType.MAP_DATA);
} else if (itemId == R.string.local_index_mi_restore) {
openSelectionMode(itemId, R.drawable.ic_action_redo_dark, R.drawable.ic_action_redo_light,
openSelectionMode(itemId, R.drawable.ic_type_archive,
new DialogInterface.OnClickListener() {
@Override
@ -735,7 +735,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
}
}
public void openSelectionMode(int stringRes, int darkIcon, int lightIcon, DialogInterface.OnClickListener listener, Boolean backup,
public void openSelectionMode(int stringRes, int darkIcon, DialogInterface.OnClickListener listener, Boolean backup,
LocalIndexType filter) {
if (backup != null) {
listAdapter.filterCategories(backup);
@ -743,7 +743,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
if (filter != null) {
listAdapter.filterCategories(filter);
}
openSelectionMode(stringRes, !isLightActionBar() ? darkIcon : lightIcon, listener);
openSelectionMode(stringRes, darkIcon, listener);
}
@ -948,7 +948,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
}
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
v.findViewById(R.id.options).setOnClickListener(new View.OnClickListener() {
ImageButton options = (ImageButton) v.findViewById(R.id.options);
options.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openPopUpMenu(v, child);
@ -961,8 +962,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
icon.setImageDrawable(sdcard);
}
viewName.setText(getNameToDisplay(child));
if (child.isNotSupported()) {
viewName.setTextColor(warningColor);
@ -974,7 +973,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
// users confused okColor here with "uptodate", so let's leave white (black in dark app theme) as "isLoaded"
//viewName.setTextColor(okColor);
viewName.setTextColor(defaultColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
} else {
viewName.setTextColor(defaultColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
@ -994,16 +992,15 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
((TextView) v.findViewById(R.id.local_index_size)).setText("");
}
TextView descr = ((TextView) v.findViewById(R.id.local_index_descr));
if (child.isExpanded()) {
descr.setVisibility(View.VISIBLE);
descr.setText(child.getDescription());
} else {
descr.setVisibility(View.GONE);
}
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
if (selectionMode) {
icon.setVisibility(View.GONE);
options.setVisibility(View.GONE);
checkbox.setChecked(selectedItems.contains(child));
checkbox.setOnClickListener(new View.OnClickListener() {
@ -1016,11 +1013,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
}
}
});
} else {
options.setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
}
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onChildClick(null, v, groupPosition, childPosition, 0);
}
});
return v;
}