parent
5081c26430
commit
45bfe3227f
11 changed files with 73 additions and 51 deletions
|
@ -224,23 +224,23 @@ public class CalendarFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
nextMonth.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
Calendar midnightToday = Calendar.getInstance();
|
||||
midnightToday.set(Calendar.HOUR, 0);
|
||||
midnightToday.set(Calendar.MINUTE, 0);
|
||||
midnightToday.set(Calendar.SECOND, 0);
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
Calendar midnightToday = Calendar.getInstance();
|
||||
midnightToday.set(Calendar.HOUR, 0);
|
||||
midnightToday.set(Calendar.MINUTE, 0);
|
||||
midnightToday.set(Calendar.SECOND, 0);
|
||||
|
||||
mCalendar.add(Calendar.YEAR, 1);
|
||||
if (mCalendar.after(midnightToday)) {
|
||||
mCalendar = midnightToday;
|
||||
}
|
||||
gridCalendar.setAdapter(getMonthAdapter());
|
||||
mCalendar.add(Calendar.YEAR, 1);
|
||||
if (mCalendar.after(midnightToday)) {
|
||||
mCalendar = midnightToday;
|
||||
}
|
||||
gridCalendar.setAdapter(getMonthAdapter());
|
||||
|
||||
updateMonthScroll();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
updateMonthScroll();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout ldate = new LinearLayout(ctx);
|
||||
ldate.setOrientation(LinearLayout.VERTICAL);
|
||||
|
|
|
@ -275,7 +275,7 @@ public class CompleteActivity extends Activity {
|
|||
getMeditationAssistant().shortToast(getString(R.string.sessionPosting));
|
||||
getMeditationAssistant().getMediNET().session.message = getSessionMessage();
|
||||
getMeditationAssistant().getMediNET().session.modified = getMeditationAssistant().getTimestamp();
|
||||
getMeditationAssistant().getMediNET().postSession(0,null, completeRunnable);
|
||||
getMeditationAssistant().getMediNET().postSession(0, null, completeRunnable);
|
||||
}
|
||||
|
||||
private void saveLastMessage() {
|
||||
|
|
|
@ -104,7 +104,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
Cursor c = db.rawQuery("UPDATE `" + TABLE_SESSIONS + "` SET `" + KEY_STARTED + "`=?, `" + KEY_COMPLETED + "`=?, `" + KEY_LENGTH + "`=?, `" + KEY_MESSAGE + "`=?, `" + KEY_ISPOSTED + "`=?, `" + KEY_STREAKDAY + "`=?, `" + KEY_MODIFIED + "`=? WHERE `" + KEY_STARTED + "`=? OR`" + KEY_STARTED + "`=?",
|
||||
new String[]{String.valueOf(session._started), String.valueOf(session._completed), String.valueOf(session._length),session._message,String.valueOf(session._isposted),String.valueOf(session._streakday),String.valueOf(session._modified), String.valueOf(session._started), String.valueOf(updateSessionStarted)});
|
||||
new String[]{String.valueOf(session._started), String.valueOf(session._completed), String.valueOf(session._length), session._message, String.valueOf(session._isposted), String.valueOf(session._streakday), String.valueOf(session._modified), String.valueOf(session._started), String.valueOf(updateSessionStarted)});
|
||||
c.moveToFirst();
|
||||
c.close();
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class DatabaseHandler extends SQLiteOpenHelper {
|
|||
}
|
||||
|
||||
SessionSQL getSessionByStarted(long started) {
|
||||
ArrayList<SessionSQL> sessions = unmarshalResult(db.rawQuery("SELECT * FROM `" + TABLE_SESSIONS + "` WHERE `" + KEY_STARTED + "`=? LIMIT 1", new String[]{String.valueOf(started)}));
|
||||
ArrayList<SessionSQL> sessions = unmarshalResult(db.rawQuery("SELECT * FROM `" + TABLE_SESSIONS + "` WHERE `" + KEY_STARTED + "`=? LIMIT 1", new String[]{String.valueOf(started)}));
|
||||
if (sessions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
|
||||
public MeditationAssistant ma = null;
|
||||
SharedPreferences.OnSharedPreferenceChangeListener sharedPrefslistener = (newprefs, key) -> {
|
||||
Log.d("MeditationAssistant",key + " changed to " + getMeditationAssistant().getPrefs().getAll().get(key).toString());
|
||||
Log.d("MeditationAssistant", key + " changed to " + getMeditationAssistant().getPrefs().getAll().get(key).toString());
|
||||
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
if ((key.equals("timerHours") || key.equals("timerMinutes")) && getMeditationAssistant().getTimeToStopMeditate() < 1) {
|
||||
|
@ -1167,8 +1167,9 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
params.screenBrightness = -1;
|
||||
getWindow().setAttributes(params);
|
||||
|
||||
getMeditationAssistant().longToast(getString(R.string.pausedNotification));
|
||||
//}
|
||||
if (view != null) {
|
||||
getMeditationAssistant().longToast(getString(R.string.pausedNotification));
|
||||
}
|
||||
} else { // Paused, un-pause
|
||||
long pausetime = getMeditationAssistant().unPauseSession();
|
||||
|
||||
|
@ -1266,7 +1267,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
if (end_at_hour >= c_now.get(Calendar.HOUR_OF_DAY)) { // later today (before noon)
|
||||
Log.d("MeditationAssistant", "End at debug: B LATER TODAY BEFORE NOON");
|
||||
if (end_at_hour == c_now.get(Calendar.HOUR_OF_DAY) && end_at_minute <= c_now.get(Calendar.MINUTE)) { // End at is now or earlier
|
||||
getMeditationAssistant().shortToast( getString(R.string.invalidEndAt));
|
||||
getMeditationAssistant().shortToast(getString(R.string.invalidEndAt));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1776,7 +1777,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
getMeditationAssistant().getMediNET().connect();
|
||||
}
|
||||
} else if (getIntent().getAction().equals("notificationPause")) {
|
||||
if (getMeditationAssistant().getTimeStartMeditate() > 0 && !getMeditationAssistant().ispaused) {
|
||||
if (getMeditationAssistant().getTimeStartMeditate() > 0) {
|
||||
updateMeditate(false, false);
|
||||
pressMeditate(new View(getApplicationContext()));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class MediNETTask extends AsyncTask<MediNET, Integer, MediNET> {
|
|||
public String nextURL = null;
|
||||
public String action = "";
|
||||
public String actionextra = "";
|
||||
public Long actionextranumber = (long)0;
|
||||
public Long actionextranumber = (long) 0;
|
||||
public MediNET medinet;
|
||||
private MeditationAssistant ma = null;
|
||||
public Runnable onComplete;
|
||||
|
@ -299,13 +299,13 @@ public class MediNETTask extends AsyncTask<MediNET, Integer, MediNET> {
|
|||
for (SessionSQL sessionsql : sessions) {
|
||||
sessionsql._isposted = (long) 1;
|
||||
sessionsql._modified = getMeditationAssistant().getTimestamp();
|
||||
getMeditationAssistant().db.addSession(sessionsql, (long)0);
|
||||
getMeditationAssistant().db.addSession(sessionsql, (long) 0);
|
||||
}
|
||||
|
||||
Integer sessuploaded = sessions.size();
|
||||
getMeditationAssistant().longToast(String.format(getMeditationAssistant().getResources().getQuantityString(
|
||||
R.plurals.sessionsUploaded, sessuploaded,
|
||||
sessuploaded), String.valueOf(sessuploaded))
|
||||
R.plurals.sessionsUploaded, sessuploaded,
|
||||
sessuploaded), String.valueOf(sessuploaded))
|
||||
);
|
||||
} else {
|
||||
getMeditationAssistant().longToast(getMeditationAssistant().getString(R.string.sessionsNotImported));
|
||||
|
@ -337,7 +337,7 @@ public class MediNETTask extends AsyncTask<MediNET, Integer, MediNET> {
|
|||
"Adding session started at "
|
||||
+ String.valueOf(sess._started)
|
||||
);
|
||||
getMeditationAssistant().db.addSession(sess, (long)0);
|
||||
getMeditationAssistant().db.addSession(sess, (long) 0);
|
||||
getMeditationAssistant().recalculateMeditationStreak(medinet.activity);
|
||||
} else {
|
||||
Log.d("MeditationAssistant",
|
||||
|
@ -347,8 +347,8 @@ public class MediNETTask extends AsyncTask<MediNET, Integer, MediNET> {
|
|||
|
||||
if (sessimported > 0) {
|
||||
getMeditationAssistant().longToast(String.format(getMeditationAssistant().getResources().getQuantityString(
|
||||
R.plurals.sessionsImported, sessimported,
|
||||
sessimported), String.valueOf(sessimported))
|
||||
R.plurals.sessionsImported, sessimported,
|
||||
sessimported), String.valueOf(sessimported))
|
||||
);
|
||||
} else {
|
||||
getMeditationAssistant().longToast(getMeditationAssistant().getString(R.string.sessionsNotImported));
|
||||
|
@ -388,7 +388,7 @@ public class MediNETTask extends AsyncTask<MediNET, Integer, MediNET> {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(MediNET medinet) {
|
||||
Log.d("MeditationAssistant","onPostExecute: " + action);
|
||||
Log.d("MeditationAssistant", "onPostExecute: " + action);
|
||||
medinet.updated();
|
||||
|
||||
if (onComplete != null) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.app.AlarmManager;
|
|||
import android.app.AlertDialog;
|
||||
import android.app.Application;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
|
@ -27,13 +27,13 @@ import android.os.SystemClock;
|
|||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
|
@ -1009,6 +1009,10 @@ public class MeditationAssistant extends Application {
|
|||
|
||||
getPrefs().registerOnSharedPreferenceChangeListener(sharedPrefslistener);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
createNotificationChannel();
|
||||
}
|
||||
|
||||
// Reset timer to default values
|
||||
if (!getPrefs().getBoolean("pref_rememberlasttimer", true)) {
|
||||
SharedPreferences.Editor editor = getPrefs().edit();
|
||||
|
@ -1141,6 +1145,7 @@ public class MeditationAssistant extends Application {
|
|||
Log.d("MeditationAssistant", "PAUSE: Un-paused. Paused for " + String.valueOf(thispausetime) + " seconds (" + String.valueOf(pausetime) + " total)");
|
||||
|
||||
ispaused = false;
|
||||
|
||||
return thispausetime;
|
||||
}
|
||||
|
||||
|
@ -1233,6 +1238,16 @@ public class MeditationAssistant extends Application {
|
|||
streakDifferenceDialog.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
public void createNotificationChannel() {
|
||||
NotificationChannel channel = new NotificationChannel("session", getString(R.string.session), NotificationManager.IMPORTANCE_LOW);
|
||||
channel.enableLights(false);
|
||||
channel.enableVibration(false);
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
public void showNotification() {
|
||||
if (!getPrefs().getBoolean("pref_notification", true)
|
||||
|| getTimeStartMeditate() < 1) {
|
||||
|
@ -1265,21 +1280,25 @@ public class MeditationAssistant extends Application {
|
|||
streaktext = String.valueOf(getMeditationStreak().get(0));
|
||||
}
|
||||
|
||||
Notification notification = new NotificationCompat.Builder(this)
|
||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
.setContentTitle(getString(R.string.sessionInProgress))
|
||||
.setContentTitle(getString(!ispaused ? R.string.sessionInProgress : R.string.sessionPaused))
|
||||
.setContentText(getString(R.string.appName))
|
||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setContentInfo(streaktext)
|
||||
.setContentIntent(pIntent)
|
||||
.addAction(R.drawable.ic_action_pause,
|
||||
getString(R.string.pause), pIntentPause)
|
||||
getString(!ispaused ? R.string.pause : R.string.resume), pIntentPause)
|
||||
.addAction(R.drawable.ic_action_stop,
|
||||
getString(R.string.end), pIntentEnd).build();
|
||||
getString(R.string.end), pIntentEnd);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
notificationBuilder.setChannelId("session");
|
||||
}
|
||||
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(0, notification);
|
||||
notificationManager.notify(0, notificationBuilder.build());
|
||||
}
|
||||
|
||||
public void showSessionDialog(final SessionSQL session, Activity activity) {
|
||||
|
@ -1866,7 +1885,7 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
|
||||
public ArrayList<Long> dateToSessionWindow(Calendar c) {
|
||||
ArrayList<Long>sessionWindow = new ArrayList<Long>();
|
||||
ArrayList<Long> sessionWindow = new ArrayList<Long>();
|
||||
ArrayList<Integer> streakbuffertime = getStreakBufferTime();
|
||||
Calendar sessionWindowCalendar = (Calendar) c.clone();
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ public class SessionSQL {
|
|||
public Long _modified;
|
||||
|
||||
public SessionSQL() {
|
||||
this._id = (long)0;
|
||||
this._started = (long)0;
|
||||
this._completed = (long)0;
|
||||
this._length = (long)0;
|
||||
this._id = (long) 0;
|
||||
this._started = (long) 0;
|
||||
this._completed = (long) 0;
|
||||
this._length = (long) 0;
|
||||
this._message = "";
|
||||
this._isposted = (long)0;
|
||||
this._streakday = (long)0;
|
||||
this._modified = (long)0;
|
||||
this._isposted = (long) 0;
|
||||
this._streakday = (long) 0;
|
||||
this._modified = (long) 0;
|
||||
}
|
||||
|
||||
public SessionSQL(Long id, Long started, Long completed, Long length, String message,
|
||||
|
|
|
@ -90,7 +90,7 @@ public class SessionsFragment extends ListFragment {
|
|||
getMeditationAssistant().getMediNET().session.message = selected_session._message;
|
||||
getMeditationAssistant().getMediNET().session.streakday = selected_session._streakday;
|
||||
getMeditationAssistant().getMediNET().session.modified = selected_session._modified;
|
||||
getMeditationAssistant().getMediNET().postSession(0,null, null);
|
||||
getMeditationAssistant().getMediNET().postSession(0, null, null);
|
||||
}
|
||||
} else { // Delete
|
||||
AlertDialog deleteDialog = new AlertDialog.Builder(
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<string name="meditate">Meditate</string>
|
||||
<string name="tapToSkip">Skip</string>
|
||||
<string name="pause">Pause</string>
|
||||
<string name="resume">Resume</string>
|
||||
<string name="end">End</string>
|
||||
<string name="pauseOrEnd">Pause or end</string>
|
||||
<string name="resumeOrEnd">Resume or end</string>
|
||||
|
@ -45,6 +46,7 @@
|
|||
<string name="mediNETConnecting">Connecting…</string>
|
||||
<string name="mediNETConnected">Connected to MediNET</string>
|
||||
<string name="sessionInProgress">Session in progress</string>
|
||||
<string name="sessionPaused">Session paused</string>
|
||||
<string name="progress">Progress</string>
|
||||
<string name="setPreset">Set preset</string>
|
||||
<string name="setPresetHint">Hold to set preset</string>
|
||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Wed Apr 24 02:10:50 PDT 2019
|
||||
#Sun Sep 08 04:16:13 PDT 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
|
|
Loading…
Reference in a new issue