This commit is contained in:
Denis 2014-11-27 20:54:59 +02:00
commit 8a57fb940b
65 changed files with 1097 additions and 631 deletions

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto" android:installLocation="auto"
android:versionName="@string/app_version" android:versionName="@string/app_version"
android:versionCode="191" android:versionCode="201"
package="net.osmand.plus"> package="net.osmand.plus">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" /> <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" />
@ -58,14 +58,17 @@
<activity android:name="net.osmand.plus.activities.MainMenuActivity" android:label="@string/app_name"> <activity android:name="net.osmand.plus.activities.MainMenuActivity" android:label="@string/app_name">
<intent-filter>
</activity>
<activity android:name="net.osmand.plus.activities.HelpActivity" />
<activity android:name="net.osmand.plus.activities.DashboardActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" /> <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="net.osmand.plus.activities.HelpActivity" />
<activity android:name="net.osmand.plus.activities.MapActivity" android:label="@string/app_name" <activity android:name="net.osmand.plus.activities.MapActivity" android:label="@string/app_name"
android:screenOrientation="unspecified" android:launchMode="singleTop"> android:screenOrientation="unspecified" android:launchMode="singleTop">

Binary file not shown.

View file

@ -38,14 +38,14 @@
</target> </target>
<target name="fix_apostrophe_issues"> <target name="fix_apostrophe_issues">
<replace token="version='1.0'" value="version=&quot;1.0&quot;"> <replace token="version='1.0'" value="version=&quot;1.0&quot;" encoding="UTF-8">
<fileset dir="res" includes="**/strings.xml" /> <fileset dir="res" includes="**/strings.xml" />
</replace> </replace>
<replace token="encoding='utf-8'" value="encoding=&quot;utf-8&quot;"> <replace token="encoding='utf-8'" value="encoding=&quot;utf-8&quot;" encoding="UTF-8">
<fileset dir="res" includes="**/strings.xml" /> <fileset dir="res" includes="**/strings.xml" />
</replace> </replace>
<replaceregexp match="([^\\])'" replace="\1\\\\'" flags="-g" byline="off"> <replaceregexp match="([^\\])'" replace="\1\\\\'" flags="-g" byline="off" encoding="UTF-8">
<fileset dir="res" includes="**/strings.xml" /> <fileset dir="res" includes="**/strings.xml" />
</replaceregexp> </replaceregexp>
</target> </target>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/dashboard_divider" android:state_selected="true"></item>
<item android:drawable="@color/dashboard_divider" android:state_pressed="true"></item>
</selector>

View file

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:background="@drawable/bg_cardui"
android:orientation="vertical" >
<TextView
android:id="@+id/search_for"
style="@style/DashboardSubHeader"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="@string/search_for" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:orientation="horizontal" >
<Button
android:id="@+id/poi"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_info2"
android:text="@string/poi" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/address"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_home2"
android:text="@string/address" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/coord"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_marker2"
android:text="@string/coordinates" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/fav_btn"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_fav2"
android:text="@string/my_favorites" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/history"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_history2"
android:text="@string/history" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/transport"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_bus2"
android:text="@string/rendering_category_transport" />
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@drawable/dashboard_button"
android:layout_height="50dp">
<View android:layout_width="match_parent"
android:background="@color/dashboard_divider"
android:layout_height="1dp"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:id="@+id/icon"
android:layout_gravity="center_vertical"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_width="28dp"
android:layout_height="28dp"/>
<LinearLayout android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/name"
android:textSize="16sp"
android:textColor="@color/dashboard_black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/distance"
android:textSize="12sp"
android:textColor="@color/dashboard_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/dashboard_background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="6dp" >
<include layout="@layout/dashboard_search"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:background="@drawable/bg_cardui"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/map_text"
style="@style/DashboardSubHeader"
android:text="@string/map_Button" />
<Button
android:id="@+id/show_map"
style="@style/DashboardGeneralButton"
android:text="@string/show_map" />
</LinearLayout>
<net.osmand.plus.views.OsmAndMapSurfaceView
android:id="@+id/MapView"
android:layout_width="fill_parent"
android:layout_height="110dp"
android:layout_marginBottom="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:contentDescription="@string/map_view"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/main_fav"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_cardui"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/fav_text"
style="@style/DashboardSubHeader"
android:text="@string/my_data_Button" />
<Button
android:id="@+id/show_all"
style="@style/DashboardGeneralButton"
android:text="@string/show_all" />
</LinearLayout>
<LinearLayout
android:id="@+id/favorites"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="6dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="0.5">
<TextView
android:id="@+id/About"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|bottom"
android:text="@string/about_settings"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:orientation="vertical" >
<TextView
android:id="@+id/Copyright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:textSize="14sp" />
<TextView
android:id="@+id/OpenStreetMaps"
android:layout_width="wrap_content"
android:layout_marginTop="5dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:autoLink="web"
android:text="@string/openstreetmap_copyright"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/search"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:background="@drawable/bg_cardui"
android:orientation="vertical" >
<TextView
android:id="@+id/search_for"
style="@style/DashboardSubHeader"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="@string/search_for" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:orientation="horizontal" >
<Button
android:id="@+id/poi"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_info2"
android:text="@string/poi" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/address"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_home2"
android:text="@string/address" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/coord"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_marker2"
android:text="@string/coordinates" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="90dp"
android:orientation="horizontal" >
<Button
android:id="@+id/fav_btn"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_fav2"
android:text="@string/my_favorites" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/history"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_history2"
android:text="@string/history" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/dashboard_divider" />
<Button
android:id="@+id/transport"
style="@style/DashboardSearchButton"
android:drawableTop="@drawable/ic_action_bus2"
android:text="@string/rendering_category_transport" />
</LinearLayout>
</LinearLayout>

View file

@ -1846,4 +1846,9 @@
<string name="advanced_settings">Avanceret</string> <string name="advanced_settings">Avanceret</string>
<string name="osmo_use_https_descr">Brug sikker forbindelse med server</string> <string name="osmo_use_https_descr">Brug sikker forbindelse med server</string>
<string name="osmo_use_https">Brug https</string> <string name="osmo_use_https">Brug https</string>
<string name="home_button">Hjem</string>
<string name="search_for">Søg efter</string>
<string name="show_map">VIS KORT</string>
<string name="show_all">VIS ALLE</string>
<string name="coordinates">Koordinater</string>
</resources> </resources>

View file

@ -1862,4 +1862,9 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et
<string name="advanced_settings">Avancé</string> <string name="advanced_settings">Avancé</string>
<string name="osmo_use_https_descr">Utiliser une connexion sécurisée avec le serveur</string> <string name="osmo_use_https_descr">Utiliser une connexion sécurisée avec le serveur</string>
<string name="osmo_use_https">Utiliser HTTPS</string> <string name="osmo_use_https">Utiliser HTTPS</string>
<string name="home_button">Accueil</string>
<string name="search_for">Rechercher</string>
<string name="show_map">AFFICHER LA CARTE</string>
<string name="show_all">AFFICHER TOUT</string>
<string name="coordinates">Coordonnées</string>
</resources> </resources>

View file

@ -607,4 +607,6 @@
<string name="poi_isolated_dwelling">Хутор</string> <string name="poi_isolated_dwelling">Хутор</string>
<string name="poi_locality">Урочище</string> <string name="poi_locality">Урочище</string>
<string name="poi_palaeontological_site">Палеонтологический сайт</string>
</resources> </resources>

View file

@ -1783,4 +1783,9 @@ Si cussigiat de annànghere unu o prus puntos intermedios pro megiorare sas pres
<string name="advanced_settings">Avantzadas</string> <string name="advanced_settings">Avantzadas</string>
<string name="osmo_use_https_descr">Imprea una cunnessione segura cun su server</string> <string name="osmo_use_https_descr">Imprea una cunnessione segura cun su server</string>
<string name="osmo_use_https">Imprea https</string> <string name="osmo_use_https">Imprea https</string>
<string name="home_button">Domo</string>
<string name="search_for">Chirca pro</string>
<string name="show_map">AMMUSTRA MAPA</string>
<string name="show_all">AMMUSTRA TOTU</string>
<string name="coordinates">Coordinatas</string>
</resources> </resources>

View file

@ -1993,4 +1993,9 @@ Afganistan, Albánsko, Alžírsko, Andora, Angola, Anguilla, Antigua a Barbuda,
<string name="advanced_settings">Pokročilé</string> <string name="advanced_settings">Pokročilé</string>
<string name="osmo_use_https_descr">Použiť zabezpečené spojenie so serverom</string> <string name="osmo_use_https_descr">Použiť zabezpečené spojenie so serverom</string>
<string name="osmo_use_https">Použiť HTTPS</string> <string name="osmo_use_https">Použiť HTTPS</string>
<string name="home_button">Domov</string>
<string name="search_for">Hľadať</string>
<string name="show_map">ZOBRAZIŤ MAPU</string>
<string name="show_all">ZOBRAZIŤ VŠETKO</string>
<string name="coordinates">Súradnice</string>
</resources> </resources>

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="actionbar_color">#ff8f00</color>
<color name="dashboard_background">#eaeaea</color>
<color name="dashboard_divider">#f0f0f0</color>
<color name="dashboard_black">#212121</color>
<color name="dashboard_blue">#536DFE</color>
<color name="gpx_color_point">#cd2c33</color> <color name="gpx_color_point">#cd2c33</color>
<color name="gpx_speed">#c79c00</color> <color name="gpx_speed">#c79c00</color>
<color name="gpx_altitude_desc">#32CD32</color> <color name="gpx_altitude_desc">#32CD32</color>

View file

@ -14,6 +14,7 @@
<string name="ga_debug">true</string> <string name="ga_debug">true</string>
<string name="versionFeatures">+play_market +gps_status -parking_plugin -blackberry -free_version -amazon</string> <string name="versionFeatures">+play_market +gps_status -parking_plugin -blackberry -free_version -amazon</string>
<string name="next_tips_and_tricks_not_translate"></string> <string name="next_tips_and_tricks_not_translate"></string>
<string name="openstreetmap_copyright"><a href="http://www.openstreetmap.org/copyright">@OpenStreetMap</a></string>
<string name="about_content">Data is powered by OpenStreetMaps ODbL <string name="about_content">Data is powered by OpenStreetMaps ODbL
\n\nAll rights belong to OsmAnd app. \n\nAll rights belong to OsmAnd app.

View file

@ -9,9 +9,14 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="home_button">Home</string>
<string name="osmo_use_https_descr">Use secure connection with server</string> <string name="osmo_use_https_descr">Use secure connection with server</string>
<string name="osmo_use_https">Use https</string> <string name="osmo_use_https">Use https</string>
<string name="advanced_settings">Advanced</string> <string name="advanced_settings">Advanced</string>
<string name="search_for">Search for</string>
<string name="show_map">SHOW MAP</string>
<string name="show_all">SHOW ALL</string>
<string name="coordinates">Coordinates</string>
<string name="rendering_attr_publicTransportMode_name">Bus, trolleybus, shuttle routes</string> <string name="rendering_attr_publicTransportMode_name">Bus, trolleybus, shuttle routes</string>
<string name="rendering_attr_tramTrainRoutes_name">Tram and train routes</string> <string name="rendering_attr_tramTrainRoutes_name">Tram and train routes</string>
<string name="rendering_attr_subwayMode_name">Subway routes</string> <string name="rendering_attr_subwayMode_name">Subway routes</string>

View file

@ -7,9 +7,41 @@
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item> <item name="android:backgroundDimEnabled">false</item>
</style> </style>
<style name="DashboardSubHeader">
<style name="ListText"> <item name="android:layout_width">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:paddingTop">2dp</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textColor">@color/dashboard_black</item>
<item name="android:layout_marginLeft">15dp</item>ll
<item name="android:textSize">14sp</item>
</style>
<style name="DashboardGeneralButton">
<item name="android:layout_marginRight">16dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">36dp</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/dashboard_blue</item>
<item name="android:background">@drawable/dashboard_button</item>
</style>
<style name="DashboardSearchButton">
<item name="android:paddingTop">17dp</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/dashboard_black</item>
<item name="android:background">@drawable/dashboard_button</item>
<item name="android:gravity">bottom|center_horizontal</item>
<item name="android:paddingBottom">11dp</item>
</style>
<style name="ListText">
<item name="android:textSize">20sp</item> <item name="android:textSize">20sp</item>
</style> </style>
<style name="ListText.Small"> <style name="ListText.Small">

View file

@ -9,6 +9,7 @@ import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.plus.activities.DashboardActivity;
import net.osmand.plus.activities.FavouritesActivity; import net.osmand.plus.activities.FavouritesActivity;
import net.osmand.plus.activities.MainMenuActivity; import net.osmand.plus.activities.MainMenuActivity;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -47,9 +48,6 @@ public class OsmAndAppCustomization {
return true; return true;
} }
public void customizeMainMenu(Window window, Activity activity) {
}
// Activities // Activities
public Class<? extends Activity> getSettingsActivity(){ public Class<? extends Activity> getSettingsActivity(){
@ -68,8 +66,8 @@ public class OsmAndAppCustomization {
return FavouritesActivity.class; return FavouritesActivity.class;
} }
public Class<MainMenuActivity> getMainMenuActivity() { public Class<DashboardActivity> getMainMenuActivity() {
return MainMenuActivity.class; return DashboardActivity.class;
} }
public Class<? extends Activity> getDownloadIndexActivity() { public Class<? extends Activity> getDownloadIndexActivity() {

View file

@ -0,0 +1,634 @@
package net.osmand.plus.activities;
import java.io.File;
import java.text.MessageFormat;
import java.util.Date;
import java.util.List;
import java.util.Random;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.map.MapTileDownloader.DownloadRequest;
import net.osmand.map.MapTileDownloader.IMapDownloaderCallback;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.render.MapVectorLayer;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.sherpafy.TourViewActivity;
import net.osmand.plus.views.MapTextLayer;
import net.osmand.plus.views.OsmAndMapSurfaceView;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.format.DateFormat;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.TypedValue;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.ibm.icu.util.Calendar;
/**
* Created by Denis on 05.11.2014.
*/
public class DashboardActivity extends SherlockFragmentActivity implements IMapDownloaderCallback {
public static final boolean TIPS_AND_TRICKS = false;
public static final int APP_EXIT_CODE = 4;
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
private static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
private static final String TIPS_SHOW = "TIPS_SHOW"; //$NON-NLS-1$
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
private ProgressDialog startProgressDialog;
private OsmandMapTileView osmandMapTileView;
@Override
public void onDestroy() {
super.onDestroy();
getMyApplication().getResourceManager().getMapTileDownloader().removeDownloaderCallback(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
if(getIntent() != null){
Intent intent = getIntent();
if(intent.getExtras() != null && intent.getExtras().containsKey(APP_EXIT_KEY)){
getMyApplication().closeApplication(this);
return;
}
}
if(Version.isSherpafy(getMyApplication())) {
final Intent mapIntent = new Intent(this, TourViewActivity.class);
startActivity(mapIntent);
finish();
return;
}
setContentView(R.layout.dashboard);
setupContributionVersion();
getSupportActionBar().setTitle(Version.getFullVersion(getMyApplication()));
ColorDrawable color = new ColorDrawable(getResources().getColor(R.color.actionbar_color));
getSupportActionBar().setBackgroundDrawable(color);
getSupportActionBar().setIcon(android.R.color.transparent);
setupMapView();
setupButtons();
setupFonts();
getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == APP_EXIT_CODE){
getMyApplication().closeApplication(this);
}
}
protected void setupContributionVersion() {
final TextView textVersionView = (TextView) findViewById(R.id.Copyright);
final Calendar inst = Calendar.getInstance();
inst.setTime(new Date());
final String textVersion = "@OsmAnd " + inst.get(Calendar.YEAR);
textVersionView.setText(textVersion);
final SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
textVersionView.setOnClickListener(new OnClickListener(){
int i = 0;
@Override
public void onClick(View v) {
if(i++ > 8 && Version.isDeveloperVersion(getMyApplication())) {
prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
enableLink(DashboardActivity.this, textVersion, textVersionView);
}
}
});
// only one commit should be with contribution version flag
// prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
if (prefs.contains(CONTRIBUTION_VERSION_FLAG) && Version.isDeveloperVersion(getMyApplication())) {
enableLink(this, textVersion, textVersionView);
}
final TextView about = (TextView) findViewById(R.id.About);
final String aboutString = getString(R.string.about_settings);
SpannableString ss = new SpannableString(aboutString);
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
showAboutDialog(DashboardActivity.this, getMyApplication());
}
};
ss.setSpan(clickableSpan, 0, aboutString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
about.setText(ss);
about.setMovementMethod(LinkMovementMethod.getInstance());
}
public static void showAboutDialog(final Activity activity, final OsmandApplication app) {
Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(R.string.about_settings);
ScrollView sv = new ScrollView(activity);
TextView tv = new TextView(activity);
sv.addView(tv);
String version = Version.getFullVersion(app);
String vt = activity.getString(R.string.about_version) +"\t";
int st = vt.length();
String edition = "";
SharedPreferences prefs = app.getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
if (prefs.contains(CONTRIBUTION_VERSION_FLAG) && Version.isDeveloperVersion(app)) {
try {
PackageManager pm = activity.getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
Date date = new Date(new File(appInfo.sourceDir).lastModified());
edition = activity.getString(R.string.local_index_installed) + " :\t" + DateFormat.getDateFormat(app).format(date);
} catch (Exception e) {
}
SpannableString content = new SpannableString(vt + version +"\n" +
edition +"\n\n"+
activity.getString(R.string.about_content));
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
final Intent mapIntent = new Intent(activity, ContributionVersionActivity.class);
activity.startActivityForResult(mapIntent, 0);
}
}, st, st + version.length(), 0);
tv.setText(content);
} else {
tv.setText(vt + version +"\n\n" +
activity.getString(R.string.about_content));
}
tv.setPadding(5, 0, 5, 5);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
tv.setMovementMethod(LinkMovementMethod.getInstance());
bld.setView(sv);
bld.setPositiveButton(R.string.default_buttons_ok, null);
bld.show();
}
@Override
protected void onResume() {
super.onResume();
setupFavorites();
}
protected void initApp(final OsmAndAppCustomization appCustomization, final Activity activity, OsmandApplication app) {
// restore follow route mode
if(app.getSettings().FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated()){
final Intent mapIndent = new Intent(this, appCustomization.getMapActivity());
startActivityForResult(mapIndent, 0);
return;
}
startProgressDialog = new ProgressDialog(this);
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
boolean dialogShown = false;
boolean firstTime = false;
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
boolean appVersionChanged = false;
if (!pref.contains(FIRST_TIME_APP_RUN)) {
firstTime = true;
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
} else if (!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))) {
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
appVersionChanged = true;
}
if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
if (firstTime) {
applicationInstalledFirstTime();
dialogShown = true;
} else {
int i = pref.getInt(TIPS_SHOW, 0);
if (i < 7) {
pref.edit().putInt(TIPS_SHOW, ++i).commit();
}
if (i == 1 || i == 5 || appVersionChanged) {
if(TIPS_AND_TRICKS) {
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
dlg.show();
dialogShown = true;
} else {
if(appVersionChanged) {
final Intent helpIntent = new Intent(activity, HelpActivity.class);
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
helpIntent.putExtra(HelpActivity.URL, "changes-1.9.html");
activity.startActivity(helpIntent);
dialogShown = true;
}
}
}
}
}
if(!dialogShown && appCustomization.checkBasemapDownloadedOnStart()) {
if (startProgressDialog.isShowing()) {
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
checkVectorIndexesDownloaded();
}
});
} else {
checkVectorIndexesDownloaded();
}
}
if(appCustomization.checkExceptionsOnStart() && !dialogShown){
checkPreviousRunsForExceptions(firstTime);
}
}
@Override
protected Dialog onCreateDialog(int id) {
if(id == OsmandApplication.PROGRESS_DIALOG){
return startProgressDialog;
}
return super.onCreateDialog(id);
}
private void applicationInstalledFirstTime() {
boolean netOsmandWasInstalled = false;
try {
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("net.osmand", PackageManager.GET_META_DATA);
netOsmandWasInstalled = applicationInfo != null && !Version.isFreeVersion(getMyApplication());
} catch (NameNotFoundException e) {
netOsmandWasInstalled = false;
}
if(netOsmandWasInstalled){
// Builder builder = new AccessibleAlertBuilder(this);
// builder.setMessage(R.string.osmand_net_previously_installed);
// builder.setPositiveButton(R.string.default_buttons_ok, null);
// builder.show();
} else {
Builder builder = new AccessibleAlertBuilder(this);
builder.setMessage(R.string.first_time_msg);
builder.setPositiveButton(R.string.first_time_download, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(DashboardActivity.this, getMyApplication().getAppCustomization().getDownloadIndexActivity()));
}
});
builder.setNegativeButton(R.string.first_time_continue, null);
builder.show();
}
}
public void checkPreviousRunsForExceptions(boolean firstTime) {
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
final OsmandApplication app = ((OsmandApplication) getApplication());
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
if (file.exists() && file.length() > 0) {
if (size != file.length() && !firstTime) {
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
Builder builder = new AccessibleAlertBuilder(DashboardActivity.this);
builder.setMessage(msg).setNeutralButton(getString(R.string.close), null);
builder.setPositiveButton(R.string.send_report, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osmand.app+crash@gmail.com" }); //$NON-NLS-1$
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
StringBuilder text = new StringBuilder();
text.append("\nDevice : ").append(Build.DEVICE); //$NON-NLS-1$
text.append("\nBrand : ").append(Build.BRAND); //$NON-NLS-1$
text.append("\nModel : ").append(Build.MODEL); //$NON-NLS-1$
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
text.append("\nApp Version : ").append(Version.getAppName(app)); //$NON-NLS-1$
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
if (info != null) {
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (NameNotFoundException e) {
}
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
}
});
builder.show();
}
getPreferences(MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
} else {
if (size > 0) {
getPreferences(MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit();
}
}
}
private void setupFonts() {
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Medium.ttf");
((TextView) findViewById(R.id.search_for)).setTypeface(typeface);
((TextView) findViewById(R.id.map_text)).setTypeface(typeface);
((TextView) findViewById(R.id.fav_text)).setTypeface(typeface);
((Button) findViewById(R.id.show_map)).setTypeface(typeface);
((Button) findViewById(R.id.show_all)).setTypeface(typeface);
}
private void setupFavorites(){
final FavouritesDbHelper helper = getMyApplication().getFavorites();
final List<FavouritePoint> points = helper.getFavouritePoints();
LinearLayout favorites = (LinearLayout) findViewById(R.id.favorites);
favorites.removeAllViews();
if (points.size() == 0){
(findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
}
if (points.size() > 3){
while (points.size() != 3){
points.remove(3);
}
}
for (final FavouritePoint point : points) {
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.dash_fav_list, null, false);
TextView name = (TextView) view.findViewById(R.id.name);
TextView label = (TextView) view.findViewById(R.id.distance);
ImageView icon = (ImageView) view.findViewById(R.id.icon);
name.setText(point.getName());
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(DashboardActivity.this, point.getColor()));
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
label.setText(distance, TextView.BufferType.SPANNABLE);
label.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent mapIntent = new Intent(DashboardActivity.this, getMyApplication().getAppCustomization().getMapActivity());
getMyApplication().getSettings().setLastKnownMapLocation(point.getLatitude(), point.getLongitude());
startActivity(mapIntent);
}
});
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics());
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
view.setLayoutParams(lp);
favorites.addView(view);
}
}
private void setupButtons(){
final Activity activity = this;
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
(findViewById(R.id.show_map)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent mapIndent = new Intent(activity, appCustomization.getMapActivity());
activity.startActivityForResult(mapIndent, 0);
}
});
(findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites);
}
});
(findViewById(R.id.poi)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
activity.startActivity(search);
}
});
(findViewById(R.id.address)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.ADDRESS_TAB_INDEX);
activity.startActivity(search);
}
});
(findViewById(R.id.coord)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.LOCATION_TAB_INDEX);
activity.startActivity(search);
}
});
(findViewById(R.id.fav_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.FAVORITES_TAB_INDEX);
activity.startActivity(search);
}
});
(findViewById(R.id.history)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.HISTORY_TAB_INDEX);
activity.startActivity(search);
}
});
(findViewById(R.id.transport)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.TRANSPORT_TAB_INDEX);
activity.startActivity(search);
}
});
}
private void setupMapView() {
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
osmandMapTileView = surf.getMapView();
osmandMapTileView.getView().setVisibility(View.VISIBLE);
osmandMapTileView.removeAllLayers();
MapVectorLayer mapVectorLayer = new MapVectorLayer(null);
MapTextLayer mapTextLayer = new MapTextLayer();
mapTextLayer.setAlwaysVisible(true);
// 5.95 all labels
osmandMapTileView.addLayer(mapTextLayer, 5.95f);
osmandMapTileView.addLayer(mapVectorLayer, 0.5f);
osmandMapTileView.setMainLayer(mapVectorLayer);
mapVectorLayer.setVisible(true);
LatLon lm = getMyApplication().getSettings().getLastKnownMapLocation();
int zm = getMyApplication().getSettings().getLastKnownMapZoom();
osmandMapTileView.setLatLon(lm.getLatitude(), lm.getLongitude());
osmandMapTileView.setIntZoom(zm);
osmandMapTileView.refreshMap(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, R.string.tips_and_tricks).setIcon(R.drawable.ic_ac_help)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.add(0, 1, 0, R.string.settings).setIcon(R.drawable.ic_ac_settings)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.add(0, 2, 0, R.string.exit_Button).setIcon(R.drawable.ic_ac_close)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
if (item.getItemId() == 0) {
if(TIPS_AND_TRICKS) {
TipsAndTricksActivity activity = new TipsAndTricksActivity(this);
Dialog dlg = activity.getDialogToShowTips(false, true);
dlg.show();
} else {
final Intent helpIntent = new Intent(this, HelpActivity.class);
startActivity(helpIntent);
}
} else if (item.getItemId() == 1){
final Intent settings = new Intent(this, appCustomization.getSettingsActivity());
startActivity(settings);
} else if (item.getItemId() == 2){
getMyApplication().closeApplication(this);
}
return true;
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getApplication();
}
protected void checkVectorIndexesDownloaded() {
MapRenderRepositories maps = getMyApplication().getResourceManager().getRenderer();
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
boolean check = pref.getBoolean(VECTOR_INDEXES_CHECK, true);
// do not show each time
if (check && new Random().nextInt() % 5 == 1) {
Builder builder = new AccessibleAlertBuilder(this);
if(maps.isEmpty()){
builder.setMessage(R.string.vector_data_missing);
} else if(!maps.basemapExists()){
builder.setMessage(R.string.basemap_missing);
} else {
return;
}
builder.setPositiveButton(R.string.download_files, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(DashboardActivity.this, DownloadActivity.class));
}
});
builder.setNeutralButton(R.string.vector_map_not_needed, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getPreferences(MODE_WORLD_WRITEABLE).edit().putBoolean(VECTOR_INDEXES_CHECK, false).commit();
}
});
builder.setNegativeButton(R.string.first_time_continue, null);
builder.show();
}
}
private static void enableLink(final Activity activity, String textVersion, TextView textVersionView) {
SpannableString content = new SpannableString(textVersion);
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
final Intent mapIntent = new Intent(activity, ContributionVersionActivity.class);
activity.startActivityForResult(mapIntent, 0);
}
}, 0, content.length(), 0);
textVersionView.setText(content);
textVersionView.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
public void tileDownloaded(DownloadRequest request) {
if(request != null && !request.error && request.fileToSave != null){
ResourceManager mgr = getMyApplication().getResourceManager();
mgr.tileDownloaded(request);
}
if(request == null || !request.error){
if(osmandMapTileView != null) {
osmandMapTileView.tileDownloaded(request);
}
}
}
}

View file

@ -1,408 +1,30 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import java.io.File;
import java.text.MessageFormat;
import java.util.Random;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexFragment;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.sherpafy.TourViewActivity;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window; import android.view.Window;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
public class MainMenuActivity extends Activity { public class MainMenuActivity extends Activity {
private static final String FIRST_TIME_APP_RUN = "FIRST_TIME_APP_RUN"; //$NON-NLS-1$
private static final String VECTOR_INDEXES_CHECK = "VECTOR_INDEXES_CHECK"; //$NON-NLS-1$
private static final String TIPS_SHOW = "TIPS_SHOW"; //$NON-NLS-1$
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
private static final String CONTRIBUTION_VERSION_FLAG = "CONTRIBUTION_VERSION_FLAG";
public static final int APP_EXIT_CODE = 4;
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
public static final boolean TIPS_AND_TRICKS = false;
private ProgressDialog startProgressDialog;
public void checkPreviousRunsForExceptions(boolean firstTime) {
long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0);
final OsmandApplication app = ((OsmandApplication) getApplication());
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
if (file.exists() && file.length() > 0) {
if (size != file.length() && !firstTime) {
String msg = MessageFormat.format(getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH);
Builder builder = new AccessibleAlertBuilder(MainMenuActivity.this);
builder.setMessage(msg).setNeutralButton(getString(R.string.close), null);
builder.setPositiveButton(R.string.send_report, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osmand.app+crash@gmail.com" }); //$NON-NLS-1$
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
StringBuilder text = new StringBuilder();
text.append("\nDevice : ").append(Build.DEVICE); //$NON-NLS-1$
text.append("\nBrand : ").append(Build.BRAND); //$NON-NLS-1$
text.append("\nModel : ").append(Build.MODEL); //$NON-NLS-1$
text.append("\nProduct : ").append(Build.PRODUCT); //$NON-NLS-1$
text.append("\nBuild : ").append(Build.DISPLAY); //$NON-NLS-1$
text.append("\nVersion : ").append(Build.VERSION.RELEASE); //$NON-NLS-1$
text.append("\nApp Version : ").append(Version.getAppName(app)); //$NON-NLS-1$
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
if (info != null) {
text.append("\nApk Version : ").append(info.versionName).append(" ").append(info.versionCode); //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (NameNotFoundException e) {
}
intent.putExtra(Intent.EXTRA_TEXT, text.toString());
startActivity(Intent.createChooser(intent, getString(R.string.send_report)));
}
});
builder.show();
}
getPreferences(MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
} else {
if (size > 0) {
getPreferences(MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit();
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == APP_EXIT_CODE){
getMyApplication().closeApplication(this);
}
}
public static Animation getAnimation(int left, int top){
Animation anim = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF, left,
TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, top, TranslateAnimation.RELATIVE_TO_SELF, 0);
anim.setDuration(700);
anim.setInterpolator(new AccelerateInterpolator());
return anim;
}
public static void onCreateMainMenu(Window window, final Activity activity){
View head = (View) window.findViewById(R.id.Headliner);
head.startAnimation(getAnimation(0, -1));
View leftview = (View) window.findViewById(R.id.MapButton);
leftview.startAnimation(getAnimation(-1, 0));
leftview = (View) window.findViewById(R.id.FavoritesButton);
leftview.startAnimation(getAnimation(-1, 0));
View rightview = (View) window.findViewById(R.id.SettingsButton);
rightview.startAnimation(getAnimation(1, 0));
rightview = (View) window.findViewById(R.id.SearchButton);
rightview.startAnimation(getAnimation(1, 0));
final String textVersion = Version.getAppVersion(((OsmandApplication) activity.getApplication()));
final TextView textVersionView = (TextView) window.findViewById(R.id.TextVersion);
textVersionView.setText(textVersion);
final SharedPreferences prefs = activity.getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
textVersionView.setOnClickListener(new OnClickListener(){
int i = 0;
@Override
public void onClick(View v) {
if(i++ > 8) {
prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
enableLink(activity, textVersion, textVersionView);
}
}
});
// only one commit should be with contribution version flag
// prefs.edit().putBoolean(CONTRIBUTION_VERSION_FLAG, true).commit();
if (prefs.contains(CONTRIBUTION_VERSION_FLAG)) {
enableLink(activity, textVersion, textVersionView);
}
View helpButton = window.findViewById(R.id.HelpButton);
helpButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(TIPS_AND_TRICKS) {
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(activity);
Dialog dlg = tactivity.getDialogToShowTips(false, true);
dlg.show();
} else {
final Intent helpIntent = new Intent(activity, HelpActivity.class);
activity.startActivity(helpIntent);
}
}
});
}
private static void enableLink(final Activity activity, String textVersion, TextView textVersionView) {
SpannableString content = new SpannableString(textVersion);
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
final Intent mapIntent = new Intent(activity, ContributionVersionActivity.class);
activity.startActivityForResult(mapIntent, 0);
}
}, 0, content.length(), 0);
textVersionView.setText(content);
textVersionView.setMovementMethod(LinkMovementMethod.getInstance());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
if(getIntent() != null){
Intent intent = getIntent();
if(intent.getExtras() != null && intent.getExtras().containsKey(APP_EXIT_KEY)){
getMyApplication().closeApplication(this);
return;
}
}
if(Version.isSherpafy(getMyApplication())) {
final Intent mapIntent = new Intent(this, TourViewActivity.class);
startActivity(mapIntent);
finish();
return;
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.menu);
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
onCreateMainMenu(getWindow(), this);
Window window = getWindow();
final Activity activity = this;
View showMap = window.findViewById(R.id.MapButton);
showMap.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent mapIndent = new Intent(activity, appCustomization.getMapActivity());
activity.startActivityForResult(mapIndent, 0);
}
});
View settingsButton = window.findViewById(R.id.SettingsButton);
settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent settings = new Intent(activity, appCustomization.getSettingsActivity());
activity.startActivity(settings);
}
});
View favouritesButton = window.findViewById(R.id.FavoritesButton);
favouritesButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent favorites = new Intent(activity, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(favorites);
}
});
final View closeButton = window.findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getMyApplication().closeApplication(activity);
}
});
View searchButton = window.findViewById(R.id.SearchButton);
searchButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent search = new Intent(activity, appCustomization.getSearchActivity());
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
activity.startActivity(search);
}
});
appCustomization.customizeMainMenu(window, this);
OsmandApplication app = getMyApplication();
// restore follow route mode
if(app.getSettings().FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated()){
final Intent mapIndent = new Intent(this, appCustomization.getMapActivity());
startActivityForResult(mapIndent, 0);
return;
}
startProgressDialog = new ProgressDialog(this);
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
boolean dialogShown = false;
boolean firstTime = false;
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
boolean appVersionChanged = false;
if (!pref.contains(FIRST_TIME_APP_RUN)) {
firstTime = true;
pref.edit().putBoolean(FIRST_TIME_APP_RUN, true).commit();
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
} else if (!Version.getFullVersion(app).equals(pref.getString(VERSION_INSTALLED, ""))) {
pref.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
appVersionChanged = true;
}
if (appCustomization.showFirstTimeRunAndTips(firstTime, appVersionChanged)) {
if (firstTime) {
applicationInstalledFirstTime();
dialogShown = true;
} else {
int i = pref.getInt(TIPS_SHOW, 0);
if (i < 7) {
pref.edit().putInt(TIPS_SHOW, ++i).commit();
}
if (i == 1 || i == 5 || appVersionChanged) {
if(TIPS_AND_TRICKS) {
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
dlg.show();
dialogShown = true;
} else {
if(appVersionChanged) {
final Intent helpIntent = new Intent(activity, HelpActivity.class);
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
helpIntent.putExtra(HelpActivity.URL, "changes-1.9.html");
activity.startActivity(helpIntent);
dialogShown = true;
}
}
}
}
}
if(!dialogShown && appCustomization.checkBasemapDownloadedOnStart()) {
if (startProgressDialog.isShowing()) {
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
checkVectorIndexesDownloaded();
}
});
} else {
checkVectorIndexesDownloaded();
}
}
if(appCustomization.checkExceptionsOnStart() && !dialogShown){
checkPreviousRunsForExceptions(firstTime);
}
}
private void applicationInstalledFirstTime() {
boolean netOsmandWasInstalled = false;
try {
ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("net.osmand", PackageManager.GET_META_DATA);
netOsmandWasInstalled = applicationInfo != null && !Version.isFreeVersion(getMyApplication());
} catch (NameNotFoundException e) {
netOsmandWasInstalled = false;
}
if(netOsmandWasInstalled){
// Builder builder = new AccessibleAlertBuilder(this);
// builder.setMessage(R.string.osmand_net_previously_installed);
// builder.setPositiveButton(R.string.default_buttons_ok, null);
// builder.show();
} else {
Builder builder = new AccessibleAlertBuilder(this);
builder.setMessage(R.string.first_time_msg);
builder.setPositiveButton(R.string.first_time_download, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(MainMenuActivity.this, getMyApplication().getAppCustomization().getDownloadIndexActivity()));
}
});
builder.setNegativeButton(R.string.first_time_continue, null);
builder.show();
}
}
protected void checkVectorIndexesDownloaded() {
MapRenderRepositories maps = getMyApplication().getResourceManager().getRenderer();
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
boolean check = pref.getBoolean(VECTOR_INDEXES_CHECK, true);
// do not show each time
if (check && new Random().nextInt() % 5 == 1) {
Builder builder = new AccessibleAlertBuilder(this);
if(maps.isEmpty()){
builder.setMessage(R.string.vector_data_missing);
} else if(!maps.basemapExists()){
builder.setMessage(R.string.basemap_missing);
} else {
return;
}
builder.setPositiveButton(R.string.download_files, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(MainMenuActivity.this, DownloadActivity.class));
}
});
builder.setNeutralButton(R.string.vector_map_not_needed, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getPreferences(MODE_WORLD_WRITEABLE).edit().putBoolean(VECTOR_INDEXES_CHECK, false).commit();
}
});
builder.setNegativeButton(R.string.first_time_continue, null);
builder.show();
}
}
private OsmandApplication getMyApplication() { private OsmandApplication getMyApplication() {
return (OsmandApplication) getApplication(); return (OsmandApplication) getApplication();
} }
@Override @Override
protected Dialog onCreateDialog(int id) { protected void onCreate(Bundle savedInstanceState) {
if(id == OsmandApplication.PROGRESS_DIALOG){ super.onCreate(savedInstanceState);
return startProgressDialog; requestWindowFeature(Window.FEATURE_NO_TITLE);
} setContentView(R.layout.menu);
return super.onCreateDialog(id);
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
final Intent settings = new Intent(this, appCustomization.getMainMenuActivity());
startActivity(settings);
} }
@ -417,114 +39,6 @@ public class MainMenuActivity extends Activity {
} }
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
public static void backToMainMenuDialog(final Activity a, final LatLon searchLocation) {
final Dialog dlg = new Dialog(a, R.style.Dialog_Fullscreen);
final View menuView = (View) a.getLayoutInflater().inflate(R.layout.menu, null);
menuView.setBackgroundColor(Color.argb(200, 150, 150, 150));
dlg.setContentView(menuView);
final OsmAndAppCustomization appCustomization = ((OsmandApplication) a.getApplication()).getAppCustomization();
MainMenuActivity.onCreateMainMenu(dlg.getWindow(), a);
Animation anim = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
ColorDrawable colorDraw = ((ColorDrawable) menuView.getBackground());
colorDraw.setAlpha((int) (interpolatedTime * 200));
}
};
anim.setDuration(700);
anim.setInterpolator(new AccelerateInterpolator());
menuView.setAnimation(anim);
View showMap = dlg.findViewById(R.id.MapButton);
showMap.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dlg.dismiss();
}
});
View settingsButton = dlg.findViewById(R.id.SettingsButton);
settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent settings = new Intent(a, appCustomization.getSettingsActivity());
a.startActivity(settings);
dlg.dismiss();
}
});
View favouritesButton = dlg.findViewById(R.id.FavoritesButton);
favouritesButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent favorites = new Intent(a, appCustomization.getFavoritesActivity());
favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
a.startActivity(favorites);
dlg.dismiss();
}
});
View closeButton = dlg.findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dlg.dismiss();
// 1. Work for almost all cases when user open apps from main menu
Intent newIntent = new Intent(a, appCustomization.getMainMenuActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
newIntent.putExtra(MainMenuActivity.APP_EXIT_KEY, MainMenuActivity.APP_EXIT_CODE);
a.startActivity(newIntent);
// 2. good analogue but user will come back to the current activity onResume()
// so application is not reloaded !!!
// moveTaskToBack(true);
// 3. bad results if user comes from favorites
// a.setResult(MainMenuActivity.APP_EXIT_CODE);
// a.finish();
}
});
View searchButton = dlg.findViewById(R.id.SearchButton);
searchButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
final Intent search = new Intent(a, appCustomization.getSearchActivity());
LatLon loc = searchLocation;
search.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
search.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
// causes wrong position caching: search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
search.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
a.startActivity(search);
dlg.dismiss();
}
});
menuView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dlg.dismiss();
}
});
dlg.show();
// Intent newIntent = new Intent(a, MainMenuActivity.class);
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(newIntent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, R.string.exit_Button);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == 0) {
getMyApplication().closeApplication(this);
return true;
}
return false;
}
} }

View file

@ -82,7 +82,7 @@ import android.widget.Toast;
public class MapActivity extends AccessibleActivity implements public class MapActivity extends AccessibleActivity implements
VoiceRouter.VoiceMessageListener { VoiceRouter.VoiceMessageListener {
private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1; private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1;
private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2; private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2;
private static final int LONG_KEYPRESS_DELAY = 500; private static final int LONG_KEYPRESS_DELAY = 500;
@ -228,6 +228,7 @@ public class MapActivity extends AccessibleActivity implements
mDeviceAdmin = new ComponentName(getApplicationContext(), DeviceAdminRecv.class); mDeviceAdmin = new ComponentName(getApplicationContext(), DeviceAdminRecv.class);
mDevicePolicyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE); mDevicePolicyManager = (DevicePolicyManager) getSystemService(DEVICE_POLICY_SERVICE);
} }
public void addLockView(FrameLayout lockView) { public void addLockView(FrameLayout lockView) {

View file

@ -838,16 +838,6 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).reg();
optionsMenuHelper.item(R.string.settings_Button).icons(R.drawable.ic_action_settings2_dark, R.drawable.ic_action_settings2_light)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
final Intent intentSettings = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSettingsActivity());
mapActivity.startActivity(intentSettings);
return true;
}
}).reg();
//////////// Others //////////// Others
if (Version.isGpsStatusEnabled(app)) { if (Version.isGpsStatusEnabled(app)) {
@ -861,23 +851,6 @@ public class MapActivityActions implements DialogProvider {
} }
}).reg(); }).reg();
} }
optionsMenuHelper.item(R.string.tips_and_tricks).
icons(R.drawable.ic_action_ghelp_dark, R.drawable.ic_action_ghelp_light).
listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (MainMenuActivity.TIPS_AND_TRICKS) {
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(mapActivity);
Dialog dlg = tactivity.getDialogToShowTips(false, true);
dlg.show();
} else {
final Intent helpIntent = new Intent(mapActivity, HelpActivity.class);
mapActivity.startActivity(helpIntent);
}
return true;
}
}).reg();
final OsmAndLocationProvider loc = app.getLocationProvider(); final OsmAndLocationProvider loc = app.getLocationProvider();
if (app.getTargetPointsHelper().getPointToNavigate() != null || loc.getLocationSimulation().isRouteAnimating()) { if (app.getTargetPointsHelper().getPointToNavigate() != null || loc.getLocationSimulation().isRouteAnimating()) {
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) { if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) {
@ -897,14 +870,15 @@ public class MapActivityActions implements DialogProvider {
} }
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper); OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
optionsMenuHelper.item(R.string.exit_Button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light ) optionsMenuHelper.item(R.string.home_button).icons(R.drawable.ic_action_quit_dark, R.drawable.ic_action_quit_light )
.listen(new OnContextMenuClick() { .listen(new OnContextMenuClick() {
@Override @Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) { public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
// 1. Work for almost all cases when user open apps from main menu // 1. Work for almost all cases when user open apps from main menu
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity()); Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
newIntent.putExtra(MainMenuActivity.APP_EXIT_KEY, MainMenuActivity.APP_EXIT_CODE); // not exit
// newIntent.putExtra(DashboardActivity.APP_EXIT_KEY, DashboardActivity.APP_EXIT_CODE);
mapActivity.startActivity(newIntent); mapActivity.startActivity(newIntent);
// In future when map will be main screen this should change // In future when map will be main screen this should change
// app.closeApplication(mapActivity); // app.closeApplication(mapActivity);

View file

@ -2,30 +2,14 @@ package net.osmand.plus.activities;
import java.io.File; import java.io.File;
import java.util.Date;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.text.SpannableString;
import android.text.format.DateFormat;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.TypedValue;
import android.view.View;
import android.widget.ScrollView;
import android.widget.TextView;
public class SettingsActivity extends SettingsBaseActivity { public class SettingsActivity extends SettingsBaseActivity {
@ -110,7 +94,7 @@ public class SettingsActivity extends SettingsBaseActivity {
startActivity(new Intent(this, SettingsNavigationActivity.class)); startActivity(new Intent(this, SettingsNavigationActivity.class));
return true; return true;
} else if (preference == about) { } else if (preference == about) {
showAboutDialog(); DashboardActivity.showAboutDialog(this, getMyApplication());
return true; return true;
} else if (preference == plugins) { } else if (preference == plugins) {
startActivityForResult(new Intent(this, getMyApplication().getAppCustomization().getPluginsActivity()), PLUGINS_SELECTION_REQUEST); startActivityForResult(new Intent(this, getMyApplication().getAppCustomization().getPluginsActivity()), PLUGINS_SELECTION_REQUEST);
@ -121,49 +105,6 @@ public class SettingsActivity extends SettingsBaseActivity {
return false; return false;
} }
private void showAboutDialog() {
Builder bld = new AlertDialog.Builder(this);
bld.setTitle(R.string.about_settings);
ScrollView sv = new ScrollView(this);
TextView tv = new TextView(this);
sv.addView(tv);
String version = Version.getFullVersion(getMyApplication());
String vt = getString(R.string.about_version) +"\t";
int st = vt.length();
String edition = "";
SharedPreferences prefs = getApplicationContext().getSharedPreferences("net.osmand.settings", MODE_WORLD_READABLE);
if (prefs.contains(CONTRIBUTION_VERSION_FLAG)) {
try {
PackageManager pm = getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(OsmandApplication.class.getPackage().getName(), 0);
Date date = new Date(new File(appInfo.sourceDir).lastModified());
edition = getString(R.string.local_index_installed) + " :\t" + DateFormat.getDateFormat(getApplicationContext()).format(date);
} catch (Exception e) {
}
SpannableString content = new SpannableString(vt + version +"\n" +
edition +"\n\n"+
getString(R.string.about_content));
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
final Intent mapIntent = new Intent(SettingsActivity.this, ContributionVersionActivity.class);
startActivityForResult(mapIntent, 0);
}
}, st, st + version.length(), 0);
tv.setText(content);
} else {
tv.setText(vt + version +"\n\n" +
getString(R.string.about_content));
}
tv.setPadding(5, 0, 5, 5);
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
tv.setMovementMethod(LinkMovementMethod.getInstance());
bld.setView(sv);
bld.setPositiveButton(R.string.default_buttons_ok, null);
bld.show();
}
} }

View file

@ -53,8 +53,9 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
public static final int POI_TAB_INDEX = 0; public static final int POI_TAB_INDEX = 0;
public static final int ADDRESS_TAB_INDEX = 1; public static final int ADDRESS_TAB_INDEX = 1;
public static final int LOCATION_TAB_INDEX = 2; public static final int LOCATION_TAB_INDEX = 2;
public static final int HISTORY_TAB_INDEX = 3; public static final int FAVORITES_TAB_INDEX = 3;
public static final int TRANSPORT_TAB_INDEX = 4; public static final int HISTORY_TAB_INDEX = 4;
public static final int TRANSPORT_TAB_INDEX = 5;
protected static final int POSITION_CURRENT_LOCATION = 1; protected static final int POSITION_CURRENT_LOCATION = 1;
protected static final int POSITION_LAST_MAP_VIEW = 2; protected static final int POSITION_LAST_MAP_VIEW = 2;

View file

@ -29,7 +29,6 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.download.DownloadIndexFragment;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.activities.SelectedGPXFragment; import net.osmand.plus.activities.SelectedGPXFragment;
@ -38,6 +37,7 @@ import net.osmand.plus.api.FileSettingsAPIImpl;
import net.osmand.plus.api.SettingsAPI; import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.DownloadIndexFragment;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.sherpafy.TourInformation.StageFavorite; import net.osmand.plus.sherpafy.TourInformation.StageFavorite;
@ -56,9 +56,7 @@ import android.os.Environment;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.view.Window;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
@ -153,29 +151,6 @@ public class SherpafyCustomization extends OsmAndAppCustomization {
return false; return false;
} }
@Override
public void customizeMainMenu(Window window, final Activity activity) {
// Update app name
TextView v = (TextView) window.findViewById(R.id.AppName);
v.setText("Sherpafy");
// TextView toursButtonText = (TextView) window.findViewById(R.id.SettingsButtonText);
// toursButtonText.setText(R.string.tour);
// View toursButton = window.findViewById(R.id.SettingsButton);
// toursButton.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View v) {
// final Intent search = new Intent(activity, getTourSelectionActivity());
// search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
// activity.startActivity(search);
// }
// });
// the image could be also updated
}
@Override @Override
public void getDownloadTypes(List<DownloadActivityType> items) { public void getDownloadTypes(List<DownloadActivityType> items) {
super.getDownloadTypes(items); super.getDownloadTypes(items);