Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-01-22 09:32:50 +01:00
commit 8a04ae371c
5 changed files with 227 additions and 130 deletions

View file

@ -3,13 +3,7 @@
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<shape>
<gradient
android:startColor="#475259"
android:centerColor="#475259"
android:centerY="1.0"
android:endColor="#475259"
android:angle="270"
/>
<solid android:color="#475259"/>
</shape>
</item>
@ -17,13 +11,7 @@
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="@color/color_distance"
android:centerColor="@color/color_distance"
android:centerY="1.0"
android:endColor="@color/color_distance"
android:angle="270"
/>
<solid android:color="@color/color_distance"/>
</shape>
</clip>
</item>

View file

@ -8,118 +8,140 @@
<include layout="@layout/shadow_top"/>
<GridLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:columnCount="2"
android:paddingLeft="16dp">
android:layout_height="wrap_content">
<TextView
android:layout_height="48dp"
android:layout_columnSpan="2"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:text="@string/select_month_and_country"
android:textColor="?android:textColorPrimary"/>
<View
android:layout_height="1dp"
android:layout_columnSpan="2"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/calendarImageView"
android:layout_height="60dp"
android:src="@drawable/ic_action_data"/>
<!-- 24 is magic number + margin 16 = 42-->
<Spinner
android:id="@+id/montReportsSpinner"
android:layout_gravity="fill_horizontal|fill_vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="42dp"
android:gravity="center_vertical"/>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/regionIconImageView"
android:layout_height="60dp"
android:src="@drawable/ic_world_globe_dark"/>
<include
android:id="@+id/reportsButton"
layout="@layout/reports_for_spinner_item"
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"/>
<View
android:layout_height="1dp"
android:layout_columnSpan="2"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/numberOfContributorsIcon"
android:layout_height="60dp"
android:src="@drawable/ic_group"/>
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
android:background="?attr/bg_color"
android:columnCount="2">
<TextView
android:layout_height="48dp"
android:layout_columnSpan="2"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:text="@string/select_month_and_country"
android:textColor="?android:textColorPrimary"/>
<View
android:layout_height="1dp"
android:layout_columnSpan="2"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/calendarImageView"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_action_data"/>
<!-- 40 is magic number + margin 16 = 56-->
<Spinner
android:id="@+id/montReportsSpinner"
android:layout_gravity="fill_horizontal|fill_vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="56dp"
android:gravity="center_vertical"/>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/regionIconImageView"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_world_globe_dark"/>
<include
android:id="@+id/reportsButton"
layout="@layout/reports_for_spinner_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_contributors"
android:textSize="@dimen/default_sub_text_size"/>
android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp"
android:layout_marginRight="56dp"/>
<TextView
android:id="@+id/contributorsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
tools:text="65"/>
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_columnSpan="2"
android:background="?attr/dashboard_divider"/>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/numberOfContributorsIcon"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_group"/>
<ImageView
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
android:id="@+id/numberOfEditsIcon"
android:layout_height="60dp"
android:src="@drawable/ic_group"/>
<TextView
android:id="@+id/numberOfContributorsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_contributors"
android:textSize="@dimen/default_sub_text_size"/>
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/contributorsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_edits"
android:textSize="@dimen/default_sub_text_size"/>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider"/>
<TextView
android:id="@+id/editsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:textColorPrimary"
tools:text="1125"/>
</LinearLayout>
</GridLayout>
<ImageView
android:id="@+id/numberOfEditsIcon"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_group"/>
<LinearLayout
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:orientation="vertical">
<TextView
android:id="@+id/numberOfEditsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_edits"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/editsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>
</GridLayout>
<!-- 48 + 1 + 60 + 1 + 60 = 170-->
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_gravity="top"
android:layout_marginTop="167dp"
android:indeterminate="true"
android:padding="0dp"
tools:progress="50"/>
</FrameLayout>
<include layout="@layout/shadow_bottom"/>

View file

@ -1,15 +1,5 @@
package net.osmand.plus.activities.actions;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
@ -18,6 +8,17 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class AppModeDialog {
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,

View file

@ -2,13 +2,19 @@ package net.osmand.plus.liveupdates;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.AttrRes;
import android.support.annotation.ColorInt;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
@ -49,6 +55,16 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
HashMap<String, String> queryRegionNames = new HashMap<>();
ArrayList<String> regionNames = new ArrayList<>();
private ImageView numberOfContributorsIcon;
private ImageView numberOfEditsIcon;
private TextView numberOfContributorsTitle;
private TextView numberOfEditsTitle;
private ProgressBar progressBar;
private int inactiveColor;
private int textColorPrimary;
private int textColorSecondary;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@ -74,8 +90,13 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
setThemedDrawable(view, R.id.calendarImageView, R.drawable.ic_action_data);
setThemedDrawable(view, R.id.regionIconImageView, R.drawable.ic_world_globe_dark);
setThemedDrawable(view, R.id.numberOfContributorsIcon, R.drawable.ic_group);
setThemedDrawable(view, R.id.numberOfEditsIcon, R.drawable.ic_group);
numberOfContributorsIcon = (ImageView) view.findViewById(R.id.numberOfContributorsIcon);
setThemedDrawable(numberOfContributorsIcon, R.drawable.ic_group);
numberOfEditsIcon = (ImageView) view.findViewById(R.id.numberOfEditsIcon);
setThemedDrawable(numberOfEditsIcon, R.drawable.ic_map);
numberOfContributorsTitle = (TextView) view.findViewById(R.id.numberOfContributorsTitle);
numberOfEditsTitle = (TextView) view.findViewById(R.id.numberOfEditsTitle);
progressBar = (ProgressBar) view.findViewById(R.id.progress);
contributorsTextView = (TextView) view.findViewById(R.id.contributorsTextView);
editsTextView = (TextView) view.findViewById(R.id.editsTextView);
@ -94,6 +115,11 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
}
};
montReportsSpinner.setOnItemSelectedListener(onItemSelectedListener);
inactiveColor = getColorFromAttr(R.attr.plugin_details_install_header_bg);
textColorPrimary = getColorFromAttr(android.R.attr.textColorPrimary);
textColorSecondary = getColorFromAttr(android.R.attr.textColorSecondary);
return view;
}
@ -101,6 +127,11 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
int monthItemPosition = montReportsSpinner.getSelectedItemPosition();
String monthUrlString = monthsForReportsAdapter.getQueryString(monthItemPosition);
String countryUrlString = queryRegionNames.get(countryNameTextView.getText().toString());
tryUpdateData(monthUrlString, countryUrlString);
}
private void tryUpdateData(String monthUrlString, String regionUrlString) {
GetJsonAsyncTask.OnResponseListener<Protocol.TotalChangesByMonthResponse> onResponseListener =
new GetJsonAsyncTask.OnResponseListener<Protocol.TotalChangesByMonthResponse>() {
@Override
@ -113,13 +144,10 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
editsTextView.setText(String.valueOf(response.changes));
}
}
disableProgress();
}
};
requestData(monthUrlString, countryUrlString, onResponseListener);
}
private void requestData(String monthUrlString, String regionUrlString,
GetJsonAsyncTask.OnResponseListener<Protocol.TotalChangesByMonthResponse> onResponseListener) {
enableProgress();
GetJsonAsyncTask<Protocol.TotalChangesByMonthResponse> totalChangesByMontAsyncTask =
new GetJsonAsyncTask<>(Protocol.TotalChangesByMonthResponse.class);
totalChangesByMontAsyncTask.setOnResponseListener(onResponseListener);
@ -271,5 +299,38 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
protected ArrayList<String> getList() {
return ((ReportsFragment) getParentFragment()).regionNames;
}
@Override
protected int getListItemIcon() {
return R.drawable.ic_map;
}
}
private void enableProgress() {
numberOfContributorsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_group, inactiveColor));
numberOfEditsIcon.setImageDrawable(getPaintedContentIcon(R.drawable.ic_map, inactiveColor));
numberOfContributorsTitle.setTextColor(inactiveColor);
numberOfEditsTitle.setTextColor(inactiveColor);
progressBar.setVisibility(View.VISIBLE);
contributorsTextView.setTextColor(inactiveColor);
editsTextView.setTextColor(inactiveColor);
}
private void disableProgress() {
numberOfContributorsIcon.setImageDrawable(getContentIcon(R.drawable.ic_group));
numberOfEditsIcon.setImageDrawable(getContentIcon(R.drawable.ic_map));
numberOfContributorsTitle.setTextColor(textColorSecondary);
numberOfEditsTitle.setTextColor(textColorSecondary);
progressBar.setVisibility(View.INVISIBLE);
contributorsTextView.setTextColor(textColorPrimary);
editsTextView.setTextColor(textColorPrimary);
}
@ColorInt
private int getColorFromAttr(@AttrRes int colorAttribute) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getActivity().getTheme();
theme.resolveAttribute(colorAttribute, typedValue, true);
return typedValue.data;
}
}

View file

@ -1,7 +1,9 @@
package net.osmand.plus.liveupdates;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
@ -12,6 +14,7 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
@ -26,10 +29,10 @@ public abstract class SearchSelectionFragment extends BaseOsmAndDialogFragment {
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_search_list, container, false);
ListView listView = (ListView) view.findViewById(android.R.id.list);
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(getMyActivity(), android.R.layout.simple_list_item_1);
final ArrayAdapter<String> adapter = new ListAdapter(getActivity(), getListItemIcon());
if (getArray() != null) {
adapter.addAll(getArray());
} else if (getList() != null){
} else if (getList() != null) {
adapter.addAll(getList());
} else {
throw new RuntimeException("Either getArray() or getList() must return non null value.");
@ -89,6 +92,11 @@ public abstract class SearchSelectionFragment extends BaseOsmAndDialogFragment {
return null;
}
@DrawableRes
protected int getListItemIcon() {
return -1;
}
@Override
public void onDetach() {
super.onDetach();
@ -98,4 +106,21 @@ public abstract class SearchSelectionFragment extends BaseOsmAndDialogFragment {
public interface OnFragmentInteractionListener {
void onSearchResult(String name);
}
private class ListAdapter extends ArrayAdapter<String> {
private final Drawable drawableLeft;
public ListAdapter(Context context, @DrawableRes int drawableLeftId) {
super(getMyActivity(), android.R.layout.simple_list_item_1);
this.drawableLeft = drawableLeftId == -1 ? null : getContentIcon(drawableLeftId);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView view = (TextView) super.getView(position, convertView, parent);
view.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, null, null, null);
view.setCompoundDrawablePadding(getResources().getDimensionPixelSize(R.dimen.list_content_padding));
return view;
}
}
}