Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added "alert on connect", changed design a little #68

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {

defaultConfig {
applicationId "s4y.itag"
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 30
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "WAYTODAY_SECRET", "\"${System.getenv('WAYTODAY_SECRET') ?: properties.getProperty('waytoday.secret')}\""
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
android:versionCode="144"
android:versionName="2.17">

<queries>
<package android:name="com.google.android.apps.maps" />
<intent>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="geo"/>
</intent>
</queries>

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
Expand Down
Binary file added app/src/main/assets/found.mp3
Binary file not shown.
Binary file modified app/src/main/assets/lost.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/java/s4y/itag/BootReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void onReceive(@NonNull Context context, @NonNull Intent intent) {
"android.intent.action.QUICKBOOT_POWERON".equals(intent.getAction())
) {
ITagsStoreInterface store = new ITagsStoreDefault(ITagApplication.context);
if (store.isDisconnectAlert() || Waytoday.tracker.isOn(context)) {
if (store.isDisconnectAlertOn() || Waytoday.tracker.isOn(context)) {
ITagsService.start(context); // expected to create application and thus start waytooday
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/s4y/itag/ITagApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static public void faWtNoTrackID() {
public void onTerminate() {
Waytoday.done(context);
try {
ITag.close();
ITag.closeApplication();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
74 changes: 74 additions & 0 deletions app/src/main/java/s4y/itag/ITagImageView.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
package s4y.itag;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;

public class ITagImageView extends AppCompatImageView {

private static final String LT = ITagImageView.class.getName();

public ITagImageView(Context context) {
super(context);
}
Expand All @@ -20,4 +29,69 @@ public ITagImageView(Context context, @Nullable AttributeSet attrs, int defStyle
super(context, attrs, defStyleAttr);
}

private static final int CLICK_INTERVAL = ViewConfiguration.getLongPressTimeout();

private final android.os.Handler clickHandler = new Handler(Looper.getMainLooper());
private final Runnable waitNext = () -> {
isLongPress = true;
Log.d(LT, "waitNext called");
};

boolean isLongPress = false;

@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
clickHandler.postDelayed(waitNext, CLICK_INTERVAL);
Log.d(LT, "action down");
startScaleAnimation(this);
return true;
case MotionEvent.ACTION_UP:
clickHandler.removeCallbacks(waitNext);
cancelScaleAnimation(this);
Log.d(LT, "callbacks removed");
if(isLongPress){
//performLongClick();
Log.d(LT, "is longpress");
isLongPress = false;
} else {
Log.d(LT, "call performClick");
}
return true;
}
return false;
}

// Because we call this from onTouchEvent, this code will be executed for both
// normal touch events and for when the system calls this using Accessibility
@Override
public boolean performClick() {
super.performClick();
Log.d(LT, "super.performClick()");
return true;
}

private void startScaleAnimation(View view) {
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 0.8f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 0.8f);
scaleDownX.setDuration(150);
scaleDownY.setDuration(150);

scaleDownX.start();
scaleDownY.start();
}

private void cancelScaleAnimation(View view) {
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1.0f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1.0f);
scaleDownX.setDuration(150);
scaleDownY.setDuration(150);

scaleDownX.start();
scaleDownY.start();
}

}
Loading