@ -0,0 +1,6 @@
|
||||
projectKey=Test
|
||||
serverUrl=http://localhost:9000
|
||||
serverVersion=9.9.0.65466
|
||||
dashboardUrl=http://localhost:9000/dashboard?id=Test
|
||||
ceTaskId=AYu0FgJhk-ulwfDUJI5I
|
||||
ceTaskUrl=http://localhost:9000/api/ce/task?id=AYu0FgJhk-ulwfDUJI5I
|
@ -0,0 +1,88 @@
|
||||
package com.example.myapplication.ui.dashboard;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.example.myapplication.databinding.FragmentDashboardBinding;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.tencent.lbssearch.TencentSearch;
|
||||
import com.tencent.lbssearch.httpresponse.HttpResponseListener;
|
||||
import com.tencent.lbssearch.object.param.WalkingParam;
|
||||
import com.tencent.lbssearch.object.result.WalkingResultObject;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class MapActivity extends Fragment {
|
||||
|
||||
private TextureMapView mapView;
|
||||
private FloatingActionButton currentPositioning;
|
||||
private FloatingActionButton nearbyTrashBinChoose;
|
||||
private FloatingActionButton navigation;
|
||||
private FragmentDashboardBinding binding;
|
||||
private MapPositioning controller;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
MapActivityViewModel dashboardViewModel = new ViewModelProvider(this).get(MapActivityViewModel.class);
|
||||
|
||||
TencentMapInitializer.setAgreePrivacy(true);
|
||||
|
||||
binding = FragmentDashboardBinding.inflate(inflater, container, false);
|
||||
|
||||
View root = binding.getRoot();
|
||||
|
||||
mapView = root.findViewById(R.id.mapview);
|
||||
|
||||
currentPositioning = root.findViewById(R.id.Get_Current_Location);
|
||||
|
||||
nearbyTrashBinChoose = root.findViewById(R.id.check_nearby_trash_cans);
|
||||
|
||||
navigation = root.findViewById(R.id.navigiation);
|
||||
|
||||
controller = new MapPositioning(mapView, binding,getActivity());
|
||||
|
||||
currentPositioning.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
controller.onClickCurrentPositioning();
|
||||
}
|
||||
});
|
||||
|
||||
nearbyTrashBinChoose.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
controller.onClickNearbyTrashBinChoose();
|
||||
}
|
||||
});
|
||||
|
||||
navigation.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
controller.onClickNavigation();
|
||||
}
|
||||
});
|
||||
|
||||
controller.startLocationUpdates();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
controller.stopLocationUpdates();
|
||||
mapView.onDestroy();
|
||||
binding = null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.myapplication.ui.dashboard;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class MapActivityViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<String> mText;
|
||||
|
||||
public MapActivityViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is dashboard fragment");
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
package com.example.myapplication.ui.dashboard;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.myapplication.databinding.FragmentDashboardBinding;
|
||||
import com.tencent.lbssearch.TencentSearch;
|
||||
import com.tencent.lbssearch.httpresponse.HttpResponseListener;
|
||||
import com.tencent.lbssearch.object.param.WalkingParam;
|
||||
import com.tencent.lbssearch.object.result.WalkingResultObject;
|
||||
import com.tencent.map.geolocation.TencentLocationManager;
|
||||
import com.tencent.map.geolocation.TencentLocationRequest;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MapPositioning {
|
||||
|
||||
private TextureMapView mapView;
|
||||
private TencentMap tencentMap;
|
||||
private FragmentDashboardBinding binding;
|
||||
|
||||
private List<LatLng> TrashBin;
|
||||
|
||||
private FragmentActivity fragmentActivity;
|
||||
|
||||
static double currentLatitude;
|
||||
|
||||
static double currentLongitude;
|
||||
|
||||
TencentSearch tencentSearch;
|
||||
|
||||
WalkingParam walkingParam;
|
||||
|
||||
LatLng chooseTrashBin;
|
||||
|
||||
public float calculateDistance(LatLng start, LatLng end) {//计算所有标记垃圾桶与当前位置的距离
|
||||
double earthRadius = 6371;
|
||||
|
||||
double lat1 = Math.toRadians(start.getLatitude());
|
||||
|
||||
double lon1 = Math.toRadians(start.getLongitude());
|
||||
|
||||
double lat2 = Math.toRadians(end.getLatitude());
|
||||
|
||||
double lon2 = Math.toRadians(end.getLongitude());
|
||||
|
||||
double deltaLat = lat2 - lat1;
|
||||
|
||||
double deltaLon = lon2 - lon1;
|
||||
|
||||
double a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2)
|
||||
+ Math.cos(lat1) * Math.cos(lat2)
|
||||
* Math.sin(deltaLon / 2) * Math.sin(deltaLon / 2);
|
||||
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
|
||||
return (float) (earthRadius * c);
|
||||
}
|
||||
private HttpResponseListener<WalkingResultObject> httpResponseListener;
|
||||
|
||||
public MapPositioning(TextureMapView mapView, FragmentDashboardBinding binding,FragmentActivity activity) {//初始化,
|
||||
this.mapView = mapView;
|
||||
this.binding = binding;
|
||||
tencentMap = mapView.getMap();
|
||||
tencentMap.setMyLocationEnabled(true);
|
||||
tencentMap.enableMultipleInfowindow(true);
|
||||
fragmentActivity=activity;
|
||||
TrashBin=new ArrayList<>();
|
||||
|
||||
TrashBin.add(new LatLng(39.111981,117.350131));//添加垃圾桶位置信息
|
||||
|
||||
TrashBin.add(new LatLng(39.112578,117.349414));
|
||||
|
||||
TrashBin.add(new LatLng(39.112062,117.349687));
|
||||
|
||||
TrashBin.add(new LatLng(39.1162,117.350954));
|
||||
|
||||
TrashBin.add(new LatLng(39.115949,117.351535));
|
||||
|
||||
TrashBin.add(new LatLng(39.115614,117.351487));
|
||||
|
||||
TrashBin.add(new LatLng(39.115767,117.351119));
|
||||
|
||||
tencentSearch=new TencentSearch(mapView.getContext());
|
||||
|
||||
httpResponseListener = new HttpResponseListener<WalkingResultObject>() {
|
||||
@Override
|
||||
public void onSuccess(int i, WalkingResultObject walkingResultObject) {
|
||||
if(walkingParam==null)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
for(WalkingResultObject.Route route:walkingResultObject.result.routes)
|
||||
{
|
||||
List<LatLng> polyline = route.polyline;
|
||||
|
||||
tencentMap.addPolyline(new PolylineOptions().addAll(polyline).width(5f).color(Color.RED));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int i, String s, Throwable throwable) {
|
||||
|
||||
}
|
||||
};
|
||||
tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() {//根据当前上一次的点击事件,判断是否为双击事件,如果是双击事件就进行导航
|
||||
private long lastClickTime;
|
||||
@Override
|
||||
public boolean onMarkerClick(Marker marker) {
|
||||
long clicktime=System.currentTimeMillis();
|
||||
|
||||
if(clicktime-lastClickTime<1000)
|
||||
{
|
||||
LatLng now = marker.getPosition();
|
||||
|
||||
walkingParam=new WalkingParam(new LatLng(currentLatitude,currentLongitude),now);
|
||||
|
||||
tencentSearch.getRoutePlan(walkingParam, httpResponseListener);
|
||||
}
|
||||
lastClickTime=clicktime;
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onClickCurrentPositioning() {//发送请求,获取当前位置信息
|
||||
String message = "当前位置:纬度:" + currentLatitude + ",经度:" + currentLongitude;
|
||||
|
||||
Toast.makeText(mapView.getContext(), message, Toast.LENGTH_SHORT).show();
|
||||
|
||||
tencentMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(currentLatitude,currentLongitude)));
|
||||
}
|
||||
|
||||
public void onClickNearbyTrashBinChoose() {//显示附近的垃圾桶位置信息
|
||||
long st=System.currentTimeMillis();
|
||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
|
||||
for(LatLng trashBin:TrashBin)
|
||||
{
|
||||
tencentMap.addMarker(new MarkerOptions(trashBin));
|
||||
}
|
||||
|
||||
builder.include(new LatLng(currentLatitude,currentLongitude));
|
||||
|
||||
for(LatLng trashBin:TrashBin)
|
||||
{
|
||||
builder.include(trashBin);
|
||||
}
|
||||
LatLngBounds bounds = builder.build();
|
||||
|
||||
int padding=100;
|
||||
|
||||
CameraUpdate cameraUpdate=CameraUpdateFactory.newLatLngBounds(bounds,padding);
|
||||
|
||||
tencentMap.moveCamera(cameraUpdate);
|
||||
long ed=System.currentTimeMillis();
|
||||
System.out.println(ed);
|
||||
}
|
||||
|
||||
public void onClickNavigation() {//进行导航功能
|
||||
double shortestDistance=Double.MAX_VALUE;
|
||||
|
||||
LatLng now = new LatLng(currentLatitude, currentLongitude);
|
||||
|
||||
for(LatLng trashBin:TrashBin)//获取所有垃圾桶位置信息并计算距离
|
||||
{
|
||||
double distance=calculateDistance(now,trashBin);
|
||||
|
||||
if(distance<shortestDistance)
|
||||
{
|
||||
shortestDistance=distance;
|
||||
|
||||
chooseTrashBin=trashBin;
|
||||
}
|
||||
}
|
||||
walkingParam = new WalkingParam(now,chooseTrashBin);
|
||||
|
||||
tencentSearch.getRoutePlan(walkingParam,httpResponseListener);
|
||||
|
||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
||||
|
||||
builder.include(now);
|
||||
|
||||
builder.include(chooseTrashBin);
|
||||
|
||||
LatLngBounds bounds = builder.build();
|
||||
|
||||
int padding=100;
|
||||
|
||||
CameraUpdate cameraUpdate=CameraUpdateFactory.newLatLngBounds(bounds,padding);
|
||||
|
||||
tencentMap.moveCamera(cameraUpdate);
|
||||
}
|
||||
|
||||
public void startLocationUpdates() {//更新地图位置信息
|
||||
TencentLocationManager mLocationManager=TencentLocationManager.getInstance(fragmentActivity,null);
|
||||
|
||||
mLocationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
|
||||
|
||||
TencentLocationRequest request= TencentLocationRequest.create();
|
||||
|
||||
request.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA);
|
||||
|
||||
MyLocationListener myLocationListener=new MyLocationListener(tencentMap,fragmentActivity);
|
||||
|
||||
request.setInterval(3000);
|
||||
|
||||
mLocationManager.requestLocationUpdates(request,myLocationListener,TencentLocationRequest.REQUEST_LEVEL_GEO);
|
||||
}
|
||||
|
||||
public void stopLocationUpdates() {//停止地图位置信息控制
|
||||
TencentLocationManager mLocationManager=TencentLocationManager.getInstance(fragmentActivity,null);
|
||||
|
||||
MyLocationListener myLocationListener=new MyLocationListener(tencentMap,fragmentActivity);
|
||||
|
||||
mLocationManager.removeUpdates(myLocationListener);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package com.example.myapplication.ui.dashboard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.map.geolocation.TencentLocationListener;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapNavi;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
|
||||
public class MyLocationListener implements TencentLocationListener, SensorEventListener {
|
||||
private final int TIME_SENSOR = 10;
|
||||
private TencentMap tencentMap;
|
||||
private Marker marker;
|
||||
private FragmentActivity activity;
|
||||
private long lastTime;
|
||||
private static float mAngle;
|
||||
|
||||
private Sensor orientationSensor;
|
||||
private SensorManager sensorManager;
|
||||
|
||||
public MyLocationListener(TencentMap tencentMap, FragmentActivity activity) {
|
||||
this.tencentMap = tencentMap;
|
||||
this.activity = activity;
|
||||
this.lastTime = System.currentTimeMillis();
|
||||
sensorManager = (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE);
|
||||
orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
|
||||
sensorManager.registerListener(this, orientationSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(TencentLocation location, int error, String reason) {//发送请求
|
||||
if (error == TencentLocation.ERROR_OK) {
|
||||
// 定位成功
|
||||
double latitude = location.getLatitude();
|
||||
double longitude = location.getLongitude();
|
||||
MapPositioning.currentLatitude=latitude;
|
||||
MapPositioning.currentLongitude=longitude;
|
||||
Log.d("latitude", "onLocationChanged: "+latitude);
|
||||
Log.d("longitude","onLocationChanged"+longitude);
|
||||
LatLng latLng = new LatLng(latitude, longitude);
|
||||
|
||||
if (marker != null) {
|
||||
marker.remove(); // 清除之前的标记
|
||||
}
|
||||
marker = tencentMap.addMarker(new MarkerOptions(latLng));
|
||||
marker.setRotation(mAngle);// 自定义标记图标
|
||||
} else {
|
||||
// 处理定位失败的情况
|
||||
Toast.makeText(activity, "定位失败:" + reason, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusUpdate(String name, int status, String desc) {
|
||||
// 处理位置提供者状态变化的情况
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGnssInfoChanged(Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNmeaMsgChanged(String s) {
|
||||
|
||||
}
|
||||
|
||||
public static int getScreenRotationOnPhone(Context context) {//获取手机的角度信息
|
||||
final Display display = ((WindowManager) context
|
||||
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||
|
||||
switch (display.getRotation()) {
|
||||
case Surface.ROTATION_0:
|
||||
return 0;
|
||||
|
||||
case Surface.ROTATION_90:
|
||||
return 90;
|
||||
|
||||
case Surface.ROTATION_180:
|
||||
return 180;
|
||||
|
||||
case Surface.ROTATION_270:
|
||||
return -90;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {//获取当前手机的方向
|
||||
if (System.currentTimeMillis() - lastTime < TIME_SENSOR) {
|
||||
return;
|
||||
}
|
||||
switch (event.sensor.getType()) {
|
||||
case Sensor.TYPE_ORIENTATION: {
|
||||
float x = event.values[0];
|
||||
x += getScreenRotationOnPhone(activity);
|
||||
x %= 360.0F;
|
||||
if (x > 180.0F)
|
||||
x -= 360.0F;
|
||||
else if (x < -180.0F)
|
||||
x += 360.0F;
|
||||
|
||||
if (Math.abs(mAngle - x) < 3.0f) {
|
||||
break;
|
||||
}
|
||||
mAngle = Float.isNaN(x) ? 0 : x;
|
||||
if (marker != null) {
|
||||
marker.setRotation(mAngle);
|
||||
}
|
||||
lastTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CameraPreview extends AppCompatActivity {
|
||||
|
||||
private static final int REQUEST_IMAGE_CAPTURE = 1;
|
||||
private static final int REQUEST_PERMISSION_CAMERA = 2;
|
||||
|
||||
private ImageView imageView;
|
||||
private File photoFile;
|
||||
|
||||
private String fileName;
|
||||
|
||||
public int flag;
|
||||
|
||||
FloatingActionButton capture,upload;
|
||||
|
||||
Bitmap bitmap;
|
||||
|
||||
private final static int RESULT_RECOGNITON=114514;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.capture);
|
||||
this.getSupportActionBar().hide();
|
||||
imageView = findViewById(R.id.show_photo);
|
||||
capture=findViewById(R.id.recapture);
|
||||
upload=findViewById(R.id.transmit);
|
||||
capture.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
checkCameraPermission();
|
||||
}
|
||||
});
|
||||
upload.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ImageUploader.setImageUploadCallback(new ImageUploadCallback() {//上传图片
|
||||
public void onResultChanged(String result) {
|
||||
int resultType = 0;
|
||||
Log.d("resultss",result);
|
||||
if ("可回收垃圾".equals(result)) {
|
||||
resultType = 1;
|
||||
} else if ("湿垃圾".equals(result)) {
|
||||
resultType = 2;
|
||||
} else if ("非生活垃圾".equals(result)||"干垃圾".equals(result)) {
|
||||
resultType = 3;
|
||||
}
|
||||
else {
|
||||
resultType=4;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(CameraPreview.this, ResultActivity.class);
|
||||
intent.putExtra("result", resultType);
|
||||
intent.putExtra("photoUrl", photoFile.getAbsolutePath());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
ImageUploader.imageUpload(photoFile.getAbsolutePath());
|
||||
}
|
||||
});
|
||||
checkCameraPermission();
|
||||
}
|
||||
|
||||
private void checkCameraPermission() {//检查相机权限
|
||||
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED ||
|
||||
checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_PERMISSION_CAMERA);
|
||||
} else {
|
||||
dispatchTakePictureIntent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {//当接受相机返回结果
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_PERMISSION_CAMERA) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED &&
|
||||
grantResults[1] == PackageManager.PERMISSION_GRANTED) {
|
||||
dispatchTakePictureIntent();
|
||||
} else {
|
||||
Toast.makeText(this, "Camera permission denied.", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File createImageFile() throws IOException {
|
||||
fileName= UUID.randomUUID().toString();
|
||||
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||
File imageFile = File.createTempFile(fileName, ".jpg", storageDir);
|
||||
return imageFile;
|
||||
}
|
||||
|
||||
private void dispatchTakePictureIntent() {
|
||||
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
|
||||
try {
|
||||
photoFile = createImageFile();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
if (photoFile != null) {
|
||||
Uri photoURI = FileProvider.getUriForFile(this, "com.example.myapplication.fileprovider", photoFile);
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
|
||||
}
|
||||
}
|
||||
|
||||
private void galleryAddPic() {
|
||||
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
Uri contentUri = Uri.fromFile(photoFile);
|
||||
mediaScanIntent.setData(contentUri);
|
||||
sendBroadcast(mediaScanIntent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
|
||||
// 照片已成功保存到指定文件,将其添加到系统相册
|
||||
galleryAddPic();
|
||||
// 显示拍摄的照片
|
||||
setPic();
|
||||
}
|
||||
else
|
||||
{
|
||||
finish();
|
||||
}
|
||||
}
|
||||
private void setPic() {//显示对应的照片
|
||||
// 获取保存的图片文件
|
||||
if (photoFile != null) {
|
||||
// 解析图片文件为 Bitmap
|
||||
bitmap = BitmapFactory.decodeFile(photoFile.getAbsolutePath());
|
||||
// 设置到 ImageView 上显示
|
||||
imageView.setImageBitmap(bitmap);
|
||||
ByteArrayOutputStream stream =new ByteArrayOutputStream();
|
||||
byte[] bytes = stream.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.example.myapplication.ui.Buttonfragments.HazardGarbageFragment;
|
||||
import com.example.myapplication.ui.Buttonfragments.KitchenGarbageFragment;
|
||||
import com.example.myapplication.ui.Buttonfragments.OtherGarbageFragment;
|
||||
import com.example.myapplication.ui.Buttonfragments.RecycleGarbageFragment;
|
||||
|
||||
public class GarbageRecognition {
|
||||
private static GarbageRecognition instance;
|
||||
|
||||
private GarbageRecognitionActivity fragment;
|
||||
private GarbageRecognition() {}
|
||||
|
||||
public static GarbageRecognition getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new GarbageRecognition();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void setFragment(GarbageRecognitionActivity fragment) {
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
public void onRecyclableGarbageButtonClick() {//转化到可回收垃圾的介绍界面
|
||||
FragmentManager fragmentManager = fragment.getParentFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_container, new RecycleGarbageFragment()).commit();
|
||||
fragment.clearTextUnderLineColor(fragment.flag);
|
||||
fragment.setTextUnderLineColor("可回收垃圾", fragment.recycleText);
|
||||
fragment.flag = 0;
|
||||
}
|
||||
|
||||
public void onKitchenGarbageButtonClick() {//转化到厨余垃圾界面
|
||||
FragmentManager fragmentManager = fragment.getParentFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_container, new KitchenGarbageFragment()).commit();
|
||||
fragment.clearTextUnderLineColor(fragment.flag);
|
||||
fragment.setTextUnderLineColor("厨余垃圾", fragment.kitchenText);
|
||||
fragment.flag = 1;
|
||||
}
|
||||
|
||||
public void onOtherGarbageButtonClick() {//转缓到其他垃圾的介绍界面
|
||||
FragmentManager fragmentManager = fragment.getParentFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_container, new OtherGarbageFragment()).commit();
|
||||
fragment.clearTextUnderLineColor(fragment.flag);
|
||||
fragment.setTextUnderLineColor("其他垃圾", fragment.otherGarbageText);
|
||||
fragment.flag = 2;
|
||||
}
|
||||
|
||||
public void onHazardGarbageButtonClick() {//转化到有害垃圾的界面
|
||||
FragmentManager fragmentManager = fragment.getParentFragmentManager();
|
||||
fragmentManager.beginTransaction().replace(R.id.content_container, new HazardGarbageFragment()).commit();
|
||||
fragment.clearTextUnderLineColor(fragment.flag);
|
||||
fragment.setTextUnderLineColor("有害垃圾", fragment.hazardText);
|
||||
fragment.flag = 3;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.UnderlineSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.example.myapplication.databinding.FragmentHomeBinding;
|
||||
|
||||
public class GarbageRecognitionActivity extends Fragment {
|
||||
private ImageButton recyclableGarbageButton;
|
||||
private ImageButton kitchenGarbageButton;
|
||||
private ImageButton otherGarbageButton;
|
||||
private ImageButton hazardGarbageButton;
|
||||
private FragmentHomeBinding binding;
|
||||
private ImageButton captureButton;
|
||||
public TextView recycleText;
|
||||
public TextView kitchenText;
|
||||
public TextView otherGarbageText;
|
||||
public TextView hazardText;
|
||||
private SpannableString spannableString;
|
||||
public int flag=0;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
binding = FragmentHomeBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
recyclableGarbageButton = root.findViewById(R.id.recycle);
|
||||
kitchenGarbageButton = root.findViewById(R.id.kitchen_garbage);
|
||||
otherGarbageButton = root.findViewById(R.id.other_garbage);
|
||||
hazardGarbageButton = root.findViewById(R.id.hazardous_waste);
|
||||
captureButton = root.findViewById(R.id.capture);
|
||||
recycleText = root.findViewById(R.id.recycle_text);
|
||||
kitchenText = root.findViewById(R.id.kitchen_text);
|
||||
otherGarbageText = root.findViewById(R.id.other_garbage_text);
|
||||
hazardText = root.findViewById(R.id.hazardous_waste_text);
|
||||
recyclableGarbageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GarbageRecognition.getInstance().setFragment(GarbageRecognitionActivity.this);
|
||||
GarbageRecognition.getInstance().onRecyclableGarbageButtonClick();
|
||||
}
|
||||
});
|
||||
kitchenGarbageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GarbageRecognition.getInstance().setFragment(GarbageRecognitionActivity.this);
|
||||
GarbageRecognition.getInstance().onKitchenGarbageButtonClick();
|
||||
}
|
||||
});
|
||||
otherGarbageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GarbageRecognition.getInstance().setFragment(GarbageRecognitionActivity.this);
|
||||
GarbageRecognition.getInstance().onOtherGarbageButtonClick();
|
||||
}
|
||||
});
|
||||
hazardGarbageButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
GarbageRecognition.getInstance().setFragment(GarbageRecognitionActivity.this);
|
||||
GarbageRecognition.getInstance().onHazardGarbageButtonClick();
|
||||
}
|
||||
});
|
||||
captureButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(getActivity(), CameraPreview.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
recyclableGarbageButton.performClick();
|
||||
return root;
|
||||
}
|
||||
|
||||
public void setTextUnderLineColor(String text,TextView curText)//设置文本下划线,提示用户目前查看的是哪一个垃圾分类介绍信息
|
||||
{
|
||||
clearTextUnderLineColor(flag);
|
||||
spannableString = new SpannableString(text);
|
||||
UnderlineSpan underlineSpan = new UnderlineSpan();
|
||||
spannableString.setSpan(underlineSpan,0,text.length(),0);
|
||||
ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.rgb(3,169,244));
|
||||
spannableString.setSpan(colorSpan,0,text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
curText.setText(spannableString);
|
||||
}
|
||||
|
||||
public void clearTextUnderLineColor(int flag)//清空之前选中的按钮选项
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case 0:
|
||||
recycleText.setText("可回收垃圾");
|
||||
case 1:
|
||||
kitchenText.setText("厨余垃圾");
|
||||
case 2:
|
||||
otherGarbageText.setText("其他垃圾");
|
||||
case 3:
|
||||
hazardText.setText("有害垃圾");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class GarbageRecognitionActivityViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<String> mText;
|
||||
|
||||
public GarbageRecognitionActivityViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is home fragment");
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
public interface ImageUploadCallback {
|
||||
void onResultChanged(String newResult);
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class ImageUploader {
|
||||
private static String result;
|
||||
private static ImageUploadCallback callback;
|
||||
|
||||
public static void setImageUploadCallback(ImageUploadCallback cb) {
|
||||
callback = cb;
|
||||
}
|
||||
|
||||
private static void notifyCallback() {
|
||||
Log.d("aaaaaaa", "notifyCallback: ");
|
||||
if (callback != null) {
|
||||
callback.onResultChanged(result);
|
||||
}
|
||||
}
|
||||
|
||||
// 在获取到上传结果时调用该方法
|
||||
private static void setResult(String newResult) {
|
||||
result = newResult;
|
||||
notifyCallback();
|
||||
}
|
||||
public static void imageUpload(String imagePath) {//前后端交互代码
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||
Future<Void> uploadTask = executorService.submit(() -> {
|
||||
try {
|
||||
String uploadUrl = "http://192.168.203.243:5000/upload_image"; // 替换为你的Flask服务器URL
|
||||
|
||||
File imageFile = new File(imagePath);
|
||||
if (!imageFile.exists()) {
|
||||
System.out.println("Image file not found.");
|
||||
return null;
|
||||
}
|
||||
|
||||
URL url = new URL(uploadUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
// 设置请求方法为POST
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setDoOutput(true);
|
||||
|
||||
// 构建请求体
|
||||
String boundary = "*****";
|
||||
String lineEnd = "\r\n";
|
||||
String twoHyphens = "--";
|
||||
String charset = "UTF-8";
|
||||
|
||||
connection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
|
||||
|
||||
DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
|
||||
dos.writeBytes(twoHyphens + boundary + lineEnd);
|
||||
dos.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"" + imageFile.getName() + "\"" + lineEnd);
|
||||
dos.writeBytes("Content-Type: image/jpeg" + lineEnd);
|
||||
dos.writeBytes(lineEnd);
|
||||
|
||||
FileInputStream fileInputStream = new FileInputStream(imageFile);
|
||||
int bytesAvailable = fileInputStream.available();
|
||||
int maxBufferSize = 1024;
|
||||
int bufferSize = Math.min(bytesAvailable, maxBufferSize);
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
|
||||
int bytesRead = fileInputStream.read(buffer, 0, bufferSize);
|
||||
while (bytesRead > 0) {
|
||||
dos.write(buffer, 0, bufferSize);
|
||||
bytesAvailable = fileInputStream.available();
|
||||
bufferSize = Math.min(bytesAvailable, maxBufferSize);
|
||||
bytesRead = fileInputStream.read(buffer, 0, bufferSize);
|
||||
}
|
||||
|
||||
dos.writeBytes(lineEnd);
|
||||
dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
|
||||
Log.d("s1", "3 ");
|
||||
// 发送请求并获取响应
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
// 请求成功
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line=reader.readLine();
|
||||
Log.d("s1", line);
|
||||
setResult(line);
|
||||
inputStream.close();
|
||||
} else {
|
||||
Log.d("s1", "2 ");
|
||||
// 请求失败
|
||||
System.out.println("HTTP POST request failed with response code: " + responseCode);
|
||||
}
|
||||
|
||||
fileInputStream.close();
|
||||
dos.flush();
|
||||
dos.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
// 等待上传任务完成
|
||||
try {
|
||||
uploadTask.get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 关闭线程池
|
||||
executorService.shutdown();
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.example.myapplication.ui.home;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ResultActivity extends AppCompatActivity {
|
||||
|
||||
private ImageView photo;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {//在后端发送数据后,跳转到对应的结果界面
|
||||
super.onCreate(savedInstanceState);
|
||||
this.getSupportActionBar().hide();
|
||||
int resultType=getIntent().getIntExtra("result",1);
|
||||
String photoFile =getIntent().getStringExtra("photoUrl") ;
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(photoFile);
|
||||
switch (resultType)
|
||||
{
|
||||
case 1:
|
||||
setContentView(R.layout.sonofrecycle_garbage);
|
||||
break;
|
||||
case 2:
|
||||
setContentView(R.layout.sonofkitchen_garbage);
|
||||
break;
|
||||
case 3:
|
||||
setContentView(R.layout.sonofother_garbage);
|
||||
break;
|
||||
case 4:
|
||||
setContentView(R.layout.sonofhazard_garbage);
|
||||
break;
|
||||
}
|
||||
photo=findViewById(R.id.picture);
|
||||
photo.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.example.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.myapplication.BottomNavigiationActivity;
|
||||
import com.example.myapplication.R;
|
||||
import com.example.myapplication.ui.home.GarbageRecognitionActivity;
|
||||
|
||||
public class index extends AppCompatActivity {
|
||||
|
||||
private static final long SPLASH_DELAY = 800; // 延迟时间,单位为毫秒,启动界面
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.getSupportActionBar().hide();
|
||||
// 设置启动页布局文件
|
||||
setContentView(R.layout.launch_screen);
|
||||
|
||||
// 延迟跳转到主界面
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(index.this, BottomNavigiationActivity.class);
|
||||
startActivity(intent);
|
||||
finish(); // 销毁当前活动,防止用户返回到启动页
|
||||
}
|
||||
}, SPLASH_DELAY);
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package com.example.myapplication.ui.notifications;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class FeedbackUploader {//反馈信息与后端进行交互
|
||||
public static void submitFeedback(UserFeedbackActivity userFeedbackActivity, String imagePath,String additionalString) {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(1);
|
||||
Toast toast = new Toast(userFeedbackActivity.getActivity());
|
||||
Future<Void> uploadTask = executorService.submit(() -> {
|
||||
try {
|
||||
Log.d("s2","t1");
|
||||
String uploadImageUrl = "http://192.168.203.243:5000/upload_image"; // 替换为图片上传的URL
|
||||
String uploadStringUrl = "http://192.168.203.243:5000/upload_text"; // 替换为字符串上传的URL
|
||||
Log.d("s2","t2");
|
||||
File imageFile = new File(imagePath);
|
||||
if (!imageFile.exists()) {
|
||||
Log.d("s2","t3");
|
||||
System.out.println("Image file not found.");
|
||||
return null;
|
||||
}
|
||||
Log.d("s2","t1");
|
||||
// 发送图片
|
||||
URL imageUrl = new URL(uploadImageUrl);
|
||||
HttpURLConnection imageConnection = (HttpURLConnection) imageUrl.openConnection();
|
||||
imageConnection.setRequestMethod("POST");
|
||||
imageConnection.setDoOutput(true);
|
||||
|
||||
// 构建请求体
|
||||
String boundary = "*****";
|
||||
String lineEnd = "\r\n";
|
||||
String twoHyphens = "--";
|
||||
|
||||
imageConnection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
|
||||
|
||||
DataOutputStream imageDos = new DataOutputStream(imageConnection.getOutputStream());
|
||||
imageDos.writeBytes(twoHyphens + boundary + lineEnd);
|
||||
imageDos.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"" + imageFile.getName() + "\"" + lineEnd);
|
||||
imageDos.writeBytes("Content-Type: image/jpeg" + lineEnd);
|
||||
imageDos.writeBytes(lineEnd);
|
||||
|
||||
FileInputStream imageInputStream = new FileInputStream(imageFile);
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = imageInputStream.read(buffer)) != -1) {
|
||||
imageDos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
imageDos.writeBytes(lineEnd);
|
||||
imageDos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
|
||||
Log.d("s2","t1");
|
||||
// 发送图片请求并获取响应
|
||||
int imageResponseCode = imageConnection.getResponseCode();
|
||||
if (imageResponseCode == HttpURLConnection.HTTP_OK) {
|
||||
// 图片上传成功
|
||||
// System.out.println("Image uploaded successfully.");
|
||||
InputStream inputStream = imageConnection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line;
|
||||
line=reader.readLine();
|
||||
|
||||
inputStream.close();
|
||||
Log.d("s2","t2");
|
||||
// 发送字符串
|
||||
URL urlString = new URL(uploadStringUrl);
|
||||
HttpURLConnection stringConnection = (HttpURLConnection) urlString.openConnection();
|
||||
stringConnection.setRequestMethod("POST");
|
||||
stringConnection.setDoOutput(true);
|
||||
stringConnection.setRequestProperty("Content-Type", "text/plain");
|
||||
|
||||
OutputStream stringOs = stringConnection.getOutputStream();
|
||||
stringOs.write(additionalString.getBytes("UTF-8"));
|
||||
stringOs.flush();
|
||||
stringOs.close();
|
||||
// 获取字符串上传响应
|
||||
int stringResponseCode = stringConnection.getResponseCode();
|
||||
if (stringResponseCode == HttpURLConnection.HTTP_OK) {
|
||||
Log.d("s2","t3");
|
||||
// 字符串上传成功
|
||||
InputStream inputStream2 = stringConnection.getInputStream();
|
||||
BufferedReader reader2 = new BufferedReader(new InputStreamReader(inputStream2));
|
||||
while ((line = reader2.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
inputStream2.close();
|
||||
toast.setText("图片上传成功!");
|
||||
} else {
|
||||
toast.setText("图片上传失败");
|
||||
// 字符串上传失败
|
||||
System.out.println("String upload failed with response code: " + stringResponseCode);
|
||||
}
|
||||
} else {
|
||||
// 图片上传失败
|
||||
toast.setText("图片上传失败");
|
||||
System.out.println("Image upload failed with response code: " + imageResponseCode);
|
||||
}
|
||||
imageInputStream.close();
|
||||
imageDos.flush();
|
||||
imageDos.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
toast.show();
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
// 等待上传任务完成
|
||||
try {
|
||||
uploadTask.get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 关闭线程池
|
||||
executorService.shutdown();
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package com.example.myapplication.ui.notifications;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.example.myapplication.databinding.FragmentNotificationsBinding;
|
||||
import com.example.myapplication.ui.home.ImageUploader;
|
||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||
|
||||
public class UserFeedbackActivity extends Fragment {
|
||||
|
||||
private FragmentNotificationsBinding binding;
|
||||
|
||||
private ImageButton buttonSelectImage;
|
||||
|
||||
public EditText editText;
|
||||
private Button submit,reset;
|
||||
|
||||
private UserFeedback userFeedback;
|
||||
|
||||
private Uri uri;
|
||||
|
||||
public MaterialCheckBox userExperience,identifyDeviations,functionalRecommendations,classificationExpansion,otherIssues,positiveRecommendation;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
UserFeedbackViewModel notificationsViewModel =
|
||||
new ViewModelProvider(this).get(UserFeedbackViewModel.class);
|
||||
userFeedback = new UserFeedback(this);
|
||||
binding = FragmentNotificationsBinding.inflate(inflater, container, false);
|
||||
View root = binding.getRoot();
|
||||
editText = root.findViewById(R.id.input_feedback);
|
||||
buttonSelectImage = root.findViewById(R.id.btn_select_image);
|
||||
userExperience=root.findViewById(R.id.user_experience);
|
||||
identifyDeviations=root.findViewById(R.id.identify_deviations);
|
||||
functionalRecommendations = root.findViewById(R.id.functional_recommendations);
|
||||
classificationExpansion = root.findViewById(R.id.classification_expansion);
|
||||
otherIssues = root.findViewById(R.id.other_issues);
|
||||
positiveRecommendation = root.findViewById(R.id.positive_recommendation);
|
||||
submit = root.findViewById(R.id.submit);
|
||||
reset = root.findViewById(R.id.reset);
|
||||
editText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
editText.setCursorVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if(editable != null&& editable.toString().length()>0)
|
||||
{
|
||||
editText.setCursorVisible(true);
|
||||
editText.setGravity(Gravity.START);
|
||||
}
|
||||
else
|
||||
{
|
||||
editText.setGravity(Gravity.CENTER);
|
||||
}
|
||||
}
|
||||
});
|
||||
buttonSelectImage.setOnClickListener(new View.OnClickListener() {//跳转到相册界面
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK,null);
|
||||
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,"image/*");
|
||||
startActivityForResult(intent,2);
|
||||
}
|
||||
});
|
||||
submit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
userFeedback.submitFeedback(uri);
|
||||
}
|
||||
});
|
||||
reset.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
userFeedback.resetAll();
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {//获取用户选择的相册的图片
|
||||
if(resultCode==-1)
|
||||
{
|
||||
if(data!=null)
|
||||
{
|
||||
uri = data.getData();
|
||||
buttonSelectImage.setImageURI(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.myapplication.ui.notifications;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class UserFeedbackViewModel extends ViewModel {
|
||||
|
||||
private final MutableLiveData<String> mText;
|
||||
|
||||
public UserFeedbackViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is notifications fragment");
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.example.myapplication.ui.quiz;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.myapplication.R;
|
||||
import com.example.myapplication.databinding.GarbageQuizBinding;
|
||||
import com.example.myapplication.ui.home.GarbageRecognition;
|
||||
import com.example.myapplication.ui.home.GarbageRecognitionActivityViewModel;
|
||||
import com.example.myapplication.ui.notifications.UserFeedbackViewModel;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GarbageQuizActivity extends Fragment {
|
||||
private GarbageQuizBinding binding;
|
||||
public Button aButton,bButton,cButton,dButton;
|
||||
private ImageButton preQuestionButton,nextQuestionButton;
|
||||
|
||||
private GarbageQuiz garbageQuiz;
|
||||
|
||||
public TextView question,analysisTextView;
|
||||
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
com.example.myapplication.ui.newthing.GarbageQuizViewModel notificationsViewModel =
|
||||
new ViewModelProvider(this).get(com.example.myapplication.ui.newthing.GarbageQuizViewModel.class);
|
||||
binding = GarbageQuizBinding.inflate(inflater,container,false);
|
||||
View root = binding.getRoot();
|
||||
aButton = root.findViewById(R.id.a_option);
|
||||
bButton = root.findViewById(R.id.b_option);
|
||||
cButton = root.findViewById(R.id.c_option);
|
||||
dButton = root.findViewById(R.id.d_option);
|
||||
question = root.findViewById(R.id.question);
|
||||
analysisTextView = root.findViewById(R.id.analysisTextView);
|
||||
preQuestionButton = root.findViewById(R.id.pre_question);
|
||||
nextQuestionButton = root.findViewById(R.id.next_question);
|
||||
try {
|
||||
garbageQuiz =new GarbageQuiz(this);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
aButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
garbageQuiz.chooseAOption();
|
||||
}
|
||||
});
|
||||
bButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
garbageQuiz.chooseBOption();
|
||||
}
|
||||
});
|
||||
cButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
garbageQuiz.chooseCOption();
|
||||
}
|
||||
});
|
||||
dButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
garbageQuiz.chooseDOption();
|
||||
}
|
||||
});
|
||||
preQuestionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
garbageQuiz.getLastQuestion();
|
||||
}
|
||||
});
|
||||
nextQuestionButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
garbageQuiz.getNextQuestion();
|
||||
}
|
||||
});
|
||||
nextQuestionButton.performClick();
|
||||
return root;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.myapplication.ui.newthing;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class GarbageQuizViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
|
||||
public GarbageQuizViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is new fragment");//根据自己喜欢放界面的测试文字
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
sonar-scanner.bat -D"sonar.projectKey=tsq" -D"sonar.sources=User" -D"sonar.host.url=http://localhost:9000" -D"sonar.login=sqp_cfe53f4667e9c83129469f7a698d2f74f5ef73ad"
|
After Width: | Height: | Size: 82 KiB |
@ -0,0 +1,4 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_checked="true" android:color="@color/blue" />
|
||||
<item android:color="@color/grey"/>
|
||||
</selector>
|
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 15 KiB |
@ -0,0 +1,4 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="23dp"/> <!-- 设置圆角半径,根据需要调整数值 -->
|
||||
<solid android:color="@color/white"></solid>
|
||||
</shape>
|
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 368 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 151 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 122 KiB |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle"
|
||||
>
|
||||
</shape>
|
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 222 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 118 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 25 KiB |
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="-4dp"
|
||||
android:right="-4dp"
|
||||
android:top="-4dp">
|
||||
<shape>
|
||||
<stroke
|
||||
android:width="3dp"
|
||||
android:color="#078EFA" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="-4dp"
|
||||
android:right="-4dp"
|
||||
android:top="-4dp">
|
||||
<shape>
|
||||
<stroke
|
||||
android:width="3dp"
|
||||
android:color="#F68D2C" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="-4dp"
|
||||
android:right="-4dp"
|
||||
android:top="-4dp">
|
||||
<shape android:layout_height="match_parent">
|
||||
<stroke
|
||||
android:width="3dp"
|
||||
android:color="#3C927D" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:left="-4dp"
|
||||
android:right="-4dp"
|
||||
android:top="-4dp">
|
||||
<shape>
|
||||
<stroke
|
||||
android:width="3dp"
|
||||
android:color="#D92D25" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:top="-2dp" android:left="-2dp" android:right="-2dp" android:bottom="-24dp">
|
||||
<shape
|
||||
android:layout_height="match_parent"
|
||||
android:shape="line">
|
||||
<stroke
|
||||
android:width="3dp"
|
||||
android:alpha="0.8"
|
||||
android:color="#78078EFA" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="-16dp" android:left="-14dp" android:right="-4dp" android:bottom="-27dp">
|
||||
<shape android:shape="line">
|
||||
<stroke
|
||||
android:width="5dp"
|
||||
android:height="30dp"
|
||||
android:color="#78078EFA"
|
||||
android:alpha="0.6" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="-16dp" android:left="-14dp" android:right="-4dp" android:bottom="-30dp">
|
||||
<shape android:shape="line">
|
||||
<stroke
|
||||
android:width="7dp"
|
||||
android:color="#78078EFA"
|
||||
android:alpha="0.4" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:color="@color/black"
|
||||
android:width="1dp"
|
||||
/>
|
||||
</shape>
|
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/show_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/recapture"
|
||||
android:backgroundTint="@color/white"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:src="@drawable/camera"
|
||||
android:layout_marginLeft="100dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:text="重新拍摄"
|
||||
/>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/transmit"
|
||||
android:backgroundTint="@color/white"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:background="@drawable/button"
|
||||
android:src="@drawable/upload"
|
||||
android:layout_marginRight="100dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:text="上传图片"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/user_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/confirm_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/user_confirm"
|
||||
android:layout_marginBottom="20dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:layout_width="100dp"-->
|
||||
<!-- android:layout_height="100dp"-->
|
||||
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<SurfaceView
|
||||
android:id="@+id/surfaceView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="500dp" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/take_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/camera"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".BottomNavigiationActivity"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/grey1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="垃圾知识问答"
|
||||
android:textSize="27sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/question"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/analysisTextView"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="190dp"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:textColor="@color/black"
|
||||
android:backgroundTint="@color/white"
|
||||
android:id="@+id/a_option"
|
||||
android:layout_width="155dp"
|
||||
android:layout_height="125dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Button
|
||||
android:textColor="@color/black"
|
||||
android:backgroundTint="@color/white"
|
||||
android:id="@+id/b_option"
|
||||
android:layout_width="155dp"
|
||||
android:layout_height="125dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:textColor="@color/black"
|
||||
android:backgroundTint="@color/white"
|
||||
android:id="@+id/c_option"
|
||||
android:layout_width="155dp"
|
||||
android:layout_height="125dp"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Button
|
||||
android:textColor="@color/black"
|
||||
android:id="@+id/d_option"
|
||||
android:layout_width="155dp"
|
||||
android:layout_height="125dp"
|
||||
android:backgroundTint="@color/white"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="100dp"
|
||||
android:gravity="center"
|
||||
>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/pre_question"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:background="@drawable/previous_question"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/next_question"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
|
||||
android:background="@drawable/next_question"
|
||||
tools:ignore="DuplicateIds" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,16 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:background="#F0F2F1"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:src="@drawable/launch_logo"
|
||||
android:background="#F0F2F1"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<com.tencent.map.navi.walk.WalkNaviView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<com.tencent.map.navi.walk.WalkNaviView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
After Width: | Height: | Size: 82 KiB |
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="MyCheckBox" parent="Theme.AppCompat.Light">
|
||||
<item name="colorControlNormal">@android:color/white</item>
|
||||
<item name="colorControlActivated">@android:color/black</item>
|
||||
</style>
|
||||
\ <style name="Textstyle1">
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#078EFA</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="Textstyle2">
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#F68D2C</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="Textstyle3">
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#D92D25</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="Textstyle4">
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#3C927D</item>
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
<style name="font_styles">
|
||||
<item name="android:fontFamily">@font/hkzykt</item>
|
||||
</style>
|
||||
<style name="font_wr">
|
||||
<item name="android:fontFamily">@font/wrxk</item>
|
||||
</style>
|
||||
<style name="ButtonNoTheme" parent="Theme.AppCompat.Light">
|
||||
<item name="android:backgroundTint">@color/white</item>
|
||||
<item name="android:background">@drawable/checkbox_rounded_corner</item>
|
||||
</style>
|
||||
</resources>
|
@ -0,0 +1,6 @@
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-files-path name="files" path="." />
|
||||
<external-path name="pictures" path="Pictures" />
|
||||
<external-path name="dcim" path="DCIM" />
|
||||
<root-path name="root" path="" />
|
||||
</paths>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<font
|
||||
android:fontStyle="normal"
|
||||
android:fontWeight="400"
|
||||
android:font="@font/hkzykt" />
|
||||
</font-family>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<font
|
||||
android:fontStyle="normal"
|
||||
android:fontWeight="400"
|
||||
android:font="@font/wrxk" />
|
||||
</font-family>
|