Commit ff40f518 authored by Matheus Horstmann's avatar Matheus Horstmann 🐴
Browse files

Merge branch 'develop' into 'master'

Develop

See merge request !20
parents dc80b77f e547bc85
......@@ -3,8 +3,10 @@
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/*
/.idea/misc.xml
.DS_Store
/build
/captures
.externalNativeBuild
build.gradle
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.14.1" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Mobile.iml" filepath="$PROJECT_DIR$/Mobile.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "br.ufpr.c3sl.agendador.agendador"
minSdkVersion 19
......@@ -24,12 +24,17 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support.test.espresso:espresso-core:2.2.2'
compile 'com.firebase:firebase-jobdispatcher:0.6.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.android.support:recyclerview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
......@@ -3,14 +3,26 @@
package="br.ufpr.c3sl.agendador.agendador">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -18,21 +30,59 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity" />
<activity android:name=".HomeActivity" />
<activity android:name=".CepActivity" />
<activity android:name=".CepNotFoundActivity" />
<activity android:name=".SignUpActivity" />
<activity android:name=".AccountActivity" />
<activity android:name=".PasswordRetrievalActivity" />
<activity android:name=".DependentsListActivity" />
<activity android:name=".LoginActivity">
</activity>
<activity android:name=".HomeActivity">
</activity>
<activity android:name=".CepActivity">
</activity>
<service
android:name=".services.ImageUpdateService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<service
android:name=".services.notification.NotificationReadService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<service
android:name=".services.notification.NotificationsListService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE">
<intent-filter>
<action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE" />
</intent-filter>
</service>
<activity android:name=".CepNotFoundActivity">
</activity>
<receiver android:name=".services.BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".services.notification.NotificationReceiver"></receiver>
<activity android:name=".SignupActivity">
</activity>
<activity android:name=".TermActivity" />
<activity android:name=".SchedulingActivity" />
<activity android:name=".CitizenListActivity" />
<activity android:name=".SchedulesActivity" />
<activity android:name=".ScheduleConfirmationActivity" />
<activity android:name=".DependentUpdateActivity" />
<activity android:name=".NewDependentActivity" />
<activity android:name=".RetrievalFailureActivity" />
<activity android:name=".RetrievalSuccessActivity" />
<activity android:name=".SchedulesHistoryActivity" />
<activity android:name=".ScheduleInfoActivity" />
<activity android:name=".EmailActivity"></activity>
</application>
</manifest>
\ No newline at end of file
package br.ufpr.c3sl.agendador.agendador;
import android.Manifest;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionChecker;
import br.ufpr.c3sl.agendador.agendador.helpers.ConnectionErrorDialog;
import br.ufpr.c3sl.agendador.agendador.helpers.DateValidator;
import br.ufpr.c3sl.agendador.agendador.helpers.Mask;
import br.ufpr.c3sl.agendador.agendador.helpers.ObscuredSharedPreferences;
import br.ufpr.c3sl.agendador.agendador.helpers.UserImgHelper;
import br.ufpr.c3sl.agendador.agendador.helpers.Utils;
import br.ufpr.c3sl.agendador.agendador.helpers.adapters.PhotoSelectionAdapter;
import br.ufpr.c3sl.agendador.agendador.presenters.AccountPresenter;
import br.ufpr.c3sl.agendador.agendador.presenters.PresenterManager;
import br.ufpr.c3sl.agendador.agendador.views.AccountView;
/**
* Created by Horstmann on 02/03/17.
*/
public class AccountActivity extends AppCompatActivity implements AccountView {
private EditText et_name, et_cpf, et_rg, et_birthdate,
et_disability, et_cep, et_address, et_number, et_neighborhood,
et_city, et_state, et_complement, et_phone, et_phone2,
et_email, et_new_password, et_password_confirmation;
private ImageView imgv_profile;
private ProgressBar pb_account;
private RadioButton rb_no, rb_yes;
private Button btn_update, btn_cancel;
private ImageButton btn_photo;
private ObscuredSharedPreferences osb;
private AccountPresenter presenter;
private String current_password;
private TextView tv_name_warning, tv_rg_warning, tv_birthdate_warning,
tv_phone_warning, tv_password_confirm_warning, tv_email_warning,
tv_account_new_password_warning;
private MenuItem btn_edit, btn_sync;
private boolean editable;
private boolean isChangingPassword;
private boolean isChangingPhoto;
private boolean isPhotoDelete;
private UserImgHelper userImgHelper;
private ConnectionErrorDialog connectionErrorDialog;
private long id;
private final int REQUEST_PERMISSIONS = 1;
private final int LOAD_IMAGE_INTENT = 1;
//private static final int DEVELOPER_MODE = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
presenter = new AccountPresenter(this);
} else {
presenter = PresenterManager.getInstance().restorePresenter(savedInstanceState);
if(presenter == null)
presenter = new AccountPresenter(this);
}
setContentView(R.layout.activity_account_view);
osb = ObscuredSharedPreferences.getPrefs(this, "Agendador", Context.MODE_PRIVATE);
String citizenName = osb.getString("name", "");
id = osb.getLong("id", 0);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_acc);
toolbar.setTitle(citizenName);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
pb_account = (ProgressBar) findViewById(R.id.pb_accountact);
btn_cancel = (Button) findViewById(R.id.btn_account_cancel);
btn_update = (Button) findViewById(R.id.btn_account_update);
btn_photo = (ImageButton) findViewById(R.id.btn_account_photo);
et_name = (EditText) findViewById(R.id.et_account_name);
et_cpf = (EditText) findViewById(R.id.et_account_cpf);
et_rg = (EditText) findViewById(R.id.et_account_rg);
et_birthdate = (EditText) findViewById(R.id.et_account_birthday);
et_disability = (EditText) findViewById(R.id.et_account_disability_name);
et_cep = (EditText) findViewById(R.id.et_account_cep);
et_address = (EditText) findViewById(R.id.et_account_address);
et_neighborhood = (EditText) findViewById(R.id.et_account_neighborhood);
et_number = (EditText) findViewById(R.id.et_account_number);
et_city = (EditText) findViewById(R.id.et_account_city);
et_state = (EditText) findViewById(R.id.et_account_state);
et_complement = (EditText) findViewById(R.id.et_account_complement);
et_phone = (EditText) findViewById(R.id.et_account_phone);
et_phone2 = (EditText) findViewById(R.id.et_account_phone2);
et_email = (EditText) findViewById(R.id.et_account_email);
et_new_password = (EditText) findViewById(R.id.et_account_new_password);
et_password_confirmation = (EditText) findViewById(R.id.et_account_password_confirm);
tv_name_warning = (TextView) findViewById(R.id.tv_account_name_warning);
tv_rg_warning = (TextView) findViewById(R.id.tv_account_rg_warning);
tv_birthdate_warning = (TextView) findViewById(R.id.tv_account_birthday_warning);
tv_phone_warning = (TextView) findViewById(R.id.tv_account_phone_warning);
tv_email_warning = (TextView) findViewById(R.id.tv_account_email_warning);
tv_account_new_password_warning = (TextView) findViewById(R.id.tv_account_new_password_warning);
tv_password_confirm_warning = (TextView) findViewById(R.id.tv_account_confirm_password_warning);
imgv_profile = (ImageView) findViewById(R.id.img_account_photo);
rb_no = (RadioButton) findViewById(R.id.rb_has_disability_no);
rb_yes = (RadioButton) findViewById(R.id.rb_has_disability_yes);
userImgHelper = new UserImgHelper(getBaseContext());
et_cep.addTextChangedListener(Mask.insert(Utils.CEP_MASK, et_cep));
et_cep.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CEP_MASK.length())});
et_phone.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone));
et_phone.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_phone2.addTextChangedListener(Mask.insert(Utils.PHONE_MASK, et_phone2));
et_phone2.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.PHONE_MASK.length())});
et_cpf.addTextChangedListener(Mask.insert(Utils.CPF_MASK, et_cpf));
et_cpf.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.CPF_MASK.length())});
et_birthdate.addTextChangedListener(Mask.insert(Utils.BIRTH_DAY_MASK, et_birthdate));
et_birthdate.setFilters(new InputFilter[]{new InputFilter.LengthFilter(Utils.BIRTH_DAY_MASK.length())});
loadData();
et_cpf.setEnabled(false);
et_disability.setEnabled(false);
enableAllFields(false);
setButtonVisible(false);
final CollapsingToolbarLayout collapsingToolbarLayout;
collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
final AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar_account);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
float percentage = 1.5f * ((float) Math.abs(verticalOffset) / appBarLayout.getTotalScrollRange());
imgv_profile.setAlpha(1 - percentage);
btn_photo.setAlpha(1 - percentage);
}
});
collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.expandedappbar);
btn_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancelUpdate();
}
});
rb_no.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rb_yes.setChecked(false);
et_disability.setEnabled(false);
et_disability.setText("");
}
});
rb_yes.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rb_no.setChecked(false);
et_disability.setEnabled(true);
}
});
et_cep.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, final boolean hasFocus) {
if (hasFocus) {
et_cep.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) {
if (Mask.unmask(et_cep.getText().toString()).length() < 8) {
et_state.setText("");
et_city.setText("");
et_neighborhood.setText("");
et_address.setText("");
}
}
@Override
public void afterTextChanged(Editable s) {}
});
} else {
if(ConnectionChecker.hasConnection(getBaseContext())) {
presenter.onCepNotFocused(Mask.unmask(et_cep.getText().toString()));
}
else{
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_cep_connection_error));
if(connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
}
}
}
});
btn_update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
et_password_confirmation.requestFocus();
boolean validated = validateData();
if(validated){
if(ConnectionChecker.hasConnection(getBaseContext())){
if(!isChangingPassword){
presenter.onUpdateClicked();
}else{
getCurrentPassword();
}
}
else{
setNoConnection(true);
if( connectionErrorDialog == null){
connectionErrorDialog = new ConnectionErrorDialog();
}
Bundle bundle = new Bundle();
bundle.putString(ConnectionErrorDialog.DIALOG_MESSAGE, getString(R.string.dialog_no_connection_message));
connectionErrorDialog.setArguments(bundle);
connectionErrorDialog.show(getFragmentManager(), ConnectionErrorDialog.DIALOG_CONNECTION_ERROR);
scrollUp();
}
}
else{
scrollUp();
}
}
});
btn_photo.setClickable(true);
btn_photo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(!userImgHelper.existsPhoto(Utils.USR_PICT_FILE_NAME, id) || isPhotoDelete){
checkBuildVersion();
return;
}
android.support.v7.app.AlertDialog.Builder builderSingle = new android.support.v7.app.AlertDialog.Builder(AccountActivity.this);
//builderSingle.setIcon(R.drawable.ic_action_search);