Skip to content

Commit

Permalink
Merge pull request #7 from nks102000/master
Browse files Browse the repository at this point in the history
final
  • Loading branch information
Aaryaman-Bhardwaj authored Jul 6, 2021
2 parents 141a1a5 + 9dbc2c3 commit 0c7d4d6
Show file tree
Hide file tree
Showing 30 changed files with 193 additions and 180 deletions.
8 changes: 4 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aaryaman.gstdatamaster">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand All @@ -12,7 +12,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.GSTDataMaster">
<activity android:name=".SplashScreen">
<activity android:name=".Splash" android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions app/src/main/java/com/aaryaman/gstdatamaster/Login.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.aaryaman.gstdatamaster

import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.aaryaman.gstdatamaster.utils.UserInfo
import kotlinx.android.synthetic.main.activity_login.*

class Login : AppCompatActivity() {
lateinit var shp:SharedPreferences
lateinit var shpEditor:SharedPreferences.Editor

override fun onStart() {
super.onStart()
checkLogin()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)

shp=getSharedPreferences("Login", MODE_PRIVATE)
checkLogin()

loginBtn.setOnClickListener {
val name=name.text
val phNo=phNo.text
if(name.toString() != "" || phNo.toString() != ""){
UserInfo.myName=name.toString()
UserInfo.phNo=phNo.toString()
doLogin(name.toString())
}
}
}

private fun doLogin(name:String) {
if (shp == null)
shp = getSharedPreferences("myPreferences", MODE_PRIVATE)

shpEditor = shp.edit()
shpEditor.putString("name", name)
shpEditor.commit()
val intent=Intent(this,MainActivity::class.java)
startActivity(intent)
}

private fun checkLogin() {
if (shp == null) shp = getSharedPreferences("myPreferences", MODE_PRIVATE)

val userName: String? = shp.getString("name", "")

if (userName != null && userName != "") {
val i = Intent(this@Login, MainActivity::class.java)
startActivity(i)
finish()
}
}
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/aaryaman/gstdatamaster/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.os.Bundle
import android.widget.TextView
import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController
import com.aaryaman.gstdatamaster.utils.UserInfo
import com.google.android.material.bottomnavigation.BottomNavigationView

class MainActivity : AppCompatActivity() {
Expand All @@ -18,6 +19,6 @@ class MainActivity : AppCompatActivity() {
bottomNavigationView.setupWithNavController(navController)

UserName1=findViewById(R.id.UserName1)
UserName1.text=UserInfo.Myname(this)
UserName1.text= UserInfo.myName
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/aaryaman/gstdatamaster/Splash.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.aaryaman.gstdatamaster

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler

class Splash : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)
val hand=Handler()
hand.postDelayed(
{startActivity(Intent(this,Login::class.java))},1000
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.aaryaman.gstdatamaster.utils

object UserInfo {
var myName:String="USER"
var phNo:String=""

}
Binary file added app/src/main/res/drawable-v24/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-v24/user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 0 additions & 170 deletions app/src/main/res/drawable/ic_launcher_background.xml

This file was deleted.

58 changes: 58 additions & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0bceb2"
android:orientation="vertical"
android:padding="10dp"
tools:context=".Login">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/logo"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:layout_marginBottom="100dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Name"
android:id="@+id/name"
android:layout_gravity="center"
android:textColorHint="@color/black"
android:backgroundTint="@color/black"
android:foregroundTint="@color/black"
/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Phone Number"
android:id="@+id/phNo"
android:layout_gravity="center"
android:textColorHint="@color/black"
android:backgroundTint="@color/black"
android:foregroundTint="@color/black"
/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:id="@+id/loginBtn"
android:layout_marginTop="20dp"
android:background="#0bceb2"
android:textColor="@color/white"/>
</LinearLayout>



</ScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="30dp"
android:layout_marginEnd="20dp"
android:src="@drawable/profilepic1"/>
android:src="@drawable/user"/>
</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
Loading

0 comments on commit 0c7d4d6

Please sign in to comment.