diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/mobileapp/android/app/.gitignore b/mobileapp/android/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/mobileapp/android/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/mobileapp/android/app/build.gradle b/mobileapp/android/app/build.gradle new file mode 100644 index 0000000..76681a6 --- /dev/null +++ b/mobileapp/android/app/build.gradle @@ -0,0 +1,33 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 30 + buildToolsVersion "30.0.1" + + defaultConfig { + applicationId "sde.odense.skolehjem" + minSdkVersion 16 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + +} \ No newline at end of file diff --git a/mobileapp/android/app/proguard-rules.pro b/mobileapp/android/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/mobileapp/android/app/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/mobileapp/android/app/release/app-release.apk b/mobileapp/android/app/release/app-release.apk new file mode 100644 index 0000000..0fce438 Binary files /dev/null and b/mobileapp/android/app/release/app-release.apk differ diff --git a/mobileapp/android/app/release/output-metadata.json b/mobileapp/android/app/release/output-metadata.json new file mode 100644 index 0000000..8e3bcca --- /dev/null +++ b/mobileapp/android/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 1, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "sde.odense.skolehjem", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "properties": [], + "versionCode": 1, + "versionName": "1.0", + "enabled": true, + "outputFile": "app-release.apk" + } + ] +} \ No newline at end of file diff --git a/mobileapp/android/app/src/androidTest/java/sde/odense/skolehjem/ExampleInstrumentedTest.java b/mobileapp/android/app/src/androidTest/java/sde/odense/skolehjem/ExampleInstrumentedTest.java new file mode 100644 index 0000000..037f955 --- /dev/null +++ b/mobileapp/android/app/src/androidTest/java/sde/odense/skolehjem/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package sde.odense.skolehjem; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("sde.odense.skolehjem", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/mobileapp/android/app/src/main/AndroidManifest.xml b/mobileapp/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..066e07d --- /dev/null +++ b/mobileapp/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/ic_launcher-playstore.png b/mobileapp/android/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..511dd3c Binary files /dev/null and b/mobileapp/android/app/src/main/ic_launcher-playstore.png differ diff --git a/mobileapp/android/app/src/main/java/sde/odense/skolehjem/MainActivity.java b/mobileapp/android/app/src/main/java/sde/odense/skolehjem/MainActivity.java new file mode 100644 index 0000000..6a18256 --- /dev/null +++ b/mobileapp/android/app/src/main/java/sde/odense/skolehjem/MainActivity.java @@ -0,0 +1,105 @@ +package sde.odense.skolehjem; + +import androidx.appcompat.app.AppCompatActivity; + +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.webkit.JavascriptInterface; +import android.webkit.JsResult; +import android.webkit.WebChromeClient; +import android.webkit.WebSettings; +import android.webkit.WebView; +import android.webkit.WebViewClient; + +public class MainActivity extends AppCompatActivity { + + private WebView webView; + private static final String TEL_PREFIX = "tel:"; + + @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + webView = findViewById(R.id.webView); + webView.setWebViewClient(new CustomWebViewClient()); + webView.setWebChromeClient(new CustomWebChromeClient(this)); + + //Settings + WebSettings webSettings = webView.getSettings(); + webSettings.setJavaScriptEnabled(true); + webSettings.setDomStorageEnabled(true); + webSettings.setLoadWithOverviewMode(true); + webSettings.setUseWideViewPort(true); + webSettings.setBuiltInZoomControls(true); + webSettings.setDisplayZoomControls(false); + webSettings.setSupportZoom(true); + webSettings.setDefaultTextEncodingName("utf-8"); + webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); + + webView.loadUrl("https://ekapp.sde.dk"); + } + + @Override + public void onBackPressed() { + if(webView.canGoBack()) + webView.goBack(); + else + super.onBackPressed(); + } + + private class CustomWebViewClient extends WebViewClient { + + @Override + public boolean shouldOverrideUrlLoading(WebView wv, String url) { + if(url.startsWith(TEL_PREFIX)) { + Intent intent = new Intent(Intent.ACTION_DIAL); + intent.setData(Uri.parse(url)); + startActivity(intent); + return true; + } + return false; + } + } + + static final class CustomWebChromeClient extends WebChromeClient { + Context myApp; + + CustomWebChromeClient(Context mContext){ + myApp = mContext; + } + + @Override + public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { + new AlertDialog.Builder(myApp) + .setTitle("Confirm") + .setMessage(message) + .setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int which) + { + result.confirm(); + } + }) + .setNegativeButton(android.R.string.cancel, + new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int which) + { + result.cancel(); + } + }) + .create() + .show(); + + return true; + } + } +} \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/mobileapp/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/mobileapp/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/drawable/ic_launcher_background.xml b/mobileapp/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/mobileapp/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobileapp/android/app/src/main/res/drawable/ic_launcher_foreground.xml b/mobileapp/android/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..6d5dec1 --- /dev/null +++ b/mobileapp/android/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mobileapp/android/app/src/main/res/layout/activity_main.xml b/mobileapp/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..f1f0a8e --- /dev/null +++ b/mobileapp/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/mobileapp/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/mobileapp/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/mobileapp/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..7353dbd --- /dev/null +++ b/mobileapp/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/mobileapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..b7aaf89 Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/mobileapp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..f156c70 Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/mobileapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..3ead88b Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/mobileapp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..71de51c Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/mobileapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..7d702ca Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/mobileapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..12068a7 Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/mobileapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..541253d Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/mobileapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..ae671e4 Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/mobileapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..c648a00 Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/mobileapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/mobileapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..38e63dd Binary files /dev/null and b/mobileapp/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/mobileapp/android/app/src/main/res/values/colors.xml b/mobileapp/android/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..4faecfa --- /dev/null +++ b/mobileapp/android/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #6200EE + #3700B3 + #03DAC5 + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/values/ic_launcher_background.xml b/mobileapp/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..c5d5899 --- /dev/null +++ b/mobileapp/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/values/strings.xml b/mobileapp/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..95f8e12 --- /dev/null +++ b/mobileapp/android/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + SDE Skolehjem + \ No newline at end of file diff --git a/mobileapp/android/app/src/main/res/values/styles.xml b/mobileapp/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..12ea838 --- /dev/null +++ b/mobileapp/android/app/src/main/res/values/styles.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/mobileapp/android/app/src/test/java/sde/odense/skolehjem/ExampleUnitTest.java b/mobileapp/android/app/src/test/java/sde/odense/skolehjem/ExampleUnitTest.java new file mode 100644 index 0000000..ce18be7 --- /dev/null +++ b/mobileapp/android/app/src/test/java/sde/odense/skolehjem/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package sde.odense.skolehjem; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file