diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..ac6b0ae --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..452e1d1 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,50 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.3" + + defaultConfig { + applicationId "com.afdhal_fa.noteapps" + minSdkVersion 21 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: "libs", include: ["*.jar"]) + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test.ext:junit:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + + //Room + implementation "androidx.room:room-runtime:2.2.5" + annotationProcessor "androidx.room:room-compiler:2.2.5" + + //RecycleView + implementation 'androidx.recyclerview:recyclerview:1.1.0' + + //Scalabel Size Unit (support for diferent screen sizes) + implementation 'com.intuit.sdp:sdp-android:1.0.6' + implementation 'com.intuit.ssp:ssp-android:1.0.6' + + //Material Design + implementation 'com.google.android.material:material:1.1.0' + + //Rounded imageview + implementation 'com.makeramen:roundedimageview:2.3.0' + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/androidTest/java/com/afdhal_fa/noteapps/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/afdhal_fa/noteapps/ExampleInstrumentedTest.java new file mode 100644 index 0000000..34de2ed --- /dev/null +++ b/app/src/androidTest/java/com/afdhal_fa/noteapps/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.afdhal_fa.noteapps; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + assertEquals("com.afdhal_fa.noteapps", appContext.getPackageName()); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..13e69e9 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/afdhal_fa/noteapps/activities/CreateNoteActivity.java b/app/src/main/java/com/afdhal_fa/noteapps/activities/CreateNoteActivity.java new file mode 100644 index 0000000..d286f4d --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/activities/CreateNoteActivity.java @@ -0,0 +1,504 @@ +package com.afdhal_fa.noteapps.activities; + +import android.Manifest; +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.GradientDrawable; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.provider.MediaStore; +import android.util.Patterns; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.afdhal_fa.noteapps.R; +import com.afdhal_fa.noteapps.database.NotesDatabase; +import com.afdhal_fa.noteapps.entities.Note; +import com.google.android.material.bottomsheet.BottomSheetBehavior; + +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class CreateNoteActivity extends AppCompatActivity { + + private EditText inputNoteTitle, inputNoteSubtitle, inputNoteText; + private TextView textDateTime; + private View viewSubtitleIndicator; + private ImageView imageNote; + private TextView textWebURl; + private LinearLayout layoutWebURL; + + private String selectNoteColor; + private String selectImagePath; + + private static final int REQUEST_CODE_STORAGE_PERMISSION = 1; + private static final int REQUEST_CODE_SELECT_IMAGE = 2; + + private AlertDialog dialogAddURL; + private AlertDialog dialogDeleteNote; + private Note alreadyAvalibleNote; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_create_note); + + ImageView imageBack = findViewById(R.id.imageBack); + imageBack.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onBackPressed(); + } + }); + + inputNoteTitle = findViewById(R.id.inputNoteTitle); + inputNoteSubtitle = findViewById(R.id.inputNoteSubtitle); + inputNoteText = findViewById(R.id.inputNote); + viewSubtitleIndicator = findViewById(R.id.viewSubtitleIndicator); + imageNote = findViewById(R.id.imageNote); + textWebURl = findViewById(R.id.textwebURL); + layoutWebURL = findViewById(R.id.layoutwebURL); + + textDateTime = findViewById(R.id.textDateTime); + + textDateTime.setText( + new SimpleDateFormat("EEEE, dd MMMM yyyy HH:mm a", Locale.getDefault()) + .format(new Date()) + ); + + ImageView imageSave = findViewById(R.id.imageSave); + imageSave.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + saveNote(); + } + }); + + selectNoteColor = "#333333"; + selectImagePath = ""; + + if (getIntent().getBooleanExtra("isViewOrUpdate", false)) { + alreadyAvalibleNote = (Note) getIntent().getSerializableExtra("note"); + setViewOrUpdate(); + } + + findViewById(R.id.imageRemoveWebURL).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + textWebURl.setText(null); + layoutWebURL.setVisibility(View.GONE); + } + }); + + findViewById(R.id.imageRemoveImage).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + imageNote.setImageBitmap(null); + imageNote.setVisibility(View.GONE); + findViewById(R.id.imageRemoveImage).setVisibility(View.GONE); + selectImagePath = ""; + } + }); + + if (getIntent().getBooleanExtra("isFromQuickAction", false)) { + String type = getIntent().getStringExtra("quickActionType"); + if (type != null) { + if (type.equals("image")) { + selectImagePath = getIntent().getStringExtra("imagePaht"); + imageNote.setImageBitmap(BitmapFactory.decodeFile(selectImagePath)); + imageNote.setVisibility(View.VISIBLE); + findViewById(R.id.imageRemoveImage).setVisibility(View.VISIBLE); + } else if (type.equals("URL")) { + textWebURl.setText(getIntent().getStringExtra("URL")); + layoutWebURL.setVisibility(View.VISIBLE); + } + } + } + + initMiscellneous(); + setSubtitleIndicator(); + } + + private void setViewOrUpdate() { + inputNoteTitle.setText(alreadyAvalibleNote.getTitle()); + inputNoteSubtitle.setText(alreadyAvalibleNote.getSubtitle()); + inputNoteText.setText(alreadyAvalibleNote.getNoteText()); + textDateTime.setText(alreadyAvalibleNote.getDateTime()); + + if (alreadyAvalibleNote.getImagePath() != null && !alreadyAvalibleNote.getImagePath().trim().isEmpty()) { + imageNote.setImageBitmap(BitmapFactory.decodeFile(alreadyAvalibleNote.getImagePath())); + imageNote.setVisibility(View.VISIBLE); + findViewById(R.id.imageRemoveImage).setVisibility(View.VISIBLE); + selectImagePath = alreadyAvalibleNote.getImagePath(); + } + + if (alreadyAvalibleNote.getWebLink() != null && !alreadyAvalibleNote.getWebLink().trim().isEmpty()) { + textWebURl.setText(alreadyAvalibleNote.getWebLink()); + layoutWebURL.setVisibility(View.VISIBLE); + } + + } + + private void saveNote() { + if (inputNoteTitle.getText().toString().trim().isEmpty()) { + Toast.makeText(this, "Note Title can't be empty", Toast.LENGTH_SHORT).show(); + return; + } else if (inputNoteSubtitle.getText().toString().trim().isEmpty() + && inputNoteText.getText().toString().trim().isEmpty()) { + Toast.makeText(this, "Note can't be empty", Toast.LENGTH_SHORT).show(); + return; + } + + final Note note = new Note(); + note.setTitle(inputNoteTitle.getText().toString()); + note.setSubtitle(inputNoteSubtitle.getText().toString()); + note.setNoteText(inputNoteText.getText().toString()); + note.setDateTime(textDateTime.getText().toString()); + note.setColor(selectNoteColor); + note.setImagePath(selectImagePath); + + if (layoutWebURL.getVisibility() == View.VISIBLE) { + note.setWebLink(textWebURl.getText().toString()); + } + + if (alreadyAvalibleNote != null) { + note.setId(alreadyAvalibleNote.getId()); + } + + @SuppressLint("StaticFieldLeak") + class SaveNoteTexk extends AsyncTask { + + @Override + protected Void doInBackground(Void... voids) { + NotesDatabase.getDatabase(getApplicationContext()).noteDao().insertNote(note); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + Intent intent = new Intent(); + setResult(RESULT_OK, intent); + finish(); + } + } + + new SaveNoteTexk().execute(); + } + + private void initMiscellneous() { + final LinearLayout layoutMiscelleneous = findViewById(R.id.layoutMiscellneous); + final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(layoutMiscelleneous); + layoutMiscelleneous.findViewById(R.id.textMiscelleous).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); + } else { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + } + } + }); + + final ImageView imageColor1 = layoutMiscelleneous.findViewById(R.id.imageColor1); + final ImageView imageColor2 = layoutMiscelleneous.findViewById(R.id.imageColor2); + final ImageView imageColor3 = layoutMiscelleneous.findViewById(R.id.imageColor3); + final ImageView imageColor4 = layoutMiscelleneous.findViewById(R.id.imageColor4); + final ImageView imageColor5 = layoutMiscelleneous.findViewById(R.id.imageColor5); + + layoutMiscelleneous.findViewById(R.id.viewColor1).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectNoteColor = "#333333"; + imageColor1.setImageResource(R.drawable.ic_done); + imageColor2.setImageResource(0); + imageColor3.setImageResource(0); + imageColor4.setImageResource(0); + imageColor5.setImageResource(0); + setSubtitleIndicator(); + } + }); + layoutMiscelleneous.findViewById(R.id.viewColor2).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectNoteColor = "#FDBE3B"; + imageColor1.setImageResource(0); + imageColor2.setImageResource(R.drawable.ic_done); + imageColor3.setImageResource(0); + imageColor4.setImageResource(0); + imageColor5.setImageResource(0); + setSubtitleIndicator(); + } + }); + layoutMiscelleneous.findViewById(R.id.viewColor3).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectNoteColor = "#FF4842"; + imageColor1.setImageResource(0); + imageColor2.setImageResource(0); + imageColor3.setImageResource(R.drawable.ic_done); + imageColor4.setImageResource(0); + imageColor5.setImageResource(0); + setSubtitleIndicator(); + } + }); + + layoutMiscelleneous.findViewById(R.id.viewColor4).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectNoteColor = "#3A52FC"; + imageColor1.setImageResource(0); + imageColor2.setImageResource(0); + imageColor3.setImageResource(0); + imageColor4.setImageResource(R.drawable.ic_done); + imageColor5.setImageResource(0); + setSubtitleIndicator(); + } + }); + + layoutMiscelleneous.findViewById(R.id.viewColor5).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + selectNoteColor = "#000000"; + imageColor1.setImageResource(0); + imageColor2.setImageResource(0); + imageColor3.setImageResource(0); + imageColor5.setImageResource(0); + imageColor5.setImageResource(R.drawable.ic_done); + setSubtitleIndicator(); + } + }); + if (alreadyAvalibleNote != null && alreadyAvalibleNote.getColor() != null && !alreadyAvalibleNote.getColor().trim().isEmpty()) { + switch (alreadyAvalibleNote.getColor()) { + case "#FDBE3B": + layoutMiscelleneous.findViewById(R.id.viewColor2).performClick(); + break; + + case "#FF4842": + layoutMiscelleneous.findViewById(R.id.viewColor3).performClick(); + break; + + case "#3A52FC": + layoutMiscelleneous.findViewById(R.id.viewColor4).performClick(); + break; + + case "#000000": + layoutMiscelleneous.findViewById(R.id.viewColor5).performClick(); + break; + + } + } + + layoutMiscelleneous.findViewById(R.id.layoutAddImage).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions( + CreateNoteActivity.this, + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + REQUEST_CODE_STORAGE_PERMISSION); + } else { + selecteImage(); + } + } + }); + + layoutMiscelleneous.findViewById(R.id.layoutAddUrl).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + showAddUrlDialg(); + } + }); + + if (alreadyAvalibleNote != null) { + layoutMiscelleneous.findViewById(R.id.layoutDeleteNote).setVisibility(View.VISIBLE); + layoutMiscelleneous.findViewById(R.id.layoutDeleteNote).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + showDeleteNoteDialog(); + } + }); + } + } + + private void showDeleteNoteDialog() { + if (dialogDeleteNote == null) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + View view = LayoutInflater.from(this).inflate( + R.layout.layout_delete_note, + (ViewGroup) findViewById(R.id.layoutDeleteNoteContainer) + ); + builder.setView(view); + dialogDeleteNote = builder.create(); + if (dialogDeleteNote.getWindow() != null) { + dialogDeleteNote.getWindow().setBackgroundDrawable(new ColorDrawable(0)); + } + view.findViewById(R.id.textDeleteNote).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + class DeleteNoteTask extends AsyncTask { + + @Override + protected Void doInBackground(Void... voids) { + NotesDatabase.getDatabase(getApplicationContext()).noteDao() + .deleteNote(alreadyAvalibleNote); + return null; + } + + @Override + protected void onPostExecute(Void aVoid) { + super.onPostExecute(aVoid); + Intent intent = new Intent(); + intent.putExtra("isNoteDeleted", true); + setResult(RESULT_OK, intent); + finish(); + } + } + new DeleteNoteTask().execute(); + } + }); + + view.findViewById(R.id.textCencel).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialogDeleteNote.dismiss(); + } + }); + } + dialogDeleteNote.show(); + } + + private void setSubtitleIndicator() { + GradientDrawable gradientDrawable = (GradientDrawable) viewSubtitleIndicator.getBackground(); + gradientDrawable.setColor(Color.parseColor(selectNoteColor)); + } + + private void selecteImage() { + Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + if (intent.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent, REQUEST_CODE_SELECT_IMAGE); + } + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode == REQUEST_CODE_STORAGE_PERMISSION && grantResults.length > 0) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + selecteImage(); + } else { + Toast.makeText(this, "Permisson Denied!", Toast.LENGTH_SHORT).show(); + } + } + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + if (requestCode == REQUEST_CODE_SELECT_IMAGE && resultCode == RESULT_OK) { + if (data != null) { + Uri selectedImageUri = data.getData(); + if (selectedImageUri != null) { + try { + InputStream inputStream = getContentResolver().openInputStream(selectedImageUri); + Bitmap bitmap = BitmapFactory.decodeStream(inputStream); + imageNote.setImageBitmap(bitmap); + imageNote.setVisibility(View.VISIBLE); + + findViewById(R.id.imageRemoveImage).setVisibility(View.VISIBLE); + + selectImagePath = getPathFromUri(selectedImageUri); + + } catch (Exception e) { + Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + } + + } + } + + private String getPathFromUri(Uri contentUri) { + String filePath; + Cursor cursor = getContentResolver() + .query(contentUri, null, null, null, null); + if (cursor == null) { + filePath = contentUri.getPath(); + } else { + cursor.moveToFirst(); + int index = cursor.getColumnIndex("_data"); + filePath = cursor.getString(index); + cursor.close(); + } + return filePath; + } + + private void showAddUrlDialg() { + if (dialogAddURL == null) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + View view = LayoutInflater.from(this).inflate( + R.layout.layout_add_url, + (ViewGroup) findViewById(R.id.layoutAddUrlContainer) + ); + builder.setView(view); + + dialogAddURL = builder.create(); + + if (dialogAddURL.getWindow() != null) { + dialogAddURL.getWindow().setBackgroundDrawable(new ColorDrawable(0)); + } + + final EditText inputURL = view.findViewById(R.id.inputURL); + inputURL.requestFocus(); + + view.findViewById(R.id.textAdd).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (inputURL.getText().toString().trim().isEmpty()) { + Toast.makeText(CreateNoteActivity.this, "Enter URL", Toast.LENGTH_SHORT).show(); + } else if (!Patterns.WEB_URL.matcher(inputURL.getText().toString()).matches()) { + Toast.makeText(CreateNoteActivity.this, "Enter valid URL", Toast.LENGTH_SHORT).show(); + } + textWebURl.setText(inputURL.getText().toString()); + layoutWebURL.setVisibility(View.VISIBLE); + dialogAddURL.dismiss(); + } + }); + + view.findViewById(R.id.textCencel).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialogAddURL.dismiss(); + } + }); + } + dialogAddURL.show(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/afdhal_fa/noteapps/activities/MainActivity.java b/app/src/main/java/com/afdhal_fa/noteapps/activities/MainActivity.java new file mode 100644 index 0000000..938d6e3 --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/activities/MainActivity.java @@ -0,0 +1,291 @@ +package com.afdhal_fa.noteapps.activities; + +import android.Manifest; +import android.annotation.SuppressLint; +import android.app.AlertDialog; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.graphics.drawable.ColorDrawable; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.provider.MediaStore; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.Patterns; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; + +import com.afdhal_fa.noteapps.R; +import com.afdhal_fa.noteapps.adapters.NotesAdapter; +import com.afdhal_fa.noteapps.database.NotesDatabase; +import com.afdhal_fa.noteapps.entities.Note; +import com.afdhal_fa.noteapps.listeners.NotesListener; + +import java.util.ArrayList; +import java.util.List; + +public class MainActivity extends AppCompatActivity implements NotesListener { + + public static final int REQUEST_CODE_ADD_NOTE = 1; + public static final int REQUEST_CODE_UPDATE_NOTE = 2; + public static final int REQUEST_CODE_SHOW_NOTE = 3; + public static final int REQUEST_CODE_SELECT_IMAGE = 4; + public static final int REQUEST_CODE_STORAGE_PERMISSION = 5; + + private RecyclerView notesRecyclerView; + private List noteList; + private NotesAdapter notesAdapter; + + private int noteClickedPosition = -1; + + private AlertDialog dialogAddURL; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + ImageView imageAddNoteMain = findViewById(R.id.imageaddNoteMain); + imageAddNoteMain.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivityForResult( + new Intent(getApplicationContext(), CreateNoteActivity.class), + REQUEST_CODE_ADD_NOTE); + } + }); + + notesRecyclerView = findViewById(R.id.noteRecyclerView); + notesRecyclerView.setHasFixedSize(true); + notesRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); + noteList = new ArrayList<>(); + notesAdapter = new NotesAdapter(noteList, this); + notesRecyclerView.setAdapter(notesAdapter); + + getNotes(REQUEST_CODE_SHOW_NOTE, false); + + EditText inputSearch = findViewById(R.id.input_search); + inputSearch.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + notesAdapter.cencelTimer(); + } + + @Override + public void afterTextChanged(Editable s) { + if (noteList.size() != 0) { + notesAdapter.seaerchNotes(s.toString()); + } + } + }); + + findViewById(R.id.imageAddNotes).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivityForResult( + new Intent(getApplicationContext(), CreateNoteActivity.class), + REQUEST_CODE_ADD_NOTE); + } + }); + findViewById(R.id.imageAddImage).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions( + MainActivity.this, + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + REQUEST_CODE_STORAGE_PERMISSION); + } else { + selecteImage(); + } + } + }); + + findViewById(R.id.imageAddWebLink).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showAddUrlDialg(); + } + }); + } + + private void selecteImage() { + Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + if (intent.resolveActivity(getPackageManager()) != null) { + startActivityForResult(intent, REQUEST_CODE_SELECT_IMAGE); + } + + } + + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode == REQUEST_CODE_STORAGE_PERMISSION && grantResults.length > 0) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + selecteImage(); + } else { + Toast.makeText(this, "Permisson Denied!", Toast.LENGTH_SHORT).show(); + } + } + } + + + private String getPathFromUri(Uri contentUri) { + String filePath; + Cursor cursor = getContentResolver() + .query(contentUri, null, null, null, null); + if (cursor == null) { + filePath = contentUri.getPath(); + } else { + cursor.moveToFirst(); + int index = cursor.getColumnIndex("_data"); + filePath = cursor.getString(index); + cursor.close(); + } + return filePath; + } + + @Override + public void onNoteClicked(Note note, int position) { + noteClickedPosition = position; + Intent intent = new Intent(getApplicationContext(), CreateNoteActivity.class); + intent.putExtra("isViewOrUpdate", true); + intent.putExtra("note", note); + startActivityForResult(intent, REQUEST_CODE_UPDATE_NOTE); + } + + private void getNotes(final int requestCode, final boolean isDeleteNote) { + @SuppressLint("StaticFieldLeak") + class GetNotesTask extends AsyncTask> { + + @Override + protected List doInBackground(Void... voids) { + return NotesDatabase + .getDatabase(getApplicationContext()) + .noteDao().getAllNotes(); + } + + @Override + protected void onPostExecute(List notes) { + super.onPostExecute(notes); + + if (requestCode == REQUEST_CODE_SHOW_NOTE) { + noteList.addAll(notes); + notesAdapter.notifyDataSetChanged(); + } else if (requestCode == REQUEST_CODE_ADD_NOTE) { + noteList.add(0, notes.get(0)); + notesAdapter.notifyItemInserted(0); + notesRecyclerView.smoothScrollToPosition(0); + } else if (requestCode == REQUEST_CODE_UPDATE_NOTE) { + noteList.remove(noteClickedPosition); + + if (isDeleteNote) { + notesAdapter.notifyItemRemoved(noteClickedPosition); + } else { + noteList.add(noteClickedPosition, notes.get(noteClickedPosition)); + notesAdapter.notifyItemChanged(noteClickedPosition); + + } + } + + } + } + new GetNotesTask().execute(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == REQUEST_CODE_ADD_NOTE && resultCode == RESULT_OK) { + getNotes(REQUEST_CODE_ADD_NOTE, false); + } else if (requestCode == REQUEST_CODE_UPDATE_NOTE && resultCode == RESULT_OK) { + if (data != null) { + getNotes(REQUEST_CODE_UPDATE_NOTE, data.getBooleanExtra("isNoteDeleted", false)); + } + } else if (requestCode == REQUEST_CODE_SELECT_IMAGE && resultCode == RESULT_OK) { + if (data != null) { + Uri selectedImageUri = data.getData(); + if (selectedImageUri != null) { + try { + String selectedImagePath = getPathFromUri(selectedImageUri); + Intent intent = new Intent(getApplicationContext(), CreateNoteActivity.class); + intent.putExtra("isFromQuickAction", true); + intent.putExtra("quickActionType", "image"); + intent.putExtra("imagePaht", selectedImagePath); + startActivityForResult(intent, REQUEST_CODE_ADD_NOTE); + } catch (Exception e) { + Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); + } + } + } + } + } + + private void showAddUrlDialg() { + if (dialogAddURL == null) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + View view = LayoutInflater.from(this).inflate( + R.layout.layout_add_url, + (ViewGroup) findViewById(R.id.layoutAddUrlContainer) + ); + builder.setView(view); + + dialogAddURL = builder.create(); + + if (dialogAddURL.getWindow() != null) { + dialogAddURL.getWindow().setBackgroundDrawable(new ColorDrawable(0)); + } + + final EditText inputURL = view.findViewById(R.id.inputURL); + inputURL.requestFocus(); + + view.findViewById(R.id.textAdd).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (inputURL.getText().toString().trim().isEmpty()) { + Toast.makeText(MainActivity.this, "Enter URL", Toast.LENGTH_SHORT).show(); + } else if (!Patterns.WEB_URL.matcher(inputURL.getText().toString()).matches()) { + Toast.makeText(MainActivity.this, "Enter valid URL", Toast.LENGTH_SHORT).show(); + } + dialogAddURL.dismiss(); + + Intent intent = new Intent(getApplicationContext(), CreateNoteActivity.class); + intent.putExtra("isFromQuickAction", true); + intent.putExtra("quickActionType", "URL"); + intent.putExtra("URL", inputURL.getText().toString()); + startActivityForResult(intent, REQUEST_CODE_ADD_NOTE); + + } + }); + + view.findViewById(R.id.textCencel).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dialogAddURL.dismiss(); + } + }); + } + dialogAddURL.show(); + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/afdhal_fa/noteapps/adapters/NotesAdapter.java b/app/src/main/java/com/afdhal_fa/noteapps/adapters/NotesAdapter.java new file mode 100644 index 0000000..0e48722 --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/adapters/NotesAdapter.java @@ -0,0 +1,142 @@ +package com.afdhal_fa.noteapps.adapters; + +import android.graphics.BitmapFactory; +import android.graphics.Color; +import android.graphics.drawable.GradientDrawable; +import android.os.Handler; +import android.os.Looper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.afdhal_fa.noteapps.R; +import com.afdhal_fa.noteapps.entities.Note; +import com.afdhal_fa.noteapps.listeners.NotesListener; +import com.makeramen.roundedimageview.RoundedImageView; + +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +public class NotesAdapter extends RecyclerView.Adapter { + + private List notes; + private NotesListener notesListener; + private Timer timer; + private List notesSource; + + + public NotesAdapter(List notes, NotesListener notesListener) { + this.notes = notes; + this.notesListener = notesListener; + this.notesSource = notes; + } + + @NonNull + @Override + public ViewHolde onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new ViewHolde(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_container_note, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolde holder, final int position) { + holder.setNote(notes.get(position)); + holder.layoutNote.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + notesListener.onNoteClicked(notes.get(position), position); + } + }); + } + + @Override + public int getItemCount() { + return notes.size(); + } + + @Override + public int getItemViewType(int position) { + return position; + } + + public class ViewHolde extends RecyclerView.ViewHolder { + TextView textTitle, textSubtitle, textDateTime; + LinearLayout layoutNote; + RoundedImageView imageNote; + + public ViewHolde(@NonNull View itemView) { + super(itemView); + textTitle = itemView.findViewById(R.id.textTitle); + textSubtitle = itemView.findViewById(R.id.textSubtitle); + textDateTime = itemView.findViewById(R.id.textDateTime); + layoutNote = itemView.findViewById(R.id.layoutNote); + imageNote = itemView.findViewById(R.id.imageNote); + } + + void setNote(Note note) { + textTitle.setText(note.getTitle()); + if (note.getSubtitle().trim().isEmpty()) { + textSubtitle.setVisibility(View.GONE); + } else { + textSubtitle.setText(note.getSubtitle()); + } + textDateTime.setText(note.getDateTime()); + GradientDrawable gradientDrawable = (GradientDrawable) itemView.getBackground(); + if (note.getColor() != null) { + gradientDrawable.setColor(Color.parseColor(note.getColor())); + } else { + gradientDrawable.setColor(Color.parseColor("#333333")); + } + + if (note.getImagePath() != null) { + imageNote.setImageBitmap(BitmapFactory.decodeFile(note.getImagePath())); + imageNote.setVisibility(View.VISIBLE); + } else { + imageNote.setVisibility(View.GONE); + } + } + } + + public void seaerchNotes(final String searchKeyword) { + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + if (searchKeyword.trim().isEmpty()) { + notes = notesSource; + } else { + ArrayList temp = new ArrayList<>(); + for (Note note : notesSource) { + if (note.getTitle().toLowerCase().contains(searchKeyword.toLowerCase()) + || note.getSubtitle().toLowerCase().contains(searchKeyword.toLowerCase()) + || note.getNoteText().toLowerCase().contains(searchKeyword.toLowerCase())) { + temp.add(note); + } + } + notes = temp; + } + + + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + notifyDataSetChanged(); + } + }); + } + }, 500); + } + + public void cencelTimer() { + + if (timer != null) { + timer.cancel(); + } + } +} diff --git a/app/src/main/java/com/afdhal_fa/noteapps/dao/NoteDao.java b/app/src/main/java/com/afdhal_fa/noteapps/dao/NoteDao.java new file mode 100644 index 0000000..043a76e --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/dao/NoteDao.java @@ -0,0 +1,24 @@ +package com.afdhal_fa.noteapps.dao; + +import androidx.room.Dao; +import androidx.room.Delete; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; + +import com.afdhal_fa.noteapps.entities.Note; + +import java.util.List; + +@Dao +public interface NoteDao { + @Query("SELECT * FROM notes ORDER BY id DESC") + List getAllNotes(); + + @Insert(onConflict = OnConflictStrategy.REPLACE) + void insertNote(Note note); + + @Delete + void deleteNote(Note note); + +} diff --git a/app/src/main/java/com/afdhal_fa/noteapps/database/NotesDatabase.java b/app/src/main/java/com/afdhal_fa/noteapps/database/NotesDatabase.java new file mode 100644 index 0000000..c0abee0 --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/database/NotesDatabase.java @@ -0,0 +1,31 @@ +package com.afdhal_fa.noteapps.database; + +import android.content.Context; + +import androidx.room.Database; +import androidx.room.Room; +import androidx.room.RoomDatabase; + +import com.afdhal_fa.noteapps.dao.NoteDao; +import com.afdhal_fa.noteapps.entities.Note; + +@Database(entities = Note.class, version = 1, exportSchema = false) +public abstract class NotesDatabase extends RoomDatabase { + + private static NotesDatabase notesDatabase; + + public static synchronized NotesDatabase getDatabase(Context context) { + if (notesDatabase == null) { + notesDatabase = Room.databaseBuilder( + context, + NotesDatabase.class, + "notes_db" + ).build(); + } + return notesDatabase; + } + + public abstract NoteDao noteDao(); + + +} diff --git a/app/src/main/java/com/afdhal_fa/noteapps/entities/Note.java b/app/src/main/java/com/afdhal_fa/noteapps/entities/Note.java new file mode 100644 index 0000000..792a928 --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/entities/Note.java @@ -0,0 +1,106 @@ +package com.afdhal_fa.noteapps.entities; + +import androidx.annotation.NonNull; +import androidx.room.ColumnInfo; +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +import java.io.Serializable; + +@Entity(tableName = "notes") +public class Note implements Serializable { + @PrimaryKey(autoGenerate = true) + private int id; + + @ColumnInfo(name = "title") + private String title; + + @ColumnInfo(name = "date_time") + private String dateTime; + + @ColumnInfo(name = "subtitle") + private String subtitle; + + @ColumnInfo(name = "note_text") + private String noteText; + + @ColumnInfo(name = "image_path") + private String imagePath; + + @ColumnInfo(name = "color") + private String color; + + @ColumnInfo(name = "web_link") + private String webLink; + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } + + public String getSubtitle() { + return subtitle; + } + + public void setSubtitle(String subtitle) { + this.subtitle = subtitle; + } + + public String getNoteText() { + return noteText; + } + + public void setNoteText(String noteText) { + this.noteText = noteText; + } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public String getWebLink() { + return webLink; + } + + public void setWebLink(String webLink) { + this.webLink = webLink; + } + + @NonNull + @Override + public String toString() { + return title + " : " + dateTime; + } +} diff --git a/app/src/main/java/com/afdhal_fa/noteapps/listeners/NotesListener.java b/app/src/main/java/com/afdhal_fa/noteapps/listeners/NotesListener.java new file mode 100644 index 0000000..37e9d7b --- /dev/null +++ b/app/src/main/java/com/afdhal_fa/noteapps/listeners/NotesListener.java @@ -0,0 +1,7 @@ +package com.afdhal_fa.noteapps.listeners; + +import com.afdhal_fa.noteapps.entities.Note; + +public interface NotesListener { + void onNoteClicked(Note note, int position); +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_add_button.xml b/app/src/main/res/drawable/background_add_button.xml new file mode 100644 index 0000000..52d9159 --- /dev/null +++ b/app/src/main/res/drawable/background_add_button.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_delete.xml b/app/src/main/res/drawable/background_delete.xml new file mode 100644 index 0000000..9cc285e --- /dev/null +++ b/app/src/main/res/drawable/background_delete.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_dialog.xml b/app/src/main/res/drawable/background_dialog.xml new file mode 100644 index 0000000..1a3a8f0 --- /dev/null +++ b/app/src/main/res/drawable/background_dialog.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_done_button.xml b/app/src/main/res/drawable/background_done_button.xml new file mode 100644 index 0000000..8b3f46f --- /dev/null +++ b/app/src/main/res/drawable/background_done_button.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_miscellneous.xml b/app/src/main/res/drawable/background_miscellneous.xml new file mode 100644 index 0000000..863c7b1 --- /dev/null +++ b/app/src/main/res/drawable/background_miscellneous.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_note.xml b/app/src/main/res/drawable/background_note.xml new file mode 100644 index 0000000..63b7fae --- /dev/null +++ b/app/src/main/res/drawable/background_note.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_note_color_1.xml b/app/src/main/res/drawable/background_note_color_1.xml new file mode 100644 index 0000000..050646b --- /dev/null +++ b/app/src/main/res/drawable/background_note_color_1.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_note_color_2.xml b/app/src/main/res/drawable/background_note_color_2.xml new file mode 100644 index 0000000..6e26ca4 --- /dev/null +++ b/app/src/main/res/drawable/background_note_color_2.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_note_color_3.xml b/app/src/main/res/drawable/background_note_color_3.xml new file mode 100644 index 0000000..391b122 --- /dev/null +++ b/app/src/main/res/drawable/background_note_color_3.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_note_color_4.xml b/app/src/main/res/drawable/background_note_color_4.xml new file mode 100644 index 0000000..2e25e47 --- /dev/null +++ b/app/src/main/res/drawable/background_note_color_4.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_note_color_5.xml b/app/src/main/res/drawable/background_note_color_5.xml new file mode 100644 index 0000000..e6d048a --- /dev/null +++ b/app/src/main/res/drawable/background_note_color_5.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_search.xml b/app/src/main/res/drawable/background_search.xml new file mode 100644 index 0000000..b779a6d --- /dev/null +++ b/app/src/main/res/drawable/background_search.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/background_subtitle_indicator.xml b/app/src/main/res/drawable/background_subtitle_indicator.xml new file mode 100644 index 0000000..a58dc3e --- /dev/null +++ b/app/src/main/res/drawable/background_subtitle_indicator.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_add.xml b/app/src/main/res/drawable/ic_add.xml new file mode 100644 index 0000000..eb23254 --- /dev/null +++ b/app/src/main/res/drawable/ic_add.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_add_outline.xml b/app/src/main/res/drawable/ic_add_outline.xml new file mode 100644 index 0000000..a1c721d --- /dev/null +++ b/app/src/main/res/drawable/ic_add_outline.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_back.xml b/app/src/main/res/drawable/ic_back.xml new file mode 100644 index 0000000..8bf031f --- /dev/null +++ b/app/src/main/res/drawable/ic_back.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_delete.xml b/app/src/main/res/drawable/ic_delete.xml new file mode 100644 index 0000000..3c4030b --- /dev/null +++ b/app/src/main/res/drawable/ic_delete.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_done.xml b/app/src/main/res/drawable/ic_done.xml new file mode 100644 index 0000000..899cbb6 --- /dev/null +++ b/app/src/main/res/drawable/ic_done.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_image.xml b/app/src/main/res/drawable/ic_image.xml new file mode 100644 index 0000000..8232c4d --- /dev/null +++ b/app/src/main/res/drawable/ic_image.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml new file mode 100644 index 0000000..07b76d6 --- /dev/null +++ b/app/src/main/res/drawable/ic_search.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_web_link.xml b/app/src/main/res/drawable/ic_web_link.xml new file mode 100644 index 0000000..3f70646 --- /dev/null +++ b/app/src/main/res/drawable/ic_web_link.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/font/ubuntu_bold.ttf b/app/src/main/res/font/ubuntu_bold.ttf new file mode 100644 index 0000000..4af149a Binary files /dev/null and b/app/src/main/res/font/ubuntu_bold.ttf differ diff --git a/app/src/main/res/font/ubuntu_medium.ttf b/app/src/main/res/font/ubuntu_medium.ttf new file mode 100644 index 0000000..5296045 Binary files /dev/null and b/app/src/main/res/font/ubuntu_medium.ttf differ diff --git a/app/src/main/res/font/ubuntu_regular.ttf b/app/src/main/res/font/ubuntu_regular.ttf new file mode 100644 index 0000000..dbb834a Binary files /dev/null and b/app/src/main/res/font/ubuntu_regular.ttf differ diff --git a/app/src/main/res/layout/activity_create_note.xml b/app/src/main/res/layout/activity_create_note.xml new file mode 100644 index 0000000..5e6f50a --- /dev/null +++ b/app/src/main/res/layout/activity_create_note.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b42914a --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_container_note.xml b/app/src/main/res/layout/item_container_note.xml new file mode 100644 index 0000000..a999a00 --- /dev/null +++ b/app/src/main/res/layout/item_container_note.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_add_url.xml b/app/src/main/res/layout/layout_add_url.xml new file mode 100644 index 0000000..7445682 --- /dev/null +++ b/app/src/main/res/layout/layout_add_url.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/layout_delete_note.xml b/app/src/main/res/layout/layout_delete_note.xml new file mode 100644 index 0000000..ec31ac4 --- /dev/null +++ b/app/src/main/res/layout/layout_delete_note.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/layout_misccellaneous.xml b/app/src/main/res/layout/layout_misccellaneous.xml new file mode 100644 index 0000000..44e3a66 --- /dev/null +++ b/app/src/main/res/layout/layout_misccellaneous.xml @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a571e60 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..61da551 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c41dd28 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..db5080a Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..6dba46d Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..da31a87 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..15ac681 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b216f2d Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..f25a419 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..e96783c Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..6cf13e6 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,21 @@ + + + #292929 + #292929 + #FDBE3B + #FFFFFF + #DBDBDB + #7B7B7B + #2F2D2E + #A4A4A4 + #CECECE + #333333 + #1F1F1F + #FAFAFA + #FDBE3B + #FF4842 + #3A52FC + #000000 + #FF4842 + #333333 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..e3c43ef --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,17 @@ + + Notes App + My Notes + Search Notes + Note Title + Note Subtitle + Type Note here + Miscellneous + Pick Color + Add Image + Add URL + Enter URL + ADD + CANCEL + Delete Note + Are you sure want to delete this note + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..13f74a4 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/test/java/com/afdhal_fa/noteapps/ExampleUnitTest.java b/app/src/test/java/com/afdhal_fa/noteapps/ExampleUnitTest.java new file mode 100644 index 0000000..cb9c6c1 --- /dev/null +++ b/app/src/test/java/com/afdhal_fa/noteapps/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.afdhal_fa.noteapps; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..92162e2 --- /dev/null +++ b/build.gradle @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + jcenter() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:4.0.1" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..c52ac9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,19 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app"s APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..22ba627 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Jul 23 13:21:16 SGT 2020 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..7e149dd --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name = "NoteApps" \ No newline at end of file