Commit 47dd78f9 authored by Roger Barton's avatar Roger Barton
Browse files

Merge branch 'master' into checkin

parents d9d785e7 240c8a86
...@@ -21,3 +21,5 @@ captures ...@@ -21,3 +21,5 @@ captures
\.idea/codeStyles/Project\.xml \.idea/codeStyles/Project\.xml
\.idea/ \.idea/
app/release/
image: registry.gitlab.com/showcheap/android-ci:react-native image: registry.gitlab.com/showcheap/android-ci:react-native
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script: before_script:
- echo $PLAYSTORE_KEY > app/google-play-key.json
- echo $SIGNING_KEYSTORE > app/keystore.properties
- sed -i 's/\s\+/\n/g' app/keystore.properties
# Note: Gitlab CI variables show newlines as a space, this will render the storePath as incorrect->Throws error that signingConfig was not found
- sdkmanager "platforms;android-27" - sdkmanager "platforms;android-27"
- sdkmanager "build-tools;27.0.3" - sdkmanager "build-tools;27.0.3"
- export GRADLE_USER_HOME=`pwd`/.gradle - export GRADLE_USER_HOME=`pwd`/.gradle
...@@ -15,9 +23,11 @@ cache: ...@@ -15,9 +23,11 @@ cache:
stages: stages:
- test - test
- build - build
- deploy
test: test:
stage: test stage: test
when: manual
script: script:
- ./gradlew check - ./gradlew check
...@@ -26,6 +36,13 @@ build: ...@@ -26,6 +36,13 @@ build:
script: script:
- ./gradlew assembleRelease - ./gradlew assembleRelease
artifacts: artifacts:
expire_in: 1 week
paths: paths:
- app/build/outputs/ - app/build/outputs/
deploy:
stage: deploy
when: manual
dependencies:
- build
script:
- ./gradlew publishRelease
[submodule "volley"] [submodule "volley"]
path = volley path = volley
url = https://github.com/google/volley.git url = https://github.com/amiv-eth/volley.git
amiv-android-app1 ### AMIV App - Android
This is the centralised amiv app for the android platform.
The idea is to have an app which contains all social things like events etc and to provide a platform for creating micro-apps, for example a barcode generator to use as a legi.
## To Start Developing
1. Install Android Studio, if android studio asks you to install extra stuff once opened, install it.
Gradle, the build system, will have to build first before you can edit properly.
2.
## To add your own micro-app
1. Install Android Studio and get set up. Not so easy as it sounds.
2. Create a java package under java/ch/amiv/android_app for your own java code
3. Name your resource files with a suitable prefix to keep the folders organised, especially the layout folder.
4. to be continued...
"$schema":"http://json-schema.org/draft-04/schema#"
"additionalProperties":false
"title":"Additional Fields"
"type":"object"
"properties":{
"SBB_Abo":
{
"type":"string"
"enum":["None", "GA", "Halbtax", "Gleis 7"]
}
"Food":
{
"type":"string"
"enum":["Omnivor", "Vegi", "Vegan", "Other"]
}
"Special Food Requirements":
{
"type":"string"
}
}
"required":["SBB_Abo", "Food"]
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
// Load keystore
def keystorePropertiesFile = file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android { android {
compileSdkVersion 27 compileSdkVersion 27
buildToolsVersion '27.0.3'
playAccountConfigs {
defaultAccountConfig {
jsonFile = file('google-play-key.json')
}
}
signingConfigs {
release {
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
}
}
defaultConfig { defaultConfig {
applicationId "ch.amiv.android_app" applicationId "ch.amiv.android_app"
minSdkVersion 23 minSdkVersion 23
...@@ -11,8 +34,10 @@ android { ...@@ -11,8 +34,10 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
buildTypes { buildTypes {
release { release {
signingConfig signingConfigs.release
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
...@@ -27,15 +52,22 @@ dependencies { ...@@ -27,15 +52,22 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:support-v4:27.1.1'
//implementation 'com.mcxiaoke.volley:library:1.0.19' //implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation project(path: ':volley') implementation project(path: ':volley')
implementation 'com.google.zxing:core:3.2.1' implementation 'com.google.zxing:core:3.2.1'
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar' implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
implementation 'com.google.android.gms:play-services-vision:15.0.2' implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.google.code.gson:gson:2.8.2'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
} }
play {
track = 'production'
uploadImages = true
errorOnSizeLimit = true
}
\ No newline at end of file
storeFile=testkeystore.jks
storePassword=000000
keyAlias=release
keyPassword=000000
\ No newline at end of file
...@@ -10,111 +10,143 @@ ...@@ -10,111 +10,143 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application <application
android:name=".core.MyApplication"
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:name=".core.MyApplication"
android:theme="@style/AppThemeLight"> android:theme="@style/AppThemeLight">
<activity <activity
android:name=".core.SettingsActivity" android:name=".core.SplashActivity"
android:label="" android:theme="@style/SplashTheme"
android:configChanges="layoutDirection|locale"
android:parentActivityName=".core.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ch.amiv.android_app.core.MainActivity" />
</activity>
<activity
android:name=".core.MainActivity"
android:configChanges="keyboardHidden|orientation|layoutDirection|screenSize|locale"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppThemeLight" android:noHistory="true">
android:windowSoftInputMode="adjustNothing">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity>
<activity
android:name=".core.MainActivity"
android:configChanges="keyboardHidden|orientation|layoutDirection|screenSize|locale"
android:theme="@style/AppThemeLight"
android:windowSoftInputMode="adjustNothing">
</activity> </activity>
<activity <activity
android:name=".core.LoginActivity" android:name=".core.LoginActivity"
android:configChanges="keyboardHidden|orientation|layoutDirection|screenSize|locale" android:configChanges="keyboardHidden|orientation|layoutDirection|screenSize|locale"
android:label="">
<!--android:windowSoftInputMode="stateVisible" use this to make the keyboard show when the activity is started-->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ch.amiv.android_app.core.MainActivity" />
</activity>
<activity
android:name=".core.IntroActivity"
android:screenOrientation="portrait"
android:configChanges="locale" />
<activity
android:name=".core.SettingsActivity"
android:configChanges="layoutDirection|locale"
android:label="" android:label=""
android:windowSoftInputMode="stateVisible"> android:parentActivityName=".core.MainActivity">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="ch.amiv.android_app.core.MainActivity" /> android:value="ch.amiv.android_app.core.MainActivity" />
</activity> </activity>
<activity <activity
android:name=".core.EventDetailActivity" android:name=".events.EventDetailActivity"
android:configChanges="orientation|layoutDirection|locale" android:configChanges="orientation|layoutDirection|locale"
android:theme="@style/AppThemeLight"> android:theme="@style/AppThemeLight">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="ch.amiv.android_app.core.MainActivity" /> android:value="ch.amiv.android_app.core.MainActivity" />
</activity> </activity>
<activity android:name=".checkin.BarcodeIdActivity"
android:screenOrientation="portrait"
android:configChanges="layoutDirection|locale"
android:parentActivityName=".core.MainActivity">
<activity
android:name=".jobs.JobDetailActivity"
android:configChanges="orientation|layoutDirection|locale"
android:theme="@style/AppThemeLight">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="ch.amiv.android_app.core.MainActivity" />
</activity> </activity>
<activity
android:name=".checkin.BarcodeIdActivity"
android:configChanges="layoutDirection|locale"
android:parentActivityName=".core.MainActivity"
android:screenOrientation="portrait" />
<!-- Checkin --> <!-- Checkin -->
<activity <activity
android:name=".checkin.MainActivity" android:name=".checkin.MainActivity"
android:label="@string/app_name_checkin"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:label="@string/app_name" android:theme="@style/AmivTheme" />
android:theme="@style/CheckinTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".checkin.ScanActivity" <activity
android:name=".checkin.ScanActivity"
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" />
</activity> </activity>
<activity android:name=".checkin.SettingsActivity" <activity
android:name=".checkin.SettingsActivity"
android:label="@string/app_name_checkin"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:label="@string/app_name" android:theme="@style/AmivTheme">
android:theme="@style/CheckinTheme">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.MainActivity" /> android:value=".checkin.MainActivity" />
</activity> </activity>
<activity android:name=".checkin.MemberListActivity" <activity
android:theme="@style/CheckinTheme" android:name=".checkin.MemberListActivity"
android:label="@string/app_name"> android:label="@string/app_name_checkin"
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>
<meta-data android:name="android.app.searchable"
android:resource="@xml/checkin_searchable"/> <meta-data
android:name="android.app.searchable"
android:resource="@xml/checkin_searchable" />
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.ScanActivity" /> android:value=".checkin.ScanActivity" />
</activity> </activity>
<activity android:name=".checkin.SearchMembersActivity" <activity
android:theme="@style/CheckinTheme" android:name=".checkin.SearchMembersActivity"
android:label="@string/app_name"> android:label="@string/app_name_checkin"
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" />
</activity> </activity>
</application>
<!-- Demo -->
<activity
android:name=".demo.MainActivity"
android:configChanges="layoutDirection|locale"
android:parentActivityName=".core.MainActivity"
android:screenOrientation="portrait" />
</application>
</manifest> </manifest>
\ No newline at end of file
package ch.amiv.android_app.checkin; package ch.amiv.android_app.checkin;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.content.res.ResourcesCompat; import android.support.v4.content.res.ResourcesCompat;
...@@ -8,6 +9,10 @@ import android.support.v7.app.AppCompatActivity; ...@@ -8,6 +9,10 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView; import android.widget.ImageView;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
...@@ -17,7 +22,6 @@ import com.google.zxing.common.BitMatrix; ...@@ -17,7 +22,6 @@ import com.google.zxing.common.BitMatrix;
import com.journeyapps.barcodescanner.BarcodeEncoder; import com.journeyapps.barcodescanner.BarcodeEncoder;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.file.attribute.UserDefinedFileAttributeView;
import ch.amiv.android_app.R; import ch.amiv.android_app.R;
import ch.amiv.android_app.core.UserInfo; import ch.amiv.android_app.core.UserInfo;
...@@ -48,23 +52,43 @@ public class BarcodeIdActivity extends AppCompatActivity { ...@@ -48,23 +52,43 @@ public class BarcodeIdActivity extends AppCompatActivity {
} }
}); });
//Setup swipe down to refresh InitSwipeRefreshUI();
}
//Setup swipe down to refresh, adds the amiv logo and rotate animation
private void InitSwipeRefreshUI()
{
swipeRefreshLayout = findViewById(R.id.swipeRefresh); swipeRefreshLayout = findViewById(R.id.swipeRefresh);
swipeRefreshLayout.setRefreshing(true); //swipeRefreshLayout.setRefreshing(true);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { //This sets what function is called when we swipe down to refresh swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { //This sets what function is called when we swipe down to refresh
@Override @Override
public void onRefresh() { public void onRefresh() {
GenerateBarcode(); GenerateBarcode();
try {
Field f = swipeRefreshLayout.getClass().getDeclaredField("mCircleView");
f.setAccessible(true);
ImageView img = (ImageView)f.get(swipeRefreshLayout);
RotateAnimation rotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setRepeatMode(Animation.INFINITE);
rotate.setDuration(1000);
rotate.setInterpolator(new LinearInterpolator());
img.startAnimation(rotate);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
} }
}); });
//Change the image on the swipe to refresh icon. Unfortunately have not found a way to make the icon rotate, may have to create overriden class
try { try {
Field f = swipeRefreshLayout.getClass().getDeclaredField("mCircleView"); Field f = swipeRefreshLayout.getClass().getDeclaredField("mCircleView");
f.setAccessible(true); f.setAccessible(true);
ImageView img = (ImageView)f.get(swipeRefreshLayout); ImageView img = (ImageView)f.get(swipeRefreshLayout);
img.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_amiv_logo_icon_scaled, null)); img.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_amiv_logo_icon_scaled, null));
swipeRefreshLayout.setColorSchemeResources(R.color.refresh_progress_1, R.color.refresh_progress_2, R.color.refresh_progress_3);
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
......
...@@ -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)
......
...@@ -25,6 +25,8 @@ import android.widget.TextView; ...@@ -25,6 +25,8 @@ import android.widget.TextView;
import ch.amiv.android_app.R; import ch.amiv.android_app.R;
import ch.amiv.android_app.core.Settings;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
public static String CurrentPin; public static String CurrentPin;
private boolean mWaitingOnServer = false; private boolean mWaitingOnServer = false;
...@@ -32,8 +34,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -32,8 +34,6 @@ public class MainActivity extends AppCompatActivity {
private EditText mPinField; private EditText mPinField;
private TextView mInvalidPinLabel; private TextView mInvalidPinLabel;
public static Vibrator vibrator;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -47,15 +47,13 @@ public class MainActivity extends AppCompatActivity { ...@@ -47,15 +47,13 @@ public class MainActivity extends AppCompatActivity {
public void onPause() public void onPause()
{ {
super.onPause(); super.onPause();
if(vibrator != null) Settings.CancelVibrate();
vibrator.cancel();
} }
private void InitialiseUI() private void InitialiseUI()
{ {
mPinField = findViewById(R.id.PinField); mPinField = findViewById(R.id.PinField);
mInvalidPinLabel = findViewById(R.id.InvalidPinLabel); mInvalidPinLabel = findViewById(R.id.InvalidPinLabel);
vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mPinField.setOnKeyListener(new View.OnKeyListener() { mPinField.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View view, int keyCode, KeyEvent keyevent) { public boolean onKey(View view, int keyCode, KeyEvent keyevent) {
...@@ -67,7 +65,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -67,7 +65,7 @@ public class MainActivity extends AppCompatActivity {