Added view for map updates
This commit is contained in:
parent
0a4a26be91
commit
742eb0a64a
7 changed files with 83 additions and 35 deletions
|
@ -10,12 +10,18 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="40dp">
|
||||||
<TextView android:text="@string/map_update"
|
<TextView android:text="@string/map_update"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="fill_parent"
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/dashboard_black"/>
|
||||||
<TextView android:id="@+id/update_count"
|
<TextView android:id="@+id/update_count"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
android:textColor="@color/dashboard_blue"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
<View android:layout_width="0dp"
|
<View android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|
|
@ -6,13 +6,18 @@
|
||||||
android:layout_marginLeft="12dp"
|
android:layout_marginLeft="12dp"
|
||||||
android:layout_marginRight="12dp"
|
android:layout_marginRight="12dp"
|
||||||
android:layout_height="50dp">
|
android:layout_height="50dp">
|
||||||
|
<View android:layout_width="match_parent"
|
||||||
|
android:background="@color/dashboard_divider"
|
||||||
|
android:layout_height="1dp"/>
|
||||||
<LinearLayout android:orientation="horizontal"
|
<LinearLayout android:orientation="horizontal"
|
||||||
|
android:layout_marginLeft="12dp"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<LinearLayout android:orientation="vertical"
|
<LinearLayout android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="50dp">
|
android:layout_height="50dp">
|
||||||
<TextView android:id="@+id/map_name"
|
<TextView android:id="@+id/map_name"
|
||||||
|
android:textColor="@color/dashboard_black"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
<TextView android:id="@+id/map_descr"
|
<TextView android:id="@+id/map_descr"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,6 +10,7 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
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.DownloadEntry;
|
import net.osmand.plus.download.DownloadEntry;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
|
||||||
|
@ -22,6 +24,14 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_updates_fragment, container, false);
|
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_updates_fragment, container, false);
|
||||||
|
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
final Intent intent = new Intent(view.getContext(), getMyApplication().getAppCustomization().getDownloadIndexActivity());
|
||||||
|
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.UPDATES_TAB);
|
||||||
|
getActivity().startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +40,17 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (BaseDownloadActivity.downloadListIndexThread != null){
|
||||||
|
updatedDownloadsList(BaseDownloadActivity.downloadListIndexThread.getItemsToUpdate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updatedDownloadsList(List<IndexItem> list) {
|
public void updatedDownloadsList(List<IndexItem> list) {
|
||||||
View mainView = getView();
|
View mainView = getView();
|
||||||
|
//it may be null because download index thread is async
|
||||||
if (mainView == null) {
|
if (mainView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +60,9 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
||||||
mainView.setVisibility(View.GONE);
|
mainView.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((TextView)mainView.findViewById(R.id.update_count)).setText(String.valueOf(list.size()));
|
||||||
|
|
||||||
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
|
LinearLayout updates = (LinearLayout) mainView.findViewById(R.id.updates_items);
|
||||||
updates.removeAllViews();
|
updates.removeAllViews();
|
||||||
|
|
||||||
|
@ -51,9 +73,9 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
View view = inflater.inflate(R.layout.dash_updates_item, null, false);
|
View view = inflater.inflate(R.layout.dash_updates_item, null, false);
|
||||||
String eName = item.getVisibleDescription(getMyApplication()) + "\n"
|
String name = item.getVisibleName(getMyApplication(), getMyApplication().getResourceManager().getOsmandRegions());
|
||||||
+ item.getVisibleName(getMyApplication(), getMyApplication().getResourceManager().getOsmandRegions());
|
String d = item.getDate(getMyApplication().getResourceManager().getDateFormat()) + ", " + item.getSizeDescription(getMyApplication());
|
||||||
String d = item.getDate(getMyApplication().getResourceManager().getDateFormat()) + "\n" + item.getSizeDescription(getMyApplication());
|
String eName = name.replace("\n", " ");
|
||||||
((TextView) view.findViewById(R.id.map_name)).setText(eName);
|
((TextView) view.findViewById(R.id.map_name)).setText(eName);
|
||||||
((TextView) view.findViewById(R.id.map_descr)).setText(d);
|
((TextView) view.findViewById(R.id.map_descr)).setText(d);
|
||||||
(view.findViewById(R.id.btn_download)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.btn_download)).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -63,6 +85,7 @@ public class DashUpdatesFragment extends DashBaseFragment {
|
||||||
getDownloadActivity().getEntriesToDownload().put(item, download);
|
getDownloadActivity().getEntriesToDownload().put(item, download);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
updates.addView(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.graphics.Color;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -22,11 +23,10 @@ import net.osmand.plus.activities.MainMenuActivity;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.TipsAndTricksActivity;
|
import net.osmand.plus.activities.TipsAndTricksActivity;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
import net.osmand.plus.download.BaseDownloadActivity;
|
import net.osmand.plus.download.*;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
|
||||||
import net.osmand.plus.download.DownloadIndexesThread;
|
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,8 +35,6 @@ import java.util.*;
|
||||||
public class DashboardActivity extends BaseDownloadActivity {
|
public class DashboardActivity extends BaseDownloadActivity {
|
||||||
public static final boolean TIPS_AND_TRICKS = false;
|
public static final boolean TIPS_AND_TRICKS = false;
|
||||||
|
|
||||||
public static DownloadIndexesThread downloadListIndexThread;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -46,16 +44,6 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
getSupportActionBar().setBackgroundDrawable(color);
|
getSupportActionBar().setBackgroundDrawable(color);
|
||||||
getSupportActionBar().setIcon(android.R.color.transparent);
|
getSupportActionBar().setIcon(android.R.color.transparent);
|
||||||
|
|
||||||
if(downloadListIndexThread == null) {
|
|
||||||
downloadListIndexThread = new DownloadIndexesThread(this);
|
|
||||||
}
|
|
||||||
if (downloadListIndexThread.getCachedIndexFiles() != null && downloadListIndexThread.isDownloadedFromInternet()) {
|
|
||||||
downloadListIndexThread.runCategorization(DownloadActivityType.NORMAL_FILE);
|
|
||||||
} else {
|
|
||||||
downloadListIndexThread.runReloadIndexFiles();
|
|
||||||
}
|
|
||||||
downloadListIndexThread.setUiActivity(this);
|
|
||||||
|
|
||||||
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
|
android.support.v4.app.FragmentManager manager = getSupportFragmentManager();
|
||||||
android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
android.support.v4.app.FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||||
|
|
||||||
|
@ -107,6 +95,18 @@ public class DashboardActivity extends BaseDownloadActivity {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDownloadList(List<IndexItem> list){
|
||||||
|
for(WeakReference<Fragment> ref : fragList) {
|
||||||
|
Fragment f = ref.get();
|
||||||
|
if(f instanceof DashUpdatesFragment) {
|
||||||
|
if(!f.isDetached()) {
|
||||||
|
((DashUpdatesFragment) f).updatedDownloadsList(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2,13 +2,17 @@ package net.osmand.plus.download;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
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.Version;
|
import net.osmand.plus.Version;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -20,9 +24,24 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
|
||||||
protected DownloadActivityType type = DownloadActivityType.NORMAL_FILE;
|
protected DownloadActivityType type = DownloadActivityType.NORMAL_FILE;
|
||||||
protected OsmandSettings settings;
|
protected OsmandSettings settings;
|
||||||
public static DownloadIndexesThread downloadListIndexThread;
|
public static DownloadIndexesThread downloadListIndexThread;
|
||||||
|
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||||
|
|
||||||
public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 10;
|
public static final int MAXIMUM_AVAILABLE_FREE_DOWNLOADS = 10;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
if(downloadListIndexThread == null) {
|
||||||
|
downloadListIndexThread = new DownloadIndexesThread(this);
|
||||||
|
}
|
||||||
|
if (downloadListIndexThread.getCachedIndexFiles() != null && downloadListIndexThread.isDownloadedFromInternet()) {
|
||||||
|
downloadListIndexThread.runCategorization(type);
|
||||||
|
} else {
|
||||||
|
downloadListIndexThread.runReloadIndexFiles();
|
||||||
|
}
|
||||||
|
downloadListIndexThread.setUiActivity(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateDownloadList(List<IndexItem> list){
|
public void updateDownloadList(List<IndexItem> list){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,5 +148,11 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
|
||||||
downloadFilesPreCheckSpace();
|
downloadFilesPreCheckSpace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachFragment(Fragment fragment) {
|
||||||
|
fragList.add(new WeakReference<Fragment>(fragment));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
private TextView progressPercent;
|
private TextView progressPercent;
|
||||||
private ImageView cancel;
|
private ImageView cancel;
|
||||||
private List<LocalIndexInfo> localIndexInfos = new ArrayList<LocalIndexInfo>();
|
private List<LocalIndexInfo> localIndexInfos = new ArrayList<LocalIndexInfo>();
|
||||||
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
|
||||||
|
|
||||||
private String initialFilter = "";
|
private String initialFilter = "";
|
||||||
|
|
||||||
|
@ -56,6 +55,7 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
|
|
||||||
public static final String TAB_TO_OPEN = "Tab_to_open";
|
public static final String TAB_TO_OPEN = "Tab_to_open";
|
||||||
public static final String DOWNLOAD_TAB = "download";
|
public static final String DOWNLOAD_TAB = "download";
|
||||||
|
public static final String UPDATES_TAB = "updates";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,15 +66,6 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
setProgressBarIndeterminateVisibility(false);
|
setProgressBarIndeterminateVisibility(false);
|
||||||
|
|
||||||
setContentView(R.layout.tab_content);
|
setContentView(R.layout.tab_content);
|
||||||
if(downloadListIndexThread == null) {
|
|
||||||
downloadListIndexThread = new DownloadIndexesThread(this);
|
|
||||||
}
|
|
||||||
if (downloadListIndexThread.getCachedIndexFiles() != null && downloadListIndexThread.isDownloadedFromInternet()) {
|
|
||||||
downloadListIndexThread.runCategorization(type);
|
|
||||||
} else {
|
|
||||||
downloadListIndexThread.runReloadIndexFiles();
|
|
||||||
}
|
|
||||||
downloadListIndexThread.setUiActivity(this);
|
|
||||||
|
|
||||||
settings = ((OsmandApplication) getApplication()).getSettings();
|
settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
tabHost = (TabHost) findViewById(android.R.id.tabhost);
|
tabHost = (TabHost) findViewById(android.R.id.tabhost);
|
||||||
|
@ -145,6 +136,8 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
if (tab.equals(DOWNLOAD_TAB)){
|
if (tab.equals(DOWNLOAD_TAB)){
|
||||||
tabHost.setCurrentTab(1);
|
tabHost.setCurrentTab(1);
|
||||||
|
} else if (tab.equals(UPDATES_TAB)){
|
||||||
|
tabHost.setCurrentTab(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,10 +432,6 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
return ((OsmandApplication) getApplication()).getSettings().isLightActionBar();
|
return ((OsmandApplication) getApplication()).getSettings().isLightActionBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttachFragment(Fragment fragment) {
|
|
||||||
fragList.add(new WeakReference<Fragment>(fragment));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copyFilesForAndroid19(final String newLoc) {
|
private void copyFilesForAndroid19(final String newLoc) {
|
||||||
SettingsGeneralActivity.MoveFilesToDifferentDirectory task =
|
SettingsGeneralActivity.MoveFilesToDifferentDirectory task =
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class UpdatesIndexFragment extends SherlockListFragment {
|
||||||
updateColor = getResources().getColor(R.color.color_update);
|
updateColor = getResources().getColor(R.color.color_update);
|
||||||
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
|
||||||
List<IndexItem> indexItems = new ArrayList<IndexItem>();
|
List<IndexItem> indexItems = new ArrayList<IndexItem>();
|
||||||
if (DownloadActivity.downloadListIndexThread != null) {
|
if (BaseDownloadActivity.downloadListIndexThread != null) {
|
||||||
indexItems = DownloadActivity.downloadListIndexThread.getItemsToUpdate();
|
indexItems = DownloadActivity.downloadListIndexThread.getItemsToUpdate();
|
||||||
}
|
}
|
||||||
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
|
listAdapter = new UpdateIndexAdapter(getDownloadActivity(), R.layout.download_index_list_item, indexItems);
|
||||||
|
|
Loading…
Reference in a new issue