extracted string resources

change material preference switch to display current state as subtitle
pull/5/head
Felix Prahl-Kamps 2019-07-07 15:51:52 +02:00
parent 6dcadd2dd3
commit 037328ff26
14 changed files with 164 additions and 82 deletions

View File

@ -248,10 +248,10 @@ public class UploadInfoActivity extends AppCompatActivity {
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Settings";
return getString(R.string.settings);
case 1:
return "Credentials";
return getString(R.string.credentials);
default:
return "N/A";

View File

@ -5,6 +5,7 @@ import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
@ -27,14 +28,15 @@ public class MaterialPreferenceSwitch extends ConstraintLayout {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceSwitch);
String title = a.getString(R.styleable.MaterialPreferenceSwitch_title);
String subTitle = a.getString(R.styleable.MaterialPreferenceSwitch_subtitle);
final String onText = a.getString(R.styleable.MaterialPreferenceSwitch_onText);
final String offText = a.getString(R.styleable.MaterialPreferenceSwitch_offText);
a.recycle();
titleView = view.findViewById(R.id.material_preference_title);
titleView.setText(title);
subTitleView = view.findViewById(R.id.material_preference_subtitle);
subTitleView.setText(subTitle);
subTitleView.setText(offText);
switchView = view.findViewById(R.id.material_preference_switch);
@ -46,6 +48,17 @@ public class MaterialPreferenceSwitch extends ConstraintLayout {
}
}
});
switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
subTitleView.setText(onText);
} else {
subTitleView.setText(offText);
}
}
});
}
public void setEnabled(boolean enabled) {

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="300"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />
</set>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="-100%p" android:duration="300"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.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:id="@+id/rootLayout"
@ -11,55 +12,50 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
<LinearLayout
android:id="@+id/qrFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/rect_rounded"
android:backgroundTint="#99FFFFFF"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="8dp"
tools:layout_height="256dp"
tools:layout_width="256dp">
<LinearLayout
<ImageView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/qr_code" />
<TextView
android:id="@+id/qrInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_info_outline"
android:drawablePadding="8dp"
android:drawableTint="@color/status_amber"
android:gravity="center_vertical"
android:orientation="vertical">
android:padding="8dp"
android:text="@string/activity_exchange_scan_partner_qr_hint"
android:textColor="@color/black" />
<ImageView
android:id="@+id/qrCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/qrInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_info_outline"
android:drawablePadding="8dp"
android:drawableTint="@color/status_amber"
android:gravity="center_vertical"
android:padding="8dp"
android:text="Scan your partners QR code"
android:textColor="@color/black" />
<TextView
android:id="@+id/qrInfoStatic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_info_outline"
android:drawablePadding="8dp"
android:drawableTint="@color/colorIconDark"
android:gravity="center_vertical"
android:lines="2"
android:padding="8dp"
android:text="Continue if your partner also scanned this QR code"
android:textColor="@color/black" />
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/qrInfoStatic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_info_outline"
android:drawablePadding="8dp"
android:drawableTint="@color/colorIconDark"
android:gravity="center_vertical"
android:lines="2"
android:padding="8dp"
android:text="@string/activity_exchange_continue_if_scanned"
android:textColor="@color/black" />
</LinearLayout>
<LinearLayout
android:id="@+id/bottom"
@ -78,7 +74,8 @@
android:padding="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_back" />
app:srcCompat="@drawable/ic_arrow_back"
android:contentDescription="@string/button_prev" />
<View
android:layout_width="0dp"
@ -93,7 +90,8 @@
android:padding="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_forward" />
app:srcCompat="@drawable/ic_arrow_forward"
android:contentDescription="@string/button_continue" />
</LinearLayout>

View File

@ -2,11 +2,9 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.LoginActivity"
android:focusableInTouchMode="true"
android:animateLayoutChanges="true">
@ -29,15 +27,13 @@
app:layout_constraintTop_toTopOf="parent">
<TextView
android:text="MISPbump"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"/>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.textfield.TextInputLayout
@ -51,7 +47,6 @@
android:gravity="center"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.textfield.TextInputEditText
@ -72,7 +67,6 @@
android:layout_marginEnd="16dp"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline"
app:passwordToggleEnabled="true">

View File

@ -26,10 +26,11 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/circle"
android:id="@+id/accountImage"
android:layout_width="112dp"
android:layout_height="112dp"
android:layout_above="@id/orgName"
@ -39,7 +40,8 @@
android:tint="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar" />
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/orgName"
@ -48,7 +50,7 @@
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
android:text="Organisation A"
tools:text="Organisation A"
android:textAlignment="center"
android:textColor="@color/white"
android:textSize="24sp"
@ -56,7 +58,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/circle" />
app:layout_constraintTop_toBottomOf="@+id/accountImage" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
@ -100,7 +102,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/uuid"
app:pref_icon="@drawable/ic_language"
app:title="Nationality"/>
app:title="@string/nationality"/>
<lu.circl.mispbump.customViews.MaterialPreferenceText
android:id="@+id/sector"
@ -111,7 +113,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nationality"
app:pref_icon="@drawable/ic_sector"
app:title="Sector"/>
app:title="@string/sector"/>
<lu.circl.mispbump.customViews.MaterialPreferenceText
android:id="@+id/description"
@ -122,7 +124,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sector"
app:pref_icon="@drawable/ic_description"
app:title="Description"/>
app:title="@string/description"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -26,7 +26,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:text="Upload"
android:text="@string/upload"
android:layout_gravity="center"/>
</androidx.appcompat.widget.Toolbar>
@ -48,7 +48,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:description="MISP instance available" />
app:description="@string/upload_action_available" />
<lu.circl.mispbump.customViews.UploadAction
android:id="@+id/orgAction"
@ -59,7 +59,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:description="Add organisation" />
app:description="@string/upload_action_add_org" />
<lu.circl.mispbump.customViews.UploadAction
android:id="@+id/userAction"
@ -70,7 +70,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:description="Add sync user" />
app:description="@string/upload_action_add_user" />
<lu.circl.mispbump.customViews.UploadAction
android:id="@+id/serverAction"
@ -81,7 +81,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:description="Add sync server" />
app:description="@string/upload_action_add_server" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.floatingactionbutton.FloatingActionButton

View File

@ -19,7 +19,7 @@
android:layout_marginTop="8dp"
android:background="@color/white"
app:subtitle="www.google.de"
app:title="Base URL"/>
app:title="@string/url"/>
<lu.circl.mispbump.customViews.MaterialPreferenceText
android:id="@+id/email"
@ -28,7 +28,7 @@
android:layout_marginTop="8dp"
android:background="@color/white"
app:subtitle="syncuser_orga@mispx.yz"
app:title="Email"/>
app:title="@string/email"/>
<lu.circl.mispbump.customViews.MaterialPasswordView
android:id="@+id/password"
@ -36,7 +36,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@color/white"
app:title="Password"
app:title="@string/password"
app:password="abc"/>
<lu.circl.mispbump.customViews.MaterialPasswordView
@ -45,7 +45,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:background="@color/white"
app:title="Authkey"
app:title="@string/authkey"
app:password="abc"/>
</LinearLayout>
</ScrollView>

View File

@ -18,7 +18,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="This Organisation will have the following rights on your MISP instance"
android:text="@string/fragment_upload_settings_title"
android:textAppearance="@style/TextAppearance.MaterialComponents.Overline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -33,8 +33,9 @@
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text"
app:subtitle="Server certificate must not be from a trusted CA (not recomended)"
app:title="Allow self signed certificates"/>
app:onText="@string/settings_self_signed_on"
app:offText="@string/settings_self_signed_off"
app:title="@string/settings_self_signed_title"/>
<lu.circl.mispbump.customViews.MaterialPreferenceSwitch
android:id="@+id/push_switch"
@ -43,8 +44,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/self_signed_switch"
app:subtitle="Allow the upload of events and their attributes"
app:title="Push"/>
app:onText="@string/settings_push_on"
app:offText="@string/settings_push_off"
app:title="@string/settings_push_title"/>
<lu.circl.mispbump.customViews.MaterialPreferenceSwitch
android:id="@+id/pull_switch"
@ -53,8 +55,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/push_switch"
app:subtitle="Allow the download of events and their attributes"
app:title="Pull"/>
app:onText="@string/settings_pull_on"
app:offText="@string/settings_pull_off"
app:title="@string/settings_pull_title"/>
<lu.circl.mispbump.customViews.MaterialPreferenceSwitch
android:id="@+id/cache_switch"
@ -63,8 +66,9 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/pull_switch"
app:subtitle="Allow the caching of events and their attributes"
app:title="Cache"/>
app:onText="@string/settings_cache_on"
app:offText="@string/settings_cache_off"
app:title="@string/settings_cache_title"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -42,7 +42,9 @@
app:layout_constraintEnd_toStartOf="@id/material_preference_switch"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/material_preference_title"
tools:text="Subtitle" />
tools:text="Subtitle"
android:inAnimation="@anim/push_up_in"
android:outAnimation="@anim/push_up_out"/>
<Switch
android:id="@+id/material_preference_switch"

View File

@ -1,14 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MispBump</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"><b>MISP Server URL</b>\nDie URL unter der Ihre MISP Instanz erreichbar ist.\n\n<b>MISP Automatisierungs Schlüssel</b>\nZu finden unter ...</string>
<string name="login_help_text"><b>MISP Server URL</b>\nDie URL unter der Ihre MISP Instanz erreichbar ist.\n\n<b>MISP Automatisierungs Schlüssel</b></string>
<string name="qr_code">QR code</string>
<string name="sync">Synchronisation</string>
<string name="no_syncs_hint">Sie haben noch keine MISP Instanzen verknüpft</string>
<string name="activity_exchange_scan_partner_qr_hint">Scannen den QR code ihres Partners</string>
<string name="activity_exchange_continue_if_scanned">Fahren sie fort, sobald dieser QR Code gescannt wurde</string>
<string name="button_continue">Weiter</string>
<string name="button_prev">Zurück</string>
<string name="nationality">Nationalität</string>
<string name="sector">Sektor</string>
<string name="description">Beschreibung</string>
<string name="settings">Einstellungen</string>
<string name="credentials">Zugangsdaten</string>
<string name="authkey">Authentifizierungsschlüssel</string>
<string name="password">Passwort</string>
<string name="fragment_upload_settings_title">Diese Organisation soll die folgenden Rechte erhalten</string>
<string name="settings_self_signed_title">Selbstsignierte Zertifikate erlauben</string>
<string name="settings_self_signed_on">Zertifikate von unbekannten CA\'s werden akzeptiert (nicht empfohlen)</string>
<string name="settings_self_signed_off">Nur Zertifikate von bekannten CA\'s werden akzeptiert</string>
<string name="settings_push_off">Ereignisse und deren Attribute können nicht hochgeladen werden</string>
<string name="settings_push_on">Ereignisse und deren Attribute können hochgeladen werden</string>
<string name="settings_pull_off">Ereignisse und deren Attribute können nicht heruntergeladen werden</string>
<string name="settings_pull_on">Ereignisse und deren Attribute können heruntergeladen werden</string>
<string name="settings_cache_off">Ereignisse und deren Attribute werden nicht zwischengespeichert</string>
<string name="settings_cache_on">Ereignisse und deren Attribute werden zwischengespeichert</string>
<string name="settings_cache_title">Zwischenspeichern</string>
<string name="settings_pull_title">Herunterladen</string>
<string name="settings_push_title">Hochladen</string>
<string name="upload">Hochladen</string>
<string name="upload_action_available">MISP Instanz erreichbar</string>
<string name="upload_action_add_org">Organisation hinzufügen</string>
<string name="upload_action_add_server">Server hinzufügen</string>
<string name="upload_action_add_user">Benutzer hinzufügen</string>
</resources>

View File

@ -12,7 +12,8 @@
<declare-styleable name="MaterialPreferenceSwitch">
<attr name="title"/>
<attr name="subtitle"/>
<attr name="onText" format="string"/>
<attr name="offText" format="string"/>
</declare-styleable>
<declare-styleable name="MaterialPasswordView">

View File

@ -1,5 +1,5 @@
<resources>
<string name="app_name">MispBump</string>
<string name="app_name" translatable="false">MISPbump</string>
<string name="login">Log in</string>
<string name="logout">Log out</string>
<string name="misp_server_url_hint" translatable="false">MISP Server URL</string>
@ -7,12 +7,42 @@
<string name="no_information">No Information</string>
<string name="save_automation_key_hint">Save Automation Key</string>
<string name="menu_login_help_label">Help</string>
<string name="login_help_text"><b>MISP Server URL</b>\nPublic MISP URL\n\n<b>MISP Automation key</b>\nZu finden unter ...</string>
<string name="login_help_text"><b>MISP Server URL</b>\nPublic MISP URL\n\n<b>MISP Automation key</b></string>
<string name="ok" translatable="false">Okay</string>
<string name="qr_code">QR code</string>
<string name="sync">Synchronization</string>
<string name="no_syncs_hint">You have not synced any MISP instances yet</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="activity_exchange_scan_partner_qr_hint">Scan your partners QR code</string>
<string name="activity_exchange_continue_if_scanned">Continue if your partner also scanned this QR code</string>
<string name="button_continue">next</string>
<string name="button_prev">previous</string>
<string name="nationality">Nationality</string>
<string name="sector">Sector</string>
<string name="description">Description</string>
<string name="settings">Settings</string>
<string name="credentials">Credentials</string>
<string name="password">Password</string>
<string name="authkey">Authkey</string>
<string name="url" translatable="false">URL</string>
<string name="email" translatable="false">Email</string>
<string name="fragment_upload_settings_title">This Organisation should have the following permissions</string>
<string name="settings_self_signed_title">Allow self signed certificates</string>
<string name="settings_self_signed_on">Server certificate can be from any CA (not recommended)</string>
<string name="settings_push_title">Push</string>
<string name="settings_push_off">Events and their attributes cannot be uploaded</string>
<string name="settings_pull_title">Pull</string>
<string name="settings_pull_off">Events and their attributes cannot be downloaded</string>
<string name="settings_cache_title">Cache</string>
<string name="settings_cache_off">Events and their attributes will not be cached</string>
<string name="settings_self_signed_off">Only certificates from trusted CA\'s are accepted</string>
<string name="settings_push_on">Events and their attributes can be uploaded</string>
<string name="settings_pull_on">Events and their attributes can be downloaded</string>
<string name="settings_cache_on">Events and their attributes will be cached</string>
<string name="upload">Upload</string>
<string name="upload_action_available">MISP instance available</string>
<string name="upload_action_add_org">Add organisation</string>
<string name="upload_action_add_user">Add sync user</string>
<string name="upload_action_add_server">Add sync server</string>
</resources>