diff --git a/src/.idea/compiler.xml b/src/.idea/compiler.xml index 61a9130..fb7f4a8 100644 --- a/src/.idea/compiler.xml +++ b/src/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/app/build.gradle b/src/app/build.gradle index 34b0d2a..375c1af 100644 --- a/src/app/build.gradle +++ b/src/app/build.gradle @@ -10,7 +10,7 @@ android { minSdk 28 targetSdk 32 versionCode 1 - versionName "0.1" + versionName "0.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -25,6 +25,9 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + buildFeatures { + viewBinding true + } } dependencies { diff --git a/src/app/release/app-release.apk b/src/app/release/Locate My Device.apk similarity index 64% rename from src/app/release/app-release.apk rename to src/app/release/Locate My Device.apk index 5bf9946..6bfa321 100644 Binary files a/src/app/release/app-release.apk and b/src/app/release/Locate My Device.apk differ diff --git a/src/app/release/output-metadata.json b/src/app/release/output-metadata.json index 6d99d3f..a760d37 100644 --- a/src/app/release/output-metadata.json +++ b/src/app/release/output-metadata.json @@ -12,7 +12,7 @@ "filters": [], "attributes": [], "versionCode": 1, - "versionName": "1.0", + "versionName": "0.2", "outputFile": "app-release.apk" } ], diff --git a/src/app/src/main/AndroidManifest.xml b/src/app/src/main/AndroidManifest.xml index ac66b94..147c5e9 100644 --- a/src/app/src/main/AndroidManifest.xml +++ b/src/app/src/main/AndroidManifest.xml @@ -24,28 +24,35 @@ android:theme="@style/Theme.LocateMyDevice" tools:targetApi="30"> + + + - + - + android:name=".AdminReceiver" + android:exported="true" + android:permission="android.permission.BIND_DEVICE_ADMIN"> + android:resource="@xml/device_admin" /> - + @@ -58,7 +65,9 @@ - + \ No newline at end of file diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/ShowMessageActivity.java b/src/app/src/main/java/com/xfarrow/locatemydevice/ShowMessageActivity.java new file mode 100644 index 0000000..f3a657a --- /dev/null +++ b/src/app/src/main/java/com/xfarrow/locatemydevice/ShowMessageActivity.java @@ -0,0 +1,51 @@ +package com.xfarrow.locatemydevice; + +import android.app.KeyguardManager; +import android.content.Context; +import android.os.Build; +import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; +import android.view.WindowManager; +import android.widget.TextView; + +public class ShowMessageActivity extends AppCompatActivity { + + private TextView textToDisplay; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_show_message); + showOnLockscreen(); + setViews(); + String messageToDisplay = getData(); + textToDisplay.setText(messageToDisplay); + } + + // https://stackoverflow.com/questions/35356848/android-how-to-launch-activity-over-lock-screen + private void showOnLockscreen(){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) + { + setShowWhenLocked(true); + setTurnScreenOn(true); + } + else + { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | + WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + } + } + + private String getData(){ + Bundle extras = getIntent().getExtras(); + if (extras != null) { + return extras.getString(Utils.SHOW_MESSAGE_OPTION); + } + return null; + } + + private void setViews(){ + textToDisplay = findViewById(R.id.text_to_display); + } + +} \ No newline at end of file diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java b/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java index ee241ba..847d218 100644 --- a/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java +++ b/src/app/src/main/java/com/xfarrow/locatemydevice/SmsHandler.java @@ -63,7 +63,9 @@ public class SmsHandler { + "|" + Utils.WIFI_OPTION + "((" + Utils.WIFI_ENABLE_SUBOPTION + ")|(" + Utils.WIFI_DISABLE_SUBOPTION + "))?" + "|" - + Utils.LOCK_OPTION; + + Utils.LOCK_OPTION + + "|" + + Utils.SHOW_MESSAGE_OPTION + "\\s+\"[\\w\\W]*[\"]$"; Pattern pattern = Pattern.compile(regexToMatch); Matcher matcher = pattern.matcher(message); @@ -318,5 +320,16 @@ public class SmsHandler { Utils.sendSms(smsManager, responseSms.toString(), sender); } + //show + else if(providedOption.contains(Utils.SHOW_MESSAGE_OPTION)){ + String messageToDisplay = message.substring(message.indexOf("\"") + 1, + message.lastIndexOf("\"")); + + Intent lockScreenMessage = new Intent(context, ShowMessageActivity.class); + lockScreenMessage.putExtra(Utils.SHOW_MESSAGE_OPTION, messageToDisplay); + lockScreenMessage.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(lockScreenMessage); + } + } } diff --git a/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java b/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java index 8e33d9d..877412e 100644 --- a/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java +++ b/src/app/src/main/java/com/xfarrow/locatemydevice/Utils.java @@ -18,6 +18,7 @@ public class Utils { public static final String CALL_ME_OPTION = "callme"; public static final String WIFI_OPTION = "wifi"; public static final String LOCK_OPTION = "lock"; + public static final String SHOW_MESSAGE_OPTION = "show"; public static final String WIFI_ENABLE_SUBOPTION = "-enable"; public static final String WIFI_DISABLE_SUBOPTION = "-disable"; diff --git a/src/app/src/main/res/layout/activity_show_message.xml b/src/app/src/main/res/layout/activity_show_message.xml new file mode 100644 index 0000000..1fa2b0d --- /dev/null +++ b/src/app/src/main/res/layout/activity_show_message.xml @@ -0,0 +1,22 @@ + + + + + \ No newline at end of file