Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabehxd committed Jul 18, 2020
1 parent 16791e9 commit e47e495
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Server/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Server/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="net.sunthecourier.questpresence">
<uses-feature android:name="android.software.leanback" android:required="false"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
Expand Down Expand Up @@ -35,19 +36,27 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, QuestService.class);
final Button mainBtn = findViewById(R.id.presence_btn);
final TextView text = findViewById(R.id.statusBox);
if (QuestService.runnable == null) {
startService(intent);
mainBtn.setText(R.string.stop_btn);
text.setText(R.string.start_action);
}
else {
//stopService(intent);
QuestService.runnable = null;
stopService(intent);
mainBtn.setText(R.string.start_btn);
text.setText(R.string.exit_action);
}
}

public void onExitClick(View view) {
System.exit(0);
new Thread(() -> {
try {
Thread.sleep(1200);
}
catch (InterruptedException e) {
e.printStackTrace();
}
android.os.Process.sendSignal(android.os.Process.myPid(), Process.SIGNAL_KILL);
}).start();
}

void requestUsageStatsPermission() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ public void onCreate() {
*/
}

@Override public void onDestroy() {
//thread.interrupt();

try {
sender.clean();
}
catch (IOException e) {
e.printStackTrace();
}
super.onDestroy();
}

private String getPkgName() {
return new AppChecker().getForegroundApp(this.getBaseContext());
}
Expand Down
15 changes: 9 additions & 6 deletions Server/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginBottom="48dp" app:layout_constraintBottom_toTopOf="@+id/presence_btn"/>
<Button
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/exitBtn"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="40dp"
app:layout_constraintTop_toBottomOf="@+id/presence_btn" android:onClick="onExitClick"
android:text="@string/exit_btn"/>
android:layout_height="wrap_content" android:id="@+id/statusBox"
android:capitalize="none"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="66dp"
app:layout_constraintTop_toBottomOf="@+id/presence_btn"
android:text="@string/wait"/>
</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 3 additions & 1 deletion Server/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
<string name="start_btn">Start Presence</string>
<string name="stop_btn">Stop Presence</string>
<string name="plchdr">plchdr</string>
<string name="exit_btn">Exit</string>
<string name="exit_action">Stopping server, now exiting!</string>
<string name="start_action">Starting server, now exiting!</string>
<string name="wait">Waiting for input!</string>
</resources>

0 comments on commit e47e495

Please sign in to comment.