Commit 240c8a86 authored by Roger Barton's avatar Roger Barton
Browse files

Cleaned up themes, string formatting

parent 2f4a7261
Pipeline #5888 passed with stages
in 3 minutes and 12 seconds
...@@ -94,13 +94,13 @@ ...@@ -94,13 +94,13 @@
android:name=".checkin.MainActivity" android:name=".checkin.MainActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/CheckinTheme" /> android:theme="@style/AmivTheme" />
<activity <activity
android:name=".checkin.ScanActivity" android:name=".checkin.ScanActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/CheckinTheme"> android:theme="@style/AmivTheme">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.MainActivity" /> android:value=".checkin.MainActivity" />
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
android:name=".checkin.SettingsActivity" android:name=".checkin.SettingsActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/CheckinTheme"> android:theme="@style/AmivTheme">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.MainActivity" /> android:value=".checkin.MainActivity" />
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
<activity <activity
android:name=".checkin.MemberListActivity" android:name=".checkin.MemberListActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
android:theme="@style/CheckinTheme"> android:theme="@style/AmivTheme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.SEARCH" />
</intent-filter> </intent-filter>
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
<activity <activity
android:name=".checkin.SearchMembersActivity" android:name=".checkin.SearchMembersActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
android:theme="@style/CheckinTheme"> android:theme="@style/AmivTheme">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.MemberListActivity" /> android:value=".checkin.MemberListActivity" />
......
...@@ -38,7 +38,7 @@ public class CustomListAdapter extends ArrayAdapter<Member> { ...@@ -38,7 +38,7 @@ public class CustomListAdapter extends ArrayAdapter<Member> {
Member m = members.get(position); Member m = members.get(position);
nameField.setText(m.firstname + " " + m.lastname); nameField.setText(m.firstname + " " + m.lastname);
infoField.setText(m.legi); infoField.setText(m.GetLegiFormatted());
checkinField.setText((m.checkedIn ? "In" : "Out")); checkinField.setText((m.checkedIn ? "In" : "Out"));
if(EventDatabase.instance != null && EventDatabase.instance.eventData.eventType == EventData.EventType.GV && m.membership.length() > 1) if(EventDatabase.instance != null && EventDatabase.instance.eventData.eventType == EventData.EventType.GV && m.membership.length() > 1)
......
...@@ -14,6 +14,7 @@ public class Member { ...@@ -14,6 +14,7 @@ public class Member {
public String firstname; public String firstname;
public String lastname; public String lastname;
public String legi; public String legi;
private String formattedLegi;
public String membership; //as in membership type: ordinary extraordinary honorary public String membership; //as in membership type: ordinary extraordinary honorary
public String nethz; public String nethz;
public String checkinCount; //how often the person has been checked in public String checkinCount; //how often the person has been checked in
...@@ -46,4 +47,28 @@ public class Member { ...@@ -46,4 +47,28 @@ public class Member {
nethz = _nethz; nethz = _nethz;
checkinCount= _checkinCount; checkinCount= _checkinCount;
} }
private static final char legiFormatSeperator = '-';
private static final char legiStandardLength = 8;
/**
* @return Legi formatted for reading
*/
public String GetLegiFormatted (){
if(!formattedLegi.isEmpty()) //cache formatted legi for faster access, e.g. when searching through list
return formattedLegi;
if(legi == null || legi.isEmpty())
formattedLegi = "-";
else if(legi.length() != legiStandardLength)
formattedLegi = legi;
else {
StringBuilder s = new StringBuilder();
s.append(legi);
s.insert(5, legiFormatSeperator);
s.insert(2, legiFormatSeperator);
formattedLegi = s.toString();
}
return formattedLegi;
}
} }
...@@ -166,10 +166,7 @@ public class MemberListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol ...@@ -166,10 +166,7 @@ public class MemberListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
else else
memberHolder.checkinField.setText(""); memberHolder.checkinField.setText("");
if(m.legi == null) memberHolder.infoField.setText(m.GetLegiFormatted());
memberHolder.infoField.setText("-");
else
memberHolder.infoField.setText(m.legi);
if(EventDatabase.instance != null && EventDatabase.instance.eventData.eventType == EventData.EventType.GV && m.membership.length() > 1) if(EventDatabase.instance != null && EventDatabase.instance.eventData.eventType == EventData.EventType.GV && m.membership.length() > 1)
memberHolder.membershipField.setText(m.membership.substring(0,1).toUpperCase() + m.membership.substring(1)); memberHolder.membershipField.setText(m.membership.substring(0,1).toUpperCase() + m.membership.substring(1));
......
...@@ -102,12 +102,9 @@ public class SearchMembersListAdapter extends RecyclerView.Adapter<RecyclerView. ...@@ -102,12 +102,9 @@ public class SearchMembersListAdapter extends RecyclerView.Adapter<RecyclerView.
else else
memberHolder.checkinField.setText(""); memberHolder.checkinField.setText("");
if(m.legi == null) memberHolder.infoField.setText(m.GetLegiFormatted());
memberHolder.infoField.setText("-");
else
memberHolder.infoField.setText(m.legi);
if(EventDatabase.instance != null && EventDatabase.instance.eventData.eventType == EventData.EventType.GV && m.membership.length() > 1) if(EventDatabase.instance.eventData.eventType == EventData.EventType.GV && m.membership.length() > 1)
memberHolder.membershipField.setText(m.membership.substring(0,1).toUpperCase() + m.membership.substring(1)); memberHolder.membershipField.setText(m.membership.substring(0,1).toUpperCase() + m.membership.substring(1));
else else
memberHolder.membershipField.setText(""); memberHolder.membershipField.setText("");
......
...@@ -80,6 +80,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -80,6 +80,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
instance = this; instance = this;
setContentView(R.layout.core_activity_main); setContentView(R.layout.core_activity_main);
/*
//Use this to set a custom taskDescription in the app overview, ie when switching apps. Can set the icon, label and color of the bar
Resources r = getResources();
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(r.getString(R.string.app_name),
BitmapFactory.decodeResource(getResources(), R.drawable.ic_amiv_logo_icon_white),
r.getColor(R.color.white));
this.setTaskDescription(taskDescription);*/
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
...@@ -311,6 +319,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -311,6 +319,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
else else
StartLoginActivity(); StartLoginActivity();
} }
else if (id == R.id.nav_settings)
StartSettingsActivity();
//Note:microapp clicking is handled in MicroApp //Note:microapp clicking is handled in MicroApp
DrawerLayout drawer = findViewById(R.id.drawer_layout); DrawerLayout drawer = findViewById(R.id.drawer_layout);
......
...@@ -29,13 +29,13 @@ public class Settings { ...@@ -29,13 +29,13 @@ public class Settings {
//Keys are always two values, (Key for shared prefs, Default value) //Keys are always two values, (Key for shared prefs, Default value)
//For boolean values true=1, false=0 (or anything else) //For boolean values true=1, false=0 (or anything else)
public static final String[] apiUrlPrefKey = {"ch.amiv.android_app.serverurl", "https://api-dev.amiv.ethz.ch"}; public static final String[] apiUrlPrefKey = {"ch.amiv.android_app.server_url", "https://api-dev.amiv.ethz.ch"};
public static final String[] apiTokenKey = {"ch.amiv.android_app.apitoken", ""}; public static final String[] apiTokenKey = {"ch.amiv.android_app.api_token", ""};
public static final String[] introDoneKey = {"ch.amiv.android_app.introdone", "0"}; public static final String[] introDoneKey = {"ch.amiv.android_app.intro_done", "0"};
public static final String[] foodPrefKey = {"ch.amiv.android_app.foodpref", ""}; public static final String[] foodPrefKey = {"ch.amiv.android_app.food_pref", ""};
public static final String[] specialFoodPrefKey = {"ch.amiv.android_app.specialfoodpref", ""}; public static final String[] specialFoodPrefKey = {"ch.amiv.android_app.special_food_pref", ""};
public static final String[] sbbPrefKey = {"ch.amiv.android_app.sbbabo", ""}; public static final String[] sbbPrefKey = {"ch.amiv.android_app.sbb_abo", ""};
//region ---SharedPrefs--- //region ---SharedPrefs---
/** /**
......
...@@ -18,7 +18,6 @@ public class SplashActivity extends AppCompatActivity { ...@@ -18,7 +18,6 @@ public class SplashActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
//DEBUG to access intro //DEBUG to access intro
//if(BuildConfig.DEBUG) //if(BuildConfig.DEBUG)
// Settings.ClearSharedPrefs(getApplicationContext()); // Settings.ClearSharedPrefs(getApplicationContext());
......
...@@ -15,6 +15,7 @@ import java.util.Locale; ...@@ -15,6 +15,7 @@ import java.util.Locale;
import ch.amiv.android_app.R; import ch.amiv.android_app.R;
import ch.amiv.android_app.core.Request; import ch.amiv.android_app.core.Request;
import ch.amiv.android_app.util.Util;
import static ch.amiv.android_app.util.Util.BuildFileUrl; import static ch.amiv.android_app.util.Util.BuildFileUrl;
...@@ -82,8 +83,8 @@ public class EventInfo implements Serializable{ ...@@ -82,8 +83,8 @@ public class EventInfo implements Serializable{
_etag = json.optString("_etag"); _etag = json.optString("_etag");
title_en = json.optString("title_en"); title_en = json.optString("title_en");
title_de = json.optString("title_de"); title_de = json.optString("title_de");
description_en = json.optString("description_en"); description_en = Util.ApplyStringFormatting(json.optString("description_en"));
description_de = json.optString("description_de"); description_de = Util.ApplyStringFormatting(json.optString("description_de"));
catchphrase_en = json.optString("catchphrase_en"); catchphrase_en = json.optString("catchphrase_en");
catchphrase_de = json.optString("catchphrase_de"); catchphrase_de = json.optString("catchphrase_de");
location = json.optString("location"); location = json.optString("location");
......
...@@ -8,6 +8,7 @@ import java.util.Date; ...@@ -8,6 +8,7 @@ import java.util.Date;
import java.util.Locale; import java.util.Locale;
import ch.amiv.android_app.core.Request; import ch.amiv.android_app.core.Request;
import ch.amiv.android_app.util.Util;
import static ch.amiv.android_app.util.Util.BuildFileUrl; import static ch.amiv.android_app.util.Util.BuildFileUrl;
...@@ -43,8 +44,8 @@ public class JobInfo { ...@@ -43,8 +44,8 @@ public class JobInfo {
_etag = json.optString("_etag"); _etag = json.optString("_etag");
title_en = json.optString("title_en"); title_en = json.optString("title_en");
title_de = json.optString("title_de"); title_de = json.optString("title_de");
description_en = json.optString("description_en"); description_en = Util.ApplyStringFormatting(json.optString("description_en"));
description_de = json.optString("description_de"); description_de = Util.ApplyStringFormatting(json.optString("description_de"));
company = json.optString("company"); company = json.optString("company");
show_website = json.optBoolean("show_website", false); show_website = json.optBoolean("show_website", false);
......
...@@ -24,4 +24,13 @@ public final class Util { ...@@ -24,4 +24,13 @@ public final class Util {
if(inputMethodManager != null && activity.getCurrentFocus() != null) if(inputMethodManager != null && activity.getCurrentFocus() != null)
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0); inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
} }
/**
* Will convert raw text to formatted text, e.g. converting \n to a new line
* @param source
* @return
*/
public static String ApplyStringFormatting(String source){
return source.replaceAll("\\\\n", "\n");
}
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/windowBackground" android:background="?android:attr/windowBackground"
android:theme="@style/AmivTheme"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
......
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout <android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh" android:id="@+id/swipeRefresh"
android:layout_height="match_parent" android:layout_width="match_parent"
android:layout_width="match_parent"> android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</style> </style>
<style name="AppThemeLight" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AppThemeLight" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/primary</item> <item name="colorPrimary">@color/white</item><!-- Set to white due to app taskDescription, ie the bar in the app overview, when switching apps-->
<item name="colorPrimaryDark">@color/secondary</item> <item name="colorPrimaryDark">@color/secondary</item>
<item name="colorAccent">@color/accent</item> <item name="colorAccent">@color/accent</item>
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
...@@ -16,29 +16,16 @@ ...@@ -16,29 +16,16 @@
<item name="android:textViewStyle">@style/TextViewStyle</item> <item name="android:textViewStyle">@style/TextViewStyle</item>
<item name="android:titleTextStyle">@style/TextViewStyle</item> <item name="android:titleTextStyle">@style/TextViewStyle</item>
<item name="android:textColorPrimary">@color/text_color_primary</item> <item name="android:textColorPrimary">@color/text_color_primary</item>
<item name="android:statusBarColor">@color/secondary</item>
</style> </style>
<style name="AppThemeDark" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/secondary</item>
<item name="colorPrimaryDark">@color/primary</item>
<item name="colorAccent">@color/accent</item>
<item name="android:colorBackground">@color/backgroundDark</item>
<item name="android:colorForeground">@android:color/background_light</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="AppThemeLight.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppThemeLight.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item> <item name="spinBars">true</item>
<item name="color">@android:color/white</item> <item name="color">@android:color/white</item>
</style> </style>
<!-- Theme using standard amiv colors, different to the default theme AppThemeLight -->
<style name="CheckinTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <style name="AmivTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/primary</item> <item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/secondary</item> <item name="colorPrimaryDark">@color/secondary</item>
<item name="colorAccent">@color/accent</item> <item name="colorAccent">@color/accent</item>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment