e9b52a2e by chiangbt

update 3.26 11.37

1 parent a437ef42
...@@ -28,6 +28,7 @@ dependencies { ...@@ -28,6 +28,7 @@ dependencies {
28 compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' 28 compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
29 compile 'com.github.arimorty:floatingsearchview:2.1.1' 29 compile 'com.github.arimorty:floatingsearchview:2.1.1'
30 compile 'com.amitshekhar.android:android-networking:0.2.0' 30 compile 'com.amitshekhar.android:android-networking:0.2.0'
31 compile 'com.github.chyrta:AndroidOnboarder:0.6'
31 32
32 implementation fileTree(dir: 'libs', include: ['*.jar']) 33 implementation fileTree(dir: 'libs', include: ['*.jar'])
33 //noinspection GradleCompatible 34 //noinspection GradleCompatible
......
...@@ -15,16 +15,18 @@ ...@@ -15,16 +15,18 @@
15 android:supportsRtl="true" 15 android:supportsRtl="true"
16 android:theme="@style/AppTheme"> 16 android:theme="@style/AppTheme">
17 <activity 17 <activity
18 android:name=".MainActivity" 18 android:name=".BootActivity">
19 android:label="@string/app_name"
20 android:screenOrientation="landscape"
21 android:theme="@style/AppTheme.NoActionBar">
22 <intent-filter> 19 <intent-filter>
23 <action android:name="android.intent.action.MAIN" /> 20 <action android:name="android.intent.action.MAIN" />
24 21
25 <category android:name="android.intent.category.LAUNCHER" /> 22 <category android:name="android.intent.category.LAUNCHER" />
26 </intent-filter> 23 </intent-filter>
27 </activity> 24 </activity>
25 <activity android:name=".MainActivity"
26 android:label="@string/app_name"
27 android:theme="@style/AppTheme.NoActionBar"
28 android:screenOrientation="landscape"> <!-- 禁止屏幕旋转 -->
29 </activity>
28 </application> 30 </application>
29 31
30 </manifest> 32 </manifest>
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.pashanhoo.landsurvey;
2
3 import android.Manifest;
4 import android.content.DialogInterface;
5 import android.content.Intent;
6 import android.content.pm.PackageManager;
7 import android.net.Uri;
8 import android.os.Bundle;
9 import android.provider.Settings;
10 import android.support.v4.app.ActivityCompat;
11 import android.support.v4.content.ContextCompat;
12 import android.support.v7.app.AlertDialog;
13 import android.view.KeyEvent;
14
15 import com.chyrta.onboarder.OnboarderActivity;
16 import com.chyrta.onboarder.OnboarderPage;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21
22 /**
23 * Created by chiangbt on 2017/5/8.
24 */
25 public class BootActivity extends OnboarderActivity {
26
27 /**
28 * 需要进行检测的权限数组
29 */
30 protected String[] needPermissions = {
31 Manifest.permission.ACCESS_COARSE_LOCATION,
32 Manifest.permission.ACCESS_FINE_LOCATION,
33 Manifest.permission.WRITE_EXTERNAL_STORAGE,
34 Manifest.permission.READ_EXTERNAL_STORAGE,
35 Manifest.permission.READ_PHONE_STATE
36 };
37
38 private static final int PERMISSON_REQUESTCODE = 0;
39 /**
40 * 判断是否需要检测,防止不停的弹框
41 */
42 private boolean isNeedCheck = true;
43
44 @Override
45 protected void onCreate(Bundle savedInstanceState) {
46 super.onCreate(savedInstanceState);
47
48 // 系统权限检查
49 if(isNeedCheck){
50 checkPermissions(needPermissions);
51 }
52
53 // 引导页设置
54 OnboarderPage onboarderPage1 = new OnboarderPage("Keymap", "服务于智慧城市信息化的产品", R.drawable.planet1);
55 OnboarderPage onboarderPage2 = new OnboarderPage("国土监测", "移动,无所不知...", R.drawable.planet2);
56 OnboarderPage onboarderPage3 = new OnboarderPage("江苏爬山虎科技股份有限公司", "中国 江苏 南京/扬州", R.drawable.planet3);
57
58 onboarderPage1.setBackgroundColor(R.color.onboarder_bg_1);
59 onboarderPage2.setBackgroundColor(R.color.onboarder_bg_2);
60 onboarderPage3.setBackgroundColor(R.color.onboarder_bg_3);
61
62 List<OnboarderPage> pages = new ArrayList<>();
63
64 pages.add(onboarderPage1);
65 pages.add(onboarderPage2);
66 pages.add(onboarderPage3);
67
68 for (OnboarderPage page : pages) {
69 page.setTitleColor(R.color.primary_text);
70 page.setDescriptionColor(R.color.secondary_text);
71 }
72
73 setSkipButtonTitle("跳过");
74 setFinishButtonTitle("进入");
75
76 setOnboardPagesReady(pages);
77 }
78
79 @Override
80 public void onSkipButtonPressed() {
81 super.onSkipButtonPressed();
82 gotoMainActivity();
83 }
84
85 @Override
86 public void onFinishButtonPressed() {
87 gotoMainActivity();
88 }
89
90 private void gotoMainActivity(){
91 Intent intent = new Intent(BootActivity.this, MainActivity.class);
92 startActivity(intent);
93 // 跳转后关闭引导页
94 finish();
95 overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
96 }
97
98 // Android6的许可检查
99 private void checkPermissions(String... permissions) {
100 List<String> needRequestPermissonList = findDeniedPermissions(permissions);
101 if (null != needRequestPermissonList
102 && needRequestPermissonList.size() > 0) {
103 ActivityCompat.requestPermissions(this,
104 needRequestPermissonList.toArray(
105 new String[needRequestPermissonList.size()]),
106 PERMISSON_REQUESTCODE);
107 }
108 }
109
110 private List<String> findDeniedPermissions(String[] permissions) {
111 List<String> needRequestPermissonList = new ArrayList<String>();
112 for (String perm : permissions) {
113 if (ContextCompat.checkSelfPermission(this,
114 perm) != PackageManager.PERMISSION_GRANTED
115 || ActivityCompat.shouldShowRequestPermissionRationale(
116 this, perm)) {
117 needRequestPermissonList.add(perm);
118 }
119 }
120 return needRequestPermissonList;
121 }
122 private boolean verifyPermissions(int[] grantResults) {
123 for (int result : grantResults) {
124 if (result != PackageManager.PERMISSION_GRANTED) {
125 return false;
126 }
127 }
128 return true;
129 }
130
131 @Override
132 public void onRequestPermissionsResult(int requestCode,
133 String[] permissions, int[] paramArrayOfInt) {
134 if (requestCode == PERMISSON_REQUESTCODE) {
135 if (!verifyPermissions(paramArrayOfInt)) {
136 showMissingPermissionDialog();
137 isNeedCheck = false;
138 }
139 }
140 }
141
142 /**
143 * 显示提示信息
144 *
145 * @since 2.5.0
146 *
147 */
148 private void showMissingPermissionDialog() {
149 AlertDialog.Builder builder = new AlertDialog.Builder(this);
150 builder.setTitle(R.string.notifyTitle);
151 builder.setMessage(R.string.notifyMsg);
152
153 // 拒绝, 退出应用
154 builder.setNegativeButton(R.string.cancel,
155 new DialogInterface.OnClickListener() {
156 @Override
157 public void onClick(DialogInterface dialog, int which) {
158 finish();
159 }
160 });
161
162 builder.setPositiveButton(R.string.setting,
163 new DialogInterface.OnClickListener() {
164 @Override
165 public void onClick(DialogInterface dialog, int which) {
166 startAppSettings();
167 }
168 });
169
170 builder.setCancelable(false);
171
172 builder.show();
173 }
174
175 /**
176 * 启动应用的设置
177 *
178 * @since 2.5.0
179 *
180 */
181 private void startAppSettings() {
182 Intent intent = new Intent(
183 Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
184 intent.setData(Uri.parse("package:" + getPackageName()));
185 startActivity(intent);
186 }
187
188 @Override
189 public boolean onKeyDown(int keyCode, KeyEvent event) {
190 if(keyCode == KeyEvent.KEYCODE_BACK){
191 this.finish();
192 return true;
193 }
194 return super.onKeyDown(keyCode, event);
195 }
196 }
...@@ -40,37 +40,48 @@ import org.json.JSONObject; ...@@ -40,37 +40,48 @@ import org.json.JSONObject;
40 import java.util.ArrayList; 40 import java.util.ArrayList;
41 41
42 public class MainActivity extends AppCompatActivity { 42 public class MainActivity extends AppCompatActivity {
43 43 // 地图控件
44 private MapView mapView; 44 private MapView mapView;
45 // 地图中的GraphicsLayer对象
45 private GraphicsLayer graphicsLayer; 46 private GraphicsLayer graphicsLayer;
47 // GPS定位器对象
46 private LocationDisplayManager locationDisplayManager; 48 private LocationDisplayManager locationDisplayManager;
49 // 四个天地图图层对象
47 private TianDiTuTiledMapServiceLayer t_vec; 50 private TianDiTuTiledMapServiceLayer t_vec;
48 private TianDiTuTiledMapServiceLayer t_cva; 51 private TianDiTuTiledMapServiceLayer t_cva;
49 private TianDiTuTiledMapServiceLayer t_img; 52 private TianDiTuTiledMapServiceLayer t_img;
50 private TianDiTuTiledMapServiceLayer t_cia; 53 private TianDiTuTiledMapServiceLayer t_cia;
51 // mbtiles式天地图数据 54 // mbtiles式天地图数据
52 private TianDiTuLocalTiledMapServiceLayer t_local; 55 private TianDiTuLocalTiledMapServiceLayer t_local;
53 56 // 左下角LGOGO信息
54 private String mapType;
55 private TextView mapinfoView; 57 private TextView mapinfoView;
58 // 浮动查询条
56 private FloatingSearchView floatingSearchView; 59 private FloatingSearchView floatingSearchView;
60 // 当前地图层级
57 private int curLevel = 0; 61 private int curLevel = 0;
62 // 地图类型名称
63 private String mapType;
58 64
59 @Override 65 @Override
60 protected void onCreate(Bundle savedInstanceState) { 66 protected void onCreate(Bundle savedInstanceState) {
61 super.onCreate(savedInstanceState); 67 super.onCreate(savedInstanceState);
62 setContentView(R.layout.activity_main); 68 setContentView(R.layout.activity_main);
69 // 分别获取控件
63 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 70 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
64 mapinfoView = (TextView) findViewById(R.id.mapinfo); 71 mapinfoView = (TextView) findViewById(R.id.mapinfo);
65 floatingSearchView = (FloatingSearchView) findViewById(R.id.floating_search_view); 72 floatingSearchView = (FloatingSearchView) findViewById(R.id.floating_search_view);
66 setSupportActionBar(toolbar); 73 setSupportActionBar(toolbar);
74
67 //初始化------------------------------------------------------------------- 75 //初始化-------------------------------------------------------------------
68 AppInfo.Settings(); 76 AppInfo.Settings();
77
69 //按钮动作------------------------------------------------------------------- 78 //按钮动作-------------------------------------------------------------------
79 // 放大按钮
70 FloatingActionButton zoomin = (FloatingActionButton) findViewById(R.id.zoomin); 80 FloatingActionButton zoomin = (FloatingActionButton) findViewById(R.id.zoomin);
71 zoomin.setOnClickListener(new View.OnClickListener() { 81 zoomin.setOnClickListener(new View.OnClickListener() {
72 @Override 82 @Override
73 public void onClick(View view) { 83 public void onClick(View view) {
84 // 停止GPS
74 if (locationDisplayManager != null) { 85 if (locationDisplayManager != null) {
75 locationDisplayManager.stop(); 86 locationDisplayManager.stop();
76 } 87 }
...@@ -79,6 +90,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -79,6 +90,7 @@ public class MainActivity extends AppCompatActivity {
79 } 90 }
80 } 91 }
81 }); 92 });
93 // 缩小按钮
82 FloatingActionButton zoomout = (FloatingActionButton) findViewById(R.id.zoomout); 94 FloatingActionButton zoomout = (FloatingActionButton) findViewById(R.id.zoomout);
83 zoomout.setOnClickListener(new View.OnClickListener() { 95 zoomout.setOnClickListener(new View.OnClickListener() {
84 @Override 96 @Override
...@@ -91,16 +103,19 @@ public class MainActivity extends AppCompatActivity { ...@@ -91,16 +103,19 @@ public class MainActivity extends AppCompatActivity {
91 } 103 }
92 } 104 }
93 }); 105 });
106 // 回到初始页面
94 FloatingActionButton fullmap = (FloatingActionButton) findViewById(R.id.fullmap); 107 FloatingActionButton fullmap = (FloatingActionButton) findViewById(R.id.fullmap);
95 fullmap.setOnClickListener(new View.OnClickListener() { 108 fullmap.setOnClickListener(new View.OnClickListener() {
96 @Override 109 @Override
97 public void onClick(View view) { 110 public void onClick(View view) {
98 locationDisplayManager.stop(); 111 locationDisplayManager.stop();
112 graphicsLayer.removeAll();
99 mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); 113 mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes);
100 curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes); 114 curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes);
101 mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel)); 115 mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
102 } 116 }
103 }); 117 });
118 // GPS按钮
104 FloatingActionButton gps = (FloatingActionButton) findViewById(R.id.gps); 119 FloatingActionButton gps = (FloatingActionButton) findViewById(R.id.gps);
105 gps.setOnClickListener(new View.OnClickListener() { 120 gps.setOnClickListener(new View.OnClickListener() {
106 @Override 121 @Override
...@@ -118,7 +133,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -118,7 +133,7 @@ public class MainActivity extends AppCompatActivity {
118 mapView = (MapView) findViewById(R.id.map); 133 mapView = (MapView) findViewById(R.id.map);
119 mapView.setEsriLogoVisible(false); 134 mapView.setEsriLogoVisible(false);
120 mapView.enableWrapAround(false); 135 mapView.enableWrapAround(false);
121 136 // 添加地图图层
122 t_vec = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.VEC_C); 137 t_vec = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.VEC_C);
123 mapView.addLayer(t_vec); 138 mapView.addLayer(t_vec);
124 t_cva = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CVA_C); 139 t_cva = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CVA_C);
...@@ -126,7 +141,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -126,7 +141,7 @@ public class MainActivity extends AppCompatActivity {
126 // 一个本地sqlite数据库,注意其只有8-9级数据,因此在数据层中予以了显示控制 141 // 一个本地sqlite数据库,注意其只有8-9级数据,因此在数据层中予以了显示控制
127 t_local = new TianDiTuLocalTiledMapServiceLayer("my.db", "IMG_C"); 142 t_local = new TianDiTuLocalTiledMapServiceLayer("my.db", "IMG_C");
128 mapView.addLayer(t_local); 143 mapView.addLayer(t_local);
129 144 // 添加地图图层
130 t_img = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.IMG_C); 145 t_img = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.IMG_C);
131 t_img.setVisible(false); 146 t_img.setVisible(false);
132 mapView.addLayer(t_img); 147 mapView.addLayer(t_img);
...@@ -134,18 +149,19 @@ public class MainActivity extends AppCompatActivity { ...@@ -134,18 +149,19 @@ public class MainActivity extends AppCompatActivity {
134 t_cia.setVisible(false); 149 t_cia.setVisible(false);
135 mapView.addLayer(t_cia); 150 mapView.addLayer(t_cia);
136 mapType = "VEC"; 151 mapType = "VEC";
137 152 // 添加GraphicsLayer
138 graphicsLayer = new GraphicsLayer(); 153 graphicsLayer = new GraphicsLayer();
139 mapView.addLayer(graphicsLayer); 154 mapView.addLayer(graphicsLayer);
140 155 // 设置地图的最小和最大分辨率
141 mapView.setMaxResolution(TDTTileinfo.getRes4490()[1]); 156 mapView.setMaxResolution(TDTTileinfo.getRes4490()[1]);
142 mapView.setMinResolution(TDTTileinfo.getRes4490()[18]); 157 mapView.setMinResolution(TDTTileinfo.getRes4490()[19]);
143 158 // 监听地图状态变化事件
144 mapView.setOnStatusChangedListener(new OnStatusChangedListener() { 159 mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
145 private static final long serialVersionUID = 1L; 160 private static final long serialVersionUID = 1L;
146 161
147 @Override 162 @Override
148 public void onStatusChanged(Object o, STATUS status) { 163 public void onStatusChanged(Object o, STATUS status) {
164 // 刚刚打开时,将地图缩放到指定位置及层级
149 if (status == STATUS.INITIALIZED) { 165 if (status == STATUS.INITIALIZED) {
150 mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes); 166 mapView.zoomToResolution(AppInfo.initPoint, AppInfo.initRes);
151 curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes); 167 curLevel = TDTTileinfo.getCurrentLevel(AppInfo.initRes);
...@@ -203,19 +219,18 @@ public class MainActivity extends AppCompatActivity { ...@@ -203,19 +219,18 @@ public class MainActivity extends AppCompatActivity {
203 219
204 POISuggestion colorSuggestion = (POISuggestion) searchSuggestion; 220 POISuggestion colorSuggestion = (POISuggestion) searchSuggestion;
205 Point poipt = new Point(colorSuggestion.getLng(), colorSuggestion.getLat()); 221 Point poipt = new Point(colorSuggestion.getLng(), colorSuggestion.getLat());
206 mapView.zoomToResolution(poipt, TDTTileinfo.getRes4490()[18]); 222 mapView.zoomToResolution(poipt, TDTTileinfo.getRes4490()[19]);
207 graphicsLayer.addGraphic(new Graphic(poipt, 223 graphicsLayer.addGraphic(new Graphic(poipt,
208 new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16))); 224 new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16)));
209 // floatingSearchView.clearSuggestions(); 225 // floatingSearchView.clearSuggestions();
210 curLevel = TDTTileinfo.getCurrentLevel(mapView.getResolution()); 226 mapinfoView.setText("当前地图级别为:19");
211 mapinfoView.setText("当前地图级别为:" + String.valueOf(curLevel));
212 } 227 }
213 228
214 @Override 229 @Override
215 public void onSearchAction(String currentQuery) { 230 public void onSearchAction(String currentQuery) {
216 if (currentQuery.length() > 3) { 231 if (currentQuery.length() > 3) {
217 floatingSearchView.clearSuggestions(); 232 floatingSearchView.clearSuggestions();
218 233 // 查询天地图API
219 String str = "{\"keyWord\":\"" + currentQuery + "\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}"; 234 String str = "{\"keyWord\":\"" + currentQuery + "\",\"level\":\"11\",\"mapBound\":\"76.24832,30.1129,156.40458,49.97618\",\"queryType\":\"1\",\"count\":\"10\",\"start\":\"0\",\"queryTerminal\":\"1000\"}";
220 AndroidNetworking.post("http://map.tianditu.com/query.shtml") 235 AndroidNetworking.post("http://map.tianditu.com/query.shtml")
221 .addBodyParameter("type", "query") 236 .addBodyParameter("type", "query")
...@@ -225,6 +240,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -225,6 +240,7 @@ public class MainActivity extends AppCompatActivity {
225 .getAsJSONObject(new JSONObjectRequestListener() { 240 .getAsJSONObject(new JSONObjectRequestListener() {
226 @Override 241 @Override
227 public void onResponse(JSONObject response) { 242 public void onResponse(JSONObject response) {
243 //解析响应结果
228 JSONArray Jarray = null; 244 JSONArray Jarray = null;
229 try { 245 try {
230 Jarray = response.getJSONArray("pois"); 246 Jarray = response.getJSONArray("pois");
......
...@@ -32,9 +32,8 @@ ...@@ -32,9 +32,8 @@
32 android:layout_marginBottom="16dp" 32 android:layout_marginBottom="16dp"
33 app:floatingSearch_searchHint="地名地址检索..." 33 app:floatingSearch_searchHint="地名地址检索..."
34 app:floatingSearch_suggestionsListAnimDuration="250" 34 app:floatingSearch_suggestionsListAnimDuration="250"
35 app:floatingSearch_showSearchKey="false" 35 app:floatingSearch_showSearchKey="true"
36 app:floatingSearch_leftActionMode="showSearch" 36 app:floatingSearch_leftActionMode="showHome"
37 app:floatingSearch_menu="@menu/menu_main"
38 app:floatingSearch_close_search_on_keyboard_dismiss="true"/> 37 app:floatingSearch_close_search_on_keyboard_dismiss="true"/>
39 38
40 <android.support.v7.widget.LinearLayoutCompat 39 <android.support.v7.widget.LinearLayoutCompat
......
...@@ -3,4 +3,10 @@ ...@@ -3,4 +3,10 @@
3 <color name="colorPrimary">#3F51B5</color> 3 <color name="colorPrimary">#3F51B5</color>
4 <color name="colorPrimaryDark">#303F9F</color> 4 <color name="colorPrimaryDark">#303F9F</color>
5 <color name="colorAccent">#FF4081</color> 5 <color name="colorAccent">#FF4081</color>
6
7 <color name="onboarder_bg_1">#5fa4c4</color>
8 <color name="onboarder_bg_2">#d4774f</color>
9 <color name="onboarder_bg_3">#724abc</color>
10 <color name="primary_text">#FAFAFA</color>
11 <color name="secondary_text">#E0E0E0</color>
6 </resources> 12 </resources>
......
1 <resources> 1 <resources>
2 <string name="app_name">土地监察</string> 2 <string name="app_name">土地监察</string>
3 <string name="action_settings">切换图层</string> 3 <string name="action_settings">切换图层</string>
4
5 <string name="notifyTitle">提示</string>
6 <string name="notifyMsg">当前应用缺少必要权限。\n\n请点击\"设置\"-\"权限\"-打开所需权限。</string>
7 <string name="setting">设置</string>
8 <string name="cancel">取消</string>
9
10 <string name="drawer_item_section_header1">图层控制</string>
11 <string name="drawer_item_section_header2">版权信息</string>
4 </resources> 12 </resources>
......