Downloads progress implementation in progress.
This commit is contained in:
parent
118248df63
commit
6d75254f7c
12 changed files with 181 additions and 36 deletions
|
@ -1,6 +1,10 @@
|
||||||
package net.osmand.util;
|
package net.osmand.util;
|
||||||
|
|
||||||
|
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
|
@ -11,7 +15,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -20,10 +23,6 @@ import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic algorithms that are not in jdk
|
* Basic algorithms that are not in jdk
|
||||||
|
@ -505,6 +504,21 @@ public class Algorithms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatMinutesDuration(int minutes) {
|
||||||
|
if (minutes < 60) {
|
||||||
|
return String.valueOf(minutes);
|
||||||
|
} else {
|
||||||
|
String min;
|
||||||
|
if (minutes % 60 < 10) {
|
||||||
|
min = "0" + (minutes % 60);
|
||||||
|
} else {
|
||||||
|
min = (minutes % 60) + "";
|
||||||
|
}
|
||||||
|
int hours = minutes / 60;
|
||||||
|
return hours + ":" + min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static <T extends Enum<T> > T parseEnumValue(T[] cl, String val, T defaultValue){
|
public static <T extends Enum<T> > T parseEnumValue(T[] cl, String val, T defaultValue){
|
||||||
for(int i = 0; i< cl.length; i++) {
|
for(int i = 0; i< cl.length; i++) {
|
||||||
if(cl[i].name().equalsIgnoreCase(val)) {
|
if(cl[i].name().equalsIgnoreCase(val)) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
<include layout="@layout/free_version_banner"/>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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:background="@color/ctx_menu_info_view_bg_dark"
|
android:background="@color/ctx_menu_info_view_bg_dark"
|
||||||
|
@ -9,11 +8,13 @@
|
||||||
<include layout="@layout/free_version_banner"/>
|
<include layout="@layout/free_version_banner"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:background="?attr/bg_card"
|
android:background="?attr/bg_card"
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="10dp">
|
android:padding="10dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -23,14 +24,15 @@
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/leftTextView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/device_memory"/>
|
tools:text="@string/device_memory"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/memory_size"
|
android:id="@+id/rightTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
@ -38,7 +40,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/memory_progress"
|
android:id="@+id/progressBar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
|
|
|
@ -15,6 +15,53 @@
|
||||||
app:contentInsetLeft="72dp"
|
app:contentInsetLeft="72dp"
|
||||||
app:contentInsetStart="72dp"/>
|
app:contentInsetStart="72dp"/>
|
||||||
|
|
||||||
|
<include layout="@layout/free_version_banner"/>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/downloadProgressLayout"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="4dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
tools:visibility="visible"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/leftTextView"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
tools:text="@string/device_memory"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/rightTextView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
tools:text="@string/free"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:progressDrawable="?attr/size_progress_bar"/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/fragmentContainer"
|
android:id="@+id/fragmentContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -1996,4 +1996,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
||||||
<string name="unsaved_changes_will_be_lost">Any unsaved changes will be lost. Continue?</string>
|
<string name="unsaved_changes_will_be_lost">Any unsaved changes will be lost. Continue?</string>
|
||||||
<string name="downloads_left_template">%1$s downloads left</string>
|
<string name="downloads_left_template">%1$s downloads left</string>
|
||||||
<string name="roads">Roads</string>
|
<string name="roads">Roads</string>
|
||||||
|
<string name="downloading_number_of_fiels">Downloding - %1$d file</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -78,6 +78,8 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
private List<DownloadActivityType> downloadTypes = new ArrayList<DownloadActivityType>();
|
private List<DownloadActivityType> downloadTypes = new ArrayList<DownloadActivityType>();
|
||||||
private List<IndexItemCategoryWithSubcat> cats;
|
private List<IndexItemCategoryWithSubcat> cats;
|
||||||
|
|
||||||
|
private OnProgressUpdateListener onProgressUpdateListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
getMyApplication().applyTheme(this);
|
getMyApplication().applyTheme(this);
|
||||||
|
@ -255,6 +257,17 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
@Override
|
@Override
|
||||||
public void updateProgress(boolean updateOnlyProgress) {
|
public void updateProgress(boolean updateOnlyProgress) {
|
||||||
BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
|
BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
|
||||||
|
final boolean isFinished = basicProgressAsyncTask == null
|
||||||
|
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
|
||||||
|
if (onProgressUpdateListener != null) {
|
||||||
|
if (isFinished) {
|
||||||
|
onProgressUpdateListener.onFinished();
|
||||||
|
} else {
|
||||||
|
onProgressUpdateListener.onProgressUpdate(
|
||||||
|
basicProgressAsyncTask.getProgressPercentage(),
|
||||||
|
downloadListIndexThread.getDownloads());
|
||||||
|
}
|
||||||
|
}
|
||||||
//needed when rotation is performed and progress can be null
|
//needed when rotation is performed and progress can be null
|
||||||
if (progressView == null) {
|
if (progressView == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -265,9 +278,8 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage());
|
determinateProgressBar.setProgress(basicProgressAsyncTask.getProgressPercentage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean visible = basicProgressAsyncTask != null && basicProgressAsyncTask.getStatus() != AsyncTask.Status.FINISHED;
|
progressView.setVisibility(!isFinished ? View.VISIBLE : View.GONE);
|
||||||
progressView.setVisibility(visible ? View.VISIBLE : View.GONE);
|
if (!isFinished) {
|
||||||
if (visible) {
|
|
||||||
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
|
boolean indeterminate = basicProgressAsyncTask.isIndeterminate();
|
||||||
indeterminateProgressBar.setVisibility(!indeterminate ? View.GONE : View.VISIBLE);
|
indeterminateProgressBar.setVisibility(!indeterminate ? View.GONE : View.VISIBLE);
|
||||||
determinateProgressBar.setVisibility(indeterminate ? View.GONE : View.VISIBLE);
|
determinateProgressBar.setVisibility(indeterminate ? View.GONE : View.VISIBLE);
|
||||||
|
@ -613,5 +625,18 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnProgressUpdateListener(OnProgressUpdateListener onProgressUpdateListener) {
|
||||||
|
this.onProgressUpdateListener = onProgressUpdateListener;
|
||||||
|
BasicProgressAsyncTask<?, ?, ?> basicProgressAsyncTask = DownloadActivity.downloadListIndexThread.getCurrentRunningTask();
|
||||||
|
final boolean isFinished = basicProgressAsyncTask == null
|
||||||
|
|| basicProgressAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
|
||||||
|
if (isFinished) {
|
||||||
|
this.onProgressUpdateListener.onFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnProgressUpdateListener {
|
||||||
|
void onProgressUpdate(int progressPercentage, int activeTasks);
|
||||||
|
void onFinished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,8 +214,6 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
final IndexItem e = listAdapter.getChild(groupPosition, childPosition);
|
final IndexItem e = listAdapter.getChild(groupPosition, childPosition);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.WorldRegion;
|
import net.osmand.plus.WorldRegion;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
|
import net.osmand.plus.download.newimplementation.DownloadsUiInitHelper;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ public class DownloadItemsFragment extends Fragment {
|
||||||
fillVoicePromtsAdapter();
|
fillVoicePromtsAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadsUiInitHelper.initFreeVersionBanner(view,
|
||||||
|
getMyApplication().getSettings(), getResources());
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.download.newimplementation;
|
package net.osmand.plus.download.newimplementation;
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
@ -7,12 +8,14 @@ import android.support.v7.widget.Toolbar;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.helpers.HasName;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -20,6 +23,7 @@ public class MapsInCategoryFragment extends DialogFragment {
|
||||||
private static final Log LOG = PlatformUtil.getLog(IndexItemCategoryWithSubcat.class);
|
private static final Log LOG = PlatformUtil.getLog(IndexItemCategoryWithSubcat.class);
|
||||||
public static final String TAG = "MapsInCategoryFragment";
|
public static final String TAG = "MapsInCategoryFragment";
|
||||||
private static final String CATEGORY = "category";
|
private static final String CATEGORY = "category";
|
||||||
|
private MapDownloadListener mProgressListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -33,7 +37,7 @@ public class MapsInCategoryFragment extends DialogFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
|
final View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
|
||||||
|
|
||||||
IndexItemCategoryWithSubcat category = getArguments().getParcelable(CATEGORY);
|
IndexItemCategoryWithSubcat category = getArguments().getParcelable(CATEGORY);
|
||||||
assert category != null;
|
assert category != null;
|
||||||
|
@ -51,9 +55,41 @@ public class MapsInCategoryFragment extends DialogFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DownloadsUiInitHelper.initFreeVersionBanner(view,
|
||||||
|
getMyActivity().getMyApplication().getSettings(), getResources());
|
||||||
|
mProgressListener = new MapDownloadListener(view, getResources()){
|
||||||
|
@Override
|
||||||
|
public void onFinished() {
|
||||||
|
super.onFinished();
|
||||||
|
DownloadsUiInitHelper.initFreeVersionBanner(view,
|
||||||
|
getMyActivity().getMyApplication().getSettings(), getResources());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
view.findViewById(R.id.downloadProgressLayout).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
getMyActivity().setOnProgressUpdateListener(mProgressListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
getMyActivity().setOnProgressUpdateListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DownloadActivity getMyActivity() {
|
||||||
|
return (DownloadActivity) getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
public void onCategorySelected(@NonNull IndexItemCategoryWithSubcat category) {
|
public void onCategorySelected(@NonNull IndexItemCategoryWithSubcat category) {
|
||||||
LOG.debug("onCategorySelected()");
|
LOG.debug("onCategorySelected()");
|
||||||
createInstance(category).show(getChildFragmentManager(), TAG);
|
createInstance(category).show(getChildFragmentManager(), TAG);
|
||||||
|
@ -68,16 +104,39 @@ public class MapsInCategoryFragment extends DialogFragment {
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Divider implements HasName {
|
private static class MapDownloadListener implements DownloadActivity.OnProgressUpdateListener {
|
||||||
private final String text;
|
private final View freeVersionBanner;
|
||||||
|
private final View downloadProgressLayout;
|
||||||
|
private final ProgressBar progressBar;
|
||||||
|
private final TextView leftTextView;
|
||||||
|
private final TextView rightTextView;
|
||||||
|
private final Resources resources;
|
||||||
|
|
||||||
public Divider(String text) {
|
MapDownloadListener(View view, Resources resources) {
|
||||||
this.text = text;
|
this.resources = resources;
|
||||||
|
freeVersionBanner = view.findViewById(R.id.freeVersionBanner);
|
||||||
|
downloadProgressLayout = view.findViewById(R.id.downloadProgressLayout);
|
||||||
|
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||||
|
leftTextView = (TextView) view.findViewById(R.id.leftTextView);
|
||||||
|
rightTextView = (TextView) view.findViewById(R.id.rightTextView);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onProgressUpdate(int progressPercentage, int activeTasks) {
|
||||||
|
if (freeVersionBanner.getVisibility() == View.VISIBLE) {
|
||||||
|
freeVersionBanner.setVisibility(View.GONE);
|
||||||
|
downloadProgressLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
progressBar.setProgress(progressPercentage);
|
||||||
|
final String format = resources.getString(R.string.downloading_number_of_fiels);
|
||||||
|
String numberOfTasks = String.format(format, activeTasks);
|
||||||
|
leftTextView.setText(numberOfTasks);
|
||||||
|
rightTextView.setText(progressPercentage + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public void onFinished() {
|
||||||
return text;
|
freeVersionBanner.setVisibility(View.VISIBLE);
|
||||||
|
downloadProgressLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class NewLocalIndexesFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMemoryConsumedCard(View header) {
|
private void initMemoryConsumedCard(View header) {
|
||||||
ProgressBar sizeProgress = (ProgressBar) header.findViewById(R.id.memory_progress);
|
ProgressBar sizeProgress = (ProgressBar) header.findViewById(R.id.progressBar);
|
||||||
File dir = getMyApplication().getAppPath("").getParentFile();
|
File dir = getMyApplication().getAppPath("").getParentFile();
|
||||||
String size = formatGb.format(new Object[]{0});
|
String size = formatGb.format(new Object[]{0});
|
||||||
int percent = 0;
|
int percent = 0;
|
||||||
|
@ -92,9 +92,11 @@ public class NewLocalIndexesFragment extends OsmAndListFragment {
|
||||||
sizeProgress.setProgress(percent);
|
sizeProgress.setProgress(percent);
|
||||||
String text = getString(R.string.free, size);
|
String text = getString(R.string.free, size);
|
||||||
|
|
||||||
TextView descriptionText = (TextView) header.findViewById(R.id.memory_size);
|
TextView descriptionText = (TextView) header.findViewById(R.id.rightTextView);
|
||||||
descriptionText.setText(Html.fromHtml(text));
|
descriptionText.setText(Html.fromHtml(text));
|
||||||
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
|
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
|
((TextView) header.findViewById(R.id.leftTextView)).setText(R.string.device_memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,7 +18,6 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.download.BaseDownloadActivity;
|
import net.osmand.plus.download.BaseDownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
|
@ -43,14 +42,10 @@ public class SubcategoriesFragment extends Fragment {
|
||||||
mAdapter.addAll(category.items);
|
mAdapter.addAll(category.items);
|
||||||
mAdapter.addAll(category.subcats);
|
mAdapter.addAll(category.subcats);
|
||||||
|
|
||||||
View freeVersionBanner = inflater.inflate(R.layout.free_version_banner, listView, false);
|
|
||||||
final OsmandSettings settings = application.getSettings();
|
|
||||||
DownloadsUiInitHelper.initFreeVersionBanner(freeVersionBanner, settings, getResources());
|
|
||||||
listView.addHeaderView(freeVersionBanner);
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
final HasName item = mAdapter.getItem(position - 1);
|
final HasName item = mAdapter.getItem(position);
|
||||||
if (item instanceof IndexItemCategoryWithSubcat) {
|
if (item instanceof IndexItemCategoryWithSubcat) {
|
||||||
((MapsInCategoryFragment) getParentFragment())
|
((MapsInCategoryFragment) getParentFragment())
|
||||||
.onCategorySelected((IndexItemCategoryWithSubcat) item);
|
.onCategorySelected((IndexItemCategoryWithSubcat) item);
|
||||||
|
@ -139,9 +134,6 @@ public class SubcategoriesFragment extends Fragment {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
((BaseDownloadActivity) v.getContext())
|
((BaseDownloadActivity) v.getContext())
|
||||||
.startDownload((IndexItem) v.getTag(R.id.index_item));
|
.startDownload((IndexItem) v.getTag(R.id.index_item));
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
|
||||||
rightImageButton.setImageDrawable(getContextIcon(context,
|
|
||||||
R.drawable.ic_action_remove_dark));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
|
@ -255,10 +255,10 @@ public class BasicDataFragment extends Fragment
|
||||||
daysTextView.setText(stringBuilder.toString());
|
daysTextView.setText(stringBuilder.toString());
|
||||||
|
|
||||||
TextView openingTextView = (TextView) view.findViewById(R.id.openingTextView);
|
TextView openingTextView = (TextView) view.findViewById(R.id.openingTextView);
|
||||||
openingTextView.setText(Algorithms.formatDuration(rule.getStartTime()));
|
openingTextView.setText(Algorithms.formatMinutesDuration(rule.getStartTime()));
|
||||||
|
|
||||||
TextView closingTextView = (TextView) view.findViewById(R.id.closingTextView);
|
TextView closingTextView = (TextView) view.findViewById(R.id.closingTextView);
|
||||||
closingTextView.setText(Algorithms.formatDuration(rule.getEndTime()));
|
closingTextView.setText(Algorithms.formatMinutesDuration(rule.getEndTime()));
|
||||||
timeContainer.setVisibility(View.VISIBLE);
|
timeContainer.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
daysTextView.setOnClickListener(new View.OnClickListener() {
|
daysTextView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue