Added option "show"
This commit is contained in:
parent
8c95d895b4
commit
cafcbbe661
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="1.8" />
|
<bytecodeTargetLevel target="11" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -10,7 +10,7 @@ android {
|
||||||
minSdk 28
|
minSdk 28
|
||||||
targetSdk 32
|
targetSdk 32
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "0.1"
|
versionName "0.2"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@ android {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
Binary file not shown.
|
@ -12,7 +12,7 @@
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 1,
|
"versionCode": 1,
|
||||||
"versionName": "1.0",
|
"versionName": "0.2",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -24,28 +24,35 @@
|
||||||
android:theme="@style/Theme.LocateMyDevice"
|
android:theme="@style/Theme.LocateMyDevice"
|
||||||
tools:targetApi="30">
|
tools:targetApi="30">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".ShowMessageActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.app.lib_name"
|
||||||
|
android:value="" />
|
||||||
|
</activity>
|
||||||
<!-- https://developer.android.com/guide/topics/manifest/receiver-element -->
|
<!-- https://developer.android.com/guide/topics/manifest/receiver-element -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".SmsReceiver"
|
android:name=".SmsReceiver"
|
||||||
|
android:directBootAware="true"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:directBootAware="true"
|
|
||||||
android:permission="android.permission.BROADCAST_SMS">
|
android:permission="android.permission.BROADCAST_SMS">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
|
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="AdminReceiver"
|
android:name=".AdminReceiver"
|
||||||
android:permission="android.permission.BIND_DEVICE_ADMIN"
|
android:exported="true"
|
||||||
android:exported="true">
|
android:permission="android.permission.BIND_DEVICE_ADMIN">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.device_admin"
|
android:name="android.app.device_admin"
|
||||||
android:resource="@xml/device_admin"/>
|
android:resource="@xml/device_admin" />
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED"/>
|
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
@ -58,7 +65,9 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:label="Settings" android:name=".SettingsActivity"/>
|
<activity
|
||||||
|
android:name=".SettingsActivity"
|
||||||
|
android:label="Settings" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -63,7 +63,9 @@ public class SmsHandler {
|
||||||
+ "|"
|
+ "|"
|
||||||
+ Utils.WIFI_OPTION + "((" + Utils.WIFI_ENABLE_SUBOPTION + ")|(" + Utils.WIFI_DISABLE_SUBOPTION + "))?"
|
+ 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);
|
Pattern pattern = Pattern.compile(regexToMatch);
|
||||||
Matcher matcher = pattern.matcher(message);
|
Matcher matcher = pattern.matcher(message);
|
||||||
|
@ -318,5 +320,16 @@ public class SmsHandler {
|
||||||
Utils.sendSms(smsManager, responseSms.toString(), sender);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class Utils {
|
||||||
public static final String CALL_ME_OPTION = "callme";
|
public static final String CALL_ME_OPTION = "callme";
|
||||||
public static final String WIFI_OPTION = "wifi";
|
public static final String WIFI_OPTION = "wifi";
|
||||||
public static final String LOCK_OPTION = "lock";
|
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_ENABLE_SUBOPTION = "-enable";
|
||||||
public static final String WIFI_DISABLE_SUBOPTION = "-disable";
|
public static final String WIFI_DISABLE_SUBOPTION = "-disable";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".MainActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_to_display"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="This device has been lost!"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:layout_marginStart="50dp"
|
||||||
|
android:layout_marginEnd="50dp"
|
||||||
|
android:maxWidth="350sp"/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue