Merge pull request #200 from osmandapp/uiChanges

Ui changes
This commit is contained in:
Pavol Zibrita 2012-03-19 09:31:08 -07:00
commit c9add226b0
39 changed files with 453 additions and 116 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- checked -->
<item android:state_expanded="true" android:drawable="@drawable/list_activities_dot_marker1_pressed"/>
<!-- unchecked empty -->
<item android:state_expanded="false" android:state_empty="false" android:drawable="@drawable/list_activities_dot_marker1_content"/>
<!-- unchecked nonempty -->
<item android:drawable="@drawable/list_activities_dot_marker1_empty"/>
</selector>

View file

@ -1,20 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/MainLayout">
<!--TextView android:id="@+id/Label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/select_index_file_to_download"></TextView-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText android:id="@+id/search_box"
<!-- TextView android:id="@+id/Label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/select_index_file_to_download"></TextView -->
<EditText
android:id="@+id/search_box"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:hint="@string/download_type_to_filter"
android:inputType="text"
android:layout_marginLeft="3dp" android:layout_marginRight="3dp"
android:maxLines="1"/>
<ExpandableListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="0dp"
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" />
<Button android:id="@+id/DownloadButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/download_files"
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp" android:visibility="gone"/>
</LinearLayout>
android:maxLines="1" />
<ExpandableListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:groupIndicator="@android:color/transparent"
style="@style/OsmandListView" />
<Button
android:id="@+id/DownloadButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:gravity="center"
android:text="@string/download_files"
android:visibility="gone" />
</LinearLayout>

View file

@ -1,8 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/tab_menu_item_small" >
<TextView android:id="@+id/download_index_category_name" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="21sp" android:layout_marginTop="5dp" android:layout_marginLeft="40dp" android:autoLink="web"></TextView>
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="10dp"
android:src="@drawable/indicator_custom_gray" />
</LinearLayout>
<TextView
android:id="@+id/download_index_category_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:autoLink="web"
android:gravity="center_vertical"
android:textSize="21sp" >
</TextView>
</LinearLayout>

View file

@ -58,10 +58,11 @@
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:groupIndicator="@android:color/transparent"
style="@style/OsmandListView">
</ExpandableListView>

View file

@ -1,12 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:paddingLeft="40dp" android:paddingTop="3dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tab_menu_item_small" >
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<CheckBox android:id="@+id/check_item" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical" android:focusable="false" android:visibility="gone"/>
</LinearLayout>
<TextView android:id="@+id/category_name" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="24sp"></TextView>
<ImageView android:src="@drawable/indicator_custom_gray"
android:id="@+id/explist_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:layout_gravity="center_vertical"
/>
<TextView
android:id="@+id/category_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:textSize="24sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right" >
<CheckBox
android:id="@+id/check_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:gravity="center_vertical"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>

View file

@ -5,13 +5,13 @@
android:layout_height="fill_parent" android:orientation="vertical">
<TextView android:id="@+id/DescriptionTextTop" android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="" android:layout_marginLeft = "3dp" android:layout_marginRight = "3dp"
android:text="" android:layout_marginLeft = "10dp" android:layout_marginRight = "10dp"
android:visibility="gone"/>
<LinearLayout android:id="@+id/LoadingPanel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="3dp">
<Button android:id="@+id/DownloadButton" android:layout_width="wrap_content" android:layout_gravity="right" android:layout_height="wrap_content" android:text="@string/local_index_download"
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp"/>
<TextView android:id="@+id/DescriptionText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"
android:text="@string/local_index_description"/>
<!-- Button android:id="@+id/DownloadButton" android:layout_width="wrap_content" android:layout_gravity="right" android:layout_height="wrap_content" android:text="@string/local_index_download"
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp"/-->
<TextView android:id="@+id/DescriptionText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:text="@string/local_index_description"/>
<LinearLayout android:id="@+id/FillLayoutStart" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:visibility="gone"/>
<Button android:id="@+id/ActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/local_index_download"
android:layout_marginLeft = "3dp" android:layout_marginTop ="3dp" android:layout_marginRight = "3dp" android:visibility="gone"/>
@ -23,8 +23,16 @@
android:layout_marginRight="5dp"/>
</LinearLayout>
<ExpandableListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="wrap_content"
android:layout_marginLeft="3dp" android:layout_marginTop="3dp" android:layout_marginRight="3dp" ></ExpandableListView>
<ExpandableListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
android:layout_weight="1"
android:groupIndicator="@android:color/transparent"
style="@style/OsmandListView" >
</ExpandableListView>
</LinearLayout>

View file

@ -1,8 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/tab_menu_item_small" >
<TextView android:id="@+id/local_index_category_name" android:gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="21sp" android:layout_marginTop="5dp" android:layout_marginLeft="40dp"></TextView>
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingLeft="10dp"
android:src="@drawable/indicator_custom_gray" />
</LinearLayout>
<TextView
android:id="@+id/local_index_category_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="0dp"
android:gravity="center_vertical"
android:textSize="21sp" >
</TextView>
</LinearLayout>

View file

@ -1,37 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tab_title_headline_background"
android:orientation="horizontal" >
<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="@drawable/tab_back_button"
android:text="" />
<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="@drawable/tab_back_button"
android:text="" />
<ImageView
android:id="@+id/title_image"
<!--
Button
android:id="@+id/extra_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="27dp"
android:src="@drawable/tab_favorites_screen_icon" />
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="@drawable/tab_back_button"
android:visibility="gone"
android:text="" /
-->
<TextView
android:id="@+id/title_text"
style="@style/WhiteTitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="29dp"
android:layout_toRightOf="@+id/back_button"
android:text="@string/favourites_activity" />
<net.osmand.plus.activities.FontFitTextView
android:id="@+id/title_text"
style="@style/WhiteTitleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_toLeftOf="@+id/title_image"
android:layout_toRightOf="@+id/back_button"
android:text="@string/favourites_activity" />
<ImageView
android:id="@+id/title_image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="20dp"
android:layout_gravity="top"
android:src="@drawable/tab_favorites_screen_icon" />
</RelativeLayout>

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tab_title_headline_background"
android:orientation="horizontal" >
<Button
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="@drawable/tab_back_button"
android:text="" />
<net.osmand.plus.activities.FontFitTextView
android:id="@+id/title_text"
style="@style/WhiteTitleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_centerVertical="true"
android:layout_marginLeft="22dp"
android:layout_marginRight="22dp"
android:layout_toLeftOf="@+id/title_image"
android:layout_toRightOf="@+id/back_button"
android:text="@string/favourites_activity" />
<ImageView
android:id="@+id/title_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="top"
android:background="@drawable/tab_back_button_background" />
</RelativeLayout>

View file

@ -82,7 +82,7 @@
<item name="android:background">@color/activity_background</item>
</style>
<style name="CustomTitleTheme" parent="OsmandTheme">
<item name="android:windowTitleSize">46dp</item>
<item name="android:windowTitleSize">52dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
<style name="CustomTitleTheme.Preference" parent="CustomTitleTheme">

View file

@ -60,7 +60,7 @@ public class ContributionVersionActivity extends OsmandListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.download_files, R.drawable.tab_favorites_screen_icon);
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.download_files, R.drawable.tab_download_screen_icon);
setContentView(R.layout.download_builds);
titleBar.afterSetContentView();

View file

@ -27,9 +27,29 @@ public class CustomTitleBar {
this.activity.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
}
protected int getTitleBarLayout() {
return R.layout.titlebar;
}
public void afterSetContentView() {
activity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
activity.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, getTitleBarLayout());
initBackButton();
initText();
initImage();
}
protected void initImage() {
ImageView titleImg = (ImageView) activity.findViewById(R.id.title_image);
titleImg.setImageResource(titleImageRes);
}
protected void initText() {
TextView title = (TextView) activity.findViewById(R.id.title_text);
title.setText(titleStringRes);
}
protected void initBackButton() {
Button backButton = (Button) activity.findViewById(R.id.back_button);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -37,10 +57,13 @@ public class CustomTitleBar {
activity.finish();
}
});
TextView title = (TextView) activity.findViewById(R.id.title_text);
title.setText(titleStringRes);
ImageView titleImg = (ImageView) activity.findViewById(R.id.title_image);
titleImg.setImageResource(titleImageRes);
}
protected Activity getActivity() {
return activity;
}
protected int getTitleImageRes() {
return titleImageRes;
}
}

View file

@ -0,0 +1,41 @@
package net.osmand.plus.activities;
import net.osmand.plus.R;
import android.app.Activity;
import android.view.View.OnClickListener;
import android.widget.ImageView;
public class CustomTitleBarWithExtraButton extends CustomTitleBar {
private final OnClickListener listener;
public CustomTitleBarWithExtraButton(Activity activity, int titleStringRes,
int titleImageRes, OnClickListener listener) {
super(activity, titleStringRes, titleImageRes);
this.listener = listener;
}
@Override
protected int getTitleBarLayout() {
return R.layout.titlebar_extrabutton;
}
@Override
protected void initImage() {
//this titlebar has no image, it has an extra button instead!
ImageView titleImg = (ImageView)getActivity().findViewById(R.id.title_image);
titleImg.setImageResource(getTitleImageRes());
// titleImg.setVisibility(View.GONE);
// titleImg.setPadding(0, 0, 2, 0);
// titleImg.getLayoutParams().height = LayoutParams.WRAP_CONTENT;
// titleImg.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// titleImg.setBackgroundResource(R.drawable.tab_back_button_background);
titleImg.setOnClickListener(listener);
// titleImg.invalidate();
//
// Button extraButton = (Button)getActivity().findViewById(R.id.extra_button);
// extraButton.setVisibility(View.VISIBLE);
// extraButton.set
}
}

View file

@ -60,7 +60,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ExpandableListAdapter;
@ -130,7 +129,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
downloadListIndexThread = new DownloadIndexListThread(Version.getVersionAsURLParam(this));
}
// recreation upon rotation is prevented in manifest file
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.local_index_download, R.drawable.tab_settings_screen_icon);
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.local_index_download, R.drawable.tab_download_screen_icon);
setContentView(R.layout.download_index);
titleBar.afterSetContentView();
tracker = GoogleAnalyticsTracker.getInstance();
@ -195,11 +194,10 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
private void updateLoadedFiles() {
indexActivatedFileNames = ((OsmandApplication)getApplication()).getResourceManager().getIndexFileNames();
indexFileNames = ((OsmandApplication)getApplication()).getResourceManager().getIndexFileNames();
((OsmandApplication)getApplication()).getResourceManager().getBackupIndexes(indexFileNames);
indexActivatedFileNames = getMyApplication().getResourceManager().getIndexFileNames();
indexFileNames = getMyApplication().getResourceManager().getIndexFileNames();
getMyApplication().getResourceManager().getBackupIndexes(indexFileNames);
}
private void downloadIndexList() {
showDialog(DIALOG_PROGRESS_LIST);
@ -717,7 +715,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
}
// reindex vector maps all at one time
if (vectorMapsToReindex) {
ResourceManager manager = ((OsmandApplication) getApplication()).getResourceManager();
ResourceManager manager = getMyApplication().getResourceManager();
List<String> warnings = manager.indexingMaps(progress);
if (warnings.isEmpty() && !OsmandApplication.getSettings().MAP_VECTOR_DATA.get()) {
warnings.add(getString(R.string.binary_map_download_success));
@ -835,7 +833,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
}
protected class DownloadIndexAdapter extends BaseExpandableListAdapter implements Filterable {
protected class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
private DownloadIndexFilter myFilter;
private final Map<String, IndexItem> indexFiles;
@ -966,6 +964,7 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
TextView item = (TextView) row.findViewById(R.id.download_index_category_name);
item.setText(group.name);
item.setLinkTextColor(Color.YELLOW);
adjustIndicator(groupPosition, isExpanded, v);
return row;
}

View file

@ -80,11 +80,12 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
setContentView(R.layout.favourites_list);
titleBar.afterSetContentView();
helper = ((OsmandApplication)getApplication()).getFavorites();
helper = getMyApplication().getFavorites();
favouritesAdapter = new FavouritesAdapter();
favouritesAdapter.setFavoriteGroups(helper.getFavoriteGroups());
getExpandableListView().setAdapter(favouritesAdapter);
/* Add Context-Menu listener to the ListView. */
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener(){
@ -471,7 +472,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
}
class FavouritesAdapter extends BaseExpandableListAdapter {
class FavouritesAdapter extends OsmandBaseExpandableListAdapter {
Map<String, List<FavouritePoint>> sourceFavoriteGroups;
Map<String, List<FavouritePoint>> favoriteGroups = new LinkedHashMap<String, List<FavouritePoint>>();
@ -560,7 +561,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View row = convertView;
@ -568,11 +569,10 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.favourites_list_category, parent, false);
}
adjustIndicator(groupPosition, isExpanded, row);
TextView label = (TextView) row.findViewById(R.id.category_name);
final String model = getGroup(groupPosition);
List<FavouritePoint> ms = helper.getFavoriteGroups().get(model);
int sz = ms != null ? ms.size() : 0;
label.setText(model + " [" + sz +"]");
label.setText(model);
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
if(selectionMode){
@ -596,7 +596,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
}
return row;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
View row = convertView;

View file

@ -0,0 +1,87 @@
package net.osmand.plus.activities;
import android.content.Context;
import android.graphics.Rect;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.widget.TextView;
/* Based on
* from http://stackoverflow.com/questions/2617266/how-to-adjust-text-font-size-to-fit-textview
*/
public class FontFitTextView extends TextView {
private static float MAX_TEXT_SIZE = 20;
public FontFitTextView(Context context) {
this(context, null);
}
public FontFitTextView(Context context, AttributeSet attrs) {
super(context, attrs);
float size = this.getTextSize();
if (size > MAX_TEXT_SIZE)
setTextSize(MAX_TEXT_SIZE);
}
// Default constructor override
public FontFitTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
float size = this.getTextSize();
if (size > MAX_TEXT_SIZE)
setTextSize(MAX_TEXT_SIZE);
}
private void refitText(String text, int textWidth) {
if (textWidth > 0) {
float availableWidth = textWidth - this.getPaddingLeft()
- this.getPaddingRight();
TextPaint tp = getPaint();
Rect rect = new Rect();
tp.getTextBounds(text, 0, text.length(), rect);
float size = rect.width();
if (size > availableWidth)
setTextScaleX(availableWidth / size);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
refitText(this.getText().toString(), parentWidth);
this.setMeasuredDimension(parentWidth, parentHeight);
}
@Override
protected void onTextChanged(final CharSequence text, final int start,
final int before, final int after) {
refitText(text.toString(), this.getWidth());
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (w != oldw) {
refitText(this.getText().toString(), w);
}
}
// /**
// * Resize text after measuring
// */
// @Override
// protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
// if(changed) { // || mNeedsResize) {
// int widthLimit = (right - left) - getCompoundPaddingLeft() - getCompoundPaddingRight();
// int heightLimit = (bottom - top) - getCompoundPaddingBottom() - getCompoundPaddingTop();
// resizeText(widthLimit, heightLimit);
// }
// super.onLayout(changed, left, top, right, bottom);
// }
}

View file

@ -39,7 +39,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
@ -75,7 +74,13 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CustomTitleBar titleBar = new CustomTitleBar(this, R.string.local_index_descr_title, R.drawable.tab_settings_screen_icon);
CustomTitleBar titleBar = new CustomTitleBarWithExtraButton(this, R.string.local_index_descr_title, R.drawable.tab_download_screen_icon, new View.OnClickListener() {
@Override
public void onClick(View v) {
asyncLoader.setResult(null);
startActivity(new Intent(LocalIndexesActivity.this, DownloadIndexActivity.class));
}
});
setContentView(R.layout.local_index);
titleBar.afterSetContentView();
settings = OsmandApplication.getSettings();
@ -83,14 +88,13 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
listAdapter = new LocalIndexesAdapter();
findViewById(R.id.DownloadButton).setOnClickListener(new View.OnClickListener() {
/*findViewById(R.id.DownloadButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
asyncLoader.setResult(null);
startActivity(new Intent(LocalIndexesActivity.this, DownloadIndexActivity.class));
}
});
});*/
getExpandableListView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
@Override
@ -163,7 +167,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
OsmandSettings settings = OsmandApplication.getSettings();
settings.setMapLocationToShow(loc.lat, loc.lon, settings.getLastKnownMapZoom());
}
((OsmandApplication) getApplication()).setGpxFileToDisplay(info.getGpxFile(), false);
getMyApplication().setGpxFileToDisplay(info.getGpxFile(), false);
MapActivity.launchMapActivityMoveToTop(LocalIndexesActivity.this);
}
} else if (resId == R.string.local_index_mi_rename) {
@ -240,7 +244,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
@Override
protected List<LocalIndexInfo> doInBackground(Activity... params) {
LocalIndexHelper helper = new LocalIndexHelper((OsmandApplication) getApplication());
LocalIndexHelper helper = new LocalIndexHelper(getMyApplication());
return helper.getAllLocalIndexData(this);
}
@ -461,7 +465,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
@Override
protected LocalIndexInfo[] doInBackground(LocalIndexInfo... params) {
LocalIndexHelper helper = new LocalIndexHelper((OsmandApplication) getApplication());
LocalIndexHelper helper = new LocalIndexHelper(getMyApplication());
for (LocalIndexInfo i : params) {
helper.updateDescription(i);
}
@ -620,7 +624,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
closeSelectionMode();
}
});
findViewById(R.id.DownloadButton).setVisibility(View.GONE);
// findViewById(R.id.DownloadButton).setVisibility(View.GONE);
findViewById(R.id.FillLayoutStart).setVisibility(View.VISIBLE);
findViewById(R.id.FillLayoutEnd).setVisibility(View.VISIBLE);
findViewById(R.id.DescriptionText).setVisibility(View.GONE);
@ -644,7 +648,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
private void closeSelectionMode(){
selectionMode = false;
findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE);
// findViewById(R.id.DownloadButton).setVisibility(View.VISIBLE);
findViewById(R.id.DescriptionText).setVisibility(View.VISIBLE);
findViewById(R.id.FillLayoutStart).setVisibility(View.GONE);
findViewById(R.id.FillLayoutEnd).setVisibility(View.GONE);
@ -714,7 +718,7 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
}
@Override
protected List<String> doInBackground(Void... params) {
return ((OsmandApplication) getApplication()).getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS);
return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS);
}
};
@ -724,7 +728,8 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
protected class LocalIndexesAdapter extends BaseExpandableListAdapter {
protected class LocalIndexesAdapter extends OsmandBaseExpandableListAdapter {
Map<LocalIndexInfo, List<LocalIndexInfo>> data = new LinkedHashMap<LocalIndexInfo, List<LocalIndexInfo>>();
List<LocalIndexInfo> category = new ArrayList<LocalIndexInfo>();
List<LocalIndexInfo> filterCategory = null;
@ -909,14 +914,8 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
if (group.isBackupedData()) {
t.append(" - ").append(getString(R.string.local_indexes_cat_backup));
}
adjustIndicator(groupPosition, isExpanded, v);
TextView nameView = ((TextView) v.findViewById(R.id.local_index_category_name));
t.append(" [").append(getChildrenCount(groupPosition));
if(getString(R.string.local_index_items).length() > 0){
t.append(" ").append(getString(R.string.local_index_items));
}
if(getString(R.string.local_index_items).length() > 0){
t.append(" ").append(getString(R.string.local_index_items));
}
List<LocalIndexInfo> list = data.get(group);
int size = 0;
for(int i=0; i<list.size(); i++){
@ -930,9 +929,8 @@ public class LocalIndexesActivity extends OsmandExpandableListActivity {
}
size = size / (1 << 10);
if(size > 0){
t.append(", ").append(size).append(" MB");
t.append(" [").append(size).append(" MB]");
}
t.append("]");
nameView.setText(t.toString());
if (!group.isBackupedData()) {
nameView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);

View file

@ -262,7 +262,7 @@ public class LocalOpenstreetmapActivity extends OsmandExpandableListActivity {
}
public void delete(OpenstreetmapPoint i) {
final AmenityIndexRepositoryOdb repo = ((OsmandApplication) getApplication()).getResourceManager().getUpdatablePoiDb();
final AmenityIndexRepositoryOdb repo = getMyApplication().getResourceManager().getUpdatablePoiDb();
android.util.Log.d(LogUtil.TAG, "Delete " + i);
db.deleteOpenstreetmap(i);
String c = i.getType();

View file

@ -0,0 +1,23 @@
package net.osmand.plus.activities;
import net.osmand.plus.R;
import android.view.View;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
public abstract class OsmandBaseExpandableListAdapter extends BaseExpandableListAdapter {
protected void adjustIndicator(int groupPosition, boolean isExpanded, View row) {
ImageView indicator = (ImageView) row.findViewById(R.id.explist_indicator);
if (!isExpanded) {
if (getChildrenCount(groupPosition) == 0) {
indicator.setImageResource(R.drawable.list_activities_dot_marker1_empty);
} else {
indicator.setImageResource(R.drawable.list_activities_dot_marker1_content);
}
} else {
indicator.setImageResource(R.drawable.list_activities_dot_marker1_pressed);
}
}
}

View file

@ -15,4 +15,8 @@ public abstract class OsmandExpandableListActivity extends
view.setCacheColorHint(getResources().getColor(R.color.activity_background));
view.setDivider(getResources().getDrawable(R.drawable.tab_text_separator));
}
protected OsmandApplication getMyApplication() {
return (OsmandApplication)getApplication();
}
}