Add mindfulness bell

merge-requests/7/head
Trevor Slocum 2020-12-28 11:56:35 -08:00
parent 7793c3e888
commit 77339f02c1
10 changed files with 311 additions and 29 deletions

View File

@ -1,3 +1,6 @@
1.6.3:
- Add mindfulness bell
1.6.2:
- Add audio output setting (alarm/media/ringtone/notification)

View File

@ -8,8 +8,8 @@ android {
minSdkVersion 16
targetSdkVersion 29
versionCode 162
versionName "1.6.2"
versionCode 163
versionName "1.6.3"
applicationId "sh.ftp.rocketninelabs.meditationassistant"
manifestPlaceholders = [
@ -78,7 +78,7 @@ dependencies {
implementation 'androidx.core:core:1.3.2'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.media:media:1.2.0'
implementation 'androidx.media:media:1.2.1'
implementation 'androidx.fragment:fragment:1.2.5'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.1'

View File

@ -37,7 +37,7 @@ public class CompleteActivity extends Activity {
setTheme(getMeditationAssistant().getMATheme());
setContentView(R.layout.activity_complete);
getMeditationAssistant().hideNotification(); // Called twice because it seems to help
getMeditationAssistant().hideSessionNotification(); // Called twice because it seems to help
if (getMeditationAssistant().getPrefs().getString("pref_full_screen", "").equals("always")) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
@ -79,7 +79,7 @@ public class CompleteActivity extends Activity {
}
getMeditationAssistant().unsetNotificationControl();
getMeditationAssistant().hideNotification(); // Called twice because it seems to help
getMeditationAssistant().hideSessionNotification(); // Called twice because it seems to help
EditText editSessionMessage = findViewById(R.id.editSessionMessage);
if (editSessionMessage.getText().toString().equals("")

View File

@ -57,6 +57,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
public static int ID_DELAY = 77702;
public static int ID_INTERVAL = 77701;
public static int ID_END = 77703;
public static int ID_BELL = 77704;
public MeditationAssistant ma = null;
SharedPreferences.OnSharedPreferenceChangeListener sharedPrefslistener = (newprefs, key) -> {
@ -156,6 +157,25 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
private Boolean finishedTutorial = null;
private String wakeLockID;
private boolean mindfulnessBellActive;
private PendingIntent mindfulnessBellIntent;
private long mindfulnessBellNextChime;
private Runnable mindfulnessBellRunnable = new Runnable() {
@Override
public void run() {
handler.removeCallbacks(this);
if (!mindfulnessBellActive) {
return;
}
Log.d("MeditationAssistant", "Mindfulness bell chiming");
getMeditationAssistant().notifySession(3, true, false);
setMindfulnessBellAlarm();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -442,7 +462,9 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
}
}
if (item.getItemId() == R.id.action_how_to_meditate) {
if (item.getItemId() == R.id.action_mindfulness_bell) {
activateMindfulnessBell();
} else if (item.getItemId() == R.id.action_how_to_meditate) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(MeditationAssistant.URL_MEDINET + "/howtomeditate")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else if (item.getItemId() == R.id.action_reddit_community) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://old.reddit.com/r/meditation")).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
@ -1468,6 +1490,41 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
}
}
private void setMindfulnessBellAlarm() {
if (mindfulnessBellNextChime == 0) {
mindfulnessBellNextChime = System.currentTimeMillis() / 1000;
}
int mindfulnessBellDuration = Integer.parseInt(getMeditationAssistant().getPrefs().getString("bellHours", "0")) * 3600 + (Integer.parseInt(getMeditationAssistant().getPrefs().getString("bellMinutes", "15")) * 60);
if (mindfulnessBellDuration == 0) {
return;
}
mindfulnessBellNextChime += mindfulnessBellDuration;
Log.d("MeditationAssistant", "Mindfulness bell is set to " + mindfulnessBellDuration + " seconds. Next chime at " + mindfulnessBellNextChime);
if (mindfulnessBellIntent != null) {
am.cancel(mindfulnessBellIntent);
}
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(mindfulnessBellNextChime * 1000);
Log.d("MeditationAssistant", "Setting BELL WAKEUP alarm for "
+ cal.getTimeInMillis() + " (Now: "
+ System.currentTimeMillis() + ", in: " + (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000 + ")");
Intent intent_bell = new Intent(
getApplicationContext(), MainActivity.class);
intent_bell.putExtra("wakeup", true);
intent_bell.putExtra("wakeupbell", true);
intent_bell.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent_bell.setAction(BROADCAST_ACTION_ALARM);
mindfulnessBellIntent = PendingIntent.getActivity(getApplicationContext(), ID_BELL, intent_bell, PendingIntent.FLAG_CANCEL_CURRENT);
getMeditationAssistant().setAlarm(true, cal.getTimeInMillis(), mindfulnessBellIntent);
}
private void screenDimOrOff() {
String pref_screencontrol = getMeditationAssistant().getPrefs().getString("pref_screencontrol", "dim");
if (!pref_screencontrol.equals("ondim") && !pref_screencontrol.equals("dim") && !pref_screencontrol.equals("off")) {
@ -1494,6 +1551,76 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
handler.postDelayed(screenDimRunnable, 250);
}
private void activateMindfulnessBell() {
if (mindfulnessBellActive) {
mindfulnessBellActive = false;
mindfulnessBellNextChime = 0;
if (mindfulnessBellIntent != null) {
am.cancel(mindfulnessBellIntent);
}
handler.removeCallbacks(mindfulnessBellRunnable);
getMeditationAssistant().hideBellNotification();
return;
}
getMeditationAssistant().clearSoundCache();
getMeditationAssistant().cacheSessionSounds();
LayoutInflater presetInflater = getLayoutInflater();
View presetLayout = presetInflater.inflate(R.layout.mindfulness_bell, null);
final EditText editBellDuration = presetLayout.findViewById(R.id.editBellDuration);
editBellDuration.setText(getMeditationAssistant().getPrefs().getString("bellHours", "0") + ":" + String.format("%02d", Integer.valueOf(getMeditationAssistant().getPrefs().getString("bellMinutes", "0"))));
editBellDuration.setSelection(editBellDuration.getText().length());
editBellDuration.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(), new int[]{R.attr.actionIconTime}).getResourceId(0, 0)))
.setTitle(getString(R.string.mindfulnessBell))
.setView(presetLayout)
.setPositiveButton(getString(R.string.start),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Set below
}
})
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// Do nothing
}
});
AlertDialog dialog = builder.create();
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ArrayList<String> duration_formatted = getMeditationAssistant().formatDuration(editBellDuration.getText().toString().trim());
if (duration_formatted != null && duration_formatted.size() == 2) {
SharedPreferences.Editor editor = getMeditationAssistant().getPrefs().edit();
editor.putString("bellHours", duration_formatted.get(0));
editor.putString("bellMinutes", duration_formatted.get(1));
editor.apply();
mindfulnessBellActive = true;
getMeditationAssistant().showMindfulnessBellNotification();
handler.removeCallbacks(mindfulnessBellRunnable);
handler.postDelayed(mindfulnessBellRunnable, 2000);
dialog.dismiss();
return;
}
getMeditationAssistant().shortToast(getString(R.string.setTimerDurationHint));
}
});
}
public boolean longPressMeditate(View view) {
long timestamp = System.currentTimeMillis() / 1000;
Log.d("MeditationAssistant", "stopMedidate");
@ -1517,7 +1644,9 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
getMeditationAssistant().releaseAllWakeLocks();
getMeditationAssistant().restoreVolume();
if (getMeditationAssistant().getTimeStartMeditate() != 0) {
if (getMeditationAssistant().getTimeStartMeditate() == 0) {
activateMindfulnessBell();
} else {
if (view != null
&& timestamp
- getMeditationAssistant().getTimeStartMeditate() > 0) {
@ -1539,10 +1668,9 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
handler.removeCallbacks(screenDimRunnable);
handler.removeCallbacks(screenOffRunnable);
getMeditationAssistant().setRunnableStopped(true);
return true;
}
return false;
return true;
}
public void onTimerModeSelected(View view) {
@ -1567,7 +1695,6 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
if (usetimepicker) {
timepickerDuration.setEnabled(true);
} else {
if (editDuration.getText().toString().equals(getString(R.string.ignore_om))) {
if (newTimerMode.equals("endat")) { // Don't leave om character in edit text
editDuration.setText(getMeditationAssistant().getPrefs().getString("timerHoursEndAt", "0")
@ -1599,7 +1726,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
protected void onPause() {
if (getMeditationAssistant().getTimeStartMeditate() > 0
&& getMeditationAssistant().getTimeToStopMeditate() != 0) {
getMeditationAssistant().showNotification();
getMeditationAssistant().showSessionNotification();
}
getMeditationAssistant().setScreenOff(true);
@ -1610,7 +1737,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
@Override
protected void onResume() {
getMeditationAssistant().hideNotification();
getMeditationAssistant().hideSessionNotification();
if (getIntent().getStringExtra("action") != null) {
Log.d("MeditationAssistant", "Intent for MainActivity: "
@ -1805,6 +1932,14 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
if (getMeditationAssistant().getTimeStartMeditate() > 0) {
longPressMeditate(new View(getApplicationContext()));
}
} else if (getIntent().getAction().equals("notificationEndBell")) {
mindfulnessBellActive = false;
mindfulnessBellNextChime = 0;
if (mindfulnessBellIntent != null) {
am.cancel(mindfulnessBellIntent);
}
handler.removeCallbacks(mindfulnessBellRunnable);
getMeditationAssistant().hideBellNotification();
}
}
@ -1812,6 +1947,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
Boolean fullWakeUp = intent.getBooleanExtra("fullwakeup", false);
Boolean wakeUpStart = intent.getBooleanExtra("wakeupstart", false);
Boolean wakeUpInterval = intent.getBooleanExtra("wakeupinterval", false);
Boolean wakeUpBell = intent.getBooleanExtra("wakeupbell", false);
Log.d("MeditationAssistant", "ALARM RECEIVER INTEGRATED: Received broadcast - Full: " + (fullWakeUp ? "Full" : "Partial") + " - Start/interval: " + (wakeUpStart ? "Start" : (wakeUpInterval ? "Interval" : "Neither")));
@ -1886,6 +2022,9 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
Log.d("MeditationAssistant", "Skipping INTERVAL WAKEUP alarm");
}
}
} else if (wakeUpBell) {
Log.d("MeditationAssistant", "Queueing wake up bell runnable");
handler.postDelayed(mindfulnessBellRunnable, 50);
}
if (fullWakeUp) {

View File

@ -101,6 +101,9 @@ public class MeditationAssistant extends Application {
public static int CSV_COLUMN_COUNT = 5;
public static int sessionNotificationID = 1990;
public static int bellNotificationID = 1991;
public boolean ispaused = false;
public long pausestart = 0;
public long pausetime = 0;
@ -568,7 +571,7 @@ public class MeditationAssistant extends Application {
public void cacheSessionSounds() {
String label;
for (int i = 0; i < 3; i++) {
for (int i = 0; i < 4; i++) {
switch (i) {
case 0:
label = "start";
@ -579,6 +582,9 @@ public class MeditationAssistant extends Application {
case 2:
label = "finish";
break;
case 3:
label = "bell";
break;
default:
return;
}
@ -681,6 +687,9 @@ public class MeditationAssistant extends Application {
case 2:
label = "finish";
break;
case 3:
label = "bell";
break;
default:
return;
}
@ -1140,9 +1149,14 @@ public class MeditationAssistant extends Application {
getPrefs().edit().putInt("webviewscale", webview_scale).apply();
}
public void hideNotification() {
public void hideBellNotification() {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancelAll();
notificationManager.cancel(bellNotificationID);
}
public void hideSessionNotification() {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancel(sessionNotificationID);
}
public void longToast(String text) {
@ -1192,7 +1206,7 @@ public class MeditationAssistant extends Application {
getPrefs().registerOnSharedPreferenceChangeListener(sharedPrefslistener);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannel();
createNotificationChannels();
}
// Reset timer to default values
@ -1414,19 +1428,56 @@ public class MeditationAssistant extends Application {
}
@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);
public void createNotificationChannels() {
NotificationChannel sessionChannel = new NotificationChannel("session", getString(R.string.session), NotificationManager.IMPORTANCE_LOW);
sessionChannel.enableLights(false);
sessionChannel.enableVibration(false);
NotificationChannel bellChannel = new NotificationChannel("bell", getString(R.string.session), NotificationManager.IMPORTANCE_LOW);
bellChannel.enableLights(false);
bellChannel.enableVibration(false);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
notificationManager.createNotificationChannel(sessionChannel);
notificationManager.createNotificationChannel(bellChannel);
}
public void showNotification() {
public void showMindfulnessBellNotification() {
Intent intent = new Intent(this, MainActivity.class);
intent.setAction("notification");
// intent.putExtra("notificationButton", "notification");
// intent.putExtra("notificationButton", "");
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
Intent intent3 = new Intent(this, MainActivity.class);
// intent3.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
// intent3.putExtra("notificationButton", "end");
intent3.setAction("notificationEndBell");
PendingIntent pIntentEnd = PendingIntent.getActivity(this, 0, intent3,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setOngoing(true)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(R.string.mindfulnessBellActive))
.setPriority(NotificationCompat.PRIORITY_LOW)
.setContentIntent(pIntent)
.addAction(R.drawable.ic_action_stop,
getString(R.string.deactivate), pIntentEnd);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notificationBuilder.setChannelId("bell");
}
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(bellNotificationID, notificationBuilder.build());
}
public void showSessionNotification() {
if (!getPrefs().getBoolean("pref_notification", true)
|| getTimeStartMeditate() < 1) {
hideNotification();
hideSessionNotification();
return;
}
@ -1459,7 +1510,6 @@ public class MeditationAssistant extends Application {
.setOngoing(true)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(!ispaused ? R.string.sessionInProgress : R.string.sessionPaused))
.setContentText(getString(R.string.appNameShort))
.setPriority(NotificationCompat.PRIORITY_LOW)
.setContentInfo(streaktext)
.setContentIntent(pIntent)
@ -1473,7 +1523,7 @@ public class MeditationAssistant extends Application {
}
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
notificationManager.notify(sessionNotificationID, notificationBuilder.build());
}
public void showSessionDialog(final SessionSQL session, Activity activity) {

View File

@ -52,6 +52,7 @@ public class SettingsActivity extends PreferenceActivity {
static int FILEPICKER_SELECT_SOUND_START = 101;
static int FILEPICKER_SELECT_SOUND_INTERVAL = 102;
static int FILEPICKER_SELECT_SOUND_FINISH = 103;
static int FILEPICKER_SELECT_SOUND_BELL = 110;
static int FILEPICKER_IMPORT_SESSIONS_UTC = 104;
static int FILEPICKER_IMPORT_SESSIONS_LOCAL = 105;
static int FILEPICKER_EXPORT_SESSIONS = 106;
@ -66,6 +67,7 @@ public class SettingsActivity extends PreferenceActivity {
public Boolean initialSoundChangeStart = true;
public Boolean initialSoundChangeInterval = true;
public Boolean initialSoundChangeFinish = true;
public Boolean initialSoundChangeBell = true;
public Boolean initialVibrationChangeStart = true;
public Boolean initialVibrationChangeInterval = true;
public Boolean initialVibrationChangeFinish = true;
@ -197,6 +199,15 @@ public class SettingsActivity extends PreferenceActivity {
preference.setSummary(customSoundSummary(getMeditationAssistant().getPrefs().getString("pref_meditation_sound_finish_custom", "")));
}
initialSoundChangeFinish = false;
} else if (listPreference.getKey().equals("pref_meditation_sound_bell")) {
if (stringValue.equals("custom")) {
if (!initialSoundChangeBell) {
selectCustomSound(FILEPICKER_SELECT_SOUND_BELL);
}
preference.setSummary(customSoundSummary(getMeditationAssistant().getPrefs().getString("pref_meditation_sound_bell_custom", "")));
}
initialSoundChangeBell = false;
} else if (listPreference.getKey().equals("pref_meditation_vibrate_start")) {
if (stringValue.equals("custom") && !initialVibrationChangeStart) {
selectCustomVibration(SElECT_VIBRATION_START);
@ -546,6 +557,9 @@ public class SettingsActivity extends PreferenceActivity {
} else if (requestCode == FILEPICKER_SELECT_SOUND_FINISH) {
pref_key = "pref_meditation_sound_finish";
pref = "pref_meditation_sound_finish_custom";
} else if (requestCode == FILEPICKER_SELECT_SOUND_BELL) {
pref_key = "pref_meditation_sound_bell";
pref = "pref_meditation_sound_bell_custom";
} else {
return;
}
@ -558,7 +572,9 @@ public class SettingsActivity extends PreferenceActivity {
initialSoundChangeInterval = true;
} else if (requestCode == FILEPICKER_SELECT_SOUND_FINISH) {
initialSoundChangeFinish = true;
}
} else if (requestCode == FILEPICKER_SELECT_SOUND_BELL) {
initialSoundChangeBell = true;
}
ListPreferenceSound prefMeditationSound = (ListPreferenceSound) (sessionPreferenceFragment == null ? findPreference(pref_key) : sessionPreferenceFragment.findPreference(pref_key));
prefMeditationSound.getOnPreferenceChangeListener().onPreferenceChange(prefMeditationSound, getMeditationAssistant().getPrefs().getString(pref_key, "gong"));
@ -596,7 +612,7 @@ public class SettingsActivity extends PreferenceActivity {
setupSimplePreferencesScreen();
}
void setupSoundPreferences(PreferenceFragment preferenceFragment) {
void setupSessionSoundPreferences(PreferenceFragment preferenceFragment) {
String[] meditation_sounds = getResources().getStringArray(R.array.meditation_sounds);
String[] meditation_sounds_values = getResources().getStringArray(R.array.meditation_sounds_values);
@ -619,6 +635,15 @@ public class SettingsActivity extends PreferenceActivity {
}
}
void setupMeditationSoundPreferences(PreferenceFragment preferenceFragment) {
String[] meditation_sounds = getResources().getStringArray(R.array.meditation_sounds);
String[] meditation_sounds_values = getResources().getStringArray(R.array.meditation_sounds_values);
ListPreferenceSound prefMeditationSoundBell = (ListPreferenceSound) (preferenceFragment == null ? findPreference("pref_meditation_sound_bell") : preferenceFragment.findPreference("pref_meditation_sound_bell"));
prefMeditationSoundBell.setEntries(meditation_sounds);
prefMeditationSoundBell.setEntryValues(meditation_sounds_values);
}
void setupVibrationPreferences(PreferenceFragment preferenceFragment) {
String[] vibration = getResources().getStringArray(R.array.vibration);
String[] vibration_values = getResources().getStringArray(R.array.vibration_values);
@ -672,6 +697,7 @@ public class SettingsActivity extends PreferenceActivity {
meditationPreferenceFragment = (MeditationPreferenceFragment) preferenceFragment;
}
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_sound_bell") : preferenceFragment.findPreference("pref_meditation_sound_bell"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_usetimepicker") : preferenceFragment.findPreference("pref_usetimepicker"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_screencontrol") : preferenceFragment.findPreference("pref_screencontrol"));
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_full_screen") : preferenceFragment.findPreference("pref_full_screen"));
@ -831,7 +857,8 @@ public class SettingsActivity extends PreferenceActivity {
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_miscellaneous);
setupSoundPreferences(null);
setupSessionSoundPreferences(null);
setupMeditationSoundPreferences(null);
setupVibrationPreferences(null);
setupPreferences("all", null);
}
@ -918,7 +945,7 @@ public class SettingsActivity extends PreferenceActivity {
getPreferenceScreen().removePreference(prefCatSession);
SettingsActivity settingsactivity = (SettingsActivity) getActivity();
settingsactivity.setupSoundPreferences(this);
settingsactivity.setupSessionSoundPreferences(this);
settingsactivity.setupVibrationPreferences(this);
settingsactivity.setupPreferences("session", this);
}
@ -950,6 +977,7 @@ public class SettingsActivity extends PreferenceActivity {
addPreferencesFromResource(R.xml.pref_meditation);
SettingsActivity settingsactivity = (SettingsActivity) getActivity();
settingsactivity.setupMeditationSoundPreferences(this);
settingsactivity.setupPreferences("meditation", this);
}
}

View File

@ -0,0 +1,45 @@
<!--suppress AndroidMissingOnClickHandler -->
<RelativeLayout
android:id="@+id/mindfulnessbell_root"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="7dp"
android:paddingLeft="7dp"
android:paddingRight="7dp"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="@string/interval"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<EditText
android:id="@+id/editBellDuration"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="21dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -7,6 +7,9 @@
android:showAsAction="always"
android:title="@string/resources">
<menu>
<item
android:id="@+id/action_mindfulness_bell"
android:title="@string/mindfulnessBell" />
<item
android:id="@+id/action_how_to_meditate"
android:title="@string/howToMeditate" />

View File

@ -65,6 +65,10 @@
<string name="unlimited">Unlimited</string>
<string name="presetLabelEndAt">End %s</string>
<string name="resources">Resources</string>
<string name="mindfulnessBell">Mindfulness bell</string>
<string name="mindfulnessBellActive">Mindfulness bell active</string>
<string name="interval">Interval</string>
<string name="deactivate">Deactivate</string>
<string name="howToMeditate">How to meditate</string>
<string name="meditationSubreddit">Reddit community</string>
<string name="whatIsMediNET">MediNET overview</string>
@ -164,6 +168,7 @@
<string name="disabled">Disabled</string>
<string name="none">None</string>
<string name="noSpecialBehavior">No special behavior</string>
<string name="start">Start</string>
<string name="labelShort">Short</string>
<string name="labelMedium">Medium</string>
<string name="labelLong">Long</string>
@ -197,6 +202,7 @@
<string name="pref_meditation_sound_start">Start sound</string>
<string name="pref_meditation_sound_interval">Interval sound</string>
<string name="pref_meditation_sound_finish">Complete sound</string>
<string name="pref_meditation_sound_bell">Mindfulness bell sound</string>
<string name="pref_remembermessage">Remember last message</string>
<string name="pref_remembermessage_summary">Default to the previous message</string>
<string name="pref_theme">Holographic theme</string>

View File

@ -19,6 +19,14 @@
android:summary="@string/pref_usetimepicker_summary"
android:title="@string/pref_usetimepicker"/>
<sh.ftp.rocketninelabs.meditationassistant.ListPreferenceSound
android:defaultValue="gong"
android:dialogIcon="?attr/actionIconVolumeOn"
android:entries="@array/meditation_sounds"
android:entryValues="@array/meditation_sounds_values"
android:key="pref_meditation_sound_bell"
android:title="@string/pref_meditation_sound_bell"/>
<ListPreference
android:defaultValue=""
android:entries="@array/autosave_labels"