Updated view
This commit is contained in:
parent
51840ae833
commit
9970816739
3 changed files with 68 additions and 27 deletions
|
@ -1,30 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
<ScrollView android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/background"
|
||||
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:padding="8dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout android:id="@+id/search"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_cardui"
|
||||
android:layout_marginBottom="8dp">
|
||||
android:layout_marginBottom="6dp">
|
||||
<TextView android:text="@string/search_for"
|
||||
android:layout_width="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@color/color_black"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:textSize="16sp"
|
||||
android:layout_height="30dp"/>
|
||||
style="@style/DashboardSubHeader"
|
||||
android:layout_height="40dp"
|
||||
android:layout_width="wrap_content"/>
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@color/group_background"
|
||||
android:layout_height="80dp">
|
||||
android:layout_height="90dp">
|
||||
<Button android:id="@+id/poi"
|
||||
android:text="@string/poi"
|
||||
android:drawableTop="@drawable/ic_action_info_light"
|
||||
|
@ -45,7 +43,7 @@
|
|||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="@color/group_background"
|
||||
android:layout_height="80dp">
|
||||
android:layout_height="90dp">
|
||||
<Button android:id="@+id/fav"
|
||||
android:text="@string/my_favorites"
|
||||
android:drawableTop="@drawable/ic_action_fav_light"
|
||||
|
@ -67,12 +65,12 @@
|
|||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:background="@drawable/bg_cardui"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="40dp">
|
||||
<TextView android:text="@string/map_Button"
|
||||
style="@style/DashboardSubHeader"/>
|
||||
<Button android:id="@+id/show_map"
|
||||
|
@ -94,7 +92,7 @@
|
|||
android:orientation="vertical">
|
||||
<LinearLayout android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="40dp">
|
||||
<TextView android:text="@string/my_data_Button"
|
||||
style="@style/DashboardSubHeader"/>
|
||||
<Button android:id="@+id/show_all"
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
<item name="android:textColor">@color/color_black</item>
|
||||
<item name="android:layout_marginLeft">10dp</item>
|
||||
<item name="android:layout_marginLeft">16dp</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
|
||||
<style name="DashboardGeneralButton">
|
||||
<item name="android:layout_marginRight">10dp</item>
|
||||
<item name="android:layout_marginRight">16dp</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:textColor">@color/gpx_time_span_color</item>
|
||||
|
|
|
@ -3,22 +3,28 @@ package net.osmand.plus.activities;
|
|||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.*;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.render.MapVectorLayer;
|
||||
import net.osmand.plus.sherpafy.StageFavoritesLayer;
|
||||
import net.osmand.plus.views.GPXLayer;
|
||||
import net.osmand.plus.views.MapTextLayer;
|
||||
import net.osmand.plus.views.OsmAndMapSurfaceView;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis on 05.11.2014.
|
||||
|
@ -26,6 +32,7 @@ import net.osmand.plus.views.OsmandMapTileView;
|
|||
public class DashboardActivity extends SherlockFragmentActivity {
|
||||
public static final boolean TIPS_AND_TRICKS = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -34,11 +41,47 @@ public class DashboardActivity extends SherlockFragmentActivity {
|
|||
ColorDrawable color = new ColorDrawable(Color.parseColor("#FF9305"));
|
||||
getSupportActionBar().setBackgroundDrawable(color);
|
||||
getSupportActionBar().setIcon(android.R.color.transparent);
|
||||
prepareMapView();
|
||||
setupMapView();
|
||||
setupButtons();
|
||||
setupFavorites();
|
||||
|
||||
}
|
||||
|
||||
private void setupFavorites(){
|
||||
final FavouritesDbHelper helper = getMyApplication().getFavorites();
|
||||
final List<FavouritePoint> points = helper.getFavouritePoints();
|
||||
ArrayAdapter<FavouritePoint> adapter = new ArrayAdapter<FavouritePoint>(this, R.layout.favourites_list_item, 0, points) {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
if (view == null) {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
view = inflater.inflate(R.layout.favourites_list_item, parent, false);
|
||||
}
|
||||
|
||||
TextView label = (TextView) view.findViewById(R.id.favourite_label);
|
||||
ImageView icon = (ImageView) view.findViewById(R.id.favourite_icon);
|
||||
final FavouritePoint model = points.get(position);
|
||||
view.setTag(model);
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(DashboardActivity.this, model.getColor()));
|
||||
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
|
||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||
label.setText(distance + model.getName(), TextView.BufferType.SPANNABLE);
|
||||
label.setTypeface(Typeface.DEFAULT, model.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
|
||||
((Spannable) label.getText()).setSpan(
|
||||
new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
|
||||
0);
|
||||
final CheckBox ch = (CheckBox) view.findViewById(R.id.check_item);
|
||||
view.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
|
||||
ch.setVisibility(View.GONE);
|
||||
return view;
|
||||
}
|
||||
};
|
||||
((ListView) findViewById(R.id.list_favorites)).setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void setupButtons(){
|
||||
final Activity activity = this;
|
||||
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
|
||||
|
@ -63,7 +106,7 @@ public class DashboardActivity extends SherlockFragmentActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void prepareMapView() {
|
||||
private void setupMapView() {
|
||||
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
|
||||
OsmandMapTileView osmandMapTileView = surf.getMapView();
|
||||
osmandMapTileView.getView().setVisibility(View.VISIBLE);
|
||||
|
|
Loading…
Reference in a new issue