Skip to content

Commit ee99de1

Browse files
authored
Add files via upload
1 parent 96fd2b6 commit ee99de1

File tree

4 files changed

+336
-0
lines changed

4 files changed

+336
-0
lines changed

MainActivity.java.txt

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.example.securesharedpreference;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
import androidx.security.crypto.EncryptedSharedPreferences;
5+
import androidx.security.crypto.MasterKeys;
6+
7+
/////////////////////////////////Made By Divyam Oza(OD)////////////////////////////
8+
import android.content.Intent;
9+
import android.content.SharedPreferences;
10+
import android.os.Bundle;
11+
import android.view.View;
12+
import android.widget.Button;
13+
import android.widget.CheckBox;
14+
import android.widget.EditText;
15+
import android.widget.ImageView;
16+
import android.widget.TextView;
17+
import android.widget.Toast;
18+
19+
import com.bumptech.glide.Glide;
20+
21+
import java.io.IOException;
22+
import java.security.GeneralSecurityException;
23+
24+
public class MainActivity extends AppCompatActivity {
25+
EditText et_username,et_password;
26+
Button submitbtn;
27+
TextView textView;
28+
SharedPreferences sharedPreferences;
29+
SharedPreferences.Editor editor;
30+
Boolean savelogin;
31+
CheckBox savecheck;
32+
ImageView logo,unmlogo,passlogo;
33+
34+
/////////////////////////////////Made By Divyam Oza(OD)////////////////////////////
35+
@Override
36+
protected void onCreate(Bundle savedInstanceState) {
37+
super.onCreate(savedInstanceState);
38+
setContentView(R.layout.activity_main);
39+
40+
et_username = findViewById(R.id.et_username);
41+
et_password = findViewById(R.id.et_password);
42+
submitbtn = findViewById(R.id.btnsave);
43+
savecheck = findViewById(R.id.rememberme);
44+
logo = findViewById(R.id.logo);
45+
unmlogo = findViewById(R.id.unmlogo);
46+
passlogo = findViewById(R.id.passlogo);
47+
48+
//IMAGES get through Glide//
49+
Glide.with(getApplicationContext()).load("https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/Ei-sc-github.svg/768px-Ei-sc-github.svg.png").into(logo);
50+
Glide.with(getApplicationContext()).load("https://i.pinimg.com/originals/e4/fb/d4/e4fbd41a84015e49d95baddee5275043.png").into(unmlogo);
51+
Glide.with(getApplicationContext()).load("https://www.lockitsolutions.com/blog/wp-content/uploads/2015/05/lockitLogo.png").into(passlogo);
52+
//IMAGES get through Glide//
53+
54+
55+
try {
56+
String masterKeys = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
57+
sharedPreferences = EncryptedSharedPreferences.create("FILE",
58+
masterKeys,
59+
getApplicationContext(),
60+
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
61+
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM);
62+
63+
} catch (GeneralSecurityException e) {
64+
e.printStackTrace();
65+
} catch (IOException e) {
66+
e.printStackTrace();
67+
}
68+
/////////////////////////////////Made By Divyam Oza(OD)////////////////////////////
69+
editor =sharedPreferences.edit();
70+
71+
submitbtn.setOnClickListener(new View.OnClickListener() {
72+
@Override
73+
public void onClick(View view) {
74+
login();
75+
}
76+
});
77+
savelogin = sharedPreferences.getBoolean("savelogin",true);
78+
if (savelogin==true)
79+
{
80+
et_username.setText(sharedPreferences.getString("username",null));
81+
et_password.setText(sharedPreferences.getString("password",null));
82+
}
83+
84+
if(et_username.getText().toString().equals("divyamoza") && et_password.getText().toString().equals("divyam123"))
85+
{
86+
Intent intent = new Intent(getApplicationContext(),MainActivity2.class);
87+
startActivity(intent);
88+
}
89+
90+
91+
/////////////////////////////////Made By Divyam Oza(OD)////////////////////////////
92+
}
93+
94+
private void login()
95+
{
96+
String username = et_username.getText().toString();
97+
String password = et_password.getText().toString();
98+
99+
if(username.equals("divyamoza") && password.equals("divyam123"))
100+
{
101+
Toast.makeText(this, "Welcome", Toast.LENGTH_SHORT).show();
102+
Intent intent = new Intent(getApplicationContext(),MainActivity2.class);
103+
startActivity(intent);
104+
}
105+
/////////////////////////////////Made By Divyam Oza(OD)////////////////////////////
106+
if(savecheck.isChecked())
107+
{
108+
editor.putBoolean("savelogin",true);
109+
editor.putString("username",username);
110+
editor.putString("password",password);
111+
editor.commit();
112+
}
113+
/////////////////////////////////Made By Divyam Oza(OD)////////////////////////////
114+
}
115+
}

Manifest.xml.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.securesharedpreference">
4+
<uses-permission android:name="android.permission.INTERNET"/>
5+
6+
<application
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/AppTheme"
13+
android:usesCleartextTraffic="true">
14+
<activity android:name=".MainActivity2"></activity>
15+
<activity android:name=".MainActivity"
16+
>
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>

activity_main.xml.txt

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".MainActivity"
8+
android:background="@drawable/mainback">
9+
10+
<de.hdodenhof.circleimageview.CircleImageView
11+
android:layout_width="120dp"
12+
android:layout_height="100dp"
13+
android:layout_marginTop="70dp"
14+
app:layout_constraintEnd_toEndOf="parent"
15+
app:layout_constraintStart_toStartOf="parent"
16+
app:layout_constraintTop_toTopOf="@+id/linearLayout"
17+
android:id="@+id/logo"/>
18+
19+
<!-- Made By Divyam Oza(OD)-->
20+
<!-- -->
21+
22+
<LinearLayout
23+
android:id="@+id/linearLayout"
24+
android:layout_width="match_parent"
25+
android:layout_height="match_parent"
26+
android:layout_gravity="center"
27+
android:gravity="center"
28+
android:orientation="vertical">
29+
30+
<LinearLayout
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content"
33+
android:layout_marginLeft="25dp"
34+
android:layout_marginRight="25dp"
35+
android:layout_marginBottom="15dp"
36+
android:background="@drawable/etback"
37+
android:orientation="horizontal">
38+
39+
<ImageView
40+
android:layout_width="40dp"
41+
android:layout_height="30dp"
42+
android:layout_gravity="center"
43+
44+
android:tint="@android:color/white"
45+
android:layout_marginLeft="5dp"
46+
android:id="@+id/unmlogo"/>
47+
48+
<EditText
49+
android:id="@+id/et_username"
50+
android:layout_width="match_parent"
51+
android:layout_height="30dp"
52+
android:layout_marginLeft="10dp"
53+
android:layout_marginRight="30dp"
54+
android:layout_marginBottom="10dp"
55+
android:background="@null"
56+
android:gravity="center_vertical"
57+
android:drawableTint="@android:color/white"
58+
android:hint="User Name "
59+
android:singleLine="true"
60+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
61+
android:textColor="@android:color/white"
62+
android:textColorHint="@android:color/white"
63+
android:layout_gravity="start"
64+
android:fontFamily="sans-serif-condensed"
65+
/>
66+
67+
</LinearLayout>
68+
69+
<LinearLayout
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content"
72+
android:layout_marginLeft="25dp"
73+
android:layout_marginRight="25dp"
74+
android:background="@drawable/etback"
75+
android:orientation="horizontal">
76+
77+
<!-- Made By Divyam Oza(OD)-->
78+
<!-- -->
79+
80+
<ImageView
81+
android:layout_width="40dp"
82+
android:layout_height="30dp"
83+
android:layout_gravity="center"
84+
android:tint="@android:color/white"
85+
android:layout_marginLeft="5dp"
86+
android:id="@+id/passlogo"/>
87+
88+
<EditText
89+
android:id="@+id/et_password"
90+
android:layout_width="match_parent"
91+
android:layout_height="30dp"
92+
android:layout_marginLeft="10dp"
93+
android:layout_marginRight="30dp"
94+
android:layout_marginBottom="10dp"
95+
android:background="@null"
96+
android:layout_gravity="start|center_horizontal"
97+
android:drawableTint="@android:color/white"
98+
android:hint="Password "
99+
android:password="true"
100+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
101+
android:textColor="@android:color/white"
102+
android:textColorHint="@android:color/white"
103+
android:gravity="start|center_vertical"
104+
android:fontFamily="sans-serif-condensed"/>
105+
106+
</LinearLayout>
107+
108+
<CheckBox
109+
android:id="@+id/rememberme"
110+
android:layout_width="wrap_content"
111+
android:layout_height="wrap_content"
112+
android:layout_gravity="start"
113+
android:layout_marginLeft="30dp"
114+
android:layout_marginTop="10dp"
115+
android:layout_marginBottom="20sp"
116+
android:buttonTint="@android:color/white"
117+
android:text="Remember Me"
118+
android:textColor="@android:color/white"
119+
android:textStyle="italic"
120+
android:fontFamily="monospace"/>
121+
122+
<!-- Made By Divyam Oza(OD)-->
123+
<!-- -->
124+
<Button
125+
android:id="@+id/btnsave"
126+
android:layout_width="match_parent"
127+
android:layout_height="wrap_content"
128+
android:layout_marginLeft="25dp"
129+
android:layout_marginRight="25dp"
130+
android:background="@drawable/btnback"
131+
android:fontFamily="sans-serif-condensed"
132+
android:text="SUBMIT"
133+
android:textAppearance="@style/TextAppearance.AppCompat.Large"
134+
android:textColor="#fc3f61"
135+
android:textSize="25dp"
136+
android:textStyle="bold" />
137+
138+
</LinearLayout>
139+
</androidx.constraintlayout.widget.ConstraintLayout>

drawable designs.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
etback.xml
2+
<?xml version="1.0" encoding="utf-8"?>
3+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
4+
<corners
5+
6+
android:radius="50dp"/>
7+
8+
<!-- Made By Divyam Oza(OD)-->
9+
<!-- -->
10+
11+
<solid
12+
android:color="#feaaae"/>
13+
14+
<!-- Made By Divyam Oza(OD)-->
15+
<!-- -->
16+
17+
</shape>
18+
19+
20+
21+
22+
btnback.xml
23+
24+
<?xml version="1.0" encoding="utf-8"?>
25+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
26+
<corners
27+
android:radius="50dp"
28+
/>
29+
30+
<!-- Made By Divyam Oza(OD)-->
31+
<!-- -->
32+
33+
<solid
34+
android:color="@android:color/white"/>
35+
36+
<!-- Made By Divyam Oza(OD)-->
37+
<!-- -->
38+
39+
</shape>
40+
41+
42+
43+
mainback.xml
44+
45+
<?xml version="1.0" encoding="utf-8"?>
46+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
47+
<gradient
48+
android:startColor="#fe7062"
49+
android:centerColor="#ff5c61"
50+
android:endColor="#fc3f61"
51+
android:angle="225"
52+
android:useLevel="true"/>
53+
54+
<!-- Made By Divyam Oza(OD)-->
55+
<!-- -->
56+
57+
</shape>

0 commit comments

Comments
 (0)