Skip to content

Commit

Permalink
Merge pull request openMF#156 from fomenkoo/feature/material-dashboard
Browse files Browse the repository at this point in the history
Feature/material dashboard
  • Loading branch information
droidchef committed Dec 28, 2015
2 parents 9d298f0 + 79df070 commit e1598cb
Show file tree
Hide file tree
Showing 38 changed files with 556 additions and 377 deletions.
10 changes: 6 additions & 4 deletions mifosng-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ tasks.withType(com.android.build.gradle.tasks.PackageApplication) {
dependencies {
compile fileTree(dir: 'src/main/libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Google Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-annotations:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:23.0.1'
compile 'com.jakewharton.fliptables:fliptables:1.0.1'
Expand All @@ -116,9 +114,13 @@ dependencies {
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'


// Test libraries provided by https://code.google.com/p/android-test-kit/
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support:support-annotations:23.1.1'


compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.jakewharton:butterknife:6.1.0'
Expand Down
38 changes: 20 additions & 18 deletions mifosng-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ This project is licensed under the open source MPL V2.
~ See https://github.com/openMF/android-client/blob/master/LICENSE.md
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mifos.mifosxdroid"
android:versionCode="3"
android:versionName="0.4.0" >
android:versionName="0.4.0">

<uses-sdk
android:minSdkVersion="10"
Expand All @@ -23,11 +22,13 @@
android:allowBackup="false"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Mifosxactionbar" >
android:theme="@style/Theme.Mifosxactionbar">

<activity
android:name=".SplashScreenActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
android:screenOrientation="portrait"
android:theme="@style/MaterialAppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -37,16 +38,17 @@
<activity
android:name=".LoginActivity"
android:label="@string/login"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/MaterialAppTheme" />
<activity
android:name=".online.LogoutActivity"
android:label="@string/logout"
android:screenOrientation="portrait" />
<activity
android:name=".online.DashboardFragmentActivity"
android:theme="@style/MaterialAppTheme"
android:label="@string/dashboard"
android:screenOrientation="portrait" >
</activity>
android:screenOrientation="portrait"></activity>
<activity
android:name=".GroupActivity"
android:configChanges="orientation|screenSize"
Expand Down Expand Up @@ -82,17 +84,17 @@
<activity
android:name=".online.ClientActivity"
android:label="@string/title_activity_client"
android:screenOrientation="portrait" >
</activity>
android:screenOrientation="portrait"></activity>
<activity
android:name=".OfflineCenterInputActivity"
android:screenOrientation="portrait"
android:parentActivityName=".online.DashboardFragmentActivity">
</activity>
android:name=".OfflineCenterInputActivity"
android:theme="@style/MaterialAppTheme"
android:label="Offline Center Input"
android:parentActivityName=".online.DashboardFragmentActivity"
android:screenOrientation="portrait"/>
<activity
android:name=".online.CentersActivity"
android:label="@string/title_activity_centers"
android:parentActivityName=".online.DashboardFragmentActivity" >
android:parentActivityName=".online.DashboardFragmentActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mifos.mifosxdroid.online.DashboardFragmentActivity" />
Expand All @@ -105,14 +107,14 @@
<activity
android:name=".online.GenerateCollectionSheet"
android:label="@string/title_activity_generate_collection_sheet"
android:parentActivityName=".online.DashboardFragmentActivity" >
android:parentActivityName=".online.DashboardFragmentActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mifos.mifosxdroid.online.DashboardFragmentActivity" />
</activity>
<activity
android:name=".CenterListActivity"
android:screenOrientation="portrait"/>
android:name=".CenterListActivity"
android:screenOrientation="portrait" />
</application>

</manifest>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
package com.mifos.mifosxdroid;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
Expand All @@ -26,9 +24,10 @@
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.mifos.exceptions.ShortOfLengthException;
import com.mifos.mifosxdroid.core.BaseActivity;
import com.mifos.mifosxdroid.core.util.Toaster;
import com.mifos.mifosxdroid.online.DashboardFragmentActivity;
import com.mifos.objects.User;
import com.mifos.services.API;
Expand All @@ -53,13 +52,16 @@
import retrofit.RetrofitError;
import retrofit.client.Response;

import static android.view.View.*;
import static android.view.View.GONE;
import static android.view.View.OnClickListener;
import static android.view.View.VISIBLE;

/**
* Created by ishankhanna on 08/02/14.
*/
public class LoginActivity extends AppCompatActivity implements Callback<User> {
public class LoginActivity extends BaseActivity implements Callback<User> {

private final static String TAG = LoginActivity.class.getSimpleName();
private static final String DOMAIN_NAME_REGEX_PATTERN = "^[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$";
private static final String IP_ADDRESS_REGEX_PATTERN = "^(\\d|[1-9]\\d|1\\d\\d|2([0-4]\\d|5[0-5]))\\.(\\d|[1-9]\\d|1\\d\\d|2([0-4]\\d|5[0-5]))\\.(\\d|[1-9]\\d|1\\d\\d|2([0-4]\\d|5[0-5]))\\.(\\d|[1-9]\\d|1\\d\\d|2([0-4]\\d|5[0-5]))$";
public static final String PROTOCOL_HTTP = "http://";
Expand Down Expand Up @@ -89,14 +91,12 @@ public class LoginActivity extends AppCompatActivity implements Callback<User> {
private String password;
private Context context;
private String authenticationToken;
private ProgressDialog progressDialog;
private final static String TAG = "LoginActivity";

private Pattern domainNamePattern;
private Matcher domainNameMatcher;
private Pattern ipAddressPattern;
private Matcher ipAddressMatcher;
private Integer port = null;

private API api;

@Override
Expand All @@ -107,14 +107,11 @@ public void onCreate(Bundle savedInstanceState) {
context = LoginActivity.this;

sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
String previouslyEnteredUrl = sharedPreferences.getString(Constants.INSTANCE_URL_KEY,
getString(R.string.default_instance_url));
String previouslyEnteredPort = sharedPreferences.getString(Constants.INSTANCE_PORT_KEY,
"80");
String previouslyEnteredUrl = sharedPreferences.getString(Constants.INSTANCE_URL_KEY, getString(R.string.default_instance_url));
String previouslyEnteredPort = sharedPreferences.getString(Constants.INSTANCE_PORT_KEY, "80");
authenticationToken = sharedPreferences.getString(User.AUTHENTICATION_KEY, "NA");

ButterKnife.inject(this);
setupUI();

domainNamePattern = Pattern.compile(DOMAIN_NAME_REGEX_PATTERN);
ipAddressPattern = Pattern.compile(IP_ADDRESS_REGEX_PATTERN);
Expand All @@ -140,40 +137,30 @@ public void onClick(View view) {
et_instanceURL.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {


}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {


}

@Override
public void afterTextChanged(Editable editable) {

updateMyInstanceUrl();

}
});



et_port.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override
public void afterTextChanged(Editable s) {

updateMyInstanceUrl();
}
});
Expand All @@ -199,12 +186,6 @@ private void updateMyInstanceUrl() {
}
}

public void setupUI() {
progressDialog = new ProgressDialog(context, ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage("Logging In");
progressDialog.setCancelable(false);
}

public boolean validateUserInputs() throws ShortOfLengthException {

String urlInputValue = et_instanceURL.getEditableText().toString();
Expand Down Expand Up @@ -239,7 +220,6 @@ public boolean validateUserInputs() throws ShortOfLengthException {
if (!et_tenantIdentifier.getEditableText().toString().isEmpty()) {

}

return true;
}

Expand All @@ -254,8 +234,8 @@ public String constructInstanceUrl(String validDomain, Integer port) {
@Override
public void success(User user, Response response) {
((MifosApplication) getApplication()).api = api;
progressDialog.dismiss();
Toast.makeText(context, getString(R.string.toast_welcome) + " " + user.getUsername(), Toast.LENGTH_SHORT).show();
hideProgress();
Toaster.show(findViewById(android.R.id.content), getString(R.string.toast_welcome) + " " + user.getUsername());
saveLastAccessedInstanceUrl(instanceURL);
saveLastAccessedInstanceDomainName(et_instanceURL.getEditableText().toString());
if (!et_port.getEditableText().toString().trim().isEmpty()) {
Expand All @@ -274,13 +254,16 @@ public void success(User user, Response response) {
@Override
public void failure(RetrofitError retrofitError) {
try {
progressDialog.dismiss();
hideProgress();
if (retrofitError.getCause() instanceof SSLHandshakeException) {
promptUserToByPassTheSSLHandshake();
} else if (retrofitError.getResponse().getStatus() == HttpStatus.SC_UNAUTHORIZED)
Toast.makeText(context, getString(R.string.error_login_failed), Toast.LENGTH_SHORT).show();
} else if (retrofitError.getResponse().getStatus() == HttpStatus.SC_UNAUTHORIZED) {
Toaster.show(findViewById(android.R.id.content), getString(R.string.error_login_failed));
} else if (retrofitError.getResponse().getStatus() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
Toaster.show(findViewById(android.R.id.content), "Internal server error");
}
} catch (NullPointerException e) {
Toast.makeText(context, getString(R.string.error_unknown), Toast.LENGTH_SHORT).show();
Toaster.show(findViewById(android.R.id.content), getString(R.string.error_unknown));
}
}

Expand All @@ -291,7 +274,6 @@ public void failure(RetrofitError retrofitError) {
* that trusts any damn thing.
*/
private void promptUserToByPassTheSSLHandshake() {

AlertDialog alertDialog = new AlertDialog.Builder(this)
.setTitle("SSL Certificate Problem")
.setMessage("There is a problem with your SSLCertificate, would you like to continue? This connection would be unsafe.")
Expand Down Expand Up @@ -321,11 +303,11 @@ public void onLoginClick(Button button) {
private void login(boolean shouldByPassSSLSecurity) {
try {
if (validateUserInputs())
progressDialog.show();
showProgress("Logging In");
api = new API(instanceURL, et_tenantIdentifier.getEditableText().toString().trim(), shouldByPassSSLSecurity);
api.userAuthService.authenticate(username, password, this);
} catch (ShortOfLengthException e) {
Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show();
Toaster.show(findViewById(android.R.id.content), e.toString());
}
}

Expand Down Expand Up @@ -422,9 +404,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.offline:
startActivity(new Intent(this, OfflineCenterInputActivity.class));
break;

default: //DO NOTHING
break;
}

return super.onOptionsItemSelected(item);
Expand Down Expand Up @@ -483,5 +462,4 @@ public boolean validateURL(final String hex) {
//TODO MAKE SURE YOU UPDATE THE REGEX to check for ports in the URL
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.mifos.mifosxdroid.core.BaseActivity;
import com.mifos.mifosxdroid.core.util.Toaster;

import java.util.Calendar;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

public class OfflineCenterInputActivity extends ActionBarActivity implements DatePickerDialog.OnDateSetListener {
public class OfflineCenterInputActivity extends BaseActivity implements DatePickerDialog.OnDateSetListener {
public static String PREF_CENTER_DETAILS = "pref_center_details";
public static String STAFF_ID_KEY = "pref_staff_id";
public static String BRANCH_ID_KEY = "pref_branch_id";
Expand All @@ -34,8 +35,6 @@ public class OfflineCenterInputActivity extends ActionBarActivity implements Dat
EditText etBranchId;
@InjectView(R.id.tv_select_date)
TextView tvSelectDate;
@InjectView(R.id.btnSave)
Button btnSave;
private String date;
private int staffId;
private int branchId;
Expand All @@ -47,8 +46,7 @@ public void onCreate(Bundle savedInstanceState) {
}
setContentView(R.layout.activity_center_details);
ButterKnife.inject(this);
getActionBar().setDisplayHomeAsUpEnabled(true);

showBackButton();
}

private boolean isCenterIdAvailable() {
Expand Down Expand Up @@ -90,7 +88,7 @@ private boolean getData() {
branchId = Integer.parseInt(etBranchId.getEditableText().toString());
} else {
isAllDetailsFilled = false;
Toast.makeText(this, "Please fill all the details", Toast.LENGTH_SHORT).show();
Toaster.show(findViewById(android.R.id.content), "Please fill all the details");
}
return isAllDetailsFilled;
}
Expand Down
Loading

0 comments on commit e1598cb

Please sign in to comment.