Skip to content

Commit

Permalink
refactor code & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusemreyakisan committed Mar 9, 2023
1 parent 8599f10 commit 37638eb
Show file tree
Hide file tree
Showing 32 changed files with 741 additions and 452 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/dictionaries/yakisan.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/render.experimental.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 23 additions & 26 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="33" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand All @@ -24,50 +21,50 @@
android:theme="@style/LightTheme.EdithorMobile"
tools:targetApi="33">


<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="ocr" />

<activity
android:name=".layouts.upload.UploadFile"
android:exported="true"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".helpers.SplashScreen"
android:exported="true"
android:theme="@style/SplashTheme"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
<activity
android:name=".layouts.detail.NoteDetail"
android:windowSoftInputMode="adjustResize"
android:exported="true" />

<activity
android:name=".NotePage"
android:exported="true"
android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustPan" />

<activity
android:name=".layouts.crud.AddNote"
android:exported="true"
android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustResize" />

<activity
android:name=".layouts.login.SignIn"
android:exported="true"
android:windowSoftInputMode="adjustPan"/>

android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".layouts.login.SignUp"
android:exported="true"
android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustPan" />

<activity
android:name=".layouts.chat_gpt.AskGPT"
android:enableOnBackInvokedCallback="true"
android:windowSoftInputMode="adjustResize"
android:exported="true" />
</application>

</manifest>
15 changes: 11 additions & 4 deletions app/src/main/java/com/app/edithormobile/NotePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
import com.app.edithormobile.databinding.ActivityNotePageBinding;
import com.app.edithormobile.layouts.chat_gpt.AskGPT;
import com.app.edithormobile.layouts.crud.AddNote;
import com.app.edithormobile.layouts.detail.NoteDetail;
import com.app.edithormobile.layouts.login.SignIn;
import com.app.edithormobile.models.NoteModel;
import com.app.edithormobile.utils.IHelper;
import com.app.edithormobile.utils.IToast;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
Expand All @@ -47,7 +48,7 @@
* @author yunusemreyakisan
*/

public class NotePage extends AppCompatActivity implements IHelper {
public class NotePage extends AppCompatActivity implements IToast {

ArrayList<NoteModel> selectedNotes = new ArrayList<>();
boolean isSelectedMode = false;
Expand Down Expand Up @@ -190,10 +191,12 @@ private void notesViewRV() {
public void onItemClick(View v, int position) {
// Toast.makeText(NotePage.this, "Kısa basıldı", Toast.LENGTH_SHORT).show();
NoteModel model = notes.get(position);
Intent intent = new Intent(NotePage.this, AddNote.class);
Intent intent = new Intent(NotePage.this, NoteDetail.class);
intent.putExtra("id", notes.get(position).getNoteID());
intent.putExtra("baslik", notes.get(position).getNotBaslik());
intent.putExtra("icerik", notes.get(position).getNotIcerigi());
intent.putExtra("olusturma_zamani", notes.get(position).getNotOlusturmaTarihi());
intent.putExtra("color", notes.get(position).getColor());
intent.putExtra("position", model);
startActivity(intent);

Expand Down Expand Up @@ -473,24 +476,28 @@ public boolean onQueryTextSubmit(String query) {
@Override
public boolean onQueryTextChange(String newText) {
filter(newText);
noteAdapter.notifyDataSetChanged();
return false;
}
});
}

//TODO: Issue -> Filtreleme sırasında notu bulduktan sonra bir önceki liste pozisyonunu alıyor.
private void filter(String text) {
ArrayList<NoteModel> filteredlist = new ArrayList<>();

for (NoteModel item : notes) {
// checking if the entered string matched with any item of our recycler view.
if (item.getNotBaslik().toLowerCase().contains(text.toLowerCase())) {
if (item.getNotBaslik().toLowerCase().contains(text.toLowerCase())
|| item.getNotIcerigi().toLowerCase().contains(text.toLowerCase())) {
filteredlist.add(item);
}
}
if (filteredlist.isEmpty()) {
Toast("Eşleşen not yok");
} else {
noteAdapter.filterList(filteredlist);
noteAdapter.notifyDataSetChanged();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.app.edithormobile.adapters;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -12,36 +11,27 @@

import com.app.edithormobile.R;
import com.app.edithormobile.models.GPTModel;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Objects;

import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;

public final class MessageAdapter extends RecyclerView.Adapter {
private ArrayList<GPTModel> messages;
private static final int TYPE_USER = 1;
private static final int TYPE_GPT = 2;


public MessageAdapter(ArrayList<GPTModel> messages) {
this.messages = messages;
}


//VH
public static class VH extends RecyclerView.ViewHolder {
LinearLayout leftChatView,rightChatView;
TextView leftTextView,rightTextView, kullanici_adi;
LinearLayout leftChatView, rightChatView;
TextView leftTextView, rightTextView, kullanici_adi;

public VH(@NonNull View itemView) {
super(itemView);
leftChatView = itemView.findViewById(R.id.left_chat_view);
leftChatView = itemView.findViewById(R.id.left_chat_view);
rightChatView = itemView.findViewById(R.id.right_chat_view);
leftTextView = itemView.findViewById(R.id.left_chat_text_view);
rightTextView = itemView.findViewById(R.id.right_chat_text_view);
Expand All @@ -62,17 +52,26 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
String message = (String) messages.get(position).getMessage();

if(!messages.get(position).getSender().equals("gpt")){
if (!messages.get(position).getSender().equals("gpt")) {
((VH) holder).leftChatView.setVisibility(View.GONE);
((VH) holder).rightChatView.setVisibility(View.VISIBLE);
((VH) holder).rightTextView.setText(message);
((VH) holder).kullanici_adi.setText(messages.get(position).getSender());
}else{
} else {
((VH) holder).rightChatView.setVisibility(View.GONE);
((VH) holder).leftChatView.setVisibility(View.VISIBLE);
((VH) holder).leftTextView.setText(message);
}


//click listener (TODO: GPT mesajına tıkladıgında kopyalanacak.)
((VH) holder).leftChatView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});

}

@Override
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/java/com/app/edithormobile/adapters/NoteAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;

import com.app.edithormobile.R;
import com.app.edithormobile.models.NoteModel;
import com.bumptech.glide.Glide;
import com.google.android.material.card.MaterialCardView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
Expand Down Expand Up @@ -44,8 +45,6 @@ public NoteAdapter(Context context, ArrayList<NoteModel> notes, ClickListener cl
}




@NonNull
@Override
public NoteHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Expand Down Expand Up @@ -73,16 +72,22 @@ public void onBindViewHolder(@NonNull NoteHolder holder, int position) {

holder.color.setBackgroundColor(mNote.getColor());

holder.card.setBackgroundColor(mNote.getColor());


//TODO:Talha hocaya sor. (Referans alma ile alakalı)
//TODO: Fotoğrafın referansı cihazın kendi depolama alanıyla sınırlı. Storage üzerinden URL alıp göstermeli.


} else {
holder.tvTitle.setText(mNote.getNotBaslik());
//TODO: Eger icerik boyutu 30'dan buyukse sonuna uc nokta koyulmalı.
holder.tvNote.setText(mNote.getNotIcerigi());
holder.tvOlusturmaTarihi.setText(mNote.getNotOlusturmaTarihi());
holder.color.setBackgroundColor(mNote.getColor());
//holder.card_layout.setBackgroundColor(mNote.getColor());
//TODO: Eger boyle yaparsak notların arkaplanı değiştirilecek ve mantık aynı olacak.
holder.card.setStrokeColor(mNote.getColor());

}

Expand Down Expand Up @@ -164,8 +169,9 @@ public void onFailure(@NonNull Exception e) {
//ViewHolder with images
public static class NoteHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
TextView tvNote, tvTitle, tvOlusturmaTarihi;
public CardView card;
public MaterialCardView card;
ImageView imageUri, color;
LinearLayout card_layout;

public NoteHolder(@NonNull View itemView) {
super(itemView);
Expand All @@ -175,6 +181,7 @@ public NoteHolder(@NonNull View itemView) {
tvOlusturmaTarihi = itemView.findViewById(R.id.tvOlusturmaTarihi);
imageUri = itemView.findViewById(R.id.imageUri);
color = itemView.findViewById(R.id.notColor);
card_layout = itemView.findViewById(R.id.card_layout);

//click
itemView.setOnClickListener(this);
Expand Down Expand Up @@ -207,6 +214,7 @@ public boolean onLongClick(View v) {
//Interface
public interface ClickListener {
void onItemClick(View v, int position);

void onItemLongClick(View v, int position);
}

Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/com/app/edithormobile/helpers/IHelper.java

This file was deleted.

Loading

0 comments on commit 37638eb

Please sign in to comment.