Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-02-26 14:55:25 +01:00
commit 106a257654
4 changed files with 258 additions and 237 deletions

View file

@ -1,250 +1,263 @@
<LinearLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="net.osmand.plus.liveupdates.ReportsFragment" >
tools:context="net.osmand.plus.liveupdates.ReportsFragment">
<include layout="@layout/card_top_divider" />
<GridLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:columnCount="2" >
android:orientation="vertical">
<LinearLayout
android:layout_columnSpan="2"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:minHeight="48dp"
<include layout="@layout/card_top_divider"/>
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
android:background="?attr/bg_color"
android:columnCount="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:text="@string/select_month_and_country"
android:textColor="?android:textColorPrimary" />
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/show_all"
style="@style/DashboardGeneralButton"
android:text="@string/shared_string_all"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
<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" />
<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" />
<LinearLayout
android:id="@+id/reportsButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="16dp"
android:background="?attr/expandable_list_item_background"
android:gravity="center"
android:orientation="vertical" >
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/reports_for"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
android:layout_columnSpan="2"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:gravity="center_vertical"
android:minHeight="48dp"
android:orientation="horizontal">
<TextView
android:id="@android:id/text1"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/select_month_and_country"
android:textColor="?android:textColorPrimary"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/show_all"
style="@style/DashboardGeneralButton"
android:text="@string/shared_string_all"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_columnSpan="2"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/calendarImageView"
android:layout_width="56dp"
android:layout_height="60dp"
android:scaleType="center"
android:src="@drawable/ic_action_data"/>
<Spinner
android:id="@+id/montReportsSpinner"
android:layout_gravity="fill_horizontal|fill_vertical"
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_width="56dp"
android:layout_height="56dp"
android:paddingTop="4dp"
android:scaleType="center"
android:src="@drawable/ic_world_globe_dark"/>
<LinearLayout
android:id="@+id/reportsButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:textColor="?android:textColorPrimary"
tools:text="Worldwide" />
</LinearLayout>
android:layout_gravity="fill_vertical"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="4dp">
<View
android:layout_height="1dp"
android:layout_columnSpan="2"
android:background="?attr/dashboard_divider" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/reports_for"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:layout_columnSpan="2" />
<TextView
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:textColor="?android:textColorPrimary"
tools:text="Worldwide"/>
</LinearLayout>
<ImageView
android:id="@+id/numberOfContributorsIcon"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_group" />
<View
android:id="@+id/divider_to_hide"
android:layout_height="1dp"
android:layout_columnSpan="2"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/numberOfContributorsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="16dp"
android:background="?attr/expandable_list_item_background"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="9dp"
android:layout_columnSpan="2"
android:indeterminate="true"/>
<TextView
android:id="@+id/numberOfContributorsTitle"
<ImageView
android:id="@+id/numberOfContributorsIcon"
android:layout_width="56dp"
android:layout_height="56dp"
android:paddingBottom="4dp"
android:scaleType="center"
android:src="@drawable/ic_group"/>
<LinearLayout
android:id="@+id/numberOfContributorsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_contributors"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
android:layout_gravity="fill_vertical"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="4dp">
<TextView
android:id="@+id/contributorsTextView"
<TextView
android:id="@+id/numberOfContributorsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_contributors"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/contributorsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/numberOfEditsIcon"
android:layout_width="56dp"
android:layout_height="60dp"
android:scaleType="center"
android:src="@drawable/ic_world_globe_dark"/>
<LinearLayout
android:id="@+id/numberOfEditsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
android:layout_gravity="fill_vertical"
android:gravity="center"
android:orientation="vertical">
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider" />
<TextView
android:id="@+id/numberOfEditsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_edits"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<ImageView
android:id="@+id/numberOfEditsIcon"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_world_globe_dark" />
<TextView
android:id="@+id/editsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>
<LinearLayout
android:id="@+id/numberOfEditsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="16dp"
android:background="?attr/expandable_list_item_background"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="@+id/donationsIcon"
android:layout_width="56dp"
android:layout_height="60dp"
android:scaleType="center"
android:src="@drawable/ic_action_message"/>
<TextView
android:id="@+id/numberOfEditsTitle"
<LinearLayout
android:id="@+id/donationsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_edits"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
android:layout_gravity="fill_vertical"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/editsTextView"
<TextView
android:id="@+id/donationsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/donations"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/donationsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="-"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider"/>
<ImageView
android:id="@+id/numberOfRecipientsIcon"
android:layout_width="56dp"
android:layout_height="60dp"
android:scaleType="center"
android:src="@drawable/ic_group"/>
<LinearLayout
android:id="@+id/numberOfRecipientsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
android:layout_gravity="fill_vertical"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/donationsIcon"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_action_message" />
<TextView
android:id="@+id/numberOfRecipientsTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/number_of_recipients"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<LinearLayout
android:id="@+id/donationsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="16dp"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/recipientsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="-"
android:textColor="?android:textColorPrimary"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:id="@+id/donationsTitle"
android:layout_height="wrap_content"
android:text="@string/donations"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
</GridLayout>
<TextView
android:id="@+id/donationsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="-"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
<include layout="@layout/card_bottom_divider"/>
<View
android:layout_height="1dp"
android:layout_column="1"
android:background="?attr/dashboard_divider" />
<ImageView
android:id="@+id/numberOfRecipientsIcon"
android:layout_height="60dp"
android:layout_marginLeft="16dp"
android:src="@drawable/ic_group" />
<LinearLayout
android:id="@+id/numberOfRecipientsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_marginLeft="16dp"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/numberOfRecipientsTitle"
android:text="@string/number_of_recipients"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
<TextView
android:id="@+id/recipientsTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="-"
android:textColor="?android:textColorPrimary" />
</LinearLayout>
<include layout="@layout/card_bottom_divider" />
</GridLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -4,6 +4,7 @@ import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@ -67,10 +68,9 @@ public class LiveUpdatesHelper {
}
public static String getNameToDisplay(LocalIndexInfo child, OsmandActionBarActivity activity) {
String mapName = FileNameTranslationHelper.getFileName(activity,
return FileNameTranslationHelper.getFileName(activity,
activity.getMyApplication().getResourceManager().getOsmandRegions(),
child.getFileName());
return mapName;
}
public static String formatDateTime(Context ctx, long dateTime) {
@ -79,7 +79,8 @@ public class LiveUpdatesHelper {
return dateFormat.format(dateTime) + " " + timeFormat.format(dateTime);
}
public static PendingIntent getPendingIntent(Context context, LocalIndexInfo localIndexInfo) {
public static PendingIntent getPendingIntent(@NonNull Context context,
@NonNull LocalIndexInfo localIndexInfo) {
Intent intent = new Intent(context, LiveUpdatesAlarmReceiver.class);
final File file = new File(localIndexInfo.getFileName());
final String fileName = Algorithms.getFileNameWithoutExtension(file);
@ -118,7 +119,7 @@ public class LiveUpdatesHelper {
return calendar.getTimeInMillis();
}
public static enum TimeOfDay {
public enum TimeOfDay {
MORNING(R.string.morning),
NIGHT(R.string.night);
private final int localizedId;
@ -138,7 +139,7 @@ public class LiveUpdatesHelper {
}
}
public static enum UpdateFrequency {
public enum UpdateFrequency {
HOURLY(R.string.hourly, AlarmManager.INTERVAL_HOUR),
DAILY(R.string.daily, AlarmManager.INTERVAL_DAY),
WEEKLY(R.string.weekly, AlarmManager.INTERVAL_DAY * 7);
@ -160,6 +161,6 @@ public class LiveUpdatesHelper {
public static void runLiveUpdate(Context context, final LocalIndexInfo info, boolean forceUpdate) {
final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info.getFileName()));
new PerformLiveUpdateAsyncTask(context, info, forceUpdate).execute(new String[]{fnExt});
new PerformLiveUpdateAsyncTask(context, info, forceUpdate).execute(fnExt);
}
}

View file

@ -5,6 +5,7 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
@ -29,11 +30,14 @@ public class PerformLiveUpdateAsyncTask
extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> {
private final static Log LOG = PlatformUtil.getLog(PerformLiveUpdateAsyncTask.class);
@NonNull
private final Context context;
@NonNull
private final LocalIndexInfo localIndexInfo;
private final boolean forceUpdate;
public PerformLiveUpdateAsyncTask(Context context, LocalIndexInfo localIndexInfo,
public PerformLiveUpdateAsyncTask(@NonNull Context context,
@NonNull LocalIndexInfo localIndexInfo,
boolean forceUpdate) {
this.context = context;
this.localIndexInfo = localIndexInfo;
@ -127,8 +131,9 @@ public class PerformLiveUpdateAsyncTask
}
}
public static void tryRescheduleDownload(Context context, OsmandSettings settings,
LocalIndexInfo localIndexInfo) {
public static void tryRescheduleDownload(@NonNull Context context,
@NonNull OsmandSettings settings,
@NonNull LocalIndexInfo localIndexInfo) {
final OsmandSettings.CommonPreference<Integer> updateFrequencyPreference =
preferenceUpdateFrequency(localIndexInfo, settings);
final Integer frequencyOrdinal = updateFrequencyPreference.get();

View file

@ -1,18 +1,5 @@
package net.osmand.plus.liveupdates;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import net.osmand.PlatformUtil;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem;
import org.apache.commons.logging.Log;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
@ -37,6 +24,19 @@ import android.widget.TextView;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import net.osmand.PlatformUtil;
import net.osmand.osm.io.NetworkUtils;
import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.liveupdates.CountrySelectionFragment.CountryItem;
import org.apache.commons.logging.Log;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
public class ReportsFragment extends BaseOsmAndFragment implements CountrySelectionFragment.OnFragmentInteractionListener {
public static final String TITLE = "Report";
public static final String DOMAIN = "http://download.osmand.net/";
@ -72,13 +72,11 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
private TextView numberOfRecipientsTitle;
private TextView donationsTitle;
private ProgressBar progressBar;
private View dividerToHide;
private int inactiveColor;
private int textColorPrimary;
private int textColorSecondary;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -89,7 +87,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
montReportsSpinner.setAdapter(monthsForReportsAdapter);
view.findViewById(R.id.show_all).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://osmand.net/osm_live"));
@ -120,7 +118,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
}
};
view.findViewById(R.id.numberOfContributorsLayout).setOnClickListener(listener);
view.findViewById(R.id.numberOfEditsLayout).setOnClickListener(listener);;
view.findViewById(R.id.numberOfEditsLayout).setOnClickListener(listener);
countrySelectionFragment.initCountries(getMyApplication());
selectedCountryItem = countrySelectionFragment.getCountryItems().get(0);
@ -154,6 +152,8 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
donationsTextView = (TextView) view.findViewById(R.id.donationsTextView);
recipientsTextView = (TextView) view.findViewById(R.id.recipientsTextView);
dividerToHide = view.findViewById(R.id.divider_to_hide);
requestAndUpdateUi();
AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() {
@ -352,6 +352,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
donationsTitle.setTextColor(inactiveColor);
progressBar.setVisibility(View.VISIBLE);
dividerToHide.setVisibility(View.GONE);
contributorsTextView.setTextColor(inactiveColor);
donationsTextView.setTextColor(inactiveColor);
@ -370,7 +371,8 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
numberOfRecipientsTitle.setTextColor(textColorSecondary);
donationsTitle.setTextColor(textColorSecondary);
progressBar.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.GONE);
dividerToHide.setVisibility(View.VISIBLE);
contributorsTextView.setTextColor(textColorPrimary);
editsTextView.setTextColor(textColorPrimary);