Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4321374

Browse files
Update to v1.1.0
2 parents2cc1332 +9337cfc commit4321374

File tree

13 files changed

+356
-51
lines changed

13 files changed

+356
-51
lines changed

‎apk/Clinometer-1.1.0.apk‎

4.29 MB
Binary file not shown.

‎apk/Clinometer-latest.apk‎

5.85 KB
Binary file not shown.

‎app/build.gradle‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
applyplugin:'com.android.application'
22

33
android {
4-
compileSdkVersion29
5-
buildToolsVersion"29.0.3"
4+
compileSdkVersion30
5+
buildToolsVersion"30.0.3"
66

77
lintOptions {
88
//checkReleaseBuilds false
@@ -14,12 +14,12 @@ android {
1414
defaultConfig {
1515
applicationId"eu.basicairdata.clinometer"
1616
minSdkVersion19
17-
targetSdkVersion29
17+
targetSdkVersion30
1818

1919
// -----------------------------------------------------------------------------------------
2020
// We use the Semantic Versioning (https://semver.org/):
21-
versionName'1.0.3'
22-
versionCode4
21+
versionName'1.1.0'
22+
versionCode5
2323
// -----------------------------------------------------------------------------------------
2424

2525
vectorDrawables.useSupportLibrary=true

‎app/src/main/java/eu/basicairdata/clinometer/ClinometerActivity.java‎

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
importstaticeu.basicairdata.clinometer.ClinometerApplication.KEY_PREF_CALIBRATION_OFFSET_2;
8181
importstaticeu.basicairdata.clinometer.ClinometerApplication.KEY_PREF_CAMERA_EXPOSURE_COMPENSATION;
8282
importstaticeu.basicairdata.clinometer.ClinometerApplication.KEY_PREF_KEEP_SCREEN_ON;
83+
importstaticeu.basicairdata.clinometer.ClinometerApplication.KEY_PREF_UNIT_OF_MEASUREMENT;
8384

8485

8586
publicclassClinometerActivityextendsAppCompatActivityimplementsSensorEventListener {
@@ -91,11 +92,11 @@ public static ClinometerActivity getInstance(){
9192
returnsingleton;
9293
}
9394

94-
privateToneGeneratortoneGen1 =newToneGenerator(AudioManager.STREAM_MUSIC,ToneGenerator.TONE_CDMA_KEYPAD_VOLUME_KEY_LITE);
95+
privatefinalToneGeneratortoneGen1 =newToneGenerator(AudioManager.STREAM_MUSIC,ToneGenerator.TONE_CDMA_KEYPAD_VOLUME_KEY_LITE);
9596
privateVibratorvibrator;
9697

9798
// RefAxis Animator
98-
privatePIDAnimatorpid =newPIDAnimator(0.0f,0.3f,0.0f,0.03f,16);
99+
privatefinalPIDAnimatorpid =newPIDAnimator(0.0f,0.3f,0.0f,0.03f,16);
99100
privatefloatold_PIDValue =0.0f;
100101

101102
privatestaticfinalintTOAST_TIME =2500;// The time a toast is shown
@@ -105,7 +106,11 @@ public static ClinometerActivity getInstance(){
105106
privatestaticfinalfloatAUTOLOCK_HORIZON_CHECK_THRESHOLD =5.0f;// The zone of horizon check (+- 5 degrees)
106107
privatestaticfinalfloatROTATION_THRESHOLD =5;// The threshold of the boundaries for DisplayRotation (in degrees)
107108
privatestaticfinalintSIZE_OF_MEANVARIANCE =200;// 2 seconds
108-
privatestaticfinalfloatALPHA =0.04f;// Weight of the new sensor reading
109+
110+
privatestaticfinalfloatALPHA =0.03f;// Weight of the new sensor reading
111+
privatefloatalpha0 =ALPHA;
112+
privatefloatalpha1 =ALPHA;
113+
privatefloatalpha2 =ALPHA;
109114

110115
privateClinometerApplicationclinometerApplication;
111116
privateSharedPreferencespreferences;
@@ -132,6 +137,11 @@ public static ClinometerActivity getInstance(){
132137
// return singleton;
133138
// }
134139

140+
privateStringformattedAngle0;
141+
privateStringformattedAngle1;
142+
privateStringformattedAngle2;
143+
privatefinalDataFormatterdataFormatter =newDataFormatter();
144+
135145
privateClinometerViewmClinometerView;
136146
privateTextViewmTextViewAngles;
137147
privateTextViewmTextViewToast;
@@ -150,13 +160,13 @@ public static ClinometerActivity getInstance(){
150160
privateSensorManagermSensorManager;
151161
privateSensormRotationSensor;
152162

153-
privatefloat[]gravity = {0,0,0};// The (filtered) current accelerometers values
154-
privatefloat[]gravity_gain = {0,0,0};
155-
privatefloat[]gravity_offset = {0,0,0};
156-
privatefloat[]gravity_calibrated = {0,0,0};// The (filtered) current calibrated accelerometers values
163+
privatefinalfloat[]gravity = {0,0,0};// The (filtered) current accelerometers values
164+
privatefinalfloat[]gravity_gain = {0,0,0};
165+
privatefinalfloat[]gravity_offset = {0,0,0};
166+
privatefinalfloat[]gravity_calibrated = {0,0,0};// The (filtered) current calibrated accelerometers values
157167

158-
privatefloat[]angle_calibration = {0,0,0};// The angles for calibration: alpha, beta, gamma (in degrees)
159-
privatefloat[]angle = {0,0,0};// The (filtered) current angles (in degrees)
168+
privatefinalfloat[]angle_calibration = {0,0,0};// The angles for calibration: alpha, beta, gamma (in degrees)
169+
privatefinalfloat[]angle = {0,0,0};// The (filtered) current angles (in degrees)
160170

161171
privatefinalfloat[][]calibrationMatrix =newfloat[3][3];
162172

@@ -180,6 +190,16 @@ public static ClinometerActivity getInstance(){
180190
privatestaticCameramCamera =null;
181191
privateCameraPreviewmPreview;
182192

193+
privatebooleandoubleBackToExitPressedOnce;
194+
privateHandlermHandler =newHandler();
195+
196+
privatefinalRunnablemRunnable =newRunnable() {
197+
@Override
198+
publicvoidrun() {
199+
doubleBackToExitPressedOnce =false;
200+
}
201+
};
202+
183203

184204
// --------------------------------------------------------------------------------------------------------------------------
185205
// --- GETTERS AND SETTERS --------------------------------------------------------------------------------------------------
@@ -373,6 +393,11 @@ protected void onResume() {
373393

374394
loadPreferences();
375395

396+
formattedAngle0 =dataFormatter.format(angle[0]);
397+
formattedAngle1 =dataFormatter.format(angle[1]);
398+
formattedAngle2 =dataFormatter.format(angle[2]);
399+
mTextViewAngles.setText(formattedAngle0 +" " +formattedAngle1 +" " +formattedAngle2);
400+
376401
mFrameLayoutClinometer.setSystemUiVisibility(
377402
//View.SYSTEM_UI_FLAG_IMMERSIVE |
378403
// Set the content to appear under the system bars so that the
@@ -410,6 +435,25 @@ public void onStop() {
410435
}
411436

412437

438+
@Override
439+
protectedvoidonDestroy() {
440+
super.onDestroy();
441+
if (mHandler !=null) {mHandler.removeCallbacks(mRunnable); }
442+
}
443+
444+
445+
@Override
446+
publicvoidonBackPressed() {
447+
if (doubleBackToExitPressedOnce) {
448+
super.onBackPressed();
449+
return;
450+
}
451+
this.doubleBackToExitPressedOnce =true;
452+
showToast(getString(R.string.toast_click_back_again_to_exit));
453+
mHandler.postDelayed(mRunnable,TOAST_TIME);
454+
}
455+
456+
413457
publicvoidonSensorChanged(SensorEventevent) {
414458

415459
if (event.sensor.getType() ==Sensor.TYPE_ACCELEROMETER) {
@@ -477,6 +521,9 @@ public void onSensorChanged(SensorEvent event) {
477521
// SIGNAL PROCESSING
478522

479523
if (!isLocked) {
524+
alpha0 =ALPHA * (float)(1 +Math.abs(mvGravity0.getMeanValue() -event.values[0])*0.1);
525+
alpha1 =ALPHA * (float)(1 +Math.abs(mvGravity1.getMeanValue() -event.values[1])*0.1);
526+
alpha2 =ALPHA * (float)(1 +Math.abs(mvGravity2.getMeanValue() -event.values[2])*0.1);
480527

481528
// Weighted gravity reads
482529

@@ -485,16 +532,16 @@ public void onSensorChanged(SensorEvent event) {
485532
gravity[1] = (event.values[1] -gravity_offset[1]) /gravity_gain[1];// Y
486533
gravity[2] = (event.values[2] -gravity_offset[2]) /gravity_gain[2];// Z
487534
}else {
488-
gravity[0] = (1 -ALPHA) *gravity[0] + (ALPHA) * (event.values[0] -gravity_offset[0]) /gravity_gain[0];
489-
gravity[1] = (1 -ALPHA) *gravity[1] + (ALPHA) * (event.values[1] -gravity_offset[1]) /gravity_gain[1];
490-
gravity[2] = (1 -ALPHA) *gravity[2] + (ALPHA) * (event.values[2] -gravity_offset[2]) /gravity_gain[2];
535+
gravity[0] = (1 -alpha0) *gravity[0] + (alpha0) * (event.values[0] -gravity_offset[0]) /gravity_gain[0];
536+
gravity[1] = (1 -alpha1) *gravity[1] + (alpha1) * (event.values[1] -gravity_offset[1]) /gravity_gain[1];
537+
gravity[2] = (1 -alpha2) *gravity[2] + (alpha2) * (event.values[2] -gravity_offset[2]) /gravity_gain[2];
491538
}
492539

493540
// Apply Calibration values
494541

495-
gravity_calibrated[0] =(float) (gravity[0] *calibrationMatrix[0][0] +gravity[1] *calibrationMatrix[0][1] +gravity[2] *calibrationMatrix[0][2]);
496-
gravity_calibrated[1] =(float) (gravity[0] *calibrationMatrix[1][0] +gravity[1] *calibrationMatrix[1][1] +gravity[2] *calibrationMatrix[1][2]);
497-
gravity_calibrated[2] =(float) (gravity[0] *calibrationMatrix[2][0] +gravity[1] *calibrationMatrix[2][1] +gravity[2] *calibrationMatrix[2][2]);
542+
gravity_calibrated[0] =gravity[0] *calibrationMatrix[0][0] +gravity[1] *calibrationMatrix[0][1] +gravity[2] *calibrationMatrix[0][2];
543+
gravity_calibrated[1] =gravity[0] *calibrationMatrix[1][0] +gravity[1] *calibrationMatrix[1][1] +gravity[2] *calibrationMatrix[1][2];
544+
gravity_calibrated[2] =gravity[0] *calibrationMatrix[2][0] +gravity[1] *calibrationMatrix[2][1] +gravity[2] *calibrationMatrix[2][2];
498545

499546
mvGravity0.loadSample(gravity_calibrated[0]);
500547
mvGravity1.loadSample(gravity_calibrated[1]);
@@ -590,7 +637,12 @@ public void onSensorChanged(SensorEvent event) {
590637

591638
// You must put this setText here in order to force the re-layout also during the rotations.
592639
// Without this, if you lock the measure during the rotation animation, the layout doesn't change correctly :(
593-
mTextViewAngles.setText(String.format("%1.1f° %1.1f° %1.1f°",angle[0],angle[1],angle[2]));
640+
641+
formattedAngle0 =dataFormatter.format(angle[0]);
642+
formattedAngle1 =dataFormatter.format(angle[1]);
643+
formattedAngle2 =dataFormatter.format(angle[2]);
644+
mTextViewAngles.setText(formattedAngle0 +" " +formattedAngle1 +" " +formattedAngle2);
645+
// mTextViewAngles.setText(String.format("%1.1f° %1.1f° %1.1f°", angle[0], angle[1], angle[2]));
594646
}
595647

596648
if (Math.abs(pid.getValue() -old_PIDValue) >0.001) {
@@ -628,6 +680,7 @@ private void loadPreferences() {
628680
elsegetWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
629681

630682
prefAutoLock =preferences.getBoolean(KEY_PREF_AUTOLOCK,false);
683+
clinometerApplication.setPrefUM(Integer.parseInt(preferences.getString(KEY_PREF_UNIT_OF_MEASUREMENT, (getResources().getStringArray(R.array.UMAnglesValues))[0])));
631684
prefAutoLockHorizonCheck =preferences.getBoolean(KEY_PREF_AUTOLOCK_HORIZON_CHECK,true);
632685
prefAutoLockTolerance =AUTOLOCK_MAX_TOLERANCE - (AUTOLOCK_MAX_TOLERANCE -AUTOLOCK_MIN_TOLERANCE) *preferences.getInt(KEY_PREF_AUTOLOCK_PRECISION,500) /1000;
633686
Log.d("Clinometer",String.format("Auto Locking Tolerance = %1.3f",prefAutoLockTolerance));
@@ -685,7 +738,11 @@ public void onAnimationUpdate(ValueAnimator updatedAnimation) {
685738
}
686739
// You must put this setText here in order to force the re-layout also during the rotations.
687740
// Without this, if you lock the measure during the rotation animation, the layout doesn't change correctly :(
688-
mTextViewAngles.setText(String.format("%1.1f° %1.1f° %1.1f°",angle[0],angle[1],angle[2]));
741+
formattedAngle0 =dataFormatter.format(angle[0]);
742+
formattedAngle1 =dataFormatter.format(angle[1]);
743+
formattedAngle2 =dataFormatter.format(angle[2]);
744+
mTextViewAngles.setText(formattedAngle0 +" " +formattedAngle1 +" " +formattedAngle2);
745+
// mTextViewAngles.setText(String.format("%1.1f° %1.1f° %1.1f°", angle[0], angle[1], angle[2]));
689746
}
690747
});
691748
animationR.start();

‎app/src/main/java/eu/basicairdata/clinometer/ClinometerApplication.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public class ClinometerApplication extends Application {
3838

3939
publicstaticfinalintCAMERA_REQUEST_CODE =100;
4040

41-
4241
publicstaticfinalStringKEY_PREF_CALIBRATION ="prefCalibration";
4342
publicstaticfinalStringKEY_PREF_CALIBRATION_RESET ="prefResetCalibration";
4443
publicstaticfinalStringKEY_PREF_CALIBRATION_TIME ="prefCalibrationTime";
@@ -51,6 +50,7 @@ public class ClinometerApplication extends Application {
5150
publicstaticfinalStringKEY_PREF_ABOUT ="prefAbout";
5251
publicstaticfinalStringKEY_PREF_ONLINE_HELP ="prefOnlineHelp";
5352
publicstaticfinalStringKEY_PREF_KEEP_SCREEN_ON ="prefKeepScreenOn";
53+
publicstaticfinalStringKEY_PREF_UNIT_OF_MEASUREMENT ="prefUnitOfMeasurement";
5454
publicstaticfinalStringKEY_PREF_CALIBRATION_ANGLE_0 ="prefCalibrationAngle0";
5555
publicstaticfinalStringKEY_PREF_CALIBRATION_ANGLE_1 ="prefCalibrationAngle1";
5656
publicstaticfinalStringKEY_PREF_CALIBRATION_ANGLE_2 ="prefCalibrationAngle2";
@@ -69,6 +69,7 @@ public static ClinometerApplication getInstance(){
6969
}
7070

7171
privateSharedPreferencespreferences;
72+
privateintprefUM =0;
7273

7374
privatebooleanhasACamera =false;// True if the device has at least a camera
7475
privatebooleanisCameraScanned =false;
@@ -82,6 +83,14 @@ public static ClinometerApplication getInstance(){
8283
// ----------------------------------------------------------------------------------------------------------------------
8384

8485

86+
publicvoidsetPrefUM(intprefUM) {
87+
this.prefUM =prefUM;
88+
}
89+
90+
publicintgetPrefUM() {
91+
returnprefUM;
92+
}
93+
8594
publicbooleanhasCamera() {
8695
returnhasACamera;
8796
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp