Initialier Commit
15
.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
*.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
|
||||
local.properties
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
1
.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
XXX BDSM Game
|
||||
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<?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="GRADLE" />
|
||||
<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>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
10
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Embedded JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
1
app/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
47
app/build.gradle
Normal file
@@ -0,0 +1,47 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.example.xxxbdsmgame'
|
||||
compileSdk 33
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.example.xxxbdsmgame"
|
||||
minSdk 24
|
||||
targetSdk 33
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-ui:2.4.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
}
|
||||
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
|
||||
47
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.XXXBDSMGame"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name="de.oaa.xxxbdsmgame.ui.gruppe.anzeige.GruppeAnzeigenActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_gruppe_anzeigen"
|
||||
android:theme="@style/Theme.XXXBDSMGame.NoActionBar" />
|
||||
<activity
|
||||
android:name="de.oaa.xxxbdsmgame.ui.sets.SetsActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_sets" />
|
||||
<activity
|
||||
android:name="de.oaa.xxxbdsmgame.ui.menu.MenuActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_menu" />
|
||||
<activity
|
||||
android:name="de.oaa.xxxbdsmgame.ui.register.RegisterActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_register" />
|
||||
<activity
|
||||
android:name="de.oaa.xxxbdsmgame.ui.login.LoginActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
6
app/src/main/java/de/oaa/xxxbdsmgame/Constants.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package de.oaa.xxxbdsmgame;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String SERVICE_HOST = "http://10.0.2.2:8080";
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package de.oaa.xxxbdsmgame.data;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.model.LoggedInUser;
|
||||
|
||||
/**
|
||||
* Class that requests authentication and user information from the remote data source and
|
||||
* maintains an in-memory cache of login status and user credentials information.
|
||||
*/
|
||||
public class LoginRepository {
|
||||
|
||||
private static volatile LoginRepository instance;
|
||||
|
||||
// If user credentials will be cached in local storage, it is recommended it be encrypted
|
||||
// @see https://developer.android.com/training/articles/keystore
|
||||
private LoggedInUser user = null;
|
||||
|
||||
// private constructor : singleton access
|
||||
private LoginRepository() {
|
||||
}
|
||||
|
||||
public static LoginRepository getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoginRepository();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
return user != null;
|
||||
}
|
||||
|
||||
private void setLoggedInUser(LoggedInUser user) {
|
||||
this.user = user;
|
||||
// If user credentials will be cached in local storage, it is recommended it be encrypted
|
||||
// @see https://developer.android.com/training/articles/keystore
|
||||
}
|
||||
|
||||
public Result<LoggedInUser> login(String username, String password) {
|
||||
// handle login
|
||||
LoginTask task = new LoginTask();
|
||||
task.execute(username, password);
|
||||
try {
|
||||
return task.get();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
app/src/main/java/de/oaa/xxxbdsmgame/data/LoginTask.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package de.oaa.xxxbdsmgame.data;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.model.LoggedInUser;
|
||||
|
||||
import de.oaa.xxxbdsmgame.util.PasswordHelper;
|
||||
|
||||
public class LoginTask extends AsyncTask<String, Void, Result> {
|
||||
|
||||
@Override
|
||||
protected Result<LoggedInUser> doInBackground(String[] strings) {
|
||||
|
||||
try {
|
||||
String hash = PasswordHelper.hashPassword(strings[1]);
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/user-service/login?email=" + strings[0] + "&hash=" + hash);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == 200) {
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuffer response = new StringBuffer();
|
||||
String inputLine;
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
LoggedInUser user = new LoggedInUser(response.toString());
|
||||
return Result.success(user);
|
||||
} else {
|
||||
return Result.error(new IllegalArgumentException("Unknown User"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Error logging in", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package de.oaa.xxxbdsmgame.data;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* Class that requests authentication and user information from the remote data source and
|
||||
* maintains an in-memory cache of login status and user credentials information.
|
||||
*/
|
||||
public class RegisterRepository {
|
||||
|
||||
private static volatile RegisterRepository instance;
|
||||
|
||||
private RegisterRepository() {
|
||||
}
|
||||
|
||||
public static RegisterRepository getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new RegisterRepository();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Result<Boolean> register(String name, String email, String password) {
|
||||
RegisterTask task = new RegisterTask();
|
||||
task.execute(name, email, password);
|
||||
try {
|
||||
return task.get();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
57
app/src/main/java/de/oaa/xxxbdsmgame/data/RegisterTask.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package de.oaa.xxxbdsmgame.data;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.model.LoggedInUser;
|
||||
import de.oaa.xxxbdsmgame.util.PasswordHelper;
|
||||
|
||||
public class RegisterTask extends AsyncTask<String, Void, Result> {
|
||||
|
||||
@Override
|
||||
protected Result<Boolean> doInBackground(String... strings) {
|
||||
try {
|
||||
String hash = PasswordHelper.hashPassword(strings[2]);
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/registration-service/registration/");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Accept","application/json");
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(true);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("name", strings[0]);
|
||||
object.put("email", strings[1]);
|
||||
object.put("passwordHash", hash);
|
||||
|
||||
DataOutputStream os = new DataOutputStream(connection.getOutputStream());
|
||||
//os.writeBytes(URLEncoder.encode(jsonParam.toString(), "UTF-8"));
|
||||
os.writeBytes(object.toString());
|
||||
os.flush();
|
||||
os.close();
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == 202) {
|
||||
return Result.success(Boolean.TRUE);
|
||||
} else {
|
||||
return Result.error(new IllegalArgumentException("Unknown User"));
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Error logging in", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
37
app/src/main/java/de/oaa/xxxbdsmgame/data/Result.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package de.oaa.xxxbdsmgame.data;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* A generic class that holds a result success w/ data or an error exception.
|
||||
*/
|
||||
public class Result<T> {
|
||||
|
||||
private T data;
|
||||
|
||||
private Exception error;
|
||||
|
||||
// hide the private constructor to limit subclass types (Success, Error)
|
||||
private Result() {
|
||||
}
|
||||
|
||||
public static <T> Result<T> success(T data) {
|
||||
Result<T> result = new Result<>();
|
||||
result.data = data;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> Result<T> error(Exception error) {
|
||||
Result<T> result = new Result<>();
|
||||
result.error = error;
|
||||
return result;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Exception getError() {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.oaa.xxxbdsmgame.data.model;
|
||||
|
||||
/**
|
||||
* Data class that captures user information for logged in users retrieved from LoginRepository
|
||||
*/
|
||||
public class LoggedInUser {
|
||||
|
||||
private final String token;
|
||||
|
||||
public LoggedInUser(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
public class AufgabenGruppeAbrufenTask extends AsyncTask<String, Void, Result> {
|
||||
private String token;
|
||||
|
||||
public AufgabenGruppeAbrufenTask(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<JSONObject> doInBackground(String... strings) {
|
||||
JSONObject result = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/aufgaben-service/gruppe/" + strings[0]);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("token", token);
|
||||
if (connection.getResponseCode() == 200) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
br.close();
|
||||
result = new JSONObject(sb.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Request error", e));
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
return Result.error(new IOException("Request error", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result != null ? Result.success(result) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
import de.oaa.xxxbdsmgame.util.PasswordHelper;
|
||||
import de.oaa.xxxbdsmgame.util.TokenHelper;
|
||||
|
||||
public class AufgabenGruppenAbrufenTask extends AsyncTask<String, Void, Result> {
|
||||
|
||||
private String token;
|
||||
|
||||
public AufgabenGruppenAbrufenTask(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<JSONObject> doInBackground(String... strings) {
|
||||
JSONObject result = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/aufgaben-service/gruppe/" + strings[0] + (strings.length == 2 ? "?search=" + strings[1] : ""));
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("token", token);
|
||||
if (connection.getResponseCode() == 200) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
br.close();
|
||||
result = new JSONObject(sb.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Request error", e));
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
return Result.error(new IOException("Request error", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result != null ? Result.success(result) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
public class FavoritEntfernenTask extends AsyncTask<String, Void, Result> {
|
||||
private String token;
|
||||
|
||||
public FavoritEntfernenTask(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<Boolean> doInBackground(String... strings) {
|
||||
try {
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/aufgaben-service/favorit/");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("DELETE");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(false);
|
||||
|
||||
connection.setRequestProperty("token", token);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("aufgabenGruppeId", strings[0]);
|
||||
|
||||
DataOutputStream os = new DataOutputStream(connection.getOutputStream());
|
||||
//os.writeBytes(URLEncoder.encode(jsonParam.toString(), "UTF-8"));
|
||||
os.writeBytes(object.toString());
|
||||
os.flush();
|
||||
os.close();
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == 201) {
|
||||
return Result.success(Boolean.TRUE);
|
||||
} else {
|
||||
return Result.error(new IllegalArgumentException("Unknown User"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Request error", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
public class FavoritErstellenTask extends AsyncTask<String, Void, Result> {
|
||||
private String token;
|
||||
|
||||
public FavoritErstellenTask(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<Boolean> doInBackground(String... strings) {
|
||||
try {
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/aufgaben-service/favorit/");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
connection.setRequestProperty("Accept","application/json");
|
||||
connection.setDoOutput(true);
|
||||
connection.setDoInput(false);
|
||||
|
||||
connection.setRequestProperty("token", token);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("aufgabenGruppeId", strings[0]);
|
||||
|
||||
DataOutputStream os = new DataOutputStream(connection.getOutputStream());
|
||||
//os.writeBytes(URLEncoder.encode(jsonParam.toString(), "UTF-8"));
|
||||
os.writeBytes(object.toString());
|
||||
os.flush();
|
||||
os.close();
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == 201) {
|
||||
return Result.success(Boolean.TRUE);
|
||||
} else {
|
||||
return Result.error(new IllegalArgumentException("Unknown User"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Request error", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import de.oaa.xxxbdsmgame.Constants;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
public class FavoritenAbrufenTask extends AsyncTask<String, Void, Result> {
|
||||
private String token;
|
||||
|
||||
public FavoritenAbrufenTask(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Result<JSONObject> doInBackground(String... strings) {
|
||||
JSONObject result = null;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
URL url = new URL(Constants.SERVICE_HOST +
|
||||
"/aufgaben-service/favorit/");
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("token", token);
|
||||
|
||||
if (connection.getResponseCode() == 200) {
|
||||
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
br.close();
|
||||
result = new JSONObject(sb.toString());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error(new IOException("Request error", e));
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
return Result.error(new IOException("Request error", e));
|
||||
}
|
||||
}
|
||||
}
|
||||
return result != null ? Result.success(result) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
public class FavoritenRepository {
|
||||
|
||||
private static FavoritenRepository instance;
|
||||
|
||||
private String token;
|
||||
|
||||
private FavoritenRepository(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static FavoritenRepository getInstance(String token) {
|
||||
if (instance == null) {
|
||||
instance = new FavoritenRepository(token);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void add(String aufgabenGruppeId) {
|
||||
new FavoritErstellenTask(token).execute(aufgabenGruppeId);
|
||||
}
|
||||
|
||||
public void remove(String aufgabenGruppeId) {
|
||||
new FavoritEntfernenTask(token).execute(aufgabenGruppeId);
|
||||
}
|
||||
|
||||
public List<UUID> get() {
|
||||
List<UUID> gruppen = new ArrayList<>();
|
||||
try {
|
||||
Result<JSONObject> result = new FavoritenAbrufenTask(token).execute().get();
|
||||
JSONArray array = result.getData().getJSONArray("favoriten");
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
JSONObject jsonObject = array.getJSONObject(i);
|
||||
gruppen.add(UUID.fromString(jsonObject.getString("aufgabenGruppeId")));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
return gruppen;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package de.oaa.xxxbdsmgame.data.sets;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
public class SetsRepository {
|
||||
|
||||
private static SetsRepository instance;
|
||||
private String token;
|
||||
|
||||
private SetsRepository(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public static SetsRepository getInstance(String token) {
|
||||
if (instance == null) {
|
||||
instance = new SetsRepository(token);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Result<JSONObject> getAlle(String search) {
|
||||
AufgabenGruppenAbrufenTask task = new AufgabenGruppenAbrufenTask(token);
|
||||
if (search == null) {
|
||||
task.execute("all");
|
||||
} else {
|
||||
task.execute("all", search);
|
||||
}
|
||||
try {
|
||||
return task.get();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Result<JSONObject> getEigene() {
|
||||
AufgabenGruppenAbrufenTask task = new AufgabenGruppenAbrufenTask(token);
|
||||
task.execute("own");
|
||||
try {
|
||||
return task.get();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Result<JSONObject> getGruppe(String gruppeId) {
|
||||
AufgabenGruppeAbrufenTask task = new AufgabenGruppeAbrufenTask(token);
|
||||
task.execute(gruppeId);
|
||||
try {
|
||||
return task.get();
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package de.oaa.xxxbdsmgame.ui.gruppe.anzeige;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class AufgabenAnzeigeFragment extends Fragment {
|
||||
|
||||
public AufgabenAnzeigeFragment(JSONObject gruppe) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_toys_anzeige, container, false);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package de.oaa.xxxbdsmgame.ui.gruppe.anzeige;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.oaa.xxxbdsmgame.ui.sets.SetsListViewAdapter;
|
||||
|
||||
|
||||
public class AufgabenListViewAdapter extends RecyclerView.Adapter<AufgabenListViewAdapter.ViewHolder> {
|
||||
|
||||
|
||||
private final List<JSONObject> aufgaben;
|
||||
private final List<JSONObject> strafen;
|
||||
private final List<JSONObject> sperren;
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
private GruppeAnzeigenActivity parent;
|
||||
private Bitmap aufgabeImage;
|
||||
private Bitmap strafeImage;
|
||||
private Bitmap sperreImage;
|
||||
|
||||
AufgabenListViewAdapter(Context context, JSONObject gruppe) {
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
|
||||
this.aufgaben = new ArrayList<>();
|
||||
this.strafen = new ArrayList<>();
|
||||
this.sperren = new ArrayList<>();
|
||||
|
||||
initData(gruppe);
|
||||
}
|
||||
|
||||
private void initData(JSONObject gruppe) {
|
||||
try {
|
||||
JSONArray aufgaben = gruppe.getJSONArray("aufgaben");
|
||||
for (int i = 0; i < aufgaben.length(); i++) {
|
||||
this.aufgaben.add(aufgaben.getJSONObject(i));
|
||||
}
|
||||
this.aufgaben.sort(levelAndNameComparator());
|
||||
JSONArray strafen = gruppe.getJSONArray("strafen");
|
||||
for (int i = 0; i < strafen.length(); i++) {
|
||||
this.strafen.add(strafen.getJSONObject(i));
|
||||
}
|
||||
this.strafen.sort(levelAndNameComparator());
|
||||
JSONArray sperren = gruppe.getJSONArray("sperren");
|
||||
for (int i = 0; i < sperren.length(); i++) {
|
||||
this.sperren.add(sperren.getJSONObject(i));
|
||||
}
|
||||
|
||||
aufgabeImage = BitmapFactory.decodeStream(getClass().getResourceAsStream("aufgabe.png"));
|
||||
strafeImage = BitmapFactory.decodeStream(getClass().getResourceAsStream("strafe.png"));
|
||||
sperreImage = BitmapFactory.decodeStream(getClass().getResourceAsStream("sperre.png"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Comparator<JSONObject> levelAndNameComparator() {
|
||||
return new Comparator<JSONObject>() {
|
||||
@Override
|
||||
public int compare(JSONObject o1, JSONObject o2) {
|
||||
try {
|
||||
int level = o1.getString("level").compareTo(o2.getString("level"));
|
||||
if (level == 0) {
|
||||
return o1.getString("kurzText").compareTo(o2.getString("kurzText"));
|
||||
} else {
|
||||
return level;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return aufgaben.size() + strafen.size() + sperren.size();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onBindViewHolder(AufgabenListViewAdapter.ViewHolder holder, int position) {
|
||||
try {
|
||||
if (position < aufgaben.size()) {
|
||||
JSONObject aufgabe = aufgaben.get(position);
|
||||
holder.bild.setImageIcon(Icon.createWithBitmap(aufgabeImage));
|
||||
holder.name.setText(aufgabe.getString("kurzText") + " (" + aufgabe.getString("level") + ")");
|
||||
holder.text.setText(aufgabe.getString("text"));
|
||||
} else if (position < (aufgaben.size() + strafen.size())) {
|
||||
JSONObject strafe = aufgaben.get(position - aufgaben.size());
|
||||
holder.bild.setImageIcon(Icon.createWithBitmap(strafeImage));
|
||||
holder.name.setText(strafe.getString("kurzText") + " (" + strafe.getString("level") + ")");
|
||||
holder.text.setText(strafe.getString("text"));
|
||||
} else {
|
||||
JSONObject sperre = aufgaben.get(position - (aufgaben.size() - strafen.size()));
|
||||
holder.bild.setImageIcon(Icon.createWithBitmap(sperreImage));
|
||||
holder.name.setText(sperre.getString("kurzText"));
|
||||
holder.text.setText(sperre.getString("text"));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AufgabenListViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.sets_row, parent, false);
|
||||
return new AufgabenListViewAdapter.ViewHolder(view);
|
||||
}
|
||||
|
||||
// stores and recycles views as they are scrolled off screen
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
ImageView bild;
|
||||
|
||||
TextView name;
|
||||
|
||||
TextView text;
|
||||
|
||||
JSONObject object;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
bild = itemView.findViewById(R.id.aufgabeBild);
|
||||
name = itemView.findViewById(R.id.aufgabeName);
|
||||
text = itemView.findViewById(R.id.aufgabeText);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.oaa.xxxbdsmgame.ui.gruppe.anzeige;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.xxxbdsmgame.databinding.ActivityGruppeAnzeigenBinding;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.sets.SetsRepository;
|
||||
import de.oaa.xxxbdsmgame.util.TokenHelper;
|
||||
|
||||
public class GruppeAnzeigenActivity extends AppCompatActivity {
|
||||
|
||||
private ActivityGruppeAnzeigenBinding binding;
|
||||
|
||||
private SetsRepository setsRepository;
|
||||
|
||||
private JSONObject gruppe;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
binding = ActivityGruppeAnzeigenBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
Intent intent = getIntent();
|
||||
setsRepository = SetsRepository.getInstance(TokenHelper.getToken(getApplicationContext()));
|
||||
|
||||
gruppe = setsRepository.getGruppe(intent.getStringExtra("gruppeId")).getData();
|
||||
|
||||
GruppeViewPagerAdapter gruppePagerAdapter = new GruppeViewPagerAdapter(this, gruppe);
|
||||
ViewPager2 viewPager = binding.pager;
|
||||
viewPager.setAdapter(gruppePagerAdapter);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package de.oaa.xxxbdsmgame.ui.gruppe.anzeige;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class GruppeViewPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
|
||||
private final AufgabenAnzeigeFragment aufgabeFragment;
|
||||
private final ToysAnzeigeFragment toysFragment;
|
||||
|
||||
public GruppeViewPagerAdapter(@NonNull FragmentActivity fragmentActivity, JSONObject gruppe) {
|
||||
super(fragmentActivity);
|
||||
this.aufgabeFragment = new AufgabenAnzeigeFragment(gruppe);
|
||||
this.toysFragment = new ToysAnzeigeFragment(gruppe);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return position == 0 ? aufgabeFragment : toysFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package de.oaa.xxxbdsmgame.ui.gruppe.anzeige;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class ToysAnzeigeFragment extends Fragment {
|
||||
|
||||
public ToysAnzeigeFragment(JSONObject gruppe) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_toys_anzeige, container, false);
|
||||
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
@@ -0,0 +1,17 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
/**
|
||||
* Class exposing authenticated user details to the UI.
|
||||
*/
|
||||
class LoggedInUserView {
|
||||
private String displayName;
|
||||
//... other data fields that may be accessible to the UI
|
||||
|
||||
LoggedInUserView(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
150
app/src/main/java/de/oaa/xxxbdsmgame/ui/login/LoginActivity.java
Normal file
@@ -0,0 +1,150 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.xxxbdsmgame.databinding.ActivityLoginBinding;
|
||||
|
||||
import de.oaa.xxxbdsmgame.ui.menu.MenuActivity;
|
||||
import de.oaa.xxxbdsmgame.util.TokenHelper;
|
||||
|
||||
public class LoginActivity extends AppCompatActivity {
|
||||
|
||||
private LoginViewModel loginViewModel;
|
||||
private ActivityLoginBinding binding;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
String token = TokenHelper.getToken(getApplicationContext());
|
||||
if (token != null) {
|
||||
openMenu();
|
||||
} else {
|
||||
initUi();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initUi() {
|
||||
binding = ActivityLoginBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
loginViewModel = new ViewModelProvider(this, new LoginViewModelFactory())
|
||||
.get(LoginViewModel.class);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
final EditText emailEditText = binding.email;
|
||||
final EditText passwordEditText = binding.password;
|
||||
final Button loginButton = binding.login;
|
||||
final ProgressBar loadingProgressBar = binding.loading;
|
||||
emailEditText.setText(intent.getStringExtra("email"));
|
||||
passwordEditText.setText(intent.getStringExtra("password"));
|
||||
|
||||
loginViewModel.getLoginFormState().observe(this, new Observer<LoginFormState>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable LoginFormState loginFormState) {
|
||||
if (loginFormState == null) {
|
||||
return;
|
||||
}
|
||||
loginButton.setEnabled(loginFormState.isDataValid());
|
||||
if (loginFormState.getUsernameError() != null) {
|
||||
emailEditText.setError(getString(loginFormState.getUsernameError()));
|
||||
}
|
||||
if (loginFormState.getPasswordError() != null) {
|
||||
passwordEditText.setError(getString(loginFormState.getPasswordError()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loginViewModel.getLoginResult().observe(this, new Observer<LoginResult>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable LoginResult loginResult) {
|
||||
if (loginResult == null) {
|
||||
return;
|
||||
}
|
||||
loadingProgressBar.setVisibility(View.GONE);
|
||||
if (loginResult.getError() != null) {
|
||||
showLoginFailed(loginResult);
|
||||
}
|
||||
if (loginResult.getToken() != null) {
|
||||
TokenHelper.storeToken(loginResult.getToken(), getApplicationContext());
|
||||
openMenu();
|
||||
}
|
||||
setResult(Activity.RESULT_OK);
|
||||
|
||||
//Complete and destroy login activity once successful
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
TextWatcher afterTextChangedListener = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
loginViewModel.loginDataChanged(emailEditText.getText().toString(),
|
||||
passwordEditText.getText().toString());
|
||||
}
|
||||
};
|
||||
emailEditText.addTextChangedListener(afterTextChangedListener);
|
||||
passwordEditText.addTextChangedListener(afterTextChangedListener);
|
||||
passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
loginViewModel.login(emailEditText.getText().toString(),
|
||||
passwordEditText.getText().toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
loginButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
loadingProgressBar.setVisibility(View.VISIBLE);
|
||||
loginViewModel.login(emailEditText.getText().toString(),
|
||||
passwordEditText.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openMenu() {
|
||||
Intent intent = new Intent(this, MenuActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void showLoginFailed(LoginResult loginResult) {
|
||||
LoginFailedDialog dialog = new LoginFailedDialog(loginResult.getEingabeEmail(), loginResult.getEingabePasswort());
|
||||
dialog.showNow(getSupportFragmentManager(), "test");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import de.oaa.xxxbdsmgame.ui.register.RegisterActivity;
|
||||
|
||||
public class LoginFailedDialog extends DialogFragment {
|
||||
|
||||
private String email;
|
||||
private String password;
|
||||
|
||||
public LoginFailedDialog(String email, String password) {
|
||||
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.login_failed).setPositiveButton(R.string.back, (dialog, which) -> {
|
||||
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||
intent.putExtra("email", email);
|
||||
intent.putExtra("password", "");
|
||||
startActivity(intent);
|
||||
}).setNegativeButton(R.string.action_register, (dialog, which) -> {
|
||||
Intent intent = new Intent(getActivity(), RegisterActivity.class);
|
||||
intent.putExtra("email", email);
|
||||
intent.putExtra("password", password);
|
||||
startActivity(intent);
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Data validation state of the login form.
|
||||
*/
|
||||
class LoginFormState {
|
||||
@Nullable
|
||||
private Integer usernameError;
|
||||
@Nullable
|
||||
private Integer passwordError;
|
||||
private boolean isDataValid;
|
||||
|
||||
LoginFormState(@Nullable Integer usernameError, @Nullable Integer passwordError) {
|
||||
this.usernameError = usernameError;
|
||||
this.passwordError = passwordError;
|
||||
this.isDataValid = false;
|
||||
}
|
||||
|
||||
LoginFormState(boolean isDataValid) {
|
||||
this.usernameError = null;
|
||||
this.passwordError = null;
|
||||
this.isDataValid = isDataValid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getUsernameError() {
|
||||
return usernameError;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getPasswordError() {
|
||||
return passwordError;
|
||||
}
|
||||
|
||||
boolean isDataValid() {
|
||||
return isDataValid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Authentication result : success (user details) or error message.
|
||||
*/
|
||||
class LoginResult {
|
||||
@Nullable
|
||||
private String token;
|
||||
@Nullable
|
||||
private Integer error;
|
||||
|
||||
@Nullable
|
||||
private String eingabeEmail;
|
||||
|
||||
@Nullable
|
||||
private String eingabePasswort;
|
||||
|
||||
LoginResult(@Nullable Integer error, String eingabeEmail, String eingabePasswort) {
|
||||
this.error = error;
|
||||
this.eingabeEmail = eingabeEmail;
|
||||
this.eingabePasswort = eingabePasswort;
|
||||
}
|
||||
|
||||
LoginResult(@Nullable String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getEingabeEmail() {
|
||||
return eingabeEmail;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getEingabePasswort() {
|
||||
return eingabePasswort;
|
||||
}
|
||||
|
||||
public void setEingabePasswort(@Nullable String eingabePasswort) {
|
||||
this.eingabePasswort = eingabePasswort;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Patterns;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.LoginRepository;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
import de.oaa.xxxbdsmgame.data.model.LoggedInUser;
|
||||
import de.oaa.xxxbdsmgame.ui.register.RegisterActivity;
|
||||
import de.oaa.xxxbdsmgame.util.TokenHelper;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
public class LoginViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<LoginFormState> loginFormState = new MutableLiveData<>();
|
||||
private MutableLiveData<LoginResult> loginResult = new MutableLiveData<>();
|
||||
private LoginRepository loginRepository;
|
||||
|
||||
LoginViewModel(LoginRepository loginRepository) {
|
||||
this.loginRepository = loginRepository;
|
||||
}
|
||||
|
||||
LiveData<LoginFormState> getLoginFormState() {
|
||||
return loginFormState;
|
||||
}
|
||||
|
||||
LiveData<LoginResult> getLoginResult() {
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
public void login(String username, String password) {
|
||||
// can be launched in a separate asynchronous job
|
||||
Result<LoggedInUser> result = loginRepository.login(username, password);
|
||||
|
||||
if (result.getData() != null) {
|
||||
LoggedInUser data = result.getData();
|
||||
loginResult.setValue(new LoginResult(data.getToken()));
|
||||
} else {
|
||||
loginResult.setValue(new LoginResult(R.string.login_failed, username, password));
|
||||
}
|
||||
}
|
||||
|
||||
public void loginDataChanged(String username, String password) {
|
||||
if (!isUserNameValid(username)) {
|
||||
loginFormState.setValue(new LoginFormState(R.string.invalid_name, null));
|
||||
} else if (!isPasswordValid(password)) {
|
||||
loginFormState.setValue(new LoginFormState(null, R.string.invalid_password));
|
||||
} else {
|
||||
loginFormState.setValue(new LoginFormState(true));
|
||||
}
|
||||
}
|
||||
|
||||
// A placeholder username validation check
|
||||
private boolean isUserNameValid(String username) {
|
||||
if (username == null) {
|
||||
return false;
|
||||
}
|
||||
if (username.contains("@")) {
|
||||
return Patterns.EMAIL_ADDRESS.matcher(username).matches();
|
||||
} else {
|
||||
return !username.trim().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
// A placeholder password validation check
|
||||
private boolean isPasswordValid(String password) {
|
||||
return password != null && password.trim().length() > 5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.oaa.xxxbdsmgame.ui.login;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.LoginRepository;
|
||||
|
||||
/**
|
||||
* ViewModel provider factory to instantiate LoginViewModel.
|
||||
* Required given LoginViewModel has a non-empty constructor
|
||||
*/
|
||||
public class LoginViewModelFactory implements ViewModelProvider.Factory {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||
if (modelClass.isAssignableFrom(LoginViewModel.class)) {
|
||||
return (T) new LoginViewModel(LoginRepository.getInstance());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown ViewModel class");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package de.oaa.xxxbdsmgame.ui.menu;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.xxxbdsmgame.databinding.ActivityMenuBinding;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.oaa.xxxbdsmgame.ui.sets.SetsActivity;
|
||||
import de.oaa.xxxbdsmgame.util.TokenHelper;
|
||||
|
||||
|
||||
public class MenuActivity extends AppCompatActivity {
|
||||
private ActivityMenuBinding binding;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
TokenHelper.getToken(getApplicationContext());
|
||||
|
||||
binding = ActivityMenuBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
binding.buttonProfile.setOnClickListener((v) -> {
|
||||
|
||||
});
|
||||
|
||||
binding.buttonSettings.setOnClickListener((v) -> {
|
||||
|
||||
});
|
||||
|
||||
binding.buttonSets.setOnClickListener((v) -> {
|
||||
Intent intent = new Intent(this, SetsActivity.class);
|
||||
intent.putExtra("all", Boolean.TRUE);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
binding.buttonOwnSets.setOnClickListener((v) -> {
|
||||
Intent intent = new Intent(this, SetsActivity.class);
|
||||
intent.putExtra("all", Boolean.FALSE);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
binding.buttonNewGame.setOnClickListener((v) -> {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
import com.example.xxxbdsmgame.databinding.ActivityRegisterBinding;
|
||||
|
||||
import de.oaa.xxxbdsmgame.ui.login.LoginActivity;
|
||||
|
||||
public class RegisterActivity extends AppCompatActivity {
|
||||
|
||||
private RegisterViewModel viewModel;
|
||||
private ActivityRegisterBinding binding;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
binding = ActivityRegisterBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
viewModel = new ViewModelProvider(this, new RegisterViewModelFactory())
|
||||
.get(RegisterViewModel.class);
|
||||
|
||||
final EditText nameEditText = binding.name;
|
||||
final EditText emailEditText = binding.email;
|
||||
emailEditText.setText(intent.getStringExtra("email"));
|
||||
final EditText passwordEditText = binding.password;
|
||||
passwordEditText.setText(intent.getStringExtra("password"));
|
||||
final Button loginButton = binding.login;
|
||||
|
||||
viewModel.getRegisterFormState().observe(this, new Observer<RegisterFormState>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable RegisterFormState loginFormState) {
|
||||
if (loginFormState == null) {
|
||||
return;
|
||||
}
|
||||
loginButton.setEnabled(loginFormState.isDataValid());
|
||||
if (loginFormState.getNameError() != null) {
|
||||
nameEditText.setError(getString(loginFormState.getNameError()));
|
||||
}
|
||||
if (loginFormState.getEmailError() != null) {
|
||||
emailEditText.setError(getString(loginFormState.getEmailError()));
|
||||
}
|
||||
if (loginFormState.getPasswordError() != null) {
|
||||
passwordEditText.setError(getString(loginFormState.getPasswordError()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
viewModel.getRegisterResult().observe(this, new Observer<RegisterResult>() {
|
||||
@Override
|
||||
public void onChanged(@Nullable RegisterResult result) {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
if (result.getError() != null) {
|
||||
updateAfterError(result.getError());
|
||||
} else {
|
||||
updateAfterSuccess(result);
|
||||
}
|
||||
setResult(Activity.RESULT_OK);
|
||||
}
|
||||
});
|
||||
|
||||
TextWatcher afterTextChangedListener = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
viewModel.registerDataChanged(nameEditText.getText().toString(),
|
||||
emailEditText.getText().toString(),
|
||||
passwordEditText.getText().toString());
|
||||
}
|
||||
};
|
||||
nameEditText.addTextChangedListener(afterTextChangedListener);
|
||||
emailEditText.addTextChangedListener(afterTextChangedListener);
|
||||
passwordEditText.addTextChangedListener(afterTextChangedListener);
|
||||
passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
viewModel.register(nameEditText.getText().toString(),
|
||||
emailEditText.getText().toString(),
|
||||
passwordEditText.getText().toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
loginButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
viewModel.register(nameEditText.getText().toString(),
|
||||
emailEditText.getText().toString(),
|
||||
passwordEditText.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateAfterSuccess(RegisterResult result) {
|
||||
RegisterSuccessDialog dialog = new RegisterSuccessDialog(result);
|
||||
dialog.showNow(getSupportFragmentManager(), "test");
|
||||
}
|
||||
|
||||
private void updateAfterError(@StringRes Integer errorString) {
|
||||
Toast.makeText(getApplicationContext(), errorString, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Data validation state of the login form.
|
||||
*/
|
||||
class RegisterFormState {
|
||||
@Nullable
|
||||
private Integer nameError;
|
||||
@Nullable
|
||||
private Integer emailError;
|
||||
@Nullable
|
||||
private Integer passwordError;
|
||||
private boolean isDataValid;
|
||||
|
||||
RegisterFormState(@Nullable Integer nameError, @Nullable Integer emailError, @Nullable Integer passwordError) {
|
||||
this.nameError = nameError;
|
||||
this.emailError = emailError;
|
||||
this.passwordError = passwordError;
|
||||
this.isDataValid = false;
|
||||
}
|
||||
|
||||
RegisterFormState(boolean isDataValid) {
|
||||
this.nameError = null;
|
||||
this.emailError = null;
|
||||
this.passwordError = null;
|
||||
this.isDataValid = isDataValid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getNameError() {
|
||||
|
||||
return nameError;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getEmailError() {
|
||||
return emailError;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getPasswordError() {
|
||||
return passwordError;
|
||||
}
|
||||
|
||||
boolean isDataValid() {
|
||||
return isDataValid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Authentication result : success (user details) or error message.
|
||||
*/
|
||||
class RegisterResult {
|
||||
|
||||
private String email;
|
||||
private String password;
|
||||
@Nullable
|
||||
private Integer error;
|
||||
|
||||
RegisterResult(@Nullable Integer error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
RegisterResult(String email, String password) {
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Integer getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import de.oaa.xxxbdsmgame.ui.login.LoginActivity;
|
||||
|
||||
public class RegisterSuccessDialog extends DialogFragment {
|
||||
|
||||
private RegisterResult result;
|
||||
|
||||
public RegisterSuccessDialog(RegisterResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.check_email).setPositiveButton(R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(getActivity(), LoginActivity.class);
|
||||
intent.putExtra("email", result.getEmail());
|
||||
intent.putExtra("password", result.getPassword());
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
/**
|
||||
* Class exposing authenticated user details to the UI.
|
||||
*/
|
||||
class RegisterUserView {
|
||||
private String displayName;
|
||||
//... other data fields that may be accessible to the UI
|
||||
|
||||
RegisterUserView(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
import android.util.Patterns;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.RegisterRepository;
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
|
||||
|
||||
public class RegisterViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<RegisterFormState> registerFormState = new MutableLiveData<>();
|
||||
private MutableLiveData<RegisterResult> registerResult = new MutableLiveData<>();
|
||||
private RegisterRepository repository;
|
||||
|
||||
RegisterViewModel(RegisterRepository loginRepository) {
|
||||
this.repository = loginRepository;
|
||||
}
|
||||
|
||||
LiveData<RegisterFormState> getRegisterFormState() {
|
||||
return registerFormState;
|
||||
}
|
||||
|
||||
LiveData<RegisterResult> getRegisterResult() {
|
||||
return registerResult;
|
||||
}
|
||||
|
||||
public void register(String name, String email, String password) {
|
||||
// can be launched in a separate asynchronous job
|
||||
Result<Boolean> result = repository.register(name, email, password);
|
||||
|
||||
if (result.getData() != null && result.getData()) {
|
||||
registerResult.setValue(new RegisterResult(email, password));
|
||||
} else {
|
||||
registerResult.setValue(new RegisterResult(R.string.register_failed));
|
||||
}
|
||||
}
|
||||
|
||||
public void registerDataChanged(String name, String email, String password) {
|
||||
if (!isNameValid(name)) {
|
||||
registerFormState.setValue(new RegisterFormState(R.string.invalid_name, null, null));
|
||||
} else if (!isEmailValid(email)) {
|
||||
registerFormState.setValue(new RegisterFormState(null, R.string.invalid_email, null));
|
||||
} else if (!isPasswordValid(password)) {
|
||||
registerFormState.setValue(new RegisterFormState(null, null, R.string.invalid_password));
|
||||
} else {
|
||||
registerFormState.setValue(new RegisterFormState(true));
|
||||
}
|
||||
}
|
||||
|
||||
// A placeholder username validation check
|
||||
private boolean isEmailValid(String email) {
|
||||
if (email == null) {
|
||||
return false;
|
||||
}
|
||||
if (email.contains("@")) {
|
||||
return Patterns.EMAIL_ADDRESS.matcher(email).matches();
|
||||
} else {
|
||||
return !email.trim().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNameValid(String name) {
|
||||
return name != null && name.length() > 6;
|
||||
}
|
||||
|
||||
// A placeholder password validation check
|
||||
private boolean isPasswordValid(String password) {
|
||||
return password != null && password.trim().length() > 6;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.oaa.xxxbdsmgame.ui.register;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.RegisterRepository;
|
||||
|
||||
/**
|
||||
* ViewModel provider factory to instantiate LoginViewModel.
|
||||
* Required given LoginViewModel has a non-empty constructor
|
||||
*/
|
||||
public class RegisterViewModelFactory implements ViewModelProvider.Factory {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||
if (modelClass.isAssignableFrom(RegisterViewModel.class)) {
|
||||
return (T) new RegisterViewModel(RegisterRepository.getInstance());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown ViewModel class");
|
||||
}
|
||||
}
|
||||
}
|
||||
164
app/src/main/java/de/oaa/xxxbdsmgame/ui/sets/SetsActivity.java
Normal file
@@ -0,0 +1,164 @@
|
||||
package de.oaa.xxxbdsmgame.ui.sets;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
import com.example.xxxbdsmgame.databinding.ActivitySetsBinding;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.oaa.xxxbdsmgame.data.Result;
|
||||
import de.oaa.xxxbdsmgame.data.sets.FavoritenRepository;
|
||||
import de.oaa.xxxbdsmgame.data.sets.SetsRepository;
|
||||
import de.oaa.xxxbdsmgame.ui.gruppe.anzeige.GruppeAnzeigenActivity;
|
||||
import de.oaa.xxxbdsmgame.util.TokenHelper;
|
||||
|
||||
|
||||
public class SetsActivity extends AppCompatActivity implements SetsListViewAdapter.ItemClickListener {
|
||||
private SetsRepository setsRepository;
|
||||
private FavoritenRepository favoritenRepository;
|
||||
|
||||
private ActivitySetsBinding binding;
|
||||
private SetsListViewAdapter adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
boolean all = getIntent().getBooleanExtra("all", Boolean.FALSE);
|
||||
|
||||
binding = ActivitySetsBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
String token = TokenHelper.getToken(getApplicationContext());
|
||||
setsRepository = SetsRepository.getInstance(token);
|
||||
favoritenRepository = FavoritenRepository.getInstance(token);
|
||||
RecyclerView listView = findViewById(R.id.listView);
|
||||
|
||||
Result<JSONObject> result = all ? setsRepository.getAlle(null) : setsRepository.getEigene();
|
||||
List<JSONObject> gruppen = new ArrayList<>();
|
||||
if (result.getData() != null) {
|
||||
try {
|
||||
JSONArray gruppenJson = result.getData().getJSONArray("gruppen");
|
||||
for (int i = 0; i < gruppenJson.length(); i++) {
|
||||
JSONObject jsonObject = gruppenJson.getJSONObject(i);
|
||||
gruppen.add(jsonObject);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
listView.setLayoutManager(new LinearLayoutManager(this));
|
||||
adapter = new SetsListViewAdapter(this, gruppen, favoritenRepository.get());
|
||||
adapter.setClickListener(this);
|
||||
adapter.setParent(this);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
EditText searchField = binding.searchField;
|
||||
searchField.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
private long letzteBeabeitung;
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
letzteBeabeitung = System.currentTimeMillis();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
if (letzteBeabeitung + 1000 > System.currentTimeMillis()) {
|
||||
doSearch();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void doSearch() {
|
||||
SetsActivity.this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Result<JSONObject> filtered = all ? setsRepository.getAlle(searchField.getText().toString()) : setsRepository.getEigene();
|
||||
List<JSONObject> gruppen = new ArrayList<>();
|
||||
if (filtered.getData() != null) {
|
||||
try {
|
||||
JSONArray gruppenJson = filtered.getData().getJSONArray("gruppen");
|
||||
for (int i = 0; i < gruppenJson.length(); i++) {
|
||||
JSONObject jsonObject = gruppenJson.getJSONObject(i);
|
||||
gruppen.add(jsonObject);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
listView.setLayoutManager(new LinearLayoutManager(SetsActivity.this));
|
||||
adapter = new SetsListViewAdapter(SetsActivity.this, gruppen, favoritenRepository.get());
|
||||
adapter.setClickListener(SetsActivity.this);
|
||||
adapter.setParent(SetsActivity.this);
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerCaptureChanged(boolean hasCapture) {
|
||||
super.onPointerCaptureChanged(hasCapture);
|
||||
}
|
||||
|
||||
void favoritChanged(JSONObject object, boolean isChecked) {
|
||||
try {
|
||||
if (isChecked) {
|
||||
favoritenRepository.add(object.getString("gruppenId"));
|
||||
} else {
|
||||
favoritenRepository.remove(object.getString("gruppenId"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
void gruppeCliecked(JSONObject object) {
|
||||
try {
|
||||
Intent intent =new Intent(this, GruppeAnzeigenActivity.class);
|
||||
intent.putExtra("gruppeId", object.getString("gruppenId"));
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package de.oaa.xxxbdsmgame.ui.sets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Build;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.xxxbdsmgame.R;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SetsListViewAdapter extends RecyclerView.Adapter<SetsListViewAdapter.ViewHolder> {
|
||||
|
||||
private List<JSONObject> mData;
|
||||
|
||||
private List<UUID> favoriten;
|
||||
private LayoutInflater mInflater;
|
||||
private ItemClickListener mClickListener;
|
||||
private SetsActivity parent;
|
||||
|
||||
// data is passed into the constructor
|
||||
SetsListViewAdapter(Context context, List<JSONObject> data, List<UUID> favoriten) {
|
||||
this.mInflater = LayoutInflater.from(context);
|
||||
this.mData = data;
|
||||
this.favoriten = favoriten;
|
||||
}
|
||||
|
||||
// inflates the row layout from xml when needed
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = mInflater.inflate(R.layout.sets_row, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
// binds the data to the TextView in each row
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
try {
|
||||
JSONObject object = mData.get(position);
|
||||
holder.name.setText(object.getString("name"));
|
||||
holder.beschreibung.setText(object.getString("beschreibung"));
|
||||
byte[] blob = Base64.getDecoder().decode(object.getString("bild"));
|
||||
Bitmap bmp= BitmapFactory.decodeByteArray(blob,0,blob.length);
|
||||
holder.bild.setImageIcon(Icon.createWithBitmap(bmp));
|
||||
holder.object = object;
|
||||
if (favoriten.contains(UUID.fromString(object.getString("gruppenId")))) {
|
||||
holder.fav.setChecked(true);
|
||||
}
|
||||
holder.von.setText(object.getString("von"));
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
// total number of rows
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mData.size();
|
||||
}
|
||||
|
||||
public JSONObject getItem(int position) {
|
||||
return mData.get(position);
|
||||
}
|
||||
|
||||
public void setParent(SetsActivity parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
// stores and recycles views as they are scrolled off screen
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||
ImageView bild;
|
||||
|
||||
TextView name;
|
||||
|
||||
TextView beschreibung;
|
||||
|
||||
TextView von;
|
||||
|
||||
Switch fav;
|
||||
|
||||
JSONObject object;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
bild = itemView.findViewById(R.id.gruppeBild);
|
||||
name = itemView.findViewById(R.id.gruppeName);
|
||||
fav = itemView.findViewById(R.id.favSwitch);
|
||||
beschreibung = itemView.findViewById((R.id.gruppeText));
|
||||
von = itemView.findViewById(R.id.gruppeVonText);
|
||||
|
||||
itemView.setOnClickListener(this);
|
||||
fav.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mClickListener != null) {
|
||||
parent.gruppeCliecked(object);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if(buttonView.isPressed()) {
|
||||
parent.favoritChanged(object, isChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// allows clicks events to be caught
|
||||
void setClickListener(ItemClickListener itemClickListener) {
|
||||
this.mClickListener = itemClickListener;
|
||||
}
|
||||
|
||||
|
||||
// parent activity will implement this method to respond to click events
|
||||
public interface ItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.oaa.xxxbdsmgame.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class PasswordHelper {
|
||||
|
||||
public static String hashPassword(String password) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(password.getBytes());
|
||||
byte[] bytes = md.digest();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (Exception exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
app/src/main/java/de/oaa/xxxbdsmgame/util/TokenHelper.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package de.oaa.xxxbdsmgame.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class TokenHelper {
|
||||
|
||||
private TokenHelper() {
|
||||
}
|
||||
|
||||
public static String getToken(Context context) {
|
||||
SharedPreferences prefs = context.getSharedPreferences("XXXTOKEN", 0);
|
||||
Map<String, ?> map= prefs.getAll();
|
||||
Optional<? extends Map.Entry<String, ?>> first =
|
||||
map.entrySet().stream().filter(entry -> entry.getKey().equals("token")).findFirst();
|
||||
return first.isPresent() ? first.get().getValue().toString() : null;
|
||||
}
|
||||
|
||||
public static void storeToken(String token, Context context) {
|
||||
SharedPreferences prefs = context.getSharedPreferences("XXXTOKEN", 0);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putString("token", token);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static void deleteToken(Context context) {
|
||||
SharedPreferences prefs = context.getSharedPreferences("XXXTOKEN", 0);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.remove("token");
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/de/oaa/xxxbdsmgame/aufgabe.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
app/src/main/res/de/oaa/xxxbdsmgame/sperre.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
app/src/main/res/de/oaa/xxxbdsmgame/strafe.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
63
app/src/main/res/layout/activity_gruppe_anzeigen.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="0dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/aufgabeBild"
|
||||
android:layout_width="128px"
|
||||
android:layout_height="128px"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_weight="0"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aufgabeName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aufgabeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="63dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
69
app/src/main/res/layout/activity_login.xml
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="de.oaa.xxxbdsmgame.ui.login.LoginActivity">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/email"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="96dp"
|
||||
android:hint="@string/prompt_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/prompt_password"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:selectAllOnFocus="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/email" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:enabled="false"
|
||||
android:text="@string/action_sign_in"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/password"
|
||||
app:layout_constraintVertical_bias="0.2" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/password"
|
||||
app:layout_constraintStart_toStartOf="@+id/password"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.3" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
60
app/src/main/res/layout/activity_menu.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:textAlignment="center"
|
||||
tools:context="de.oaa.xxxbdsmgame.ui.menu.MenuActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/menuLbl"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_activity_menu"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonProfile"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/action_profile" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_settings" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonSets"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_sets" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonOwnSets"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/action_own_sets" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/buttonNewGame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/action_newgame" />
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
60
app/src/main/res/layout/activity_register.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="de.oaa.xxxbdsmgame.ui.register.RegisterActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="96dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:layout_editor_absoluteX="16dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/promt_name"
|
||||
android:inputType="text"
|
||||
android:selectAllOnFocus="true" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/prompt_email"
|
||||
android:inputType="textEmailAddress"
|
||||
android:selectAllOnFocus="true" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/prompt_password"
|
||||
android:imeActionLabel="@string/action_sign_in_short"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:selectAllOnFocus="true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/login"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|center_vertical"
|
||||
android:layout_marginTop="80dp"
|
||||
android:layout_marginBottom="64dp"
|
||||
android:enabled="false"
|
||||
android:text="@string/action_register" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
44
app/src/main/res/layout/activity_sets.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="de.oaa.xxxbdsmgame.ui.sets.SetsActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchField"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:hint="@string/promt_search"
|
||||
android:inputType="text" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/listView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
6
app/src/main/res/layout/activity_sets/sets_view_row.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
29
app/src/main/res/layout/fragment_aufgaben_anzeige.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="de.oaa.xxxbdsmgame.ui.gruppe.anzeige.GruppeAnzeigenActivity">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
13
app/src/main/res/layout/fragment_toys_anzeige.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="de.oaa.xxxbdsmgame.ui.gruppe.anzeige.GruppeAnzeigenActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/text_margin"
|
||||
android:text="Text" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
49
app/src/main/res/layout/sets_aufgaben_anzeigen.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="0dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/aufgabeBild"
|
||||
android:layout_width="128px"
|
||||
android:layout_height="128px"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_weight="0"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aufgabeName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aufgabeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0" />
|
||||
|
||||
</LinearLayout>
|
||||
67
app/src/main/res/layout/sets_row.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="0dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gruppeBild"
|
||||
android:layout_width="128px"
|
||||
android:layout_height="128px"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_weight="0"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
tools:layout_gravity="fill">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gruppeName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="0"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gruppeText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gruppeVonText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_weight="1"
|
||||
android:textAlignment="textEnd" />
|
||||
</LinearLayout>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/favSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|center_vertical"
|
||||
android:layout_weight="0"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0" />
|
||||
|
||||
</LinearLayout>
|
||||
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="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/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="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
6
app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 982 B |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
5
app/src/main/res/values-land/dimens.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<dimen name="activity_horizontal_margin">48dp</dimen>
|
||||
<dimen name="fab_margin">48dp</dimen>
|
||||
<dimen name="text_margin">48dp</dimen>
|
||||
</resources>
|
||||
21
app/src/main/res/values-night/themes.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.XXXBDSMGame" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_200</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/black</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_200</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.XXXBDSMGame.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_900</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A400</item>
|
||||
</style>
|
||||
</resources>
|
||||
4
app/src/main/res/values-w1240dp/dimens.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<resources>
|
||||
<dimen name="activity_horizontal_margin">200dp</dimen>
|
||||
<dimen name="fab_margin">200dp</dimen>
|
||||
</resources>
|
||||
5
app/src/main/res/values-w600dp/dimens.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<dimen name="activity_horizontal_margin">48dp</dimen>
|
||||
<dimen name="fab_margin">48dp</dimen>
|
||||
<dimen name="text_margin">48dp</dimen>
|
||||
</resources>
|
||||
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
6
app/src/main/res/values/attrs.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<declare-styleable name="FullscreenAttrs">
|
||||
<attr name="fullscreenBackgroundColor" format="color" />
|
||||
<attr name="fullscreenTextColor" format="color" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
15
app/src/main/res/values/colors.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="purple_200">#FFBB86FC</color>
|
||||
<color name="purple_500">#FF6200EE</color>
|
||||
<color name="purple_700">#FF3700B3</color>
|
||||
<color name="teal_200">#FF03DAC5</color>
|
||||
<color name="teal_700">#FF018786</color>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="light_blue_600">#FF039BE5</color>
|
||||
<color name="light_blue_900">#FF01579B</color>
|
||||
<color name="light_blue_A200">#FF40C4FF</color>
|
||||
<color name="light_blue_A400">#FF00B0FF</color>
|
||||
<color name="black_overlay">#66000000</color>
|
||||
</resources>
|
||||
10
app/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
<dimen name="app_bar_height">180dp</dimen>
|
||||
<dimen name="text_margin">16dp</dimen>
|
||||
<dimen name="appbar_padding">16dp</dimen>
|
||||
<dimen name="appbar_padding_top">8dp</dimen>
|
||||
</resources>
|
||||
38
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<resources>
|
||||
<string name="app_name">XXX BDSM-Game</string>
|
||||
<!-- Strings related to login-->
|
||||
<string name="promt_name">Nickname</string>
|
||||
<string name="prompt_email">E-Mail</string>
|
||||
<string name="prompt_password">Passwort</string>
|
||||
<string name="action_sign_in">Anmelden oder Registrieren</string>
|
||||
<string name="action_sign_in_short">Anmeldung</string>
|
||||
<string name="welcome">"Welcome !"</string>
|
||||
<string name="invalid_name">Kein valider Name</string>
|
||||
<string name="invalid_email">Keine valide E-Mail-Adresse</string>
|
||||
<string name="invalid_password">Das Passwort muss aus mindestens 6 Zeichen bestehen</string>
|
||||
<string name="login_failed">"Login gescheitert"</string>
|
||||
<string name="register_failed">Registrierung gescheitert, bitte versuche es später noch einmal.</string>
|
||||
<string name="title_activity_register">Registrierung</string>
|
||||
<string name="action_register">Registrieren</string>
|
||||
<string name="dummy_button">Dummy Button</string>
|
||||
<string name="dummy_content">DUMMY\nCONTENT</string>
|
||||
<string name="check_email">Wir haben dir eine E-Mail gesendet. Bitte prüfe deine E-Mails und bestätige deine E-Mail-Adresse.</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="back">Zurück</string>
|
||||
<string name="title_activity_menu">Hauptmenü</string>
|
||||
<string name="action_profile">Profil</string>
|
||||
<string name="action_settings">Einstellungen</string>
|
||||
<string name="action_sets">Aufgabensets</string>
|
||||
<string name="action_own_sets">Eigene Sets</string>
|
||||
<string name="action_newgame">Neues Spiel</string>
|
||||
<string name="title_activity_sets">Aufgabensets</string>
|
||||
<string name="promt_search">Suche</string>
|
||||
<string name="invalid_username">Not a valid username</string>
|
||||
<string name="title_activity_gruppe_anzeigen">GruppeAnzeigenActivity</string>
|
||||
<string name="tab_text_toys">Toys</string>
|
||||
<string name="tab_text_tasks">Aufgaben</string>
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
|
||||
|
||||
|
||||
</resources>
|
||||
11
app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<style name="Widget.Theme.XXXBDSMGame.ActionBar.Fullscreen" parent="Widget.AppCompat.ActionBar">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Theme.XXXBDSMGame.ButtonBar.Fullscreen" parent="">
|
||||
<item name="android:background">@color/black_overlay</item>
|
||||
<item name="android:buttonBarStyle">?android:attr/buttonBarStyle</item>
|
||||
</style>
|
||||
</resources>
|
||||
37
app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.XXXBDSMGame" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Primary brand color. -->
|
||||
<item name="colorPrimary">@color/purple_500</item>
|
||||
<item name="colorPrimaryVariant">@color/purple_700</item>
|
||||
<item name="colorOnPrimary">@color/white</item>
|
||||
<!-- Secondary brand color. -->
|
||||
<item name="colorSecondary">@color/teal_200</item>
|
||||
<item name="colorSecondaryVariant">@color/teal_700</item>
|
||||
<item name="colorOnSecondary">@color/black</item>
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.XXXBDSMGame.Fullscreen" parent="Theme.XXXBDSMGame">
|
||||
<item name="android:actionBarStyle">@style/Widget.Theme.XXXBDSMGame.ActionBar.Fullscreen
|
||||
</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowBackground">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.XXXBDSMGame.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A200</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.XXXBDSMGame.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.XXXBDSMGame.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="Theme.XXXBDSMGame.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
</resources>
|
||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
6
app/src/main/res/xml/network_security_config.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<domain-config cleartextTrafficPermitted="true">
|
||||
<domain includeSubdomains="true">10.0.2.2</domain>
|
||||
</domain-config>
|
||||
</network-security-config>
|
||||
5
build.gradle
Normal file
@@ -0,0 +1,5 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
id 'com.android.application' version '7.4.2' apply false
|
||||
id 'com.android.library' version '7.4.2' apply false
|
||||
}
|
||||
21
gradle.properties
Normal file
@@ -0,0 +1,21 @@
|
||||
# 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=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# 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
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#Mon Mar 27 19:24:03 CEST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
185
gradlew
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## 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='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# 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 or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@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 Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@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="-Xmx64m" "-Xms64m"
|
||||
|
||||
@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 execute
|
||||
|
||||
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 execute
|
||||
|
||||
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
|
||||
|
||||
: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 %*
|
||||
|
||||
: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
|
||||
16
settings.gradle
Normal file
@@ -0,0 +1,16 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
rootProject.name = "XXX BDSM Game"
|
||||
include ':app'
|
||||