Created Notes Activity and Defined recycler
This commit is contained in:
parent
a3aa30c6d7
commit
d49918d8c4
|
|
@ -10,7 +10,7 @@
|
||||||
<component name="VisualizationToolProject">
|
<component name="VisualizationToolProject">
|
||||||
<option name="state">
|
<option name="state">
|
||||||
<ProjectState>
|
<ProjectState>
|
||||||
<option name="scale" value="0.053000877083072294" />
|
<option name="scale" value="0.28396739130434784" />
|
||||||
</ProjectState>
|
</ProjectState>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ android {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -33,6 +36,8 @@ dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'com.google.android.material:material:1.8.0'
|
implementation 'com.google.android.material:material:1.8.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
|
implementation 'androidx.navigation:navigation-fragment:2.5.3'
|
||||||
|
implementation 'androidx.navigation:navigation-ui:2.5.3'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.CpsAssist"
|
android:theme="@style/Theme.CpsAssist"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".notes.NotesActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:label="@string/title_activity_notes"
|
||||||
|
android:theme="@style/Theme.CpsAssist.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".login.LoginActivity"
|
android:name=".login.LoginActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
package xyz.r0r5chach.cpsAssist.home;
|
|
||||||
|
|
||||||
public class HomeActivity {
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package xyz.r0r5chach.cpsAssist.login;
|
package xyz.r0r5chach.cpsAssist.login;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
@ -8,11 +7,12 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import xyz.r0r5chach.cpsAssist.ArrayTools;
|
import xyz.r0r5chach.cpsAssist.ArrayTools;
|
||||||
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
import xyz.r0r5chach.cpsAssist.notes.NotesActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Class defines the definition of the OnCLickListener for the LoginActivity
|
* This Class defines the definition of the OnCLickListener for the LoginActivity
|
||||||
* @author r0r5chach
|
* @author r0r5chach
|
||||||
*/
|
*/
|
||||||
public class OnClickListener implements View.OnClickListener{
|
public class BtnOnClickListener implements View.OnClickListener{
|
||||||
/**
|
/**
|
||||||
* This attribute stores the amount of attempts the user has currently taken
|
* This attribute stores the amount of attempts the user has currently taken
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,7 +34,7 @@ public class OnClickListener implements View.OnClickListener{
|
||||||
* @param usernameField the View for the username field of the UI
|
* @param usernameField the View for the username field of the UI
|
||||||
* @param passwordField the View for the password field of the UI
|
* @param passwordField the View for the password field of the UI
|
||||||
*/
|
*/
|
||||||
public OnClickListener(EditText usernameField, EditText passwordField, String users) {
|
public BtnOnClickListener(EditText usernameField, EditText passwordField, String users) {
|
||||||
initUsers(users);
|
initUsers(users);
|
||||||
this.currentAttempts = 0;
|
this.currentAttempts = 0;
|
||||||
this.usernameField = usernameField;
|
this.usernameField = usernameField;
|
||||||
|
|
@ -56,7 +56,7 @@ public class OnClickListener implements View.OnClickListener{
|
||||||
Intent home = new Intent(view.getContext(), NotesActivity.class);
|
Intent home = new Intent(view.getContext(), NotesActivity.class);
|
||||||
home.putExtra("username", inputs[0]);
|
home.putExtra("username", inputs[0]);
|
||||||
view.getContext().startActivity(home);
|
view.getContext().startActivity(home);
|
||||||
((Activity)view.getContext()).finish();
|
((android.app.Activity)view.getContext()).finish();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
currentAttempts += 1;
|
currentAttempts += 1;
|
||||||
|
|
@ -12,6 +12,6 @@ public class LoginActivity extends AppCompatActivity {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
findViewById(R.id.loginButton).setOnClickListener(new OnClickListener(findViewById(R.id.userNameField), findViewById(R.id.passwordField), getString(R.string.users)));
|
findViewById(R.id.loginButton).setOnClickListener(new BtnOnClickListener(findViewById(R.id.userNameField), findViewById(R.id.passwordField), getString(R.string.users)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package xyz.r0r5chach.cpsAssist.notes;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import xyz.r0r5chach.cpsAssist.R;
|
||||||
|
|
||||||
|
public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder> {
|
||||||
|
|
||||||
|
private final List<File> notes;
|
||||||
|
|
||||||
|
public Adapter(List<File> notes) {
|
||||||
|
this.notes = notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.notes_item, parent, false);
|
||||||
|
return new ViewHolder(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(ViewHolder holder, int index) {
|
||||||
|
File note = notes.get(index);
|
||||||
|
holder.getFileName().setText(note.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
private final TextView fileName;
|
||||||
|
public ViewHolder(View v) {
|
||||||
|
super(v);
|
||||||
|
fileName = v.findViewById(R.id.fileNameField);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextView getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
package xyz.r0r5chach.cpsAssist.notes;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import xyz.r0r5chach.cpsAssist.R;
|
||||||
|
|
||||||
|
public class NotesActivity extends AppCompatActivity {
|
||||||
|
private List<File> notes;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_notes);
|
||||||
|
notes = getStoredNotes();
|
||||||
|
initRecycler();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initRecycler() {
|
||||||
|
RecyclerView list =findViewById(R.id.notesList);
|
||||||
|
list.setAdapter(new Adapter(notes));
|
||||||
|
list.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<File> getStoredNotes() {
|
||||||
|
return Arrays.asList(Objects.requireNonNull(getFilesDir().listFiles()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
tools:context=".notes.NotesActivity">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/addButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="275dp"
|
||||||
|
android:layout_marginTop="650dp"
|
||||||
|
android:text="@string/addButtonText" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/notesList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
</androidx.recyclerview.widget.RecyclerView>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fileNameField"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<dimen name="fab_margin">48dp</dimen>
|
||||||
|
</resources>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<dimen name="fab_margin">200dp</dimen>
|
||||||
|
</resources>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<dimen name="fab_margin">48dp</dimen>
|
||||||
|
</resources>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<resources>
|
||||||
|
<dimen name="fab_margin">16dp</dimen>
|
||||||
|
</resources>
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">cpsAssist</string>
|
<string name="app_name">CPSAssist</string>
|
||||||
|
<!-- Login View -->
|
||||||
<string name="usernameFieldHint">Username</string>
|
<string name="usernameFieldHint">Username</string>
|
||||||
<string name="passwordFieldHint">Password</string>
|
<string name="passwordFieldHint">Password</string>
|
||||||
<string name="loginButtonText">Login</string>
|
<string name="loginButtonText">Login</string>
|
||||||
<string name="users">josh#pass%kofi#pass%jaiwin#pass</string>
|
<string name="users">josh#pass%kofi#pass%jaiwin#pass</string>
|
||||||
|
<string name="title_activity_notes">NotesActivity</string>
|
||||||
|
<!-- Notes View -->
|
||||||
|
<string name="addButtonText">Add</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="Theme.CpsAssist" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="Theme.CpsAssist" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
<!-- Primary brand color. -->
|
<!-- Primary brand color. -->
|
||||||
|
|
@ -13,4 +13,10 @@
|
||||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||||
<!-- Customize your theme here. -->
|
<!-- Customize your theme here. -->
|
||||||
</style>
|
</style>
|
||||||
|
<style name="Theme.CpsAssist.NoActionBar">
|
||||||
|
<item name="windowActionBar">false</item>
|
||||||
|
<item name="windowNoTitle">true</item>
|
||||||
|
</style>
|
||||||
|
<style name="Theme.CpsAssist.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||||
|
<style name="Theme.CpsAssist.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue