Commit c7c602eb authored by Roger Barton's avatar Roger Barton
Browse files

Added splash screen, started app intro

Lots of small changes due to renaming colors
Improved Login activity, better UI spacing, ability to skip in intro
Improved language changing and tested, change language in settings then restart activty
Logout moved to user info
parent 0d5a8fdb
...@@ -20,36 +20,51 @@ ...@@ -20,36 +20,51 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:theme="@style/AppThemeLight"> android:theme="@style/AppThemeLight">
<activity <activity
android:name=".core.SettingsActivity" android:name=".core.SplashActivity"
android:configChanges="layoutDirection|locale" android:theme="@style/SplashTheme"
android:label=""
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>
<activity
android:name=".core.MainActivity"
android:configChanges="keyboardHidden|orientation|layoutDirection|screenSize|locale"
android:theme="@style/AppThemeLight"
android:windowSoftInputMode="adjustNothing">
</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=".events.EventDetailActivity" android:name=".events.EventDetailActivity"
android:configChanges="orientation|layoutDirection|locale" android:configChanges="orientation|layoutDirection|locale"
...@@ -58,6 +73,7 @@ ...@@ -58,6 +73,7 @@
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=".jobs.JobDetailActivity" android:name=".jobs.JobDetailActivity"
android:configChanges="orientation|layoutDirection|locale" android:configChanges="orientation|layoutDirection|locale"
...@@ -66,18 +82,20 @@ ...@@ -66,18 +82,20 @@
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=".checkin.BarcodeIdActivity" android:name=".checkin.BarcodeIdActivity"
android:configChanges="layoutDirection|locale" android:configChanges="layoutDirection|locale"
android:parentActivityName=".core.MainActivity" android:parentActivityName=".core.MainActivity"
android:screenOrientation="portrait"></activity> android:screenOrientation="portrait" />
<!-- Checkin --> <!-- Checkin -->
<activity <activity
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"></activity> android:theme="@style/CheckinTheme" />
<activity <activity
android:name=".checkin.ScanActivity" android:name=".checkin.ScanActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
...@@ -87,6 +105,7 @@ ...@@ -87,6 +105,7 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.MainActivity" /> android:value=".checkin.MainActivity" />
</activity> </activity>
<activity <activity
android:name=".checkin.SettingsActivity" android:name=".checkin.SettingsActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
...@@ -96,6 +115,7 @@ ...@@ -96,6 +115,7 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.MainActivity" /> android:value=".checkin.MainActivity" />
</activity> </activity>
<activity <activity
android:name=".checkin.MemberListActivity" android:name=".checkin.MemberListActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
...@@ -111,6 +131,7 @@ ...@@ -111,6 +131,7 @@
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".checkin.ScanActivity" /> android:value=".checkin.ScanActivity" />
</activity> </activity>
<activity <activity
android:name=".checkin.SearchMembersActivity" android:name=".checkin.SearchMembersActivity"
android:label="@string/app_name_checkin" android:label="@string/app_name_checkin"
...@@ -121,12 +142,11 @@ ...@@ -121,12 +142,11 @@
</activity> </activity>
<!-- Demo --> <!-- Demo -->
<activity android:name=".demo.MainActivity" <activity
android:name=".demo.MainActivity"
android:configChanges="layoutDirection|locale" android:configChanges="layoutDirection|locale"
android:parentActivityName=".core.MainActivity" android:parentActivityName=".core.MainActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait" />
</activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -329,7 +329,7 @@ public class ScanActivity extends AppCompatActivity { ...@@ -329,7 +329,7 @@ public class ScanActivity extends AppCompatActivity {
mTickImage.setVisibility(View.VISIBLE); mTickImage.setVisibility(View.VISIBLE);
mBGTint.setVisibility(View.VISIBLE); mBGTint.setVisibility(View.VISIBLE);
mTickImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow)); mTickImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow));
mTickImage.setColorFilter(getResources().getColor(R.color.colorValid)); mTickImage.setColorFilter(getResources().getColor(R.color.valid));
if(EventDatabase.instance.eventData.eventType == EventData.EventType.Counter) { if(EventDatabase.instance.eventData.eventType == EventData.EventType.Counter) {
mCheckinCountLabel.setVisibility(View.VISIBLE); mCheckinCountLabel.setVisibility(View.VISIBLE);
...@@ -342,13 +342,13 @@ public class ScanActivity extends AppCompatActivity { ...@@ -342,13 +342,13 @@ public class ScanActivity extends AppCompatActivity {
if(member.membership.equalsIgnoreCase("regular")) if(member.membership.equalsIgnoreCase("regular"))
{ {
mTickImage.setColorFilter(getResources().getColor(R.color.colorValid)); mTickImage.setColorFilter(getResources().getColor(R.color.valid));
mBGTint.setColorFilter(getResources().getColor(R.color.colorValid)); mBGTint.setColorFilter(getResources().getColor(R.color.valid));
} }
else else
{ {
mTickImage.setColorFilter(getResources().getColor(R.color.colorOrange)); mTickImage.setColorFilter(getResources().getColor(R.color.orange));
mBGTint.setColorFilter(getResources().getColor(R.color.colorOrange)); mBGTint.setColorFilter(getResources().getColor(R.color.orange));
} }
Settings.Vibrate(Settings.VibrateTime.NORMAL, getApplicationContext()); Settings.Vibrate(Settings.VibrateTime.NORMAL, getApplicationContext());
...@@ -369,20 +369,20 @@ public class ScanActivity extends AppCompatActivity { ...@@ -369,20 +369,20 @@ public class ScanActivity extends AppCompatActivity {
mResponseLabel.setVisibility(View.VISIBLE); mResponseLabel.setVisibility(View.VISIBLE);
mResponseLabel.setText(responseText); mResponseLabel.setText(responseText);
mTickImage.setVisibility(View.VISIBLE); mTickImage.setVisibility(View.VISIBLE);
mTickImage.setColorFilter(getResources().getColor(R.color.colorValid)); mTickImage.setColorFilter(getResources().getColor(R.color.valid));
mTickImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow)); mTickImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow));
mBGTint.setVisibility(View.VISIBLE); mBGTint.setVisibility(View.VISIBLE);
if(responseText.substring(0, 12).equalsIgnoreCase("regular")) if(responseText.substring(0, 12).equalsIgnoreCase("regular"))
{ {
mTickImage.setColorFilter(getResources().getColor(R.color.colorValid)); mTickImage.setColorFilter(getResources().getColor(R.color.valid));
mBGTint.setColorFilter(getResources().getColor(R.color.colorValid)); mBGTint.setColorFilter(getResources().getColor(R.color.valid));
} }
else else
{ {
mTickImage.setColorFilter(getResources().getColor(R.color.colorOrange)); mTickImage.setColorFilter(getResources().getColor(R.color.orange));
mBGTint.setColorFilter(getResources().getColor(R.color.colorOrange)); mBGTint.setColorFilter(getResources().getColor(R.color.orange));
} }
Settings.Vibrate(Settings.VibrateTime.NORMAL, getApplicationContext()); Settings.Vibrate(Settings.VibrateTime.NORMAL, getApplicationContext());
...@@ -394,7 +394,7 @@ public class ScanActivity extends AppCompatActivity { ...@@ -394,7 +394,7 @@ public class ScanActivity extends AppCompatActivity {
mCrossImage.setVisibility(View.VISIBLE); mCrossImage.setVisibility(View.VISIBLE);
mCrossImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow)); mCrossImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow));
mBGTint.setVisibility(View.VISIBLE); mBGTint.setVisibility(View.VISIBLE);
mBGTint.setColorFilter(getResources().getColor(R.color.colorInvalid)); mBGTint.setColorFilter(getResources().getColor(R.color.invalid));
} }
else else
{ //invalid legi/already checked in etc { //invalid legi/already checked in etc
...@@ -403,7 +403,7 @@ public class ScanActivity extends AppCompatActivity { ...@@ -403,7 +403,7 @@ public class ScanActivity extends AppCompatActivity {
mCrossImage.setVisibility(View.VISIBLE); mCrossImage.setVisibility(View.VISIBLE);
mCrossImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow)); mCrossImage.startAnimation(AnimationUtils.loadAnimation(this, R.anim.item_anim_grow));
mBGTint.setVisibility(View.VISIBLE); mBGTint.setVisibility(View.VISIBLE);
mBGTint.setColorFilter(getResources().getColor(R.color.colorInvalid)); mBGTint.setColorFilter(getResources().getColor(R.color.invalid));
Settings.Vibrate(Settings.VibrateTime.LONG, getApplicationContext()); Settings.Vibrate(Settings.VibrateTime.LONG, getApplicationContext());
} }
......
package ch.amiv.android_app.core;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import ch.amiv.android_app.R;
import ch.amiv.android_app.ui.NonSwipeableViewPager;
public class IntroActivity extends AppCompatActivity {
private NonSwipeableViewPager viewPager;
private IntroViewPagerAdapter introViewPagerAdapter;
private LinearLayout dotsLayout;
private TextView[] dots;
private Button btnSkip, btnNext;
//page configs & layouts
private int[] layouts = {
R.layout.core_intro_slide_language,
R.layout.core_intro_slide_info,
R.layout.core_intro_slide_profile,
R.layout.core_intro_slide_event_prefs};
private boolean[] allowSkip = {false, false, true, false};
private int[] nextText = {0, R.string.next, 0, R.string.lets_go};//set to 0 to hide next button
private boolean hasLoggedIn; //used when using back after the login page
private String langSetIntentKey = "lang_set";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.core_activity_intro);
viewPager = findViewById(R.id.viewPager);
dotsLayout = findViewById(R.id.layoutDots);
btnSkip = findViewById(R.id.buttonSkip);
btnNext = findViewById(R.id.buttonNext);
boolean hasSetLang = false;
Intent intent = getIntent();
if(intent != null)
hasSetLang = intent.getBooleanExtra(langSetIntentKey, false);
//init ui elements
introViewPagerAdapter = new IntroViewPagerAdapter();
viewPager.setAdapter(introViewPagerAdapter);
viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
viewPager.setOffscreenPageLimit(0);
btnSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NextPage(false);
}
});
btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NextPage(true);
}
});
if(hasSetLang)
NextPage(true);
else
RefreshPageUI(0);
}
@Override
public void onBackPressed() {
int currentPos = viewPager.getCurrentItem();
if(currentPos == 2) {
StartLoginActivity(true);
}
else if(currentPos == 3){
if(hasLoggedIn)
viewPager.setCurrentItem(2);
else
StartLoginActivity(true);
}
else if(currentPos > 0)
viewPager.setCurrentItem(currentPos -1);
//Dont call super.onBackPressed as we will otherwise leave the app
}
/**
* Will set the buttons and dots correctly for the page given
*/
private void RefreshPageUI(int currentPage){
RefreshPageDots(currentPage);
btnSkip.setVisibility(allowSkip[currentPage] ? View.VISIBLE : View.INVISIBLE);
btnNext.setVisibility(nextText[currentPage] != 0 ? View.VISIBLE : View.INVISIBLE);
if(nextText[currentPage] != 0)
btnNext.setText(getString(nextText[currentPage]));
}
/**
* Will update the page dots at the bottom, to indicate which page we are on. note: the views are deleted and recreated
*/
private void RefreshPageDots(int currentPage) {
dots = new TextView[layouts.length +1]; //+1 for login acitivty
int inactive = ContextCompat.getColor(this, R.color.darkGrey);
dotsLayout.removeAllViews();
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("&#8226;"));
dots[i].setTextSize(35);
dots[i].setTextColor(inactive);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)//change indexes for login activity
dots[currentPage < 2 ? currentPage : currentPage +1].setTextColor(ContextCompat.getColor(this, R.color.lightGrey));
}
private void NextPage(boolean success){
int nextPos = viewPager.getCurrentItem() + 1;
if (nextPos == 2)//go to login first
StartLoginActivity(false);
else if (nextPos < layouts.length) {
viewPager.setCurrentItem(nextPos);
} else {
StartMainAcivity();
}
}
// Callbacks for when the page changes to refresh the progress dots
ViewPager.OnPageChangeListener viewPagerPageChangeListener = new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
RefreshPageUI(position);
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {}
@Override
public void onPageScrollStateChanged(int arg0) {}
};
/**
* View pager adapter
*/
public class IntroViewPagerAdapter extends PagerAdapter {
private LayoutInflater layoutInflater;
public IntroViewPagerAdapter() {
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(layouts[position], container, false);
container.addView(view);
return view;
}
@Override
public int getCount() {
return layouts.length;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
View view = (View) object;
container.removeView(view);
}
}
/**
* This is called when we return from the login activity
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == 0) { //skip the profile page if we are not logged in
hasLoggedIn = data.getBooleanExtra("login_success", false);
if(hasLoggedIn)
hasLoggedIn = Settings.HasToken(getApplicationContext());//check if user is only logged in by mail, or if we have no user profile to edit
if(resultCode == RESULT_OK)
viewPager.setCurrentItem(hasLoggedIn ? 2 : 3);
else
viewPager.setCurrentItem(1);//means the user canceled using back, show the previous page
}
}
private void StartLoginActivity(boolean logoutFirst) {
if(logoutFirst)
UserInfo.LogoutUser(getApplicationContext());
startActivityForResult(new Intent(this, LoginActivity.class), 0);
}
private void StartMainAcivity() {
Settings.SetIntroDone(true, this);
startActivity(new Intent(this, MainActivity.class));
finish();
}
//endregion
//region----Functionality specific to a page----
//region---Language Page---
public void SetLanguageEN(View view){
ApplyLanguage(0);
}
public void SetLanguageDE(View view){
ApplyLanguage(1);
}
/**
* @param langIndex According to the language pref array (pref_lang_list_entries) in strings.xml
*/
private void ApplyLanguage(int langIndex){
Settings.SetLanguage(getResources().getStringArray(R.array.pref_lang_list_entries)[langIndex], getApplicationContext());
//restart activty and set extra to skip language page
Intent intent = getIntent();
intent.putExtra(langSetIntentKey, true);
finish();
startActivity(intent);
}
//endregion
//region---Profile---
//endregion
//endregion
}
...@@ -34,6 +34,8 @@ import ch.amiv.android_app.R; ...@@ -34,6 +34,8 @@ import ch.amiv.android_app.R;
*/ */
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
boolean isIntroLogin;
EditText userField; EditText userField;
EditText passwordField; EditText passwordField;
Button submitButton; Button submitButton;
...@@ -43,14 +45,33 @@ public class LoginActivity extends AppCompatActivity { ...@@ -43,14 +45,33 @@ public class LoginActivity extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
isIntroLogin = !Settings.GetIntroDone(this);
//Set for the keyboard to resize the window so the snackbars appear just above the keyboard //Set for the keyboard to resize the window so the snackbars appear just above the keyboard
prevLayoutParams = getWindow().getAttributes().softInputMode; prevLayoutParams = getWindow().getAttributes().softInputMode;
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
setContentView(R.layout.core_activity_login); setContentView(R.layout.core_activity_login);
//Show skip button if this is in the intro
Button btnSkip = findViewById(R.id.buttonSkip);
if (isIntroLogin) {
btnSkip.setVisibility(View.VISIBLE);
btnSkip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ReturnToCallingActivity(false, false);
}
});
}
else {
btnSkip.setVisibility(View.GONE);
}