Update plugins

This commit is contained in:
Victor Shcherb 2015-03-19 01:34:35 +01:00
parent bef93375e7
commit 2500269cec
16 changed files with 16 additions and 363 deletions

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_notes"
android:background="?attr/card_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/header_layout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight">
<TextView android:id="@+id/notes_text"
android:text="@string/map_widget_av_notes"
style="?attr/dashboardSubHeaderStyle"/>
<Button android:id="@+id/show_all"
android:text="@string/shared_string_show_all"
style="?attr/dashboardGeneralButtonStyle"/>
</LinearLayout>
<LinearLayout android:id="@+id/notes"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -12,10 +12,11 @@
android:layout_height="@dimen/dashHeaderHeight"
android:orientation="horizontal" >
<TextView
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/fav_text"
style="?attr/dashboardSubHeaderStyle"
android:text="@string/shared_string_my_places" />
android:text="@string/shared_string_my_places"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/show_all"

View file

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_bg"
android:orientation="vertical">
<TextView
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:padding="@dimen/dashFavIconMargin"
android:textColor="?android:textColorPrimary"
tools:text="@string/lorem_ipsum"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight"
android:orientation="horizontal">
<Button
android:id="@+id/local_downloads"
style="?attr/dashboardGeneralButtonStyle"
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/dash_download_manage"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<Button
android:id="@+id/download_new_map"
style="?attr/dashboardGeneralButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/dash_download_new_one"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_fav"
android:background="?attr/card_bg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashHeaderHeight">
<TextView android:id="@+id/fav_text"
android:text="@string/shared_string_my_places"
style="?attr/dashboardSubHeaderStyle"/>
<Button android:id="@+id/show_all"
android:text="@string/shared_string_show_all"
style="?attr/dashboardGeneralButtonStyle"/>
</LinearLayout>
<LinearLayout android:id="@+id/items"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>

View file

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/card_bg"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dashHeaderHeight"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/plugin_text"
style="?attr/dashboardSubHeaderStyle"
android:text="@string/prefs_plugins"/>
<net.osmand.plus.widgets.ButtonEx
android:id="@+id/show_all"
style="?attr/dashboardGeneralButtonStyle"
android:text="@string/shared_string_show_all"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/plugins"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>

View file

@ -9,10 +9,6 @@
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="2dp"
android:divider="@null"
android:dividerHeight="4dp"
android:layout_height="match_parent"
tools:listitem="@layout/plugins_list_item"/>
</LinearLayout>

View file

@ -39,10 +39,8 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.notes_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
((TextView) view.findViewById(R.id.fav_text)).setText(R.string.map_widget_av_notes);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -75,7 +73,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
mainView.setVisibility(View.VISIBLE);
}
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.notes);
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.items);
notesLayout.removeAllViews();
if (notes.size() > 3){
while (notes.size() != 3){

View file

@ -1,128 +0,0 @@
package net.osmand.plus.dashboard;
import java.io.File;
import java.text.MessageFormat;
import java.util.Locale;
import net.osmand.IndexConstants;
import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.helpers.FontCache;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
/**
* Created by dummy on 02.12.14.
*/
public class DashDownloadMapsFragment extends DashBaseFragment {
public static final String TAG = "DASH_DOWNLOAD_MAPS_FRAGMENT";
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
MessageFormat formatGb = new MessageFormat("{0, number,#.##} GB", Locale.US);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.dash_download_maps_fragment, container,
false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
final TextView message = ((TextView) view.findViewById(R.id.message));
message.setTypeface(typeface);
Button local = ((Button) view.findViewById(R.id.local_downloads));
local.setTypeface(typeface);
local.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.LOCAL_TAB);
// intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
Button cancelBtn = ((Button) view.findViewById(R.id.download_new_map));
cancelBtn.setTypeface(typeface);
cancelBtn.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.DOWNLOAD_TAB);
// intent.putExtra(DownloadActivity.SINGLE_TAB, true);
getActivity().startActivity(intent);
}
});
return view;
}
@Override
public void onOpenDash() {
refreshData();
}
public void refreshData() {
if (getView() == null) {
return;
}
final TextView message = ((TextView) getView().findViewById(R.id.message));
final Button local = ((Button) getView().findViewById(R.id.local_downloads));
new AsyncTask<Void, Void, Void>() {
int countMaps = 0;
long size = 0;
@Override
protected Void doInBackground(Void... params) {
updateCount(IndexConstants.MAPS_PATH);
updateCount(IndexConstants.SRTM_INDEX_DIR);
return null;
}
protected void updateCount(String s) {
if (!DashDownloadMapsFragment.this.isAdded() || getMyApplication() == null) {
return;
}
File ms = getMyApplication().getAppPath(s);
if (ms.exists()) {
File[] lf = ms.listFiles();
if (lf != null) {
for (File f : ms.listFiles()) {
if (f.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
size += f.length();
countMaps++;
}
}
}
}
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
if (!DashDownloadMapsFragment.this.isAdded() || getMyApplication() == null) {
return;
}
if (countMaps > 0) {
long mb = 1 << 20;
long gb = 1 << 30;
String sz = size > gb ? formatGb.format(new Object[] { (float) size / (gb) }) : formatMb
.format(new Object[] { (float) size / mb });
message.setText(getString(R.string.dash_download_msg, countMaps + "") + " (" + sz + ")");
local.setVisibility(View.VISIBLE);
} else {
message.setText(getString(R.string.dash_download_msg_none));
local.setVisibility(View.GONE);
}
}
}.execute((Void) null);
}
}

View file

@ -41,10 +41,6 @@ public class DashFavoritesFragment extends DashLocationFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.fav_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -1,64 +0,0 @@
package net.osmand.plus.dashboard;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
/**
* Created by Denis on 24.11.2014.
*/
public class DashListFragment extends DashBaseFragment {
public static final String TAG = "DASH_LIST_FRAGMENT";
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_list_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.fav_text)).setTypeface(typeface);
((TextView) view.findViewById(R.id.fav_text)).setText("Here will be text");
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setVisibility(View.GONE);
return view;
}
@Override
public void onOpenDash() {
setupList();
}
public void setupList() {
View mainView = getView();
mainView.findViewById(R.id.main_fav).setVisibility(View.VISIBLE);
LinearLayout lv = (LinearLayout) mainView.findViewById(R.id.items);
lv.removeAllViews();
ArrayAdapter<?> la = dashboard.getListAdapter();
final OnItemClickListener onClick = dashboard.getListAdapterOnClickListener();
for(int i = 0; i < la.getCount(); i++) {
final int position = i;
View v = la.getView(position, null, lv);
if (onClick != null) {
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClick.onItemClick(null, v, position, position);
}
});
}
lv.addView(v);
}
}
}

View file

@ -56,15 +56,17 @@ public class DashPluginsFragment extends DashBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View contentView = inflater.inflate(R.layout.dash_plugins_fragment, container, false);
contentView.findViewById(R.id.show_all).setOnClickListener(new View.OnClickListener() {
View view = inflater.inflate(R.layout.dash_common_fragment, container, false);
TextView header = ((TextView) view.findViewById(R.id.fav_text));
header.setText(R.string.prefs_plugins);
view.findViewById(R.id.show_all).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getActivity(), getMyApplication().getAppCustomization().getPluginsActivity()));
}
});
initPlugins();
return contentView;
return view;
}
@ -95,7 +97,7 @@ public class DashPluginsFragment extends DashBaseFragment {
View contentView = getView();
LayoutInflater inflater = getActivity().getLayoutInflater();
initPlugins();
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.plugins);
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.items);
pluginsContainer.removeAllViews();
for (OsmandPlugin p : plugins) {
inflatePluginView(inflater, pluginsContainer, p);

View file

@ -41,11 +41,6 @@ public class DashRecentsFragment extends DashLocationFragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.fav_text)).setTypeface(typeface);
((TextView) view.findViewById(R.id.fav_text)).setText(Algorithms
.capitalizeFirstLetterAndLowercase(getString(R.string.shared_string_history)));
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -42,11 +42,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
((TextView) view.findViewById(R.id.fav_text)).setTypeface(typeface);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
((TextView) view.findViewById(R.id.fav_text)).setText(getString(R.string.waypoints));
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -37,9 +37,7 @@ public class DashSimulateFragment extends DashBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
TextView header = (TextView) view.findViewById(R.id.fav_text);
header.setTypeface(typeface);
header.setText(R.string.simulate_your_location);
((Button) view.findViewById(R.id.show_all)).setVisibility(View.GONE);
LinearLayout tracks = (LinearLayout) view.findViewById(R.id.items);

View file

@ -47,13 +47,9 @@ public class DashTrackFragment extends DashBaseFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
TextView header = (TextView) view.findViewById(R.id.fav_text);
header.setTypeface(typeface);
header.setText(R.string.shared_string_my_tracks);
((Button) view.findViewById(R.id.show_all)).setTypeface(typeface);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -38,13 +38,10 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
plugin = OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_audio_video_notes_plugin, container, false);
Typeface typeface = FontCache.getRobotoMedium(getActivity());
TextView header = ((TextView) view.findViewById(R.id.notes_text));
header.setTypeface(typeface);
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_common_fragment, container, false);
TextView header = ((TextView) view.findViewById(R.id.fav_text));
header.setText(R.string.osm_settings);
Button manage = ((Button) view.findViewById(R.id.show_all));
manage.setTypeface(typeface);
manage.setText(R.string.osm_editing_manage);
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
@ -81,7 +78,7 @@ public class DashOsmEditsFragment extends DashBaseFragment implements OsmEditsUp
mainView.setVisibility(View.VISIBLE);
}
LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.notes);
LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.items);
osmLayout.removeAllViews();
for (final OsmPoint point : dataPoints){