Reinitialize
|
@ -1,64 +1,10 @@
|
|||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
.idea/caches
|
||||
|
||||
# Keystore files
|
||||
# Uncomment the following line if you do not want to check your keystore files in.
|
||||
#*.jks
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Freeline
|
||||
freeline.py
|
||||
freeline/
|
||||
freeline_project_description.json
|
||||
|
||||
# fastlane
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
fastlane/readme.md
|
||||
|
|
|
@ -3,37 +3,22 @@
|
|||
<component name="WizardSettings">
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="imageWizard">
|
||||
<entry key="vectorWizard">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="imageAssetPanel">
|
||||
<entry key="vectorAssetStep">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="actionbar">
|
||||
<entry key="clipartAsset">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="clipartAsset">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="jar:file:/opt/android-studio/plugins/android/lib/android.jar!/images/material_design_icons/image/ic_center_focus_weak_black_24dp.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="theme" value="HOLO_DARK" />
|
||||
<entry key="url" value="jar:file:/opt/android-studio/plugins/android/lib/android.jar!/images/material_design_icons/navigation/ic_arrow_back_black_24dp.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
|
@ -43,7 +28,9 @@
|
|||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="outputIconType" value="ACTIONBAR" />
|
||||
<entry key="color" value="ffffff" />
|
||||
<entry key="outputName" value="ic_arrow_back_white" />
|
||||
<entry key="sourceFile" value="$USER_HOME$" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -25,7 +25,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/MISPAuthentificator.iml" filepath="$PROJECT_DIR$/MISPAuthentificator.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/mispAuth-v2.iml" filepath="$PROJECT_DIR$/mispAuth-v2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
|
|||
android {
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
applicationId "de.korrelator.overview.mispauthv2"
|
||||
applicationId "de.overview.wg.its.misp_authentificator"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
|
@ -23,10 +23,10 @@ dependencies {
|
|||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
||||
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
implementation 'com.android.support:cardview-v7:27.1.1'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
|
||||
implementation 'com.android.volley:volley:1.1.0'
|
||||
implementation 'com.github.kenglxn.QRGen:android:2.4.0'
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("de.korrelator.overview.mispauthv2", appContext.getPackageName());
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
package de.overview.wg.its.misp_authentificator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
|
@ -21,6 +21,6 @@ public class ExampleInstrumentedTest {
|
|||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("de.korrelator.overview.mispauth", appContext.getPackageName());
|
||||
assertEquals("de.overview.wg.its.misp_authentificator", appContext.getPackageName());
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="de.korrelator.overview.mispauthv2">
|
||||
package="de.overview.wg.its.misp_authentificator">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -11,14 +11,21 @@
|
|||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".activity.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".SyncActivity"></activity>
|
||||
<activity
|
||||
android:name=".activity.SettingsActivity"
|
||||
android:parentActivityName=".activity.MainActivity" />
|
||||
<activity
|
||||
android:parentActivityName=".activity.MainActivity"
|
||||
android:name=".activity.SyncActivity"
|
||||
android:label="@string/title_activity_sync"
|
||||
android:theme="@style/AppTheme"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,109 +0,0 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatDelegate;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/**
|
||||
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
|
||||
* to be used with AppCompat.
|
||||
*/
|
||||
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
|
||||
|
||||
private AppCompatDelegate mDelegate;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getDelegate().installViewFactory();
|
||||
getDelegate().onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
getDelegate().onPostCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
public ActionBar getSupportActionBar() {
|
||||
return getDelegate().getSupportActionBar();
|
||||
}
|
||||
|
||||
public void setSupportActionBar(@Nullable Toolbar toolbar) {
|
||||
getDelegate().setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuInflater getMenuInflater() {
|
||||
return getDelegate().getMenuInflater();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(@LayoutRes int layoutResID) {
|
||||
getDelegate().setContentView(layoutResID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(View view) {
|
||||
getDelegate().setContentView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
||||
getDelegate().setContentView(view, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addContentView(View view, ViewGroup.LayoutParams params) {
|
||||
getDelegate().addContentView(view, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
getDelegate().onPostResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTitleChanged(CharSequence title, int color) {
|
||||
super.onTitleChanged(title, color);
|
||||
getDelegate().setTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
getDelegate().onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getDelegate().onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
getDelegate().onDestroy();
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
getDelegate().invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private AppCompatDelegate getDelegate() {
|
||||
if (mDelegate == null) {
|
||||
mDelegate = AppCompatDelegate.create(this, null);
|
||||
}
|
||||
return mDelegate;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Display;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.glxn.qrgen.android.QRCode;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class GenerateQrActivity extends AppCompatActivity {
|
||||
|
||||
private Point displaySize;
|
||||
private ImageView qrImageView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
|
||||
setContentView(R.layout.activity_generate_qr);
|
||||
qrImageView = findViewById(R.id.image_view_qr);
|
||||
|
||||
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
displaySize = new Point();
|
||||
display.getSize(displaySize);
|
||||
|
||||
DisplayQR("https://www.google.de \n OrgName \n " + UUID.randomUUID());
|
||||
}
|
||||
|
||||
public void DisplayQR(String message){
|
||||
|
||||
Bitmap bitmap = QRCode.from(message)
|
||||
.withSize(displaySize.x, displaySize.y)
|
||||
.withColor(0xFF000000, 0x00000000)
|
||||
.bitmap();
|
||||
|
||||
qrImageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final int QR_REQUEST_CODE = 123;
|
||||
private TextView qrResult;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
qrResult = findViewById(R.id.text_view_qr_result);
|
||||
|
||||
Button scanButton = findViewById(R.id.button_scan);
|
||||
scanButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startCameraIntent();
|
||||
}
|
||||
});
|
||||
|
||||
Button generateButton = findViewById(R.id.button_generate);
|
||||
generateButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startQrIntent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void startCameraIntent(){
|
||||
Intent intent = new Intent(this, ReadQrActivity.class);
|
||||
startActivityForResult(intent, QR_REQUEST_CODE);
|
||||
}
|
||||
|
||||
|
||||
private void startQrIntent(){
|
||||
Intent intent = new Intent(this, GenerateQrActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
if (requestCode == QR_REQUEST_CODE) {
|
||||
if(resultCode == Activity.RESULT_OK){
|
||||
String result = data.getStringExtra("result");
|
||||
qrResult.setText(result);
|
||||
}
|
||||
|
||||
if (resultCode == Activity.RESULT_CANCELED) {
|
||||
qrResult.setText("NO QR FOUND");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.action_settings) {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
|
@ -1,346 +0,0 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.ImageFormat;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCaptureSession;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraDevice;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CaptureRequest;
|
||||
import android.hardware.camera2.params.StreamConfigurationMap;
|
||||
import android.media.Image;
|
||||
import android.media.ImageReader;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.renderscript.Allocation;
|
||||
import android.renderscript.Element;
|
||||
import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicYuvToRGB;
|
||||
import android.renderscript.Type;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.util.Size;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Surface;
|
||||
import android.view.TextureView;
|
||||
|
||||
import com.google.android.gms.vision.Frame;
|
||||
import com.google.android.gms.vision.barcode.Barcode;
|
||||
import com.google.android.gms.vision.barcode.BarcodeDetector;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ReadQrActivity extends AppCompatActivity {
|
||||
|
||||
// CAMERA
|
||||
private static final int CAMERA_REQUEST_CODE = 1;
|
||||
|
||||
private CameraManager cameraManager;
|
||||
private int cameraFacing;
|
||||
private String cameraId;
|
||||
private Size previewSize;
|
||||
|
||||
private CameraDevice cameraDevice;
|
||||
private CameraDevice.StateCallback stateCallback;
|
||||
private CameraCaptureSession cameraCaptureSession;
|
||||
private CaptureRequest captureRequest;
|
||||
private CaptureRequest.Builder captureRequestBuilder;
|
||||
|
||||
private TextureView texturePreviewView;
|
||||
private TextureView.SurfaceTextureListener surfaceTextureListener;
|
||||
|
||||
private HandlerThread camBackgroundThread;
|
||||
private Handler camBackgroundHandler;
|
||||
|
||||
private ImageReader previewImageReader;
|
||||
private ImageReader.OnImageAvailableListener previewImageListener;
|
||||
|
||||
// BARCODE
|
||||
private BarcodeDetector barcodeDetector;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_read_qr);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize(){
|
||||
|
||||
texturePreviewView = findViewById(R.id.texture_view);
|
||||
|
||||
setUpBarcodeDetector();
|
||||
|
||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CODE);
|
||||
|
||||
cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
|
||||
cameraFacing = CameraCharacteristics.LENS_FACING_BACK;
|
||||
|
||||
surfaceTextureListener = new TextureView.SurfaceTextureListener() {
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
|
||||
setUpCamera();
|
||||
openCamera();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
stateCallback = new CameraDevice.StateCallback() {
|
||||
@Override
|
||||
public void onOpened(CameraDevice cameraDevice) {
|
||||
ReadQrActivity.this.cameraDevice = cameraDevice;
|
||||
createPreviewSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected(CameraDevice cameraDevice) {
|
||||
cameraDevice.close();
|
||||
ReadQrActivity.this.cameraDevice = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(CameraDevice cameraDevice, int error) {
|
||||
cameraDevice.close();
|
||||
ReadQrActivity.this.cameraDevice = null;
|
||||
}
|
||||
};
|
||||
|
||||
previewImageListener = new ImageReader.OnImageAvailableListener() {
|
||||
@Override
|
||||
public void onImageAvailable(ImageReader reader) {
|
||||
|
||||
Image img = reader.acquireLatestImage();
|
||||
|
||||
if(img == null){
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bitmapImage = YUV_420_888_toRGBIntrinsics(img);
|
||||
|
||||
if(bitmapImage != null){
|
||||
Frame frame = new Frame.Builder().setBitmap(bitmapImage).build();
|
||||
SparseArray<Barcode> barcodes = barcodeDetector.detect(frame);
|
||||
|
||||
if(barcodes.size() > 0){
|
||||
returnQrResult(barcodes.valueAt(0).displayValue);
|
||||
}
|
||||
}
|
||||
|
||||
img.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void returnQrResult(String msg){
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra("result", msg);
|
||||
setResult(Activity.RESULT_OK, returnIntent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void setUpBarcodeDetector(){
|
||||
barcodeDetector = new BarcodeDetector.Builder(getApplicationContext())
|
||||
.setBarcodeFormats(Barcode.DATA_MATRIX | Barcode.QR_CODE)
|
||||
.build();
|
||||
|
||||
Log.i("QR", "Setting up BarCodeDetector!");
|
||||
|
||||
if (!barcodeDetector.isOperational()) {
|
||||
Log.e("QR", "BARCODE DETECTOR IS NOT OPERATIONAL !!!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setUpCamera() {
|
||||
try {
|
||||
for (String cameraId : cameraManager.getCameraIdList()) {
|
||||
|
||||
CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId);
|
||||
|
||||
if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING) == cameraFacing) {
|
||||
StreamConfigurationMap streamConfigurationMap = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
|
||||
previewSize = streamConfigurationMap.getOutputSizes(SurfaceTexture.class)[0];
|
||||
this.cameraId = cameraId;
|
||||
|
||||
// TEST
|
||||
previewImageReader = ImageReader.newInstance(400, 600, ImageFormat.YUV_420_888, 2);
|
||||
previewImageReader.setOnImageAvailableListener(previewImageListener, camBackgroundHandler);
|
||||
}
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void openCamera() {
|
||||
try {
|
||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
|
||||
cameraManager.openCamera(cameraId, stateCallback, camBackgroundHandler);
|
||||
}
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createPreviewSession() {
|
||||
try {
|
||||
|
||||
SurfaceTexture surfaceTexture = texturePreviewView.getSurfaceTexture();
|
||||
surfaceTexture.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
|
||||
|
||||
Surface previewSurface = new Surface(surfaceTexture);
|
||||
|
||||
captureRequestBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
|
||||
|
||||
// This is the real surface used for preview
|
||||
captureRequestBuilder.addTarget(previewSurface);
|
||||
|
||||
// preview Surface for postprocessing
|
||||
captureRequestBuilder.addTarget(previewImageReader.getSurface());
|
||||
|
||||
cameraDevice.createCaptureSession(Arrays.asList(previewSurface, previewImageReader.getSurface()), new CameraCaptureSession.StateCallback() {
|
||||
|
||||
@Override
|
||||
public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) {
|
||||
if (cameraDevice == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
captureRequest = captureRequestBuilder.build();
|
||||
|
||||
ReadQrActivity.this.cameraCaptureSession = cameraCaptureSession;
|
||||
ReadQrActivity.this.cameraCaptureSession.setRepeatingRequest(captureRequest, null, camBackgroundHandler);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) {
|
||||
|
||||
}
|
||||
}, camBackgroundHandler);
|
||||
} catch (CameraAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void camOpenBackgroundThread() {
|
||||
camBackgroundThread = new HandlerThread("camera_background_thread");
|
||||
camBackgroundThread.start();
|
||||
camBackgroundHandler = new Handler(camBackgroundThread.getLooper());
|
||||
}
|
||||
|
||||
private void closeCamera() {
|
||||
if (cameraCaptureSession != null) {
|
||||
cameraCaptureSession.close();
|
||||
cameraCaptureSession = null;
|
||||
}
|
||||
|
||||
if (cameraDevice != null) {
|
||||
cameraDevice.close();
|
||||
cameraDevice = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void closeBackgroundThreads() {
|
||||
if (camBackgroundHandler != null) {
|
||||
camBackgroundThread.quitSafely();
|
||||
camBackgroundThread = null;
|
||||
camBackgroundHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
camOpenBackgroundThread();
|
||||
|
||||
if (texturePreviewView.isAvailable()) {
|
||||
setUpCamera();
|
||||
openCamera();
|
||||
} else {
|
||||
texturePreviewView.setSurfaceTextureListener(surfaceTextureListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
closeCamera();
|
||||
closeBackgroundThreads();
|
||||
}
|
||||
|
||||
|
||||
private Bitmap YUV_420_888_toRGBIntrinsics(Image image) {
|
||||
|
||||
if (image == null) return null;
|
||||
|
||||
int W = image.getWidth();
|
||||
int H = image.getHeight();
|
||||
|
||||
Image.Plane Y = image.getPlanes()[0];
|
||||
Image.Plane U = image.getPlanes()[1];
|
||||
Image.Plane V = image.getPlanes()[2];
|
||||
|
||||
int Yb = Y.getBuffer().remaining();
|
||||
int Ub = U.getBuffer().remaining();
|
||||
int Vb = V.getBuffer().remaining();
|
||||
|
||||
byte[] data = new byte[Yb + Ub + Vb];
|
||||
|
||||
Y.getBuffer().get(data, 0, Yb);
|
||||
V.getBuffer().get(data, Yb, Vb);
|
||||
U.getBuffer().get(data, Yb + Vb, Ub);
|
||||
|
||||
RenderScript rs = RenderScript.create(getApplicationContext());
|
||||
|
||||
ScriptIntrinsicYuvToRGB yuvToRgbIntrinsic = ScriptIntrinsicYuvToRGB.create(rs, Element.U8_4(rs));
|
||||
|
||||
Type.Builder yuvType = new Type.Builder(rs, Element.U8(rs)).setX(data.length);
|
||||
Allocation in = Allocation.createTyped(rs, yuvType.create(), Allocation.USAGE_SCRIPT);
|
||||
|
||||
Type.Builder rgbaType = new Type.Builder(rs, Element.RGBA_8888(rs)).setX(W).setY(H);
|
||||
Allocation out = Allocation.createTyped(rs, rgbaType.create(), Allocation.USAGE_SCRIPT);
|
||||
|
||||
|
||||
final Bitmap bmpout = Bitmap.createBitmap(W, H, Bitmap.Config.ARGB_8888);
|
||||
|
||||
in.copyFromUnchecked(data);
|
||||
|
||||
yuvToRgbIntrinsic.setInput(in);
|
||||
yuvToRgbIntrinsic.forEach(out);
|
||||
out.copyTo(bmpout);
|
||||
image.close();
|
||||
return bmpout ;
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
|
||||
}
|
||||
|
||||
public static class MainPreferenceFragment extends PreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.pref_main);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.volley.VolleyError;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.korrelator.overview.mispauthv2.models.Organisation;
|
||||
import de.korrelator.overview.mispauthv2.models.OrganisationBuilder;
|
||||
import de.korrelator.overview.mispauthv2.models.Server;
|
||||
import de.korrelator.overview.mispauthv2.models.ServerBuilder;
|
||||
import de.korrelator.overview.mispauthv2.models.User;
|
||||
import de.korrelator.overview.mispauthv2.models.UserBuilder;
|
||||
import de.korrelator.overview.mispauthv2.network.MispRequests;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "MISPAUTH";
|
||||
private static final int SYNC_EVENTS_REQUEST = 1000;
|
||||
|
||||
private MispRequests mispRequests;
|
||||
|
||||
private String myOrgName = "My Orgname";
|
||||
private String myEmail = "example@email.bar";
|
||||
private String baseURL = "http://192.168.178.200";
|
||||
|
||||
private TextView textViewResponse;
|
||||
|
||||
private int tmpOrgID, tmpSyncUserID;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
mispRequests = new MispRequests(getApplicationContext(), baseURL);
|
||||
textViewResponse = findViewById(R.id.textview_json_result);
|
||||
|
||||
Button syncEventsButton = findViewById(R.id.button_sync_events);
|
||||
syncEventsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SyncEvents();
|
||||
}
|
||||
});
|
||||
|
||||
Button shareEventsButton = findViewById(R.id.button_share_events);
|
||||
shareEventsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ShareEvents();
|
||||
}
|
||||
});
|
||||
|
||||
Button receiveEventsButton = findViewById(R.id.button_receive_events);
|
||||
receiveEventsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ReceiveEvents();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode){
|
||||
case SYNC_EVENTS_REQUEST:
|
||||
|
||||
String qrContent = data.getStringExtra("qr_data");
|
||||
|
||||
try {
|
||||
|
||||
JSONArray qrData = new JSONArray(qrContent);
|
||||
|
||||
JSONObject serverInfo = Server.fromJSON(qrData.getJSONObject(0)).toJSON();
|
||||
JSONObject userInfo = User.fromJSON(qrData.getJSONObject(1)).toJSON();
|
||||
JSONObject orgInfo = Organisation.fromJSON(qrData.getJSONObject(2)).toJSON();
|
||||
|
||||
mispRequests.EditOrganisation(tmpOrgID, orgInfo, new MispRequests.EditOrganisationResponse() {
|
||||
@Override
|
||||
public void result(boolean success) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(VolleyError volleyError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mispRequests.EditUser(tmpSyncUserID, userInfo, new MispRequests.EditUserResponse() {
|
||||
@Override
|
||||
public void result(JSONObject msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(VolleyError volleyError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mispRequests.AddServer(serverInfo, new MispRequests.AddServerResponse() {
|
||||
@Override
|
||||
public void result(JSONObject result) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(VolleyError volleyError) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.e(TAG, "requestCode " + requestCode + " is not known!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SyncEvents(){
|
||||
|
||||
JSONObject tmpOrgBody = new OrganisationBuilder().local(true).build().toJSON();
|
||||
|
||||
mispRequests.AddOrganisation(tmpOrgBody, new MispRequests.AddOrganisationResponse() {
|
||||
@Override
|
||||
public void result(int orgID) {
|
||||
|
||||
tmpOrgID = orgID;
|
||||
|
||||
JSONObject tmpSyncUser = new UserBuilder().orgID(orgID).roleType(User.RoleType.SYNC_USER).build().toJSON();
|
||||
|
||||
mispRequests.AddUser(tmpSyncUser, new MispRequests.AddUserResponse() {
|
||||
@Override
|
||||
public void result(int id, String authKey) {
|
||||
|
||||
tmpSyncUserID = id;
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
|
||||
JSONObject myServerInformation = new ServerBuilder()
|
||||
.url(baseURL)
|
||||
.name(myOrgName)
|
||||
.authKey(authKey)
|
||||
.build().toJSON();
|
||||
|
||||
JSONObject myUserInformation = new UserBuilder()
|
||||
.email("felixpk@outlug.de")
|
||||
.build()
|
||||
.toJSON();
|
||||
|
||||
JSONObject myOrganisationInformation = new OrganisationBuilder()
|
||||
.name(myOrgName)
|
||||
.local(true)
|
||||
.description("sample description")
|
||||
.nationality("DE")
|
||||
.sector("Programming")
|
||||
.build()
|
||||
.toJSON();
|
||||
|
||||
array.put(myServerInformation);
|
||||
array.put(myUserInformation);
|
||||
array.put(myOrganisationInformation);
|
||||
|
||||
Intent syncIntent = new Intent(getApplicationContext(), SyncActivity.class);
|
||||
syncIntent.putExtra("qr_data", array.toString());
|
||||
startActivityForResult(syncIntent, SYNC_EVENTS_REQUEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(VolleyError volleyError) {
|
||||
textViewResponse.setText(volleyError.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(VolleyError error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ShareEvents(){
|
||||
|
||||
}
|
||||
|
||||
private void ReceiveEvents(){
|
||||
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Display;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import net.glxn.qrgen.android.QRCode;
|
||||
|
||||
public class SyncActivity extends AppCompatActivity {
|
||||
|
||||
private Point displaySize;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sync);
|
||||
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
displaySize = new Point();
|
||||
display.getSize(displaySize);
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
String qrData = intent.getStringExtra("qr_data");
|
||||
PopulateMyQR(qrData);
|
||||
}
|
||||
|
||||
private void PopulateMyQR(String qrData){
|
||||
ImageView qrView = findViewById(R.id.image_view_sync_qr);
|
||||
|
||||
Bitmap bitmap =
|
||||
QRCode.from(qrData)
|
||||
.withSize(displaySize.x, displaySize.x)
|
||||
.withColor(0xFF000000, 0x00000000)
|
||||
.bitmap();
|
||||
|
||||
qrView.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
private void returnQrData(String qrData){
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra("qr_data", qrData);
|
||||
setResult(Activity.RESULT_OK, resultIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.camera;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.view.TextureView;
|
||||
|
||||
public class QRScanner {
|
||||
|
||||
private static final int CAM_REQUEST_CODE = 1;
|
||||
|
||||
private Context context;
|
||||
private TextureView textureView;
|
||||
|
||||
private CameraManager cameraManager;
|
||||
private int cameraFacing;
|
||||
|
||||
|
||||
public QRScanner(Context context, TextureView textureView){
|
||||
this.context = context.getApplicationContext();
|
||||
this.textureView = textureView;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize(){
|
||||
// ActivityCompat.requestPermissions(, new String[]{Manifest.permission.CAMERA}, CAM_REQUEST_CODE);
|
||||
|
||||
// cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
|
||||
// cameraFacing = CameraCharacteristics.LENS_FACING_BACK;
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.models;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Organisation {
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String nationality;
|
||||
private String sector;
|
||||
private String uuid;
|
||||
private boolean local;
|
||||
|
||||
|
||||
public Organisation(String name, boolean local, String description, String nationality, String sector, String uuid){
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.nationality = nationality;
|
||||
this.sector = sector;
|
||||
this.uuid = uuid;
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getSector() {
|
||||
return sector;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
return local;
|
||||
}
|
||||
|
||||
|
||||
public JSONObject toJSON(){
|
||||
JSONObject organisation = new JSONObject();
|
||||
|
||||
try {
|
||||
|
||||
organisation.put("local", local);
|
||||
|
||||
if(!name.equals("")){
|
||||
organisation.put("name", Uri.decode(name));
|
||||
}
|
||||
|
||||
if(!description.equals("")){
|
||||
organisation.put("description", Uri.decode(description));
|
||||
}
|
||||
|
||||
if(!nationality.equals("")){
|
||||
organisation.put("nationality", Uri.decode(nationality));
|
||||
}
|
||||
|
||||
if(!sector.equals("")){
|
||||
organisation.put("sector", Uri.decode(sector));
|
||||
}
|
||||
|
||||
if(!uuid.equals("")){
|
||||
organisation.put("uuid", Uri.decode(uuid));
|
||||
}
|
||||
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return organisation;
|
||||
}
|
||||
|
||||
public static Organisation fromJSON(JSONObject json){
|
||||
return new OrganisationBuilder()
|
||||
.name(json.optString("name", ""))
|
||||
.local(json.optBoolean("local", true))
|
||||
.description(json.optString("description", ""))
|
||||
.nationality(json.optString("nationality", ""))
|
||||
.sector(json.optString("sector", ""))
|
||||
.uuid(json.optString("uuid", ""))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.models;
|
||||
|
||||
public class OrganisationBuilder {
|
||||
|
||||
private String name = "Default Org";
|
||||
private boolean local = true;
|
||||
private String description = "";
|
||||
private String nationality = "";
|
||||
private String sector = "";
|
||||
private String uuid = "";
|
||||
|
||||
public OrganisationBuilder() {}
|
||||
|
||||
public Organisation build(){
|
||||
return new Organisation(name, local, description, nationality, sector, uuid);
|
||||
}
|
||||
|
||||
public OrganisationBuilder name(String name){
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrganisationBuilder local(boolean local){
|
||||
this.local = local;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrganisationBuilder description(String description){
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrganisationBuilder nationality(String nationality){
|
||||
this.nationality = nationality;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrganisationBuilder sector(String sector){
|
||||
this.sector = sector;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OrganisationBuilder uuid(String uuid){
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.models;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Server {
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
private String organisationType;
|
||||
private String authKey;
|
||||
|
||||
|
||||
public Server(String url, String name, String organisationType, String authKey) {
|
||||
this.url = url;
|
||||
this.name = name;
|
||||
this.organisationType = organisationType;
|
||||
this.authKey = authKey;
|
||||
}
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getOrganisationType() {
|
||||
return organisationType;
|
||||
}
|
||||
|
||||
public String getAuthKey() {
|
||||
return authKey;
|
||||
}
|
||||
|
||||
|
||||
public JSONObject toJSON(){
|
||||
|
||||
JSONObject server = new JSONObject();
|
||||
|
||||
try {
|
||||
|
||||
if(!url.equals("")){
|
||||
server.put("url", url);
|
||||
}
|
||||
|
||||
if(!name.equals("")){
|
||||
server.put("name", name);
|
||||
}
|
||||
|
||||
if(!organisationType.equals("")){
|
||||
server.put("organisation_type", organisationType);
|
||||
}
|
||||
|
||||
if(!authKey.equals("")){
|
||||
server.put("authkey", authKey);
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
public static Server fromJSON(JSONObject json){
|
||||
return new Server(
|
||||
json.optString("url", ""),
|
||||
json.optString("name", ""),
|
||||
json.optString("organisation_type", ""),
|
||||
json.optString("authkey", ""));
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.models;
|
||||
|
||||
public class ServerBuilder {
|
||||
|
||||
private String url = "";
|
||||
private String name = "";
|
||||
private String organisationType = "";
|
||||
private String authKey = "";
|
||||
|
||||
public ServerBuilder() {}
|
||||
|
||||
public Server build(){
|
||||
return new Server(url, name, organisationType, authKey);
|
||||
}
|
||||
|
||||
public ServerBuilder url(String url){
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerBuilder name(String name){
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerBuilder organisationType(String organisationType){
|
||||
this.organisationType = organisationType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerBuilder authKey(String authKey){
|
||||
this.authKey = authKey;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.models;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class User {
|
||||
|
||||
private String email;
|
||||
private int orgID;
|
||||
private int roleType;
|
||||
private String authKey;
|
||||
|
||||
|
||||
public User(String email, int orgID, int roleType, String authKey) {
|
||||
this.email = email;
|
||||
this.orgID = orgID;
|
||||
this.roleType = roleType;
|
||||
this.authKey = authKey;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public int getOrgID() {
|
||||
return orgID;
|
||||
}
|
||||
|
||||
public int getRoleType() {
|
||||
return roleType;
|
||||
}
|
||||
|
||||
public String getAuthKey() {
|
||||
return authKey;
|
||||
}
|
||||
|
||||
|
||||
public JSONObject toJSON(){
|
||||
JSONObject user = new JSONObject();
|
||||
|
||||
try {
|
||||
|
||||
if(!email.equals("")){
|
||||
user.put("email", email);
|
||||
}
|
||||
|
||||
if(orgID > -1){
|
||||
user.put("org_id", orgID);
|
||||
}
|
||||
|
||||
if(roleType > -1){
|
||||
user.put("role_id", roleType);
|
||||
}
|
||||
|
||||
if(!authKey.equals("")){
|
||||
user.put("authkey", authKey);
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public static User fromJSON(JSONObject json){
|
||||
return new User(
|
||||
json.optString("name", ""),
|
||||
json.optInt("org_id", -1),
|
||||
json.optInt("role_id", -1),
|
||||
json.optString("authkey", ""));
|
||||
}
|
||||
|
||||
|
||||
public interface RoleType{
|
||||
int ADMIN = 0;
|
||||
int SYNC_USER = 5;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.models;
|
||||
|
||||
public class UserBuilder {
|
||||
|
||||
private String email = "default@email.bar";
|
||||
private int orgID = -1;
|
||||
private int roleType = -1;
|
||||
private String authKey = "";
|
||||
|
||||
public UserBuilder(){}
|
||||
|
||||
public User build(){
|
||||
return new User(email, orgID, roleType, authKey);
|
||||
}
|
||||
|
||||
public UserBuilder email(String email){
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserBuilder orgID(int orgID){
|
||||
this.orgID = orgID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserBuilder roleType(int roleType){
|
||||
this.roleType = roleType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserBuilder authKey(String authKey){
|
||||
this.authKey = authKey;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,269 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.JsonArrayRequest;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.korrelator.overview.mispauthv2.R;
|
||||
|
||||
public class MispRequests {
|
||||
|
||||
private Context context;
|
||||
private RequestQueue queue;
|
||||
private String baseURL;
|
||||
|
||||
|
||||
public MispRequests(Context context, String baseURL){
|
||||
|
||||
this.context = context.getApplicationContext();
|
||||
this.baseURL = baseURL;
|
||||
|
||||
queue = Volley.newRequestQueue(this.context);
|
||||
}
|
||||
|
||||
|
||||
public void GetSyncUsers(final GetSyncUsersResponse resp){
|
||||
|
||||
String currentURL = baseURL + "/admin/users";
|
||||
|
||||
Response.Listener<JSONArray> responseListener = new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
|
||||
int userCount = response.length();
|
||||
|
||||
List<Integer> userIDList = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < userCount; i++){
|
||||
try{
|
||||
JSONObject root = response.getJSONObject(i);
|
||||
JSONObject role = root.getJSONObject("Role");
|
||||
JSONObject user = root.getJSONObject("User");
|
||||
|
||||
if(role.getInt("id") == 5){
|
||||
userIDList.add(user.getInt("id"));
|
||||
}
|
||||
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
resp.result(userIDList.toArray(new Integer[userIDList.size()]));
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
resp.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
queue.add(arrayRequest(Request.Method.GET, currentURL, null, responseListener, errorListener));
|
||||
}
|
||||
|
||||
public void AddUser(JSONObject body, final AddUserResponse resp){
|
||||
|
||||
String currentURL = baseURL + "/admin/users/add";
|
||||
|
||||
Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
JSONObject user = response.getJSONObject("User");
|
||||
resp.result(user.getInt("id"), user.getString("authkey"));
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
resp.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
queue.add(objectRequest(Request.Method.POST, currentURL, body, responseListener, errorListener));
|
||||
}
|
||||
|
||||
public void EditUser(int userID, JSONObject body, final EditUserResponse resp){
|
||||
String currentURL = baseURL + "/admin/users/edit/" + userID;
|
||||
|
||||
Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
resp.result(response);
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
resp.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
queue.add(objectRequest(Request.Method.POST, currentURL, body, responseListener, errorListener));
|
||||
}
|
||||
|
||||
public void AddOrganisation(JSONObject body, final AddOrganisationResponse response){
|
||||
|
||||
String currentURL = baseURL + "/admin/organisations/add";
|
||||
|
||||
Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject resp) {
|
||||
try {
|
||||
JSONObject org = resp.getJSONObject("Organisation");
|
||||
response.result(org.getInt("id"));
|
||||
} catch (JSONException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
response.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
queue.add(objectRequest(Request.Method.POST, currentURL, body, responseListener, errorListener));
|
||||
}
|
||||
|
||||
public void EditOrganisation(int orgID, JSONObject updateBody, final EditOrganisationResponse resp){
|
||||
|
||||
String currentURL = baseURL + "/admin/organisations/edit/" + orgID;
|
||||
|
||||
Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
resp.result(true);
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
resp.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
queue.add(objectRequest(Request.Method.POST, currentURL, updateBody, responseListener, errorListener));
|
||||
}
|
||||
|
||||
public void AddServer(JSONObject body, final AddServerResponse resp){
|
||||
String currentURL = baseURL + "/servers/add";
|
||||
|
||||
Response.Listener<JSONObject> responseListener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
resp.result(response);
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
resp.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
queue.add(objectRequest(Request.Method.POST, currentURL, body, responseListener, errorListener));
|
||||
}
|
||||
|
||||
|
||||
private JsonObjectRequest objectRequest(int method, String url, @Nullable JSONObject body, Response.Listener listener, Response.ErrorListener errorListener){
|
||||
return new JsonObjectRequest(
|
||||
method,
|
||||
url,
|
||||
body,
|
||||
listener,
|
||||
errorListener) {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
params.put("Authorization", context.getString(R.string.api_key));
|
||||
params.put("Accept", "application/json");
|
||||
params.put("Content-Type", "application/json; utf-8");
|
||||
|
||||
return params;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private JsonArrayRequest arrayRequest(int method, String url, @Nullable JSONArray body, Response.Listener listener, Response.ErrorListener errorListener){
|
||||
return new JsonArrayRequest(
|
||||
method,
|
||||
url,
|
||||
body,
|
||||
listener,
|
||||
errorListener){
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() throws AuthFailureError {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
params.put("Authorization", context.getString(R.string.api_key));
|
||||
params.put("Accept", "application/json");
|
||||
params.put("Content-Type", "application/json; utf-8");
|
||||
|
||||
return params;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public interface GetSyncUsersResponse{
|
||||
void result(Integer[] userIDs);
|
||||
void error(VolleyError volleyError);
|
||||
}
|
||||
|
||||
public interface AddOrganisationResponse{
|
||||
void result(int orgID);
|
||||
void error(VolleyError error);
|
||||
}
|
||||
|
||||
public interface EditOrganisationResponse{
|
||||
void result(boolean success);
|
||||
void error(VolleyError volleyError);
|
||||
}
|
||||
|
||||
public interface AddUserResponse {
|
||||
void result(int id, String authKey);
|
||||
void error(VolleyError volleyError);
|
||||
}
|
||||
|
||||
public interface EditUserResponse{
|
||||
void result(JSONObject msg);
|
||||
void error(VolleyError volleyError);
|
||||
}
|
||||
|
||||
public interface AddServerResponse{
|
||||
void result(JSONObject result);
|
||||
void error(VolleyError volleyError);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package de.overview.wg.its.misp_authentificator;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
public class PreferenceManager {
|
||||
|
||||
private static PreferenceManager instance;
|
||||
private Context context;
|
||||
private SharedPreferences sharedPreferences;
|
||||
|
||||
private String PREF_KEY_SERVER_URL;
|
||||
private String PREF_KEY_SERVER_API_KEY;
|
||||
|
||||
private PreferenceManager(Context context) {
|
||||
this.context = context;
|
||||
sharedPreferences = android.preference.PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
PREF_KEY_SERVER_URL = context.getResources().getString(R.string.key_server_url);
|
||||
PREF_KEY_SERVER_API_KEY = context.getResources().getString(R.string.key_server_api_key);
|
||||
}
|
||||
|
||||
public String getMyServerUrl() {
|
||||
return sharedPreferences.getString(PREF_KEY_SERVER_URL, "");
|
||||
}
|
||||
public void setMyServerUrl(String serverUrl) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(PREF_KEY_SERVER_URL, serverUrl);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public String getMyServerApiKey() {
|
||||
return sharedPreferences.getString(PREF_KEY_SERVER_API_KEY, "");
|
||||
}
|
||||
public void setMyServerApiKey(String apiKey) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(PREF_KEY_SERVER_API_KEY, apiKey);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public void deleteAllLocalData() {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.clear();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public static PreferenceManager Instance(Context context) {
|
||||
if(instance == null) {
|
||||
instance = new PreferenceManager(context);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package de.overview.wg.its.misp_authentificator.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import de.overview.wg.its.misp_authentificator.PreferenceManager;
|
||||
import de.overview.wg.its.misp_authentificator.R;
|
||||
import de.overview.wg.its.misp_authentificator.adapter.ExtOrgAdapter;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
PreferenceManager preferenceManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
preferenceManager = PreferenceManager.Instance(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
RecyclerView orgRecyclerView = findViewById(R.id.orgRecyclerView);
|
||||
orgRecyclerView.setHasFixedSize(true);
|
||||
|
||||
RecyclerView.LayoutManager orgLayoutManager = new LinearLayoutManager(this);
|
||||
orgRecyclerView.setLayoutManager(orgLayoutManager);
|
||||
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(orgRecyclerView.getContext(), 1);
|
||||
orgRecyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
String[] dataSet = {};
|
||||
RecyclerView.Adapter orgAdapter = new ExtOrgAdapter(dataSet);
|
||||
orgRecyclerView.setAdapter(orgAdapter);
|
||||
|
||||
if(dataSet.length == 0){
|
||||
orgRecyclerView.setVisibility(View.GONE);
|
||||
findViewById(R.id.empty_view).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
orgRecyclerView.setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.empty_view).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
FloatingActionButton fabAdd = findViewById(R.id.fab_add);
|
||||
final FloatingActionButton fabSync = findViewById(R.id.fab_sync);
|
||||
|
||||
fabAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(fabSync.getVisibility() == View.GONE){
|
||||
fabSync.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
fabSync.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fabSync.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startSyncActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.menu_item_settings) {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
private void startSyncActivity(){
|
||||
startActivity(new Intent(this, SyncActivity.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
package de.overview.wg.its.misp_authentificator.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.android.volley.AuthFailureError;
|
||||
import com.android.volley.NoConnectionError;
|
||||
import com.android.volley.VolleyError;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import de.overview.wg.its.misp_authentificator.PreferenceManager;
|
||||
import de.overview.wg.its.misp_authentificator.R;
|
||||
import de.overview.wg.its.misp_authentificator.network.MispRequest;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = "MISP-TAG";
|
||||
|
||||
private PreferenceManager preferenceManager;
|
||||
private ProgressBar progressBar;
|
||||
private TextInputLayout serverUrlLayout, apiKeyLayout;
|
||||
private EditText serverUrlText, apiKeyText;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
serverUrlLayout = findViewById(R.id.input_layout_server_url);
|
||||
apiKeyLayout = findViewById(R.id.input_layout_api_key);
|
||||
serverUrlText = findViewById(R.id.edit_server_url);
|
||||
apiKeyText = findViewById(R.id.edit_api_key);
|
||||
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
|
||||
FloatingActionButton fabDlOrgInfo = findViewById(R.id.fab_download_own_org_info);
|
||||
|
||||
fabDlOrgInfo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
downloadMyOrgInfo();
|
||||
}
|
||||
});
|
||||
|
||||
restoreSavedValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_settings, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.menu_item_deleteData) {
|
||||
serverUrlText.setText("");
|
||||
apiKeyText.setText("");
|
||||
preferenceManager.deleteAllLocalData();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
private void restoreSavedValues() {
|
||||
preferenceManager = PreferenceManager.Instance(this);
|
||||
|
||||
serverUrlText.setText(preferenceManager.getMyServerUrl());
|
||||
apiKeyText.setText(preferenceManager.getMyServerApiKey());
|
||||
}
|
||||
|
||||
private void downloadMyOrgInfo(){
|
||||
|
||||
boolean failed = false;
|
||||
|
||||
String tmpServerUrl = serverUrlText.getText().toString();
|
||||
String tmpApiKey = apiKeyText.getText().toString();
|
||||
|
||||
if(tmpServerUrl.isEmpty()) {
|
||||
serverUrlLayout.setError("Server URL is required");
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if(tmpApiKey.isEmpty()) {
|
||||
apiKeyLayout.setError("API Key is required");
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if(failed) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MispRequest request = MispRequest.Instance(this);
|
||||
|
||||
request.setServerCredentials(tmpServerUrl, tmpApiKey);
|
||||
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
request.myUserInformation(new MispRequest.UserInformationCallback() {
|
||||
@Override
|
||||
public void onResult(JSONObject myUserInformation) {
|
||||
|
||||
int orgID;
|
||||
|
||||
try {
|
||||
orgID = myUserInformation.getInt("org_id");
|
||||
|
||||
request.OrganisationInformation(orgID, new MispRequest.OrganisationInformationCallback() {
|
||||
@Override
|
||||
public void onResult(JSONObject organisationInformation) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
Log.i(TAG, "onResult: " + organisationInformation.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(VolleyError volleyError) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
Log.e(TAG, "onError: " + volleyError.toString());
|
||||
}
|
||||
});
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(VolleyError volleyError) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
if(volleyError instanceof NoConnectionError) {
|
||||
MakeAlert("No connection to server");
|
||||
} else if(volleyError instanceof AuthFailureError) {
|
||||
MakeAlert("Wrong API key");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// If auth was successful: save new credentials
|
||||
preferenceManager.setMyServerUrl(tmpServerUrl);
|
||||
preferenceManager.setMyServerApiKey(tmpApiKey);
|
||||
|
||||
}
|
||||
|
||||
private void MakeAlert(String msg){
|
||||
|
||||
View contextView = findViewById(R.id.coordinator);
|
||||
|
||||
Snackbar.make(contextView, msg, Snackbar.LENGTH_LONG)
|
||||
.addCallback(new Snackbar.Callback(){
|
||||
@Override
|
||||
public void onShown(Snackbar sb) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package de.overview.wg.its.misp_authentificator.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import de.overview.wg.its.misp_authentificator.R;
|
||||
|
||||
public class SyncActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sync);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package de.overview.wg.its.misp_authentificator.adapter;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.overview.wg.its.misp_authentificator.R;
|
||||
|
||||
public class ExtOrgAdapter extends RecyclerView.Adapter<ExtOrgAdapter.ViewHolder> {
|
||||
|
||||
private String[] dataSet;
|
||||
|
||||
public ExtOrgAdapter(String[] dataSet) {
|
||||
this.dataSet = dataSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
||||
View extOrgView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.view_holder_ext_org, parent, false);
|
||||
|
||||
return new ViewHolder(extOrgView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
holder.orgTitle.setText(dataSet[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataSet.length;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public TextView orgTitle;
|
||||
|
||||
public ViewHolder(View v) {
|
||||
super(v);
|
||||
orgTitle = v.findViewById(R.id.ext_org_title);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package de.overview.wg.its.misp_authentificator.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.RequestQueue;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.JsonObjectRequest;
|
||||
import com.android.volley.toolbox.Volley;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import de.overview.wg.its.misp_authentificator.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Simple JSON based API to communicate with MISP-Instances
|
||||
*/
|
||||
public class MispRequest {
|
||||
|
||||
private static final String TAG = "MISP-TAG";
|
||||
private static MispRequest instance;
|
||||
|
||||
private RequestQueue requestQueue;
|
||||
private PreferenceManager preferenceManager;
|
||||
|
||||
private String serverUrl, apiKey;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context for Volley and PreferenceManager
|
||||
*/
|
||||
private MispRequest(Context context) {
|
||||
requestQueue = Volley.newRequestQueue(context);
|
||||
preferenceManager = PreferenceManager.Instance(context);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param orgId organisation ID on the MISP-Instance
|
||||
* @param callback returns a single Organisation-JSON
|
||||
*/
|
||||
public void OrganisationInformation(int orgId, final OrganisationInformationCallback callback) {
|
||||
|
||||
Response.Listener<JSONObject> listener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
try {
|
||||
callback.onResult(response.getJSONObject("Organisation"));
|
||||
return;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
callback.onResult(response);
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
callback.onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Request r = objectRequest(Request.Method.GET,
|
||||
serverUrl + "/organisations/view/"+orgId,
|
||||
null,
|
||||
listener,
|
||||
errorListener);
|
||||
|
||||
requestQueue.add(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Typically used to get the organisation linked with this user
|
||||
* @param callback return user associated with this API-Key
|
||||
*/
|
||||
public void myUserInformation(final UserInformationCallback callback) {
|
||||
|
||||
Response.Listener<JSONObject> listener = new Response.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
|
||||
try {
|
||||
callback.onResult(response.getJSONObject("User"));
|
||||
return;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
callback.onResult(response);
|
||||
}
|
||||
};
|
||||
|
||||
Response.ErrorListener errorListener = new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e(TAG, "onErrorResponse: " + error.toString());
|
||||
callback.onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
if(serverUrl.isEmpty() || apiKey.isEmpty()) {
|
||||
Log.e(TAG, "myUserInformation: server or api key is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
Request r = objectRequest(
|
||||
Request.Method.GET,
|
||||
serverUrl + "/users/view/me",
|
||||
null,
|
||||
listener,
|
||||
errorListener);
|
||||
|
||||
requestQueue.add(r);
|
||||
}
|
||||
|
||||
|
||||
private JsonObjectRequest objectRequest(int method,
|
||||
String url,
|
||||
@Nullable JSONObject body,
|
||||
Response.Listener<JSONObject> listener,
|
||||
Response.ErrorListener errorListener){
|
||||
|
||||
return new JsonObjectRequest(method, url, body, listener, errorListener) {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHeaders() {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
params.put("Authorization", apiKey);
|
||||
params.put("Accept", "application/json");
|
||||
params.put("Content-Type", "application/json; utf-8");
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void setServerCredentials(String serverUrl, String apiKey) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
|
||||
public static MispRequest Instance(Context context) {
|
||||
if(instance == null) {
|
||||
instance = new MispRequest(context);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
public interface OrganisationInformationCallback {
|
||||
void onResult(JSONObject organisationInformation);
|
||||
void onError(VolleyError volleyError);
|
||||
}
|
||||
public interface UserInformationCallback {
|
||||
void onResult(JSONObject myOrganisationInformation);
|
||||
void onError(VolleyError volleyError);
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 262 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 437 B |
Before Width: | Height: | Size: 644 B |
Before Width: | Height: | Size: 736 B |
Before Width: | Height: | Size: 1.1 KiB |
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid
|
||||
android:color="#FFFFFF" />
|
||||
|
||||
<corners
|
||||
android:topLeftRadius="6dp"
|
||||
android:topRightRadius="6dp" />
|
||||
|
||||
</shape>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
|
||||
</vector>
|
|
@ -1,9 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z" />
|
||||
</vector>
|
|
@ -1,9 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M11.5,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zm6.5,-6v-5.5c0,-3.07 -2.13,-5.64 -5,-6.32V3.5c0,-0.83 -0.67,-1.5 -1.5,-1.5S10,2.67 10,3.5v0.68c-2.87,0.68 -5,3.25 -5,6.32V16l-2,2v1h17v-1l-2,-2z" />
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
|
||||
</vector>
|
|
@ -1,9 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01,-.25 1.97,-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0,-4.42,-3.58,-8,-8,-8zm0 14c-3.31 0,-6,-2.69,-6,-6 0,-1.01.25,-1.97.7,-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4,-4,-4,-4v3z" />
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M12,4L12,1L8,5l4,4L12,6c3.31,0 6,2.69 6,6 0,1.01 -0.25,1.97 -0.7,2.8l1.46,1.46C19.54,15.03 20,13.57 20,12c0,-4.42 -3.58,-8 -8,-8zM12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24,7.74C4.46,8.97 4,10.43 4,12c0,4.42 3.58,8 8,8v3l4,-4 -4,-4v3z"/>
|
||||
</vector>
|
|
@ -1,33 +1,81 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_sync_events"
|
||||
tools:context=".activity.SettingsActivity"
|
||||
android:background="@color/colorPrimary">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/settings.appbar"
|
||||
app:elevation="0dp"
|
||||
android:background="@color/colorPrimaryDark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:text="@string/sync_events"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_share_events"
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:background="@drawable/background_rounded_main"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:text="@string/share_events"/>
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/background_rounded_main"
|
||||
android:padding="16dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_receive_events"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:text="@string/receive_events"/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/orgRecyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textview_json_result"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<TextView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/empty_ext_org_dataset"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab_add"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:fabSize="normal"
|
||||
app:layout_anchor="@+id/constraintLayout"
|
||||
app:layout_anchorGravity="right|bottom"
|
||||
app:srcCompat="@drawable/ic_add_white" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:visibility="gone"
|
||||
android:id="@+id/fab_sync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="100dp"
|
||||
app:fabSize="mini"
|
||||
app:layout_anchor="@+id/fab_add"
|
||||
app:layout_anchorGravity="top|center_horizontal"
|
||||
app:srcCompat="@drawable/ic_sync_white" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/texture_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
|
||||
android:id="@+id/coordinator"
|
||||
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
tools:context=".activity.SettingsActivity"
|
||||
android:background="@color/colorPrimary"
|
||||
android:focusableInTouchMode="true">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/settings.appbar"
|
||||
app:elevation="0dp"
|
||||
android:background="@color/colorPrimaryDark"
|
||||
android:theme="@style/AppTheme.AppBarOverlay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:background="@drawable/background_rounded_main"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:background="@color/colorPrimary"
|
||||
android:id="@+id/input_layout_server_url"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_server_url"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:hint="@string/settings_server_url"
|
||||
android:inputType="textUri"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:background="@color/colorPrimary"
|
||||
android:id="@+id/input_layout_api_key"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="42dp"
|
||||
app:passwordToggleEnabled="true"
|
||||
app:passwordToggleTint="#FFF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/edit_api_key"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:hint="@string/settings_api_key"
|
||||
android:inputType="textPassword"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.constraint.ConstraintLayout
|
||||
android:padding="16dp"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:background="@drawable/background_rounded_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab_download_own_org_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:fabSize="normal"
|
||||
app:layout_anchor="@id/settings.appbar"
|
||||
app:layout_anchorGravity="bottom|right|end"
|
||||
app:srcCompat="@drawable/ic_cloud_download_white"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -1,32 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".SyncActivity">
|
||||
|
||||
<FrameLayout
|
||||
tools:context=".activity.SyncActivity"
|
||||
android:background="@color/colorPrimary">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:id="@+id/sync.appbar"
|
||||
app:elevation="0dp"
|
||||
android:background="@color/colorPrimaryDark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.5">
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/texture_view_sync_qr"
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:background="@drawable/background_rounded_main"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
<ImageView
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:paddingStart="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/ic_action_name"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/TextLabel">
|
||||
|
||||
</FrameLayout>
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:hint="@string/settings_server_url"
|
||||
android:inputType="textUri"/>
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_sync_qr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.5" />
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:paddingStart="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="42dp"
|
||||
app:passwordToggleEnabled="true"
|
||||
app:passwordToggleTint="#FFF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/TextLabel">
|
||||
|
||||
</LinearLayout>
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:hint="@string/settings_api_key"
|
||||
android:inputType="textPassword"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_sync" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:fabSize="normal"
|
||||
app:layout_anchor="@id/sync.appbar"
|
||||
app:layout_anchorGravity="bottom|right|end"
|
||||
app:srcCompat="@drawable/ic_cloud_download_white"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
|
@ -4,11 +4,9 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".GenerateQrActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_qr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context=".activity.SyncActivity"
|
||||
tools:showIn="@layout/activity_sync"
|
||||
android:background="@drawable/background_rounded_main">
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
|
@ -1,13 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:attr/dividerVertical">
|
||||
</View>
|
||||
</LinearLayout>
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ext_org_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:text="Title"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ext_org_sub_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/ext_org_title"
|
||||
android:text="http://192.168.178.200"
|
||||
android:textSize="15sp"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:title="Setttings"
|
||||
android:icon="@drawable/ic_settings"
|
||||
app:showAsAction="never" />
|
||||
android:id="@+id/menu_item_settings"
|
||||
android:title="Settings"
|
||||
android:icon="@drawable/ic_settings_white"
|
||||
app:showAsAction="always">
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:title="Delete Local Data"
|
||||
android:id="@+id/menu_item_deleteData">
|
||||
|
||||
</item>
|
||||
|
||||
</menu>
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#212121</color>
|
||||
<color name="colorPrimaryDark">#000000</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
<color name="colorPrimary">#424242</color>
|
||||
<color name="colorPrimaryDark">#212121</color>
|
||||
<color name="colorAccent">#42a5f5</color>
|
||||
<color name="color_text_foreground">#ffffff</color>
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
</resources>
|
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="api_key">HWnFznJAccL7CkxnrsE5pcRzkiUmGobwTF2ExR8i</string>
|
||||
</resources>
|
|
@ -1,9 +1,18 @@
|
|||
<resources>
|
||||
<string name="app_name">MispAuth</string>
|
||||
<string name="app_name">MISPauth</string>
|
||||
|
||||
//main
|
||||
<string name="sync_events">Synchronise Events</string>
|
||||
<string name="share_events">Share Events</string>
|
||||
<string name="receive_events">Receive Events</string>
|
||||
<string name="empty_ext_org_dataset">No External Organisations available</string>
|
||||
<string name="empty_local_org_dataset">No Local Information Available</string>
|
||||
|
||||
// Settings
|
||||
|
||||
<string name="settings_server_url">Server URL</string>
|
||||
<string name="settings_api_key">API Key</string>
|
||||
<string name="title_activity_sync">SyncActivity</string>
|
||||
|
||||
// Preferences
|
||||
|
||||
<string name="key_server_url">key_server_url</string>
|
||||
<string name="key_server_api_key">key_server_api_key</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="TextLabel" parent="TextAppearance.AppCompat">
|
||||
|
||||
<item name="android:textColorHint">@color/color_text_foreground</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="android:textColorPrimary">@color/color_text_foreground</item>
|
||||
|
||||
<item name="android:background">@color/colorPrimary</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="colorControlNormal">@color/color_text_foreground</item>
|
||||
<item name="colorControlActivated">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:title="MISP Server Configuration">
|
||||
<EditTextPreference
|
||||
android:defaultValue="https://example.foo"
|
||||
android:key="server_url"
|
||||
android:summary="https://example.foo"
|
||||
android:title="URL"/>
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="Company Name"
|
||||
android:key="company_name"
|
||||
android:summary="Company XY"
|
||||
android:title="Organization Name"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<!--<PreferenceCategory android:layout="@layout/preference_divider"/>-->
|
||||
|
||||
<PreferenceCategory android:title="About">
|
||||
<Preference
|
||||
android:key="pref_static_field_key"
|
||||
android:selectable="false"
|
||||
android:persistent="false"
|
||||
android:title="Version"
|
||||
android:summary="0.0"/>
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -1,17 +0,0 @@
|
|||
package de.korrelator.overview.mispauthv2;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package de.korrelator.overview.mispauth;
|
||||
package de.overview.wg.its.misp_authentificator;
|
||||
|
||||
import org.junit.Test;
|
||||
|
|
@ -7,7 +7,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
@ -19,8 +19,6 @@ allprojects {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#Fri Apr 20 12:42:32 CEST 2018
|
||||
#Tue May 22 17:01:34 CEST 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|