Skip to content

Commit

Permalink
added new notes
Browse files Browse the repository at this point in the history
  • Loading branch information
tappdesign committed May 17, 2024
1 parent 935ca6f commit 2d15523
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static pk.tappdesign.knizka.BaseActivity.TRANSITION_VERTICAL;
import static pk.tappdesign.knizka.MainActivity.FRAGMENT_DETAIL_TAG;
import static pk.tappdesign.knizka.db.DbHelper.COL_LINKED_SET_TEXT_ORDER;
import static pk.tappdesign.knizka.helpers.PermissionsHelper.requestPermission;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_DISMISS;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_FAB_TAKE_PHOTO;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_MERGE;
Expand Down Expand Up @@ -2714,6 +2715,18 @@ public void onAttachingFileFinished(Attachment mAttachment) {

@Override
public void onReminderPicked(long reminder) {

if (!ReminderHelper.checkPermisson(getContext()))
{
startActivity(new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM, Uri.parse("package:"+ getContext().getPackageName())));
}

requestPermission(getActivity(), Manifest.permission.POST_NOTIFICATIONS, R
.string.permission_post_notifications,
getActivity().findViewById(R.id.crouton_handle), () -> {
//mainActivity.showToast(getText(R.string.permission_post_notifications_granted), Toast.LENGTH_LONG);
});

noteTmp.setAlarm(reminder);
if (mFragment.isAdded()) {
binding.fragmentDetailContent.reminderIcon.setImageDrawable(getAlarmIconForTheme(R.attr.ic_alarm_note_layout));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package pk.tappdesign.knizka;

import static androidx.core.view.ViewCompat.animate;
import static pk.tappdesign.knizka.helpers.PermissionsHelper.requestPermission;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_FAB_TAKE_PHOTO;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_MERGE;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_POSTPONE;
Expand Down Expand Up @@ -71,6 +72,7 @@
import static pk.tappdesign.knizka.utils.Navigation.UNCATEGORIZED;


import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
Expand All @@ -82,6 +84,7 @@
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
Expand Down Expand Up @@ -117,6 +120,7 @@
import androidx.recyclerview.widget.RecyclerView;
import com.afollestad.materialdialogs.MaterialDialog;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.pixplicity.easyprefs.library.Prefs;

import de.greenrobot.event.EventBus;
Expand Down Expand Up @@ -177,6 +181,8 @@
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.Toast;

import pk.tappdesign.knizka.async.bus.NotesUpdatedEvent;

public class ListFragment extends BaseFragment implements OnViewTouchedListener, UndoBarController.UndoListener, OnLinkedNoteAdded {
Expand Down Expand Up @@ -1212,6 +1218,18 @@ public void onClick(View v) {


private void addReminders () {
if (!ReminderHelper.checkPermisson(Knizka.getAppContext()))
{
startActivity(new Intent(android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM, Uri.parse("package:"+ Knizka.getAppContext().getPackageName())));
}

requestPermission(getActivity(), Manifest.permission.POST_NOTIFICATIONS, R
.string.permission_post_notifications,
getActivity().findViewById(R.id.crouton_handle), () -> {
//mainActivity.showToast(getText(R.string.permission_post_notifications_granted), Toast.LENGTH_LONG);
});


Intent intent = new Intent(Knizka.getAppContext(), SnoozeActivity.class);
intent.setAction(ACTION_POSTPONE);
intent.putExtra(INTENT_NOTE, selectedNotes.toArray(new Note[selectedNotes.size()]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

package pk.tappdesign.knizka;

import static android.provider.Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_NOTIFICATION_CLICK;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_PICKED_FROM_BROWSE_TEXTS;
import static pk.tappdesign.knizka.utils.ConstantsBase.ACTION_RESTART_APP;
Expand Down Expand Up @@ -131,6 +132,7 @@ protected void onCreate (Bundle savedInstanceState) {

// check for an apk update
new UpdaterTask(this).execute();

new RestoreRemindersTask().execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.text.TextUtils;
import android.widget.Toast;
Expand All @@ -48,6 +49,23 @@ private ReminderHelper() {
// hides public constructor
}

public static boolean checkPermisson(Context context) {

boolean result = false;

AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (am.canScheduleExactAlarms())
{
result = true;
}
} else {
result = true;
}
return result;
}

public static void addReminder(Context context, Note note) {
if (note.getAlarm() != null) {
addReminder(context, note, Long.parseLong(note.getAlarm()));
Expand All @@ -61,7 +79,16 @@ public static void addReminder(Context context, Note note, long reminder) {
intent.putExtra(INTENT_NOTE, ParcelableUtil.marshall(note));
PendingIntent sender = NotificationsHelper.getBroatcastPendingIntent(context, getRequestCode(note), intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.setExact(AlarmManager.RTC_WAKEUP, reminder, sender);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (am.canScheduleExactAlarms())
{
am.setExact(AlarmManager.RTC_WAKEUP, reminder, sender);
} else {
am.set(AlarmManager.RTC_WAKEUP, reminder, sender);
}
} else {
am.setExact(AlarmManager.RTC_WAKEUP, reminder, sender);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion Knizka_Project/src/main/res/raw/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<changelog bulletedList="true">

<changelogversion
changeDate="Máj 17, 2024"
versionName="2.3.9">
<changelogtext>[b]Fix:[/b] Vyžiadanie povolenia pre notifikácie</changelogtext>
</changelogversion>
<changelogversion
changeDate="Máj 1, 2024"
versionName="2.3.8">
Expand Down
2 changes: 2 additions & 0 deletions Knizka_Project/src/main/res/values-sk-rSK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
<string name="remove_filter_old_reminders">Zobraziť staré pripomienky</string>
<string name="filter_archived">Skryť archivované položky</string>
<string name="remove_filter_archived">Zobraziť archivované položky</string>
<string name="permission_post_notifications_granted">Povolenie bolo udelené</string>
<string name="permission_post_notifications">Je potrebné povolenie pre zobrazovanie notifikácií...</string>
<string name="permission_external_storage">Povolenie na zápis na externé úložisko je potrebné na ukladanie záloh do verejných priečinkov</string>
<string name="permission_external_storage_detail_attachment">Permission to read on external storage is needed to allow attaching files from there</string>
<string name="permission_audio_recording">Povolenie na použitie mikrofónu je potrebné na nahrávanie zvukových poznámok</string>
Expand Down
2 changes: 2 additions & 0 deletions Knizka_Project/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@
<string name="remove_filter_old_reminders">Show old reminders</string>
<string name="filter_archived">Hide archived notes</string>
<string name="remove_filter_archived">Show archived notes</string>
<string name="permission_post_notifications_granted">Permission was granted</string>
<string name="permission_post_notifications">Permission for Posting notifications needed...</string>
<string name="permission_external_storage">Permission to write on external storage is needed to allow backups on public folders</string>
<string name="permission_external_storage_detail_attachment">Permission to read on external storage is needed to allow attaching files from there</string>
<string name="permission_audio_recording">Permission to use microphone is needed to record audio notes</string>
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
VERSION_NAME=2.3.8
VERSION_CODE=38
VERSION_NAME=2.3.9
VERSION_CODE=39
PACKAGE=pk.tappdesign.knizka
MIN_SDK=19
# Upgrading this to 24+ will need ContentProvider for sharing and camera attachments
Expand Down

0 comments on commit 2d15523

Please sign in to comment.