Skip to content

Commit 052c80d

Browse files
author
Talha
committed
Initial commit
0 parents  commit 052c80d

File tree

93 files changed

+3896
-0
lines changed

Some content is hidden

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

93 files changed

+3896
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
plugins {
2+
id 'com.android.application'
3+
}
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "30.0.2"
8+
9+
defaultConfig {
10+
applicationId "com.icode.easynote"
11+
minSdkVersion 16
12+
targetSdkVersion 30
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
compileOptions {
26+
sourceCompatibility JavaVersion.VERSION_1_8
27+
targetCompatibility JavaVersion.VERSION_1_8
28+
}
29+
}
30+
31+
dependencies {
32+
33+
implementation 'androidx.appcompat:appcompat:1.2.0'
34+
implementation 'com.google.android.material:material:1.3.0'
35+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
36+
testImplementation 'junit:junit:4.13.2'
37+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
38+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
39+
40+
//Material Design
41+
implementation 'com.google.android.material:material:1.3.0'
42+
43+
//Scalable Unit/Text Size
44+
implementation 'com.intuit.sdp:sdp-android:1.0.6'
45+
implementation 'com.intuit.ssp:ssp-android:1.0.6'
46+
47+
//Glide
48+
implementation 'com.github.bumptech.glide:glide:4.12.0'
49+
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
50+
51+
//Google Play services
52+
implementation 'com.google.android.gms:play-services-auth:19.0.0'
53+
54+
//Lottie
55+
implementation 'com.airbnb.android:lottie:3.6.1'
56+
57+
//CircleImageView
58+
implementation 'de.hdodenhof:circleimageview:3.1.0'
59+
60+
//RoundedImageView
61+
implementation 'com.makeramen:roundedimageview:2.3.0'
62+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.icode.easynote;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest {
20+
@Test
21+
public void useAppContext() {
22+
// Context of the app under test.
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24+
assertEquals("com.icode.easynote", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.icode.easynote">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
7+
8+
<application
9+
android:allowBackup="true"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:requestLegacyExternalStorage="true"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity
17+
android:name=".activities.LoginActivity"
18+
android:screenOrientation="portrait"
19+
android:windowSoftInputMode="stateAlwaysHidden">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
<activity
26+
android:name=".activities.MainActivity"
27+
android:screenOrientation="portrait"
28+
android:windowSoftInputMode="stateAlwaysHidden" />
29+
</application>
30+
31+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
package com.icode.easynote.activities;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.content.Context;
6+
import android.content.Intent;
7+
import android.content.SharedPreferences;
8+
import android.os.Bundle;
9+
import android.util.Log;
10+
import android.view.LayoutInflater;
11+
import android.view.View;
12+
import android.widget.Button;
13+
import android.widget.EditText;
14+
import android.widget.LinearLayout;
15+
import android.widget.ProgressBar;
16+
import android.widget.RelativeLayout;
17+
18+
import com.google.android.gms.auth.api.signin.GoogleSignIn;
19+
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
20+
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
21+
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
22+
import com.google.android.gms.common.api.ApiException;
23+
import com.google.android.gms.tasks.Task;
24+
import com.google.android.material.bottomsheet.BottomSheetDialog;
25+
import com.icode.easynote.R;
26+
27+
public class LoginActivity extends AppCompatActivity {
28+
29+
ProgressBar progressBar;
30+
GoogleSignInClient mGoogleSignInClient;
31+
private static final int RC_SIGN_IN = 0;
32+
SharedPreferences sharedPreferences;
33+
34+
@Override
35+
protected void onStart() {
36+
super.onStart();
37+
// Check for existing Google Sign In account, if the user is already signed in
38+
// the GoogleSignInAccount will be non-null.
39+
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
40+
updateUI(account);
41+
42+
if (sharedPreferences.getBoolean("LOGGED_IN", false)) {
43+
toMainActivity();
44+
}
45+
}
46+
47+
@Override
48+
protected void onCreate(Bundle savedInstanceState) {
49+
super.onCreate(savedInstanceState);
50+
setContentView(R.layout.activity_login);
51+
progressBar = findViewById(R.id.progress_circular);
52+
sharedPreferences = getSharedPreferences("PREF", MODE_PRIVATE);
53+
;
54+
55+
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
56+
.requestEmail()
57+
.build();
58+
59+
// Build a GoogleSignInClient with the options specified by gso.
60+
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
61+
62+
RelativeLayout g_login = findViewById(R.id.btn_loginGoogle);
63+
g_login.setOnClickListener(v -> signIn());
64+
65+
Button login = findViewById(R.id.btn_login);
66+
login.setOnClickListener(v -> {
67+
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(LoginActivity.this, R.style.BottomSheetDialogTheme);
68+
View view = LayoutInflater.from(LoginActivity.this).inflate(R.layout.layout_bottom_sheet_login, (LinearLayout) findViewById(R.id.layout_bottom_sheet_login));
69+
view.findViewById(R.id.btn_continue).setOnClickListener(vv -> {
70+
EditText inputName = view.findViewById(R.id.input_name);
71+
String name = inputName.getText().toString().trim();
72+
if (name.isEmpty()) {
73+
inputName.setError("Name can't be empty!");
74+
} else {
75+
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
76+
SharedPreferences.Editor editor = sharedPreferences.edit();
77+
editor.putString("NAME", name);
78+
editor.putBoolean("LOGGED_IN", true);
79+
editor.apply();
80+
bottomSheetDialog.dismiss();
81+
startActivity(intent);
82+
finish();
83+
}
84+
});
85+
view.findViewById(R.id.btn_cancel).setOnClickListener(vv -> bottomSheetDialog.dismiss());
86+
bottomSheetDialog.setContentView(view);
87+
bottomSheetDialog.show();
88+
});
89+
}
90+
91+
private void updateUI(GoogleSignInAccount account) {
92+
if (account != null) {
93+
toMainActivity();
94+
}
95+
}
96+
97+
void toMainActivity() {
98+
startActivity(new Intent(LoginActivity.this, MainActivity.class));
99+
finish();
100+
}
101+
102+
private void signIn() {
103+
progressBar.setVisibility(View.VISIBLE);
104+
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
105+
startActivityForResult(signInIntent, RC_SIGN_IN);
106+
}
107+
108+
@Override
109+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
110+
super.onActivityResult(requestCode, resultCode, data);
111+
112+
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
113+
if (requestCode == RC_SIGN_IN) {
114+
// The Task returned from this call is always completed, no need to attach
115+
// a listener.
116+
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
117+
handleSignInResult(task);
118+
}
119+
}
120+
121+
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
122+
try {
123+
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
124+
// Signed in successfully, show authenticated UI.
125+
progressBar.setVisibility(View.GONE);
126+
updateUI(account);
127+
} catch (ApiException e) {
128+
// The ApiException status code indicates the detailed failure reason.
129+
// Please refer to the GoogleSignInStatusCodes class reference for more information.
130+
Log.w("LOGIN ERROR", "signInResult:failed code=" + e.getStatusCode());
131+
progressBar.setVisibility(View.GONE);
132+
updateUI(null);
133+
}
134+
}
135+
}

0 commit comments

Comments
 (0)