Live updates: Fixed some UI problems. Added non null checking with annotations.
This commit is contained in:
parent
9ec141a44f
commit
62ae222b22
4 changed files with 256 additions and 236 deletions
|
@ -1,251 +1,263 @@
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
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"/>
|
<LinearLayout
|
||||||
|
|
||||||
<GridLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/bg_color"
|
android:orientation="vertical">
|
||||||
android:columnCount="2">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
|
<include layout="@layout/card_top_divider"/>
|
||||||
|
|
||||||
|
<GridLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_columnSpan="2"
|
android:background="?attr/bg_color"
|
||||||
android:layout_marginLeft="16dp"
|
android:columnCount="2">
|
||||||
android:layout_marginRight="16dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:minHeight="48dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
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_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
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/reports_for"
|
android:layout_columnSpan="2"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:layout_marginLeft="16dp"
|
||||||
android:textSize="@dimen/default_sub_text_size"/>
|
android:layout_marginRight="16dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:minHeight="48dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/text1"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="fill_horizontal"
|
android:layout_gravity="fill_vertical"
|
||||||
android:textColor="?android:textColorPrimary"
|
android:gravity="center"
|
||||||
tools:text="Worldwide"/>
|
android:orientation="vertical"
|
||||||
</LinearLayout>
|
android:paddingTop="4dp">
|
||||||
|
|
||||||
<View
|
<TextView
|
||||||
android:layout_height="1dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_columnSpan="2"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/dashboard_divider"/>
|
android:text="@string/reports_for"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
<ProgressBar
|
<TextView
|
||||||
android:id="@+id/progress"
|
android:id="@android:id/text1"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="8dp"
|
android:layout_gravity="fill_horizontal"
|
||||||
android:layout_columnSpan="2"/>
|
android:textColor="?android:textColorPrimary"
|
||||||
|
tools:text="Worldwide"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<View
|
||||||
android:id="@+id/numberOfContributorsIcon"
|
android:id="@+id/divider_to_hide"
|
||||||
android:layout_height="60dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_columnSpan="2"
|
||||||
android:src="@drawable/ic_group"/>
|
android:layout_marginBottom="4dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
<LinearLayout
|
<ProgressBar
|
||||||
android:id="@+id/numberOfContributorsLayout"
|
android:id="@+id/progress"
|
||||||
android:layout_width="match_parent"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="fill_vertical"
|
android:layout_height="9dp"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_columnSpan="2"
|
||||||
android:background="?attr/expandable_list_item_background"
|
android:indeterminate="true"/>
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
android:id="@+id/numberOfContributorsTitle"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/number_of_contributors"
|
android:layout_gravity="fill_vertical"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:gravity="center"
|
||||||
android:textSize="@dimen/default_sub_text_size"/>
|
android:orientation="vertical"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contributorsTextView"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="0"
|
android:layout_gravity="fill_vertical"
|
||||||
android:textColor="?android:textColorPrimary"/>
|
android:gravity="center"
|
||||||
</LinearLayout>
|
android:orientation="vertical">
|
||||||
|
|
||||||
<View
|
<TextView
|
||||||
android:layout_height="1dp"
|
android:id="@+id/numberOfEditsTitle"
|
||||||
android:layout_column="1"
|
android:layout_width="match_parent"
|
||||||
android:background="?attr/dashboard_divider"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/number_of_edits"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:id="@+id/numberOfEditsIcon"
|
android:id="@+id/editsTextView"
|
||||||
android:layout_height="60dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_world_globe_dark"/>
|
android:text="0"
|
||||||
|
android:textColor="?android:textColorPrimary"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<ImageView
|
||||||
android:id="@+id/numberOfEditsLayout"
|
android:id="@+id/donationsIcon"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="56dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="60dp"
|
||||||
android:layout_gravity="fill_vertical"
|
android:scaleType="center"
|
||||||
android:layout_marginLeft="16dp"
|
android:src="@drawable/ic_action_message"/>
|
||||||
android:background="?attr/expandable_list_item_background"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/numberOfEditsTitle"
|
android:id="@+id/donationsLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/number_of_edits"
|
android:layout_gravity="fill_vertical"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:gravity="center"
|
||||||
android:textSize="@dimen/default_sub_text_size"/>
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/editsTextView"
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="0"
|
android:layout_gravity="fill_vertical"
|
||||||
android:textColor="?android:textColorPrimary"/>
|
android:gravity="center"
|
||||||
</LinearLayout>
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:id="@+id/donationsIcon"
|
android:id="@+id/numberOfRecipientsTitle"
|
||||||
android:layout_height="60dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_action_message"/>
|
android:text="@string/number_of_recipients"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:id="@+id/donationsLayout"
|
android:id="@+id/recipientsTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="fill_vertical"
|
android:text="-"
|
||||||
android:layout_marginLeft="16dp"
|
android:textColor="?android:textColorPrimary"/>
|
||||||
android:gravity="center"
|
</LinearLayout>
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
</GridLayout>
|
||||||
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
|
<include layout="@layout/card_bottom_divider"/>
|
||||||
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
|
</LinearLayout>
|
||||||
android:id="@+id/numberOfRecipientsIcon"
|
</ScrollView>
|
||||||
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: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"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/recipientsTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="-"
|
|
||||||
android:textColor="?android:textColorPrimary"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</GridLayout>
|
|
||||||
|
|
||||||
<include layout="@layout/card_bottom_divider"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -4,6 +4,7 @@ import android.app.AlarmManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -67,10 +68,9 @@ public class LiveUpdatesHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNameToDisplay(LocalIndexInfo child, OsmandActionBarActivity activity) {
|
public static String getNameToDisplay(LocalIndexInfo child, OsmandActionBarActivity activity) {
|
||||||
String mapName = FileNameTranslationHelper.getFileName(activity,
|
return FileNameTranslationHelper.getFileName(activity,
|
||||||
activity.getMyApplication().getResourceManager().getOsmandRegions(),
|
activity.getMyApplication().getResourceManager().getOsmandRegions(),
|
||||||
child.getFileName());
|
child.getFileName());
|
||||||
return mapName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatDateTime(Context ctx, long dateTime) {
|
public static String formatDateTime(Context ctx, long dateTime) {
|
||||||
|
@ -79,7 +79,8 @@ public class LiveUpdatesHelper {
|
||||||
return dateFormat.format(dateTime) + " " + timeFormat.format(dateTime);
|
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);
|
Intent intent = new Intent(context, LiveUpdatesAlarmReceiver.class);
|
||||||
final File file = new File(localIndexInfo.getFileName());
|
final File file = new File(localIndexInfo.getFileName());
|
||||||
final String fileName = Algorithms.getFileNameWithoutExtension(file);
|
final String fileName = Algorithms.getFileNameWithoutExtension(file);
|
||||||
|
@ -118,7 +119,7 @@ public class LiveUpdatesHelper {
|
||||||
return calendar.getTimeInMillis();
|
return calendar.getTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum TimeOfDay {
|
public enum TimeOfDay {
|
||||||
MORNING(R.string.morning),
|
MORNING(R.string.morning),
|
||||||
NIGHT(R.string.night);
|
NIGHT(R.string.night);
|
||||||
private final int localizedId;
|
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),
|
HOURLY(R.string.hourly, AlarmManager.INTERVAL_HOUR),
|
||||||
DAILY(R.string.daily, AlarmManager.INTERVAL_DAY),
|
DAILY(R.string.daily, AlarmManager.INTERVAL_DAY),
|
||||||
WEEKLY(R.string.weekly, AlarmManager.INTERVAL_DAY * 7);
|
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) {
|
public static void runLiveUpdate(Context context, final LocalIndexInfo info, boolean forceUpdate) {
|
||||||
final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info.getFileName()));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -29,11 +30,14 @@ public class PerformLiveUpdateAsyncTask
|
||||||
extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> {
|
extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> {
|
||||||
private final static Log LOG = PlatformUtil.getLog(PerformLiveUpdateAsyncTask.class);
|
private final static Log LOG = PlatformUtil.getLog(PerformLiveUpdateAsyncTask.class);
|
||||||
|
|
||||||
|
@NonNull
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
@NonNull
|
||||||
private final LocalIndexInfo localIndexInfo;
|
private final LocalIndexInfo localIndexInfo;
|
||||||
private final boolean forceUpdate;
|
private final boolean forceUpdate;
|
||||||
|
|
||||||
public PerformLiveUpdateAsyncTask(Context context, LocalIndexInfo localIndexInfo,
|
public PerformLiveUpdateAsyncTask(@NonNull Context context,
|
||||||
|
@NonNull LocalIndexInfo localIndexInfo,
|
||||||
boolean forceUpdate) {
|
boolean forceUpdate) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.localIndexInfo = localIndexInfo;
|
this.localIndexInfo = localIndexInfo;
|
||||||
|
@ -127,8 +131,9 @@ public class PerformLiveUpdateAsyncTask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tryRescheduleDownload(Context context, OsmandSettings settings,
|
public static void tryRescheduleDownload(@NonNull Context context,
|
||||||
LocalIndexInfo localIndexInfo) {
|
@NonNull OsmandSettings settings,
|
||||||
|
@NonNull LocalIndexInfo localIndexInfo) {
|
||||||
final OsmandSettings.CommonPreference<Integer> updateFrequencyPreference =
|
final OsmandSettings.CommonPreference<Integer> updateFrequencyPreference =
|
||||||
preferenceUpdateFrequency(localIndexInfo, settings);
|
preferenceUpdateFrequency(localIndexInfo, settings);
|
||||||
final Integer frequencyOrdinal = updateFrequencyPreference.get();
|
final Integer frequencyOrdinal = updateFrequencyPreference.get();
|
||||||
|
|
|
@ -1,18 +1,5 @@
|
||||||
package net.osmand.plus.liveupdates;
|
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.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -37,6 +24,19 @@ import android.widget.TextView;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonSyntaxException;
|
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 class ReportsFragment extends BaseOsmAndFragment implements CountrySelectionFragment.OnFragmentInteractionListener {
|
||||||
public static final String TITLE = "Report";
|
public static final String TITLE = "Report";
|
||||||
public static final String DOMAIN = "http://download.osmand.net/";
|
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 numberOfRecipientsTitle;
|
||||||
private TextView donationsTitle;
|
private TextView donationsTitle;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
private View dividerToHide;
|
||||||
|
|
||||||
private int inactiveColor;
|
private int inactiveColor;
|
||||||
private int textColorPrimary;
|
private int textColorPrimary;
|
||||||
private int textColorSecondary;
|
private int textColorSecondary;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
@ -89,7 +87,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
|
||||||
montReportsSpinner.setAdapter(monthsForReportsAdapter);
|
montReportsSpinner.setAdapter(monthsForReportsAdapter);
|
||||||
|
|
||||||
view.findViewById(R.id.show_all).setOnClickListener(new OnClickListener() {
|
view.findViewById(R.id.show_all).setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://osmand.net/osm_live"));
|
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.numberOfContributorsLayout).setOnClickListener(listener);
|
||||||
view.findViewById(R.id.numberOfEditsLayout).setOnClickListener(listener);;
|
view.findViewById(R.id.numberOfEditsLayout).setOnClickListener(listener);
|
||||||
|
|
||||||
countrySelectionFragment.initCountries(getMyApplication());
|
countrySelectionFragment.initCountries(getMyApplication());
|
||||||
selectedCountryItem = countrySelectionFragment.getCountryItems().get(0);
|
selectedCountryItem = countrySelectionFragment.getCountryItems().get(0);
|
||||||
|
@ -154,6 +152,8 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
|
||||||
donationsTextView = (TextView) view.findViewById(R.id.donationsTextView);
|
donationsTextView = (TextView) view.findViewById(R.id.donationsTextView);
|
||||||
recipientsTextView = (TextView) view.findViewById(R.id.recipientsTextView);
|
recipientsTextView = (TextView) view.findViewById(R.id.recipientsTextView);
|
||||||
|
|
||||||
|
dividerToHide = view.findViewById(R.id.divider_to_hide);
|
||||||
|
|
||||||
requestAndUpdateUi();
|
requestAndUpdateUi();
|
||||||
|
|
||||||
AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() {
|
AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() {
|
||||||
|
@ -352,6 +352,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
|
||||||
donationsTitle.setTextColor(inactiveColor);
|
donationsTitle.setTextColor(inactiveColor);
|
||||||
|
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
dividerToHide.setVisibility(View.GONE);
|
||||||
|
|
||||||
contributorsTextView.setTextColor(inactiveColor);
|
contributorsTextView.setTextColor(inactiveColor);
|
||||||
donationsTextView.setTextColor(inactiveColor);
|
donationsTextView.setTextColor(inactiveColor);
|
||||||
|
@ -370,7 +371,8 @@ public class ReportsFragment extends BaseOsmAndFragment implements CountrySelect
|
||||||
numberOfRecipientsTitle.setTextColor(textColorSecondary);
|
numberOfRecipientsTitle.setTextColor(textColorSecondary);
|
||||||
donationsTitle.setTextColor(textColorSecondary);
|
donationsTitle.setTextColor(textColorSecondary);
|
||||||
|
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
dividerToHide.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
contributorsTextView.setTextColor(textColorPrimary);
|
contributorsTextView.setTextColor(textColorPrimary);
|
||||||
editsTextView.setTextColor(textColorPrimary);
|
editsTextView.setTextColor(textColorPrimary);
|
||||||
|
|
Loading…
Reference in a new issue