Merge branch 'master' of https://github.com/sebathefox/skolehjem-webapp into master
This commit is contained in:
commit
a4509fa412
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,35 +1,101 @@
|
||||||
package sde.odense.skolehjem;
|
package sde.odense.skolehjem;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.webkit.JavascriptInterface;
|
import android.os.Environment;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.webkit.JsResult;
|
import android.webkit.JsResult;
|
||||||
|
import android.webkit.ValueCallback;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private static final String TEL_PREFIX = "tel:";
|
private static final String TEL_PREFIX = "tel:";
|
||||||
|
|
||||||
|
private static final String TAG = MainActivity.class.getSimpleName();
|
||||||
|
private final static int FCR = 1;
|
||||||
|
private String mCM;
|
||||||
|
private ValueCallback<Uri> mUM;
|
||||||
|
private ValueCallback<Uri[]> mUMA;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, intent);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Uri[] results = null;
|
||||||
|
|
||||||
|
//Check if response is positive
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
if (requestCode == FCR) {
|
||||||
|
|
||||||
|
if (null == mUMA) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (intent == null) {
|
||||||
|
//Capture Photo if no image available
|
||||||
|
if (mCM != null) {
|
||||||
|
results = new Uri[]{Uri.parse(mCM)};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String dataString = intent.getDataString();
|
||||||
|
if (dataString != null) {
|
||||||
|
results = new Uri[]{Uri.parse(dataString)};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mUMA.onReceiveValue(results);
|
||||||
|
mUMA = null;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (requestCode == FCR) {
|
||||||
|
if (null == mUM) return;
|
||||||
|
Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
|
||||||
|
mUM.onReceiveValue(result);
|
||||||
|
mUM = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 23 && (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)) {
|
||||||
|
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
webView = findViewById(R.id.webView);
|
webView = findViewById(R.id.webView);
|
||||||
webView.setWebViewClient(new CustomWebViewClient());
|
|
||||||
webView.setWebChromeClient(new CustomWebChromeClient(this));
|
|
||||||
|
|
||||||
//Settings
|
//Settings
|
||||||
WebSettings webSettings = webView.getSettings();
|
WebSettings webSettings = webView.getSettings();
|
||||||
|
@ -42,38 +108,20 @@ public class MainActivity extends AppCompatActivity {
|
||||||
webSettings.setSupportZoom(true);
|
webSettings.setSupportZoom(true);
|
||||||
webSettings.setDefaultTextEncodingName("utf-8");
|
webSettings.setDefaultTextEncodingName("utf-8");
|
||||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||||
|
webSettings.setAllowFileAccess(true);
|
||||||
|
|
||||||
webView.loadUrl("https://ekapp.sde.dk");
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
webSettings.setMixedContentMode(0);
|
||||||
|
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
} else if (Build.VERSION.SDK_INT >= 19) {
|
||||||
|
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
|
} else if (Build.VERSION.SDK_INT < 19) {
|
||||||
|
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
webView.setWebViewClient(new CustomWebViewClient());
|
||||||
public void onBackPressed() {
|
webView.setWebChromeClient(new WebChromeClient(){
|
||||||
if(webView.canGoBack())
|
Context myApp = getApplicationContext();
|
||||||
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
|
@Override
|
||||||
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
|
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
|
||||||
|
@ -101,5 +149,148 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//For Android 3.0+
|
||||||
|
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
|
||||||
|
|
||||||
|
mUM = uploadMsg;
|
||||||
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
i.setType("*/*");
|
||||||
|
MainActivity.this.startActivityForResult(Intent.createChooser(i, "File Chooser"), FCR);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For Android 3.0+, above method not supported in some android 3+ versions, in such case we use this
|
||||||
|
public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
|
||||||
|
|
||||||
|
mUM = uploadMsg;
|
||||||
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
i.setType("*/*");
|
||||||
|
MainActivity.this.startActivityForResult(
|
||||||
|
Intent.createChooser(i, "File Browser"),
|
||||||
|
FCR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//For Android 4.1+
|
||||||
|
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
|
||||||
|
mUM = uploadMsg;
|
||||||
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
i.setType("*/*");
|
||||||
|
MainActivity.this.startActivityForResult(Intent.createChooser(i, "File Chooser"), MainActivity.FCR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//For Android 5.0+
|
||||||
|
public boolean onShowFileChooser(
|
||||||
|
WebView webView, ValueCallback<Uri[]> filePathCallback,
|
||||||
|
WebChromeClient.FileChooserParams fileChooserParams) {
|
||||||
|
|
||||||
|
if (mUMA != null) {
|
||||||
|
mUMA.onReceiveValue(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
mUMA = filePathCallback;
|
||||||
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
if (takePictureIntent.resolveActivity(MainActivity.this.getPackageManager()) != null) {
|
||||||
|
|
||||||
|
File photoFile = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
photoFile = createImageFile();
|
||||||
|
takePictureIntent.putExtra("PhotoPath", mCM);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Log.e(TAG, "Image file creation failed", ex);
|
||||||
|
}
|
||||||
|
if (photoFile != null) {
|
||||||
|
mCM = "file:" + photoFile.getAbsolutePath();
|
||||||
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
|
||||||
|
} else {
|
||||||
|
takePictureIntent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
contentSelectionIntent.setType("*/*");
|
||||||
|
Intent[] intentArray;
|
||||||
|
|
||||||
|
if (takePictureIntent != null) {
|
||||||
|
intentArray = new Intent[]{takePictureIntent};
|
||||||
|
} else {
|
||||||
|
intentArray = new Intent[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
|
||||||
|
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
|
||||||
|
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
|
||||||
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
||||||
|
startActivityForResult(chooserIntent, FCR);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
webView.loadUrl("https://ekapp.sde.dk");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create an image file
|
||||||
|
private File createImageFile() throws IOException {
|
||||||
|
|
||||||
|
@SuppressLint("SimpleDateFormat") String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||||
|
String imageFileName = "img_" + timeStamp + "_";
|
||||||
|
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
||||||
|
return File.createTempFile(imageFileName, ".jpg", storageDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if(webView.canGoBack())
|
||||||
|
webView.goBack();
|
||||||
|
else
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
|
||||||
|
|
||||||
|
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
|
|
||||||
|
switch (keyCode) {
|
||||||
|
case KeyEvent.KEYCODE_BACK:
|
||||||
|
|
||||||
|
if (webView.canGoBack()) {
|
||||||
|
webView.goBack();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||||
|
Toast.makeText(getApplicationContext(), "Failed loading app!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<androidx.appcompat>
|
<androidx.appcompat>
|
||||||
<appcompat versions="1.0.0-alpha1,1.0.0-alpha3,1.0.0-beta01,1.0.0-rc01,1.0.0-rc02,1.0.0,1.0.1,1.0.2,1.1.0-alpha01,1.1.0-alpha02,1.1.0-alpha03,1.1.0-alpha04,1.1.0-alpha05,1.1.0-beta01,1.1.0-rc01,1.1.0,1.2.0-alpha01,1.2.0-alpha02,1.2.0-alpha03,1.2.0-beta01,1.2.0-rc01,1.2.0-rc02,1.3.0-alpha01"/>
|
<appcompat versions="1.0.0-alpha1,1.0.0-alpha3,1.0.0-beta01,1.0.0-rc01,1.0.0-rc02,1.0.0,1.0.1,1.0.2,1.1.0-alpha01,1.1.0-alpha02,1.1.0-alpha03,1.1.0-alpha04,1.1.0-alpha05,1.1.0-beta01,1.1.0-rc01,1.1.0,1.2.0-alpha01,1.2.0-alpha02,1.2.0-alpha03,1.2.0-beta01,1.2.0-rc01,1.2.0-rc02,1.2.0,1.3.0-alpha01"/>
|
||||||
<appcompat-resources versions="1.1.0-alpha03,1.1.0-alpha04,1.1.0-alpha05,1.1.0-beta01,1.1.0-rc01,1.1.0,1.2.0-alpha01,1.2.0-alpha02,1.2.0-alpha03,1.2.0-beta01,1.2.0-rc01,1.2.0-rc02,1.3.0-alpha01"/>
|
<appcompat-resources versions="1.1.0-alpha03,1.1.0-alpha04,1.1.0-alpha05,1.1.0-beta01,1.1.0-rc01,1.1.0,1.2.0-alpha01,1.2.0-alpha02,1.2.0-alpha03,1.2.0-beta01,1.2.0-rc01,1.2.0-rc02,1.2.0,1.3.0-alpha01"/>
|
||||||
</androidx.appcompat>
|
</androidx.appcompat>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<androidx.test.espresso>
|
<androidx.test.espresso>
|
||||||
<espresso-accessibility versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-accessibility versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
<espresso-contrib versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-contrib versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
<espresso-core versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-core versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
<espresso-idling-resource versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-idling-resource versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
<espresso-intents versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-intents versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
<espresso-remote versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-remote versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
<espresso-web versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02"/>
|
<espresso-web versions="3.1.0-alpha1,3.1.0-alpha2,3.1.0-alpha3,3.1.0-alpha4,3.1.0-beta01,3.1.0-beta02,3.1.0,3.1.1-alpha01,3.1.1-beta01,3.1.1,3.1.2-alpha01,3.2.0-alpha02,3.2.0-alpha03,3.2.0-alpha04,3.2.0-alpha05,3.2.0-beta01,3.2.0,3.3.0-alpha01,3.3.0-alpha02,3.3.0-alpha03,3.3.0-alpha04,3.3.0-alpha05,3.3.0-beta01,3.3.0-beta02,3.3.0-rc01,3.3.0-rc02,3.3.0-rc03"/>
|
||||||
</androidx.test.espresso>
|
</androidx.test.espresso>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<androidx.test.ext>
|
<androidx.test.ext>
|
||||||
<junit versions="1.0.0-beta01,1.0.0-beta02,1.0.0,1.1.0-alpha01,1.1.0-beta01,1.1.0,1.1.1-alpha01,1.1.1-alpha02,1.1.1-alpha03,1.1.1-alpha04,1.1.1-alpha05,1.1.1-beta01,1.1.1,1.1.2-alpha01,1.1.2-alpha02,1.1.2-alpha03,1.1.2-alpha04,1.1.2-alpha05,1.1.2-beta01,1.1.2-beta02,1.1.2-rc01,1.1.2-rc02"/>
|
<junit versions="1.0.0-beta01,1.0.0-beta02,1.0.0,1.1.0-alpha01,1.1.0-beta01,1.1.0,1.1.1-alpha01,1.1.1-alpha02,1.1.1-alpha03,1.1.1-alpha04,1.1.1-alpha05,1.1.1-beta01,1.1.1,1.1.2-alpha01,1.1.2-alpha02,1.1.2-alpha03,1.1.2-alpha04,1.1.2-alpha05,1.1.2-beta01,1.1.2-beta02,1.1.2-rc01,1.1.2-rc02,1.1.2-rc03"/>
|
||||||
<junit-ktx versions="1.1.0-alpha01,1.1.0-beta01,1.1.0,1.1.1-alpha01,1.1.1-alpha02,1.1.1-alpha03,1.1.1-alpha04,1.1.1-alpha05,1.1.1-beta01,1.1.1,1.1.2-alpha01,1.1.2-alpha02,1.1.2-alpha03,1.1.2-alpha04,1.1.2-alpha05,1.1.2-beta01,1.1.2-beta02,1.1.2-rc01,1.1.2-rc02"/>
|
<junit-ktx versions="1.1.0-alpha01,1.1.0-beta01,1.1.0,1.1.1-alpha01,1.1.1-alpha02,1.1.1-alpha03,1.1.1-alpha04,1.1.1-alpha05,1.1.1-beta01,1.1.1,1.1.2-alpha01,1.1.2-alpha02,1.1.2-alpha03,1.1.2-alpha04,1.1.2-alpha05,1.1.2-beta01,1.1.2-beta02,1.1.2-rc01,1.1.2-rc02,1.1.2-rc03"/>
|
||||||
<truth versions="1.0.0-alpha2,1.0.0-alpha3,1.0.0-alpha4,1.0.0-beta01,1.0.0-beta02,1.0.0,1.1.0-alpha01,1.1.0-beta01,1.1.0,1.1.1-alpha01,1.2.0-alpha02,1.2.0-alpha03,1.2.0-alpha04,1.2.0-alpha05,1.2.0-beta01,1.2.0,1.3.0-alpha01,1.3.0-alpha02,1.3.0-alpha03,1.3.0-alpha04,1.3.0-alpha05,1.3.0-beta01,1.3.0-beta02,1.3.0-rc01,1.3.0-rc02"/>
|
<truth versions="1.0.0-alpha2,1.0.0-alpha3,1.0.0-alpha4,1.0.0-beta01,1.0.0-beta02,1.0.0,1.1.0-alpha01,1.1.0-beta01,1.1.0,1.1.1-alpha01,1.2.0-alpha02,1.2.0-alpha03,1.2.0-alpha04,1.2.0-alpha05,1.2.0-beta01,1.2.0,1.3.0-alpha01,1.3.0-alpha02,1.3.0-alpha03,1.3.0-alpha04,1.3.0-alpha05,1.3.0-beta01,1.3.0-beta02,1.3.0-rc01,1.3.0-rc02,1.3.0-rc03"/>
|
||||||
</androidx.test.ext>
|
</androidx.test.ext>
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
<androidx.enterprise/>
|
<androidx.enterprise/>
|
||||||
<androidx.exifinterface/>
|
<androidx.exifinterface/>
|
||||||
<androidx.fragment/>
|
<androidx.fragment/>
|
||||||
|
<androidx.games/>
|
||||||
<androidx.gaming/>
|
<androidx.gaming/>
|
||||||
<androidx.gridlayout/>
|
<androidx.gridlayout/>
|
||||||
<androidx.heifwriter/>
|
<androidx.heifwriter/>
|
||||||
|
|
|
@ -358,6 +358,42 @@ class UserController extends Controller
|
||||||
return redirect()->route("users.index");
|
return redirect()->route("users.index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createajax() {
|
||||||
|
// Check the UserEvent table if there is a row that has the user_id AND the event_id
|
||||||
|
$User = User::query()->where('id', '=', auth()->user()->id);
|
||||||
|
|
||||||
|
// If you are in the Event, then remove yourself.
|
||||||
|
if (count($User->get()) > 0) {
|
||||||
|
// If not, then it keeps going and saves and shows a success message
|
||||||
|
$User->update([ "wants_emails" => true ]);
|
||||||
|
|
||||||
|
if (request()->cookie('languagesSetting') == "dk")
|
||||||
|
return '<p class="text-center"><b>Du får nu mails, når der kommer nyheder!</b></p>';
|
||||||
|
if (request()->cookie('languagesSetting') == "en")
|
||||||
|
return "<p class='text-center'><b>You'll now receive a mail when there's news!</b></p>";
|
||||||
|
|
||||||
|
return '<p class="text-center"><b>Du får nu mails, når der kommer nyheder!</b></p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createajaxcancel() {
|
||||||
|
// Check the UserEvent table if there is a row that has the user_id AND the event_id
|
||||||
|
$User = User::query()->where('id', '=', auth()->user()->id);
|
||||||
|
|
||||||
|
// If you are in the Event, then remove yourself.
|
||||||
|
if (count($User->get()) > 0) {
|
||||||
|
// If not, then it keeps going and saves and shows a success message
|
||||||
|
$User->update([ "wants_emails" => false ]);
|
||||||
|
|
||||||
|
if (request()->cookie('languagesSetting') == "dk")
|
||||||
|
return '<p class="text-center"><b>Du får ikke mails mere, når kommer nyheder!</b></p>';
|
||||||
|
if (request()->cookie('languagesSetting') == "en")
|
||||||
|
return "<p class='text-center'><b>You'll no longer receive a mail when there's news!</b></p>";
|
||||||
|
|
||||||
|
return '<p class="text-center"><b>Du får ikke mails mere, når kommer nyheder!</b></p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
/* Search and settings */
|
/* Search and settings */
|
||||||
/*******************************************/
|
/*******************************************/
|
||||||
|
|
|
@ -97,13 +97,14 @@
|
||||||
<div>
|
<div>
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
@if(\App\User::query()->where('id', '=', auth()->user()->id)->first()->wants_emails == true)
|
@if(\App\User::query()->where('id', '=', auth()->user()->id)->first()->wants_emails == true)
|
||||||
<input type="checkbox" checked>
|
<input type="checkbox" onclick="ajaxCall(this)" checked>
|
||||||
@else
|
@else
|
||||||
<input type="checkbox">
|
<input type="checkbox" onclick="ajaxCall(this)">
|
||||||
@endif
|
@endif
|
||||||
<span class="slider round"></span>
|
<span class="slider round"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="snackbar"></div>
|
||||||
</main>
|
</main>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function (){
|
$(document).ready(function (){
|
||||||
|
@ -142,5 +143,39 @@
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function snackbar(data) {
|
||||||
|
var x = document.getElementById("snackbar");
|
||||||
|
x.innerHTML = data;
|
||||||
|
x.className = "show";
|
||||||
|
|
||||||
|
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ajaxCall(el) {
|
||||||
|
if (el.hasAttribute('checked')) {
|
||||||
|
axios.post("{{ route("users.createajaxcancel") }}", {}
|
||||||
|
).then(function (response) {
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
|
snackbar(data);
|
||||||
|
|
||||||
|
el.removeAttribute('checked');
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
axios.post("{{ route("users.createajax") }}", {}
|
||||||
|
).then(function (response) {
|
||||||
|
var data = response.data;
|
||||||
|
|
||||||
|
snackbar(data);
|
||||||
|
|
||||||
|
el.setAttribute('checked', 'checked');
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
@ -33,8 +33,10 @@ Route::get("/washing-reservationsapi", "WashingReservationController@api")->name
|
||||||
Route::get("/app/washing-reservations", "WashingReservationController@appindex")->name("washing-reservations.appindex");
|
Route::get("/app/washing-reservations", "WashingReservationController@appindex")->name("washing-reservations.appindex");
|
||||||
Route::get("/settings", "SettingsController@index")->name("settings.index");
|
Route::get("/settings", "SettingsController@index")->name("settings.index");
|
||||||
Route::post("/events/signup", "UserEventController@createajax")->name("userevents.createajax");
|
Route::post("/events/signup", "UserEventController@createajax")->name("userevents.createajax");
|
||||||
|
Route::post("/account/mailwants", "UserController@createajax")->name("users.createajax");
|
||||||
Route::get("/about", "AboutController@index")->name("about.index");
|
Route::get("/about", "AboutController@index")->name("about.index");
|
||||||
Route::post("/events/cancelsignup", "UserEventController@createajaxcancel")->name("userevents.createajaxcancel");
|
Route::post("/events/cancelsignup", "UserEventController@createajaxcancel")->name("userevents.createajaxcancel");
|
||||||
|
Route::post("/account/cancelmailwants", "UserController@createajaxcancel")->name("users.createajaxcancel");
|
||||||
Route::delete("/notifications/delete", "EventController@deleteNotifications")->name("notifications.delete");
|
Route::delete("/notifications/delete", "EventController@deleteNotifications")->name("notifications.delete");
|
||||||
|
|
||||||
//Search/Filter
|
//Search/Filter
|
||||||
|
|
Loading…
Reference in New Issue