Local index activity refactored to be fragment
This commit is contained in:
parent
4f03debcfd
commit
d3a7ab2368
7 changed files with 137 additions and 103 deletions
|
@ -220,7 +220,7 @@
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name="net.osmand.plus.development.TestVoiceActivity" />
|
<activity android:name="net.osmand.plus.development.TestVoiceActivity" />
|
||||||
<activity android:name="net.osmand.plus.activities.LocalIndexesActivity" android:label="@string/local_index_descr_title" />
|
<activity android:name="net.osmand.plus.download.DownloadActivity" android:label="@string/local_index_descr_title" />
|
||||||
<activity android:name="net.osmand.plus.osmedit.LocalOpenstreetmapActivity" android:label="@string/local_openstreetmap_act_title" />
|
<activity android:name="net.osmand.plus.osmedit.LocalOpenstreetmapActivity" android:label="@string/local_openstreetmap_act_title" />
|
||||||
|
|
||||||
<!-- keep android:process on a separate line !! -->
|
<!-- keep android:process on a separate line !! -->
|
||||||
|
|
|
@ -12,12 +12,12 @@ import net.osmand.Location;
|
||||||
import net.osmand.data.LocationPoint;
|
import net.osmand.data.LocationPoint;
|
||||||
import net.osmand.plus.activities.DownloadIndexActivity;
|
import net.osmand.plus.activities.DownloadIndexActivity;
|
||||||
import net.osmand.plus.activities.FavouritesActivity;
|
import net.osmand.plus.activities.FavouritesActivity;
|
||||||
import net.osmand.plus.activities.LocalIndexesActivity;
|
|
||||||
import net.osmand.plus.activities.MainMenuActivity;
|
import net.osmand.plus.activities.MainMenuActivity;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.PluginsActivity;
|
import net.osmand.plus.activities.PluginsActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.activities.search.SearchActivity;
|
import net.osmand.plus.activities.search.SearchActivity;
|
||||||
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.helpers.WaypointHelper;
|
import net.osmand.plus.helpers.WaypointHelper;
|
||||||
import net.osmand.plus.routing.RouteCalculationResult;
|
import net.osmand.plus.routing.RouteCalculationResult;
|
||||||
|
@ -87,7 +87,7 @@ public class OsmAndAppCustomization {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends Activity> getLocalIndexActivity() {
|
public Class<? extends Activity> getLocalIndexActivity() {
|
||||||
return LocalIndexesActivity.class;
|
return DownloadActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download screen
|
// Download screen
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
import net.osmand.access.AccessibilityPlugin;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
|
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
|
@ -19,7 +19,6 @@ import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
import net.osmand.plus.osmedit.OsmEditingPlugin;
|
||||||
import net.osmand.plus.osmo.OsMoPlugin;
|
import net.osmand.plus.osmo.OsMoPlugin;
|
||||||
import net.osmand.plus.osmodroid.OsMoDroidPlugin;
|
|
||||||
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin;
|
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.SQLiteTileSource;
|
import net.osmand.plus.SQLiteTileSource;
|
||||||
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
|
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
|
||||||
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
||||||
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
|
@ -34,11 +34,11 @@ import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.activities.LocalIndexesActivity;
|
import net.osmand.plus.download.LocalIndexesFragment.LoadLocalIndexTask;
|
||||||
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.views.MapInfoLayer;
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
@ -1094,8 +1094,8 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void contextMenuLocalIndexes(Activity activity, SherlockFragment fragment, Object obj,
|
public void contextMenuLocalIndexes(Activity activity, SherlockFragment fragment, Object obj,
|
||||||
ContextMenuAdapter adapter) {
|
ContextMenuAdapter adapter) {
|
||||||
if (activity instanceof LocalIndexesActivity) {
|
if (activity instanceof DownloadActivity) {
|
||||||
final LocalIndexesActivity la = (LocalIndexesActivity) activity;
|
final DownloadActivity la = (DownloadActivity) activity;
|
||||||
LocalIndexInfo info = (LocalIndexInfo) obj;
|
LocalIndexInfo info = (LocalIndexInfo) obj;
|
||||||
if (info.getType() == LocalIndexType.AV_DATA) {
|
if (info.getType() == LocalIndexType.AV_DATA) {
|
||||||
final RecordingLocalIndexInfo ri = (RecordingLocalIndexInfo) info;
|
final RecordingLocalIndexInfo ri = (RecordingLocalIndexInfo) info;
|
||||||
|
|
37
OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
Normal file
37
OsmAnd/src/net/osmand/plus/download/DownloadActivity.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.widget.TabHost;
|
||||||
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.FavouritesActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Denis on 08.09.2014.
|
||||||
|
*/
|
||||||
|
public class DownloadActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
|
private TabHost tabHost;
|
||||||
|
private FavouritesActivity.TabsAdapter mTabsAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((OsmandApplication) getApplication()).applyTheme(this);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
|
||||||
|
setContentView(R.layout.tab_content);
|
||||||
|
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
|
tabHost = (TabHost) findViewById(android.R.id.tabhost);
|
||||||
|
tabHost.setup();
|
||||||
|
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
|
mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings);
|
||||||
|
mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator("Local maps"),
|
||||||
|
LocalIndexesFragment.class, null);
|
||||||
|
tabHost.setCurrentTab(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
@ -10,13 +10,16 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.actionbarsherlock.view.*;
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.map.OsmandRegions;
|
import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.plus.*;
|
import net.osmand.plus.*;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
|
import net.osmand.plus.activities.*;
|
||||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||||
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -48,14 +51,9 @@ import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.ActionMode;
|
|
||||||
import com.actionbarsherlock.view.ActionMode.Callback;
|
import com.actionbarsherlock.view.ActionMode.Callback;
|
||||||
import com.actionbarsherlock.view.Menu;
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
|
||||||
import com.actionbarsherlock.view.SubMenu;
|
|
||||||
import com.actionbarsherlock.view.Window;
|
|
||||||
|
|
||||||
public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
private LoadLocalIndexTask asyncLoader;
|
private LoadLocalIndexTask asyncLoader;
|
||||||
private LocalIndexesAdapter listAdapter;
|
private LocalIndexesAdapter listAdapter;
|
||||||
|
@ -77,20 +75,41 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
//requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.local_index);
|
//setContentView(R.layout.local_index);
|
||||||
getSupportActionBar().setTitle(R.string.local_index_descr_title);
|
//getSupportActionBar().setTitle(R.string.local_index_descr_title);
|
||||||
setSupportProgressBarIndeterminateVisibility(false);
|
//setSupportProgressBarIndeterminateVisibility(false);
|
||||||
// getSupportActionBar().setLogo(R.drawable.tab_download_screen_icon);
|
// getSupportActionBar().setLogo(R.drawable.tab_download_screen_icon);
|
||||||
|
|
||||||
|
|
||||||
descriptionLoader = new LoadLocalIndexDescriptionTask();
|
descriptionLoader = new LoadLocalIndexDescriptionTask();
|
||||||
listAdapter = new LocalIndexesAdapter(this);
|
listAdapter = new LocalIndexesAdapter(getActivity());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setAdapter(listAdapter);
|
||||||
|
updateDescriptionTextWithSize();
|
||||||
|
if (asyncLoader == null || asyncLoader.getResult() == null) {
|
||||||
|
// getLastNonConfigurationInstance method should be in onCreate() method
|
||||||
|
// (onResume() doesn't work)
|
||||||
|
Object indexes = getActivity().getLastNonConfigurationInstance();
|
||||||
|
asyncLoader = new LoadLocalIndexTask();
|
||||||
|
if (indexes instanceof List<?>) {
|
||||||
|
asyncLoader.setResult((List<LocalIndexInfo>) indexes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (asyncLoader == null || asyncLoader.getResult() == null) {
|
||||||
|
asyncLoader = new LoadLocalIndexTask();
|
||||||
|
asyncLoader.execute(getActivity());
|
||||||
|
}
|
||||||
|
|
||||||
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
|
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
|
@ -103,35 +122,14 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setListAdapter(listAdapter);
|
|
||||||
updateDescriptionTextWithSize();
|
|
||||||
if (asyncLoader == null || asyncLoader.getResult() == null) {
|
|
||||||
// getLastNonConfigurationInstance method should be in onCreate() method
|
|
||||||
// (onResume() doesn't work)
|
|
||||||
Object indexes = getLastNonConfigurationInstance();
|
|
||||||
asyncLoader = new LoadLocalIndexTask();
|
|
||||||
if (indexes instanceof List<?>) {
|
|
||||||
asyncLoader.setResult((List<LocalIndexInfo>) indexes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (asyncLoader == null || asyncLoader.getResult() == null) {
|
|
||||||
asyncLoader = new LoadLocalIndexTask();
|
|
||||||
asyncLoader.execute(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showContextMenu(final LocalIndexInfo info) {
|
private void showContextMenu(final LocalIndexInfo info) {
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(this);
|
final ContextMenuAdapter adapter = new ContextMenuAdapter(getActivity());
|
||||||
basicFileOperation(info, adapter);
|
basicFileOperation(info, adapter);
|
||||||
OsmandPlugin.onContextMenuActivity(this, null, info, adapter);
|
OsmandPlugin.onContextMenuActivity(getActivity(), null, info, adapter);
|
||||||
|
|
||||||
String[] values = adapter.getItemNames();
|
String[] values = adapter.getItemNames();
|
||||||
builder.setItems(values, new DialogInterface.OnClickListener() {
|
builder.setItems(values, new DialogInterface.OnClickListener() {
|
||||||
|
@ -157,7 +155,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
} else if (resId == R.string.local_index_mi_restore) {
|
} else if (resId == R.string.local_index_mi_restore) {
|
||||||
new LocalIndexOperationTask(RESTORE_OPERATION).execute(info);
|
new LocalIndexOperationTask(RESTORE_OPERATION).execute(info);
|
||||||
} else if (resId == R.string.local_index_mi_delete) {
|
} else if (resId == R.string.local_index_mi_delete) {
|
||||||
Builder confirm = new AlertDialog.Builder(LocalIndexesActivity.this);
|
Builder confirm = new AlertDialog.Builder(getActivity());
|
||||||
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -186,9 +184,9 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
private void renameFile(LocalIndexInfo info) {
|
private void renameFile(LocalIndexInfo info) {
|
||||||
final File f = new File(info.getPathToData());
|
final File f = new File(info.getPathToData());
|
||||||
Builder b = new AlertDialog.Builder(this);
|
Builder b = new AlertDialog.Builder(getActivity());
|
||||||
if(f.exists()){
|
if(f.exists()){
|
||||||
final EditText editText = new EditText(this);
|
final EditText editText = new EditText(getActivity());
|
||||||
editText.setText(f.getName());
|
editText.setText(f.getName());
|
||||||
b.setView(editText);
|
b.setView(editText);
|
||||||
b.setPositiveButton(R.string.default_buttons_save, new DialogInterface.OnClickListener() {
|
b.setPositiveButton(R.string.default_buttons_save, new DialogInterface.OnClickListener() {
|
||||||
|
@ -198,7 +196,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
String newName = editText.getText().toString();
|
String newName = editText.getText().toString();
|
||||||
File dest = new File(f.getParentFile(), newName);
|
File dest = new File(f.getParentFile(), newName);
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
AccessibleToast.makeText(LocalIndexesActivity.this, R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(getMyActivity(), R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
if(!f.getParentFile().exists()) {
|
if(!f.getParentFile().exists()) {
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
|
@ -206,7 +204,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
if(f.renameTo(dest)){
|
if(f.renameTo(dest)){
|
||||||
reloadIndexes();
|
reloadIndexes();
|
||||||
} else {
|
} else {
|
||||||
AccessibleToast.makeText(LocalIndexesActivity.this, R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(getMyActivity(), R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +231,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
setSupportProgressBarIndeterminateVisibility(true);
|
getMyActivity().setSupportProgressBarIndeterminateVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -260,7 +258,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<LocalIndexInfo> result) {
|
protected void onPostExecute(List<LocalIndexInfo> result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
setSupportProgressBarIndeterminateVisibility(false);
|
getMyActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LocalIndexInfo> getResult() {
|
public List<LocalIndexInfo> getResult() {
|
||||||
|
@ -365,13 +363,13 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
setProgressBarIndeterminateVisibility(true);
|
getMyActivity().setProgressBarIndeterminateVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String result) {
|
protected void onPostExecute(String result) {
|
||||||
setProgressBarIndeterminateVisibility(false);
|
getMyActivity().setProgressBarIndeterminateVisibility(false);
|
||||||
AccessibleToast.makeText(LocalIndexesActivity.this, result, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(getMyActivity(), result, Toast.LENGTH_LONG).show();
|
||||||
listAdapter.clear();
|
listAdapter.clear();
|
||||||
reloadIndexes();
|
reloadIndexes();
|
||||||
|
|
||||||
|
@ -430,7 +428,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if(operationTask != null){
|
if(operationTask != null){
|
||||||
operationTask.cancel(true);
|
operationTask.cancel(true);
|
||||||
|
@ -438,23 +436,23 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
asyncLoader.cancel(true);
|
asyncLoader.cancel(true);
|
||||||
descriptionLoader.cancel(true);
|
descriptionLoader.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public Object onRetainNonConfigurationInstance() {
|
// public Object onRetainNonConfigurationInstance() {
|
||||||
if(asyncLoader != null){
|
// if(asyncLoader != null){
|
||||||
return asyncLoader.getResult();
|
// return asyncLoader.getResult();
|
||||||
}
|
// }
|
||||||
return super.onRetainNonConfigurationInstance();
|
// return super.onRetainNonConfigurationInstance();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
optionsMenuAdapter = new ContextMenuAdapter(this);
|
optionsMenuAdapter = new ContextMenuAdapter(getMyActivity());
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||||
|
@ -476,7 +474,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
optionsMenuAdapter.item(R.string.local_index_mi_delete)
|
optionsMenuAdapter.item(R.string.local_index_mi_delete)
|
||||||
.icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light)
|
.icons(R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light)
|
||||||
.listen(listener).position(4).reg();
|
.listen(listener).position(4).reg();
|
||||||
OsmandPlugin.onOptionsMenuActivity(this, null, optionsMenuAdapter);
|
OsmandPlugin.onOptionsMenuActivity(getMyActivity(), 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);
|
||||||
SubMenu split = null;
|
SubMenu split = null;
|
||||||
|
@ -501,18 +499,16 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
if(operationTask == null || operationTask.getStatus() == Status.FINISHED){
|
// if(operationTask == null || operationTask.getStatus() == Status.FINISHED){
|
||||||
menu.setGroupVisible(0, true);
|
// menu.setGroupVisible(0, true);
|
||||||
} else {
|
// } else {
|
||||||
menu.setGroupVisible(0, false);
|
// menu.setGroupVisible(0, false);
|
||||||
}
|
// }
|
||||||
return true;
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
@ -561,14 +557,14 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
final String actionButton = value;
|
final String actionButton = value;
|
||||||
if(listAdapter.getGroupCount() == 0){
|
if(listAdapter.getGroupCount() == 0){
|
||||||
listAdapter.cancelFilter();
|
listAdapter.cancelFilter();
|
||||||
AccessibleToast.makeText(LocalIndexesActivity.this, getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
|
AccessibleToast.makeText(getMyActivity(), getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collapseAllGroups();
|
collapseAllGroups();
|
||||||
|
|
||||||
selectionMode = true;
|
selectionMode = true;
|
||||||
selectedItems.clear();
|
selectedItems.clear();
|
||||||
actionMode = startActionMode(new Callback() {
|
actionMode = getMyActivity().startActionMode(new Callback() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
|
@ -590,12 +586,12 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
@Override
|
@Override
|
||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||||
if (selectedItems.isEmpty()) {
|
if (selectedItems.isEmpty()) {
|
||||||
AccessibleToast.makeText(LocalIndexesActivity.this,
|
AccessibleToast.makeText(getMyActivity(),
|
||||||
getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
|
getString(R.string.local_index_no_items_to_do, actionButton.toLowerCase()), Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Builder builder = new AlertDialog.Builder(LocalIndexesActivity.this);
|
Builder builder = new AlertDialog.Builder(getMyActivity());
|
||||||
builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), selectedItems.size()));
|
builder.setMessage(getString(R.string.local_index_action_do, actionButton.toLowerCase(), selectedItems.size()));
|
||||||
builder.setPositiveButton(actionButton, listener);
|
builder.setPositiveButton(actionButton, listener);
|
||||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
|
@ -606,15 +602,15 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
selectionMode = false;
|
selectionMode = false;
|
||||||
findViewById(R.id.DescriptionText).setVisibility(View.VISIBLE);
|
//findViewById(R.id.DescriptionText).setVisibility(View.VISIBLE);
|
||||||
updateDescriptionTextWithSize();
|
//updateDescriptionTextWithSize();
|
||||||
listAdapter.cancelFilter();
|
listAdapter.cancelFilter();
|
||||||
collapseAllGroups();
|
collapseAllGroups();
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
findViewById(R.id.DescriptionText).setVisibility(View.GONE);
|
//findViewById(R.id.DescriptionText).setVisibility(View.GONE);
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,7 +621,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
StatFs fs = new StatFs(dir.getAbsolutePath());
|
StatFs fs = new StatFs(dir.getAbsolutePath());
|
||||||
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
|
size = formatGb.format(new Object[]{(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30) });
|
||||||
}
|
}
|
||||||
TextView ds = (TextView) findViewById(R.id.DescriptionText);
|
//TextView ds = (TextView) findViewById(R.id.DescriptionText);
|
||||||
String text = getString(R.string.download_link_and_local_description, size);
|
String text = getString(R.string.download_link_and_local_description, size);
|
||||||
int l = text.indexOf('.');
|
int l = text.indexOf('.');
|
||||||
if(l == -1) {
|
if(l == -1) {
|
||||||
|
@ -636,7 +632,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View widget) {
|
public void onClick(View widget) {
|
||||||
asyncLoader.setResult(null);
|
asyncLoader.setResult(null);
|
||||||
startActivity(new Intent(LocalIndexesActivity.this, DownloadIndexActivity.class));
|
startActivity(new Intent(getMyActivity(), DownloadIndexActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -645,8 +641,8 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
// ds.setColor(Color.GREEN);
|
// ds.setColor(Color.GREEN);
|
||||||
}
|
}
|
||||||
}, 0, l, 0);
|
}, 0, l, 0);
|
||||||
ds.setText(content);
|
//ds.setText(content);
|
||||||
ds.setMovementMethod(LinkMovementMethod.getInstance());
|
//ds.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -654,7 +650,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
public void localOptionsMenu(final int itemId) {
|
public void localOptionsMenu(final int itemId) {
|
||||||
if (itemId == R.string.local_index_download) {
|
if (itemId == R.string.local_index_download) {
|
||||||
asyncLoader.setResult(null);
|
asyncLoader.setResult(null);
|
||||||
startActivity(new Intent(LocalIndexesActivity.this, DownloadIndexActivity.class));
|
startActivity(new Intent(getMyActivity(), DownloadIndexActivity.class));
|
||||||
} else if (itemId == R.string.local_index_mi_reload) {
|
} else 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) {
|
||||||
|
@ -707,7 +703,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<String> warnings) {
|
protected void onPostExecute(List<String> warnings) {
|
||||||
setProgressBarIndeterminateVisibility(false);
|
getMyActivity().setProgressBarIndeterminateVisibility(false);
|
||||||
if (!warnings.isEmpty()) {
|
if (!warnings.isEmpty()) {
|
||||||
final StringBuilder b = new StringBuilder();
|
final StringBuilder b = new StringBuilder();
|
||||||
boolean f = true;
|
boolean f = true;
|
||||||
|
@ -719,17 +715,17 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
}
|
}
|
||||||
b.append(w);
|
b.append(w);
|
||||||
}
|
}
|
||||||
AccessibleToast.makeText(LocalIndexesActivity.this, b.toString(), Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(getMyActivity(), b.toString(), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
if(asyncLoader.getStatus() == Status.PENDING) {
|
if(asyncLoader.getStatus() == Status.PENDING) {
|
||||||
asyncLoader.execute(LocalIndexesActivity.this);
|
asyncLoader.execute(getMyActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
setProgressBarIndeterminateVisibility(true);
|
getMyActivity().setProgressBarIndeterminateVisibility(true);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected List<String> doInBackground(Void... params) {
|
protected List<String> doInBackground(Void... params) {
|
||||||
|
@ -877,12 +873,12 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
final LocalIndexInfo child = (LocalIndexInfo) getChild(groupPosition, childPosition);
|
final LocalIndexInfo child = (LocalIndexInfo) getChild(groupPosition, childPosition);
|
||||||
if (v == null ) {
|
if (v == null ) {
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = (LayoutInflater) getMyActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||||
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));
|
||||||
String mapDescr = getMapDescription(child.getFileName());
|
String mapDescr = getMapDescription(child.getFileName());
|
||||||
String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getApplication()).getResourceManager().getOsmandRegions(), child.getFileName());
|
String mapName = FileNameTranslationHelper.getFileName(ctx, ((OsmandApplication) getMyActivity().getApplication()).getResourceManager().getOsmandRegions(), child.getFileName());
|
||||||
|
|
||||||
if (mapDescr.length() > 0){
|
if (mapDescr.length() > 0){
|
||||||
viewName.setText(mapDescr + " - " + mapName);
|
viewName.setText(mapDescr + " - " + mapName);
|
||||||
|
@ -951,10 +947,10 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
LocalIndexInfo group = getGroup(groupPosition);
|
LocalIndexInfo group = getGroup(groupPosition);
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
LayoutInflater inflater = (LayoutInflater) getMyActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
|
||||||
v = inflater.inflate(net.osmand.plus.R.layout.expandable_list_item_category, parent, false);
|
v = inflater.inflate(net.osmand.plus.R.layout.expandable_list_item_category, parent, false);
|
||||||
}
|
}
|
||||||
StringBuilder t = new StringBuilder(group.getType().getHumanString(LocalIndexesActivity.this));
|
StringBuilder t = new StringBuilder(group.getType().getHumanString(getMyActivity()));
|
||||||
if(group.getSubfolder() != null) {
|
if(group.getSubfolder() != null) {
|
||||||
t.append(" ").append(group.getSubfolder());
|
t.append(" ").append(group.getSubfolder());
|
||||||
}
|
}
|
||||||
|
@ -1035,4 +1031,6 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DownloadActivity getMyActivity(){ return (DownloadActivity)getActivity();}
|
||||||
}
|
}
|
Loading…
Reference in a new issue