Skip to content

Commit 261d02c

Browse files
author
Benjamin Kerensa
committed
Merge pull request #95 from Glucosio/develop
Merge develop to master
2 parents 0cda630 + 801583c commit 261d02c

File tree

727 files changed

+38250
-7667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

727 files changed

+38250
-7667
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: android
2+
sudo: false
23

34
android:
45
components:
@@ -15,7 +16,10 @@ before_install:
1516

1617
after_success:
1718
- chmod +x ./upload-gh-pages.sh
19+
- chmod +x ./import-translations-github.sh
20+
- ./import-translations-github.sh
1821
- ./upload-gh-pages.sh
1922

2023
script:
24+
- cd $TRAVIS_BUILD_DIR/
2125
- ./gradlew clean build

app/build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ android {
2727
}
2828

2929
repositories {
30+
mavenCentral()
3031
maven { url "https://jitpack.io" }
32+
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
3133
}
3234

3335
dependencies {
@@ -36,9 +38,13 @@ dependencies {
3638
compile 'com.android.support:design:23.0.1'
3739
compile 'com.android.support:cardview-v7:23.0.1'
3840
compile 'com.android.support:recyclerview-v7:23.0.1'
39-
compile 'com.wdullaer:materialdatetimepicker:1.5.1'
41+
compile 'com.wdullaer:materialdatetimepicker:1.5.3'
4042
compile 'com.android.support:percent:23.0.1'
41-
compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
43+
compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
4244
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
4345
compile 'com.github.paolorotolo:gitty_reporter:1.1.1'
46+
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
47+
compile 'com.wnafee:vector-compat:1.0.5'
48+
compile 'io.realm:realm-android:0.83.0'
49+
compile 'net.danlew:android.joda:2.8.2'
4450
}

app/src/main/AndroidManifest.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package="org.glucosio.android" >
44

55
<application
6+
android:name=".GlucosioApplication"
67
android:allowBackup="true"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
@@ -21,13 +22,20 @@
2122
<activity
2223
android:name=".activity.HelloActivity"
2324
android:theme="@style/AppThemeNoActionBar"
24-
android:screenOrientation="portrait"
2525
android:label="@string/title_activity_hello" >
2626
</activity>
2727
<activity
2828
android:name=".activity.GittyActivity"
2929
android:theme="@style/GittyTheme">
3030
</activity>
31+
<activity
32+
android:name=".activity.PreferencesActivity"
33+
android:theme="@style/GlucosioSettings">
34+
</activity>
35+
<activity
36+
android:name=".activity.LicenceActivity"
37+
android:theme="@style/GlucosioTheme">
38+
</activity>
3139
</application>
3240

3341
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.glucosio.android;
2+
3+
import android.content.Context;
4+
5+
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
6+
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
7+
8+
public class GlucosioApplication extends com.activeandroid.app.Application {
9+
@Override
10+
public void onCreate() {
11+
super.onCreate();
12+
13+
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
14+
.setDefaultFontPath("fonts/lato.ttf")
15+
.setFontAttrId(R.attr.fontPath)
16+
.build());
17+
}
18+
19+
@Override
20+
protected void attachBaseContext(Context newBase) {
21+
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
22+
}
23+
}

app/src/main/java/org/glucosio/android/activity/GittyActivity.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
package org.glucosio.android.activity;
22

3+
import android.content.Context;
4+
import android.content.Intent;
35
import android.os.Bundle;
46
import android.util.Base64;
57

68
import com.github.paolorotolo.gitty_reporter.GittyReporter;
79

10+
import org.glucosio.android.R;
11+
812
import java.io.UnsupportedEncodingException;
913

14+
import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
15+
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
16+
1017

1118
public class GittyActivity extends GittyReporter {
1219
@Override
1320
public void init(Bundle savedInstanceState) {
1421

15-
String token = "OGRlZDVkZjBjZGYzNzNjYTdiNzY2MmYwMGVmMTU5ZjcyMjYwMWQ1NA==";
22+
String token = "NTZhYmQ5NjQ5MTU5ZmU5ZjI3ZDU2MmE2OTM0OWU0MGRhMDRmMGVhMg==";
1623

1724
byte[] data1 = Base64.decode(token, Base64.DEFAULT);
1825
String decodedToken = token;
@@ -24,7 +31,7 @@ public void init(Bundle savedInstanceState) {
2431

2532
// Set where Gitty will send issues.
2633
// (username, repository name);
27-
setTargetRepository("Glucosio", "andorid");
34+
setTargetRepository("Glucosio", "android");
2835

2936
// Set Auth token to open issues if user doesn't have a GitHub account
3037
// For example, you can register a bot account on GitHub that will open bugs for you.
@@ -40,4 +47,9 @@ public void init(Bundle savedInstanceState) {
4047
// If false, Gitty will redirect non registred users to github.com/join
4148
enableGuestGitHubLogin(true);
4249
}
50+
51+
@Override
52+
public void onBackPressed() {
53+
finish();
54+
}
4355
}

app/src/main/java/org/glucosio/android/activity/HelloActivity.java

Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,61 @@
33
import android.animation.Animator;
44
import android.animation.AnimatorListenerAdapter;
55
import android.content.Intent;
6-
import android.support.design.widget.TextInputLayout;
6+
import android.graphics.drawable.Drawable;
77
import android.support.v7.app.AppCompatActivity;
88
import android.os.Bundle;
9-
import android.support.v7.widget.Toolbar;
10-
import android.text.TextUtils;
119
import android.text.method.ScrollingMovementMethod;
1210
import android.view.Menu;
1311
import android.view.MenuItem;
1412
import android.view.View;
13+
import android.view.WindowManager;
14+
import android.widget.ArrayAdapter;
1515
import android.widget.Button;
1616
import android.widget.CheckBox;
1717
import android.widget.CompoundButton;
18+
import android.widget.RelativeLayout;
1819
import android.widget.ScrollView;
1920
import android.widget.TextView;
2021
import android.widget.Toast;
2122

2223
import org.glucosio.android.R;
23-
import org.glucosio.android.db.DatabaseHandler;
24-
import org.glucosio.android.db.User;
2524
import org.glucosio.android.presenter.HelloPresenter;
2625
import org.glucosio.android.tools.LabelledSpinner;
2726

27+
import java.util.ArrayList;
28+
import java.util.Collections;
29+
import java.util.Locale;
30+
2831
public class HelloActivity extends AppCompatActivity {
2932

30-
LabelledSpinner languageSpinner;
31-
LabelledSpinner genderSpinner;
32-
LabelledSpinner typeSpinner;
33-
LabelledSpinner unitSpinner;
34-
View firstView;
35-
View EULAView;
36-
CheckBox EULACheckbox;
37-
Button startButton;
38-
TextView ageTextView;
39-
TextView termsTextView;
40-
Button nextButton;
41-
HelloPresenter presenter;
33+
private LabelledSpinner countrySpinner;
34+
private LabelledSpinner genderSpinner;
35+
private LabelledSpinner typeSpinner;
36+
private LabelledSpinner unitSpinner;
37+
private View firstView;
38+
private View EULAView;
39+
private CheckBox EULACheckbox;
40+
private Button startButton;
41+
private TextView ageTextView;
42+
private TextView termsTextView;
43+
private Button nextButton;
44+
private HelloPresenter presenter;
4245

4346
@Override
4447
protected void onCreate(Bundle savedInstanceState) {
4548
super.onCreate(savedInstanceState);
4649
setContentView(R.layout.activity_hello);
4750

51+
// Prevent SoftKeyboard to pop up on start
52+
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
53+
4854
presenter = new HelloPresenter(this);
4955
presenter.loadDatabase();
5056

5157
firstView = (ScrollView) findViewById(R.id.helloactivity_mainframe);
52-
EULAView = (ScrollView) findViewById(R.id.helloactivity_eulaframe);
58+
EULAView = (RelativeLayout) findViewById(R.id.helloactivity_eulaframe);
5359
EULACheckbox = (CheckBox) findViewById(R.id.helloactivity_checkbox_eula);
54-
languageSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_language);
60+
countrySpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_country);
5561
genderSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_gender);
5662
typeSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_diabetes_type);
5763
unitSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_preferred_unit);
@@ -62,31 +68,54 @@ protected void onCreate(Bundle savedInstanceState) {
6268
ageTextView = (TextView) findViewById(R.id.helloactivity_age);
6369
nextButton = (Button) findViewById(R.id.helloactivity_next);
6470

71+
// Get countries list from locale
72+
ArrayList<String> countries = new ArrayList<String>();
73+
Locale[] locales = Locale.getAvailableLocales();
74+
75+
for (Locale locale : locales) {
76+
String country = locale.getDisplayCountry();
77+
if (country.trim().length()>0 && !countries.contains(country)) {
78+
countries.add(country);
79+
}
80+
}
81+
Collections.sort(countries);
82+
6583
// Populate Spinners with array
66-
languageSpinner.setItemsArray(R.array.helloactivity_language_list);
84+
countrySpinner.setItemsArray(countries);
85+
86+
// Get locale country name and set the spinner
87+
String localCountry = getApplicationContext().getResources().getConfiguration().locale.getDisplayCountry();
88+
if (!localCountry.equals(null)) {
89+
countrySpinner.setSelection(((ArrayAdapter) countrySpinner.getSpinner().getAdapter()).getPosition(localCountry));
90+
}
91+
6792
genderSpinner.setItemsArray(R.array.helloactivity_gender_list);
6893
unitSpinner.setItemsArray(R.array.helloactivity_preferred_unit);
6994
typeSpinner.setItemsArray(R.array.helloactivity_diabetes_type);
7095

7196
termsTextView.setMovementMethod(new ScrollingMovementMethod());
97+
final Drawable greyArrow = getApplicationContext().getResources().getDrawable( R.drawable.ic_navigate_next_grey_24px );
98+
greyArrow.setBounds(0, 0, 60, 60);
99+
final Drawable pinkArrow = getApplicationContext().getResources().getDrawable( R.drawable.ic_navigate_next_pink_24px );
100+
pinkArrow.setBounds(0, 0, 60, 60);
72101
EULACheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
73102
@Override
74103
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
75104
if (isChecked) {
76105
startButton.setEnabled(true);
106+
startButton.setCompoundDrawables(null, null, pinkArrow, null);
77107
} else {
78108
startButton.setEnabled(false);
109+
startButton.setCompoundDrawables(null, null, greyArrow, null);
79110
}
80111
}
81112
}
82113
);
83-
84-
//TODO: add Preferred Unit and Diabetes Type in dB
85114
}
86115

87116
public void onNextClicked(View v){
88117
presenter.onNextClicked(ageTextView.getText().toString(),
89-
genderSpinner.getSpinner().getSelectedItemPosition(), languageSpinner.getSpinner().getSelectedItem().toString());
118+
genderSpinner.getSpinner().getSelectedItem().toString(), Locale.getDefault().getDisplayLanguage(), countrySpinner.getSpinner().getSelectedItem().toString(), typeSpinner.getSpinner().getSelectedItemPosition() + 1, unitSpinner.getSpinner().getSelectedItem().toString());
90119
}
91120

92121
public void showEULA(){
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.glucosio.android.activity;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.view.View;
6+
import android.widget.TextView;
7+
import org.glucosio.android.R;
8+
9+
public class LicenceActivity extends AppCompatActivity {
10+
11+
@Override
12+
protected void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
setContentView(R.layout.activity_licence);
15+
16+
TextView dialogOk = (TextView) findViewById(R.id.dialog_terms_ok);
17+
dialogOk.setOnClickListener(new View.OnClickListener() {
18+
@Override
19+
public void onClick(View v) {
20+
finish();
21+
}
22+
});
23+
}
24+
}

0 commit comments

Comments
 (0)