照片路径

This commit is contained in:
wds 2021-08-06 22:00:02 +08:00
parent 8430b05cf8
commit ec501bc6d2
11 changed files with 125 additions and 28 deletions

View File

@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
ndkVersion '23.0.7123448'
// ndkVersion '23.0.7123448'
defaultConfig {
applicationId "com.navinfo.outdoor"

View File

@ -87,6 +87,16 @@
android:screenOrientation="portrait"/>
<activity android:name=".activity.UserActivity"
android:screenOrientation="portrait"/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.xx.xx.android7.my_provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>

View File

@ -237,7 +237,8 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
for (int i = 0; i < lineStringByVideoFileList.size(); i++) {
LatLng latLng = lineStringByVideoFileList.get(i);
if (latLng!=null){
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).alpha(0.9f)
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(ic_baseline);
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).icon(pileDescriptor).alpha(0.9f)
.flat(true)
.clockwise(false));
removables.add(marker);
@ -628,7 +629,8 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
}
sb.append("\r\n");
LatLng latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).alpha(0.9f)
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(ic_baseline);
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng).icon(pileDescriptor).alpha(0.9f)
.flat(true)
.clockwise(false));
removables.add(marker);

View File

@ -1,6 +1,7 @@
package com.navinfo.outdoor.api;
import android.app.Application;
import android.os.StrictMode;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity;
@ -95,6 +96,10 @@ public class UserApplication extends Application {
//全局统一超时重连次数默认为三次那么最差的情况会请求4次(一次原始请求三次重连请求)不需要可以设置为0;
.setRetryCount(0);
StrictMode.VmPolicy.Builder picBuilder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(picBuilder.build());
picBuilder.detectFileUriExposure();
}
}

View File

@ -91,11 +91,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
private RelativeLayout rlPanorama, rlName, rlInternalPhotos, rlElse, rlScutcheon, rlNull;
private ImageView ivPanorama, ivName, ivInternal, ivElse, ivScutcheon;
private TextView tvExamine;
private TextView tvPanorama;
private TextView tvName;
private TextView tvInternal;
private TextView tvElse;
private TextView tvScutcheon;
private TextView tvPanorama, tvName, tvInternal, tvElse, tvScutcheon;
private EditText editNameContent, editSiteContent;
private ArrayList<PhoneBean> poiBeans;
private Button btnSaveLocal;
@ -745,7 +741,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
} else {
chargingStationList.add(new File(tagInternal));
}
String tagElse = (String) ivElse.getTag();
String tagElse = (String) tvElse.getTag();
if (tagElse == null) {
Toast.makeText(getContext(), "请拍照", Toast.LENGTH_SHORT).show();
return;

View File

@ -4,8 +4,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -83,6 +85,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
private EditText editDescribe;
private RelativeLayout rlPanorama, rlName, rlInternalPhotos, rlCard, rlElse;
private ImageView ivPanorama, ivName, ivInternal, ivCard, ivElse;
private TextView tvPanorama, tvName, tvInternal, tvCard, tvElse;
public TextView tvExamine;
private EditText editNameContent, editSiteContent;
private ArrayList<PhoneBean> poiBeans;
@ -200,11 +203,18 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
tvExamine.setOnClickListener(this::onClick);
editDescribe = findViewById(R.id.edit_describe);
ivPanorama = findViewById(R.id.iv_panorama);
tvPanorama = findViewById(R.id.tv_panorama);
ivName = findViewById(R.id.iv_name);
tvName = findViewById(R.id.tv_name);
ivInternal = findViewById(R.id.iv_internal);
linearContact = findViewById(R.id.linear_contact);
tvInternal = findViewById(R.id.tv_internal);
ivCard = findViewById(R.id.iv_card);
tvCard = findViewById(R.id.tv_card);
ivElse = findViewById(R.id.iv_else);
tvElse = findViewById(R.id.tv_else);
linearContact = findViewById(R.id.linear_contact);
rlPanorama = findViewById(R.id.rl_panorama);
rlPanorama.setOnClickListener(this::onClick);
rlName = findViewById(R.id.rl_name);
@ -518,7 +528,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
break;
case R.id.btn_uploading:
poiPicList = new ArrayList<>();
String tagPanorama = (String) ivPanorama.getTag();
String name = editNameContent.getText().toString().trim();//名称
if (name == null || name.equals("")) {
Toast.makeText(getActivity(), "请输入poi 名称", Toast.LENGTH_SHORT).show();
@ -528,13 +538,14 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
Toast.makeText(getActivity(), "请确定点位", Toast.LENGTH_SHORT).show();
return;
}
String tagPanorama = (String) tvPanorama.getTag();
if (tagPanorama == null) {
Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show();
return;
} else {
poiPicList.add(new File(tagPanorama));
}
String tagName = (String) ivName.getTag();
String tagName = (String)tvName.getTag();
if (tagName == null) {
Toast.makeText(getActivity(), "请拍照", Toast.LENGTH_SHORT).show();
return;
@ -542,15 +553,15 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
poiPicList.add(new File(tagName));
}
String tagInternal = (String) ivInternal.getTag();
String tagInternal = (String) tvInternal.getTag();
if (tagInternal != null) {
poiPicList.add(new File(tagInternal));
}
String tagElse = (String) ivElse.getTag();
String tagElse = (String) tvElse.getTag();
if (tagElse != null) {
poiPicList.add(new File(tagElse));
}
String tagCard = (String) ivCard.getTag();
String tagCard = (String) tvCard.getTag();
if (tagCard != null) {
poiPicList.add(new File(tagCard));
}
@ -577,6 +588,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
break;
case R.id.rl_panorama:
Intent intentPanorama = new Intent("android.media.action.IMAGE_CAPTURE");
File file = new File(Constant.PICTURE_FOLDER+"/aaaaaa.jpg");
intentPanorama.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intentPanorama, 101);
break;
case R.id.rl_name:
@ -809,7 +822,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath1 = PhotoPathUtil.getTakePhotoPath(data, "a", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
ivPanorama.setTag(takePhotoPath1);
tvPanorama.setTag(takePhotoPath1);
ivPanorama.setImageBitmap(bitmap);//显示图像
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
@ -830,7 +843,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath2 = PhotoPathUtil.getTakePhotoPath(data, "b", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
ivName.setTag(takePhotoPath2);
tvName.setTag(takePhotoPath2);
ivName.setImageBitmap(bitmap);//显示图像
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
@ -851,7 +864,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath3 = PhotoPathUtil.getTakePhotoPath(data, "c", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
ivInternal.setTag(takePhotoPath3);
tvInternal.setTag(takePhotoPath3);
ivInternal.setImageBitmap(bitmap);//显示图像
/*int height = bitmap.getHeight();
int width = bitmap.getWidth();
@ -872,7 +885,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath4 = PhotoPathUtil.getTakePhotoPath(data, "d", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
ivCard.setTag(takePhotoPath4);
tvCard.setTag(takePhotoPath4);
ivCard.setImageBitmap(bitmap);//显示图像
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
@ -893,7 +906,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
Bundle extras = data.getExtras();//从Intent中获取附加值
Bitmap bitmap = (Bitmap) extras.get("data");//从附加值中获取返回的图像
String takePhotoPath5 = PhotoPathUtil.getTakePhotoPath(data, "e", Geohash.getInstance().encode(latLng.latitude, latLng.longitude));
ivElse.setTag(takePhotoPath5);
tvElse.setTag(takePhotoPath5);
ivElse.setImageBitmap(bitmap);//显示图像
/* int height = bitmap.getHeight();
int width = bitmap.getWidth();
@ -963,24 +976,25 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
if (phoneBean) {
String list = contactView.getList();
poiEntity.setTelPhone(list);
}
String tagPanorama = (String) ivPanorama.getTag();
String tagPanorama = (String) tvPanorama.getTag();
if (tagPanorama != null && !tagPanorama.equals("")) {
infoPhoto.add(new Info(tagPanorama));
}
String tagName = (String) ivName.getTag();
String tagName = (String) tvName.getTag();
if (tagName != null && !tagName.equals("")) {
infoPhoto.add(new Info(tagName));
}
String tagInternal = (String) ivInternal.getTag();
String tagInternal = (String) tvInternal.getTag();
if (tagInternal != null && !tagInternal.equals("")) {
infoPhoto.add(new Info(tagInternal));
}
String tagElse = (String) ivElse.getTag();
String tagElse = (String) tvElse.getTag();
if (tagElse != null && !tagElse.equals("")) {
infoPhoto.add(new Info(tagElse));
}
String tagCard = (String) ivCard.getTag();
String tagCard = (String) tvCard.getTag();
if (tagCard != null && !tagCard.equals("")) {
infoPhoto.add(new Info(tagCard));
}
@ -1005,12 +1019,12 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
poiCheckResult.setMsg("请输入 名称");
return poiCheckResult;
}
if (ivPanorama.getTag()==null){
if (tvPanorama.getTag()==null){
poiCheckResult.setCode(1);
poiCheckResult.setMsg("请 拍照");
return poiCheckResult;
}
if (ivName.getTag()==null){
if (tvName.getTag()==null){
poiCheckResult.setCode(1);
poiCheckResult.setMsg("请 拍照");
return poiCheckResult;

View File

@ -987,6 +987,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
break;
}
frameLayout.setVisibility(View.GONE);
initThread();
initList(Constant.currentLocation);
if (gatherGetFragment != null) {
fragmentTransaction.remove(gatherGetFragment);
}

View File

@ -54,7 +54,7 @@ public class PhotoPathUtil {
if (angle==0){
angle=90;
}
File file = new File(Constant.PICTURE_FOLDER, d+time+"_p"+coord+"_a"+angle+".jpg");
File file = new File(Constant.PICTURE_FOLDER+d+time+"_p"+coord+"_a"+angle+".jpg");
/***打开文件输出流*/
fileOutputStream = new FileOutputStream(file);
// 生成图片文件

View File

@ -0,0 +1,58 @@
package com.navinfo.outdoor.util;
import android.content.Intent;
import android.util.Log;
import android.widget.ImageView;
import androidx.exifinterface.media.ExifInterface;
import com.navinfo.outdoor.api.Constant;
import java.io.File;
import java.io.IOException;
import static org.greenrobot.eventbus.EventBus.TAG;
public class PhotoUtils {
public static String showPhotoAndGetPath(File file, ImageView imageView) {
return null;
}
public static File showPhotoFile(String d,String lat) {
long time=System.currentTimeMillis();
File file = new File(Constant.PICTURE_FOLDER, d+time+"_p"+lat+"_a"+0+".jpg");
return file;
}
/**
* 获取图片旋转角度
* @param filepath
* @return
*/
public static int getExifOrientation(String filepath) {
int degree = 0;
ExifInterface exif = null;
try {
exif = new ExifInterface(filepath);
} catch (IOException ex) {
Log.d(TAG, "cannot read exif" + ex);
}
if (exif != null) {
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
if (orientation != -1) {
switch(orientation) {
case ExifInterface.ORIENTATION_ROTATE_90:
degree = 90;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
degree = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
degree = 270;
break;
}
}
}
return degree;
}
}

View File

@ -0,0 +1,5 @@
<vector android:alpha="0.91" android:height="16dp"
android:tint="#91230A" android:viewportHeight="24"
android:viewportWidth="24" android:width="16dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2z"/>
</vector>

View File

@ -277,6 +277,7 @@
android:layout_height="20dp"
/>
<TextView
android:id="@+id/tv_panorama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
@ -313,6 +314,7 @@
android:layout_height="20dp"
/>
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
@ -349,6 +351,7 @@
android:layout_height="20dp"
/>
<TextView
android:id="@+id/tv_internal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
@ -391,6 +394,7 @@
android:layout_height="20dp"
/>
<TextView
android:id="@+id/tv_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
@ -427,6 +431,7 @@
android:layout_height="20dp"
/>
<TextView
android:id="@+id/tv_else"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"