diff --git a/OsmAnd/res/layout/fragment_reports.xml b/OsmAnd/res/layout/fragment_reports.xml index fd6083a386..01107fce82 100644 --- a/OsmAnd/res/layout/fragment_reports.xml +++ b/OsmAnd/res/layout/fragment_reports.xml @@ -1,251 +1,263 @@ - - - - + android:orientation="vertical"> - + + + android:background="?attr/bg_color" + android:columnCount="2"> - - - - - - - - - - - - - - - - - - + android:layout_columnSpan="2" + android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" + android:gravity="center_vertical" + android:minHeight="48dp" + android:orientation="horizontal"> - + + + + + + + + + + + + + + + - + android:layout_gravity="fill_vertical" + android:gravity="center" + android:orientation="vertical" + android:paddingTop="4dp"> - + - + + - + - + - + + + android:layout_gravity="fill_vertical" + android:gravity="center" + android:orientation="vertical" + android:paddingBottom="4dp"> - + + + + + + + + + - + android:layout_gravity="fill_vertical" + android:gravity="center" + android:orientation="vertical"> - + - + + - + - + android:layout_gravity="fill_vertical" + android:gravity="center" + android:orientation="vertical"> - + + + + + + + + + - + android:layout_gravity="fill_vertical" + android:gravity="center" + android:orientation="vertical"> - + - + + - + - - + - - - - - - - - - - - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java index a55e9a788c..6de28b1732 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesHelper.java @@ -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); } } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java index 16cd021ff3..eab8a6b078 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java @@ -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 { 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 updateFrequencyPreference = preferenceUpdateFrequency(localIndexInfo, settings); final Integer frequencyOrdinal = updateFrequencyPreference.get(); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index 4639c1b2db..b40a9f8bc1 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -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);