Added redownload icon to first screen. Fixes.

This commit is contained in:
Alexey Kulish 2016-08-18 13:36:45 +03:00
parent a557439595
commit 41d9e92f7c
2 changed files with 123 additions and 49 deletions

View file

@ -13,8 +13,8 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp"
android:fillViewport="true">
android:fillViewport="true"
android:paddingTop="8dp">
<LinearLayout
android:layout_width="match_parent"
@ -486,13 +486,13 @@
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:visibility="gone"
android:text="@string/search_another_country"
android:textColor="@color/color_dialog_buttons_light"/>
android:textColor="@color/color_dialog_buttons_light"
android:visibility="gone"/>
<android.support.v7.widget.CardView
android:id="@+id/map_downloading_card"
@ -534,27 +534,45 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="14dp"
android:gravity="center_vertical"
android:minHeight="35dp"
android:orientation="vertical">
android:orientation="horizontal">
<TextView
android:id="@+id/map_downloading_title"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="The Netherlands"/>
android:layout_weight="1"
android:gravity="center_vertical"
android:minHeight="35dp"
android:orientation="vertical">
<TextView
android:id="@+id/map_downloading_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="255 MB"/>
<TextView
android:id="@+id/map_downloading_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="The Netherlands"/>
<TextView
android:id="@+id/map_downloading_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="255 MB"/>
</LinearLayout>
<ImageButton
android:id="@+id/map_redownload_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="44dp"
android:layout_height="60dp"
android:layout_marginTop="-14dp"
android:contentDescription="@string/shared_string_cancel"
android:src="@drawable/ic_action_refresh_dark"
android:tint="@color/map_widget_blue"
android:visibility="gone"/>
</LinearLayout>
@ -569,8 +587,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-8dp"
android:visibility="visible"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="visible">
<LinearLayout
android:layout_width="0dp"
@ -633,27 +651,45 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="14dp"
android:gravity="center_vertical"
android:minHeight="35dp"
android:orientation="vertical">
android:orientation="horizontal">
<TextView
android:id="@+id/map2_downloading_title"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="The Netherlands"/>
android:layout_weight="1"
android:gravity="center_vertical"
android:minHeight="35dp"
android:orientation="vertical">
<TextView
android:id="@+id/map2_downloading_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="255 MB"/>
<TextView
android:id="@+id/map2_downloading_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="The Netherlands"/>
<TextView
android:id="@+id/map2_downloading_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="255 MB"/>
</LinearLayout>
<ImageButton
android:id="@+id/map2_redownload_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="44dp"
android:layout_height="60dp"
android:layout_marginTop="-14dp"
android:contentDescription="@string/shared_string_cancel"
android:src="@drawable/ic_action_refresh_dark"
android:tint="@color/map_widget_blue"
android:visibility="gone"/>
</LinearLayout>

View file

@ -16,6 +16,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -220,6 +221,19 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
final View progressPadding = view.findViewById(R.id.map_download_padding);
final View progressLayout = view.findViewById(R.id.map_download_progress_layout);
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
final ImageButton redownloadButton = (ImageButton) view.findViewById(R.id.map_redownload_button);
redownloadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!downloadThread.isDownloading(item) && !item.isDownloaded() && firstMapDownloadCancelled) {
progressPadding.setVisibility(View.GONE);
progressLayout.setVisibility(View.VISIBLE);
redownloadButton.setVisibility(View.GONE);
validationManager.startDownload(getActivity(), item);
firstMapDownloadCancelled = false;
}
}
});
view.findViewById(R.id.map_download_progress_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -228,11 +242,13 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
progressPadding.setVisibility(View.VISIBLE);
progressLayout.setVisibility(View.GONE);
redownloadButton.setVisibility(View.VISIBLE);
}
});
if (item.isDownloaded() || firstMapDownloadCancelled) {
progressPadding.setVisibility(View.VISIBLE);
progressLayout.setVisibility(View.GONE);
redownloadButton.setVisibility(firstMapDownloadCancelled ? View.VISIBLE : View.GONE);
}
view.findViewById(R.id.map_downloading_layout).setVisibility(View.VISIBLE);
} else {
@ -248,6 +264,19 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
final View progressPadding = view.findViewById(R.id.map2_download_padding);
final View progressLayout = view.findViewById(R.id.map2_download_progress_layout);
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
final ImageButton redownloadButton = (ImageButton) view.findViewById(R.id.map2_redownload_button);
redownloadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!downloadThread.isDownloading(item) && !item.isDownloaded() && secondMapDownloadCancelled) {
progressPadding.setVisibility(View.GONE);
progressLayout.setVisibility(View.VISIBLE);
redownloadButton.setVisibility(View.GONE);
validationManager.startDownload(getActivity(), item);
secondMapDownloadCancelled = false;
}
}
});
view.findViewById(R.id.map2_download_progress_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -256,11 +285,13 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
mapDescriptionTextView.setText(item.getSizeDescription(getContext()));
progressPadding.setVisibility(View.VISIBLE);
progressLayout.setVisibility(View.GONE);
redownloadButton.setVisibility(View.VISIBLE);
}
});
if (item.isDownloaded() || secondMapDownloadCancelled) {
progressPadding.setVisibility(View.VISIBLE);
progressLayout.setVisibility(View.GONE);
redownloadButton.setVisibility(secondMapDownloadCancelled ? View.VISIBLE : View.GONE);
}
view.findViewById(R.id.map2_downloading_layout).setVisibility(View.VISIBLE);
} else {
@ -441,7 +472,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
@Override
public void downloadInProgress() {
IndexItem indexItem = downloadThread.getCurrentDownloadingItem();
if (indexItem != null) {
if (indexItem != null && !indexItem.isDownloaded()) {
int progress = downloadThread.getCurrentDownloadingItemProgress();
double mb = indexItem.getArchiveSizeMB();
String v;
@ -468,23 +499,30 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
}
}
}
updateDownloadedItems();
}
@Override
public void downloadHasFinished() {
updateDownloadedItems();
}
private void updateDownloadedItems() {
int i = 0;
for (IndexItem indexItem : indexItems) {
if (indexItem.isDownloaded()) {
if (i == 0) {
final View progressLayout = view.findViewById(R.id.map_download_progress_layout);
final View progressLayout2 = view.findViewById(R.id.map2_download_progress_layout);
if (i == 0 && progressLayout.getVisibility() == View.VISIBLE) {
final TextView mapDescriptionTextView = (TextView) view.findViewById(R.id.map_downloading_desc);
final View progressLayout = view.findViewById(R.id.map_download_progress_layout);
mapDescriptionTextView.setText(indexItem.getSizeDescription(getContext()));
view.findViewById(R.id.map_download_padding).setVisibility(View.VISIBLE);
progressLayout.setVisibility(View.GONE);
} else if (i == 1) {
} else if (i == 1 && progressLayout2.getVisibility() == View.VISIBLE) {
final TextView mapDescriptionTextView = (TextView) view.findViewById(R.id.map2_downloading_desc);
final View progressLayout = view.findViewById(R.id.map2_download_progress_layout);
mapDescriptionTextView.setText(indexItem.getSizeDescription(getContext()));
progressLayout.setVisibility(View.GONE);
view.findViewById(R.id.map2_download_padding).setVisibility(View.VISIBLE);
progressLayout2.setVisibility(View.GONE);
}
}
i++;