Skip to content

Commit

Permalink
v1.5.1 (36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandros committed Jul 1, 2021
1 parent b454f5f commit bd9f64e
Show file tree
Hide file tree
Showing 133 changed files with 8,499 additions and 4,349 deletions.
36 changes: 18 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static def gitBranch() {


android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 30
buildToolsVersion "30.0.2"

signingConfigs {
// signing configuration for a local debug.keystore file
Expand All @@ -59,10 +59,10 @@ android {

defaultConfig {
applicationId "de.telekom.sync.plus"
minSdkVersion 21
targetSdkVersion 29
versionCode 29
versionName "1.4.4"
minSdkVersion 21 // Android 5
targetSdkVersion 30 // Android 11
versionCode 36
versionName "1.5.1"
multiDexEnabled true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -128,31 +128,31 @@ dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
implementation 'androidx.fragment:fragment-ktx:1.2.4'
implementation 'androidx.core:core-ktx:1.2.0'
//implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.fragment:fragment-ktx:1.3.4'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
implementation 'androidx.multidex:multidex:2.0.1'

implementation 'com.google.android.material:material:1.1.0'
implementation 'com.github.AppIntro:AppIntro:5.1.0'
implementation 'com.jaredrummler:material-spinner:1.3.1'
implementation 'com.github.rahatarmanahmed:circularprogressview:2.5.0'

def room_version = '2.2.5'
def room_version = '2.2.6'
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ object DavNotificationUtils {
private const val CHANNEL_SYNC_WARNINGS = NotificationUtils.CHANNEL_SYNC_WARNINGS
private const val CHANNEL_SYNC_IO_ERRORS = NotificationUtils.CHANNEL_SYNC_IO_ERRORS

/*
private fun buildRetryAction(
context: Context,
authority: String,
account: Account
): NotificationCompat.Action {
val retryIntent = Intent(context, DavService::class.java)
retryIntent.action = DavService.ACTION_FORCE_SYNC
// TODO: Missing 'serviceEnvironments' action.
val syncAuthority = if (authority == ContactsContract.AUTHORITY) {
// if this is a contacts sync, retry syncing all address books of the main account
Expand All @@ -74,6 +76,7 @@ object DavNotificationUtils {
PendingIntent.getService(context, 0, retryIntent, PendingIntent.FLAG_UPDATE_CURRENT)
)
}
*/

/*
fun buildSyncErrorNotification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.CalendarContract
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -38,8 +39,8 @@ import android.widget.CheckBox
import android.widget.ImageView
import android.widget.ListView
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
import de.telekom.dtagsyncpluskit.davx5.log.Logger
import de.telekom.dtagsyncpluskit.davx5.model.Collection
Expand Down Expand Up @@ -119,28 +120,36 @@ class AccountSettingsFragment : BaseFragment() {
setupCalendarSubView(v, accountSettings)
setupAddressBookSubView(v, accountSettings)
setupSyncDropdown(v, accountSettings)
updateLastSyncDate(v, accountSettings)

val context = requireContext()
v.syncnowButton.setOnClickListener {
v.syncnowButton.isEnabled = false
v.syncnowButton.icon = context.getDrawable(R.drawable.ic_sync_now_icon)
v.syncnowButton.icon = ContextCompat.getDrawable(context, R.drawable.ic_sync_now_icon)
v.syncnowtextview.text = requireContext().getString(R.string.sync_now)
accountSettings.resyncCalendars(false)
accountSettings.resyncContacts(false)

mHandler.postDelayed({
v.syncnowButton.isEnabled = true
val drawable = context.getDrawable(R.drawable.ic_sync_check_animated)
val drawable = ContextCompat.getDrawable(context, R.drawable.ic_sync_check_animated)
v.syncnowButton.icon = drawable
v.syncnowtextview.text = requireContext().getString(R.string.sync_done)
mHandler.post { (drawable as? AnimatedVectorDrawable)?.start() }
mHandler.postDelayed({
if (v.syncnowButton.isEnabled) {
v.syncnowtextview.text = requireContext().getString(R.string.sync_now)
v.syncnowButton.icon =
requireContext().getDrawable(R.drawable.ic_sync_now_icon)
ContextCompat.getDrawable(requireContext(), R.drawable.ic_sync_now_icon)
}

// Sync should be completed now, update last synced date.
updateLastSyncDate(v, accountSettings)
}, 5000)

// It's not guaranteed that the sync is done at this point, we'll try updating it
// once again in a couple seconds.
updateLastSyncDate(v, accountSettings)
}, 2500)
}

Expand All @@ -152,6 +161,28 @@ class AccountSettingsFragment : BaseFragment() {
mHandler.removeCallbacksAndMessages(null)
}

private fun updateLastSyncDate(view: View, accountSettings: AccountSettings) {
val calendarSyncDate = accountSettings.lastSyncDate(CalendarContract.AUTHORITY)
if (calendarSyncDate != null) {
val (dayMonYear, hourMin) = calendarSyncDate
view.synctext_calendar?.text = getString(R.string.synctext_format, dayMonYear, hourMin)
view.synctext_calendar?.visibility =
if (accountSettings.isCalendarSyncEnabled()) View.VISIBLE else View.GONE
} else {
view.synctext_calendar?.visibility = View.GONE
}

val addressSyncDate = accountSettings.lastSyncDate(getString(de.telekom.dtagsyncpluskit.R.string.address_books_authority))
if (addressSyncDate != null) {
val (dayMonYear, hourMin) = addressSyncDate
view.synctext?.text = getString(R.string.synctext_format, dayMonYear, hourMin)
view.synctext?.visibility =
if (accountSettings.isContactSyncEnabled()) View.VISIBLE else View.GONE
} else {
view.synctext?.visibility = View.GONE
}
}

@SuppressLint("MissingPermission")
private fun setupCalendarSubView(v: View, accountSettings: AccountSettings) {
val model by activityViewModels<CalendarCollectionsViewModel>()
Expand Down Expand Up @@ -193,9 +224,9 @@ class AccountSettingsFragment : BaseFragment() {
}

model.fetch(mAccount, App.serviceEnvironments(requireContext()), Collection.TYPE_CALENDAR)
model.fetcher.observe(viewLifecycleOwner, Observer { fetcher ->
model.fetcher.observe(viewLifecycleOwner, { fetcher ->
fetcher?.collections?.removeObservers(viewLifecycleOwner)
fetcher?.collections?.observe(viewLifecycleOwner, Observer { collections ->
fetcher?.collections?.observe(viewLifecycleOwner, { collections ->
val adapter = v.calendarList.adapter as? CalendarAdapter
adapter?.dataSource = sortCalendarCollections(collections.toList())
adapter?.notifyDataSetChanged()
Expand All @@ -210,9 +241,6 @@ class AccountSettingsFragment : BaseFragment() {

private fun setupAddressBookSubView(v: View, accountSettings: AccountSettings) {
v.addressBookSwitch.isChecked = accountSettings.isContactSyncEnabled()
v.synctext.text = getString(R.string.synctext_format, accountSettings.lastSyncDate())
v.synctext.visibility =
if (accountSettings.isContactSyncEnabled()) View.VISIBLE else View.GONE

val enableContactSync: (isEnabled: Boolean) -> Unit = { isEnabled ->
accountSettings.setContactSyncEnabled(isEnabled)
Expand All @@ -223,7 +251,7 @@ class AccountSettingsFragment : BaseFragment() {
}

v.addressBookSwitch.setOnCheckedChangeListener { _, isChecked ->
v.synctext.visibility = if (isChecked) View.VISIBLE else View.GONE
//v.synctext.visibility = if (isChecked) View.VISIBLE else View.GONE

if (isChecked) {
// Request required permissions first.
Expand Down Expand Up @@ -252,7 +280,9 @@ class AccountSettingsFragment : BaseFragment() {
val getSyncInterval: () -> Long? = {
val addressBookSyncInterval = accountSettings.getSyncInterval(addressBookAuthority)
val calendarSyncInterval = accountSettings.getSyncInterval(CalendarContract.AUTHORITY)
(addressBookSyncInterval ?: calendarSyncInterval)
val ret = (addressBookSyncInterval ?: calendarSyncInterval)
Logger.log.info("getSyncInterval = $ret")
ret
}

val syncInterval = getSyncInterval()
Expand All @@ -262,6 +292,7 @@ class AccountSettingsFragment : BaseFragment() {
}

v.more_settings_wrapper.visibility = View.VISIBLE
Logger.log.info("formatSyncIntervalString = ${formatSyncIntervalString(syncInterval)}")
v.moreSettingsText.text = formatSyncIntervalString(syncInterval)
v.moreSettingsButton.setOnClickListener {
showSyncIntervalDialog(getSyncInterval()) { interval ->
Expand All @@ -277,6 +308,7 @@ class AccountSettingsFragment : BaseFragment() {

// Interval is in seconds!
private fun formatSyncIntervalString(interval: Long): String {
Logger.log.info("formatSyncIntervalString($interval)")
val intervalInMinutes = interval / 60
if (intervalInMinutes <= 60) {
return getString(R.string.every_x_minutes, intervalInMinutes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class CalendarCollectionsViewModel(private val app: Application) : AndroidViewMo

val serviceId =
mDB.serviceDao().getIdByAccountAndType(account.name, serviceType)
?: return@launch

val newFetcher = CollectionFetcher(
app,
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/drawable/ic_sync_errors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12.5704,20.7249C12.3814,20.7379 12.1914,20.7499 12.0004,20.7499C9.3494,20.7499 6.8494,19.4999 5.2004,17.4999L7.6504,15.8999L1.5004,13.2009L1.5004,19.8499L3.9004,18.2499C5.8494,20.7499 8.8494,22.2499 12.0004,22.2499C12.7124,22.2499 13.4094,22.1659 14.0884,22.0229C13.5174,21.6679 13.0064,21.2319 12.5704,20.7249"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M17.4997,11.0004C20.5377,11.0004 22.9997,13.4624 22.9997,16.5004C22.9997,19.5364 20.5377,22.0004 17.4997,22.0004C14.4627,22.0004 11.9997,19.5364 11.9997,16.5004C11.9997,13.4624 14.4627,11.0004 17.4997,11.0004ZM17.5997,17.9384C17.1587,17.9384 16.7997,18.2964 16.7997,18.7384C16.7997,19.1804 17.1587,19.5384 17.5997,19.5384C18.0417,19.5384 18.4007,19.1804 18.4007,18.7384C18.4007,18.2964 18.0417,17.9384 17.5997,17.9384ZM18.1997,13.8004L16.9997,13.8004L16.9997,17.0004L18.1997,17.0004L18.1997,13.8004Z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
<path
android:pathData="M22.5001,10.8001L16.3501,8.1001L18.8001,6.5001C17.2001,4.5001 14.7001,3.2501 12.0001,3.2501C7.9501,3.2501 4.3501,6.1501 3.4501,10.1001C3.3501,10.5001 2.9501,10.7501 2.5501,10.6501C2.1491,10.5501 1.8991,10.1501 2.0001,9.7501C3.0501,5.1001 7.2501,1.7501 12.0001,1.7501C15.2001,1.7501 18.1491,3.2501 20.1001,5.6991L22.5001,4.1001L22.5001,10.8001Z"
android:strokeWidth="1"
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
</vector>
36 changes: 24 additions & 12 deletions app/src/main/res/layout/fragment_accounts_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@
android:theme="@style/Switch" />
</LinearLayout>

<TextView
android:id="@+id/synctext_calendar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:fontFamily="@font/telegrotesknext_regular"
android:text="@string/synctext_format"
android:textColor="#7C7C7C"
android:paddingStart="@dimen/marginStart"
android:paddingEnd="@dimen/marginStart"
android:textSize="@dimen/fontSizeVerySmall" />

<!-- Expandable area here -->
<LinearLayout
android:id="@+id/calendarListWrapper"
Expand Down Expand Up @@ -196,7 +208,6 @@
android:id="@+id/addressbook_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:orientation="vertical"
android:paddingStart="@dimen/marginStart"
android:paddingEnd="@dimen/marginEnd">
Expand Down Expand Up @@ -230,19 +241,20 @@
android:layout_height="wrap_content"
android:theme="@style/Switch" />
</LinearLayout>

<TextView
android:id="@+id/synctext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:fontFamily="@font/telegrotesknext_regular"
android:text="@string/synctext_format"
android:textColor="#7C7C7C"
android:textSize="@dimen/fontSizeVerySmall" />

</LinearLayout>

<TextView
android:id="@+id/synctext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/marginStart"
android:layout_marginBottom="50dp"
android:paddingEnd="@dimen/marginStart"
android:fontFamily="@font/telegrotesknext_regular"
android:text="@string/synctext_format"
android:textColor="#7C7C7C"
android:textSize="@dimen/fontSizeVerySmall" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ vom Handy: 2202</string>
<string name="sync_timing_description">Häufigkeit der Synchronisation</string>
<string name="every_x_hours">Alle %1$d Stunden</string>
<string name="every_x_minutes">Alle %1$d Minuten</string>
<string name="synctext_format">Letzte Synchronisation am %1$s</string>
<string name="synctext_format">Letzte Synchronisation am %1$s um %2$s</string>
<string name="dialog_login_duplicated_title">Account existiert bereits</string>
<string name="fallbackName"><![CDATA[<Unbekannt>]]></string>
<string name="please_wait">Einen Moment bitte …</string>
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.71'
ext.kotlin_version = '1.4.32'
repositories {
google()
jcenter()
Expand All @@ -11,7 +11,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jaredsburrows:gradle-license-plugin:0.8.80'
classpath 'de.fabgroeger.gradle.plugins:birdflightupload:4.2'
Expand Down
Loading

0 comments on commit bd9f64e

Please sign in to comment.