Update action bar

This commit is contained in:
Victor Shcherb 2014-12-10 01:19:27 +01:00
parent d43d5255c1
commit bb74b7563a
8 changed files with 50 additions and 38 deletions

View file

@ -222,7 +222,7 @@
</activity>
<activity android:name="net.osmand.plus.development.TestVoiceActivity" />
<activity android:name="net.osmand.plus.download.DownloadActivity" android:label="@string/local_index_descr_title" />
<activity android:name="net.osmand.plus.download.DownloadActivity" android:label="" />
<activity android:name="net.osmand.plus.osmedit.LocalOpenstreetmapActivity" android:label="@string/local_openstreetmap_act_title" />
<!-- keep android:process on a separate line !! -->

View file

@ -148,5 +148,8 @@ public class OsmAndAppCustomization {
public boolean showNavigationControls() { return true;}
public boolean onlyTourDownload() { return false;}
public boolean onlyTourDownload() {
return false;
}
}

View file

@ -97,20 +97,12 @@ public class DownloadActivity extends BaseDownloadActivity {
tabHost.setup();
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings, false);
if (getMyApplication().getAppCustomization().onlyTourDownload()) {
mTabsAdapter.addTab(
tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
DownloadIndexFragment.class, null);
} else {
mTabsAdapter.addTab(
tabHost.newTabSpec("LOCAL_INDEX").setIndicator(getString(R.string.download_tab_local)),
LocalIndexesFragment.class, null);
mTabsAdapter.addTab(
tabHost.newTabSpec("DOWNLOADS").setIndicator(getString(R.string.download_tab_downloads)),
DownloadIndexFragment.class, null);
mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES")
.setIndicator(getString(R.string.download_tab_updates)), UpdatesIndexFragment.class, null);
}
mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator(getString(R.string.download_tab_local)),
LocalIndexesFragment.class, null);
mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS")
.setIndicator(getString(R.string.download_tab_downloads)), DownloadIndexFragment.class, null);
mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES").setIndicator(getString(R.string.download_tab_updates)),
UpdatesIndexFragment.class, null);
tabHost.setCurrentTab(currentTab);
}

View file

@ -41,6 +41,7 @@ import com.actionbarsherlock.view.SubMenu;
public class DownloadIndexFragment extends OsmandExpandableListFragment {
/** menus **/
private static boolean SHOW_ONLY_RELOAD = true;
public static final int MORE_ID = 10;
public static final int RELOAD_ID = 0;
public static final int SELECT_ALL_ID = 1;
@ -62,7 +63,7 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
listView.setAdapter(listAdapter);
setListView(listView);
getDownloadActivity().getSupportActionBar().setTitle(R.string.local_index_download);
// getDownloadActivity().getSupportActionBar().setTitle(R.string.local_index_download);
// recreation upon rotation is pgetaprevented in manifest file
filterText = (EditText) view.findViewById(R.id.search_box);
@ -151,14 +152,21 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
});
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, SELECT_ALL_ID, 0, R.string.select_all);
s.add(0, DESELECT_ALL_ID, 0, R.string.deselect_all);
if (SHOW_ONLY_RELOAD) {
MenuItem item = menu.add(0, RELOAD_ID, 0, R.string.update_downlod_list);
item.setIcon(isLightActionBar() ? R.drawable.ic_action_refresh_light :
R.drawable.ic_action_refresh_dark);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
} else {
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, 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);
}
}
}

View file

@ -85,7 +85,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.local_index, container, false);
getDownloadActivity().getSupportActionBar().setTitle(R.string.local_index_descr_title);
// getDownloadActivity().getSupportActionBar().setTitle(R.string.local_index_descr_title);
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
ExpandableListView listView = (ExpandableListView)view.findViewById(android.R.id.list);
@ -998,18 +998,23 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
TextView nameView = ((TextView) v.findViewById(R.id.category_name));
List<LocalIndexInfo> list = data.get(group);
int size = 0;
for(int i=0; i<list.size(); i++){
for (int i = 0; i < list.size(); i++) {
int sz = list.get(i).getSize();
if(sz < 0){
if (sz < 0) {
size = 0;
break;
} else {
size += sz;
}
}
size = size / (1 << 10);
if(size > 0){
t.append(" [").append(size).append(" MB]");
if (size > 0) {
String sz;
if (size > 1 << 20) {
sz = formatGb.format(new Object[] { (float) size / (1 << 20) });
} else {
sz = formatMb.format(new Object[] { (float) size / (1 << 10) });
}
t.append(" [").append(sz).append("]");
}
nameView.setText(t.toString());
if (!group.isBackupedData()) {

View file

@ -50,8 +50,8 @@ public class UpdatesIndexFragment extends SherlockListFragment {
}
private void createListView(List<IndexItem> indexItems) {
if (indexItems.size() == 0){
indexItems.add(new IndexItem(getString(R.string.everything_up_to_date),"",0,"",0,0, null));
if (indexItems.size() == 0) {
indexItems.add(new IndexItem(getString(R.string.everything_up_to_date), "", 0, "", 0, 0, null));
}
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
listAdapter.sort(new Comparator<IndexItem>() {
@ -109,8 +109,12 @@ public class UpdatesIndexFragment extends SherlockListFragment {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
if (getMyApplication().getAppCustomization().showDownloadExtraActions()) {
MenuItem item = menu.add(0, DownloadIndexFragment.RELOAD_ID, 0, R.string.update_downlod_list);
item.setIcon(isLightActionBar() ? R.drawable.ic_action_refresh_light :
R.drawable.ic_action_refresh_dark);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
SubMenu s = menu.addSubMenu(0, DownloadIndexFragment.MORE_ID, 0, R.string.default_buttons_other_actions);
s.add(0, DownloadIndexFragment.RELOAD_ID, 0, R.string.update_downlod_list);
s.add(0, DownloadIndexFragment.SELECT_ALL_ID, 0, R.string.select_all);
s.add(0, DownloadIndexFragment.DESELECT_ALL_ID, 0, R.string.deselect_all);

View file

@ -732,8 +732,4 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
return false;
}
@Override
public boolean onlyTourDownload() {
return true;
}
}

View file

@ -379,6 +379,8 @@ public class TourViewActivity extends SherlockFragmentActivity {
public void startDownloadActivity() {
final Intent download = new Intent(this, DownloadActivity.class);
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
download.putExtra(DownloadActivity.SINGLE_TAB, true);
download.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
refreshListAfterDownload = true;
startActivity(download);
}
@ -418,6 +420,8 @@ public class TourViewActivity extends SherlockFragmentActivity {
}
public boolean onlyTourDownload() {
return true;
}
}