-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nks102000/master
final
- Loading branch information
Showing
30 changed files
with
193 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/aaryaman/gstdatamaster/utils/UserInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="" | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.