Merge branch 'master' of github.com:osmandapp/Osmand
|
@ -21,7 +21,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
|
<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
|
||||||
<orderEntry type="module-library">
|
<orderEntry type="module-library">
|
||||||
<library name="bsh-core-2.0b4.jar">
|
<library name="bsh-core-2.0b4.jar">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
|
@ -105,4 +105,3 @@
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ android {
|
||||||
targetSdkVersion 21
|
targetSdkVersion 21
|
||||||
|
|
||||||
versionCode System.getenv("APK_NUMBER_VERSION")? System.getenv("APK_NUMBER_VERSION").toInteger(): versionCode
|
versionCode System.getenv("APK_NUMBER_VERSION")? System.getenv("APK_NUMBER_VERSION").toInteger(): versionCode
|
||||||
versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
|
//versionName already assigned in code
|
||||||
|
//versionName System.getenv("APK_VERSION")? System.getenv("APK_VERSION").toString(): versionName
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
|
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.8 KiB |
8
OsmAnd/res/drawable/background_tab.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_shortAnimTime">
|
||||||
|
|
||||||
|
<item android:state_pressed="true" android:drawable="@color/background_tab_pressed" />
|
||||||
|
<item android:state_focused="true" android:drawable="@color/background_tab_pressed"/>
|
||||||
|
<item android:drawable="@android:color/transparent"/>
|
||||||
|
|
||||||
|
</selector>
|
53
OsmAnd/res/layout/dash_parking_fragment.xml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@drawable/bg_cardui"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:background="@color/dashboard_blue"
|
||||||
|
android:layout_height="@dimen/dash_parking_height">
|
||||||
|
<ImageView android:id="@+id/direction_icon"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||||
|
android:layout_marginRight="@dimen/dashFavIconMargin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="vertical"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView android:id="@+id/distance"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
<TextView android:id="@+id/name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginRight="@dimen/dashFavIconMargin"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView android:id="@+id/next_turn_distance"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
<TextView android:id="@+id/next_turn"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button android:id="@+id/remove_tag"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/remove_the_tag"
|
||||||
|
style="@style/DashboardGeneralButton"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -32,6 +32,14 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<!--<fragment-->
|
||||||
|
<!--xmlns:android="http://schemas.android.com/apk/res/android"-->
|
||||||
|
<!--android:id="@+id/ParkingFragment"-->
|
||||||
|
<!--android:name="net.osmand.plus.dashboard.DashParkingFragment"-->
|
||||||
|
<!--android:layout_marginTop="@dimen/dashCardMargin"-->
|
||||||
|
<!--android:layout_width="match_parent"-->
|
||||||
|
<!--android:layout_height="wrap_content"/>-->
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/SearchFragment"
|
android:id="@+id/SearchFragment"
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginTop="?attr/actionBarSize">
|
android:layout_marginTop="?attr/actionBarSize">
|
||||||
|
|
||||||
<com.example.android.common.view.SlidingTabLayout
|
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
||||||
android:id="@+id/sliding_tabs"
|
android:id="@+id/sliding_tabs"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"/>
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
|
|
8
OsmAnd/res/layout/tab.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/tab_title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:singleLine="true" />
|
|
@ -10,6 +10,12 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
||||||
|
android:id="@+id/sliding_tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/ProgressView"
|
android:id="@+id/ProgressView"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -82,25 +88,6 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TabWidget
|
|
||||||
android:id="@android:id/tabs"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0" />
|
|
||||||
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@android:id/tabcontent"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp" />
|
|
||||||
|
|
||||||
<net.osmand.plus.CustomPager
|
<net.osmand.plus.CustomPager
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
|
|
|
@ -2006,4 +2006,7 @@ OsmAnd мае адкрыты зыходны код і актыўна разві
|
||||||
<string name="tracks">Сьляды</string>
|
<string name="tracks">Сьляды</string>
|
||||||
<string name="my_location">Маё месцазнаходжаньне</string>
|
<string name="my_location">Маё месцазнаходжаньне</string>
|
||||||
<string name="osm_editing_manage">Кіраваць</string>
|
<string name="osm_editing_manage">Кіраваць</string>
|
||||||
|
<string name="gps_status">Стан GPS</string>
|
||||||
|
<string name="parking_place">Парковачнае месца</string>
|
||||||
|
<string name="remove_the_tag">Выдаліць тэг</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -316,4 +316,8 @@
|
||||||
<string name="poi_car_wash">Neteja de cotxes</string>
|
<string name="poi_car_wash">Neteja de cotxes</string>
|
||||||
<string name="poi_fuel">Benzinera</string>
|
<string name="poi_fuel">Benzinera</string>
|
||||||
<string name="poi_charging_station">Estació de recàrrega</string>
|
<string name="poi_charging_station">Estació de recàrrega</string>
|
||||||
|
<string name="poi_seamark_wreck">Restes naufragi</string>
|
||||||
|
|
||||||
|
<string name="poi_seamark_radio_station">Emissor de radio</string>
|
||||||
|
<string name="poi_seamark_mooring">Amarratge</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1881,4 +1881,5 @@
|
||||||
<string name="version_settings_descr">Baixada de les darreres actualitzacions</string>
|
<string name="version_settings_descr">Baixada de les darreres actualitzacions</string>
|
||||||
<string name="version_settings">Versions</string>
|
<string name="version_settings">Versions</string>
|
||||||
<string name="rendering_attr_streetLighting_name">Enllumenat dels carrers</string>
|
<string name="rendering_attr_streetLighting_name">Enllumenat dels carrers</string>
|
||||||
|
<string name="gps_status">Estat GPS</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1897,4 +1897,7 @@
|
||||||
<string name="version_settings_descr">"Hent aktuelle udviklingsversioner"</string>
|
<string name="version_settings_descr">"Hent aktuelle udviklingsversioner"</string>
|
||||||
<string name="version_settings">Versioner</string>
|
<string name="version_settings">Versioner</string>
|
||||||
<string name="points">Punkter</string>
|
<string name="points">Punkter</string>
|
||||||
|
<string name="gps_status">GPS status</string>
|
||||||
|
<string name="parking_place">Parkeringsplads</string>
|
||||||
|
<string name="remove_the_tag">FJERN MÆRKET</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1901,4 +1901,10 @@
|
||||||
<string name="proxy_host_descr">Configura el hostname de tu proxy (p.e. 127.0.0.1)</string>
|
<string name="proxy_host_descr">Configura el hostname de tu proxy (p.e. 127.0.0.1)</string>
|
||||||
<string name="version_settings_descr">Descargar versiones de desarrollo (nightly builds)</string>
|
<string name="version_settings_descr">Descargar versiones de desarrollo (nightly builds)</string>
|
||||||
<string name="version_settings">Compilaciones</string>
|
<string name="version_settings">Compilaciones</string>
|
||||||
|
<string name="gps_status">Estado GPS</string>
|
||||||
|
<string name="rendering_attr_streetLighting_name">Iluminación de la calle</string>
|
||||||
|
<string name="points">Puntos</string>
|
||||||
|
<string name="tracks">Pistas</string>
|
||||||
|
<string name="my_location">Mi localización</string>
|
||||||
|
<string name="osm_editing_manage">Administrar</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1910,9 +1910,12 @@ Afghanistan, Albanie, Algérie, Allemagne, Andorre, Angola, Anguilla, Antigua-et
|
||||||
<string name="rendering_attr_streetLighting_name">Éclairage public</string>
|
<string name="rendering_attr_streetLighting_name">Éclairage public</string>
|
||||||
<string name="enable_proxy_title">Activer le mandataire HTTP</string>
|
<string name="enable_proxy_title">Activer le mandataire HTTP</string>
|
||||||
<string name="version_settings_descr">Télécharger les versions en cours développement</string>
|
<string name="version_settings_descr">Télécharger les versions en cours développement</string>
|
||||||
<string name="version_settings">Builds</string>
|
<string name="version_settings">Versions de développement</string>
|
||||||
<string name="points">Points</string>
|
<string name="points">Points</string>
|
||||||
<string name="tracks">Traces</string>
|
<string name="tracks">Traces</string>
|
||||||
<string name="my_location">Ma position</string>
|
<string name="my_location">Ma position</string>
|
||||||
<string name="osm_editing_manage">Gérer</string>
|
<string name="osm_editing_manage">Gérer</string>
|
||||||
|
<string name="gps_status">Statut GPS</string>
|
||||||
|
<string name="parking_place">Place de parking</string>
|
||||||
|
<string name="remove_the_tag">Enlever l\'attribut</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -2064,4 +2064,5 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
|
||||||
<string name="tracks">Tracce</string>
|
<string name="tracks">Tracce</string>
|
||||||
<string name="my_location">La mia posizione</string>
|
<string name="my_location">La mia posizione</string>
|
||||||
<string name="osm_editing_manage">Gestisci</string>
|
<string name="osm_editing_manage">Gestisci</string>
|
||||||
|
<string name="gps_status">Stato GPS</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -2127,4 +2127,5 @@
|
||||||
<string name="tracks">경로</string>
|
<string name="tracks">경로</string>
|
||||||
<string name="my_location">내 위치</string>
|
<string name="my_location">내 위치</string>
|
||||||
<string name="osm_editing_manage">관리</string>
|
<string name="osm_editing_manage">관리</string>
|
||||||
|
<string name="gps_status">GPS status</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -21,9 +21,11 @@
|
||||||
<dimen name="dashPadding">9dp</dimen>
|
<dimen name="dashPadding">9dp</dimen>
|
||||||
<dimen name="dashAboutTextSize">30sp</dimen>
|
<dimen name="dashAboutTextSize">30sp</dimen>
|
||||||
<dimen name="dashCardMargin">6dp</dimen>
|
<dimen name="dashCardMargin">6dp</dimen>
|
||||||
|
<dimen name="dash_parking_height">60dp</dimen>
|
||||||
|
|
||||||
<!-- TextSizes -->
|
<!-- TextSizes -->
|
||||||
<dimen name="showAllButtonTextSize">16sp</dimen>
|
<dimen name="showAllButtonTextSize">16sp</dimen>
|
||||||
<dimen name="subHeaderTextSize">21sp</dimen>
|
<dimen name="subHeaderTextSize">21sp</dimen>
|
||||||
<dimen name="dashFavNameTextSize">24sp</dimen>
|
<dimen name="dashFavNameTextSize">24sp</dimen>
|
||||||
|
<dimen name="dashParkingTextSize">24sp</dimen>
|
||||||
</resources>
|
</resources>
|
|
@ -1868,4 +1868,6 @@
|
||||||
<string name="version_settings">Сборки</string>
|
<string name="version_settings">Сборки</string>
|
||||||
<string name="tracks">Треки</string>
|
<string name="tracks">Треки</string>
|
||||||
<string name="my_location">Мое местоположение</string>
|
<string name="my_location">Мое местоположение</string>
|
||||||
|
<string name="gps_status">Статус GPS</string>
|
||||||
|
<string name="points">Точки</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1839,4 +1839,5 @@ Si cussigiat de annànghere unu o prus puntos intermedios pro megiorare sas pres
|
||||||
<string name="tracks">Rastas</string>
|
<string name="tracks">Rastas</string>
|
||||||
<string name="my_location">Positzione mea</string>
|
<string name="my_location">Positzione mea</string>
|
||||||
<string name="osm_editing_manage">Gesti</string>
|
<string name="osm_editing_manage">Gesti</string>
|
||||||
|
<string name="gps_status">Istadu GPS</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1889,4 +1889,5 @@
|
||||||
<string name="tracks">軌跡</string>
|
<string name="tracks">軌跡</string>
|
||||||
<string name="my_location">我的位置</string>
|
<string name="my_location">我的位置</string>
|
||||||
<string name="osm_editing_manage">管理</string>
|
<string name="osm_editing_manage">管理</string>
|
||||||
|
<string name="gps_status">GPS 狀態</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -7,4 +7,32 @@
|
||||||
<attr name="expandable_category_color" format="reference"/>
|
<attr name="expandable_category_color" format="reference"/>
|
||||||
<attr name="reset_image" format="reference"/>
|
<attr name="reset_image" format="reference"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
<declare-styleable name="PagerSlidingTabStrip">
|
||||||
|
<attr name="pstsIndicatorColor" format="color" />
|
||||||
|
<attr name="pstsUnderlineColor" format="color" />
|
||||||
|
<attr name="pstsDividerColor" format="color" />
|
||||||
|
<attr name="pstsDividerWidth" format="dimension" />
|
||||||
|
<attr name="pstsIndicatorHeight" format="dimension" />
|
||||||
|
<attr name="pstsUnderlineHeight" format="dimension" />
|
||||||
|
<attr name="pstsDividerPadding" format="dimension" />
|
||||||
|
<attr name="pstsTabPaddingLeftRight" format="dimension" />
|
||||||
|
<attr name="pstsScrollOffset" format="dimension" />
|
||||||
|
<attr name="pstsTabBackground" format="reference" />
|
||||||
|
<attr name="pstsShouldExpand" format="boolean" />
|
||||||
|
<attr name="pstsTextAllCaps" format="boolean" />
|
||||||
|
<attr name="pstsPaddingMiddle" format="boolean" />
|
||||||
|
<attr name="pstsTextStyle">
|
||||||
|
<flag name="normal" value="0x0" />
|
||||||
|
<flag name="bold" value="0x1" />
|
||||||
|
<flag name="italic" value="0x2" />
|
||||||
|
</attr>
|
||||||
|
<attr name="pstsTextSelectedStyle">
|
||||||
|
<flag name="normal" value="0x0" />
|
||||||
|
<flag name="bold" value="0x1" />
|
||||||
|
<flag name="italic" value="0x2" />
|
||||||
|
</attr>
|
||||||
|
<attr name="pstsTextAlpha" format="float" />
|
||||||
|
<attr name="pstsTextSelectedAlpha" format="float" />
|
||||||
|
</declare-styleable>
|
||||||
</resources>
|
</resources>
|
|
@ -14,6 +14,8 @@
|
||||||
<color name="gpx_time_span_color">#0080FF</color>
|
<color name="gpx_time_span_color">#0080FF</color>
|
||||||
|
|
||||||
|
|
||||||
|
<color name="background_tab_pressed">#1AFFFFFF</color>
|
||||||
|
|
||||||
<color name="color_transparent">#00000000</color>
|
<color name="color_transparent">#00000000</color>
|
||||||
<color name="color_favorite">#eecc22</color>
|
<color name="color_favorite">#eecc22</color>
|
||||||
<!-- style colors -->
|
<!-- style colors -->
|
||||||
|
|
|
@ -21,10 +21,12 @@
|
||||||
<dimen name="dashCardMargin">4dp</dimen>
|
<dimen name="dashCardMargin">4dp</dimen>
|
||||||
<dimen name="abp__shadow_height">4dp</dimen>
|
<dimen name="abp__shadow_height">4dp</dimen>
|
||||||
<dimen name="dashFABMargin">0dp</dimen>
|
<dimen name="dashFABMargin">0dp</dimen>
|
||||||
|
<dimen name="dash_parking_height">100dp</dimen>
|
||||||
|
|
||||||
<!-- TextSizes -->
|
<!-- TextSizes -->
|
||||||
<dimen name="showAllButtonTextSize">12sp</dimen>
|
<dimen name="showAllButtonTextSize">12sp</dimen>
|
||||||
<dimen name="subHeaderTextSize">14sp</dimen>
|
<dimen name="subHeaderTextSize">14sp</dimen>
|
||||||
<dimen name="dashFavNameTextSize">16sp</dimen>
|
<dimen name="dashFavNameTextSize">16sp</dimen>
|
||||||
<dimen name="dashProgressTextSize">18sp</dimen>
|
<dimen name="dashProgressTextSize">18sp</dimen>
|
||||||
|
<dimen name="dashParkingTextSize">24sp</dimen>
|
||||||
</resources>
|
</resources>
|
|
@ -9,6 +9,8 @@
|
||||||
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="parking_place">Parking place</string>
|
||||||
|
<string name="remove_the_tag">REMOVE THE TAG</string>
|
||||||
<string name="gps_status">GPS Status</string>
|
<string name="gps_status">GPS Status</string>
|
||||||
<string name="version_settings_descr">Download nightly builds</string>
|
<string name="version_settings_descr">Download nightly builds</string>
|
||||||
<string name="version_settings">Builds</string>
|
<string name="version_settings">Builds</string>
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
<item name="android:textSize">@dimen/subHeaderTextSize</item>
|
<item name="android:textSize">@dimen/subHeaderTextSize</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="DashParkingText">
|
||||||
|
<item name="android:textStyle">bold</item>
|
||||||
|
<item name="android:textSize">@dimen/dashParkingTextSize</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="DashboardGeneralButton">
|
<style name="DashboardGeneralButton">
|
||||||
<item name="android:layout_marginRight">@dimen/showAllButtonMarginRight</item>
|
<item name="android:layout_marginRight">@dimen/showAllButtonMarginRight</item>
|
||||||
<item name="android:layout_width">wrap_content</item>
|
<item name="android:layout_width">wrap_content</item>
|
||||||
|
|
|
@ -4,20 +4,18 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.support.v7.app.ActionBarActivity;
|
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.Window;
|
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
@ -25,16 +23,20 @@ import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
import android.widget.TabWidget;
|
import android.widget.TabWidget;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import net.osmand.plus.activities.search.SearchActivity;
|
||||||
|
import net.osmand.plus.dashboard.DashDownloadMapsFragment;
|
||||||
|
import net.osmand.plus.dashboard.DashUpdatesFragment;
|
||||||
|
import net.osmand.plus.download.IndexItem;
|
||||||
|
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FavouritesActivity extends ActionBarProgressActivity {
|
public class FavouritesActivity extends TabActivity {
|
||||||
|
|
||||||
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
||||||
private static final String TRACKS = "TRACKS";
|
private static final String TRACKS = "TRACKS";
|
||||||
|
@ -43,10 +45,8 @@ public class FavouritesActivity extends ActionBarProgressActivity {
|
||||||
public static int GPX_TAB = 1;
|
public static int GPX_TAB = 1;
|
||||||
public static int SELECTED_GPX_TAB = 2;
|
public static int SELECTED_GPX_TAB = 2;
|
||||||
public static String TAB_PARAM = "TAB_PARAM";
|
public static String TAB_PARAM = "TAB_PARAM";
|
||||||
private TabsAdapter mTabsAdapter;
|
|
||||||
private TabSpec selectedTrack;
|
private TabSpec selectedTrack;
|
||||||
private TabHost tabHost;
|
protected List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
|
@ -74,33 +74,40 @@ public class FavouritesActivity extends ActionBarProgressActivity {
|
||||||
setContentView(R.layout.search_activity_single);
|
setContentView(R.layout.search_activity_single);
|
||||||
getSupportFragmentManager().beginTransaction().add(R.id.layout, new FavouritesTreeFragment()).commit();
|
getSupportFragmentManager().beginTransaction().add(R.id.layout, new FavouritesTreeFragment()).commit();
|
||||||
} else {
|
} else {
|
||||||
setContentView(R.layout.tab_content);
|
setContentView(R.layout.search_main);
|
||||||
tabHost = (TabHost) findViewById(android.R.id.tabhost);
|
|
||||||
tabHost.setup();
|
|
||||||
|
|
||||||
|
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
||||||
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
||||||
Integer tab = settings.FAVORITES_TAB.get();
|
Integer tab = settings.FAVORITES_TAB.get();
|
||||||
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
|
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mTabsAdapter = new TabsAdapter(this, tabHost, mViewPager, settings, true);
|
|
||||||
mTabsAdapter.addTab(tabHost.newTabSpec(FAVOURITES_INFO).setIndicator(getString(R.string.my_favorites)),
|
List<TabItem> mTabs = new ArrayList<TabItem>();
|
||||||
FavouritesTreeFragment.class, null);
|
mTabs.add(getTabIndicator(R.string.my_favorites, FavouritesTreeFragment.class));
|
||||||
mTabsAdapter.addTab(tabHost.newTabSpec(TRACKS).setIndicator(getString(R.string.my_tracks)),
|
mTabs.add(getTabIndicator(R.string.my_tracks, AvailableGPXFragment.class));
|
||||||
AvailableGPXFragment.class, null);
|
mTabs.add(getTabIndicator(R.string.selected_track, SelectedGPXFragment.class));
|
||||||
selectedTrack = mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
|
|
||||||
SelectedGPXFragment.class, null);
|
setViewPagerAdapter(mViewPager, mTabs);
|
||||||
|
mSlidingTabLayout.setViewPager(mViewPager);
|
||||||
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if(intent != null) {
|
if(intent != null) {
|
||||||
int tt = intent.getIntExtra(TAB_PARAM, -1);
|
int tt = intent.getIntExtra(TAB_PARAM, -1);
|
||||||
if(tt >= 0) {
|
if(tt >= 0) {
|
||||||
tabHost.setCurrentTab(tt);
|
mViewPager.setCurrentItem(tt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tabHost.setCurrentTab(tab);
|
mViewPager.setCurrentItem(tab);
|
||||||
}
|
}
|
||||||
updateSelectedTracks();
|
updateSelectedTracks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachFragment(Fragment fragment) {
|
||||||
|
fragList.add(new WeakReference<Fragment>(fragment));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -120,7 +127,9 @@ public class FavouritesActivity extends ActionBarProgressActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSelectedTracks() {
|
public void updateSelectedTracks() {
|
||||||
if (selectedTrack != null) {
|
for (WeakReference<Fragment> ref : fragList) {
|
||||||
|
Fragment f = ref.get();
|
||||||
|
if (f instanceof SelectedGPXFragment && !f.isDetached()) {
|
||||||
GpxSelectionHelper gpx = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
|
GpxSelectionHelper gpx = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
|
||||||
String vl = getString(R.string.selected_track);
|
String vl = getString(R.string.selected_track);
|
||||||
if (gpx.isShowingAnyGpxFiles()) {
|
if (gpx.isShowingAnyGpxFiles()) {
|
||||||
|
@ -129,11 +138,11 @@ public class FavouritesActivity extends ActionBarProgressActivity {
|
||||||
} else {
|
} else {
|
||||||
vl += " (0)";
|
vl += " (0)";
|
||||||
}
|
}
|
||||||
try {
|
try{
|
||||||
((TextView)tabHost.getTabWidget().getChildAt(2).findViewById(android.R.id.title)).setText(vl);
|
((TextView)f.getView().findViewById(android.R.id.title)).setText(vl);
|
||||||
} catch (Exception e) {
|
} catch (NullPointerException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mTabsAdapter.notifyDataSetChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -479,8 +479,8 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
|
||||||
public void updateCompassValue(float value) {
|
public void updateCompassValue(float value) {
|
||||||
for (WeakReference<Fragment> ref : fragList) {
|
for (WeakReference<Fragment> ref : fragList) {
|
||||||
Fragment f = ref.get();
|
Fragment f = ref.get();
|
||||||
if (f instanceof DashFavoritesFragment && !f.isDetached()) {
|
if (f instanceof DashLocationFragment && !f.isDetached()) {
|
||||||
((DashFavoritesFragment) f).updateCompassValue(value);
|
((DashLocationFragment) f).updateCompassValue(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,8 +489,8 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
|
||||||
public void updateLocation(Location location) {
|
public void updateLocation(Location location) {
|
||||||
for (WeakReference<Fragment> ref : fragList) {
|
for (WeakReference<Fragment> ref : fragList) {
|
||||||
Fragment f = ref.get();
|
Fragment f = ref.get();
|
||||||
if (f instanceof DashFavoritesFragment && !f.isDetached()) {
|
if (f instanceof DashLocationFragment && !f.isDetached()) {
|
||||||
((DashFavoritesFragment) f).updateLocation(location);
|
((DashLocationFragment) f).updateLocation(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
79
OsmAnd/src/net/osmand/plus/activities/TabActivity.java
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Denis
|
||||||
|
* on 26.01.2015.
|
||||||
|
*/
|
||||||
|
public class TabActivity extends ActionBarProgressActivity {
|
||||||
|
|
||||||
|
protected TabItem getTabIndicator(int resId, Class<?> fragment){
|
||||||
|
return new TabItem(getString(resId), Color.DKGRAY, Color.LTGRAY, fragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TabItem {
|
||||||
|
public final CharSequence mTitle;
|
||||||
|
private final int mIndicatorColor;
|
||||||
|
private final int mDividerColor;
|
||||||
|
public final Class<?> fragment;
|
||||||
|
|
||||||
|
public TabItem(CharSequence mTitle, int mIndicatorColor, int mDividerColor, Class<?> fragment) {
|
||||||
|
this.mTitle = mTitle;
|
||||||
|
this.mIndicatorColor = mIndicatorColor;
|
||||||
|
this.mDividerColor = mDividerColor;
|
||||||
|
this.fragment = fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setViewPagerAdapter(ViewPager pager, List<TabItem> items){
|
||||||
|
pager.setAdapter(new OsmandFragmentPagerAdapter(getSupportFragmentManager(), items));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OsmandFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
|
private List<TabItem> mTabs;
|
||||||
|
|
||||||
|
public OsmandFragmentPagerAdapter(FragmentManager fm, List<TabItem> items) {
|
||||||
|
super(fm);
|
||||||
|
mTabs = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link android.support.v4.app.Fragment} to be displayed at {@code position}.
|
||||||
|
* <p>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int i) {
|
||||||
|
try {
|
||||||
|
return (Fragment) mTabs.get(i).fragment.newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return mTabs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// BEGIN_INCLUDE (pageradapter_getpagetitle)
|
||||||
|
/**
|
||||||
|
* Return the title of the item at {@code position}. This is important as what this method
|
||||||
|
* returns is what is displayed in the {@link com.example.android.common.view.SlidingTabLayout}.
|
||||||
|
* <p>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CharSequence getPageTitle(int position) {
|
||||||
|
return mTabs.get(position).mTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,8 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.FavouritesListActivity;
|
import net.osmand.plus.activities.FavouritesListActivity;
|
||||||
import net.osmand.plus.activities.FavouritesListFragment;
|
import net.osmand.plus.activities.FavouritesListFragment;
|
||||||
import net.osmand.plus.activities.NavigatePointFragment;
|
import net.osmand.plus.activities.NavigatePointFragment;
|
||||||
|
import net.osmand.plus.activities.TabActivity;
|
||||||
|
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import android.app.ActionBar;
|
import android.app.ActionBar;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -41,7 +43,7 @@ import android.widget.Button;
|
||||||
|
|
||||||
import com.example.android.common.view.SlidingTabLayout;
|
import com.example.android.common.view.SlidingTabLayout;
|
||||||
|
|
||||||
public class SearchActivity extends ActionBarActivity implements OsmAndLocationListener {
|
public class SearchActivity extends TabActivity implements OsmAndLocationListener {
|
||||||
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;
|
||||||
|
@ -72,37 +74,13 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
||||||
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
List<WeakReference<Fragment>> fragList = new ArrayList<WeakReference<Fragment>>();
|
||||||
private boolean showOnlyOneTab;
|
private boolean showOnlyOneTab;
|
||||||
|
|
||||||
private List<TabItem> mTabs = new ArrayList<TabItem>();
|
|
||||||
private ViewPager mViewPager;
|
|
||||||
private SlidingTabLayout mSlidingTabLayout;
|
|
||||||
|
|
||||||
public interface SearchActivityChild {
|
public interface SearchActivityChild {
|
||||||
|
|
||||||
public void locationUpdate(LatLon l);
|
public void locationUpdate(LatLon l);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TabItem {
|
|
||||||
private final CharSequence mTitle;
|
|
||||||
private final int mIcon;
|
|
||||||
private final int mIndicatorColor;
|
|
||||||
private final int mDividerColor;
|
|
||||||
private final Class<?> fragment;
|
|
||||||
|
|
||||||
public TabItem(CharSequence mTitle, int mIcon, int mIndicatorColor, int mDividerColor, Class<?> fragment) {
|
|
||||||
this.mTitle = mTitle;
|
|
||||||
this.mIcon = mIcon;
|
|
||||||
this.mIndicatorColor = mIndicatorColor;
|
|
||||||
this.mDividerColor = mDividerColor;
|
|
||||||
this.fragment = fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private TabItem getTabIndicator(int iconId, int resId, Class<?> fragment){
|
|
||||||
return new TabItem(getString(resId), iconId, Color.DKGRAY, Color.LTGRAY, fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((OsmandApplication) getApplication()).applyTheme(this);
|
((OsmandApplication) getApplication()).applyTheme(this);
|
||||||
|
@ -115,26 +93,23 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
||||||
showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
|
showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setTitle("");
|
getSupportActionBar().setTitle("");
|
||||||
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#39464d")));
|
getSupportActionBar().setElevation(0);
|
||||||
// getSupportActionBar().setTitle(R.string.select_search_position);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!showOnlyOneTab) {
|
if (!showOnlyOneTab) {
|
||||||
mViewPager = (ViewPager)findViewById(R.id.pager);
|
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.sliding_tabs);
|
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
||||||
|
List<TabItem> mTabs = new ArrayList<TabItem>();
|
||||||
mTabs.add(getTabIndicator(R.drawable.tab_search_poi_icon, R.string.poi, getFragment(POI_TAB_INDEX)));
|
mTabs.add(getTabIndicator(R.string.poi, getFragment(POI_TAB_INDEX)));
|
||||||
mTabs.add(getTabIndicator(R.drawable.tab_search_address_icon, R.string.address, getFragment(ADDRESS_TAB_INDEX)));
|
mTabs.add(getTabIndicator(R.string.address, getFragment(ADDRESS_TAB_INDEX)));
|
||||||
mTabs.add(getTabIndicator(R.drawable.tab_search_location_icon, R.string.search_tabs_location, getFragment(LOCATION_TAB_INDEX)));
|
mTabs.add(getTabIndicator(R.string.search_tabs_location, getFragment(LOCATION_TAB_INDEX)));
|
||||||
mTabs.add(getTabIndicator(R.drawable.tab_search_favorites_icon, R.string.favorite, getFragment(FAVORITES_TAB_INDEX)));
|
mTabs.add(getTabIndicator(R.string.favorite, getFragment(FAVORITES_TAB_INDEX)));
|
||||||
mTabs.add(getTabIndicator(R.drawable.tab_search_history_icon, R.string.history, getFragment(HISTORY_TAB_INDEX)));
|
mTabs.add(getTabIndicator(R.string.history, getFragment(HISTORY_TAB_INDEX)));
|
||||||
|
|
||||||
|
|
||||||
mViewPager.setAdapter(new SearchFragmentPagerAdapter(getSupportFragmentManager()));
|
setViewPagerAdapter(mViewPager, mTabs);
|
||||||
mSlidingTabLayout.setViewPager(mViewPager);
|
mSlidingTabLayout.setViewPager(mViewPager);
|
||||||
|
|
||||||
mViewPager.setCurrentItem(Math.min(tab , HISTORY_TAB_INDEX));
|
mViewPager.setCurrentItem(Math.min(tab, HISTORY_TAB_INDEX));
|
||||||
mSlidingTabLayout.setOnPageChangeListener(new OnPageChangeListener() {
|
mSlidingTabLayout.setOnPageChangeListener(new OnPageChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -409,43 +384,6 @@ public class SearchActivity extends ActionBarActivity implements OsmAndLocationL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SearchFragmentPagerAdapter extends FragmentPagerAdapter
|
|
||||||
/*implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener*/ {
|
|
||||||
|
|
||||||
SearchFragmentPagerAdapter(FragmentManager fm) {
|
|
||||||
super(fm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the {@link android.support.v4.app.Fragment} to be displayed at {@code position}.
|
|
||||||
* <p>
|
|
||||||
* Here we return the value returned from {@link SamplePagerItem#createFragment()}.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Fragment getItem(int i) {
|
|
||||||
try {
|
|
||||||
return (Fragment) mTabs.get(i).fragment.newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return mTabs.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
// BEGIN_INCLUDE (pageradapter_getpagetitle)
|
|
||||||
/**
|
|
||||||
* Return the title of the item at {@code position}. This is important as what this method
|
|
||||||
* returns is what is displayed in the {@link SlidingTabLayout}.
|
|
||||||
* <p>
|
|
||||||
* Here we return the value returned from {@link SamplePagerItem#getTitle()}.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public CharSequence getPageTitle(int position) {
|
|
||||||
return mTabs.get(position).mTitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -785,7 +785,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(loc != null){
|
if(loc != null){
|
||||||
DirectionDrawable draw = new DirectionDrawable(SearchPOIActivity.this, width, height, false);
|
DirectionDrawable draw = new DirectionDrawable(SearchPOIActivity.this, width, height);
|
||||||
Float h = heading;
|
Float h = heading;
|
||||||
float a = h != null ? h : 0;
|
float a = h != null ? h : 0;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ import java.io.File;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by dummy on 02.12.14.
|
* Created by Denis
|
||||||
|
* on 02.12.14.
|
||||||
*/
|
*/
|
||||||
public class DashErrorFragment extends DashBaseFragment {
|
public class DashErrorFragment extends DashBaseFragment {
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,9 @@ import android.widget.TextView;
|
||||||
* Created by Denis
|
* Created by Denis
|
||||||
* on 24.11.2014.
|
* on 24.11.2014.
|
||||||
*/
|
*/
|
||||||
public class DashFavoritesFragment extends DashBaseFragment implements FavouritesDbHelper.FavoritesUpdatedListener {
|
public class DashFavoritesFragment extends DashLocationFragment implements FavouritesDbHelper.FavoritesUpdatedListener {
|
||||||
public static final String TAG = "DASH_FAVORITES_FRAGMENT";
|
public static final String TAG = "DASH_FAVORITES_FRAGMENT";
|
||||||
private net.osmand.Location location = null;
|
private net.osmand.Location location = null;
|
||||||
private LatLon loc = null;
|
|
||||||
private Float heading = null;
|
|
||||||
|
|
||||||
private static final int ORIENTATION_0 = 0;
|
|
||||||
private static final int ORIENTATION_90 = 3;
|
|
||||||
private static final int ORIENTATION_270 = 1;
|
|
||||||
private static final int ORIENTATION_180 = 2;
|
|
||||||
|
|
||||||
private List<ImageView> arrows = new ArrayList<ImageView>();
|
private List<ImageView> arrows = new ArrayList<ImageView>();
|
||||||
List<FavouritePoint> points = new ArrayList<FavouritePoint>();
|
List<FavouritePoint> points = new ArrayList<FavouritePoint>();
|
||||||
|
@ -81,17 +74,6 @@ public class DashFavoritesFragment extends DashBaseFragment implements Favourite
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
//'location' seems actually not needed in this Fragment, as both setupFavorites and updateArrow only reference lastKnownMapLocation
|
|
||||||
//if (getMyApplication().getFavorites().getFavouritePoints().size() > 0) {
|
|
||||||
// if(!getMyApplication().getSettings().isLastKnownMapLocation()) {
|
|
||||||
// // show first time when application ran
|
|
||||||
// location = getMyApplication().getLocationProvider().getFirstTimeRunDefaultLocation();
|
|
||||||
// } else {
|
|
||||||
// location = getLocationProvider().getLastKnownLocation();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//This is used as origin for both Fav-list and direction arrows
|
//This is used as origin for both Fav-list and direction arrows
|
||||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
|
@ -157,7 +139,8 @@ public class DashFavoritesFragment extends DashBaseFragment implements Favourite
|
||||||
|
|
||||||
if(loc != null){
|
if(loc != null){
|
||||||
direction.setVisibility(View.VISIBLE);
|
direction.setVisibility(View.VISIBLE);
|
||||||
updateArrow(point, direction);
|
updateArrow(new LatLon(point.getLatitude(), point.getLongitude()), direction,
|
||||||
|
10, R.drawable.ic_destination_arrow);
|
||||||
}
|
}
|
||||||
arrows.add(direction);
|
arrows.add(direction);
|
||||||
name.setText(point.getName());
|
name.setText(point.getName());
|
||||||
|
@ -194,79 +177,22 @@ public class DashFavoritesFragment extends DashBaseFragment implements Favourite
|
||||||
|
|
||||||
for (int i = 0; i < arrows.size(); i++) {
|
for (int i = 0; i < arrows.size(); i++) {
|
||||||
arrows.get(i).setVisibility(View.VISIBLE);
|
arrows.get(i).setVisibility(View.VISIBLE);
|
||||||
updateArrow(points.get(i), arrows.get(i));
|
updateArrow(new LatLon(points.get(i).getLatitude(),points.get(i).getLongitude()),
|
||||||
|
arrows.get(i), 10, R.drawable.ic_destination_arrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateArrow(FavouritePoint point, ImageView direction) {
|
@Override
|
||||||
float[] mes = new float[2];
|
public boolean updateCompassValue(float value) {
|
||||||
LatLon l = new LatLon(point.getLatitude(), point.getLongitude());
|
if (super.updateCompassValue(value)){
|
||||||
Location.distanceBetween(l.getLatitude(), l.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes);
|
|
||||||
DirectionDrawable draw = new DirectionDrawable(getActivity(), 10, 10, true);
|
|
||||||
Float h = heading;
|
|
||||||
float a = h != null ? h : 0;
|
|
||||||
|
|
||||||
//Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation
|
|
||||||
int screenOrientation = 0;
|
|
||||||
screenOrientation = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
|
||||||
switch (screenOrientation)
|
|
||||||
{
|
|
||||||
case ORIENTATION_0: // Device default (normally portrait)
|
|
||||||
screenOrientation = 0;
|
|
||||||
break;
|
|
||||||
case ORIENTATION_90: // Landscape right
|
|
||||||
screenOrientation = 90;
|
|
||||||
break;
|
|
||||||
case ORIENTATION_270: // Landscape left
|
|
||||||
screenOrientation = 270;
|
|
||||||
break;
|
|
||||||
case ORIENTATION_180: // Upside down
|
|
||||||
screenOrientation = 180;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Looks like screenOrientation correction must not be applied for devices without compass?
|
|
||||||
Sensor compass = ((SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
|
||||||
if (compass == null) {
|
|
||||||
screenOrientation = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
draw.setAngle(mes[1] - a + 180 + screenOrientation);
|
|
||||||
|
|
||||||
direction.setImageDrawable(draw);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateCompassValue(float value) {
|
|
||||||
//heading = value;
|
|
||||||
//updateArrows();
|
|
||||||
//99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass devices
|
|
||||||
float lastHeading = heading != null ? heading : 99;
|
|
||||||
heading = value;
|
|
||||||
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
|
|
||||||
updateArrows();
|
updateArrows();
|
||||||
} else {
|
|
||||||
heading = lastHeading;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void updateLocation(Location location) {
|
public void updateLocation(Location location) {
|
||||||
//'location' seems actually not needed in this Fragment, as both setupFavorites and updateArrow only reference lastKnownMapLocation
|
super.updateLocation(location);
|
||||||
//if (location != null) {
|
|
||||||
//this.location = location;
|
|
||||||
//Next line commented out so that reference is always lastKnownMapLocation, because this is also always used as reference in setupFavorites
|
|
||||||
// loc = new LatLon(location.getLatitude(), location.getLongitude());
|
|
||||||
//} else if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
|
||||||
// loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
|
||||||
//} else {
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//This is used as origin for both Fav-list and direction arrows
|
|
||||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
|
||||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
|
||||||
} else {
|
|
||||||
loc = new LatLon(0f, 0f);
|
|
||||||
}
|
|
||||||
updateArrows();
|
updateArrows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.hardware.Sensor;
|
||||||
|
import android.hardware.SensorManager;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.views.DirectionDrawable;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Denis
|
||||||
|
* on 26.01.2015.
|
||||||
|
*/
|
||||||
|
public class DashLocationFragment extends DashBaseFragment {
|
||||||
|
|
||||||
|
private static final int ORIENTATION_0 = 0;
|
||||||
|
private static final int ORIENTATION_90 = 3;
|
||||||
|
private static final int ORIENTATION_270 = 1;
|
||||||
|
private static final int ORIENTATION_180 = 2;
|
||||||
|
|
||||||
|
protected Float heading = null;
|
||||||
|
|
||||||
|
protected LatLon loc = null;
|
||||||
|
|
||||||
|
public void updateLocation(Location location) {
|
||||||
|
//This is used as origin for both Fav-list and direction arrows
|
||||||
|
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||||
|
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
|
} else {
|
||||||
|
loc = new LatLon(0f, 0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateArrow(LatLon l, ImageView direction, int size, int resourceId) {
|
||||||
|
float[] mes = new float[2];
|
||||||
|
Location.distanceBetween(l.getLatitude(), l.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes);
|
||||||
|
DirectionDrawable draw = new DirectionDrawable(getActivity(), size, size, resourceId);
|
||||||
|
Float h = heading;
|
||||||
|
float a = h != null ? h : 0;
|
||||||
|
|
||||||
|
//Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation
|
||||||
|
int screenOrientation = 0;
|
||||||
|
screenOrientation = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
||||||
|
switch (screenOrientation)
|
||||||
|
{
|
||||||
|
case ORIENTATION_0: // Device default (normally portrait)
|
||||||
|
screenOrientation = 0;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_90: // Landscape right
|
||||||
|
screenOrientation = 90;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_270: // Landscape left
|
||||||
|
screenOrientation = 270;
|
||||||
|
break;
|
||||||
|
case ORIENTATION_180: // Upside down
|
||||||
|
screenOrientation = 180;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Looks like screenOrientation correction must not be applied for devices without compass?
|
||||||
|
Sensor compass = ((SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||||
|
if (compass == null) {
|
||||||
|
screenOrientation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw.setAngle(mes[1] - a + 180 + screenOrientation);
|
||||||
|
|
||||||
|
direction.setImageDrawable(draw);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateCompassValue(float value) {
|
||||||
|
//heading = value;
|
||||||
|
//updateArrows();
|
||||||
|
//99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass devices
|
||||||
|
float lastHeading = heading != null ? heading : 99;
|
||||||
|
heading = value;
|
||||||
|
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
heading = lastHeading;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
113
OsmAnd/src/net/osmand/plus/dashboard/DashParkingFragment.java
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Denis on
|
||||||
|
* 26.01.2015.
|
||||||
|
*/
|
||||||
|
public class DashParkingFragment extends DashLocationFragment {
|
||||||
|
ParkingPositionPlugin plugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_parking_fragment, container, false);
|
||||||
|
Typeface typeface = FontCache.getRobotoMedium(getActivity());
|
||||||
|
Button remove = (Button) view.findViewById(R.id.remove_tag);
|
||||||
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
AlertDialog dialog = plugin.showDeleteDialog(getActivity());
|
||||||
|
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
updateParkingPosition();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
remove.setTypeface(typeface);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||||
|
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
|
} else {
|
||||||
|
loc = new LatLon(0f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateParkingPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateParkingPosition() {
|
||||||
|
View mainView = getView();
|
||||||
|
if (plugin == null || plugin.getParkingPosition() == null){
|
||||||
|
mainView.setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
mainView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
LatLon position = plugin.getParkingPosition();
|
||||||
|
|
||||||
|
int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(),
|
||||||
|
loc.getLatitude(), loc.getLongitude()));
|
||||||
|
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
|
||||||
|
((TextView) mainView.findViewById(R.id.distance)).setText(distance);
|
||||||
|
//TODO add parking time
|
||||||
|
String parking_name = plugin.getParkingType() ?
|
||||||
|
getString(R.string.parking_place) : getString(R.string.parking_place);
|
||||||
|
((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
|
||||||
|
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
|
||||||
|
if (loc != null){
|
||||||
|
direction.setVisibility(View.VISIBLE);
|
||||||
|
updateArrow(position, direction, 10, R.drawable.ic_destination_arrow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateCompassValue(float value) {
|
||||||
|
if (plugin == null){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (super.updateCompassValue(value)){
|
||||||
|
updateParkingPosition();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLocation(Location location) {
|
||||||
|
super.updateLocation(location);
|
||||||
|
|
||||||
|
if (plugin == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateParkingPosition();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,9 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import android.app.FragmentManager;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
@ -13,6 +16,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.FavouritesActivity;
|
import net.osmand.plus.activities.FavouritesActivity;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
|
import net.osmand.plus.activities.TabActivity;
|
||||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
@ -30,16 +34,15 @@ import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 08.09.2014.
|
* Created by Denis
|
||||||
|
* on 08.09.2014.
|
||||||
*/
|
*/
|
||||||
public class DownloadActivity extends BaseDownloadActivity {
|
public class DownloadActivity extends BaseDownloadActivity {
|
||||||
|
|
||||||
private TabHost tabHost;
|
|
||||||
private FavouritesActivity.TabsAdapter mTabsAdapter;
|
|
||||||
|
|
||||||
private View progressView;
|
private View progressView;
|
||||||
private ProgressBar indeterminateProgressBar;
|
private ProgressBar indeterminateProgressBar;
|
||||||
private ProgressBar determinateProgressBar;
|
private ProgressBar determinateProgressBar;
|
||||||
|
@ -51,6 +54,7 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
private String initialFilter = "";
|
private String initialFilter = "";
|
||||||
private boolean singleTab;
|
private boolean singleTab;
|
||||||
|
|
||||||
|
List<TabActivity.TabItem> mTabs = new ArrayList<TabActivity.TabItem>();
|
||||||
|
|
||||||
public static final String FILTER_KEY = "filter";
|
public static final String FILTER_KEY = "filter";
|
||||||
public static final String FILTER_CAT = "filter_cat";
|
public static final String FILTER_CAT = "filter_cat";
|
||||||
|
@ -95,18 +99,17 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
getSupportFragmentManager().beginTransaction().add(R.id.layout, f, tag).commit();
|
getSupportFragmentManager().beginTransaction().add(R.id.layout, f, tag).commit();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tabHost = (TabHost) findViewById(android.R.id.tabhost);
|
|
||||||
tabHost.setup();
|
|
||||||
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
|
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
|
||||||
mTabsAdapter = new FavouritesActivity.TabsAdapter(this, tabHost, viewPager, settings, false);
|
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
||||||
mTabsAdapter.addTab(tabHost.newTabSpec("LOCAL_INDEX").setIndicator(getString(R.string.download_tab_local)),
|
|
||||||
LocalIndexesFragment.class, null);
|
|
||||||
mTabsAdapter.addTab(tabHost.newTabSpec("DOWNLOADS")
|
|
||||||
.setIndicator(getString(R.string.download_tab_downloads)), DownloadIndexFragment.class, null);
|
|
||||||
mTabsAdapter.addTab(tabHost.newTabSpec("UPDATES").setIndicator(getString(R.string.download_tab_updates)),
|
|
||||||
UpdatesIndexFragment.class, null);
|
|
||||||
|
|
||||||
tabHost.setCurrentTab(currentTab);
|
mTabs.add(new TabActivity.TabItem(getString(R.string.download_tab_local), Color.DKGRAY, Color.LTGRAY, LocalIndexesFragment.class));
|
||||||
|
mTabs.add(new TabActivity.TabItem(getString(R.string.download_tab_downloads), Color.DKGRAY, Color.LTGRAY, DownloadIndexFragment.class));
|
||||||
|
mTabs.add(new TabActivity.TabItem(getString(R.string.download_tab_updates), Color.DKGRAY, Color.LTGRAY, UpdatesIndexFragment.class));
|
||||||
|
|
||||||
|
viewPager.setAdapter(new TabActivity.OsmandFragmentPagerAdapter(getSupportFragmentManager(), mTabs));
|
||||||
|
mSlidingTabLayout.setViewPager(viewPager);
|
||||||
|
|
||||||
|
viewPager.setCurrentItem(currentTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = ((OsmandApplication)getApplication()).getSettings();
|
settings = ((OsmandApplication)getApplication()).getSettings();
|
||||||
|
|
|
@ -275,24 +275,26 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
/**
|
/**
|
||||||
* Method creates confirmation dialog for deletion of a parking location.
|
* Method creates confirmation dialog for deletion of a parking location.
|
||||||
*/
|
*/
|
||||||
private void showDeleteDialog(final MapActivity mapActivity) {
|
public AlertDialog showDeleteDialog(final Activity activity) {
|
||||||
Builder confirm = new AlertDialog.Builder(mapActivity);
|
Builder confirm = new AlertDialog.Builder(activity);
|
||||||
confirm.setTitle(mapActivity.getString(R.string.osmand_parking_delete));
|
confirm.setTitle(activity.getString(R.string.osmand_parking_delete));
|
||||||
confirm.setMessage(mapActivity.getString(R.string.osmand_parking_delete_confirm));
|
confirm.setMessage(activity.getString(R.string.osmand_parking_delete_confirm));
|
||||||
confirm.setCancelable(true);
|
confirm.setCancelable(true);
|
||||||
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
confirm.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
showDeleteEventWarning(mapActivity);
|
showDeleteEventWarning(activity);
|
||||||
if(parkingLayer != null) {
|
if(parkingLayer != null) {
|
||||||
parkingLayer.refresh();
|
parkingLayer.refresh();
|
||||||
}
|
}
|
||||||
clearParkingPosition();
|
clearParkingPosition();
|
||||||
mapActivity.getMapView().refreshMap();
|
if (activity instanceof MapActivity){
|
||||||
|
((MapActivity)activity).getMapView().refreshMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
confirm.setNegativeButton(R.string.default_buttons_cancel, null);
|
confirm.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
confirm.show();
|
return confirm.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,13 +386,13 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method shows warning, if previously the event for time-limited parking was added to Calendar app.
|
* Method shows warning, if previously the event for time-limited parking was added to Calendar app.
|
||||||
* @param mapActivity
|
* @param activity
|
||||||
*/
|
*/
|
||||||
private void showDeleteEventWarning(final MapActivity mapActivity) {
|
private void showDeleteEventWarning(final Activity activity) {
|
||||||
if (isParkingEventAdded()) {
|
if (isParkingEventAdded()) {
|
||||||
Builder deleteEventWarning = new AlertDialog.Builder(mapActivity);
|
Builder deleteEventWarning = new AlertDialog.Builder(activity);
|
||||||
deleteEventWarning.setTitle(mapActivity.getString(R.string.osmand_parking_warning));
|
deleteEventWarning.setTitle(activity.getString(R.string.osmand_parking_warning));
|
||||||
deleteEventWarning.setMessage(mapActivity.getString(R.string.osmand_parking_warning_text));
|
deleteEventWarning.setMessage(activity.getString(R.string.osmand_parking_warning_text));
|
||||||
deleteEventWarning.setNeutralButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
|
deleteEventWarning.setNeutralButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
|
@ -8,19 +8,24 @@ import android.view.WindowManager;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 10.12.2014.
|
* Created by Denis
|
||||||
|
* on 10.12.2014.
|
||||||
*/
|
*/
|
||||||
public class DirectionDrawable extends Drawable {
|
public class DirectionDrawable extends Drawable {
|
||||||
Paint paintRouteDirection;
|
Paint paintRouteDirection;
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
Context ctx;
|
Context ctx;
|
||||||
boolean favorite;
|
|
||||||
private float angle;
|
private float angle;
|
||||||
|
int resourceId = -1;
|
||||||
|
|
||||||
|
public DirectionDrawable(Context ctx, float width, float height, int resourceId) {
|
||||||
|
this(ctx, width, height);
|
||||||
|
this.resourceId = resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public DirectionDrawable(Context ctx, float width, float height, boolean favorite) {
|
public DirectionDrawable(Context ctx, float width, float height) {
|
||||||
this.favorite = favorite;
|
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
@ -47,9 +52,9 @@ public class DirectionDrawable extends Drawable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
if (favorite) {
|
if (resourceId != -1) {
|
||||||
canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth()/2);
|
canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth()/2);
|
||||||
Bitmap arrow = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.ic_destination_arrow);
|
Bitmap arrow = BitmapFactory.decodeResource(ctx.getResources(), resourceId);
|
||||||
canvas.drawBitmap(arrow, null, new Rect(0,0,arrow.getHeight(), arrow.getWidth()), null);
|
canvas.drawBitmap(arrow, null, new Rect(0,0,arrow.getHeight(), arrow.getWidth()), null);
|
||||||
} else {
|
} else {
|
||||||
canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth() / 2);
|
canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth() / 2);
|
||||||
|
@ -79,7 +84,7 @@ public class DirectionDrawable extends Drawable {
|
||||||
int w = 4;
|
int w = 4;
|
||||||
float sarrowL = 8; // side of arrow
|
float sarrowL = 8; // side of arrow
|
||||||
float harrowL = (float) Math.sqrt(2) * sarrowL; // hypotenuse of arrow
|
float harrowL = (float) Math.sqrt(2) * sarrowL; // hypotenuse of arrow
|
||||||
float hpartArrowL = (float) (harrowL - w) / 2;
|
float hpartArrowL = (harrowL - w) / 2;
|
||||||
Path path = new Path();
|
Path path = new Path();
|
||||||
path.moveTo(width / 2, height - (height - h) / 3);
|
path.moveTo(width / 2, height - (height - h) / 3);
|
||||||
path.rMoveTo(w / 2, 0);
|
path.rMoveTo(w / 2, 0);
|
||||||
|
|
|
@ -0,0 +1,778 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Andreas Stuetz <andreas.stuetz@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.osmand.plus.views.controls;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.database.DataSetObserver;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Paint.Style;
|
||||||
|
import android.graphics.Typeface;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
import android.support.v4.util.Pair;
|
||||||
|
import android.support.v4.view.ViewCompat;
|
||||||
|
import android.support.v4.view.ViewPager;
|
||||||
|
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
|
import android.widget.HorizontalScrollView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class PagerSlidingTabStrip extends HorizontalScrollView {
|
||||||
|
|
||||||
|
private static final float OPAQUE = 1.0f;
|
||||||
|
private static final float HALF_TRANSP = 0.5f;
|
||||||
|
|
||||||
|
public interface CustomTabProvider {
|
||||||
|
public View getCustomTabView(ViewGroup parent, int position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnTabReselectedListener {
|
||||||
|
public void onTabReselected(int position);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @formatter:off
|
||||||
|
private static final int[] ATTRS = new int[]{
|
||||||
|
android.R.attr.textColorPrimary,
|
||||||
|
android.R.attr.textSize,
|
||||||
|
android.R.attr.textColor,
|
||||||
|
android.R.attr.paddingLeft,
|
||||||
|
android.R.attr.paddingRight,
|
||||||
|
};
|
||||||
|
// @formatter:on
|
||||||
|
|
||||||
|
private final PagerAdapterObserver adapterObserver = new PagerAdapterObserver();
|
||||||
|
|
||||||
|
//These indexes must be related with the ATTR array above
|
||||||
|
private static final int TEXT_COLOR_PRIMARY = 0;
|
||||||
|
private static final int TEXT_SIZE_INDEX = 1;
|
||||||
|
private static final int TEXT_COLOR_INDEX = 2;
|
||||||
|
private static final int PADDING_LEFT_INDEX = 3;
|
||||||
|
private static final int PADDING_RIGHT_INDEX = 4;
|
||||||
|
|
||||||
|
private LinearLayout.LayoutParams defaultTabLayoutParams;
|
||||||
|
private LinearLayout.LayoutParams expandedTabLayoutParams;
|
||||||
|
|
||||||
|
private final PageListener pageListener = new PageListener();
|
||||||
|
private OnTabReselectedListener tabReselectedListener = null;
|
||||||
|
public OnPageChangeListener delegatePageListener;
|
||||||
|
|
||||||
|
private LinearLayout tabsContainer;
|
||||||
|
private ViewPager pager;
|
||||||
|
|
||||||
|
private int tabCount;
|
||||||
|
|
||||||
|
private int currentPosition = 0;
|
||||||
|
private float currentPositionOffset = 0f;
|
||||||
|
|
||||||
|
private Paint rectPaint;
|
||||||
|
private Paint dividerPaint;
|
||||||
|
|
||||||
|
private int indicatorColor;
|
||||||
|
private int indicatorHeight = 2;
|
||||||
|
|
||||||
|
private int underlineHeight = 0;
|
||||||
|
private int underlineColor;
|
||||||
|
|
||||||
|
private int dividerWidth = 0;
|
||||||
|
private int dividerPadding = 0;
|
||||||
|
private int dividerColor;
|
||||||
|
|
||||||
|
private int tabPadding = 12;
|
||||||
|
private int tabTextSize = 14;
|
||||||
|
private ColorStateList tabTextColor = null;
|
||||||
|
private float tabTextAlpha = HALF_TRANSP;
|
||||||
|
private float tabTextSelectedAlpha = OPAQUE;
|
||||||
|
|
||||||
|
private int padding = 0;
|
||||||
|
|
||||||
|
private boolean shouldExpand = false;
|
||||||
|
private boolean textAllCaps = true;
|
||||||
|
private boolean isPaddingMiddle = false;
|
||||||
|
|
||||||
|
private Typeface tabTypeface = null;
|
||||||
|
private int tabTypefaceStyle = Typeface.BOLD;
|
||||||
|
private int tabTypefaceSelectedStyle = Typeface.BOLD;
|
||||||
|
|
||||||
|
private int scrollOffset;
|
||||||
|
private int lastScrollX = 0;
|
||||||
|
|
||||||
|
private int tabBackgroundResId = R.drawable.background_tab;
|
||||||
|
|
||||||
|
private Locale locale;
|
||||||
|
|
||||||
|
public PagerSlidingTabStrip(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagerSlidingTabStrip(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
setFillViewport(true);
|
||||||
|
setWillNotDraw(false);
|
||||||
|
tabsContainer = new LinearLayout(context);
|
||||||
|
tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
|
tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||||
|
addView(tabsContainer);
|
||||||
|
|
||||||
|
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||||
|
scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
|
||||||
|
indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
|
||||||
|
underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
|
||||||
|
dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
|
||||||
|
tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
|
||||||
|
dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
|
||||||
|
tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);
|
||||||
|
|
||||||
|
// get system attrs (android:textSize and android:textColor)
|
||||||
|
TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
|
||||||
|
tabTextSize = a.getDimensionPixelSize(TEXT_SIZE_INDEX, tabTextSize);
|
||||||
|
ColorStateList colorStateList = a.getColorStateList(TEXT_COLOR_INDEX);
|
||||||
|
int textPrimaryColor = a.getColor(TEXT_COLOR_PRIMARY, android.R.color.white);
|
||||||
|
if (colorStateList != null) {
|
||||||
|
tabTextColor = colorStateList;
|
||||||
|
} else {
|
||||||
|
tabTextColor = getColorStateList(textPrimaryColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
underlineColor = textPrimaryColor;
|
||||||
|
dividerColor = textPrimaryColor;
|
||||||
|
indicatorColor = textPrimaryColor;
|
||||||
|
int paddingLeft = a.getDimensionPixelSize(PADDING_LEFT_INDEX, padding);
|
||||||
|
int paddingRight = a.getDimensionPixelSize(PADDING_RIGHT_INDEX, padding);
|
||||||
|
a.recycle();
|
||||||
|
|
||||||
|
//In case we have the padding they must be equal so we take the biggest
|
||||||
|
padding = Math.max(paddingLeft, paddingRight);
|
||||||
|
|
||||||
|
// get custom attrs
|
||||||
|
a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
|
||||||
|
indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
|
||||||
|
underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
|
||||||
|
dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
|
||||||
|
dividerWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerWidth, dividerWidth);
|
||||||
|
indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight, indicatorHeight);
|
||||||
|
underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight, underlineHeight);
|
||||||
|
dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding, dividerPadding);
|
||||||
|
tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
|
||||||
|
tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground, tabBackgroundResId);
|
||||||
|
shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
|
||||||
|
scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
|
||||||
|
textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);
|
||||||
|
isPaddingMiddle = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsPaddingMiddle, isPaddingMiddle);
|
||||||
|
tabTypefaceStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextStyle, Typeface.BOLD);
|
||||||
|
tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.BOLD);
|
||||||
|
tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP);
|
||||||
|
tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE);
|
||||||
|
a.recycle();
|
||||||
|
|
||||||
|
setMarginBottomTabContainer();
|
||||||
|
|
||||||
|
rectPaint = new Paint();
|
||||||
|
rectPaint.setAntiAlias(true);
|
||||||
|
rectPaint.setStyle(Style.FILL);
|
||||||
|
|
||||||
|
|
||||||
|
dividerPaint = new Paint();
|
||||||
|
dividerPaint.setAntiAlias(true);
|
||||||
|
dividerPaint.setStrokeWidth(dividerWidth);
|
||||||
|
|
||||||
|
defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||||
|
expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
|
||||||
|
|
||||||
|
if (locale == null) {
|
||||||
|
locale = getResources().getConfiguration().locale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setMarginBottomTabContainer() {
|
||||||
|
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) tabsContainer.getLayoutParams();
|
||||||
|
int bottomMargin = indicatorHeight >= underlineHeight ? indicatorHeight : underlineHeight;
|
||||||
|
mlp.setMargins(mlp.leftMargin, mlp.topMargin, mlp.rightMargin, bottomMargin);
|
||||||
|
tabsContainer.setLayoutParams(mlp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewPager(ViewPager pager) {
|
||||||
|
this.pager = pager;
|
||||||
|
if (pager.getAdapter() == null) {
|
||||||
|
throw new IllegalStateException("ViewPager does not have adapter instance.");
|
||||||
|
}
|
||||||
|
|
||||||
|
pager.setOnPageChangeListener(pageListener);
|
||||||
|
pager.getAdapter().registerDataSetObserver(adapterObserver);
|
||||||
|
adapterObserver.setAttached(true);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
tabsContainer.removeAllViews();
|
||||||
|
tabCount = pager.getAdapter().getCount();
|
||||||
|
View tabView;
|
||||||
|
for (int i = 0; i < tabCount; i++) {
|
||||||
|
|
||||||
|
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||||
|
tabView = ((CustomTabProvider) pager.getAdapter()).getCustomTabView(this, i);
|
||||||
|
} else {
|
||||||
|
tabView = LayoutInflater.from(getContext()).inflate(R.layout.tab, this, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
CharSequence title = pager.getAdapter().getPageTitle(i);
|
||||||
|
|
||||||
|
addTab(i, title, tabView);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTabStyles();
|
||||||
|
getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentPosition = pager.getCurrentItem();
|
||||||
|
currentPositionOffset = 0f;
|
||||||
|
scrollToChild(currentPosition, 0);
|
||||||
|
updateSelection(currentPosition);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTab(final int position, CharSequence title, View tabView) {
|
||||||
|
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
||||||
|
if (textView != null) {
|
||||||
|
if (title != null) textView.setText(title);
|
||||||
|
float alpha = pager.getCurrentItem() == position ? tabTextSelectedAlpha : tabTextAlpha;
|
||||||
|
ViewCompat.setAlpha(textView, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
tabView.setFocusable(true);
|
||||||
|
tabView.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (pager.getCurrentItem() != position) {
|
||||||
|
View tab = tabsContainer.getChildAt(pager.getCurrentItem());
|
||||||
|
notSelected(tab);
|
||||||
|
pager.setCurrentItem(position);
|
||||||
|
} else if (tabReselectedListener != null) {
|
||||||
|
tabReselectedListener.onTabReselected(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTabStyles() {
|
||||||
|
for (int i = 0; i < tabCount; i++) {
|
||||||
|
View v = tabsContainer.getChildAt(i);
|
||||||
|
v.setBackgroundResource(tabBackgroundResId);
|
||||||
|
v.setPadding(tabPadding, v.getPaddingTop(), tabPadding, v.getPaddingBottom());
|
||||||
|
TextView tab_title = (TextView) v.findViewById(R.id.tab_title);
|
||||||
|
|
||||||
|
if (tab_title != null) {
|
||||||
|
tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||||
|
tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||||
|
if (tabTextColor != null) {
|
||||||
|
tab_title.setTextColor(tabTextColor);
|
||||||
|
}
|
||||||
|
// setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
|
||||||
|
// pre-ICS-build
|
||||||
|
if (textAllCaps) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
|
tab_title.setAllCaps(true);
|
||||||
|
} else {
|
||||||
|
tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scrollToChild(int position, int offset) {
|
||||||
|
if (tabCount == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newScrollX = tabsContainer.getChildAt(position).getLeft() + offset;
|
||||||
|
if (position > 0 || offset > 0) {
|
||||||
|
|
||||||
|
//Half screen offset.
|
||||||
|
//- Either tabs start at the middle of the view scrolling straight away
|
||||||
|
//- Or tabs start at the begging (no padding) scrolling when indicator gets
|
||||||
|
// to the middle of the view width
|
||||||
|
newScrollX -= scrollOffset;
|
||||||
|
Pair<Float, Float> lines = getIndicatorCoordinates();
|
||||||
|
newScrollX += ((lines.second - lines.first) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newScrollX != lastScrollX) {
|
||||||
|
lastScrollX = newScrollX;
|
||||||
|
scrollTo(newScrollX, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Pair<Float, Float> getIndicatorCoordinates() {
|
||||||
|
// default: line below current tab
|
||||||
|
View currentTab = tabsContainer.getChildAt(currentPosition);
|
||||||
|
float lineLeft = currentTab.getLeft();
|
||||||
|
float lineRight = currentTab.getRight();
|
||||||
|
|
||||||
|
// if there is an offset, start interpolating left and right coordinates between current and next tab
|
||||||
|
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
|
||||||
|
|
||||||
|
View nextTab = tabsContainer.getChildAt(currentPosition + 1);
|
||||||
|
final float nextTabLeft = nextTab.getLeft();
|
||||||
|
final float nextTabRight = nextTab.getRight();
|
||||||
|
|
||||||
|
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
|
||||||
|
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
|
||||||
|
}
|
||||||
|
return new Pair<Float, Float>(lineLeft, lineRight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||||
|
if (isPaddingMiddle || padding > 0) {
|
||||||
|
//Make sure tabContainer is bigger than the HorizontalScrollView to be able to scroll
|
||||||
|
tabsContainer.setMinimumWidth(getWidth());
|
||||||
|
//Clipping padding to false to see the tabs while we pass them swiping
|
||||||
|
setClipToPadding(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tabsContainer.getChildCount() > 0) {
|
||||||
|
tabsContainer
|
||||||
|
.getChildAt(0)
|
||||||
|
.getViewTreeObserver()
|
||||||
|
.addOnGlobalLayoutListener(firstTabGlobalLayoutListener);
|
||||||
|
}
|
||||||
|
super.onLayout(changed, l, t, r, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnGlobalLayoutListener firstTabGlobalLayoutListener = new OnGlobalLayoutListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
View view = tabsContainer.getChildAt(0);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
|
getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||||
|
} else {
|
||||||
|
getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPaddingMiddle) {
|
||||||
|
int mHalfWidthFirstTab = view.getWidth() / 2;
|
||||||
|
padding = getWidth() / 2 - mHalfWidthFirstTab;
|
||||||
|
}
|
||||||
|
setPadding(padding, getPaddingTop(), padding, getPaddingBottom());
|
||||||
|
if (scrollOffset == 0) scrollOffset = getWidth() / 2 - padding;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
if (isInEditMode() || tabCount == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int height = getHeight();
|
||||||
|
// draw indicator line
|
||||||
|
rectPaint.setColor(indicatorColor);
|
||||||
|
Pair<Float, Float> lines = getIndicatorCoordinates();
|
||||||
|
canvas.drawRect(lines.first + padding, height - indicatorHeight, lines.second + padding, height, rectPaint);
|
||||||
|
// draw underline
|
||||||
|
rectPaint.setColor(underlineColor);
|
||||||
|
canvas.drawRect(padding, height - underlineHeight, tabsContainer.getWidth() + padding, height, rectPaint);
|
||||||
|
// draw divider
|
||||||
|
if (dividerWidth != 0) {
|
||||||
|
dividerPaint.setStrokeWidth(dividerWidth);
|
||||||
|
dividerPaint.setColor(dividerColor);
|
||||||
|
for (int i = 0; i < tabCount - 1; i++) {
|
||||||
|
View tab = tabsContainer.getChildAt(i);
|
||||||
|
canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnTabReselectedListener(OnTabReselectedListener tabReselectedListener) {
|
||||||
|
this.tabReselectedListener = tabReselectedListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnPageChangeListener(OnPageChangeListener listener) {
|
||||||
|
this.delegatePageListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PageListener implements OnPageChangeListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
currentPosition = position;
|
||||||
|
currentPositionOffset = positionOffset;
|
||||||
|
int offset = tabCount > 0 ? (int) (positionOffset * tabsContainer.getChildAt(position).getWidth()) : 0;
|
||||||
|
scrollToChild(position, offset);
|
||||||
|
invalidate();
|
||||||
|
if (delegatePageListener != null) {
|
||||||
|
delegatePageListener.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
if (state == ViewPager.SCROLL_STATE_IDLE) {
|
||||||
|
scrollToChild(pager.getCurrentItem(), 0);
|
||||||
|
}
|
||||||
|
//Full alpha for current item
|
||||||
|
View currentTab = tabsContainer.getChildAt(pager.getCurrentItem());
|
||||||
|
selected(currentTab);
|
||||||
|
//Half transparent for prev item
|
||||||
|
if (pager.getCurrentItem() - 1 >= 0) {
|
||||||
|
View prevTab = tabsContainer.getChildAt(pager.getCurrentItem() - 1);
|
||||||
|
notSelected(prevTab);
|
||||||
|
}
|
||||||
|
//Half transparent for next item
|
||||||
|
if (pager.getCurrentItem() + 1 <= pager.getAdapter().getCount() - 1) {
|
||||||
|
View nextTab = tabsContainer.getChildAt(pager.getCurrentItem() + 1);
|
||||||
|
notSelected(nextTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delegatePageListener != null) {
|
||||||
|
delegatePageListener.onPageScrollStateChanged(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
updateSelection(position);
|
||||||
|
if (delegatePageListener != null) {
|
||||||
|
delegatePageListener.onPageSelected(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSelection(int position) {
|
||||||
|
for (int i = 0; i < tabCount; ++i) {
|
||||||
|
View tv = tabsContainer.getChildAt(i);
|
||||||
|
final boolean selected = i == position;
|
||||||
|
tv.setSelected(selected);
|
||||||
|
if (selected) {
|
||||||
|
selected(tv);
|
||||||
|
} else {
|
||||||
|
notSelected(tv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notSelected(View tab) {
|
||||||
|
if (tab != null) {
|
||||||
|
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
||||||
|
ViewCompat.setAlpha(title, tabTextAlpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selected(View tab) {
|
||||||
|
if (tab != null) {
|
||||||
|
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
||||||
|
if (title != null) {
|
||||||
|
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
||||||
|
ViewCompat.setAlpha(title, tabTextSelectedAlpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PagerAdapterObserver extends DataSetObserver {
|
||||||
|
|
||||||
|
private boolean attached = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChanged() {
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttached(boolean attached) {
|
||||||
|
this.attached = attached;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAttached() {
|
||||||
|
return attached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
if (pager != null) {
|
||||||
|
if (!adapterObserver.isAttached()) {
|
||||||
|
pager.getAdapter().registerDataSetObserver(adapterObserver);
|
||||||
|
adapterObserver.setAttached(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
if (pager != null) {
|
||||||
|
if (adapterObserver.isAttached()) {
|
||||||
|
pager.getAdapter().unregisterDataSetObserver(adapterObserver);
|
||||||
|
adapterObserver.setAttached(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRestoreInstanceState(Parcelable state) {
|
||||||
|
SavedState savedState = (SavedState) state;
|
||||||
|
super.onRestoreInstanceState(savedState.getSuperState());
|
||||||
|
currentPosition = savedState.currentPosition;
|
||||||
|
if (currentPosition != 0 && tabsContainer.getChildCount() > 0) {
|
||||||
|
notSelected(tabsContainer.getChildAt(0));
|
||||||
|
selected(tabsContainer.getChildAt(currentPosition));
|
||||||
|
}
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Parcelable onSaveInstanceState() {
|
||||||
|
Parcelable superState = super.onSaveInstanceState();
|
||||||
|
SavedState savedState = new SavedState(superState);
|
||||||
|
savedState.currentPosition = currentPosition;
|
||||||
|
return savedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class SavedState extends BaseSavedState {
|
||||||
|
int currentPosition;
|
||||||
|
|
||||||
|
public SavedState(Parcelable superState) {
|
||||||
|
super(superState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SavedState(Parcel in) {
|
||||||
|
super(in);
|
||||||
|
currentPosition = in.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
super.writeToParcel(dest, flags);
|
||||||
|
dest.writeInt(currentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
|
||||||
|
@Override
|
||||||
|
public SavedState createFromParcel(Parcel in) {
|
||||||
|
return new SavedState(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SavedState[] newArray(int size) {
|
||||||
|
return new SavedState[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndicatorColor() {
|
||||||
|
return this.indicatorColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndicatorHeight() {
|
||||||
|
return indicatorHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUnderlineColor() {
|
||||||
|
return underlineColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDividerColor() {
|
||||||
|
return dividerColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDividerWidth() {
|
||||||
|
return dividerWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUnderlineHeight() {
|
||||||
|
return underlineHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDividerPadding() {
|
||||||
|
return dividerPadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScrollOffset() {
|
||||||
|
return scrollOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getShouldExpand() {
|
||||||
|
return shouldExpand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTextSize() {
|
||||||
|
return tabTextSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTextAllCaps() {
|
||||||
|
return textAllCaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorStateList getTextColor() {
|
||||||
|
return tabTextColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTabBackground() {
|
||||||
|
return tabBackgroundResId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTabPaddingLeftRight() {
|
||||||
|
return tabPadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndicatorColor(int indicatorColor) {
|
||||||
|
this.indicatorColor = indicatorColor;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndicatorColorResource(int resId) {
|
||||||
|
this.indicatorColor = getResources().getColor(resId);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndicatorHeight(int indicatorLineHeightPx) {
|
||||||
|
this.indicatorHeight = indicatorLineHeightPx;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnderlineColor(int underlineColor) {
|
||||||
|
this.underlineColor = underlineColor;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnderlineColorResource(int resId) {
|
||||||
|
this.underlineColor = getResources().getColor(resId);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDividerColor(int dividerColor) {
|
||||||
|
this.dividerColor = dividerColor;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDividerColorResource(int resId) {
|
||||||
|
this.dividerColor = getResources().getColor(resId);
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDividerWidth(int dividerWidthPx) {
|
||||||
|
this.dividerWidth = dividerWidthPx;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnderlineHeight(int underlineHeightPx) {
|
||||||
|
this.underlineHeight = underlineHeightPx;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDividerPadding(int dividerPaddingPx) {
|
||||||
|
this.dividerPadding = dividerPaddingPx;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScrollOffset(int scrollOffsetPx) {
|
||||||
|
this.scrollOffset = scrollOffsetPx;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShouldExpand(boolean shouldExpand) {
|
||||||
|
this.shouldExpand = shouldExpand;
|
||||||
|
if (pager != null) {
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllCaps(boolean textAllCaps) {
|
||||||
|
this.textAllCaps = textAllCaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextSize(int textSizePx) {
|
||||||
|
this.tabTextSize = textSizePx;
|
||||||
|
updateTabStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(int textColor) {
|
||||||
|
setTextColor(getColorStateList(textColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
private ColorStateList getColorStateList(int textColor) {
|
||||||
|
return new ColorStateList(new int[][]{new int[]{}}, new int[]{textColor});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColor(ColorStateList colorStateList) {
|
||||||
|
this.tabTextColor = colorStateList;
|
||||||
|
updateTabStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColorResource(int resId) {
|
||||||
|
setTextColor(getResources().getColor(resId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextColorStateListResource(int resId) {
|
||||||
|
setTextColor(getResources().getColorStateList(resId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeface(Typeface typeface, int style) {
|
||||||
|
this.tabTypeface = typeface;
|
||||||
|
this.tabTypefaceSelectedStyle = style;
|
||||||
|
updateTabStyles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTabBackground(int resId) {
|
||||||
|
this.tabBackgroundResId = resId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTabPaddingLeftRight(int paddingPx) {
|
||||||
|
this.tabPadding = paddingPx;
|
||||||
|
updateTabStyles();
|
||||||
|
}
|
||||||
|
}
|