Updated local indexes design
This commit is contained in:
parent
e7865effac
commit
50e0932586
2 changed files with 46 additions and 34 deletions
|
@ -43,7 +43,15 @@ public class LocalIndexHelper {
|
||||||
|
|
||||||
|
|
||||||
public String getInstalledDate(File f){
|
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){
|
public String getInstalledDate(long t, TimeZone timeZone){
|
||||||
|
@ -51,7 +59,7 @@ public class LocalIndexHelper {
|
||||||
if(timeZone != null) {
|
if(timeZone != null) {
|
||||||
dateFormat.setTimeZone(timeZone);
|
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){
|
public void updateDescription(LocalIndexInfo info){
|
||||||
|
|
|
@ -60,6 +60,7 @@ import android.widget.CheckBox;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -103,7 +104,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
setListView(listView);
|
setListView(listView);
|
||||||
//getDownloadActivity().getSupportActionBar().setLogo(R.drawable.tab_download_screen_icon);
|
|
||||||
descriptionText = (TextView) view.findViewById(R.id.memory_size);
|
descriptionText = (TextView) view.findViewById(R.id.memory_size);
|
||||||
sizeProgress = (ProgressBar) view.findViewById(R.id.memory_progress);
|
sizeProgress = (ProgressBar) view.findViewById(R.id.memory_progress);
|
||||||
updateDescriptionTextWithSize();
|
updateDescriptionTextWithSize();
|
||||||
|
@ -288,6 +288,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
protected void onProgressUpdate(LocalIndexInfo... values) {
|
protected void onProgressUpdate(LocalIndexInfo... values) {
|
||||||
for (LocalIndexInfo v : values) {
|
for (LocalIndexInfo v : values) {
|
||||||
listAdapter.addLocalIndexInfo(v);
|
listAdapter.addLocalIndexInfo(v);
|
||||||
|
descriptionLoader = new LoadLocalIndexDescriptionTask();
|
||||||
|
descriptionLoader.execute(v);
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
|
@ -300,6 +302,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
} else {
|
} else {
|
||||||
for (LocalIndexInfo v : result) {
|
for (LocalIndexInfo v : result) {
|
||||||
listAdapter.addLocalIndexInfo(v);
|
listAdapter.addLocalIndexInfo(v);
|
||||||
|
descriptionLoader = new LoadLocalIndexDescriptionTask();
|
||||||
|
descriptionLoader.execute(v);
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
|
@ -464,15 +468,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
|
if (!selectionMode){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
LocalIndexInfo item = listAdapter.getChild(groupPosition, childPosition);
|
LocalIndexInfo item = listAdapter.getChild(groupPosition, childPosition);
|
||||||
item.setExpanded(!item.isExpanded());
|
selectedItems.add(item);
|
||||||
if (item.isExpanded()) {
|
|
||||||
descriptionLoader = new LoadLocalIndexDescriptionTask();
|
|
||||||
descriptionLoader.execute(item);
|
|
||||||
}
|
|
||||||
if(selectionMode){
|
|
||||||
selectedItems.add(item);
|
|
||||||
}
|
|
||||||
listAdapter.notifyDataSetInvalidated();
|
listAdapter.notifyDataSetInvalidated();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -536,15 +536,15 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
optionsMenuAdapter.item(R.string.local_index_mi_reload)
|
optionsMenuAdapter.item(R.string.local_index_mi_reload)
|
||||||
.icon(R.drawable.ic_action_refresh_dark)
|
.icon(R.drawable.ic_action_refresh_dark)
|
||||||
.listen(listener).position(1).reg();
|
.listen(listener).position(1).reg();
|
||||||
optionsMenuAdapter.item(R.string.local_index_mi_delete)
|
optionsMenuAdapter.item(R.string.local_index_mi_delete)
|
||||||
.icon(R.drawable.ic_action_delete_dark)
|
.icon(R.drawable.ic_action_delete_dark)
|
||||||
.listen(listener).position(2).reg();
|
.listen(listener).position(2).reg();
|
||||||
optionsMenuAdapter.item(R.string.local_index_mi_backup)
|
optionsMenuAdapter.item(R.string.local_index_mi_backup)
|
||||||
.listen(listener).position(3).reg();
|
.listen(listener).position(3).reg();
|
||||||
optionsMenuAdapter.item(R.string.local_index_mi_restore)
|
optionsMenuAdapter.item(R.string.local_index_mi_restore)
|
||||||
.listen(listener).position(4).reg();
|
.listen(listener).position(4).reg();
|
||||||
OsmandPlugin.onOptionsMenuActivity(getDownloadActivity(), null, optionsMenuAdapter);
|
OsmandPlugin.onOptionsMenuActivity(getDownloadActivity(), null, optionsMenuAdapter);
|
||||||
// doesn't work correctly
|
// doesn't work correctly
|
||||||
//int max = getResources().getInteger(R.integer.abs__max_action_buttons);
|
//int max = getResources().getInteger(R.integer.abs__max_action_buttons);
|
||||||
|
@ -705,7 +705,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
if (itemId == R.string.local_index_mi_reload) {
|
if (itemId == R.string.local_index_mi_reload) {
|
||||||
reloadIndexes();
|
reloadIndexes();
|
||||||
} else if (itemId == R.string.local_index_mi_delete) {
|
} 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() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -714,7 +714,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}, null, null);
|
}, null, null);
|
||||||
} else if (itemId == R.string.local_index_mi_backup) {
|
} 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() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -723,7 +723,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}, Boolean.FALSE, LocalIndexType.MAP_DATA);
|
}, Boolean.FALSE, LocalIndexType.MAP_DATA);
|
||||||
} else if (itemId == R.string.local_index_mi_restore) {
|
} 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() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@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) {
|
LocalIndexType filter) {
|
||||||
if (backup != null) {
|
if (backup != null) {
|
||||||
listAdapter.filterCategories(backup);
|
listAdapter.filterCategories(backup);
|
||||||
|
@ -743,7 +743,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
listAdapter.filterCategories(filter);
|
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);
|
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
||||||
}
|
}
|
||||||
TextView viewName = ((TextView) v.findViewById(R.id.local_index_name));
|
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
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
openPopUpMenu(v, child);
|
openPopUpMenu(v, child);
|
||||||
|
@ -961,8 +962,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
icon.setImageDrawable(sdcard);
|
icon.setImageDrawable(sdcard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
viewName.setText(getNameToDisplay(child));
|
viewName.setText(getNameToDisplay(child));
|
||||||
if (child.isNotSupported()) {
|
if (child.isNotSupported()) {
|
||||||
viewName.setTextColor(warningColor);
|
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"
|
// users confused okColor here with "uptodate", so let's leave white (black in dark app theme) as "isLoaded"
|
||||||
//viewName.setTextColor(okColor);
|
//viewName.setTextColor(okColor);
|
||||||
viewName.setTextColor(defaultColor);
|
viewName.setTextColor(defaultColor);
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
|
|
||||||
} else {
|
} else {
|
||||||
viewName.setTextColor(defaultColor);
|
viewName.setTextColor(defaultColor);
|
||||||
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
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) v.findViewById(R.id.local_index_size)).setText("");
|
||||||
}
|
}
|
||||||
TextView descr = ((TextView) v.findViewById(R.id.local_index_descr));
|
TextView descr = ((TextView) v.findViewById(R.id.local_index_descr));
|
||||||
if (child.isExpanded()) {
|
|
||||||
descr.setVisibility(View.VISIBLE);
|
descr.setVisibility(View.VISIBLE);
|
||||||
descr.setText(child.getDescription());
|
descr.setText(child.getDescription());
|
||||||
} else {
|
|
||||||
descr.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
||||||
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
icon.setVisibility(View.GONE);
|
icon.setVisibility(View.GONE);
|
||||||
|
options.setVisibility(View.GONE);
|
||||||
checkbox.setChecked(selectedItems.contains(child));
|
checkbox.setChecked(selectedItems.contains(child));
|
||||||
checkbox.setOnClickListener(new View.OnClickListener() {
|
checkbox.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@ -1016,11 +1013,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
options.setVisibility(View.VISIBLE);
|
||||||
icon.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;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue