add german locale

restructure project
pull/5/head
Felix Prahl-Kamps 2019-05-29 14:52:00 +02:00
parent becef4298f
commit c8c16dcb3c
15 changed files with 182 additions and 109 deletions

View File

@ -3,6 +3,41 @@
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/.." />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="10">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="9">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>

View File

@ -16,7 +16,7 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".StartUpActivity">
<activity android:name=".activities.StartUpActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -25,15 +25,15 @@
</activity>
<activity
android:name=".HomeActivity"
android:name=".activities.HomeActivity"
android:label="@string/home" />
<activity
android:name=".LoginActivity"
android:name=".activities.LoginActivity"
android:label="@string/login" />
<activity
android:name=".SyncActivity"
android:name=".activities.SyncActivity"
android:label="@string/app_name"
android:parentActivityName=".HomeActivity"/>
android:parentActivityName=".activities.HomeActivity"/>
</application>
</manifest>

View File

@ -1,4 +1,4 @@
package lu.circl.mispbump;
package lu.circl.mispbump.activities;
import android.content.DialogInterface;
import android.content.Intent;
@ -13,15 +13,13 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.restful_client.Organisation;
import lu.circl.mispbump.restful_client.User;
import lu.circl.mispbump.security.KeyStoreWrapper;
public class HomeActivity extends AppCompatActivity {
private static final String TAG = "HomeActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -72,7 +70,6 @@ public class HomeActivity extends AppCompatActivity {
private void populateViewsWithInfo() {
PreferenceManager preferenceManager = PreferenceManager.getInstance(this);
User user = preferenceManager.getUserInfo();
Organisation org = preferenceManager.getUserOrganisation();
TextView orgTitle = findViewById(R.id.home_org_name);

View File

@ -1,4 +1,4 @@
package lu.circl.mispbump;
package lu.circl.mispbump.activities;
import android.app.AlertDialog;
import android.content.DialogInterface;
@ -19,6 +19,8 @@ import android.widget.ProgressBar;
import java.util.Objects;
import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.DialogManager;
import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.restful_client.MispRestClient;
import lu.circl.mispbump.restful_client.Organisation;
@ -32,69 +34,6 @@ public class LoginActivity extends AppCompatActivity {
private ProgressBar progressBar;
private PreferenceManager preferenceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// populate Toolbar (Actionbar)
Toolbar myToolbar = findViewById(R.id.toolbar);
setSupportActionBar(myToolbar);
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(false);
}
constraintLayout = findViewById(R.id.login_root);
progressBar = findViewById(R.id.login_progressbar);
serverUrl = findViewById(R.id.login_server_url);
serverAutomationKey = findViewById(R.id.login_automation_key);
Button downloadInfoButton = findViewById(R.id.login_download_button);
downloadInfoButton.setOnClickListener(onClickDownload);
preferenceManager = PreferenceManager.getInstance(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_login, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_login_help:
showHelpDialog();
return true;
default:
// invoke superclass to handle unrecognized item (eg. homeAsUp)
return super.onOptionsItemSelected(item);
}
}
private void showHelpDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.app_name);
builder.setMessage("You need to have admin rights in order to create sync users and so on");
builder.setPositiveButton("Got it", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
private View.OnClickListener onClickDownload = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -107,12 +46,12 @@ public class LoginActivity extends AppCompatActivity {
serverUrl.setError(null);
serverAutomationKey.setError(null);
if(!isValidUrl(url)) {
if (!isValidUrl(url)) {
error = true;
serverUrl.setError("Invalid Server URL");
}
if(!isValidAutomationKey(authkey)) {
if (!isValidAutomationKey(authkey)) {
error = true;
serverAutomationKey.setError("Invalid automation key");
}
@ -165,6 +104,55 @@ public class LoginActivity extends AppCompatActivity {
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// populate Toolbar (Actionbar)
Toolbar myToolbar = findViewById(R.id.toolbar);
setSupportActionBar(myToolbar);
ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(false);
}
constraintLayout = findViewById(R.id.login_root);
progressBar = findViewById(R.id.login_progressbar);
serverUrl = findViewById(R.id.login_server_url);
serverAutomationKey = findViewById(R.id.login_automation_key);
Button downloadInfoButton = findViewById(R.id.login_download_button);
downloadInfoButton.setOnClickListener(onClickDownload);
preferenceManager = PreferenceManager.getInstance(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_login, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_login_help:
showHelpDialog();
return true;
default:
// invoke superclass to handle unrecognized item (eg. homeAsUp)
return super.onOptionsItemSelected(item);
}
}
private void showHelpDialog() {
DialogManager.loginHelpDialog(LoginActivity.this);
}
private boolean isValidUrl(String url) {
return url.startsWith("https://") || url.startsWith("http://");
}

View File

@ -1,8 +1,8 @@
package lu.circl.mispbump;
package lu.circl.mispbump.activities;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.restful_client.User;
@ -21,7 +21,7 @@ public class StartUpActivity extends AppCompatActivity {
startActivity(login);
}
// closes the activity thus prevents going back to this (empty) activity
// closes the activity to prevent going back to this (empty) activity
finish();
}

View File

@ -1,4 +1,4 @@
package lu.circl.mispbump;
package lu.circl.mispbump.activities;
import android.graphics.Bitmap;
import android.os.Bundle;
@ -20,11 +20,14 @@ import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.util.List;
import lu.circl.mispbump.R;
import lu.circl.mispbump.auxiliary.DialogManager;
import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.auxiliary.QrCodeGenerator;
import lu.circl.mispbump.auxiliary.RandomString;
import lu.circl.mispbump.cam.CameraFragment;
import lu.circl.mispbump.fragments.SyncOptionsFragment;
import lu.circl.mispbump.models.SyncInformation;
import lu.circl.mispbump.restful_client.MispRestClient;
import lu.circl.mispbump.restful_client.MispServer;
import lu.circl.mispbump.restful_client.Organisation;
@ -53,6 +56,14 @@ public class SyncActivity extends AppCompatActivity {
private FloatingActionButton continueButton;
private SyncState currentSyncState = SyncState.publicKeyExchange;
private enum SyncState {
publicKeyExchange,
dataExchange
}
/**
* Callback to any
*/
private View.OnClickListener onContinueClicked = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -85,6 +96,7 @@ public class SyncActivity extends AppCompatActivity {
}
}
};
/**
* Callback for the camera fragment.
* Delivers the content of a scanned QR code.
@ -98,6 +110,7 @@ public class SyncActivity extends AppCompatActivity {
case publicKeyExchange:
try {
final PublicKey pk = AESSecurity.publicKeyFromString(qrData);
DialogManager.publicKeyDialog(pk.toString(), SyncActivity.this,
new DialogManager.IDialogFeedback() {
@Override
@ -292,11 +305,6 @@ public class SyncActivity extends AppCompatActivity {
});
}
private enum SyncState {
publicKeyExchange,
dataExchange
}
// private View.OnClickListener onGetServers = new View.OnClickListener() {
// @Override
// public void onClick(View v) {

View File

@ -5,25 +5,20 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import lu.circl.mispbump.R;
/**
* Creates and show dialogs.
* Automatically takes care of using the UI Thread.
*/
public class DialogManager {
/**
* Interface to give feedback about the user choice in dialogs.
*/
public interface IDialogFeedback {
void positive();
void negative();
}
/**
* Dialog to display a received public key.
*
* @param publicKey the public key to display
* @param context needed to build and show the dialog
* @param callback {@link IDialogFeedback}
* @param context needed to build and show the dialog
* @param callback {@link IDialogFeedback}
*/
public static void publicKeyDialog(String publicKey, Context context, final IDialogFeedback callback) {
final AlertDialog.Builder adb = new AlertDialog.Builder(context);
@ -55,7 +50,8 @@ public class DialogManager {
/**
* Dialog to ask the user if his sync partner already scanned the displayed qr code.
* @param context needed to build and show the dialog
*
* @param context needed to build and show the dialog
* @param callback {@link IDialogFeedback}
*/
public static void confirmProceedDialog(Context context, final IDialogFeedback callback) {
@ -85,4 +81,39 @@ public class DialogManager {
}
});
}
/**
* Dialog to provide login information.
*
* @param context needed to build and show the dialog
*/
public static void loginHelpDialog(Context context) {
final AlertDialog.Builder adb = new AlertDialog.Builder(context);
adb.setTitle(R.string.app_name);
adb.setMessage(R.string.login_help_text);
adb.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
Activity act = (Activity) context;
act.runOnUiThread(new Runnable() {
@Override
public void run() {
adb.create().show();
}
});
}
/**
* Interface to give feedback about the user choice in dialogs.
*/
public interface IDialogFeedback {
void positive();
void negative();
}
}

View File

@ -1,6 +1,7 @@
package lu.circl.mispbump;
package lu.circl.mispbump.fragments;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
@ -8,6 +9,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import lu.circl.mispbump.R;
public class SyncOptionsFragment extends Fragment {
private Switch share, push, pull, cache;
@ -18,7 +21,7 @@ public class SyncOptionsFragment extends Fragment {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_sync_options, container, false);
share = v.findViewById(R.id.share_events_switch);

View File

@ -1,4 +1,4 @@
package lu.circl.mispbump;
package lu.circl.mispbump.models;
import lu.circl.mispbump.restful_client.Organisation;
import lu.circl.mispbump.restful_client.Server;
@ -14,7 +14,7 @@ public class SyncInformation {
public Organisation organisation;
public Server server;
SyncInformation(User user, Organisation organisation, Server server) {
public SyncInformation(User user, Organisation organisation, Server server) {
this.user = user;
this.organisation = organisation;
this.server = server;

View File

@ -5,7 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeActivity">
tools:context=".activities.HomeActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"

View File

@ -6,7 +6,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
tools:context=".activities.LoginActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"

View File

@ -4,6 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StartUpActivity">
tools:context=".activities.StartUpActivity">
</android.support.constraint.ConstraintLayout>

View File

@ -5,7 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SyncActivity">
tools:context=".activities.SyncActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MispBump</string>
<string name="download_misp_infos">MISP Informationen laden</string>
<string name="login">Anmelden</string>
<string name="logout">Abmelden</string>
<string name="menu_login_help_label">Hilfe</string>
<string name="misp_automation_hint">MISP Automatisierungs-Schlüssel</string>
<string name="no_information">Keine Informationen</string>
<string name="save_automation_key_hint">Automatisierungs-Schlüssel speichern</string>
<string name="login_help_text">Das ist der Anmelde Informations Text.</string>
</resources>

View File

@ -2,14 +2,13 @@
<string name="app_name">MispBump</string>
<string name="login">Log in</string>
<string name="logout">Log out</string>
<string name="misp_server_url_hint">Misp Server URL</string>
<string name="misp_server_url_hint" translatable="false">MISP Server URL</string>
<string name="misp_automation_hint">MISP Automation Key</string>
<string name="download_misp_infos">Download MISP Infos</string>
<string name="no_information">No Information</string>
<string name="save_automation_key_hint">Save Automation Key</string>
<string name="home">Home</string>
<string name="home" translatable="false">Home</string>
<string name="menu_login_help_label">Help</string>
// Sync options preferences
<string name="sync_option_share"><u>Share events</u>\nThis will generate a sync server on your instance</string>
<string name="login_help_text">This is the login info text.</string>
<string name="ok" translatable="false">Okay</string>
</resources>