Skip to content

Commit

Permalink
Merge pull request #95 from Glucosio/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
Benjamin Kerensa committed Oct 12, 2015
2 parents 0cda630 + 801583c commit 261d02c
Show file tree
Hide file tree
Showing 727 changed files with 38,250 additions and 7,667 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: android
sudo: false

android:
components:
Expand All @@ -15,7 +16,10 @@ before_install:

after_success:
- chmod +x ./upload-gh-pages.sh
- chmod +x ./import-translations-github.sh
- ./import-translations-github.sh
- ./upload-gh-pages.sh

script:
- cd $TRAVIS_BUILD_DIR/
- ./gradlew clean build
10 changes: 8 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ android {
}

repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
Expand All @@ -36,9 +38,13 @@ dependencies {
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.wdullaer:materialdatetimepicker:1.5.1'
compile 'com.wdullaer:materialdatetimepicker:1.5.3'
compile 'com.android.support:percent:23.0.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.4'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.github.paolorotolo:gitty_reporter:1.1.1'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.wnafee:vector-compat:1.0.5'
compile 'io.realm:realm-android:0.83.0'
compile 'net.danlew:android.joda:2.8.2'
}
10 changes: 9 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="org.glucosio.android" >

<application
android:name=".GlucosioApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -21,13 +22,20 @@
<activity
android:name=".activity.HelloActivity"
android:theme="@style/AppThemeNoActionBar"
android:screenOrientation="portrait"
android:label="@string/title_activity_hello" >
</activity>
<activity
android:name=".activity.GittyActivity"
android:theme="@style/GittyTheme">
</activity>
<activity
android:name=".activity.PreferencesActivity"
android:theme="@style/GlucosioSettings">
</activity>
<activity
android:name=".activity.LicenceActivity"
android:theme="@style/GlucosioTheme">
</activity>
</application>

</manifest>
23 changes: 23 additions & 0 deletions app/src/main/java/org/glucosio/android/GlucosioApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.glucosio.android;

import android.content.Context;

import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;

public class GlucosioApplication extends com.activeandroid.app.Application {
@Override
public void onCreate() {
super.onCreate();

CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/lato.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
}

@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
}
16 changes: 14 additions & 2 deletions app/src/main/java/org/glucosio/android/activity/GittyActivity.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package org.glucosio.android.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Base64;

import com.github.paolorotolo.gitty_reporter.GittyReporter;

import org.glucosio.android.R;

import java.io.UnsupportedEncodingException;

import uk.co.chrisjenx.calligraphy.CalligraphyConfig;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;


public class GittyActivity extends GittyReporter {
@Override
public void init(Bundle savedInstanceState) {

String token = "OGRlZDVkZjBjZGYzNzNjYTdiNzY2MmYwMGVmMTU5ZjcyMjYwMWQ1NA==";
String token = "NTZhYmQ5NjQ5MTU5ZmU5ZjI3ZDU2MmE2OTM0OWU0MGRhMDRmMGVhMg==";

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

// Set where Gitty will send issues.
// (username, repository name);
setTargetRepository("Glucosio", "andorid");
setTargetRepository("Glucosio", "android");

// Set Auth token to open issues if user doesn't have a GitHub account
// For example, you can register a bot account on GitHub that will open bugs for you.
Expand All @@ -40,4 +47,9 @@ public void init(Bundle savedInstanceState) {
// If false, Gitty will redirect non registred users to github.com/join
enableGuestGitHubLogin(true);
}

@Override
public void onBackPressed() {
finish();
}
}
75 changes: 52 additions & 23 deletions app/src/main/java/org/glucosio/android/activity/HelloActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,61 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Intent;
import android.support.design.widget.TextInputLayout;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import org.glucosio.android.R;
import org.glucosio.android.db.DatabaseHandler;
import org.glucosio.android.db.User;
import org.glucosio.android.presenter.HelloPresenter;
import org.glucosio.android.tools.LabelledSpinner;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;

public class HelloActivity extends AppCompatActivity {

LabelledSpinner languageSpinner;
LabelledSpinner genderSpinner;
LabelledSpinner typeSpinner;
LabelledSpinner unitSpinner;
View firstView;
View EULAView;
CheckBox EULACheckbox;
Button startButton;
TextView ageTextView;
TextView termsTextView;
Button nextButton;
HelloPresenter presenter;
private LabelledSpinner countrySpinner;
private LabelledSpinner genderSpinner;
private LabelledSpinner typeSpinner;
private LabelledSpinner unitSpinner;
private View firstView;
private View EULAView;
private CheckBox EULACheckbox;
private Button startButton;
private TextView ageTextView;
private TextView termsTextView;
private Button nextButton;
private HelloPresenter presenter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello);

// Prevent SoftKeyboard to pop up on start
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

presenter = new HelloPresenter(this);
presenter.loadDatabase();

firstView = (ScrollView) findViewById(R.id.helloactivity_mainframe);
EULAView = (ScrollView) findViewById(R.id.helloactivity_eulaframe);
EULAView = (RelativeLayout) findViewById(R.id.helloactivity_eulaframe);
EULACheckbox = (CheckBox) findViewById(R.id.helloactivity_checkbox_eula);
languageSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_language);
countrySpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_country);
genderSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_gender);
typeSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_diabetes_type);
unitSpinner = (LabelledSpinner) findViewById(R.id.helloactivity_spinner_preferred_unit);
Expand All @@ -62,31 +68,54 @@ protected void onCreate(Bundle savedInstanceState) {
ageTextView = (TextView) findViewById(R.id.helloactivity_age);
nextButton = (Button) findViewById(R.id.helloactivity_next);

// Get countries list from locale
ArrayList<String> countries = new ArrayList<String>();
Locale[] locales = Locale.getAvailableLocales();

for (Locale locale : locales) {
String country = locale.getDisplayCountry();
if (country.trim().length()>0 && !countries.contains(country)) {
countries.add(country);
}
}
Collections.sort(countries);

// Populate Spinners with array
languageSpinner.setItemsArray(R.array.helloactivity_language_list);
countrySpinner.setItemsArray(countries);

// Get locale country name and set the spinner
String localCountry = getApplicationContext().getResources().getConfiguration().locale.getDisplayCountry();
if (!localCountry.equals(null)) {
countrySpinner.setSelection(((ArrayAdapter) countrySpinner.getSpinner().getAdapter()).getPosition(localCountry));
}

genderSpinner.setItemsArray(R.array.helloactivity_gender_list);
unitSpinner.setItemsArray(R.array.helloactivity_preferred_unit);
typeSpinner.setItemsArray(R.array.helloactivity_diabetes_type);

termsTextView.setMovementMethod(new ScrollingMovementMethod());
final Drawable greyArrow = getApplicationContext().getResources().getDrawable( R.drawable.ic_navigate_next_grey_24px );
greyArrow.setBounds(0, 0, 60, 60);
final Drawable pinkArrow = getApplicationContext().getResources().getDrawable( R.drawable.ic_navigate_next_pink_24px );
pinkArrow.setBounds(0, 0, 60, 60);
EULACheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
startButton.setEnabled(true);
startButton.setCompoundDrawables(null, null, pinkArrow, null);
} else {
startButton.setEnabled(false);
startButton.setCompoundDrawables(null, null, greyArrow, null);
}
}
}
);

//TODO: add Preferred Unit and Diabetes Type in dB
}

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

public void showEULA(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.glucosio.android.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import org.glucosio.android.R;

public class LicenceActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_licence);

TextView dialogOk = (TextView) findViewById(R.id.dialog_terms_ok);
dialogOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
}
Loading

0 comments on commit 261d02c

Please sign in to comment.