mirror of
https://github.com/wesaphzt/privatelock.git
synced 2025-04-21 06:59:09 +00:00
Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
0cfce130fd | ||
|
1b0d587a8d | ||
|
995403a129 | ||
|
0aa22e93e3 |
8 changed files with 162 additions and 22 deletions
21
CHANGELOG.md
Normal file
21
CHANGELOG.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
Changelog
|
||||
==========
|
||||
|
||||
Release 1.2 *(2019-09-21)*
|
||||
----------------------------
|
||||
* Fix for background service < Android 8.0/Oreo
|
||||
* Add option for haptic feedback (vibration) on lock trigger
|
||||
* Reworked animation logic
|
||||
* Fix 'License' and 'Bug report' links on about page
|
||||
|
||||
Release 1.1 *(2019-06-25)*
|
||||
----------------------------
|
||||
* Animation scaling issues fixed
|
||||
* Stop service correctly to fix memory leak & reduce code
|
||||
* Notification priority changed to low for Nougat and lower
|
||||
* Option added to run service when screen is off to be able to force PIN entry
|
||||
* Gradle & library updates
|
||||
|
||||
Release 1.0 *(2019-06-01)*
|
||||
----------------------------
|
||||
* Initial release
|
|
@ -40,6 +40,8 @@ import com.wesaphzt.privatelock.receivers.DeviceAdminReceiver;
|
|||
import com.wesaphzt.privatelock.service.LockService;
|
||||
import com.wesaphzt.privatelock.widget.LockWidgetProvider;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.wesaphzt.privatelock.service.LockService.CHANNEL_ID;
|
||||
import static com.wesaphzt.privatelock.service.LockService.DEFAULT_SENSITIVITY;
|
||||
import static com.wesaphzt.privatelock.service.LockService.activeListener;
|
||||
|
@ -54,7 +56,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
private boolean mInitialized;
|
||||
private static SensorManager mSensorManager;
|
||||
private Sensor mAccelerometer;
|
||||
private final float NOISE = (float) 2.0;
|
||||
|
||||
private SensorEventListener mActiveListener;
|
||||
|
||||
|
@ -74,22 +75,23 @@ public class MainActivity extends AppCompatActivity {
|
|||
private boolean isRunning = false;
|
||||
private boolean isHit = false;
|
||||
|
||||
//stats
|
||||
private TextView tvLastBreachValue;
|
||||
private TextView tvAvgBreachValue;
|
||||
private TextView tvHighestBreachValue;
|
||||
|
||||
private int triggerCount = 0;
|
||||
private float avgBreachValueTotal = 0;
|
||||
private double highestBreach = 0;
|
||||
|
||||
private Circle circle;
|
||||
private Circle circle_bg;
|
||||
//circle bg color
|
||||
private int circleBgR = 240; private int circleBgG = 240; private int circleBgB = 240;
|
||||
//circle color
|
||||
private int circleDefaultR = 88; private int circleDefaultG = 186; private int circleDefaultB = 255;
|
||||
//circle lock color
|
||||
private int circleLockR = 88; private int circleLockG = 255; private int circleLockB = 135;
|
||||
int animationDuration = 220;
|
||||
|
||||
CircleAngleAnimation animation;
|
||||
|
||||
//first run
|
||||
final private String PREF_VERSION_CODE_KEY = "VERSION_CODE";
|
||||
final private int DOESNT_EXIST = -1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -129,6 +131,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
});
|
||||
|
||||
//animation
|
||||
circle = findViewById(R.id.circle);
|
||||
circle_bg = findViewById(R.id.circle_bg);
|
||||
|
||||
|
@ -158,10 +161,19 @@ public class MainActivity extends AppCompatActivity {
|
|||
CircleAngleAnimation animation = new CircleAngleAnimation(circle_bg, 360);
|
||||
//initial animation
|
||||
animation.setDuration(500);
|
||||
circle_bg.setColor(circleBgR,circleBgG,circleBgB);
|
||||
//circle bg color
|
||||
int circleBgR = 240;
|
||||
int circleBgG = 240;
|
||||
int circleBgB = 240;
|
||||
circle_bg.setColor(circleBgR, circleBgG, circleBgB);
|
||||
|
||||
circle_bg.startAnimation(animation);
|
||||
|
||||
//stats
|
||||
tvLastBreachValue = findViewById(R.id.tvLastBreachValue);
|
||||
tvAvgBreachValue = findViewById(R.id.tvAvgBreachValue);
|
||||
tvHighestBreachValue = findViewById(R.id.tvHighestBreachValue);
|
||||
|
||||
//shared prefs
|
||||
try {
|
||||
mSensitivity = prefs.getInt(PREFS_THRESHOLD, DEFAULT_SENSITIVITY);
|
||||
|
@ -180,6 +192,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
isRunning = false;
|
||||
isHit = false;
|
||||
circle.setColor(circleDefaultR, circleDefaultG, circleDefaultB);
|
||||
//reset stat variables
|
||||
triggerCount = 0;
|
||||
avgBreachValueTotal = 0;
|
||||
highestBreach = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -388,7 +404,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
//get current version code
|
||||
int currentVersionCode = BuildConfig.VERSION_CODE;
|
||||
//get saved version code
|
||||
int DOESNT_EXIST = -1;
|
||||
int savedVersionCode = DOESNT_EXIST;
|
||||
//first run
|
||||
String PREF_VERSION_CODE_KEY = "VERSION_CODE";
|
||||
try {
|
||||
savedVersionCode = this.prefs.getInt(PREF_VERSION_CODE_KEY, DOESNT_EXIST);
|
||||
} catch (Exception e) {
|
||||
|
@ -423,6 +442,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
float deltaY = Math.abs(mLastY - y);
|
||||
float deltaZ = Math.abs(mLastZ - z);
|
||||
|
||||
float NOISE = (float) 2.0;
|
||||
if (deltaX < NOISE) deltaX = (float) 0.0;
|
||||
if (deltaY < NOISE) deltaY = (float) 0.0;
|
||||
if (deltaZ < NOISE) deltaZ = (float) 0.0;
|
||||
|
@ -438,8 +458,14 @@ public class MainActivity extends AppCompatActivity {
|
|||
if (total >= mSensitivity) {
|
||||
//lock screen threshold hit
|
||||
|
||||
stats(total);
|
||||
|
||||
if(!isHit) {
|
||||
CircleAngleAnimation anim = new CircleAngleAnimation(circle, 360);
|
||||
//circle lock color
|
||||
int circleLockR = 88;
|
||||
int circleLockG = 255;
|
||||
int circleLockB = 135;
|
||||
circle.setColor(circleLockR, circleLockG, circleLockB);
|
||||
anim.setDuration(animationDuration);
|
||||
//set lock color
|
||||
|
@ -467,4 +493,17 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void stats(float total) {
|
||||
tvLastBreachValue.setText(String.format(Locale.ENGLISH, "%.1f", (double) total));
|
||||
|
||||
if(total == 0 || total > highestBreach) {
|
||||
highestBreach = total;
|
||||
}
|
||||
tvHighestBreachValue.setText(String.format(Locale.ENGLISH, "%.1f", highestBreach));
|
||||
|
||||
triggerCount += 1;
|
||||
avgBreachValueTotal += total;
|
||||
tvAvgBreachValue.setText(String.format(Locale.ENGLISH, "%.1f", avgBreachValueTotal / triggerCount));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ public class LockService extends JobIntentService {
|
|||
private float mLastX, mLastY, mLastZ;
|
||||
public static boolean mInitialized;
|
||||
public static SensorManager mSensorManager;
|
||||
private final float NOISE = (float) 2.0;
|
||||
public static Sensor mAccelerometer;
|
||||
|
||||
public static SensorEventListener activeListener;
|
||||
|
@ -83,7 +82,6 @@ public class LockService extends JobIntentService {
|
|||
|
||||
//vibrate
|
||||
boolean isHaptic = false;
|
||||
private final int vibrateTime = 100;
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
@ -97,6 +95,7 @@ public class LockService extends JobIntentService {
|
|||
LockWidgetProvider lockWidgetProvider = new LockWidgetProvider();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
assert action != null;
|
||||
switch (action) {
|
||||
case ACTION_START_FOREGROUND_SERVICE:
|
||||
presenceReceiver = new PresenceReceiver();
|
||||
|
@ -233,6 +232,7 @@ public class LockService extends JobIntentService {
|
|||
float deltaY = Math.abs(mLastY - y);
|
||||
float deltaZ = Math.abs(mLastZ - z);
|
||||
|
||||
float NOISE = (float) 2.0;
|
||||
if (deltaX < NOISE) deltaX = (float) 0.0;
|
||||
if (deltaY < NOISE) deltaY = (float) 0.0;
|
||||
if (deltaZ < NOISE) deltaZ = (float) 0.0;
|
||||
|
@ -279,6 +279,7 @@ public class LockService extends JobIntentService {
|
|||
}
|
||||
|
||||
private void vibrateItBaby() {
|
||||
int vibrateTime = 100;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
((Vibrator) Objects.requireNonNull(getSystemService(VIBRATOR_SERVICE))).vibrate(VibrationEffect.createOneShot(vibrateTime, VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
} else {
|
||||
|
|
|
@ -141,6 +141,79 @@
|
|||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlStatTitles"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin_small"
|
||||
android:layout_marginEnd="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLastBreachValueTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stats_last_breach_value_title"
|
||||
android:textSize="@dimen/_10sdp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAvgBreachValueTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tvLastBreachValueTitle"
|
||||
android:text="@string/stats_avg_breach_value_title"
|
||||
android:textSize="@dimen/_10sdp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHighestBreachValueTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tvAvgBreachValueTitle"
|
||||
android:text="@string/stats_highest_breach_value_title"
|
||||
android:textSize="@dimen/_10sdp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlStatValues"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:layout_marginTop="@dimen/activity_margin_small"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:layout_toEndOf="@id/rlStatTitles">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLastBreachValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stats_zero"
|
||||
android:textSize="@dimen/_10sdp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAvgBreachValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tvLastBreachValue"
|
||||
android:text="@string/stats_zero"
|
||||
android:textSize="@dimen/_10sdp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvHighestBreachValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tvAvgBreachValue"
|
||||
android:text="@string/stats_zero"
|
||||
android:textSize="@dimen/_10sdp" />
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlCircle"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
<string name="main_lock_sensitivity_title_arrow">→</string>
|
||||
<string name="sensitivity_value">Value: %1$s</string>
|
||||
|
||||
<!--stats-->
|
||||
<string name="stats_last_breach_value_title">Last Breach Value:</string>
|
||||
<string name="stats_avg_breach_value_title">Avg. Breach Value:</string>
|
||||
<string name="stats_highest_breach_value_title">Highest Breach Value:</string>
|
||||
<string name="stats_zero">0</string>
|
||||
|
||||
<!--intro-->
|
||||
<string name="slider_page_one_title">@string/app_name</string>
|
||||
<string name="slider_page_one_desc">Private Lock, the perfect companion to help protect your phone privacy and security.</string>
|
||||
|
|
|
@ -1 +1 @@
|
|||
Initial release.
|
||||
* Initial release.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
- Animation scaling issues fixed
|
||||
- Stop service correctly to fix memory leak & reduce code
|
||||
- Notification priority changed to low for Nougat and lower
|
||||
- Option added to run service when screen is off to be able to force PIN entry
|
||||
- Gradle & library updates
|
||||
* Animation scaling issues fixed
|
||||
* Stop service correctly to fix memory leak & reduce code
|
||||
* Notification priority changed to low for Nougat and lower
|
||||
* Option added to run service when screen is off to be able to force PIN entry
|
||||
* Gradle & library updates
|
|
@ -1,4 +1,4 @@
|
|||
- Fix for background service < Android 8.0/Oreo
|
||||
- Add option for haptic feedback (vibration) on lock trigger
|
||||
- Reworked animation logic
|
||||
- Fix 'License' and 'Bug report' links on about page
|
||||
* Fix for background service < Android 8.0/Oreo
|
||||
* Add option for haptic feedback (vibration) on lock trigger
|
||||
* Reworked animation logic
|
||||
* Fix 'License' and 'Bug report' links on about page
|
Loading…
Add table
Reference in a new issue