Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JapneetRajput committed Dec 8, 2021
0 parents commit 78a691d
Show file tree
Hide file tree
Showing 51 changed files with 1,287 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
id 'com.android.application'
}

android {
compileSdk 31

defaultConfig {
applicationId "com.example.workflow"
minSdk 16
targetSdk 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# 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 *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.workflow;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented 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() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.workflow", appContext.getPackageName());
}
}
32 changes: 32 additions & 0 deletions app/src/main/AndroidManifest.xml
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.example.workflow">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.WorkFlow">
<activity
android:name=".Profile"
android:exported="false" />
<activity
android:name=".HomeActivity"
android:exported="false" />
<activity
android:name=".Register"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
68 changes: 68 additions & 0 deletions app/src/main/java/com/example/workflow/DbHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.example.workflow;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DbHandler extends SQLiteOpenHelper {
public static final String DBNAME = "Login.db";

public DbHandler(Context context) {
super(context, "Login.db", null, 1);
}


@Override
public void onCreate(SQLiteDatabase MyDB) {
MyDB.execSQL("CREATE TABLE employee (emp_id Integer Primary Key Autoincrement, first_name Text, Surname Text, Username Text, Password Text)");
}

@Override
public void onUpgrade(SQLiteDatabase MyDB, int oldVersion, int newVersion) {
MyDB.execSQL("Drop Table if exists employee");
}

public Boolean addEmployee(String Fname, String Sname, String Uname, String Pword){
SQLiteDatabase MyDB = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("first_name", Fname);
values.put("Surname", Sname);
values.put("Username", Uname);
values.put("Password", Pword);
long result = MyDB.insert("employee", null, values);
if(result==-1) return false;
else return true;
}
public Boolean checkusername(String username){
SQLiteDatabase MyDB = this.getReadableDatabase();
Cursor cursor = MyDB.rawQuery("Select * from employee where username = ?", new String[]{username});
if(cursor.getCount()>0)
return false;
else
return true;
}
public Boolean checkuserpass(String username,String Pass){
SQLiteDatabase MyDB = this.getReadableDatabase();
Cursor cursor = MyDB.rawQuery("Select * from employee where Username = ? and Password =?", new String[]{username,Pass});
if(cursor.getCount()>0)
return true;
else
return false;

}
// public String getName(String username){
// SQLiteDatabase MyDB = this.getReadableDatabase();
// Cursor cursor = MyDB.rawQuery("Select first_name from employee where Username = ?" , new String[]{username});
// final int nameIndex = cursor.getColumnIndex("first_name");
// String name;
// do {
// name = cursor.getString(nameIndex);
// }while(cursor.moveToNext());
// return name;
// }

}
29 changes: 29 additions & 0 deletions app/src/main/java/com/example/workflow/HomeActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.workflow;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class HomeActivity extends AppCompatActivity {
TextView textView,profile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
textView = findViewById(R.id.textView3);
profile = findViewById(R.id.profile);
Intent intent=getIntent();
String s=intent.getStringExtra(MainActivity.Extra_NAME);
textView.setText("Welcome "+s);
profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(HomeActivity.this,Profile.class);
startActivity(intent);
}
});
}
}
56 changes: 56 additions & 0 deletions app/src/main/java/com/example/workflow/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.workflow;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
public static final String Extra_NAME="com.example.workflow.extra.NAME";
Button login,register;
EditText pass ;
AutoCompleteTextView user;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
login = findViewById(R.id.login);
user = findViewById(R.id.Username);
pass = findViewById(R.id.editTextPass);
register = findViewById(R.id.register);
DbHandler db=new DbHandler(this);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent= new Intent(getApplicationContext(),Register.class);
startActivity(intent);
}
});
login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username= user.getText().toString();
String password= pass.getText().toString();
if(username.equals("")||password.equals(""))
Toast.makeText(MainActivity.this, "* All fields are mandatory", Toast.LENGTH_SHORT).show();
else{
if(db.checkusername(username))
Toast.makeText(MainActivity.this, "User doesn't exist! Please register", Toast.LENGTH_SHORT).show();
else if(db.checkuserpass(username,password)){
Toast.makeText(MainActivity.this, "Logged in successfully", Toast.LENGTH_SHORT).show();
Intent intent=new Intent(getApplicationContext(),HomeActivity.class);
intent.putExtra(Extra_NAME,username);
startActivity(intent);
}
else
Toast.makeText(MainActivity.this, "Invalid Credentials", Toast.LENGTH_SHORT).show();
}
}
});
}
}
14 changes: 14 additions & 0 deletions app/src/main/java/com/example/workflow/Profile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.workflow;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class Profile extends AppCompatActivity {

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

0 comments on commit 78a691d

Please sign in to comment.