Update download activity
This commit is contained in:
parent
d5798f8d3c
commit
1f9afebdf3
5 changed files with 67 additions and 32 deletions
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -7,7 +8,6 @@ import java.util.Map;
|
|||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.activities.DownloadIndexActivity;
|
||||
import net.osmand.plus.activities.FavouritesActivity;
|
||||
import net.osmand.plus.activities.LocalIndexesActivity;
|
||||
|
@ -16,11 +16,13 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.activities.PluginsActivity;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.api.SettingsAPI;
|
||||
import net.osmand.plus.api.SettingsAPIImpl;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import android.app.Activity;
|
||||
import android.view.Window;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
|
||||
|
||||
public class OsmAndAppCustomization {
|
||||
|
||||
|
@ -111,4 +113,31 @@ public class OsmAndAppCustomization {
|
|||
public String getIndexesUrl() {
|
||||
return "http://"+IndexConstants.INDEX_DOWNLOAD_DOMAIN+"/get_indexes?gzip&" + Version.getVersionAsURLParam(app); //$NON-NLS-1$;
|
||||
}
|
||||
|
||||
public void preDownloadActivity(final DownloadIndexActivity da, final List<DownloadActivityType> downloadTypes, ActionBar actionBar ) {
|
||||
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(actionBar.getThemedContext(), R.layout.sherlock_spinner_item,
|
||||
toString(downloadTypes)
|
||||
);
|
||||
spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
|
||||
actionBar.setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() {
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
|
||||
da.changeType(downloadTypes.get(itemPosition));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> toString(List<DownloadActivityType> t) {
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for(DownloadActivityType ts : t) {
|
||||
items.add(ts.getString(app));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public boolean showDownloadExtraActions() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
public static final String FILTER_KEY = "filter";
|
||||
public static final String FILTER_CAT = "filter_cat";
|
||||
|
||||
private static DownloadIndexesThread downloadListIndexThread;
|
||||
public static DownloadIndexesThread downloadListIndexThread;
|
||||
private DownloadActivityType type = DownloadActivityType.NORMAL_FILE;
|
||||
public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 10;
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
});
|
||||
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
||||
getSupportActionBar().setTitle(R.string.local_index_download);
|
||||
// recreation upon rotation is prevented in manifest file
|
||||
// recreation upon rotation is pgetaprevented in manifest file
|
||||
findViewById(R.id.DownloadButton).setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
|
@ -181,18 +181,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
showDialogOfFreeDownloadsIfNeeded();
|
||||
}
|
||||
|
||||
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(getSupportActionBar().getThemedContext(), R.layout.sherlock_spinner_item,
|
||||
toString(downloadTypes)
|
||||
);
|
||||
spinnerAdapter.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
|
||||
getSupportActionBar().setListNavigationCallbacks(spinnerAdapter, new OnNavigationListener() {
|
||||
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
|
||||
changeType(downloadTypes.get(itemPosition));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
getMyApplication().getAppCustomization().preDownloadActivity(this, downloadTypes, getSupportActionBar());
|
||||
if (Build.VERSION.SDK_INT >= OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
|
||||
final String currentStorage = settings.getExternalStorageDirectory().getAbsolutePath();
|
||||
String primaryStorage = settings.getDefaultExternalStorageLocation();
|
||||
|
@ -329,14 +318,17 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
}
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
SubMenu s = menu.addSubMenu(0, MORE_ID, 0, R.string.default_buttons_other_actions);
|
||||
s.add(0, RELOAD_ID, 0, R.string.update_downlod_list);
|
||||
s.add(0, FILTER_EXISTING_REGIONS, 0, R.string.filter_existing_indexes);
|
||||
s.add(0, SELECT_ALL_ID, 0, R.string.select_all);
|
||||
s.add(0, DESELECT_ALL_ID, 0, R.string.deselect_all);
|
||||
if (getMyApplication().getAppCustomization().showDownloadExtraActions()) {
|
||||
SubMenu s = menu.addSubMenu(0, MORE_ID, 0, R.string.default_buttons_other_actions);
|
||||
s.add(0, RELOAD_ID, 0, R.string.update_downlod_list);
|
||||
s.add(0, FILTER_EXISTING_REGIONS, 0, R.string.filter_existing_indexes);
|
||||
s.add(0, SELECT_ALL_ID, 0, R.string.select_all);
|
||||
s.add(0, DESELECT_ALL_ID, 0, R.string.deselect_all);
|
||||
|
||||
s.setIcon(isLightActionBar() ? R.drawable.abs__ic_menu_moreoverflow_holo_light : R.drawable.abs__ic_menu_moreoverflow_holo_dark);
|
||||
s.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
s.setIcon(isLightActionBar() ? R.drawable.abs__ic_menu_moreoverflow_holo_light
|
||||
: R.drawable.abs__ic_menu_moreoverflow_holo_dark);
|
||||
s.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -435,13 +427,6 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
}
|
||||
|
||||
|
||||
private List<String> toString(List<DownloadActivityType> t) {
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for(DownloadActivityType ts : t) {
|
||||
items.add(ts.getString(getMyApplication()));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private List<DownloadActivityType> getDownloadTypes() {
|
||||
List<DownloadActivityType> items = new ArrayList<DownloadActivityType>();
|
||||
|
|
|
@ -68,6 +68,10 @@ public class DownloadIndexesThread {
|
|||
dateFormat = app.getResourceManager().getDateFormat();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
indexFiles = null;
|
||||
}
|
||||
|
||||
public void setUiActivity(DownloadIndexActivity uiActivity) {
|
||||
this.uiActivity = uiActivity;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
|
@ -64,6 +66,9 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
|
||||
public boolean setAccessCode(String acCode) {
|
||||
acCode = acCode.toUpperCase();
|
||||
if(DownloadIndexActivity.downloadListIndexThread != null) {
|
||||
DownloadIndexActivity.downloadListIndexThread.clear();
|
||||
}
|
||||
if(validate(acCode) || Algorithms.isEmpty(acCode)) {
|
||||
accessCodePref.set(acCode);
|
||||
return true;
|
||||
|
@ -348,4 +353,13 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
|
|||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public void preDownloadActivity(final DownloadIndexActivity da, final List<DownloadActivityType> downloadTypes, ActionBar actionBar) {
|
||||
actionBar.setTitle(TourDownloadType.TOUR.getString(da));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDownloadExtraActions() {
|
||||
return super.showDownloadExtraActions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.sherpafy;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import android.app.Activity;
|
||||
|
@ -90,6 +91,7 @@ public class SherpafySelectToursFragment extends SherlockListFragment {
|
|||
LinearLayout ll = new LinearLayout(getActivity());
|
||||
ll.setPadding(5, 3, 5, 0);
|
||||
ll.addView(editText, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
AndroidUtils.softKeyboardDelayed(editText);
|
||||
builder.setView(ll);
|
||||
builder.setNegativeButton(R.string.sherpafy_public_access, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -98,6 +100,7 @@ public class SherpafySelectToursFragment extends SherlockListFragment {
|
|||
((TourViewActivity) getActivity()).startDownloadActivity();
|
||||
}
|
||||
});
|
||||
|
||||
builder.setPositiveButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
|
Loading…
Reference in a new issue