-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 24 | ||
buildToolsVersion "24.0.3" | ||
defaultConfig { | ||
applicationId "com.hendiware.hendienger" | ||
minSdkVersion 15 | ||
targetSdkVersion 24 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
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:24.2.1' | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:design:24.2.1' | ||
compile 'com.hendiware.utils:futils:1.6.91' | ||
compile 'com.jakewharton:butterknife:8.4.0' | ||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' | ||
compile 'com.squareup.retrofit2:retrofit:2.1.0' | ||
compile 'com.squareup.retrofit2:converter-gson:2.1.0' | ||
|
||
|
||
} | ||
apply plugin: 'com.jakewharton.butterknife' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Volumes/Data/AndroidSdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hendiware.hendienger; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.hendiware.hendienger", appContext.getPackageName()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.hendiware.hendienger"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/SplashTheme"> | ||
<activity android:name=".SplashActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".LoginActivity" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
<activity | ||
android:name=".RegisterActivity" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/title_activity_main" | ||
android:theme="@style/AppTheme.NoActionBar" /> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package com.hendiware.hendienger; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
import android.widget.ProgressBar; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import com.fourhcode.forhutils.FUtilsValidation; | ||
import com.hendiware.hendienger.models.MainResponse; | ||
import com.hendiware.hendienger.models.User; | ||
import com.hendiware.hendienger.webservices.WebService; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
|
||
public class LoginActivity extends AppCompatActivity { | ||
private final String TAG = "LoginActivity"; | ||
|
||
@BindView(R.id.img_header_logo) | ||
ImageView imgHeaderLogo; | ||
@BindView(R.id.tv_login) | ||
TextView tvLogin; | ||
@BindView(R.id.et_email) | ||
EditText etEmail; | ||
@BindView(R.id.et_password) | ||
EditText etPassword; | ||
@BindView(R.id.lnlt_inputs_container) | ||
LinearLayout lnltInputsContainer; | ||
@BindView(R.id.tv_dont_have_account) | ||
TextView tvDontHaveAccount; | ||
@BindView(R.id.btn_login) | ||
Button btnLogin; | ||
@BindView(R.id.rllt_body) | ||
RelativeLayout rlltBody; | ||
@BindView(R.id.prgs_loading) | ||
ProgressBar prgsLoading; | ||
@BindView(R.id.rllt_loading) | ||
RelativeLayout rlltLoading; | ||
@BindView(R.id.activity_login) | ||
RelativeLayout activityLogin; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_login); | ||
ButterKnife.bind(this); | ||
} | ||
|
||
@OnClick({R.id.tv_dont_have_account, R.id.btn_login}) | ||
public void onClick(View view) { | ||
switch (view.getId()) { | ||
case R.id.tv_dont_have_account: | ||
Intent intent = new Intent(this, RegisterActivity.class); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | ||
startActivity(intent); | ||
// override default transation of activity | ||
this.overridePendingTransition(R.anim.enter_from_left, R.anim.exit_out_right); | ||
|
||
break; | ||
case R.id.btn_login: | ||
|
||
if (!FUtilsValidation.isEmpty(etEmail, getString(R.string.enter_email)) | ||
&& FUtilsValidation.isValidEmail(etEmail, getString(R.string.enter_valid_email)) | ||
&& !FUtilsValidation.isEmpty(etPassword, getString(R.string.enter_password)) | ||
) { | ||
setLoadingMode(); | ||
// create new user | ||
User user = new User(); | ||
user.email = etEmail.getText().toString(); | ||
user.password = etPassword.getText().toString(); | ||
// login User using Retrofit | ||
WebService.getInstance().getApi().loginUser(user).enqueue(new Callback<MainResponse>() { | ||
@Override | ||
public void onResponse(Call<MainResponse> call, Response<MainResponse> response) { | ||
// check for status value comming from server (response of login-user.php file status) | ||
if (response.body().status == 2) { | ||
Toast.makeText(LoginActivity.this, response.body().message, Toast.LENGTH_SHORT).show(); | ||
|
||
} else if (response.body().status == 1) { | ||
Toast.makeText(LoginActivity.this, response.body().message, Toast.LENGTH_SHORT).show(); | ||
Intent goToMain = new Intent(LoginActivity.this, MainActivity.class); | ||
startActivity(goToMain); | ||
finish(); | ||
|
||
} else { | ||
Toast.makeText(LoginActivity.this, response.body().message, Toast.LENGTH_SHORT).show(); | ||
} | ||
setNormalMode(); | ||
} | ||
|
||
@Override | ||
public void onFailure(Call<MainResponse> call, Throwable t) { | ||
// print error message in logcat | ||
Log.e(TAG, t.getLocalizedMessage()); | ||
|
||
} | ||
}); | ||
|
||
|
||
} | ||
break; | ||
|
||
} | ||
} | ||
|
||
// set loading layout visible and hide body layout | ||
private void setLoadingMode() { | ||
rlltLoading.setVisibility(View.VISIBLE); | ||
rlltBody.setVisibility(View.GONE); | ||
} | ||
|
||
// set body layout visible and hide loading layout | ||
private void setNormalMode() { | ||
rlltLoading.setVisibility(View.GONE); | ||
rlltBody.setVisibility(View.VISIBLE); | ||
} | ||
} |