parent
2798f0779b
commit
e179b93f6e
|
@ -2,6 +2,7 @@
|
|||
- Add resources menu linking to how to meditate, /r/meditation, an overview of MediNET and replaying the tutorial
|
||||
- Add presets to tutorial
|
||||
- Add session volume preview
|
||||
- Add custom vibration patterns
|
||||
- Resolve possible crash when waking device
|
||||
- Resolve duration not being preselected when editing
|
||||
- Remove usage of Google Play Services (was previously used in releases on Google Play and Amazon)
|
||||
|
|
|
@ -146,8 +146,8 @@ public class CompleteActivity extends Activity {
|
|||
}
|
||||
|
||||
String finishSoundPath = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_finish", "");
|
||||
if (!manual && !finishSoundPath.equals("none")) {
|
||||
getMeditationAssistant().playSessionSound(2, false);
|
||||
if (!manual) {
|
||||
getMeditationAssistant().notifySession(2, false, false);
|
||||
} else {
|
||||
getMeditationAssistant().restoreVolume();
|
||||
}
|
||||
|
@ -156,8 +156,6 @@ public class CompleteActivity extends Activity {
|
|||
}
|
||||
|
||||
if (!manual) {
|
||||
getMeditationAssistant().vibrateDevice();
|
||||
|
||||
String autosave = getMeditationAssistant().getPrefs().getString("pref_autosave", "");
|
||||
if (autosave.equals("save")) {
|
||||
saveMediNET(null);
|
||||
|
|
|
@ -43,8 +43,6 @@ public class ListPreferenceSound extends ListPreference {
|
|||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ListPreference, 0, 0);
|
||||
// mEntries = a.getTextArray(R.styleable.ListPreference_entries);
|
||||
// mEntryValues = a.getTextArray(R.styleable.ListPreference_entryValues);
|
||||
setEntries(a.getTextArray(R.styleable.ListPreference_entries));
|
||||
setEntryValues(a.getTextArray(R.styleable.ListPreference_entryValues));
|
||||
|
||||
|
@ -99,7 +97,6 @@ public class ListPreferenceSound extends ListPreference {
|
|||
if (mSummary == null || entry == null) {
|
||||
return super.getSummary();
|
||||
} else {
|
||||
//Log.d("MeditationAssistant", "getsummary(): " + String.valueOf(mSummary) + " " + String.valueOf(entry));
|
||||
try {
|
||||
return String.format(mSummary.toString(), entry);
|
||||
} catch (Exception e) {
|
||||
|
@ -152,8 +149,7 @@ public class ListPreferenceSound extends ListPreference {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (positiveResult && mClickedDialogEntryIndex >= 0
|
||||
&& mEntryValues != null) {
|
||||
if (positiveResult && mClickedDialogEntryIndex >= 0 && mEntryValues != null) {
|
||||
String value = mEntryValues[mClickedDialogEntryIndex].toString();
|
||||
if (callChangeListener(value)) {
|
||||
setValue(value);
|
||||
|
@ -262,10 +258,8 @@ public class ListPreferenceSound extends ListPreference {
|
|||
builder.setPositiveButton(
|
||||
builder.getContext().getString(R.string.set),
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Log.d("MeditationAssistant", "Set clicked");
|
||||
ListPreferenceSound.this.onClick(dialog,
|
||||
DialogInterface.BUTTON_POSITIVE);
|
||||
dialog.dismiss();
|
||||
|
|
|
@ -0,0 +1,240 @@
|
|||
package sh.ftp.rocketninelabs.meditationassistant;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
public class ListPreferenceVibration extends ListPreference {
|
||||
private int mClickedDialogEntryIndex;
|
||||
private CharSequence[] mEntries;
|
||||
private CharSequence[] mEntryValues;
|
||||
private CharSequence mSummary;
|
||||
private String mValue;
|
||||
private Context ctx = null;
|
||||
private SharedPreferences prefs = null;
|
||||
|
||||
public ListPreferenceVibration(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ListPreferenceVibration(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
ctx = context;
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ListPreference, 0, 0);
|
||||
setEntries(a.getTextArray(R.styleable.ListPreference_entries));
|
||||
setEntryValues(a.getTextArray(R.styleable.ListPreference_entryValues));
|
||||
|
||||
a.recycle();
|
||||
mSummary = super.getSummary();
|
||||
}
|
||||
|
||||
public int findIndexOfValue(String value) {
|
||||
if (value != null && mEntryValues != null) {
|
||||
for (int i = mEntryValues.length - 1; i >= 0; i--) {
|
||||
if (mEntryValues[i].equals(value)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public CharSequence[] getEntries() {
|
||||
return mEntries;
|
||||
}
|
||||
|
||||
public void setEntries(CharSequence[] entries) {
|
||||
mEntries = entries;
|
||||
}
|
||||
|
||||
public void setEntries(int entriesResId) {
|
||||
setEntries(getContext().getResources().getTextArray(entriesResId));
|
||||
}
|
||||
|
||||
public CharSequence getEntry() {
|
||||
int index = getValueIndex();
|
||||
return index >= 0 && mEntries != null ? mEntries[index] : null;
|
||||
}
|
||||
|
||||
public CharSequence[] getEntryValues() {
|
||||
return mEntryValues;
|
||||
}
|
||||
|
||||
public void setEntryValues(CharSequence[] entryValues) {
|
||||
mEntryValues = entryValues;
|
||||
}
|
||||
|
||||
public void setEntryValues(int entryValuesResId) {
|
||||
setEntryValues(getContext().getResources().getTextArray(
|
||||
entryValuesResId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
final CharSequence entry = getEntry();
|
||||
if (mSummary == null || entry == null) {
|
||||
return super.getSummary();
|
||||
} else {
|
||||
try {
|
||||
return String.format(mSummary.toString(), entry);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return mSummary.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSummary(CharSequence summary) {
|
||||
super.setSummary(summary);
|
||||
if (summary == null && mSummary != null) {
|
||||
mSummary = null;
|
||||
} else if (summary != null && !summary.equals(mSummary)) {
|
||||
mSummary = summary;
|
||||
}
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
mValue = value;
|
||||
persistString(value);
|
||||
}
|
||||
|
||||
private int getValueIndex() {
|
||||
return findIndexOfValue(mValue);
|
||||
}
|
||||
|
||||
public void setValueIndex(int index) {
|
||||
if (mEntryValues != null) {
|
||||
setValue(mEntryValues[index].toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDialogClosed(boolean positiveResult) {
|
||||
super.onDialogClosed(positiveResult);
|
||||
|
||||
if (positiveResult && mClickedDialogEntryIndex >= 0 && mEntryValues != null) {
|
||||
String value = mEntryValues[mClickedDialogEntryIndex].toString();
|
||||
if (callChangeListener(value)) {
|
||||
setValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object onGetDefaultValue(TypedArray a, int index) {
|
||||
return a.getString(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
|
||||
super.onPrepareDialogBuilder(builder);
|
||||
if (mEntries == null || mEntryValues == null) {
|
||||
throw new IllegalStateException(
|
||||
"ListPreference requires an entries array and an entryValues array.");
|
||||
}
|
||||
mClickedDialogEntryIndex = getValueIndex();
|
||||
builder.setSingleChoiceItems(mEntries, mClickedDialogEntryIndex,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mClickedDialogEntryIndex = which;
|
||||
String itemSelected = mEntryValues[mClickedDialogEntryIndex]
|
||||
.toString();
|
||||
|
||||
Log.d("MeditationAssistant",
|
||||
"Selected: " + which + " - "
|
||||
+ itemSelected
|
||||
);
|
||||
|
||||
if (itemSelected.equals("custom")) {
|
||||
ListPreferenceVibration.this.onClick(dialog,
|
||||
DialogInterface.BUTTON_POSITIVE);
|
||||
dialog.dismiss();
|
||||
} else if (!itemSelected.equals("")) {
|
||||
((MeditationAssistant) ctx.getApplicationContext()).vibrateDevice(itemSelected);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
builder.setPositiveButton(
|
||||
builder.getContext().getString(R.string.set),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
ListPreferenceVibration.this.onClick(dialog,
|
||||
DialogInterface.BUTTON_POSITIVE);
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state == null || !state.getClass().equals(SavedState.class)) {
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
SavedState myState = (SavedState) state;
|
||||
super.onRestoreInstanceState(myState.getSuperState());
|
||||
setValue(myState.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
final Parcelable superState = super.onSaveInstanceState();
|
||||
if (isPersistent()) {
|
||||
return superState;
|
||||
}
|
||||
final SavedState myState = new SavedState(superState);
|
||||
myState.value = getValue();
|
||||
return myState;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
|
||||
mValue = restoreValue ? getPersistedString(mValue)
|
||||
: (String) defaultValue;
|
||||
}
|
||||
|
||||
private static class SavedState extends BaseSavedState {
|
||||
String value;
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
value = source.readString();
|
||||
}
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeString(value);
|
||||
}
|
||||
}
|
||||
|
||||
public SharedPreferences getPrefs() {
|
||||
if (prefs == null) {
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
}
|
||||
return prefs;
|
||||
}
|
||||
}
|
|
@ -105,42 +105,34 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
return; // No interval sounds during the final 30 seconds
|
||||
}
|
||||
|
||||
String intervalSoundPath = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_interval", "");
|
||||
getMeditationAssistant().notifySession(1, false, false);
|
||||
|
||||
if (!intervalSoundPath.equals("none") || getMeditationAssistant().vibrationEnabled()) {
|
||||
if (!intervalSoundPath.equals("none")) {
|
||||
getMeditationAssistant().playSessionSound(1, false);
|
||||
}
|
||||
long interval = Math.max(
|
||||
getMeditationAssistant().timePreferenceValueToSeconds(getMeditationAssistant().getPrefs().getString("pref_session_interval", "00:00"), "00:00"), 0);
|
||||
Log.d("MeditationAssistant", "Interval is set to " + interval + " seconds");
|
||||
|
||||
getMeditationAssistant().vibrateDevice();
|
||||
if (interval > 0 && (getMeditationAssistant().getTimeToStopMeditate() == -1
|
||||
|| getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000) > (interval + 30) || getMeditationAssistant().getPrefs().getBoolean("pref_softfinish", false))) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.SECOND, (int) interval);
|
||||
|
||||
long interval = Math.max(
|
||||
getMeditationAssistant().timePreferenceValueToSeconds(getMeditationAssistant().getPrefs().getString("pref_session_interval", "00:00"), "00:00"), 0);
|
||||
Log.d("MeditationAssistant", "Interval is set to " + interval + " seconds");
|
||||
Log.d("MeditationAssistant", "Setting INTERVAL WAKEUP alarm for "
|
||||
+ cal.getTimeInMillis() + " (Now: "
|
||||
+ System.currentTimeMillis() + ", in: " + (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000 + ")");
|
||||
|
||||
if (interval > 0 && (getMeditationAssistant().getTimeToStopMeditate() == -1
|
||||
|| getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000) > (interval + 30) || getMeditationAssistant().getPrefs().getBoolean("pref_softfinish", false))) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.SECOND, (int) interval);
|
||||
Intent intent_interval = new Intent(
|
||||
getApplicationContext(), MainActivity.class);
|
||||
intent_interval.putExtra("wakeup", true);
|
||||
intent_interval.putExtra("wakeupinterval", true);
|
||||
intent_interval.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
intent_interval.setAction(BROADCAST_ACTION_ALARM);
|
||||
pendingintent_interval = PendingIntent.getActivity(
|
||||
getApplicationContext(), ID_INTERVAL,
|
||||
intent_interval, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
getMeditationAssistant().setAlarm(true, cal.getTimeInMillis(), pendingintent_interval);
|
||||
|
||||
Log.d("MeditationAssistant", "Setting INTERVAL WAKEUP alarm for "
|
||||
+ cal.getTimeInMillis() + " (Now: "
|
||||
+ System.currentTimeMillis() + ", in: " + (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000 + ")");
|
||||
|
||||
Intent intent_interval = new Intent(
|
||||
getApplicationContext(), MainActivity.class);
|
||||
intent_interval.putExtra("wakeup", true);
|
||||
intent_interval.putExtra("wakeupinterval", true);
|
||||
intent_interval.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
intent_interval.setAction(BROADCAST_ACTION_ALARM);
|
||||
pendingintent_interval = PendingIntent.getActivity(
|
||||
getApplicationContext(), ID_INTERVAL,
|
||||
intent_interval, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
getMeditationAssistant().setAlarm(true, cal.getTimeInMillis(), pendingintent_interval);
|
||||
|
||||
handler.postDelayed(this, interval * 1000);
|
||||
}
|
||||
handler.postDelayed(this, interval * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -332,19 +324,8 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
editPresetTitle.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.actionIconForward}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(), new int[]{R.attr.actionIconForward}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.setPreset))
|
||||
.setView(presetLayout)
|
||||
.setPositiveButton(getString(R.string.set),
|
||||
|
@ -361,7 +342,8 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// Do nothing
|
||||
}
|
||||
}).show();
|
||||
})
|
||||
.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -405,25 +387,13 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMeditationAssistant()
|
||||
.getMATheme(),
|
||||
new int[]{R.attr.actionIconNotImportant}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(), new int[]{R.attr.actionIconNotImportant}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.translate))
|
||||
.setMessage(
|
||||
getString(R.string.translateMeditationAssistantText))
|
||||
.setPositiveButton(getString(R.string.yes),
|
||||
dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.no),
|
||||
dialogClickListener).show();
|
||||
.setMessage(getString(R.string.translateMeditationAssistantText))
|
||||
.setPositiveButton(getString(R.string.yes), dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.no), dialogClickListener)
|
||||
.show();
|
||||
}
|
||||
|
||||
showNextTutorial(false);
|
||||
|
@ -991,6 +961,14 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
// Start vibration
|
||||
if (presetSettings.contains("startvibration") && preset.has("startvibration")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_start", preset.getString("startvibration")).apply();
|
||||
if (preset.getString("startvibration").equals("custom") && preset.has("startvibrationcustom")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_start_custom", preset.getString("startvibrationcustom")).apply();
|
||||
}
|
||||
}
|
||||
|
||||
// Interval duration
|
||||
if (presetSettings.contains("intervalduration")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_session_interval", preset.getString("intervalduration")).apply();
|
||||
|
@ -1004,6 +982,14 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
// Interval vibration
|
||||
if (presetSettings.contains("intervalvibration") && preset.has("intervalvibration")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_interval", preset.getString("intervalvibration")).apply();
|
||||
if (preset.getString("intervalvibration").equals("custom") && preset.has("intervalvibrationcustom")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_interval_custom", preset.getString("intervalvibrationcustom")).apply();
|
||||
}
|
||||
}
|
||||
|
||||
// Interval count
|
||||
if (presetSettings.contains("intervalcount")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_interval_count", preset.getString("intervalcount")).apply();
|
||||
|
@ -1017,6 +1003,14 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
// Complete vibration
|
||||
if (presetSettings.contains("completevibration") && preset.has("completevibration")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_finish", preset.getString("completevibration")).apply();
|
||||
if (preset.getString("completevibration").equals("custom") && preset.has("completevibrationcustom")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_finish_custom", preset.getString("completevibrationcustom")).apply();
|
||||
}
|
||||
}
|
||||
|
||||
// Ringtone and notifications
|
||||
if (presetSettings.contains("ringtone")) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_notificationcontrol", preset.getString("ringtone")).apply();
|
||||
|
@ -1032,11 +1026,6 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
getMeditationAssistant().getPrefs().edit().putBoolean("pref_softfinish", preset.getBoolean("endless")).apply();
|
||||
}
|
||||
|
||||
// Vibrate
|
||||
if (presetSettings.contains("vibrate")) {
|
||||
getMeditationAssistant().getPrefs().edit().putBoolean("pref_vibrate", preset.getBoolean("vibrate")).apply();
|
||||
}
|
||||
|
||||
successfulRestore = true;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1105,16 +1094,21 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
preset.delay = getMeditationAssistant().getPrefs().getString("pref_session_delay", "00:15");
|
||||
preset.startsound = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_start", "");
|
||||
preset.startsoundcustom = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_start_custom", "");
|
||||
preset.startvibration = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_start", "");
|
||||
preset.startvibrationcustom = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_start_custom", "");
|
||||
preset.intervalduration = getMeditationAssistant().getPrefs().getString("pref_session_interval", "00:00");
|
||||
preset.intervalsound = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_interval", "");
|
||||
preset.intervalsoundcustom = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_interval_custom", "");
|
||||
preset.intervalvibration = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_interval", "");
|
||||
preset.intervalvibrationcustom = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_interval_custom", "");
|
||||
preset.intervalcount = getMeditationAssistant().getPrefs().getString("pref_interval_count", "");
|
||||
preset.completesound = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_finish", "");
|
||||
preset.completesoundcustom = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_finish_custom", "");
|
||||
preset.completevibration = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_finish", "");
|
||||
preset.completevibrationcustom = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_finish_custom", "");
|
||||
preset.ringtone = getMeditationAssistant().getPrefs().getString("pref_notificationcontrol", "");
|
||||
preset.volume = getMeditationAssistant().getPrefs().getInt("pref_sessionvolume", 50);
|
||||
preset.endless = getMeditationAssistant().getPrefs().getBoolean("pref_softfinish", false);
|
||||
preset.vibrate = getMeditationAssistant().getPrefs().getBoolean("pref_vibrate", false);
|
||||
|
||||
String exported = preset.export().toString();
|
||||
Log.d("MeditationAssistant", "Setting preset: " + exported);
|
||||
|
@ -1389,11 +1383,7 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
getMeditationAssistant().setAlarm(true, cal.getTimeInMillis(), pendingintent);
|
||||
}
|
||||
|
||||
if (!skipDelay) {
|
||||
getMeditationAssistant().vibrateDevice();
|
||||
}
|
||||
|
||||
getMeditationAssistant().playSessionSound(0, false);
|
||||
getMeditationAssistant().notifySession(0, skipDelay, false);
|
||||
|
||||
setIntervalAlarm();
|
||||
}
|
||||
|
@ -1660,25 +1650,13 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMeditationAssistant()
|
||||
.getMATheme(),
|
||||
new int[]{R.attr.actionIconNotImportant}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(), new int[]{R.attr.actionIconNotImportant}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.rateMeditationAssistant))
|
||||
.setMessage(
|
||||
getString(R.string.rateMeditationAssistantText))
|
||||
.setPositiveButton(getString(R.string.yes),
|
||||
dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.no),
|
||||
dialogClickListener).show();
|
||||
.setMessage(getString(R.string.rateMeditationAssistantText))
|
||||
.setPositiveButton(getString(R.string.yes), dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.no), dialogClickListener)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1851,63 +1829,53 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
return; // No further intervals
|
||||
}
|
||||
|
||||
String intervalSoundPath = getMeditationAssistant().getPrefs().getString("pref_meditation_sound_interval", "");
|
||||
if (getMeditationAssistant().getTimeToStopMeditate() == -1
|
||||
|| ((System.currentTimeMillis() / 1000) > getMeditationAssistant().getTimeToStopMeditate() && (System.currentTimeMillis() / 1000) - getMeditationAssistant().getTimeToStopMeditate() >= 5) || getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000) >= 5) { // Not within last 5 seconds
|
||||
getMeditationAssistant().notifySession(1, false, false);
|
||||
}
|
||||
|
||||
if (!intervalSoundPath.equals("none") || getMeditationAssistant().vibrationEnabled()) {
|
||||
if (getMeditationAssistant().getTimeToStopMeditate() == -1
|
||||
|| ((System.currentTimeMillis() / 1000) > getMeditationAssistant().getTimeToStopMeditate() && (System.currentTimeMillis() / 1000) - getMeditationAssistant().getTimeToStopMeditate() >= 5) || getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000) >= 5) { // Not within last 5 seconds
|
||||
if (!intervalSoundPath.equals("none")) {
|
||||
getMeditationAssistant().playSessionSound(1, false);
|
||||
}
|
||||
long interval = Math.max(
|
||||
getMeditationAssistant().timePreferenceValueToSeconds(getMeditationAssistant().getPrefs().getString("pref_session_interval", "00:00"), "00:00"), 0);
|
||||
Log.d("MeditationAssistant", "Interval is set to " + interval + " seconds");
|
||||
|
||||
getMeditationAssistant().vibrateDevice();
|
||||
if (interval > 0 && (getMeditationAssistant().getTimeToStopMeditate() == -1
|
||||
|| ((getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000)) > (interval + 30)) || getMeditationAssistant().getPrefs().getBoolean("pref_softfinish", false))) {
|
||||
intervals++;
|
||||
|
||||
if (Integer.valueOf(interval_limit) > 0 && intervals >= Integer.valueOf(interval_limit)) {
|
||||
Log.d("MeditationAssistant", "Interval - reached interval limit, not firing B");
|
||||
return; // No further intervals
|
||||
}
|
||||
|
||||
long interval = Math.max(
|
||||
getMeditationAssistant().timePreferenceValueToSeconds(getMeditationAssistant().getPrefs().getString("pref_session_interval", "00:00"), "00:00"), 0);
|
||||
Log.d("MeditationAssistant", "Interval is set to " + interval + " seconds");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.SECOND, (int) interval);
|
||||
|
||||
if (interval > 0 && (getMeditationAssistant().getTimeToStopMeditate() == -1
|
||||
|| ((getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000)) > (interval + 30)) || getMeditationAssistant().getPrefs().getBoolean("pref_softfinish", false))) {
|
||||
intervals++;
|
||||
Log.d("MeditationAssistant", "Setting INTERVAL WAKEUP alarm for "
|
||||
+ cal.getTimeInMillis() + " (Now: "
|
||||
+ System.currentTimeMillis() + ", in: " + (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000 + ") - TOTAL TIME LEFT: " + (getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000)));
|
||||
|
||||
if (Integer.valueOf(interval_limit) > 0 && intervals >= Integer.valueOf(interval_limit)) {
|
||||
Log.d("MeditationAssistant", "Interval - reached interval limit, not firing B");
|
||||
return; // No further intervals
|
||||
}
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.SECOND, (int) interval);
|
||||
|
||||
Log.d("MeditationAssistant", "Setting INTERVAL WAKEUP alarm for "
|
||||
+ cal.getTimeInMillis() + " (Now: "
|
||||
+ System.currentTimeMillis() + ", in: " + (cal.getTimeInMillis() - System.currentTimeMillis()) / 1000 + ") - TOTAL TIME LEFT: " + (getMeditationAssistant().getTimeToStopMeditate()
|
||||
- (System.currentTimeMillis() / 1000)));
|
||||
|
||||
Intent intent_interval = new Intent(
|
||||
getApplicationContext(), MainActivity.class);
|
||||
intent_interval.putExtra("wakeup", true);
|
||||
intent_interval.putExtra("wakeupinterval", true);
|
||||
intent_interval.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
intent_interval.setAction(BROADCAST_ACTION_ALARM);
|
||||
pendingintent_interval = PendingIntent.getActivity(
|
||||
getApplicationContext(), ID_INTERVAL,
|
||||
intent_interval, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
getMeditationAssistant().setAlarm(true, cal.getTimeInMillis(), pendingintent_interval);
|
||||
} else {
|
||||
Log.d("MeditationAssistant", "Skipping INTERVAL WAKEUP alarm");
|
||||
}
|
||||
Intent intent_interval = new Intent(
|
||||
getApplicationContext(), MainActivity.class);
|
||||
intent_interval.putExtra("wakeup", true);
|
||||
intent_interval.putExtra("wakeupinterval", true);
|
||||
intent_interval.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
intent_interval.setAction(BROADCAST_ACTION_ALARM);
|
||||
pendingintent_interval = PendingIntent.getActivity(
|
||||
getApplicationContext(), ID_INTERVAL,
|
||||
intent_interval, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
getMeditationAssistant().setAlarm(true, cal.getTimeInMillis(), pendingintent_interval);
|
||||
} else {
|
||||
Log.d("MeditationAssistant", "Skipping INTERVAL WAKEUP alarm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fullWakeUp) {
|
||||
if (getMeditationAssistant().getPrefs().getBoolean("pref_softfinish", false)) {
|
||||
getMeditationAssistant().playSessionSound(2, false);
|
||||
|
||||
getMeditationAssistant().vibrateDevice();
|
||||
getMeditationAssistant().notifySession(2, false, false);
|
||||
} else {
|
||||
Intent openAlarmReceiverActivity = new Intent(getApplicationContext(), CompleteActivity.class);
|
||||
openAlarmReceiverActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
@ -2162,21 +2130,16 @@ public class MainActivity extends Activity implements OnShowcaseEventListener {
|
|||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(
|
||||
getResources().getDrawable(
|
||||
getTheme().obtainStyledAttributes(
|
||||
getMeditationAssistant().getMATheme(),
|
||||
new int[]{R.attr.actionIconSignOut})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(), new int[]{R.attr.actionIconSignOut}).getResourceId(0, 0)))
|
||||
.setTitle(
|
||||
getString(R.string.signOut))
|
||||
.setMessage(getString(R.string.signOutOfMediNETConfirmTitle))
|
||||
.setPositiveButton(getString(R.string.signOut),
|
||||
dialogClickListener)
|
||||
.setNegativeButton(getString(R.string.cancel),
|
||||
dialogClickListener).show();
|
||||
dialogClickListener)
|
||||
.show();
|
||||
}
|
||||
} else {
|
||||
askToSignIn();
|
||||
|
|
|
@ -56,6 +56,8 @@ import org.acra.annotation.AcraCore;
|
|||
import org.acra.annotation.AcraHttpSender;
|
||||
import org.acra.data.StringFormat;
|
||||
import org.acra.sender.HttpSender;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -81,6 +83,8 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@AcraCore(buildConfigClass = BuildConfig.class, reportFormat = StringFormat.KEY_VALUE_LIST)
|
||||
|
@ -94,8 +98,6 @@ public class MeditationAssistant extends Application {
|
|||
public static String ACTION_REMINDER = "sh.ftp.rocketninelabs.meditationassistant.DAILY_NOTIFICATION";
|
||||
public static String ACTION_UPDATED = "sh.ftp.rocketninelabs.meditationassistant.DAILY_NOTIFICATION_UPDATED";
|
||||
|
||||
public static int REQUEST_FIT = 22;
|
||||
|
||||
public static int CSV_COLUMN_COUNT = 5;
|
||||
|
||||
public boolean ispaused = false;
|
||||
|
@ -137,6 +139,7 @@ public class MeditationAssistant extends Application {
|
|||
private SharedPreferences prefs = null;
|
||||
private AlarmManager am;
|
||||
private WakeLocker wakeLocker = new WakeLocker();
|
||||
private Lock wakeLockerLock = new ReentrantLock();
|
||||
String pausedTimerHoursMinutes;
|
||||
String pausedTimerSeconds;
|
||||
private HashMap<String, MediaPlayer> mediaPlayers = new HashMap<String, MediaPlayer>();
|
||||
|
@ -291,16 +294,6 @@ public class MeditationAssistant extends Application {
|
|||
return string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
public boolean canVibrate() {
|
||||
try {
|
||||
Vibrator vi = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
return vi.hasVibrator();
|
||||
} catch (NoSuchMethodError e) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void restoreVolume() {
|
||||
if (previous_volume != null) {
|
||||
try {
|
||||
|
@ -650,9 +643,9 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
public void playSessionSound(int sound, boolean restoreVolume) {
|
||||
public void notifySession(int phase, boolean skipVibration, boolean restoreVolume) {
|
||||
String label;
|
||||
switch (sound) {
|
||||
switch (phase) {
|
||||
case 0:
|
||||
label = "start";
|
||||
break;
|
||||
|
@ -665,8 +658,9 @@ public class MeditationAssistant extends Application {
|
|||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences prefs = getPrefs();
|
||||
|
||||
// Play sound
|
||||
String soundPath = prefs.getString("pref_meditation_sound_" + label, "");
|
||||
if (!soundPath.equals("none")) {
|
||||
if (soundPath.equals("custom")) {
|
||||
|
@ -675,6 +669,18 @@ public class MeditationAssistant extends Application {
|
|||
playSound(MeditationSounds.getMeditationSound(soundPath), "", restoreVolume);
|
||||
}
|
||||
}
|
||||
|
||||
// Vibrate device
|
||||
if (!skipVibration) {
|
||||
String vibration = prefs.getString("pref_meditation_vibrate_" + label, "");
|
||||
if (!vibration.equals("none")) {
|
||||
if (vibration.equals("custom")) {
|
||||
vibrateDevice(prefs.getString("pref_meditation_vibrate_" + label + "_custom", ""));
|
||||
} else {
|
||||
vibrateDevice(vibration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startAuth(Context context, boolean showToast) {
|
||||
|
@ -1141,6 +1147,16 @@ public class MeditationAssistant extends Application {
|
|||
+ Build.VERSION.SDK_INT
|
||||
);
|
||||
|
||||
if (getPrefs().getBoolean("pref_vibrate", false)) {
|
||||
getPrefs()
|
||||
.edit()
|
||||
.putString("pref_meditation_vibrate_start", "medium")
|
||||
.putString("pref_meditation_vibrate_interval", "medium")
|
||||
.putString("pref_meditation_vibrate_finish", "medium")
|
||||
.putBoolean("pref_vibrate", false)
|
||||
.apply();
|
||||
}
|
||||
|
||||
getPrefs().registerOnSharedPreferenceChangeListener(sharedPrefslistener);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
|
@ -1289,8 +1305,7 @@ public class MeditationAssistant extends Application {
|
|||
|
||||
if (getMediNET().activity != null
|
||||
&& !getMediNET().announcement.equals("")) {
|
||||
AlertDialog announceDialog = new AlertDialog.Builder(
|
||||
getMediNET().activity)
|
||||
AlertDialog announceDialog = new AlertDialog.Builder(getMediNET().activity)
|
||||
.setPositiveButton(R.string.dismiss,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -1302,21 +1317,11 @@ public class MeditationAssistant extends Application {
|
|||
)
|
||||
.setTitle(title == null ? getString(R.string.announcement) : title)
|
||||
.setMessage(medinet.announcement)
|
||||
.setIcon(
|
||||
getMediNET().activity
|
||||
.getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMATheme(true),
|
||||
new int[]{R.attr.actionIconGoToToday})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setCancelable(false).create();
|
||||
.setIcon(getMediNET().activity.getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
|
||||
announceDialog.show();
|
||||
|
||||
return announceDialog;
|
||||
}
|
||||
|
||||
|
@ -1356,8 +1361,7 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
getPrefs().edit().putBoolean("meditationstreakwarningshown", true).apply();
|
||||
|
||||
AlertDialog streakDifferenceDialog = new AlertDialog.Builder(
|
||||
activity)
|
||||
AlertDialog streakDifferenceDialog = new AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.yes,
|
||||
(dialog, id) -> {
|
||||
setMeditationStreak(newstreak, twodays ? getStreakExpiresTwoDaysTimestamp() : getStreakExpiresOneDayTimestamp());
|
||||
|
@ -1370,12 +1374,9 @@ public class MeditationAssistant extends Application {
|
|||
)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(String.format(getString(R.string.streakdifferencewarning), oldstreak, newstreak))
|
||||
.setIcon(activity.getResources().getDrawable(
|
||||
getTheme().obtainStyledAttributes(getMATheme(true),
|
||||
new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setCancelable(false).create();
|
||||
.setIcon(activity.getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
|
||||
streakDifferenceDialog.show();
|
||||
}
|
||||
|
@ -1616,13 +1617,7 @@ public class MeditationAssistant extends Application {
|
|||
});
|
||||
|
||||
sessionDialog = new AlertDialog.Builder(sessionDialogActivity)
|
||||
.setIcon(
|
||||
getResources().getDrawable(
|
||||
getTheme().obtainStyledAttributes(getMATheme(true),
|
||||
new int[]{session._id == 0 ? R.attr.actionIconNew : R.attr.actionIconGoToToday})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{session._id == 0 ? R.attr.actionIconNew : R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setTitle(getString(session._id == 0 ? R.string.addSession : R.string.editSession))
|
||||
.setView(sessionDialogView)
|
||||
.setPositiveButton(getString(session._id == 0 ? R.string.add : R.string.edit), new DialogInterface.OnClickListener() {
|
||||
|
@ -1686,9 +1681,7 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
|
||||
AlertDialog postSessionDialog = new AlertDialog.Builder(activity)
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true),
|
||||
new int[]{R.attr.actionIconInfo})
|
||||
.getResourceId(0, 0)))
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconInfo}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.sessionPosted))
|
||||
.setMessage(getString(R.string.postUpdatedSession))
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
|
@ -1939,17 +1932,7 @@ public class MeditationAssistant extends Application {
|
|||
)
|
||||
.setTitle(R.string.downloadsessionstitle)
|
||||
.setMessage(R.string.downloadsessionsmessage)
|
||||
.setIcon(
|
||||
getMediNET().activity
|
||||
.getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMATheme(true),
|
||||
new int[]{R.attr.actionIconDownCloud})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getMediNET().activity.getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconDownCloud}).getResourceId(0, 0)))
|
||||
.create();
|
||||
|
||||
staleDataDialog.show();
|
||||
|
@ -1975,20 +1958,10 @@ public class MeditationAssistant extends Application {
|
|||
|
||||
public void askToDonate(Activity activity) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMATheme(true),
|
||||
new int[]{R.attr.actionIconInfo}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconInfo}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.announcement))
|
||||
.setMessage(
|
||||
getString(R.string.donate156))
|
||||
.setMessage(getString(R.string.donate156))
|
||||
.setPositiveButton(getString(R.string.donate),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -2001,25 +1974,16 @@ public class MeditationAssistant extends Application {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
}).show();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public void showImportSessionsDialog(Activity activity) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMATheme(true),
|
||||
new int[]{R.attr.actionIconForward}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconForward}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.importsessions))
|
||||
.setMessage(
|
||||
getString(R.string.importsessions_utc_or_local))
|
||||
.setMessage(getString(R.string.importsessions_utc_or_local))
|
||||
.setPositiveButton(getString(R.string.utc),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -2033,7 +1997,8 @@ public class MeditationAssistant extends Application {
|
|||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
showFilePickerDialog(activity, SettingsActivity.FILEPICKER_IMPORT_SESSIONS_LOCAL, FilePickerActivity.MODE_FILE);
|
||||
}
|
||||
}).show();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
public void importSessions(Activity activity, Uri uri, boolean useLocalTimeZone) {
|
||||
|
@ -2171,13 +2136,7 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
|
||||
AlertDialog sessionsImportedDialog = new AlertDialog.Builder(activity)
|
||||
.setIcon(
|
||||
getResources().getDrawable(
|
||||
getTheme().obtainStyledAttributes(getMATheme(true),
|
||||
new int[]{R.attr.actionIconForward})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconForward}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.importsessions))
|
||||
.setMessage(String.format(getString(R.string.importsessions_complete), existingSessions, sessions.size()))
|
||||
.setPositiveButton(getString(R.string.wordimport), new DialogInterface.OnClickListener() {
|
||||
|
@ -2255,13 +2214,7 @@ public class MeditationAssistant extends Application {
|
|||
txtSessionsExportedPath.setText(file.getPath());
|
||||
|
||||
AlertDialog sessionsExportedDialog = new AlertDialog.Builder(activity)
|
||||
.setIcon(
|
||||
getResources().getDrawable(
|
||||
getTheme().obtainStyledAttributes(getMATheme(true),
|
||||
new int[]{R.attr.actionIconSignOut})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMATheme(true), new int[]{R.attr.actionIconSignOut}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.exportSessions))
|
||||
.setView(exp)
|
||||
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||
|
@ -2292,29 +2245,50 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
|
||||
public void updateWidgets() {
|
||||
AppWidgetManager man = AppWidgetManager
|
||||
.getInstance(getApplicationContext());
|
||||
/*int[] ids = man.getAppWidgetIds(new ComponentName(
|
||||
getApplicationContext(), WidgetStreakProvider.class));*/
|
||||
Intent updateIntent = new Intent();
|
||||
updateIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
|
||||
getApplicationContext().sendBroadcast(updateIntent);
|
||||
}
|
||||
|
||||
public Boolean vibrationEnabled() {
|
||||
return (getPrefs().getBoolean("pref_vibrate", false) && canVibrate());
|
||||
}
|
||||
public void vibrateDevice(String pattern) {
|
||||
ArrayList<Long> p = new ArrayList<Long>();
|
||||
if (pattern.equals("short")) {
|
||||
p.add((long) 110);
|
||||
p.add((long) 225);
|
||||
p.add((long) 110);
|
||||
} else if (pattern.equals("medium")) {
|
||||
p.add((long) 420);
|
||||
p.add((long) 375);
|
||||
p.add((long) 420);
|
||||
} else if (pattern.equals("long")) {
|
||||
p.add((long) 840);
|
||||
p.add((long) 550);
|
||||
p.add((long) 840);
|
||||
} else {
|
||||
String[] patternSplit = pattern.split(",");
|
||||
for (String pp : patternSplit) {
|
||||
pp = pp.trim();
|
||||
if (pp.isEmpty() || !StringUtils.isNumeric(pp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
public void vibrateDevice() {
|
||||
if (vibrationEnabled()) {
|
||||
try {
|
||||
Vibrator vi = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
long[] pattern = {225, 110, 225, 110, 225, 110};
|
||||
vi.vibrate(pattern, -1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
long ppv = Long.parseLong(pp);
|
||||
if (ppv < 0L) {
|
||||
ppv = 0L;
|
||||
} else if (ppv > 15000L) {
|
||||
ppv = 15000L;
|
||||
}
|
||||
p.add(ppv);
|
||||
}
|
||||
}
|
||||
p.add(0, 0L);
|
||||
|
||||
try {
|
||||
Vibrator vi = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
|
||||
vi.vibrate(ArrayUtils.toPrimitive(p.toArray(new Long[p.size()])), -1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean haveNotificationPermission() {
|
||||
|
@ -2446,21 +2420,23 @@ public class MeditationAssistant extends Application {
|
|||
}
|
||||
|
||||
public String acquireWakeLock(Boolean fullWakeUp) {
|
||||
synchronized (wakeLocker) {
|
||||
return wakeLocker.acquire(getApplicationContext(), fullWakeUp);
|
||||
}
|
||||
wakeLockerLock.lock();
|
||||
String wakelockID = wakeLocker.acquire(getApplicationContext(), fullWakeUp);
|
||||
wakeLockerLock.unlock();
|
||||
|
||||
return wakelockID;
|
||||
}
|
||||
|
||||
public void releaseWakeLock(String wakeLockID) {
|
||||
synchronized (wakeLocker) {
|
||||
wakeLocker.release(wakeLockID);
|
||||
}
|
||||
wakeLockerLock.lock();
|
||||
wakeLocker.release(wakeLockID);
|
||||
wakeLockerLock.unlock();
|
||||
}
|
||||
|
||||
public void releaseAllWakeLocks() {
|
||||
synchronized (wakeLocker) {
|
||||
wakeLocker.releaseAll();
|
||||
}
|
||||
wakeLockerLock.lock();
|
||||
wakeLocker.releaseAll();
|
||||
wakeLockerLock.unlock();
|
||||
}
|
||||
|
||||
public enum TrackerName {
|
||||
|
|
|
@ -9,12 +9,18 @@ public class Preset {
|
|||
public String delay = "";
|
||||
public String startsound = "";
|
||||
public String startsoundcustom = "";
|
||||
public String startvibration = "";
|
||||
public String startvibrationcustom = "";
|
||||
public String intervalduration = "";
|
||||
public String intervalsound = "";
|
||||
public String intervalsoundcustom = "";
|
||||
public String intervalvibration = "";
|
||||
public String intervalvibrationcustom = "";
|
||||
public String intervalcount = "";
|
||||
public String completesound = "";
|
||||
public String completesoundcustom = "";
|
||||
public String completevibration = "";
|
||||
public String completevibrationcustom = "";
|
||||
public String ringtone = "";
|
||||
public Integer volume = 50;
|
||||
public Boolean endless = false;
|
||||
|
@ -28,12 +34,18 @@ public class Preset {
|
|||
jobj.put("delay", delay);
|
||||
jobj.put("startsound", startsound);
|
||||
jobj.put("startsoundcustom", startsoundcustom);
|
||||
jobj.put("startvibration", startvibration);
|
||||
jobj.put("startvibrationcustom", startvibrationcustom);
|
||||
jobj.put("intervalduration", intervalduration);
|
||||
jobj.put("intervalsound", intervalsound);
|
||||
jobj.put("intervalsoundcustom", intervalsoundcustom);
|
||||
jobj.put("intervalvibration", intervalvibration);
|
||||
jobj.put("intervalvibrationcustom", intervalvibrationcustom);
|
||||
jobj.put("intervalcount", intervalcount);
|
||||
jobj.put("completesound", completesound);
|
||||
jobj.put("completesoundcustom", completesoundcustom);
|
||||
jobj.put("completevibration", completevibration);
|
||||
jobj.put("completevibrationcustom", completevibrationcustom);
|
||||
jobj.put("ringtone", ringtone);
|
||||
jobj.put("volume", volume);
|
||||
jobj.put("endless", endless);
|
||||
|
|
|
@ -134,13 +134,7 @@ public class ProgressActivity extends FragmentActivity {
|
|||
}
|
||||
|
||||
sessionDetailsDialog = new AlertDialog.Builder(this)
|
||||
.setIcon(
|
||||
getResources().getDrawable(
|
||||
getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true),
|
||||
new int[]{R.attr.actionIconGoToToday})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getResources().getDrawable(getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setTitle(sdf.format(sess_date))
|
||||
.setAdapter(sessionsDialogAdapter,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
@ -206,13 +200,7 @@ public class ProgressActivity extends FragmentActivity {
|
|||
}
|
||||
|
||||
sessionDetailsDialog = new AlertDialog.Builder(this)
|
||||
.setIcon(
|
||||
getResources().getDrawable(
|
||||
getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true),
|
||||
new int[]{R.attr.actionIconGoToToday})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getResources().getDrawable(getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setTitle(session_title)
|
||||
.setView(detailsView)
|
||||
.create();
|
||||
|
|
|
@ -59,13 +59,7 @@ public class SessionsFragment extends ListFragment {
|
|||
|
||||
selected_session = (SessionSQL) getListView().getItemAtPosition(position);
|
||||
sessionDialog = new AlertDialog.Builder(getActivity())
|
||||
.setIcon(
|
||||
getActivity().getResources().getDrawable(
|
||||
getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true),
|
||||
new int[]{R.attr.actionIconGoToToday})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setIcon(getActivity().getResources().getDrawable(getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setTitle(session_title)
|
||||
.setItems(R.array.session_actions,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
@ -94,15 +88,8 @@ public class SessionsFragment extends ListFragment {
|
|||
getMeditationAssistant().getMediNET().postSession(0, null, null);
|
||||
}
|
||||
} else { // Delete
|
||||
AlertDialog deleteDialog = new AlertDialog.Builder(
|
||||
getActivity())
|
||||
.setIcon(
|
||||
getActivity().getResources().getDrawable(
|
||||
getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true),
|
||||
new int[]{R.attr.actionIconGoToToday})
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
AlertDialog deleteDialog = new AlertDialog.Builder(getActivity())
|
||||
.setIcon(getActivity().getResources().getDrawable(getMeditationAssistant().getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconGoToToday}).getResourceId(0, 0)))
|
||||
.setTitle(session_title)
|
||||
.setItems(
|
||||
R.array.session_delete_actions,
|
||||
|
@ -137,15 +124,16 @@ public class SessionsFragment extends ListFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
).create();
|
||||
)
|
||||
.create();
|
||||
deleteDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
).create();
|
||||
)
|
||||
.create();
|
||||
|
||||
sessionDialog.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,10 +25,15 @@ import android.preference.PreferenceActivity;
|
|||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.RingtonePreference;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
@ -52,6 +57,9 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
static int FILEPICKER_IMPORT_SESSIONS_UTC = 104;
|
||||
static int FILEPICKER_IMPORT_SESSIONS_LOCAL = 105;
|
||||
static int FILEPICKER_EXPORT_SESSIONS = 106;
|
||||
static int SElECT_VIBRATION_START = 107;
|
||||
static int SElECT_VIBRATION_INTERVAL = 108;
|
||||
static int SElECT_VIBRATION_FINISH = 109;
|
||||
private static final int PERMISSION_REQUEST_SOUND_READ_EXTERNAL_STORAGE = 3002;
|
||||
private static final int PERMISSION_REQUEST_IMPORT_READ_EXTERNAL_STORAGE = 3003;
|
||||
private static final int PERMISSION_REQUEST_EXPORT_WRITE_EXTERNAL_STORAGE = 3004;
|
||||
|
@ -60,13 +68,17 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
public Boolean initialSoundChangeStart = true;
|
||||
public Boolean initialSoundChangeInterval = true;
|
||||
public Boolean initialSoundChangeFinish = true;
|
||||
public Boolean initialVibrationChangeStart = true;
|
||||
public Boolean initialVibrationChangeInterval = true;
|
||||
public Boolean initialVibrationChangeFinish = true;
|
||||
public SessionPreferenceFragment sessionPreferenceFragment = null;
|
||||
public ReminderPreferenceFragment reminderPreferenceFragment = null;
|
||||
public MeditationPreferenceFragment meditationPreferenceFragment = null;
|
||||
public ProgressPreferenceFragment progressPreferenceFragment = null;
|
||||
public MediNETPreferenceFragment medinetPreferenceFragment = null;
|
||||
public MiscellaneousPreferenceFragment miscellaneousPreferenceFragment = null;
|
||||
private int selectingPrefsound = 0;
|
||||
private int selectingPrefSound = 0;
|
||||
private int selectingPrefVibration = 0;
|
||||
private MeditationAssistant ma = null;
|
||||
private Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
|
@ -141,7 +153,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
preference.setSummary(presetsummary.toString());
|
||||
}
|
||||
} else if (preference instanceof ListPreference || preference instanceof ListPreferenceSound) {
|
||||
} else if (preference instanceof ListPreference || preference instanceof ListPreferenceSound || preference instanceof ListPreferenceVibration) {
|
||||
// For list preferences, look up the correct display value in
|
||||
// the preference's 'entries' list.
|
||||
ListPreference listPreference = (ListPreference) preference;
|
||||
|
@ -149,9 +161,9 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
// Set the summary to reflect the new value.
|
||||
preference.setSummary(
|
||||
index >= 0
|
||||
? listPreference.getEntries()[index]
|
||||
: "Gong"
|
||||
index >= 0
|
||||
? listPreference.getEntries()[index]
|
||||
: (preference instanceof ListPreferenceSound ? "Gong" : getString(R.string.disabled))
|
||||
); // TODO: Don't hardcode sound names
|
||||
|
||||
if (listPreference.getKey().equals("pref_theme")) {
|
||||
|
@ -187,6 +199,21 @@ 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_vibrate_start")) {
|
||||
if (stringValue.equals("custom") && !initialVibrationChangeStart) {
|
||||
selectCustomVibration(SElECT_VIBRATION_START);
|
||||
}
|
||||
initialVibrationChangeStart = false;
|
||||
} else if (listPreference.getKey().equals("pref_meditation_vibrate_interval")) {
|
||||
if (stringValue.equals("custom") && !initialVibrationChangeInterval) {
|
||||
selectCustomVibration(SElECT_VIBRATION_INTERVAL);
|
||||
}
|
||||
initialVibrationChangeInterval = false;
|
||||
} else if (listPreference.getKey().equals("pref_meditation_vibrate_finish")) {
|
||||
if (stringValue.equals("custom") && !initialVibrationChangeFinish) {
|
||||
selectCustomVibration(SElECT_VIBRATION_FINISH);
|
||||
}
|
||||
initialVibrationChangeFinish = false;
|
||||
}
|
||||
} else if (preference instanceof RingtonePreference) {
|
||||
// For ringtone preferences, look up the correct display value
|
||||
|
@ -197,7 +224,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
} else {
|
||||
Ringtone ringtone = RingtoneManager.getRingtone(
|
||||
preference.getContext(), Uri.parse(stringValue));
|
||||
preference.getContext(), Uri.parse(stringValue));
|
||||
|
||||
if (ringtone == null) {
|
||||
// Clear the summary if there was a lookup error.
|
||||
|
@ -225,7 +252,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
}
|
||||
|
||||
timeValue = Integer.valueOf(timeValueSplit[0]) + ":"
|
||||
+ String.format("%02d", Integer.valueOf(timeValueSplit[1])) + " " + ampm;
|
||||
+ String.format("%02d", Integer.valueOf(timeValueSplit[1])) + " " + ampm;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -244,8 +271,8 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
try {
|
||||
String[] timeValueSplit = ((stringValue != null && stringValue != "") ? stringValue : (preference.getKey().equals("pref_session_delay") ? "00:15" : "00:00")).split(":");
|
||||
timeValue = (int) Math.floor(Integer.valueOf(timeValueSplit[0]) / 60) + ":"
|
||||
+ String.format("%02d", Integer.valueOf(timeValueSplit[0]) % 60) + ":"
|
||||
+ String.format("%02d", Integer.valueOf(timeValueSplit[1]));
|
||||
+ String.format("%02d", Integer.valueOf(timeValueSplit[0]) % 60) + ":"
|
||||
+ String.format("%02d", Integer.valueOf(timeValueSplit[1]));
|
||||
isDisabled = (Integer.valueOf(timeValueSplit[0]) == 0 && Integer.valueOf(timeValueSplit[1]) == 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -257,33 +284,38 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
ListPreferenceSound prefIntervalSound = (ListPreferenceSound) (sessionPreferenceFragment == null ? findPreference("pref_meditation_sound_interval") : sessionPreferenceFragment.findPreference("pref_meditation_sound_interval"));
|
||||
prefIntervalSound.setEnabled(!isDisabled);
|
||||
|
||||
ListPreferenceVibration prefIntervalVibrate = (ListPreferenceVibration) (sessionPreferenceFragment == null ? findPreference("pref_meditation_vibrate_interval") : sessionPreferenceFragment.findPreference("pref_meditation_vibrate_interval"));
|
||||
prefIntervalVibrate.setEnabled(!isDisabled);
|
||||
|
||||
EditTextPreference prefIntervalCount = (EditTextPreference) (sessionPreferenceFragment == null ? findPreference("pref_interval_count") : sessionPreferenceFragment.findPreference("pref_interval_count"));
|
||||
prefIntervalCount.setEnabled(!isDisabled);
|
||||
}
|
||||
}
|
||||
} else if (preference instanceof EditTextPreference) {
|
||||
String reminderText = getString(preference.getKey().equals("pref_daily_reminder_text") ? R.string.reminderText : R.string.ignore_introphrase);
|
||||
if (stringValue != null && (preference.getKey().equals("pref_sessionintro") || !stringValue.trim().equals(""))) {
|
||||
reminderText = stringValue.trim();
|
||||
if (preference.getKey().equals("pref_interval_count")) {
|
||||
if (stringValue == null || stringValue.trim().equals("")) {
|
||||
stringValue = "0";
|
||||
}
|
||||
if (Integer.valueOf(stringValue) <= 0) {
|
||||
preference.setSummary(getString(R.string.unlimited));
|
||||
} else {
|
||||
preference.setSummary(getResources().getQuantityString(
|
||||
R.plurals.numtimes, Integer.valueOf(stringValue),
|
||||
String.valueOf(Integer.valueOf(stringValue))
|
||||
));
|
||||
}
|
||||
} else {
|
||||
String reminderText = getString(preference.getKey().equals("pref_daily_reminder_text") ? R.string.reminderText : R.string.ignore_introphrase);
|
||||
if (stringValue != null && (preference.getKey().equals("pref_sessionintro") || !stringValue.trim().equals(""))) {
|
||||
reminderText = stringValue.trim();
|
||||
}
|
||||
preference.setSummary(reminderText);
|
||||
}
|
||||
preference.setSummary(reminderText);
|
||||
} else if (preference instanceof SeekBarPreference) {
|
||||
if (stringValue == null || stringValue.equals("")) {
|
||||
stringValue = "50";
|
||||
}
|
||||
preference.setSummary((Integer.valueOf(stringValue) + 4) / 5 * 5 + "%");
|
||||
} else if (preference.getKey().equals("pref_interval_count")) {
|
||||
if (stringValue == null || stringValue.trim().equals("")) {
|
||||
stringValue = "0";
|
||||
}
|
||||
if (Integer.valueOf(stringValue) <= 0) {
|
||||
preference.setSummary(getString(R.string.unlimited));
|
||||
} else {
|
||||
preference.setSummary(getResources().getQuantityString(
|
||||
R.plurals.numtimes, Integer.valueOf(stringValue),
|
||||
String.valueOf(Integer.valueOf(stringValue))
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// For all other preferences, set the summary to the value's
|
||||
// simple string representation.
|
||||
|
@ -295,138 +327,177 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
};
|
||||
|
||||
private void selectCustomSound(int requestCode) {
|
||||
selectingPrefsound = requestCode;
|
||||
selectingPrefSound = requestCode;
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_SOUND_READ_EXTERNAL_STORAGE);
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_SOUND_READ_EXTERNAL_STORAGE);
|
||||
} else {
|
||||
getMeditationAssistant().showFilePickerDialog(SettingsActivity.this, requestCode, FilePickerActivity.MODE_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
private void selectCustomVibration(int requestCode) {
|
||||
selectingPrefVibration = requestCode;
|
||||
|
||||
String dialogTitle = "";
|
||||
String value = "";
|
||||
if (requestCode == SElECT_VIBRATION_START) {
|
||||
dialogTitle = getString(R.string.pref_meditation_vibrate_start);
|
||||
value = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_start_custom", "");
|
||||
} else if (requestCode == SElECT_VIBRATION_INTERVAL) {
|
||||
dialogTitle = getString(R.string.pref_meditation_vibrate_interval);
|
||||
value = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_interval_custom", "");
|
||||
} else if (requestCode == SElECT_VIBRATION_FINISH) {
|
||||
dialogTitle = getString(R.string.pref_meditation_vibrate_finish);
|
||||
value = getMeditationAssistant().getPrefs().getString("pref_meditation_vibrate_finish_custom", "");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (value.trim().equals("")) {
|
||||
value = "110,225,110";
|
||||
}
|
||||
|
||||
LayoutInflater presetInflater = getLayoutInflater();
|
||||
View presetLayout = presetInflater.inflate(R.layout.set_vibration, null);
|
||||
final EditText editVibrationPattern = presetLayout.findViewById(R.id.editVibrationPattern);
|
||||
editVibrationPattern.setText(value);
|
||||
editVibrationPattern.selectAll();
|
||||
editVibrationPattern.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this);
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(), new int[]{R.attr.actionIconFlashOn}).getResourceId(0, 0)))
|
||||
.setTitle(dialogTitle)
|
||||
.setView(presetLayout)
|
||||
.setPositiveButton(getString(R.string.set),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (requestCode == SElECT_VIBRATION_START) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_start_custom", editVibrationPattern.getText().toString()).apply();
|
||||
} else if (requestCode == SElECT_VIBRATION_INTERVAL) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_interval_custom", editVibrationPattern.getText().toString()).apply();
|
||||
} else if (requestCode == SElECT_VIBRATION_FINISH) {
|
||||
getMeditationAssistant().getPrefs().edit().putString("pref_meditation_vibrate_finish_custom", editVibrationPattern.getText().toString()).apply();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNeutralButton(getString(R.string.vibrate), null)
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// Do nothing
|
||||
}
|
||||
});
|
||||
|
||||
final AlertDialog alertDialog = builder.create();
|
||||
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
Button b = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
|
||||
b.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
getMeditationAssistant().vibrateDevice(editVibrationPattern.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String[] permissions, int[] grantResults) {
|
||||
switch (requestCode) {
|
||||
case PERMISSION_REQUEST_SOUND_READ_EXTERNAL_STORAGE: {
|
||||
if ((grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
getMeditationAssistant().showFilePickerDialog(SettingsActivity.this, selectingPrefsound, FilePickerActivity.MODE_FILE);
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
getMeditationAssistant().showFilePickerDialog(SettingsActivity.this, selectingPrefSound, FilePickerActivity.MODE_FILE);
|
||||
} else if (ActivityCompat.shouldShowRequestPermissionRationale(this,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMeditationAssistant()
|
||||
.getMATheme(true),
|
||||
new int[]{R.attr.actionIconSettings}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setTitle(getString(R.string.permissionRequest))
|
||||
.setMessage(
|
||||
getString(R.string.permissionRequired))
|
||||
.setPositiveButton(getString(R.string.tryAgain),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
selectCustomSound(selectingPrefsound);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.deny),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
}).show();
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconSettings}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.permissionRequest))
|
||||
.setMessage(getString(R.string.permissionRequired))
|
||||
.setPositiveButton(getString(R.string.tryAgain),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
selectCustomSound(selectingPrefSound);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.deny),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PERMISSION_REQUEST_IMPORT_READ_EXTERNAL_STORAGE: {
|
||||
if ((grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
getMeditationAssistant().showImportSessionsDialog(SettingsActivity.this);
|
||||
} else if (ActivityCompat.shouldShowRequestPermissionRationale(this,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMeditationAssistant()
|
||||
.getMATheme(true),
|
||||
new int[]{R.attr.actionIconSettings}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setTitle(getString(R.string.permissionRequest))
|
||||
.setMessage(
|
||||
getString(R.string.permissionRequired))
|
||||
.setPositiveButton(getString(R.string.tryAgain),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ActivityCompat.requestPermissions(SettingsActivity.this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_IMPORT_READ_EXTERNAL_STORAGE);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.deny),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
}).show();
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconSettings}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.permissionRequest))
|
||||
.setMessage(getString(R.string.permissionRequired))
|
||||
.setPositiveButton(getString(R.string.tryAgain),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ActivityCompat.requestPermissions(SettingsActivity.this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_IMPORT_READ_EXTERNAL_STORAGE);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.deny),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PERMISSION_REQUEST_EXPORT_WRITE_EXTERNAL_STORAGE: {
|
||||
if ((grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
|
||||
getMeditationAssistant().showFilePickerDialog(SettingsActivity.this, FILEPICKER_EXPORT_SESSIONS, FilePickerActivity.MODE_NEW_FILE);
|
||||
} else if (ActivityCompat.shouldShowRequestPermissionRationale(this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setIcon(
|
||||
getResources()
|
||||
.getDrawable(
|
||||
getTheme()
|
||||
.obtainStyledAttributes(
|
||||
getMeditationAssistant()
|
||||
.getMATheme(true),
|
||||
new int[]{R.attr.actionIconSettings}
|
||||
)
|
||||
.getResourceId(0, 0)
|
||||
)
|
||||
)
|
||||
.setTitle(getString(R.string.permissionRequest))
|
||||
.setMessage(
|
||||
getString(R.string.permissionRequired))
|
||||
.setPositiveButton(getString(R.string.tryAgain),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ActivityCompat.requestPermissions(SettingsActivity.this,
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_EXPORT_WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.deny),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
}).show();
|
||||
builder
|
||||
.setIcon(getResources().getDrawable(getTheme().obtainStyledAttributes(getMeditationAssistant().getMATheme(true), new int[]{R.attr.actionIconSettings}).getResourceId(0, 0)))
|
||||
.setTitle(getString(R.string.permissionRequest))
|
||||
.setMessage(getString(R.string.permissionRequired))
|
||||
.setPositiveButton(getString(R.string.tryAgain),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ActivityCompat.requestPermissions(SettingsActivity.this,
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_EXPORT_WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.deny),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -438,7 +509,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
private static boolean isXLargeTablet(Context context) {
|
||||
return FORCE_TABLET_VIEW || ((context.getResources().getConfiguration().screenLayout
|
||||
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE);
|
||||
& Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
|
@ -521,7 +592,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
return true;
|
||||
} else if (i == R.id.action_accountsettings) {
|
||||
Intent openActivity = new Intent(this,
|
||||
MediNETActivity.class);
|
||||
MediNETActivity.class);
|
||||
openActivity.putExtra("page", "account");
|
||||
startActivity(openActivity);
|
||||
finish();
|
||||
|
@ -560,6 +631,23 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
}
|
||||
}
|
||||
|
||||
void setupVibrationPreferences(PreferenceFragment preferenceFragment) {
|
||||
String[] vibration = getResources().getStringArray(R.array.vibration);
|
||||
String[] vibration_values = getResources().getStringArray(R.array.vibration_values);
|
||||
|
||||
ListPreferenceVibration prefMeditationVibrateStart = (ListPreferenceVibration) (preferenceFragment == null ? findPreference("pref_meditation_vibrate_start") : preferenceFragment.findPreference("pref_meditation_vibrate_start"));
|
||||
prefMeditationVibrateStart.setEntries(vibration);
|
||||
prefMeditationVibrateStart.setEntryValues(vibration_values);
|
||||
|
||||
ListPreferenceVibration prefMeditationVibrateInterval = (ListPreferenceVibration) (preferenceFragment == null ? findPreference("pref_meditation_vibrate_interval") : preferenceFragment.findPreference("pref_meditation_vibrate_interval"));
|
||||
prefMeditationVibrateInterval.setEntries(vibration);
|
||||
prefMeditationVibrateInterval.setEntryValues(vibration_values);
|
||||
|
||||
ListPreferenceVibration prefMeditationVibrateFinish = (ListPreferenceVibration) (preferenceFragment == null ? findPreference("pref_meditation_vibrate_finish") : preferenceFragment.findPreference("pref_meditation_vibrate_finish"));
|
||||
prefMeditationVibrateFinish.setEntries(vibration);
|
||||
prefMeditationVibrateFinish.setEntryValues(vibration_values);
|
||||
}
|
||||
|
||||
void setupPreferences(String pref_type, PreferenceFragment preferenceFragment) {
|
||||
if (pref_type.equals("all") || pref_type.equals("session")) {
|
||||
if (preferenceFragment != null) {
|
||||
|
@ -569,10 +657,13 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_sessionintro") : preferenceFragment.findPreference("pref_sessionintro"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_session_delay") : preferenceFragment.findPreference("pref_session_delay"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_sound_start") : preferenceFragment.findPreference("pref_meditation_sound_start"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_vibrate_start") : preferenceFragment.findPreference("pref_meditation_vibrate_start"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_sound_interval") : preferenceFragment.findPreference("pref_meditation_sound_interval"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_vibrate_interval") : preferenceFragment.findPreference("pref_meditation_vibrate_interval"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_session_interval") : preferenceFragment.findPreference("pref_session_interval"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_interval_count") : preferenceFragment.findPreference("pref_interval_count"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_sound_finish") : preferenceFragment.findPreference("pref_meditation_sound_finish"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_meditation_vibrate_finish") : preferenceFragment.findPreference("pref_meditation_vibrate_finish"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_notificationcontrol") : preferenceFragment.findPreference("pref_notificationcontrol"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_sessionvolume") : preferenceFragment.findPreference("pref_sessionvolume"));
|
||||
bindPreferenceSummaryToValue(preferenceFragment == null ? findPreference("pref_presetsettings") : preferenceFragment.findPreference("pref_presetsettings"));
|
||||
|
@ -612,11 +703,11 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
@Override
|
||||
public boolean onPreferenceClick(Preference arg0) {
|
||||
if (ContextCompat.checkSelfPermission(SettingsActivity.this,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SettingsActivity.this,
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_IMPORT_READ_EXTERNAL_STORAGE);
|
||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_IMPORT_READ_EXTERNAL_STORAGE);
|
||||
} else {
|
||||
getMeditationAssistant().showImportSessionsDialog(SettingsActivity.this);
|
||||
}
|
||||
|
@ -629,11 +720,11 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
@Override
|
||||
public boolean onPreferenceClick(Preference arg0) {
|
||||
if (ContextCompat.checkSelfPermission(SettingsActivity.this,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(SettingsActivity.this,
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_EXPORT_WRITE_EXTERNAL_STORAGE);
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
PERMISSION_REQUEST_EXPORT_WRITE_EXTERNAL_STORAGE);
|
||||
} else {
|
||||
getMeditationAssistant().showFilePickerDialog(SettingsActivity.this, FILEPICKER_EXPORT_SESSIONS, FilePickerActivity.MODE_NEW_FILE);
|
||||
}
|
||||
|
@ -657,17 +748,17 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
} else {
|
||||
if (getMeditationAssistant().db.getNumSessions() == 0) {
|
||||
getMeditationAssistant().longToast(
|
||||
getMeditationAssistant().getString(R.string.sessionsUpToDate));
|
||||
getMeditationAssistant().getString(R.string.sessionsUpToDate));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getMeditationAssistant().getTimestamp()
|
||||
- uploadsessions_lastlick > 5) {
|
||||
- uploadsessions_lastlick > 5) {
|
||||
uploadsessions_lastlick = getMeditationAssistant()
|
||||
.getTimestamp();
|
||||
.getTimestamp();
|
||||
getMeditationAssistant().getMediNET()
|
||||
.uploadSessions();
|
||||
.uploadSessions();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,11 +774,11 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
getMeditationAssistant().startAuth(SettingsActivity.this, true);
|
||||
} else {
|
||||
if (getMeditationAssistant().getTimestamp()
|
||||
- downloadsessions_lastlick > 5) {
|
||||
- downloadsessions_lastlick > 5) {
|
||||
downloadsessions_lastlick = getMeditationAssistant()
|
||||
.getTimestamp();
|
||||
.getTimestamp();
|
||||
getMeditationAssistant().getMediNET()
|
||||
.downloadSessions();
|
||||
.downloadSessions();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,6 +842,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
addPreferencesFromResource(R.xml.pref_miscellaneous);
|
||||
|
||||
setupSoundPreferences(null);
|
||||
setupVibrationPreferences(null);
|
||||
setupPreferences("all", null);
|
||||
}
|
||||
|
||||
|
@ -794,21 +886,15 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
// Trigger the listener immediately with the preference's
|
||||
// current value.
|
||||
if (preference.getKey().equals("pref_daily_reminder") || preference.getKey().equals("pref_usetimepicker")) {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
getMeditationAssistant().getPrefs()
|
||||
.getBoolean(preference.getKey(), false)
|
||||
);
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, getMeditationAssistant().getPrefs().getBoolean(preference.getKey(), false));
|
||||
} else if (preference.getKey().equals("pref_presetsettings")) {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, getMeditationAssistant().getPrefs().getStringSet("pref_presetsettings", new HashSet<>(Arrays.asList(getResources().getStringArray(R.array.presetsettings_default))))
|
||||
);
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, getMeditationAssistant().getPrefs().getStringSet("pref_presetsettings", new HashSet<>(Arrays.asList(getResources().getStringArray(R.array.presetsettings_default)))));
|
||||
} else if (preference.getKey().equals("pref_mainbuttons")) {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, getMeditationAssistant().getPrefs().getStringSet("pref_mainbuttons", new HashSet<>()));
|
||||
} else if (preference.getKey().equals("pref_sessionvolume")) {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, getMeditationAssistant().getPrefs().getInt("pref_sessionvolume", 50));
|
||||
} else {
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
|
||||
getMeditationAssistant().getPrefs().getString(preference.getKey(), "")
|
||||
);
|
||||
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference, getMeditationAssistant().getPrefs().getString(preference.getKey(), ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,11 +908,11 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
@Override
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
return SessionPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
ReminderPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
MeditationPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
ProgressPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
MediNETPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
MiscellaneousPreferenceFragment.class.getName().equals(fragmentName);
|
||||
ReminderPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
MeditationPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
ProgressPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
MediNETPreferenceFragment.class.getName().equals(fragmentName) ||
|
||||
MiscellaneousPreferenceFragment.class.getName().equals(fragmentName);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
|
@ -843,6 +929,7 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
|
||||
SettingsActivity settingsactivity = (SettingsActivity) getActivity();
|
||||
settingsactivity.setupSoundPreferences(this);
|
||||
settingsactivity.setupVibrationPreferences(this);
|
||||
settingsactivity.setupPreferences("session", this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ class WakeLocker {
|
|||
|
||||
void releaseAll() {
|
||||
Log.d("MeditationAssistant", "WAKELOCKER: Releasing all wakelocks");
|
||||
|
||||
for (String wakeLockID : wakeLocks) {
|
||||
List<String> wakeLocksCopy = new ArrayList<>(wakeLocks);
|
||||
for (String wakeLockID : wakeLocksCopy) {
|
||||
release(wakeLockID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<!--suppress AndroidMissingOnClickHandler -->
|
||||
<RelativeLayout
|
||||
android:id="@+id/medinetsignin_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=".MediNET">
|
||||
|
||||
<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/pattern"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editVibrationPattern"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginLeft="14dp"
|
||||
android:singleLine="true"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:includeFontPadding="false"
|
||||
android:text="@string/setVibrationTip"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textSize="13sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="empty_array">
|
||||
</string-array>
|
||||
<string-array name="empty_array"></string-array>
|
||||
<string-array name="session_actions">
|
||||
<item>@string/post</item>
|
||||
<item>@string/delete</item>
|
||||
|
@ -127,10 +126,13 @@
|
|||
<item>introduction</item>
|
||||
<item>delay</item>
|
||||
<item>startsound</item>
|
||||
<item>startvibration</item>
|
||||
<item>intervalduration</item>
|
||||
<item>intervalsound</item>
|
||||
<item>intervalvibration</item>
|
||||
<item>intervalcount</item>
|
||||
<item>completesound</item>
|
||||
<item>completevibration</item>
|
||||
<item>ringtone</item>
|
||||
<item>volume</item>
|
||||
<item>endless</item>
|
||||
|
@ -141,14 +143,16 @@
|
|||
<item>@string/pref_sessionintro</item>
|
||||
<item>@string/pref_delay</item>
|
||||
<item>@string/pref_meditation_sound_start</item>
|
||||
<item>@string/pref_meditation_vibrate_start</item>
|
||||
<item>@string/pref_interval</item>
|
||||
<item>@string/pref_meditation_sound_interval</item>
|
||||
<item>@string/pref_meditation_vibrate_interval</item>
|
||||
<item>@string/pref_interval_count</item>
|
||||
<item>@string/pref_meditation_sound_finish</item>
|
||||
<item>@string/pref_meditation_vibrate_finish</item>
|
||||
<item>@string/pref_notificationcontrol</item>
|
||||
<item>@string/pref_sessionvolume</item>
|
||||
<item>@string/pref_softfinish</item>
|
||||
<item>@string/pref_vibrate</item>
|
||||
</string-array>
|
||||
<string-array name="presetsettings_default">
|
||||
<item>modeandduration</item>
|
||||
|
@ -163,5 +167,19 @@
|
|||
<item>save</item>
|
||||
<item>post</item>
|
||||
</string-array>
|
||||
<string-array name="vibration_values">
|
||||
<item></item>
|
||||
<item>short</item>
|
||||
<item>medium</item>
|
||||
<item>long</item>
|
||||
<item>custom</item>
|
||||
</string-array>
|
||||
<string-array name="vibration">
|
||||
<item>@string/disabled</item>
|
||||
<item>@string/labelShort</item>
|
||||
<item>@string/labelMedium</item>
|
||||
<item>@string/labelLong</item>
|
||||
<item>@string/custom</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
|
@ -52,8 +52,10 @@
|
|||
<string name="setPresetHint">Hold to set preset</string>
|
||||
<string name="setPresetTip">Choose which settings to restore by tapping the gear icon (Settings), then tap Preset settings.</string>
|
||||
<string name="setPresetHintBlank">Enter a duration (or end time) to set preset</string>
|
||||
<string name="setVibrationTip">Enter the number of milliseconds to turn the vibrator on or off, separated by commas.</string>
|
||||
<string name="configureWidget">Configure Widget</string>
|
||||
<string name="label">Label</string>
|
||||
<string name="pattern">Pattern</string>
|
||||
<string name="setTimerDurationHint">Enter a valid duration (e.g. 0:22)</string>
|
||||
<string name="setTimerEndAtHint">Enter a valid time (e.g. 4:20)</string>
|
||||
<string name="invalidEndAt">Invalid time to end session</string>
|
||||
|
@ -148,7 +150,10 @@
|
|||
<string name="reminderText">Do you have a moment?</string>
|
||||
<!-- Settings -->
|
||||
<string name="meditation">Meditation</string>
|
||||
<string name="pref_vibrate">Vibrate</string>
|
||||
<string name="vibrate">Vibrate</string>
|
||||
<string name="pref_meditation_vibrate_start">Start vibration</string>
|
||||
<string name="pref_meditation_vibrate_interval">Interval vibration</string>
|
||||
<string name="pref_meditation_vibrate_finish">Complete vibration</string>
|
||||
<string name="pref_vibrate_summary">Occurs at the beginning, intervals, and end of meditation</string>
|
||||
<string name="pref_vibrate_reminder_summary">The daily reminder will vibrate the device</string>
|
||||
<string name="pref_sound_reminder">Play sound</string>
|
||||
|
@ -159,6 +164,10 @@
|
|||
<string name="disabled">Disabled</string>
|
||||
<string name="none">None</string>
|
||||
<string name="noSpecialBehavior">No special behavior</string>
|
||||
<string name="labelShort">Short</string>
|
||||
<string name="labelMedium">Medium</string>
|
||||
<string name="labelLong">Long</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="noSound">No sound</string>
|
||||
<string name="customSound">Custom sound</string>
|
||||
<string name="duringSession">During session</string>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:dependency="pref_daily_reminder"
|
||||
android:key="pref_vibrate_reminder"
|
||||
android:summary="@string/pref_vibrate_reminder_summary"
|
||||
android:title="@string/pref_vibrate"/>
|
||||
android:title="@string/vibrate"/>
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue=""
|
||||
|
|
|
@ -32,6 +32,15 @@
|
|||
android:key="pref_meditation_sound_start"
|
||||
android:title="@string/pref_meditation_sound_start"/>
|
||||
|
||||
<sh.ftp.rocketninelabs.meditationassistant.ListPreferenceVibration
|
||||
android:defaultValue=""
|
||||
android:dialogIcon="?attr/actionIconFlashOn"
|
||||
android:entries="@array/vibration"
|
||||
android:entryValues="@array/vibration_values"
|
||||
android:icon="?attr/actionIconFlashOn"
|
||||
android:key="pref_meditation_vibrate_start"
|
||||
android:title="@string/pref_meditation_vibrate_start"/>
|
||||
|
||||
<sh.ftp.rocketninelabs.meditationassistant.TimePreference
|
||||
android:defaultValue="00:00"
|
||||
android:dialogIcon="?attr/actionIconTime"
|
||||
|
@ -50,6 +59,16 @@
|
|||
android:icon="?attr/actionIconVolumeOn"
|
||||
android:key="pref_meditation_sound_interval"
|
||||
android:title="@string/pref_meditation_sound_interval"/>
|
||||
|
||||
<sh.ftp.rocketninelabs.meditationassistant.ListPreferenceVibration
|
||||
android:defaultValue=""
|
||||
android:dialogIcon="?attr/actionIconFlashOn"
|
||||
android:entries="@array/vibration"
|
||||
android:entryValues="@array/vibration_values"
|
||||
android:icon="?attr/actionIconFlashOn"
|
||||
android:key="pref_meditation_vibrate_interval"
|
||||
android:title="@string/pref_meditation_vibrate_interval"/>
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue=""
|
||||
android:dialogIcon="?attr/actionIconRefresh"
|
||||
|
@ -68,6 +87,15 @@
|
|||
android:key="pref_meditation_sound_finish"
|
||||
android:title="@string/pref_meditation_sound_finish"/>
|
||||
|
||||
<sh.ftp.rocketninelabs.meditationassistant.ListPreferenceVibration
|
||||
android:defaultValue=""
|
||||
android:dialogIcon="?attr/actionIconFlashOn"
|
||||
android:entries="@array/vibration"
|
||||
android:entryValues="@array/vibration_values"
|
||||
android:icon="?attr/actionIconFlashOn"
|
||||
android:key="pref_meditation_vibrate_finish"
|
||||
android:title="@string/pref_meditation_vibrate_finish"/>
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue=""
|
||||
android:dialogIcon="?attr/actionIconRingVolume"
|
||||
|
@ -92,13 +120,6 @@
|
|||
android:summary="@string/pref_softfinish_summary"
|
||||
android:title="@string/pref_softfinish"/>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:icon="?attr/actionIconFlashOn"
|
||||
android:key="pref_vibrate"
|
||||
android:summary="@string/pref_vibrate_summary"
|
||||
android:title="@string/pref_vibrate"/>
|
||||
|
||||
<MultiSelectListPreference
|
||||
android:defaultValue="@array/presetsettings_default"
|
||||
android:dialogIcon="?attr/actionIconForward"
|
||||
|
|
Loading…
Reference in New Issue