Refactor sherpafy
8
OsmAnd/assets/style.css
Normal file
|
@ -0,0 +1,8 @@
|
|||
h3 { text-align: center}
|
||||
h4 { text-align: center}
|
||||
div {border-width: 1px; padding: 10px;
|
||||
border: groove; margin-left:auto;margin-right:auto; }
|
||||
li { text-align:justify;"}
|
||||
img { max-width: 75%; width: auto; height: auto; }
|
||||
p.img {text-align: center}
|
||||
|
|
@ -40,6 +40,11 @@
|
|||
<include name="images/**/*.png"/>
|
||||
</fileset>
|
||||
</sync>
|
||||
<copy todir="assets/help">
|
||||
<fileset dir="assets/" >
|
||||
<include name="style.css"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${src.absolute.dir}/net/osmand/render/">
|
||||
<fileset dir="../../resources/rendering_styles/" >
|
||||
<include name="*.xml"/>
|
||||
|
@ -58,7 +63,8 @@
|
|||
</target>
|
||||
|
||||
|
||||
|
||||
<target name="generate-resources" depends="">
|
||||
</target>
|
||||
|
||||
<!-- Extra target -->
|
||||
<target name="-pre-build" depends="copy_resources,fix_apostrophe_issues">
|
||||
|
@ -135,6 +141,14 @@
|
|||
</if>
|
||||
|
||||
</target>
|
||||
<target name="copy_sherpafy">
|
||||
<copy todir="gen/net/osmand/plus">
|
||||
<fileset dir="gen/net/osmand/sherpafy">
|
||||
<include name="R.java" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<replaceregexp file="gen/net/osmand/plus/R.java" match='package (.*);' replace='package net.osmand.plus;' byline="true" />
|
||||
</target>
|
||||
|
||||
<!-- Compiles this project's .java files into .class files. -->
|
||||
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
|
||||
|
|
BIN
OsmAnd/libs/android-support-v4.jar
Normal file
|
@ -12,3 +12,4 @@ split.density=false
|
|||
# Project target.
|
||||
target=android-19
|
||||
android.library.reference.1=../SherlockBar
|
||||
dex.force.jumbo=true
|
||||
|
|
BIN
OsmAnd/res/drawable-hdpi/drawer_shadow.9.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
OsmAnd/res/drawable-hdpi/ic_drawer_am.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_navigation_drawer_dark.png
Normal file
After Width: | Height: | Size: 137 B |
BIN
OsmAnd/res/drawable-hdpi/ic_navigation_drawer_light.png
Normal file
After Width: | Height: | Size: 133 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.8 KiB |
BIN
OsmAnd/res/drawable-mdpi/drawer_shadow.9.png
Normal file
After Width: | Height: | Size: 158 B |
BIN
OsmAnd/res/drawable-mdpi/ic_drawer_am.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_navigation_drawer_dark.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
OsmAnd/res/drawable-mdpi/ic_navigation_drawer_light.png
Normal file
After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.4 KiB |
BIN
OsmAnd/res/drawable-xhdpi/drawer_shadow.9.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
OsmAnd/res/drawable-xhdpi/ic_drawer_am.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_navigation_drawer_dark.png
Normal file
After Width: | Height: | Size: 140 B |
BIN
OsmAnd/res/drawable-xhdpi/ic_navigation_drawer_light.png
Normal file
After Width: | Height: | Size: 140 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 5.3 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_navigation_drawer_dark.png
Normal file
After Width: | Height: | Size: 206 B |
BIN
OsmAnd/res/drawable-xxhdpi/ic_navigation_drawer_light.png
Normal file
After Width: | Height: | Size: 208 B |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 12 KiB |
20
OsmAnd/res/layout/sherpafy_browse_tour.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<android.support.v4.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!-- The main content view -->
|
||||
<FrameLayout
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<!-- The navigation drawer -->
|
||||
<ListView android:id="@+id/left_drawer"
|
||||
android:layout_width="240dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="0dp"
|
||||
android:background="#111"/>
|
||||
</android.support.v4.widget.DrawerLayout>
|
39
OsmAnd/res/layout/sherpafy_list_tour_item.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" android:background="@color/color_white"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp">
|
||||
|
||||
<FrameLayout >
|
||||
<ImageView
|
||||
android:id="@+id/TourImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<TextView
|
||||
android:id="@+id/TourName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:background="@color/shadow_color"
|
||||
android:ellipsize="end"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/color_white"
|
||||
/>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/TourDescription"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="3"
|
||||
android:ellipsize="end"
|
||||
android:textSize="20sp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="auto_zoom_none">Без аўтаматычнага масштабіраваньня</string>
|
||||
<string name="auto_zoom_close">Зачыніць</string>
|
||||
<string name="auto_zoom_far">Для сярэдняга масштаба</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="show_warnings_title">Mostra els missatges d\'avís…</string>
|
||||
<string name="map_widget_fluorescent">Rutes amb fluorescència</string>
|
||||
<string name="map_widget_show_ruler">Mostra el regle</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="srtm_paid_version_msg">Overvej at købe Højdekurve udvidelsen (\'Contour lines\') på Google Play for at støtte den videre udvikling.</string>
|
||||
<string name="av_def_action_video">Optag video</string>
|
||||
<string name="av_def_action_audio">Optag audio</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="btn_add_tag">Προσθήκη Ετικέτας</string>
|
||||
<string name="btn_advanced_mode">Λειτουργία για προχωρημένους…</string>
|
||||
<string name="poi_filter_parking">Στάθμευση</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="layer_map_appearance">Configura pantalla</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="local_osm_changes_backup_failed">پشتیبانگیری از تغییرات OsmAnd ناموفق بود</string>
|
||||
<string name="plugin_distance_point_time">زمان</string>
|
||||
<string name="plugin_distance_point_hdop">دقت</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="offline_edition">Modifications hors-ligne</string>
|
||||
<string name="offline_edition_descr">Toujours utiliser l\'édition hors-ligne</string>
|
||||
<string name="tip_recent_changes_0_7_1_t">"Changements en 0.7.1 :
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="tip_recent_changes_0_7_2_t">"A 0.7.2 kiadás változásai:
|
||||
\n\t- Natív renderelő minden eszközre
|
||||
\n\t- Offline POI szerkesztés
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="use_fluorescent_overlays">Sovrapposizioni fluorescenti</string>
|
||||
<string name="use_fluorescent_overlays_descr">Usa colori fluorescenti per visualizzare tracce e percorsi</string>
|
||||
<string name="offline_edition">Modifiche offline</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="vector_maps_may_display_faster_on_some_devices">벡터 맵이 더욱 빠르게 표시됩니다. 하지만, 어떤 기기에서는 잘 작동하지 않을 수 있습니다.</string>
|
||||
|
||||
<string name="play_commands_of_currently_selected_voice">현재 선택된 음성 명령을 재생합니다</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="starting_point_too_far">Pradžios taškas yra per toli nuo artimiausio kelio.</string>
|
||||
<string name="shared_location">Bendrinta vieta</string>
|
||||
<string name="osmand_parking_warning">Dėmesio</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="layer_map_appearance">Configureer scherm</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="srtm_plugin_description">Этот плагин позволяет загружать линии высот (Загрузка данных -> Меню -> "Другие карты") для использования оффлайн.</string>
|
||||
<string name="srtm_paid_version_msg">Рассмотрите пожалуйста покупку плагина \"Линии высот\" на Market, чтобы поддержать последующую разработку.</string>
|
||||
<string name="srtm_paid_version_title">Линии высот</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="recording_context_menu_show">Zobraziť</string>
|
||||
<string name="recording_photo_description">Fotografia %1$s zachytená dňa %2$s</string>
|
||||
<string name="av_def_action_picture">Zachytiť fotografiu</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="search_button">Iskanje</string>
|
||||
<string name="search_activity">Iskanje</string>
|
||||
<string name="settings_Button">Nastavitve</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources><string name="rendering_attr_roadColors_description">選擇道路的色彩調配:</string>
|
||||
<string name="rendering_attr_roadColors_name">道路的色彩調配</string>
|
||||
<string name="map_widget_show_destination_arrow">顯示目的地方向</string>
|
||||
|
|
|
@ -64,4 +64,5 @@
|
|||
<color name="osmbug_not_submitted">#C8FFFF00</color> <!-- standard YELLOW -->
|
||||
|
||||
<color name="distance_color">#dd6CB336</color>
|
||||
<color name="shadow_color">#33aaaaaa</color>
|
||||
</resources>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="app_name">OsmAnd~</string>
|
||||
<string name="app_name">Sherpafy</string>
|
||||
<string name="app_version">1.8 alpha</string>
|
||||
<!-- Not translatable -->
|
||||
<string name="ga_api_key">UA-28342846-2</string>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="sherpafy_tours">Sherpafy Tours</string>
|
||||
<string name="access_code_is_not_valid">Access code is not valid</string>
|
||||
<string name="enter_access_code">Enter access code</string>
|
||||
<string name="overview">Overview</string>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
||||
public class SherpafyLoadingFragment extends SherlockFragment {
|
||||
OsmandApplication app;
|
||||
private View view;
|
||||
|
||||
public SherpafyLoadingFragment(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.sherpafy_loading, container, false);
|
||||
|
||||
app.checkApplicationIsBeingInitialized(getActivity(), (TextView) view.findViewById(R.id.ProgressMessage),
|
||||
(ProgressBar) view.findViewById(R.id.ProgressBar), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((TextView) view.findViewById(R.id.ProgressMessage)).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.ProgressBar).setVisibility(View.GONE);
|
||||
((TourViewActivity)getSherlockActivity()).loadingFinished();
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
173
OsmAnd/src/net/osmand/plus/sherpafy/SherpafyToursFragment.java
Normal file
|
@ -0,0 +1,173 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.DownloadIndexActivity;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListFragment;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
|
||||
|
||||
public class SherpafyToursFragment extends SherlockListFragment {
|
||||
private static final int ACTION_DOWNLOAD = 5;
|
||||
OsmandApplication app;
|
||||
private View view;
|
||||
private SherpafyCustomization custom;
|
||||
|
||||
public SherpafyToursFragment(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
OsmandApplication app = (OsmandApplication) getSherlockActivity().getApplication();
|
||||
custom = (SherpafyCustomization) app.getAppCustomization();
|
||||
TourAdapter tourAdapter = new TourAdapter(custom.getTourInformations());
|
||||
setListAdapter(tourAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||
boolean light = true; //app.getSettings().isLightActionBar();
|
||||
com.actionbarsherlock.view.MenuItem menuItem = menu.add(0, ACTION_DOWNLOAD, 0, R.string.download_tours).setShowAsActionFlags(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
//menuItem = menuItem.setIcon(light ? R.drawable.ic_action_gdirections_light : R.drawable.ic_action_gdirections_dark);
|
||||
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) {
|
||||
if (custom.getAccessCode().length() == 0) {
|
||||
openAccessCode(true);
|
||||
} else {
|
||||
startDownloadActivity();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void openAccessCode(final boolean startDownload) {
|
||||
Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.enter_access_code);
|
||||
final EditText editText = new EditText(getActivity());
|
||||
editText.setInputType(EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS);
|
||||
LinearLayout ll = new LinearLayout(getActivity());
|
||||
ll.setPadding(5, 3, 5, 0);
|
||||
ll.addView(editText, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
builder.setView(ll);
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String acCode = editText.getText().toString();
|
||||
if (!custom.setAccessCode(acCode)) {
|
||||
Toast.makeText(getActivity(), R.string.access_code_is_not_valid, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (startDownload) {
|
||||
startDownloadActivity();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void startDownloadActivity() {
|
||||
final Intent download = new Intent(getActivity(), DownloadIndexActivity.class);
|
||||
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(download);
|
||||
}
|
||||
|
||||
private void selectTourAsync(final TourInformation tour) {
|
||||
new AsyncTask<TourInformation, Void, Void>() {
|
||||
private ProgressDialog dlg;
|
||||
|
||||
protected void onPreExecute() {
|
||||
dlg = new ProgressDialog(getActivity());
|
||||
dlg.setTitle(R.string.selecting_tour_progress);
|
||||
dlg.setMessage(getString(R.string.indexing_tour, tour == null ? "" : tour.getName()));
|
||||
dlg.show();
|
||||
};
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(TourInformation... params) {
|
||||
// if tour is already selected - do nothing
|
||||
if (custom.getSelectedTour() != null) {
|
||||
if (custom.getSelectedTour().equals(params[0])) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
custom.selectTour(params[0], IProgress.EMPTY_PROGRESS);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
// to avoid illegal argument exception when rotating phone during loading
|
||||
try {
|
||||
dlg.dismiss();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
//startTourView();
|
||||
};
|
||||
}.execute(tour);
|
||||
}
|
||||
|
||||
class TourAdapter extends ArrayAdapter<TourInformation> {
|
||||
|
||||
public TourAdapter(List<TourInformation> list) {
|
||||
super(getActivity(), R.layout.search_history_list_item, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.sherpafy_list_tour_item, parent, false);
|
||||
}
|
||||
TourInformation ti = getItem(position);
|
||||
TextView description = (TextView) row.findViewById(R.id.TourDescription);
|
||||
TextView name = (TextView) row.findViewById(R.id.TourName);
|
||||
description.setText(ti.getShortDescription());
|
||||
name.setText(ti.getName());
|
||||
ImageView iv = (ImageView) row.findViewById(R.id.TourImage);
|
||||
if(ti.getImageBitmap() != null) {
|
||||
iv.setBackground(new BitmapDrawable(getResources(), ti.getImageBitmap()));
|
||||
}
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -204,6 +204,11 @@ public class TourInformation {
|
|||
return img;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Returns full string from which contains XML tags from XMLParser
|
||||
|
@ -236,5 +241,10 @@ public class TourInformation {
|
|||
String content = sb.toString();
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,24 +21,37 @@ import android.app.ProgressDialog;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v4.widget.DrawerLayout.DrawerListener;
|
||||
import android.text.Html;
|
||||
import android.text.Html.ImageGetter;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
@ -47,6 +60,7 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
@ -56,73 +70,160 @@ import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
|
|||
*/
|
||||
public class TourViewActivity extends SherlockFragmentActivity {
|
||||
|
||||
private static final int GO_TO_MAP = 1;
|
||||
private static final int SETTINGS_ID = 2;
|
||||
private static final int TOUR_ID = 3;
|
||||
private static final int STATE_TOUR_VIEW = 1;
|
||||
private static final int STATE_LOADING = 0;
|
||||
private static final int STATE_SELECT_TOUR = -1;
|
||||
private static final int ACTION_GO_TO_MAP = 1;
|
||||
private static final int ACTION_TOUR_ID = 3;
|
||||
private static final int ACTION_SHARE = 4;
|
||||
|
||||
private static final int STATE_LOADING = -1;
|
||||
private static final int STATE_TOUR_VIEW = 1;
|
||||
private static final int STATE_SELECT_TOUR = 2;
|
||||
private static int state = STATE_LOADING;
|
||||
|
||||
|
||||
public static final int APP_EXIT_CODE = 4;
|
||||
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
||||
|
||||
|
||||
private SherpafyCustomization customization;
|
||||
ImageView img;
|
||||
TextView description;
|
||||
LinearLayout fullDescriptionView;
|
||||
RadioGroup stages;
|
||||
private ToggleButton collapser;
|
||||
Point size;
|
||||
private Set<TourInformation> currentTourInformations = new HashSet<TourInformation>();
|
||||
private Set<TourInformation> currentTourInformations = new HashSet<TourInformation>();
|
||||
|
||||
private SherpafyCustomization customization;
|
||||
private Point displaySize;
|
||||
private ActionBarDrawerToggle mDrawerToggle;
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private ListView mDrawerList;
|
||||
private ArrayAdapter<Object> drawerAdapter;
|
||||
private SherpafyToursFragment toursFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
if (!(getMyApplication().getAppCustomization() instanceof SherpafyCustomization)) {
|
||||
getMyApplication().setAppCustomization(new SherpafyCustomization());
|
||||
}
|
||||
customization = (SherpafyCustomization) getMyApplication().getAppCustomization();
|
||||
setTheme(R.style.OsmandLightTheme);
|
||||
((OsmandApplication) getApplication()).setLanguage(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
if(getIntent() != null){
|
||||
getMyApplication().setAppCustomization(new SherpafyCustomization());
|
||||
}
|
||||
customization = (SherpafyCustomization) getMyApplication().getAppCustomization();
|
||||
setTheme(R.style.OsmandLightTheme);
|
||||
((OsmandApplication) getApplication()).setLanguage(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getIntent() != null) {
|
||||
Intent intent = getIntent();
|
||||
if(intent.getExtras() != null && intent.getExtras().containsKey(APP_EXIT_KEY)){
|
||||
if (intent.getExtras() != null && intent.getExtras().containsKey(APP_EXIT_KEY)) {
|
||||
getMyApplication().closeApplication(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
|
||||
getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getSupportActionBar().setTitle(R.string.sherpafy_app_name);
|
||||
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
getSupportActionBar().setTitle(R.string.sherpafy_app_name);
|
||||
|
||||
setContentView(R.layout.sherpafy_loading);
|
||||
setContentView(R.layout.sherpafy_browse_tour);
|
||||
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
mDrawerList = (ListView) findViewById(R.id.left_drawer);
|
||||
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
|
||||
|
||||
size = new Point();
|
||||
getWindowManager().getDefaultDisplay().getSize(size);
|
||||
if (state == STATE_LOADING) {
|
||||
getMyApplication().checkApplicationIsBeingInitialized(this, (TextView) findViewById(R.id.ProgressMessage),
|
||||
(ProgressBar) findViewById(R.id.ProgressBar), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(customization.getSelectedTour() != null) {
|
||||
startTourView();
|
||||
} else {
|
||||
startSettings();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if(state == STATE_SELECT_TOUR ){
|
||||
state = STATE_LOADING;
|
||||
startSettings();
|
||||
} else if(state == STATE_TOUR_VIEW){
|
||||
state = STATE_LOADING;
|
||||
startTourView();
|
||||
// The drawer title must be set in order to announce state changes when
|
||||
// accessibility is turned on. This is typically a simple description,
|
||||
// e.g. "Navigation".
|
||||
mDrawerLayout.setDrawerTitle(GravityCompat.START, getString(R.string.sherpafy_app_name));
|
||||
|
||||
// Set the adapter for the list view
|
||||
drawerAdapter = new ArrayAdapter<Object>(this, android.R.layout.simple_list_item_1){
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Object it = getItem(position);
|
||||
if(convertView == null){
|
||||
convertView = getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
|
||||
}
|
||||
if(position == 0) {
|
||||
((TextView) convertView).setText(R.string.sherpafy_tours);
|
||||
} else {
|
||||
((TextView) convertView).setText(it.toString());
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
};
|
||||
mDrawerList.setAdapter(drawerAdapter);
|
||||
// Set the list's click listener
|
||||
mDrawerList.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectMenu(position, drawerAdapter.getItem(position));
|
||||
}
|
||||
});
|
||||
|
||||
displaySize = new Point();
|
||||
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, new SherpafyLoadingFragment(getMyApplication()))
|
||||
.commit();
|
||||
|
||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light,
|
||||
R.string.default_buttons_other_actions, R.string.close) {
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(View view) {
|
||||
super.onDrawerOpened(view);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerClosed(View view) {
|
||||
super.onDrawerOpened(view);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void selectMenu(int position, Object item) {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
if (position == 0) {
|
||||
if (toursFragment == null) {
|
||||
toursFragment = new SherpafyToursFragment(getMyApplication());
|
||||
}
|
||||
fragmentManager.beginTransaction().replace(R.id.content_frame, toursFragment).commit();
|
||||
state = STATE_SELECT_TOUR;
|
||||
}
|
||||
updateActionBarTitle();
|
||||
}
|
||||
|
||||
public void updateActionBarTitle() {
|
||||
if(state == STATE_LOADING) {
|
||||
getSupportActionBar().setTitle(R.string.app_name);
|
||||
} else if(state == STATE_SELECT_TOUR) {
|
||||
getSupportActionBar().setTitle(R.string.sherpafy_tours);
|
||||
} else if(state == STATE_TOUR_VIEW) {
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
||||
public void loadingFinished() {
|
||||
drawerAdapter.clear();
|
||||
drawerAdapter.add(getString(R.string.sherpafy_tours));
|
||||
if(customization.getSelectedTour() != null) {
|
||||
drawerAdapter.add(customization.getSelectedTour());
|
||||
if(customization.getSelectedStage() != null) {
|
||||
drawerAdapter.add(customization.getSelectedStage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// Sync the toggle state after onRestoreInstanceState has occurred.
|
||||
mDrawerToggle.syncState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
mDrawerToggle.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
private ImageGetter getImageGetter(final View v) {
|
||||
|
@ -134,10 +235,10 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
Drawable bmp = new BitmapDrawable(getResources(), file);
|
||||
// if image is thicker than screen - it may cause some problems, so we need to scale it
|
||||
int imagewidth = bmp.getIntrinsicWidth();
|
||||
if (size.x - 1 > imagewidth) {
|
||||
if (displaySize.x - 1 > imagewidth) {
|
||||
bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
|
||||
} else {
|
||||
double scale = (double) (size.x - 1) / imagewidth;
|
||||
double scale = (double) (displaySize.x - 1) / imagewidth;
|
||||
bmp.setBounds(0, 0, (int) (scale * bmp.getIntrinsicWidth()),
|
||||
(int) (scale * bmp.getIntrinsicHeight()));
|
||||
}
|
||||
|
@ -147,11 +248,11 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if(resultCode == APP_EXIT_CODE){
|
||||
if (resultCode == APP_EXIT_CODE) {
|
||||
getMyApplication().closeApplication(this);
|
||||
}
|
||||
}
|
||||
|
@ -160,21 +261,21 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
TourInformation selectedTour = customization.getSelectedTour();
|
||||
if (selectedTour == null || currentTourInformations.contains(selectedTour)) {
|
||||
for (TourInformation i : customization.getTourInformations()) {
|
||||
if (!currentTourInformations.contains(i)) {
|
||||
currentTourInformations.add(i);
|
||||
selectedTour = i;
|
||||
}
|
||||
}
|
||||
if(selectedTour != null) {
|
||||
selectTourAsync(selectedTour);
|
||||
//startTourView();
|
||||
}
|
||||
}
|
||||
// TourInformation selectedTour = customization.getSelectedTour();
|
||||
// if (selectedTour == null || currentTourInformations.contains(selectedTour)) {
|
||||
// for (TourInformation i : customization.getTourInformations()) {
|
||||
// if (!currentTourInformations.contains(i)) {
|
||||
// currentTourInformations.add(i);
|
||||
// selectedTour = i;
|
||||
// }
|
||||
// }
|
||||
// if (selectedTour != null) {
|
||||
// selectTourAsync(selectedTour);
|
||||
// // startTourView();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
private void setTourInfoContent() {
|
||||
setContentView(R.layout.sherpafy_tour_info);
|
||||
|
||||
|
@ -195,7 +296,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
});
|
||||
|
||||
collapser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
|
@ -221,14 +322,13 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
StageInformation st = customization.getSelectedStage();
|
||||
description.setText(Html.fromHtml(st.getShortDescription(), getImageGetter(description), null));
|
||||
setFullDescriptions(st.getFullDescription());
|
||||
|
||||
|
||||
// ((TextView)findViewById(R.id.tour_name)).setText(st.getName());
|
||||
setCollapserText(st.getName());
|
||||
prepareBitmap(st.getImageBitmap());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setFullDescriptions(String fulldescription) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (fulldescription.length() > 0) {
|
||||
|
@ -250,15 +350,15 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
tv.setText(Html.fromHtml(list.get(i), getImageGetter(tv), null));
|
||||
fullDescriptionView.addView(tv);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addOnClickListener(final TextView tv) {
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(v.getTag() instanceof Bitmap) {
|
||||
if (v.getTag() instanceof Bitmap) {
|
||||
final AccessibleAlertBuilder dlg = new AccessibleAlertBuilder(getActivity());
|
||||
dlg.setPositiveButton(R.string.default_buttons_ok, null);
|
||||
ScrollView sv = new ScrollView(getActivity());
|
||||
|
@ -278,16 +378,9 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
collapser.setTextOn(" " + t);
|
||||
}
|
||||
|
||||
private void startSettings() {
|
||||
if(state != STATE_SELECT_TOUR) {
|
||||
setTourSelectionContentView();
|
||||
state = STATE_SELECT_TOUR;
|
||||
}
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
||||
private void startTourView() {
|
||||
if(state != STATE_TOUR_VIEW) {
|
||||
if (state != STATE_TOUR_VIEW) {
|
||||
setTourInfoContent();
|
||||
state = STATE_TOUR_VIEW;
|
||||
}
|
||||
|
@ -295,30 +388,28 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
updateTourView();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
|
||||
if (state == STATE_TOUR_VIEW) {
|
||||
createMenuItem(menu, GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
createMenuItem(menu, SETTINGS_ID, R.string.settings, R.drawable.ic_action_settings_light,
|
||||
R.drawable.ic_action_settings_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
} else if(state == STATE_SELECT_TOUR) {
|
||||
// createMenuItem(menu, ACTION_GO_TO_MAP, R.string.start_tour, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
// MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
// createMenuItem(menu, ACTION_SETTINGS_ID, R.string.settings, R.drawable.ic_action_settings_light,
|
||||
// R.drawable.ic_action_settings_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
// | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
} else if (state == STATE_SELECT_TOUR) {
|
||||
if (customization.isTourSelected()) {
|
||||
createMenuItem(menu, TOUR_ID, R.string.default_buttons_ok, R.drawable.ic_action_ok_light,
|
||||
createMenuItem(menu, ACTION_TOUR_ID, R.string.default_buttons_ok, R.drawable.ic_action_ok_light,
|
||||
R.drawable.ic_action_ok_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM
|
||||
| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) {
|
||||
// int r = getMyApplication().getSettings().isLightActionBar() ? iconLight : iconDark;
|
||||
// int r = getMyApplication().getSettings().isLightActionBar() ? iconLight : iconDark;
|
||||
int r = iconLight;
|
||||
MenuItem menuItem = m.add(0, id, 0, titleRes);
|
||||
if (r != 0) {
|
||||
|
@ -333,7 +424,6 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
return menuItem;
|
||||
}
|
||||
|
||||
|
||||
private void updateTourView() {
|
||||
TourInformation curTour = customization.getSelectedTour();
|
||||
List<StageInformation> stagesInfo = curTour.getStageInformation();
|
||||
|
@ -365,7 +455,7 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
}
|
||||
|
||||
StageInformation stage = customization.getSelectedStage();
|
||||
|
||||
|
||||
int i = 0;
|
||||
if (stage != null) {
|
||||
for (i = 1; i < count; i++) {
|
||||
|
@ -379,12 +469,12 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
stages.check(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void goToMap() {
|
||||
if (customization.getSelectedStage() != null) {
|
||||
GPXFile gpx = customization.getSelectedStage().getGpx();
|
||||
List<SelectedGpxFile> sgpx = getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
|
||||
if(gpx == null && sgpx.size() > 0) {
|
||||
if (gpx == null && sgpx.size() > 0) {
|
||||
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
} else if (sgpx.size() != 1 || sgpx.get(0).getGpxFile() != gpx) {
|
||||
getMyApplication().getSelectedGpxHelper().clearAllGpxFileToShow();
|
||||
|
@ -416,169 +506,28 @@ public class TourViewActivity extends SherlockFragmentActivity {
|
|||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||
if (item.getItemId() == GO_TO_MAP) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
|
||||
mDrawerLayout.closeDrawer(mDrawerList);
|
||||
} else {
|
||||
mDrawerLayout.openDrawer(mDrawerList);
|
||||
}
|
||||
return true;
|
||||
} else if (item.getItemId() == ACTION_GO_TO_MAP) {
|
||||
goToMap();
|
||||
return true;
|
||||
} else if (item.getItemId() == SETTINGS_ID) {
|
||||
startSettings();
|
||||
return true;
|
||||
} else if (item.getItemId() == TOUR_ID) {
|
||||
} else if (item.getItemId() == ACTION_TOUR_ID) {
|
||||
startTourView();
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
return true;
|
||||
// return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setTourSelectionContentView() {
|
||||
setContentView(R.layout.sherpafy_start);
|
||||
final Button selectTour = (Button) findViewById(R.id.select_tour);
|
||||
final View accessCode = (View) findViewById(R.id.access_code);
|
||||
accessCode.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openAccessCode(false);
|
||||
}
|
||||
});
|
||||
|
||||
if (!customization.getTourInformations().isEmpty()) {
|
||||
selectTour.setText(R.string.select_tour);
|
||||
selectTour.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectTourDialog();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
selectTour.setText(R.string.download_tour);
|
||||
selectTour.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(customization.getAccessCode().length() == 0) {
|
||||
openAccessCode(true);
|
||||
} else {
|
||||
startDownloadActivity();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void openAccessCode(final boolean startDownload) {
|
||||
Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.enter_access_code);
|
||||
final EditText editText = new EditText(this);
|
||||
editText.setInputType(EditorInfo.TYPE_TEXT_FLAG_CAP_CHARACTERS);
|
||||
LinearLayout ll = new LinearLayout(this);
|
||||
ll.setPadding(5, 3, 5, 0);
|
||||
ll.addView(editText, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
builder.setView(ll);
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String acCode = editText.getText().toString();
|
||||
if(!customization.setAccessCode(acCode)) {
|
||||
Toast.makeText(getActivity(), R.string.access_code_is_not_valid, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if(startDownload) {
|
||||
startDownloadActivity();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
|
||||
private void startDownloadActivity() {
|
||||
final Intent download = new Intent(this, DownloadIndexActivity.class);
|
||||
download.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivity(download);
|
||||
}
|
||||
|
||||
private void selectTourDialog() {
|
||||
// creating alert dialog with multiple tours to select
|
||||
AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
|
||||
final List<TourInformation> tours = customization.getTourInformations();
|
||||
|
||||
final String[] tourNames = new String[tours.size() + 1];
|
||||
// creating list of tour names to select
|
||||
for (int i = 0; i < tourNames.length - 1; i++) {
|
||||
tourNames[i] = tours.get(i).getName();
|
||||
}
|
||||
tourNames[tourNames.length - 1] = getString(R.string.download_more);
|
||||
int ch = -1;
|
||||
if (customization.getSelectedTour() != null) {
|
||||
for (int i = 0; i < tourNames.length - 1; i++) {
|
||||
if (customization.getSelectedTour().equals(tours.get(i))) {
|
||||
ch = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
adb.setSingleChoiceItems(tourNames, ch, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
if (i == tourNames.length - 1) {
|
||||
startDownloadActivity();
|
||||
} else {
|
||||
selectTourAsync(tours.get(i));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
adb.setTitle(R.string.select_tour);
|
||||
adb.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
adb.show();
|
||||
}
|
||||
|
||||
|
||||
private Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private void selectTourAsync(final TourInformation tour){
|
||||
new AsyncTask<TourInformation, Void, Void>(){
|
||||
private ProgressDialog dlg;
|
||||
|
||||
protected void onPreExecute() {
|
||||
dlg = new ProgressDialog(getActivity());
|
||||
dlg.setTitle(R.string.selecting_tour_progress);
|
||||
dlg.setMessage(getString(R.string.indexing_tour, tour == null ? "" : tour.getName()));
|
||||
dlg.show();
|
||||
};
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(TourInformation... params) {
|
||||
//if tour is already selected - do nothing
|
||||
if (customization.getSelectedTour()!= null){
|
||||
if (customization.getSelectedTour().equals(params[0])){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
customization.selectTour(params[0], IProgress.EMPTY_PROGRESS);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
//to avoid illegal argument exception when rotating phone during loading
|
||||
try {
|
||||
dlg.dismiss();
|
||||
} catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
startTourView();
|
||||
};
|
||||
}.execute(tour);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<project name="SherlockBar" default="help">
|
||||
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
|
|