Project commit
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
Yipanic
|
116
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,116 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
9
.idea/dictionaries/bandie.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="bandie">
|
||||
<words>
|
||||
<w>bandie</w>
|
||||
<w>passcode</w>
|
||||
<w>yipanic</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
20
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
9
.idea/misc.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
12
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
25
LICENSE
Normal file
@ -0,0 +1,25 @@
|
||||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2017, Bandie <bandie@chaospott.de>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
44
README.md
Normal file
@ -0,0 +1,44 @@
|
||||
# Yipanic
|
||||
This appilcation sends a JSON to an API with the intent to remote control your computer or infrastructure in terms of panic.
|
||||
|
||||
The app can be secured by a passcode.
|
||||
|
||||
## What the app sends
|
||||
|
||||
```json
|
||||
{
|
||||
"key": string,
|
||||
"secret": string,
|
||||
"cmd": "(lock|shutdown|panic|infraShutdown|infraPanic)"
|
||||
}
|
||||
```
|
||||
|
||||
`cmd` requires one of `lock`, `shutdown`, ...
|
||||
|
||||
|
||||
## What answers the app expect
|
||||
|
||||
```json
|
||||
{
|
||||
"access": (true|false),
|
||||
"error": int
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
At the moment the following error codes are defined:
|
||||
|
||||
```
|
||||
0 - OK
|
||||
1 - Command not set
|
||||
```
|
||||
|
||||
|
||||
## Example backend
|
||||
|
||||
See `example/index.php`.
|
||||
|
||||
|
||||
### What is ding?
|
||||
|
||||
See [ding](https://git.chaospott.de/Bandie/ding/).
|
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
34
app/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "org.bandie.yipanic"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.1"
|
||||
testFunctionalTest = false
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.android.volley:volley:1.1.1'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation 'androidx.security:security-crypto:1.0.0-rc02'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
}
|
6
app/lint.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
<issue id="IconLocation">
|
||||
<ignore path="src/main/res/drawable/bandie.png" />
|
||||
</issue>
|
||||
</lint>
|
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
BIN
app/release/app-release.apk
Normal file
1
app/release/output.json
Normal file
@ -0,0 +1 @@
|
||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]
|
34
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.bandie.yipanic">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Design">
|
||||
<activity android:name=".PasscodeActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="@string/title_activity_settings">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".CommandActivity" />
|
||||
</activity>
|
||||
<activity android:name=".CommandActivity">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".PasscodeActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
app/src/main/ic_launcher-playstore.png
Normal file
After Width: | Height: | Size: 72 KiB |
134
app/src/main/java/org/bandie/yipanic/Command.java
Normal file
@ -0,0 +1,134 @@
|
||||
package org.bandie.yipanic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.security.crypto.EncryptedSharedPreferences;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
class Command {
|
||||
private final Snackbar sbOk, sbNotSet, sbAccessDenied, sbFailed, sbNoServer;
|
||||
private String server, k, s;
|
||||
|
||||
Command(View view, Context context) {
|
||||
this.sbOk = Snackbar.make(view, "Sent. :)", 3000);
|
||||
this.sbNotSet = Snackbar.make(view, "Command not set. :/", 3000);
|
||||
this.sbAccessDenied = Snackbar.make(view, "Access denied. >:(", 3000);
|
||||
this.sbFailed = Snackbar.make(view, "Failed. :C", 3000);
|
||||
this.sbNoServer = Snackbar.make(view, "No server configured! :o", 3000);
|
||||
|
||||
try {
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
context,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
this.server = sharedPreferences.getString("server", null);
|
||||
this.k = sharedPreferences.getString("key", null);
|
||||
this.s = sharedPreferences.getString("secret", null);
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
}
|
||||
}
|
||||
|
||||
private JsonObjectRequest requestHandler(String cmd) {
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("key", this.k);
|
||||
json.put("secret", this.s);
|
||||
json.put("cmd", cmd);
|
||||
} catch (JSONException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
}
|
||||
if (this.server == null) {
|
||||
sbNoServer.show();
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectRequest
|
||||
(Request.Method.POST, this.server, json, new Response.Listener<JSONObject>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
if (response.getBoolean("access")) {
|
||||
switch (response.getInt("error")) {
|
||||
case 0:
|
||||
sbOk.show();
|
||||
break;
|
||||
case 1:
|
||||
sbNotSet.show();
|
||||
break;
|
||||
case 2:
|
||||
//Password required
|
||||
break;
|
||||
case 4:
|
||||
//Password OK
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sbAccessDenied.show();
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yip", e.getMessage());
|
||||
else
|
||||
Log.e("Yip", "[ No exception message ]");
|
||||
sbFailed.show();
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yip", e.getMessage());
|
||||
else
|
||||
Log.e("Yip", "[ No exception message ]");
|
||||
sbFailed.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
JsonObjectRequest lock() {
|
||||
return requestHandler("lock");
|
||||
}
|
||||
|
||||
JsonObjectRequest shutdown() {
|
||||
return requestHandler("shutdown");
|
||||
}
|
||||
|
||||
JsonObjectRequest panic() {
|
||||
return requestHandler("panic");
|
||||
}
|
||||
|
||||
JsonObjectRequest infraShutdown() {
|
||||
return requestHandler("infraShutdown");
|
||||
}
|
||||
|
||||
JsonObjectRequest infraPanic() {
|
||||
return requestHandler("infraPanic");
|
||||
}
|
||||
|
||||
}
|
212
app/src/main/java/org/bandie/yipanic/CommandActivity.java
Normal file
@ -0,0 +1,212 @@
|
||||
package org.bandie.yipanic;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.Switch;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.NavUtils;
|
||||
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
|
||||
|
||||
public class CommandActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.command_activity);
|
||||
|
||||
ImageButton b = findViewById(R.id.btnShutdown);
|
||||
b.setEnabled(false);
|
||||
b = findViewById(R.id.btnPanic);
|
||||
b.setEnabled(false);
|
||||
b = findViewById(R.id.btnInfraShutdown);
|
||||
b.setEnabled(false);
|
||||
b = findViewById(R.id.btnInfraPanic);
|
||||
b.setEnabled(false);
|
||||
|
||||
Switch s = findViewById(R.id.swSecShutdown1);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecShutdown2);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecPanic1);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecPanic2);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecPanic3);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecInfraShutdown1);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecInfraShutdown2);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecInfraPanic1);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecInfraPanic2);
|
||||
s.setChecked(false);
|
||||
s = findViewById(R.id.swSecInfraPanic3);
|
||||
s.setChecked(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
System.out.println(item.getItemId());
|
||||
switch (item.getItemId()) {
|
||||
case 16908332:
|
||||
case R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
public void sendLockCmd(View view) {
|
||||
Command c = new Command(view, getApplicationContext());
|
||||
JsonObjectRequest send = c.lock();
|
||||
if (send != null)
|
||||
Volley.newRequestQueue(this).add(send);
|
||||
}
|
||||
|
||||
public void sendShutdownCmd(View view) {
|
||||
Command c = new Command(view, getApplicationContext());
|
||||
JsonObjectRequest send = c.shutdown();
|
||||
if (send != null)
|
||||
Volley.newRequestQueue(this).add(send);
|
||||
}
|
||||
|
||||
public void sendPanicCmd(View view) {
|
||||
Command c = new Command(view, getApplicationContext());
|
||||
JsonObjectRequest send = c.panic();
|
||||
if (send != null)
|
||||
Volley.newRequestQueue(this).add(send);
|
||||
}
|
||||
|
||||
public void sendInfraShutdownCmd(View view) {
|
||||
Command c = new Command(view, getApplicationContext());
|
||||
JsonObjectRequest send = c.infraShutdown();
|
||||
if (send != null)
|
||||
Volley.newRequestQueue(this).add(send);
|
||||
}
|
||||
|
||||
public void sendInfraPanicCmd(View view) {
|
||||
Command c = new Command(view, getApplicationContext());
|
||||
JsonObjectRequest send = c.infraPanic();
|
||||
if (send != null)
|
||||
Volley.newRequestQueue(this).add(send);
|
||||
}
|
||||
|
||||
public void switchShutdown(View view) {
|
||||
final Switch s = findViewById(view.getId());
|
||||
Switch s1 = findViewById(R.id.swSecShutdown1);
|
||||
Switch s2 = findViewById(R.id.swSecShutdown2);
|
||||
ImageButton b = findViewById(R.id.btnShutdown);
|
||||
if (s1.isChecked() && s2.isChecked())
|
||||
b.setEnabled(true);
|
||||
else
|
||||
b.setEnabled(false);
|
||||
|
||||
if (s.isChecked()) {
|
||||
Handler h = new Handler();
|
||||
h.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageButton b = findViewById(R.id.btnShutdown);
|
||||
s.setChecked(false);
|
||||
b.setEnabled(false);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
public void switchPanic(View view) {
|
||||
final Switch s = findViewById(view.getId());
|
||||
Switch s1 = findViewById(R.id.swSecPanic1);
|
||||
Switch s2 = findViewById(R.id.swSecPanic2);
|
||||
Switch s3 = findViewById(R.id.swSecPanic3);
|
||||
ImageButton b = findViewById(R.id.btnPanic);
|
||||
if (s1.isChecked() && s2.isChecked() && s3.isChecked())
|
||||
b.setEnabled(true);
|
||||
else
|
||||
b.setEnabled(false);
|
||||
|
||||
if (s.isChecked()) {
|
||||
Handler h = new Handler();
|
||||
h.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageButton b = findViewById(R.id.btnPanic);
|
||||
s.setChecked(false);
|
||||
b.setEnabled(false);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
public void switchInfraShutdown(View view) {
|
||||
final Switch s = findViewById(view.getId());
|
||||
Switch s1 = findViewById(R.id.swSecInfraShutdown1);
|
||||
Switch s2 = findViewById(R.id.swSecInfraShutdown2);
|
||||
ImageButton b = findViewById(R.id.btnInfraShutdown);
|
||||
if (s1.isChecked() && s2.isChecked())
|
||||
b.setEnabled(true);
|
||||
else
|
||||
b.setEnabled(false);
|
||||
|
||||
if (s.isChecked()) {
|
||||
Handler h = new Handler();
|
||||
h.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageButton b = findViewById(R.id.btnInfraShutdown);
|
||||
s.setChecked(false);
|
||||
b.setEnabled(false);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
public void switchInfraPanic(View view) {
|
||||
final Switch s = findViewById(view.getId());
|
||||
Switch s1 = findViewById(R.id.swSecInfraPanic1);
|
||||
Switch s2 = findViewById(R.id.swSecInfraPanic2);
|
||||
Switch s3 = findViewById(R.id.swSecInfraPanic3);
|
||||
ImageButton b = findViewById(R.id.btnInfraPanic);
|
||||
if (s1.isChecked() && s2.isChecked() && s3.isChecked())
|
||||
b.setEnabled(true);
|
||||
else
|
||||
b.setEnabled(false);
|
||||
|
||||
if (s.isChecked()) {
|
||||
Handler h = new Handler();
|
||||
h.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImageButton b = findViewById(R.id.btnInfraPanic);
|
||||
s.setChecked(false);
|
||||
b.setEnabled(false);
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void startSettingsActivity(@SuppressWarnings("unused") View view) {
|
||||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
120
app/src/main/java/org/bandie/yipanic/PasscodeActivity.java
Normal file
@ -0,0 +1,120 @@
|
||||
package org.bandie.yipanic;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.security.crypto.EncryptedSharedPreferences;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Random;
|
||||
|
||||
public class PasscodeActivity<RequestQueue, StringRequest> extends AppCompatActivity {
|
||||
|
||||
private String passcode;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_passcode);
|
||||
|
||||
try {
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
getApplicationContext(),
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
this.passcode = sharedPreferences.getString("passcode", null);
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
}
|
||||
|
||||
if (this.passcode == null) {
|
||||
Intent intent = new Intent(this, CommandActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
try {
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
getApplicationContext(),
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
this.passcode = sharedPreferences.getString("passcode", null);
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yip", e.getMessage());
|
||||
else
|
||||
Log.e("Yip", "[ No exception message ]");
|
||||
}
|
||||
|
||||
if (this.passcode == null) {
|
||||
Intent intent = new Intent(this, CommandActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPasscode() {
|
||||
EditText v = findViewById(R.id.pwPasscodeInput);
|
||||
if (v.getText().toString().equals(this.passcode) || this.passcode == null) {
|
||||
v.setText("");
|
||||
Intent intent = new Intent(this, CommandActivity.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
v.setText("");
|
||||
v.setError("Passcode wrong.");
|
||||
}
|
||||
}
|
||||
|
||||
public void yip(@SuppressWarnings("unused") View view) {
|
||||
int audio;
|
||||
|
||||
switch (new Random().nextInt(4)) {
|
||||
default:
|
||||
case 0:
|
||||
audio = R.raw.yip1;
|
||||
break;
|
||||
case 1:
|
||||
audio = R.raw.yip2;
|
||||
break;
|
||||
case 2:
|
||||
audio = R.raw.yip3;
|
||||
break;
|
||||
case 3:
|
||||
audio = R.raw.yip4;
|
||||
break;
|
||||
}
|
||||
|
||||
MediaPlayer mp = MediaPlayer.create(this, audio);
|
||||
mp.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
this.checkPasscode();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
197
app/src/main/java/org/bandie/yipanic/SettingsActivity.java
Normal file
@ -0,0 +1,197 @@
|
||||
package org.bandie.yipanic;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.NavUtils;
|
||||
import androidx.security.crypto.EncryptedSharedPreferences;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case 16908332:
|
||||
case R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.settings_activity);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
EditText srv = findViewById(R.id.textServer);
|
||||
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
try {
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
getApplicationContext(),
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
String server = sharedPreferences.getString("server", null);
|
||||
srv.setText(server);
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
this.finish();
|
||||
}
|
||||
|
||||
public void saveServerSettings(View view) {
|
||||
Snackbar sbSaved = Snackbar.make(view, "Server settings saved! <3", 3000);
|
||||
Snackbar sbFailedToSave = Snackbar.make(view, "Couldn't save settings! :'(", 3000);
|
||||
try {
|
||||
EditText srv = findViewById(R.id.textServer);
|
||||
EditText k = findViewById(R.id.pwKey);
|
||||
EditText s = findViewById(R.id.pwSecret);
|
||||
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
this,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
|
||||
SharedPreferences.Editor sharedPrefsEditor = sharedPreferences.edit();
|
||||
sharedPrefsEditor.putString("server", srv.getText().toString());
|
||||
if (!k.getText().toString().equals(""))
|
||||
sharedPrefsEditor.putString("key", k.getText().toString());
|
||||
if (!s.getText().toString().equals(""))
|
||||
sharedPrefsEditor.putString("secret", s.getText().toString());
|
||||
|
||||
sharedPrefsEditor.apply();
|
||||
sbSaved.show();
|
||||
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
sbFailedToSave.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void savePasscode(View view) {
|
||||
Snackbar sbSaved = Snackbar.make(view, "Passcode saved! <3", 3000);
|
||||
Snackbar sbFailedToSave = Snackbar.make(view, "Couldn't save! :'(", 3000);
|
||||
try {
|
||||
EditText pc = findViewById(R.id.pwSetPasscode);
|
||||
EditText pcc = findViewById(R.id.pwSetPasscodeConfirm);
|
||||
String pcS = pc.getText().toString();
|
||||
String pccS = pcc.getText().toString();
|
||||
|
||||
if (pcS.equals("") || pccS.equals("")) {
|
||||
pc.setError("Passcode is empty. >;(");
|
||||
pcc.setError("Passcode is empty. >;(");
|
||||
sbFailedToSave.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pcS.length() < 4) {
|
||||
pc.setError("Passcode needs to have at least 4 digits.");
|
||||
pcc.setError("Passcode needs to have at least 4 digits.");
|
||||
sbFailedToSave.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pcS.equals(pccS)) {
|
||||
pc.setError("Passcode didn't match. ;(");
|
||||
pcc.setError("Passcode didn't match. ;(");
|
||||
sbFailedToSave.show();
|
||||
return;
|
||||
}
|
||||
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
this,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
|
||||
SharedPreferences.Editor sharedPrefsEditor = sharedPreferences.edit();
|
||||
sharedPrefsEditor.putString("passcode", pcS);
|
||||
sharedPrefsEditor.apply();
|
||||
sbSaved.show();
|
||||
pc.setText("");
|
||||
pcc.setText("");
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
sbFailedToSave.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePasscode(View view) {
|
||||
Snackbar sbSaved = Snackbar.make(view, "Passcode deleted! D:", 3000);
|
||||
Snackbar sbFailedToSave = Snackbar.make(view, "Couldn't delete passcode! :'(", 3000);
|
||||
try {
|
||||
EditText pc = findViewById(R.id.pwSetPasscode);
|
||||
String pcS = pc.getText().toString();
|
||||
|
||||
EncryptedSharedPreferences sharedPreferences = (EncryptedSharedPreferences) EncryptedSharedPreferences
|
||||
.create(
|
||||
"Yipanic",
|
||||
"Yipanic",
|
||||
this,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
||||
);
|
||||
|
||||
SharedPreferences.Editor sharedPrefsEditor = sharedPreferences.edit();
|
||||
|
||||
if (pcS.equals(sharedPreferences.getString("passcode", null))) {
|
||||
sharedPrefsEditor.remove("passcode");
|
||||
sharedPrefsEditor.apply();
|
||||
sbSaved.show();
|
||||
} else {
|
||||
pc.setError("Wrong passcode.");
|
||||
sbFailedToSave.show();
|
||||
}
|
||||
|
||||
} catch (IOException | GeneralSecurityException e) {
|
||||
if (e.getMessage() != null)
|
||||
Log.e("Yipanic", e.getMessage());
|
||||
else
|
||||
Log.e("Yipanic", "[ No exception message ]");
|
||||
sbFailedToSave.show();
|
||||
}
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable/bandie.png
Normal file
After Width: | Height: | Size: 37 KiB |
43
app/src/main/res/layout/activity_passcode.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?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=".PasscodeActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pwPasscodeInput"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="240dp"
|
||||
android:ems="10"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberPassword"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/pwPasscodeInput"
|
||||
android:text="@string/passcode"
|
||||
app:layout_constraintBottom_toTopOf="@+id/pwPasscodeInput"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.498"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="157dp"
|
||||
android:layout_height="155dp"
|
||||
android:layout_marginTop="44dp"
|
||||
android:contentDescription="@string/bandie_who_is_a_big_yip"
|
||||
android:onClick="yip"
|
||||
android:soundEffectsEnabled="false"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/bandie" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
295
app/src/main/res/layout/command_activity.xml
Normal file
@ -0,0 +1,295 @@
|
||||
<?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=".CommandActivity">
|
||||
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout_editor_absoluteX="0dp"
|
||||
tools:layout_editor_absoluteY="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/labelLock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lock" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnLock"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="0dp"
|
||||
android:backgroundTint="#246FA8"
|
||||
android:contentDescription="@string/send_lock_command"
|
||||
android:onClick="sendLockCmd"
|
||||
app:srcCompat="@android:drawable/ic_lock_idle_lock" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="86dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="72dp"
|
||||
android:gravity="top"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/labelShutdown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:text="@string/shutdown" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnShutdown"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:backgroundTint="#734B1A"
|
||||
android:contentDescription="@string/send_shutdown_command"
|
||||
android:onClick="sendShutdownCmd"
|
||||
app:srcCompat="@android:drawable/ic_lock_power_off" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecShutdown1"
|
||||
android:layout_width="113dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:onClick="switchShutdown"
|
||||
android:text="@string/shutdown" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecShutdown2"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:onClick="switchShutdown"
|
||||
android:text="@string/shutdown" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="113dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/labelPanic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/panic" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnPanic"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="45dp"
|
||||
android:backgroundTint="#880000"
|
||||
android:contentDescription="@string/panic"
|
||||
android:onClick="sendPanicCmd"
|
||||
app:srcCompat="@android:drawable/ic_menu_delete" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="232dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecPanic1"
|
||||
android:layout_width="113dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:onClick="switchPanic"
|
||||
android:text="@string/panic" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecPanic2"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="switchPanic"
|
||||
android:text="@string/panic" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecPanic3"
|
||||
android:layout_width="205dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="switchPanic"
|
||||
android:text="@string/panic" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="85dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="top"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/labelInfraShutdown"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/infra_shutdown" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnInfraShutdown"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="45dp"
|
||||
android:backgroundTint="#B36200"
|
||||
android:contentDescription="@string/infra_shutdown"
|
||||
android:onClick="sendInfraShutdownCmd"
|
||||
app:srcCompat="?android:attr/alertDialogIcon" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecInfraShutdown1"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:onClick="switchInfraShutdown"
|
||||
android:text="@string/infra_shutdown" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecInfraShutdown2"
|
||||
android:layout_width="205dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="switchInfraShutdown"
|
||||
android:text="@string/infra_shutdown" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/labelInfraPanic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/infra_panic" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnInfraPanic"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="45dp"
|
||||
android:backgroundTint="#9C0000"
|
||||
android:contentDescription="@string/infra_panic"
|
||||
android:onClick="sendInfraPanicCmd"
|
||||
app:srcCompat="@android:drawable/ic_menu_close_clear_cancel" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecInfraPanic1"
|
||||
android:layout_width="117dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:onClick="switchInfraPanic"
|
||||
android:text="@string/infra_panic" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecInfraPanic2"
|
||||
android:layout_width="159dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="switchInfraPanic"
|
||||
android:text="@string/infra_panic" />
|
||||
|
||||
<Switch
|
||||
android:id="@+id/swSecInfraPanic3"
|
||||
android:layout_width="206dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="switchInfraPanic"
|
||||
android:text="@string/infra_panic" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:onClick="startSettingsActivity"
|
||||
app:backgroundTint="@color/colorPrimaryDark"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@android:drawable/ic_menu_manage" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
154
app/src/main/res/layout/settings_activity.xml
Normal file
@ -0,0 +1,154 @@
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/textServer"
|
||||
android:text="@string/server"
|
||||
android:textColor="#999" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textServer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/editTextBackground"
|
||||
android:backgroundTint="#999999"
|
||||
android:contentDescription="@string/server"
|
||||
android:ems="10"
|
||||
android:foregroundTint="#FFFFFF"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textPersonName"
|
||||
android:singleLine="true"
|
||||
android:textColor="#CCCCCC"
|
||||
android:textColorHint="#444444" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/pwKey"
|
||||
android:text="@string/key"
|
||||
android:textColor="#999" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pwKey"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="#999999"
|
||||
android:contentDescription="@string/some_api_key"
|
||||
android:ems="10"
|
||||
android:foregroundTint="#FFFFFF"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:textColor="#CCCCCC"
|
||||
android:textColorHint="#444444" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/pwSecret"
|
||||
android:text="@string/secret"
|
||||
android:textColor="#999" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pwSecret"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="#999999"
|
||||
android:contentDescription="@string/some_api_secret"
|
||||
android:ems="10"
|
||||
android:foregroundTint="#FFFFFF"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:textColor="#CCCCCC"
|
||||
android:textColorHint="#444444" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="122dp">
|
||||
|
||||
<Button
|
||||
android:layout_width="205dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="#777777"
|
||||
android:onClick="saveServerSettings"
|
||||
android:text="@string/save"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/pwSetPasscode"
|
||||
android:text="@string/passcode" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pwSetPasscode"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberPassword" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:labelFor="@id/pwSetPasscodeConfirm"
|
||||
android:text="@string/confirm_passcode" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/pwSetPasscodeConfirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:importantForAutofill="no"
|
||||
android:inputType="numberPassword" />
|
||||
|
||||
<LinearLayout
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:onClick="deletePasscode"
|
||||
android:text="@string/delete" />
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:onClick="savePasscode"
|
||||
android:text="@string/set" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="19dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/to_delete_your_passcode_type_in_the_passcode_in_the_first_field_and_press_delete" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@color/ic_launcher_background" />
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
app/src/main/res/raw/yip1.mp3
Normal file
BIN
app/src/main/res/raw/yip2.mp3
Normal file
BIN
app/src/main/res/raw/yip3.mp3
Normal file
BIN
app/src/main/res/raw/yip4.mp3
Normal file
4
app/src/main/res/values/arrays.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<!-- Reply Preference -->
|
||||
|
||||
</resources>
|
4
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimaryDark">#3700B3</color>
|
||||
</resources>
|
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#2B2B2B</color>
|
||||
</resources>
|
4
app/src/main/res/values/ids.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
</resources>
|
23
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<resources>
|
||||
<string name="app_name">Yipanic</string>
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
<string name="key">Key</string>
|
||||
<string name="secret">Secret</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="server">Server</string>
|
||||
<string name="some_api_key">Some API key</string>
|
||||
<string name="some_api_secret">Some API secret</string>
|
||||
<string name="send_lock_command">Send lock command</string>
|
||||
<string name="send_shutdown_command">Send shutdown command</string>
|
||||
<string name="bandie_who_is_a_big_yip">Bandie who is a big yip</string>
|
||||
<string name="passcode">Passcode</string>
|
||||
<string name="confirm_passcode">Confirm Passcode</string>
|
||||
<string name="delete">Delete</string>
|
||||
<string name="set">Set</string>
|
||||
<string name="to_delete_your_passcode_type_in_the_passcode_in_the_first_field_and_press_delete">To delete your passcode, type in the passcode in the first field and press delete.</string>
|
||||
<string name="panic">Panic</string>
|
||||
<string name="infra_shutdown">Infra-Shutdown</string>
|
||||
<string name="infra_panic">Infra-Panic</string>
|
||||
<string name="shutdown">Shutdown</string>
|
||||
<string name="lock">Lock</string>
|
||||
</resources>
|
5
app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
|
||||
</resources>
|
29
build.gradle
Normal file
@ -0,0 +1,29 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
63
example/index.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
// Author: Bandie <bandie@chaospott.de>
|
||||
// Project: Yipanic
|
||||
// License: GNU-GPLv3
|
||||
|
||||
define("_KEY_", "somekey");
|
||||
define("_SEC_", "somesecret");
|
||||
|
||||
$json = json_decode(file_get_contents('php://input', true));
|
||||
|
||||
function checkCreds($json){
|
||||
return (_KEY_ == $json->key && _SEC_ == $json->secret);
|
||||
}
|
||||
|
||||
function execCmd($cmd) {
|
||||
exec("/usr/bin/python3 /var/www/ding/ding -c /var/www/ding/ding.cfg $cmd >> /dev/null", $output, $retval);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function execCmdInfra($cmd) {
|
||||
exec("/usr/bin/python3 /var/www/dingInfra/ding -c /var/www/dingInfra/ding.cfg $cmd >> /dev/null", $output, $retval);
|
||||
return $retval;
|
||||
}
|
||||
|
||||
if(checkCreds($json)){
|
||||
$access = true;
|
||||
|
||||
switch($json->cmd) {
|
||||
case "lock":
|
||||
$retval = execCmd("lock");
|
||||
break;
|
||||
case "shutdown":
|
||||
$retval = execCmd("shutdown");
|
||||
break;
|
||||
case "panic":
|
||||
$retval = execCmd("panic");
|
||||
break;
|
||||
case "infraShutdown":
|
||||
$retval = execCmdInfra("shutdown");
|
||||
break;
|
||||
case "infraPanic":
|
||||
$retval = execCmdInfra("panic");
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
$access = false;
|
||||
}
|
||||
|
||||
|
||||
$ret = array(
|
||||
"access" => $access,
|
||||
"error" => $retval
|
||||
);
|
||||
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
echo(json_encode($ret));
|
||||
|
||||
?>
|
||||
|
||||
|
20
gradle.properties
Normal file
@ -0,0 +1,20 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Sun Apr 19 00:07:21 CEST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
172
gradlew
vendored
Executable file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
gradlew.bat
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
2
settings.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name='Yipanic'
|
||||
include ':app'
|