Skip to content

Commit

Permalink
Merge pull request #22 from Adikso/master
Browse files Browse the repository at this point in the history
Initial app revival. Dependencies, theme fixes etc.
  • Loading branch information
matiasdelellis authored Apr 23, 2024
2 parents b195027 + 46b1375 commit 43a3b0f
Show file tree
Hide file tree
Showing 57 changed files with 444 additions and 477 deletions.
38 changes: 21 additions & 17 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "30.0.1"
namespace "ar.com.delellis.quicknotes"
compileSdkVersion 34

defaultConfig {
applicationId 'ar.com.delellis.quicknotes'
minSdkVersion 21
compileSdkVersion 29
minSdkVersion 24
compileSdkVersion 34
versionCode 1
versionName "0.3.0"

Expand All @@ -41,6 +41,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
buildConfig true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -71,44 +74,45 @@ android {
repositories {
// Needed for Nextcloud SSO
maven { url "https://jitpack.io" }
maven { url "https://a8c-libs.s3.amazonaws.com/android" }
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])

implementation 'com.android.support:design:29.0.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.preference:preference:1.1.1"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.preference:preference:1.2.1"
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// Retrofif2
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.9.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'

// Wordpress mobile html editor
api ('com.github.wordpress-mobile.WordPress-Aztec-Android:aztec:v1.3.44')
api ('org.wordpress:aztec:v1.6.2')

// Parse and clean HTML tags.
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'org.jsoup:jsoup:1.15.4'

//Palette
implementation 'petrov.kristiyan:colorpicker-library:1.1.10'

// Nextcloud SSO
implementation "com.github.nextcloud:Android-SingleSignOn:0.5.6"
implementation "com.github.nextcloud:Android-SingleSignOn:0.8.1"

// Glide integration
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

implementation 'com.github.stefan-niedermann.nextcloud-commons:sso-glide:1.2.5'
implementation 'com.github.stefan-niedermann.nextcloud-commons:sso-glide:1.8.2'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
android:requestLegacyExternalStorage="true">

<activity
android:exported="true"
android:name=".activity.splash.SplashscreenActivity"
android:theme="@style/SplashTheme">
<intent-filter>
Expand All @@ -50,7 +51,7 @@
</activity>
<activity android:name=".activity.login.LoginActivity">
</activity>
<activity android:name=".activity.main.MainActivity">
<activity android:name=".activity.main.MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@

package ar.com.delellis.quicknotes.activity.editor;

import static android.Manifest.permission.CAMERA;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.M;
import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED;
import static ar.com.delellis.quicknotes.activity.editor.AttachBottomSheetDialog.ATTACH_ADD_FILE;
import static ar.com.delellis.quicknotes.activity.editor.AttachBottomSheetDialog.ATTACH_TAKE_PHOTO;
import static ar.com.delellis.quicknotes.activity.editor.AttachBottomSheetDialog.ATTACH_TAKE_VIDEO;

import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.Menu;
Expand All @@ -43,14 +52,15 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import org.wordpress.aztec.AztecText;
import org.wordpress.aztec.AztecTextFormat;

Expand Down Expand Up @@ -81,15 +91,6 @@
import okhttp3.RequestBody;
import petrov.kristiyan.colorpicker.ColorPicker;

import static android.Manifest.permission.CAMERA;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.M;
import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED;
import static ar.com.delellis.quicknotes.activity.editor.AttachBottomSheetDialog.ATTACH_ADD_FILE;
import static ar.com.delellis.quicknotes.activity.editor.AttachBottomSheetDialog.ATTACH_TAKE_PHOTO;
import static ar.com.delellis.quicknotes.activity.editor.AttachBottomSheetDialog.ATTACH_TAKE_VIDEO;

public class EditorActivity extends AppCompatActivity implements EditorView, OnAttachOptionListener {
private final String TAG = EditorActivity.class.getCanonicalName();

Expand Down Expand Up @@ -153,9 +154,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

mApi = new ApiProvider(getApplicationContext());

Expand All @@ -177,6 +176,7 @@ protected void onCreate(Bundle savedInstanceState) {

et_title = findViewById(R.id.editor_title);
et_content = findViewById(R.id.editor_content);
et_content.setCalypsoMode(false);
rich_toolbar = findViewById(R.id.editor_rich_toolbar);

tagAdapter = new TagAdapter();
Expand Down Expand Up @@ -204,6 +204,7 @@ protected void onCreate(Bundle savedInstanceState) {

// Store the either loaded or just created note as a copy so we can compare for modifications later
shadowCopyNote = note.clone();
getSupportActionBar().setElevation(0);
}


Expand All @@ -230,60 +231,61 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.pin:
note.setIsPinned(!note.getIsPinned());
item.setIcon(note.getIsPinned() ? R.drawable.ic_pinned : R.drawable.ic_pin);
ColorUtil.menuItemTintColor(item, this.getResources().getColor(R.color.defaultNoteTint));
int itemId = item.getItemId();
if (itemId == R.id.pin) {
note.setIsPinned(!note.getIsPinned());
item.setIcon(note.getIsPinned() ? R.drawable.ic_pinned : R.drawable.ic_pin);
ColorUtil.menuItemTintColor(item, this.getResources().getColor(R.color.defaultNoteTint));
return true;
} else if (itemId == R.id.save) {
if (note.getIsShared()) {
closeEdition();
return true;
case R.id.save:
if (note.getIsShared()) {
closeEdition();
return true;
}
}

fetchDataToNoteObject();
fetchDataToNoteObject();

if (note.getTitle().isEmpty()) {
et_title.setError(getString(R.string.must_enter_title));
} else {
if (note.getId() == 0)
presenter.createNote(note);
else
presenter.updateNote(note);
}
return true;
case R.id.delete:
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle(getString(R.string.delete_note));
alertDialog.setMessage(R.string.sure_want_delete);
alertDialog.setNegativeButton(R.string.common_yes, (dialog, wich) -> {
dialog.dismiss();
presenter.deleteNote(note.getId());
});
alertDialog.setPositiveButton(R.string.common_cancel, ((dialog, which) -> dialog.dismiss()));
alertDialog.show();
return true;
case android.R.id.home:
if (hasModifications()) {
showDiscardDialog(() -> {
setResult(RESULT_CANCELED);
finish();
}, null);
} else {
setResult(RESULT_OK);
if (note.getTitle().isEmpty()) {
et_title.setError(getString(R.string.must_enter_title));
} else {
if (note.getId() == 0)
presenter.createNote(note);
else
presenter.updateNote(note);
}
return true;
} else if (itemId == R.id.delete) {
new MaterialAlertDialogBuilder(this).setTitle(R.string.delete_note)
.setMessage(R.string.sure_want_delete)
.setPositiveButton(R.string.common_yes, ((dialog, which) -> {
dialog.dismiss();
presenter.deleteNote(note.getId());
}))
.setNegativeButton(R.string.common_cancel, (dialog, which) -> {
dialog.dismiss();
})
.show();
return true;
} else if (itemId == android.R.id.home) {
if (hasModifications()) {
showDiscardDialog(() -> {
setResult(RESULT_CANCELED);
finish();
}
return true;
default:
return super.onOptionsItemSelected(item);
}, null);
} else {
setResult(RESULT_OK);
finish();
}
return true;
} else {
return super.onOptionsItemSelected(item);
}
}

private void fetchDataToNoteObject() {
// Clean html from view and update note to save.
note.setTitle(HtmlUtil.cleanString(et_title.getText().toString()));
note.setContent(HtmlUtil.cleanHtml(et_content.toFormattedHtml()));
note.setContent(HtmlUtil.cleanHtml(et_content.toPlainHtml(false)));
}

public void initToolbar() {
Expand Down Expand Up @@ -556,9 +558,8 @@ private void readMode() {

private void tintActivityColor(int noteColor) {
et_content.getRootView().setBackgroundColor(noteColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(noteColor);
}
getWindow().setStatusBarColor(noteColor);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(noteColor));
}

private void closeEdition() {
Expand Down Expand Up @@ -644,20 +645,19 @@ private boolean hasModifications() {
* @param stayAction What to do when user wants to stay (can be null)
*/
private void showDiscardDialog(Runnable discardAction, Runnable stayAction) {
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.note_confirm_discard_unsaved_changes_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(R.string.note_confirm_discard_unsaved_changes_text)
.setPositiveButton(R.string.common_yes, (dialog, which) -> {
.setPositiveButton(R.string.common_yes, ((dialog, which) -> {
discardAction.run();
})
}))
.setNegativeButton(R.string.common_cancel, (dialog, which) -> {
if (stayAction != null) stayAction.run();
})
.show();
}


@Override
public void onBackPressed() {
if (hasModifications()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package ar.com.delellis.quicknotes.activity.main;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.AppCompatImageButton;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.Toolbar;
Expand Down Expand Up @@ -372,7 +373,7 @@ public void onComplete() {
startActivity(intent);
finish();
} else {
String errorDetail = !errorMessage.isEmpty() ? errorMessage : getString(R.string.error_unknown);
String errorDetail = errorMessage != null && !errorMessage.isEmpty() ? errorMessage : getString(R.string.error_unknown);
Intent intent = new Intent(getApplicationContext(), ErrorActivity.class);
intent.putExtra("errorMessage", errorDetail);
startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class RecyclerViewAdapter extends RecyclerView.ViewHolder implements View.OnClic

card_item.setOnClickListener(this);
tv_content.setOnClickListener(this);
tv_content.setCalypsoMode(false);

attachmentAdapter.setOnImageClickListener(position -> this.onClick(itemView));
}
Expand Down
Loading

0 comments on commit 43a3b0f

Please sign in to comment.