Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
iSoron committed Jun 5, 2018
2 parents bf8c14f + ce27773 commit 87f069f
Show file tree
Hide file tree
Showing 50 changed files with 1,017 additions and 365 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

### 1.7.8 (September 30, 2017)
### 1.7.8 (April 21, 2018)

* Add support for adaptive icons (Oreo)
* Add support for notification channels (Oreo)
* Update translations

### 1.7.7 (September 30, 2017)

* Fix bug that caused reminders to show repeatedly on DST changes

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 178 additions & 0 deletions app/src/main/res/values-ta-rIN/strings.xml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions app/src/main/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#1976D2</color>
</resources>
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ VERSION_CODE = 35
VERSION_NAME = 1.7.8

MIN_SDK_VERSION = 19
TARGET_SDK_VERSION = 25
COMPILE_SDK_VERSION = 25
TARGET_SDK_VERSION = 27
COMPILE_SDK_VERSION = 27

DAGGER_VERSION = 2.9
BUILD_TOOLS_VERSION = 26.0.2
BUILD_TOOLS_VERSION = 27.0.3
KOTLIN_VERSION = 1.1.2-4
SUPPORT_LIBRARY_VERSION = 25.3.1
SUPPORT_LIBRARY_VERSION = 27.1.1

org.gradle.parallel=false
org.gradle.daemon=true
Expand Down
4 changes: 3 additions & 1 deletion uhabits-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
-->
<manifest
package="org.isoron.uhabits"
xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="36"
android:versionName="1.7.9">

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

Expand Down
Binary file modified uhabits-android/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class NumberPickerFactory
val inflater = LayoutInflater.from(context)
val view = inflater.inflate(R.layout.number_picker_dialog, null)

val picker = view.findViewById(R.id.picker) as NumberPicker
val picker2 = view.findViewById(R.id.picker2) as NumberPicker
val tvUnit = view.findViewById(R.id.tvUnit) as TextView
val picker = view.findViewById<NumberPicker>(R.id.picker)
val picker2 = view.findViewById<NumberPicker>(R.id.picker2)
val tvUnit = view.findViewById<TextView>(R.id.tvUnit)

val intValue = Math.round(value * 100).toInt()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,12 @@
import org.isoron.uhabits.*;
import org.isoron.uhabits.R;
import org.isoron.uhabits.core.preferences.*;
import org.isoron.uhabits.core.ui.*;
import org.isoron.uhabits.notifications.*;

import static android.media.RingtoneManager.ACTION_RINGTONE_PICKER;
import static android.media.RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI;
import static android.media.RingtoneManager.EXTRA_RINGTONE_EXISTING_URI;
import static android.media.RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT;
import static android.media.RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT;
import static android.media.RingtoneManager.EXTRA_RINGTONE_TYPE;
import static android.media.RingtoneManager.TYPE_NOTIFICATION;
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.RESULT_BUG_REPORT;
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.RESULT_EXPORT_CSV;
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.RESULT_EXPORT_DB;
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.RESULT_IMPORT_DATA;
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.RESULT_REPAIR_DB;
import static android.media.RingtoneManager.*;
import static android.os.Build.VERSION.SDK_INT;
import static org.isoron.uhabits.activities.habits.list.ListHabitsScreenKt.*;

public class SettingsFragment extends PreferenceFragmentCompat
implements SharedPreferences.OnSharedPreferenceChangeListener
Expand Down Expand Up @@ -114,6 +106,16 @@ public boolean onPreferenceTreeClick(Preference preference)
showRingtonePicker();
return true;
}
else if (key.equals("reminderCustomize"))
{
if (SDK_INT < Build.VERSION_CODES.O) return true;
AndroidNotificationTray.Companion.createAndroidNotificationChannel(getContext());
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getContext().getPackageName());
intent.putExtra(Settings.EXTRA_CHANNEL_ID, NotificationTray.REMINDERS_CHANNEL_ID);
startActivity(intent);
return true;
}

return super.onPreferenceTreeClick(preference);
}
Expand All @@ -135,7 +137,14 @@ public void onResume()
devCategory.setVisible(false);
}

updateRingtoneDescription();
if (SDK_INT < Build.VERSION_CODES.O)
findPreference("reminderCustomize").setVisible(false);
else
{
findPreference("reminderSound").setVisible(false);
findPreference("pref_snooze_interval").setVisible(false);
}

updateSync();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PendingIntentFactory
.addNextIntentWithParentStack(
intentFactory.startShowHabitActivity(
context, habit))
.getPendingIntent(0, FLAG_UPDATE_CURRENT)
.getPendingIntent(0, FLAG_UPDATE_CURRENT)!!

fun showReminder(habit: Habit,
reminderTime: Long?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import android.app.*
import android.content.*
import android.graphics.*
import android.graphics.BitmapFactory.*
import android.os.*
import android.os.Build.VERSION.*
import android.support.annotation.*
import android.support.v4.app.*
import android.support.v4.app.NotificationCompat.*
Expand All @@ -35,6 +37,9 @@ import org.isoron.uhabits.core.ui.*
import org.isoron.uhabits.intents.*
import javax.inject.*




@AppScope
class AndroidNotificationTray
@Inject constructor(
Expand All @@ -46,6 +51,7 @@ class AndroidNotificationTray

private var active = HashSet<Int>()


override fun removeNotification(id: Int) {
val manager = NotificationManagerCompat.from(context)
manager.cancel(id)
Expand All @@ -64,6 +70,7 @@ class AndroidNotificationTray
val summary = buildSummary(reminderTime)
notificationManager.notify(Int.MAX_VALUE, summary)
val notification = buildNotification(habit, reminderTime, timestamp)
createAndroidNotificationChannel(context)
notificationManager.notify(notificationId, notification)
active.add(notificationId)
}
Expand All @@ -79,11 +86,6 @@ class AndroidNotificationTray
context.getString(R.string.yes),
pendingIntents.addCheckmark(habit, timestamp))

val snoozeAction = Action(
R.drawable.ic_action_snooze,
context.getString(R.string.snooze),
pendingIntents.snoozeNotification(habit))

val removeRepetitionAction = Action(
R.drawable.ic_action_cancel,
context.getString(R.string.no),
Expand All @@ -98,19 +100,16 @@ class AndroidNotificationTray
.setBackground(wearableBg)
.addAction(addRepetitionAction)
.addAction(removeRepetitionAction)
.addAction(snoozeAction)

val builder = NotificationCompat.Builder(context)
val builder = NotificationCompat.Builder(context, REMINDERS_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(habit.name)
.setContentText(habit.description)
.setContentIntent(pendingIntents.showHabit(habit))
.setDeleteIntent(pendingIntents.dismissNotification(habit))
.addAction(addRepetitionAction)
.addAction(removeRepetitionAction)
.addAction(snoozeAction)
.setSound(ringtoneManager.getURI())
.extend(wearableExtender)
.setWhen(reminderTime)
.setShowWhen(true)
.setOngoing(preferences.shouldMakeNotificationsSticky())
Expand All @@ -119,13 +118,22 @@ class AndroidNotificationTray
if (preferences.shouldMakeNotificationsLed())
builder.setLights(Color.RED, 1000, 1000)

return builder.build()
if(SDK_INT < Build.VERSION_CODES.O) {
val snoozeAction = Action(R.drawable.ic_action_snooze,
context.getString(R.string.snooze),
pendingIntents.snoozeNotification(habit))
wearableExtender.addAction(snoozeAction)
builder.addAction(snoozeAction)
}

builder.extend(wearableExtender)
return builder.build()
}

@NonNull
private fun buildSummary(@NonNull reminderTime: Long) : Notification
{
return NotificationCompat.Builder(context)
return NotificationCompat.Builder(context, REMINDERS_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(context.getString(R.string.app_name))
.setWhen(reminderTime)
Expand All @@ -134,4 +142,20 @@ class AndroidNotificationTray
.setGroupSummary(true)
.build()
}

companion object {
private val REMINDERS_CHANNEL_ID = "REMINDERS"
fun createAndroidNotificationChannel(context: Context) {
val notificationManager = context.getSystemService(Activity.NOTIFICATION_SERVICE)
as NotificationManager
if (SDK_INT >= Build.VERSION_CODES.O)
{
val channel = NotificationChannel(REMINDERS_CHANNEL_ID,
context.resources.getString(R.string.reminder),
NotificationManager.IMPORTANCE_DEFAULT)
notificationManager.createNotificationChannel(channel)
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import android.content.*;
import android.net.*;
import android.os.*;
import android.support.v7.app.*;
import android.support.v4.app.*;

import org.isoron.uhabits.*;
import org.isoron.uhabits.core.preferences.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ fun View.showMessage(@StringRes stringId: Int) {
try {
val snackbar = Snackbar.make(this, stringId, Snackbar.LENGTH_SHORT)
val tvId = android.support.design.R.id.snackbar_text
val tv = snackbar.view.findViewById(tvId)
if(tv is TextView) tv.setTextColor(Color.WHITE)
val tv = snackbar.view.findViewById<TextView>(tvId)
tv?.setTextColor(Color.WHITE)
snackbar.show()
} catch (e: IllegalArgumentException) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HabitPickerDialog : Activity(), AdapterView.OnItemClickListener {
}

setContentView(R.layout.widget_configure_activity)
with(findViewById(R.id.listView) as ListView) {
with(findViewById<ListView>(R.id.listView)) {
adapter = ArrayAdapter(context, android.R.layout.simple_list_item_1,
habitNames)
onItemClickListener = this@HabitPickerDialog
Expand Down
Loading

0 comments on commit 87f069f

Please sign in to comment.