|
|
|
@ -38,11 +38,15 @@ import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
|
import com.xypower.common.CameraUtils;
|
|
|
|
|
import com.xypower.common.FilesUtils;
|
|
|
|
|
import com.xypower.common.JSONUtils;
|
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
|
import com.xypower.mpapp.databinding.ActivityMainBinding;
|
|
|
|
|
import com.xypower.mpapp.utils.RandomReader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
@ -245,6 +249,13 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
binding.logs.setText("");
|
|
|
|
|
MicroPhotoContext.AppConfig curAppConfig = retrieveAndSaveAppConfig();
|
|
|
|
|
|
|
|
|
|
TakeAndThrowPhoto(2, 0xFF);
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(20);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startMicroPhotoService(MainActivity.this.getApplicationContext(), appConfig, mMessenger);
|
|
|
|
|
|
|
|
|
|
binding.btnStartServ.setEnabled(false);
|
|
|
|
@ -602,6 +613,26 @@ public class MainActivity extends AppCompatActivity {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void TakeAndThrowPhoto(int channel, int preset) {
|
|
|
|
|
String appPath = MicroPhotoContext.buildMpAppDir(getApplicationContext());
|
|
|
|
|
File configFile = new File(appPath);
|
|
|
|
|
configFile = new File(configFile, "data/channels/" + Integer.toString(channel) + ".json");
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
Date dt = new Date();
|
|
|
|
|
|
|
|
|
|
File tmpPath = new File(appPath, "tmp");
|
|
|
|
|
if (!tmpPath.exists()) {
|
|
|
|
|
tmpPath.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
File photoFile = new File(tmpPath, "IMG-" + Integer.toString(channel) + "-" + sdf.format(dt) + ".jpg");
|
|
|
|
|
if (photoFile.exists()) {
|
|
|
|
|
photoFile.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MicroPhotoService.takePhoto(channel, preset, true, configFile.getAbsolutePath(), photoFile.getAbsolutePath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onResume() {
|
|
|
|
|
// call the superclass method first
|
|
|
|
|