Skip to content

Commit

Permalink
Merge branch 'hotfix/1.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
iSoron committed May 29, 2016
2 parents 33bc8f7 + cbf1bd3 commit 0077436
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 1.5.4 (May 29, 2016)

* Fix crash upon opening settings screen in some phones
* Fix missing folders in CSV archive
* Add Serbian translation

### 1.5.3 (May 22, 2016)

* Complete Arabic and Czech translations
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<manifest
package="org.isoron.uhabits"
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="19"
android:versionName="1.5.3">
android:versionCode="20"
android:versionName="1.5.4">

<uses-permission android:name="android.permission.VIBRATE"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data)
private void updateRingtoneDescription()
{
String ringtoneName = ReminderHelper.getRingtoneName(getContext());
if(ringtoneName == null) return;
Preference ringtonePreference = findPreference("reminderSound");
ringtonePreference.setSummary(ringtoneName);
}
Expand Down
29 changes: 19 additions & 10 deletions app/src/main/java/org/isoron/uhabits/helpers/ReminderHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,30 @@ public static void startRingtonePickerActivity(Fragment fragment, int requestCod
fragment.startActivityForResult(intent, requestCode);
}

@Nullable
public static String getRingtoneName(Context context)
{
Uri ringtoneUri = getRingtoneUri(context);
String ringtoneName = context.getResources().getString(R.string.none);

if(ringtoneUri != null)
try
{
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
if(ringtone != null)
Uri ringtoneUri = getRingtoneUri(context);
String ringtoneName = context.getResources().getString(R.string.none);

if (ringtoneUri != null)
{
ringtoneName = ringtone.getTitle(context);
ringtone.stop();
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
if (ringtone != null)
{
ringtoneName = ringtone.getTitle(context);
ringtone.stop();
}
}
}

return ringtoneName;
return ringtoneName;
}
catch (RuntimeException e)
{
e.printStackTrace();
return null;
}
}
}
14 changes: 13 additions & 1 deletion app/src/main/java/org/isoron/uhabits/io/HabitsCSVExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.isoron.uhabits.io;

import android.support.annotation.NonNull;

import org.isoron.uhabits.helpers.DateHelper;
import org.isoron.uhabits.models.CheckmarkList;
import org.isoron.uhabits.models.Habit;
Expand Down Expand Up @@ -64,7 +66,10 @@ private void writeHabits() throws IOException

for(Habit h : habits)
{
String habitDirName = String.format("%03d %s/", h.position + 1, h.name);
String sane = sanitizeFilename(h.name);
String habitDirName = String.format("%03d %s", h.position + 1, sane);
habitDirName = habitDirName.trim() + "/";

new File(exportDirName + habitDirName).mkdirs();
generateDirs.add(habitDirName);

Expand All @@ -73,6 +78,13 @@ private void writeHabits() throws IOException
}
}

@NonNull
private String sanitizeFilename(String name)
{
String s = name.replaceAll("[^a-zA-Z0-9\\._-]+", "");
return s.substring(0, Math.min(s.length(), 100));
}

private void writeScores(String habitDirName, ScoreList scores) throws IOException
{
String path = habitDirName + "Scores.csv";
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/isoron/uhabits/models/Habit.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public void clearReminder()
*/
public static void writeCSV(List<Habit> habits, Writer out) throws IOException
{
String header[] = { "Name", "Description", "NumRepetitions", "Interval", "Color" };
String header[] = { "Position", "Name", "Description", "NumRepetitions", "Interval", "Color" };

CSVWriter csv = new CSVWriter(out);
csv.writeNext(header, false);
Expand All @@ -498,6 +498,7 @@ public static void writeCSV(List<Habit> habits, Writer out) throws IOException
{
String[] cols =
{
String.format("%03d", habit.position + 1),
habit.name,
habit.description,
Integer.toString(habit.freqNum),
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
style="@style/About.Item"
android:text="Robin (Svenska)"/>

<TextView
style="@style/About.Item"
android:text="Đorđe Vasiljević (српски)"/>

<TextView
style="@style/About.Item"
android:text="Caner Başaran (Türkçe)"/>
Expand Down
Loading

0 comments on commit 0077436

Please sign in to comment.