Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
47af2d0
refactor: add support for build with sign key
JeelDobariya38 Aug 9, 2024
c7fa277
feature: add a script that build and install the apk
JeelDobariya38 Aug 9, 2024
c085c4e
feat: make a basic layout for saving passwords
JeelDobariya38 Aug 9, 2024
6a40d97
feat: enhance layout
JeelDobariya38 Aug 10, 2024
da8b060
feat: Made a Home Activity
JeelDobariya38 Aug 10, 2024
b218036
refactor: change onClickListener to use lambda function
JeelDobariya38 Aug 10, 2024
1418eae
feat: Made a load password activity
JeelDobariya38 Aug 11, 2024
47c0fa8
feat: make a load password layout
JeelDobariya38 Aug 11, 2024
1108a23
refactor: break the onCreate into multiple parts
JeelDobariya38 Aug 11, 2024
b8ec9af
feat: create a database
JeelDobariya38 Aug 11, 2024
6cc4f42
feat: made load password and save password functional
JeelDobariya38 Aug 11, 2024
370b0fb
refactor: reindented the files
JeelDobariya38 Aug 11, 2024
1daaff4
refactor: the id and strings
JeelDobariya38 Aug 11, 2024
8618742
update the app version
JeelDobariya38 Aug 11, 2024
e74921f
Update activity_main.xml
JeelDobariya38 Aug 11, 2024
3816680
Rename app/src/main/java/com/passwordmanager/LoadPasswordActivity.jav…
JeelDobariya38 Aug 11, 2024
30277c6
refactor: organize activity files in ui folders
JeelDobariya38 Aug 12, 2024
1b9e210
refactor: move hard code string to res.strings
JeelDobariya38 Aug 12, 2024
59a6bd0
refactor: implemented viewbinding
JeelDobariya38 Aug 12, 2024
4c679e5
refactor: context in all layout files
JeelDobariya38 Aug 12, 2024
b3a6961
feat: make a password view activity
JeelDobariya38 Aug 12, 2024
8b0a5db
feat: implement delete feature
JeelDobariya38 Aug 12, 2024
b65961b
Update ViewPasswordActivity.java
JeelDobariya38 Aug 12, 2024
48098de
feat: create a update activity
JeelDobariya38 Aug 12, 2024
6a31a7d
fix: the datetime('now') inserted as string
JeelDobariya38 Aug 12, 2024
c24dab6
feat: create password list in load password activity
JeelDobariya38 Aug 12, 2024
67212f7
refactor: make code consistent
JeelDobariya38 Aug 12, 2024
88ef34d
Merge branch 'main' into jeel-dev-layout
JeelDobariya38 Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
.externalNativeBuild
.cxx
local.properties
keystore.properties
*.jks
41 changes: 35 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,50 @@ android {
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"
versionName "0.1.0-Alpha"
}

viewBinding {
enabled = true
}

signingConfigs {
release {
storeFile file("passwordmanager.jks")
storePassword 'beMbDcv94lv3'
keyAlias 'passwordmanager'
keyPassword 'beMbDcv94lv3'
def keystorePropertiesFile = rootProject.file("keystore.properties")
if (keystorePropertiesFile.exists()) {
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
}

splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}

lintOptions {
// You can enable lint checking and provide a baseline file if needed:
// baseline file("lint-baseline.xml")

// To ensure that lint uses the lint.xml configuration
lintConfig rootProject.file("lint.xml")
}

buildTypes {
release {
signingConfig signingConfigs.release
if (rootProject.file("keystore.properties").exists()) {
signingConfig signingConfigs.release
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />

<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
Expand All @@ -25,14 +26,18 @@
android:supportsRtl="true"
android:theme="@style/PasswordManagerTheme">
<activity
android:name=".MainActivity"
android:name=".ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.SavePasswordActivity" />
<activity android:name=".ui.LoadPasswordActivity" />
<activity android:name=".ui.ViewPasswordActivity" />
<activity android:name=".ui.UpdatePasswordActivity" />
</application>

</manifest>
41 changes: 0 additions & 41 deletions app/src/main/java/com/passwordmanager/MainActivity.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.passwordmanager.database;

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

public class MyDatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "master.db";
private static final int DATABASE_VERSION = 1;

public static final String PASSWORDS_TABLE = "passwords";

// SQL statement to create a passwords table.
private static final String CREATE_PASSWORDS_TABLE = "CREATE TABLE IF NOT EXISTS " + PASSWORDS_TABLE + " (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"domain VARCHAR(40) NOT NULL, " +
"username VARCHAR(60) NOT NULL, " +
"password VARCHAR(60) NOT NULL, " +
"notes VARCHAR(100), " +
"createdat DATE DEFAULT CURRENT_TIMESTAMP, " +
"updatedat DATE DEFAULT CURRENT_TIMESTAMP);";


public MyDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
// Create passwords table.
db.execSQL(CREATE_PASSWORDS_TABLE);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// not Implemented a not needed.
return;
}
}
111 changes: 111 additions & 0 deletions app/src/main/java/com/passwordmanager/models/PasswordModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package com.passwordmanager.models;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class PasswordModel {
private int id; // Primary key of passwords table.
private String domain; // Domain associated with password entity.
private String username; // Username associated with password entity.
private String password; // Password of password entity.
private String notes; // Notes associated with the password entity.
private String createdAt; // Date of password entity when the entity was first saved.
private String updatedAt; // Date of password entity when the entity was last updated.

// Constructor to initialize a new password model without an ID.
public PasswordModel(String domain, String username, String password, String notes) {
this.domain = domain;
this.username = username;
this.password = password;
this.notes = notes;

// Retrieve the current date and time
LocalDateTime currentDate = LocalDateTime.now();

// Formatting the time so that it is better seen by users
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
this.createdAt = currentDate.format(formatter);
this.updatedAt = currentDate.format(formatter);
}

// Constructor with ID (e.g., when fetching from the database)
public PasswordModel(int id, String domain, String username, String password, String notes, String createdAt, String updatedAt) {
this.id = id;
this.domain = domain;
this.username = username;
this.password = password;
this.notes = notes;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
}

// Getters and Setters
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getDomain() {
return domain;
}

public void setDomain(String domain) {
this.domain = domain;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getNotes() {
return notes;
}

public void setNotes(String notes) {
this.notes = notes;
}

public String getCreatedAt() {
return createdAt;
}

public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}

public String getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(String updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public String toString() {
return "PasswordModel{" +
"id=" + id +
", domain='" + domain + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", notes='" + notes + '\'' +
", createdAt='" + createdAt + '\'' +
", updatedAt='" + updatedAt + '\'' +
'}';
}
}
60 changes: 60 additions & 0 deletions app/src/main/java/com/passwordmanager/ui/LoadPasswordActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.passwordmanager.ui;

import android.os.Bundle;
import android.content.Intent;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.WindowCompat;

import com.passwordmanager.R;
import com.passwordmanager.utils.Controller;
import com.passwordmanager.models.PasswordModel;
import com.passwordmanager.databinding.ActivityLoadPasswordBinding;
import com.passwordmanager.ui.adapter.PasswordAdapter;

import java.util.List;

public class LoadPasswordActivity extends AppCompatActivity {
private ActivityLoadPasswordBinding binding;
private PasswordAdapter passwordAdapter;
private Controller controller;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityLoadPasswordBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

// Add event onclick listener
addOnClickListenerOnButton();

// Make window fullscreen
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
}

private void fillPasswordList() {
controller = new Controller(LoadPasswordActivity.this);

List<PasswordModel> passwordList = controller.getAllPasswords();
passwordAdapter = new PasswordAdapter(this, passwordList);
binding.passwordList.setAdapter(passwordAdapter);
}

// Added all the onclick event listiners
private void addOnClickListenerOnButton() {
binding.passwordList.setOnItemClickListener((parent, view, position, id) -> {
PasswordModel selectedPassword = (PasswordModel) passwordAdapter.getItem(position);

// Do something with the selectedPassword
Intent intent = new Intent(LoadPasswordActivity.this, ViewPasswordActivity.class);
intent.putExtra("id", selectedPassword.getId());
startActivity(intent);
});
}

@Override
protected void onResume() {
super.onResume();
fillPasswordList();
}
}
Loading