Commit 462a6af7 authored by Ricki Hirner's avatar Ricki Hirner

Migrate to SDK level 28 and AndroidX

parent 99d992fd
......@@ -12,12 +12,12 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "at.bitfire.icsdroid"
minSdkVersion 19
targetSdkVersion 27
targetSdkVersion 28
versionCode 24
versionName "1.6"
......@@ -46,10 +46,12 @@ dependencies {
implementation project(':cert4android')
implementation project(':ical4android')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:cardview-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
implementation 'android.arch.work:work-runtime-ktx:1.0.0-alpha08'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-livedata:2.0.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'android.arch.work:work-runtime-ktx:1.0.0-alpha11'
implementation 'com.github.yukuku:ambilwarna:2.0.1'
implementation 'commons-io:commons-io:2.6'
......
......@@ -39,7 +39,8 @@
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security">
<service
android:name=".AccountAuthenticatorService"
android:exported="false" >
......
......@@ -5,10 +5,10 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.support.v4.app.NotificationCompat
import android.support.v4.content.ContextCompat
import android.util.Base64
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.ical4android.Event
......
......@@ -12,7 +12,7 @@ import android.accounts.Account
import android.app.PendingIntent
import android.content.*
import android.os.Bundle
import android.support.v4.app.NotificationCompat
import androidx.core.app.NotificationCompat
import at.bitfire.icsdroid.ui.CalendarListActivity
import at.bitfire.icsdroid.ui.NotificationUtils
......
......@@ -9,14 +9,13 @@
package at.bitfire.icsdroid
import android.accounts.Account
import android.annotation.SuppressLint
import android.content.ContentProviderClient
import android.content.Context
import android.os.Build
import android.provider.CalendarContract
import android.util.Log
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import androidx.work.Worker
import androidx.work.*
import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.icsdroid.db.LocalCalendar
import java.util.concurrent.LinkedBlockingQueue
......@@ -24,7 +23,10 @@ import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
class SyncWorker: Worker() {
class SyncWorker(
context: Context,
workerParams: WorkerParameters
): Worker(context, workerParams) {
companion object {
......@@ -42,7 +44,7 @@ class SyncWorker: Worker() {
.enqueue()
}
fun liveStatus() = WorkManager.getInstance().getStatusesForUniqueWork(NAME)
fun liveStatus() = WorkManager.getInstance().getWorkInfosForUniqueWorkLiveData(NAME)
}
......@@ -54,6 +56,7 @@ class SyncWorker: Worker() {
syncQueue
)
@SuppressLint("Recycle")
override fun doWork(): Result {
if (syncRunning.get()) {
Log.w(Constants.TAG, "There's already another sync running, aborting")
......
......@@ -11,9 +11,9 @@ package at.bitfire.icsdroid.ui
import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import android.support.v4.app.ActivityCompat
import android.support.v7.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import at.bitfire.icsdroid.R
class AddCalendarActivity: AppCompatActivity() {
......
......@@ -14,7 +14,7 @@ import android.content.ContentValues
import android.os.Bundle
import android.provider.CalendarContract
import android.provider.CalendarContract.Calendars
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.util.Log
import android.view.*
import android.widget.Toast
......
......@@ -11,12 +11,12 @@ package at.bitfire.icsdroid.ui
import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import android.support.v4.app.ActivityCompat
import android.support.v4.app.Fragment
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import android.view.*
import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment
import at.bitfire.icsdroid.Constants
import at.bitfire.icsdroid.R
import kotlinx.android.synthetic.main.add_calendar_enter_url.view.*
......
......@@ -12,13 +12,13 @@ import android.app.Dialog
import android.app.ProgressDialog
import android.content.Context
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.support.v4.app.LoaderManager
import android.support.v4.content.AsyncTaskLoader
import android.support.v4.content.Loader
import android.util.Base64
import android.util.Log
import android.widget.Toast
import androidx.fragment.app.DialogFragment
import androidx.loader.app.LoaderManager
import androidx.loader.content.AsyncTaskLoader
import androidx.loader.content.Loader
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.ical4android.Event
import at.bitfire.icsdroid.Constants
......@@ -49,7 +49,7 @@ class AddCalendarValidationFragment: DialogFragment(), LoaderManager.LoaderCallb
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
loaderManager.initLoader(0, arguments, this)
LoaderManager.getInstance(this).initLoader(0, arguments, this)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
......
......@@ -10,7 +10,6 @@ package at.bitfire.icsdroid.ui
import android.Manifest
import android.annotation.SuppressLint
import android.arch.lifecycle.Observer
import android.content.*
import android.content.pm.PackageManager
import android.database.ContentObserver
......@@ -19,28 +18,33 @@ import android.os.Bundle
import android.os.PowerManager
import android.provider.CalendarContract
import android.provider.Settings
import android.support.design.widget.Snackbar
import android.support.v4.app.ActivityCompat
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.LoaderManager
import android.support.v4.content.Loader
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.*
import android.widget.AdapterView
import android.widget.ArrayAdapter
import androidx.work.State
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import androidx.loader.app.LoaderManager
import androidx.loader.content.Loader
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.work.WorkInfo
import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.icsdroid.*
import at.bitfire.icsdroid.db.LocalCalendar
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.calendar_list_activity.*
import kotlinx.android.synthetic.main.calendar_list_item.view.*
import java.text.DateFormat
import java.util.*
class CalendarListActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<List<LocalCalendar>>, AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener {
class CalendarListActivity:
AppCompatActivity(),
LoaderManager.LoaderCallbacks<List<LocalCalendar>>,
AdapterView.OnItemClickListener,
SwipeRefreshLayout.OnRefreshListener {
private var listAdapter: CalendarListAdapter? = null
......@@ -70,7 +74,7 @@ class CalendarListActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<L
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED)
supportLoaderManager.initLoader(0, null, this)
LoaderManager.getInstance(this).initLoader(0, null, this)
else
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR), 0)
......@@ -82,7 +86,7 @@ class CalendarListActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<L
}, false)
SyncWorker.liveStatus().observe(this, Observer { statuses ->
val running = statuses?.any { it.state == State.RUNNING } ?: false
val running = statuses.any { it.state == WorkInfo.State.RUNNING } ?: false
Log.d(Constants.TAG, "Sync running: $running")
refresh.isRefreshing = running
})
......@@ -213,7 +217,7 @@ class CalendarListActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<L
val v = convertView ?:
LayoutInflater.from(context).inflate(R.layout.calendar_list_item, parent, false)
val calendar = getItem(position)
val calendar = getItem(position)!!
v.url.text = calendar.url
v.title.text = calendar.displayName
......
......@@ -9,13 +9,13 @@
package at.bitfire.icsdroid.ui
import android.os.Bundle
import android.support.v4.app.Fragment
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CompoundButton
import androidx.fragment.app.Fragment
import at.bitfire.icsdroid.R
import kotlinx.android.synthetic.main.credentials.view.*
import org.apache.commons.lang3.StringUtils
......
......@@ -10,8 +10,8 @@ package at.bitfire.icsdroid.ui;
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import at.bitfire.icsdroid.Constants
import at.bitfire.icsdroid.R
......
......@@ -19,14 +19,18 @@ import android.database.ContentObserver
import android.net.Uri
import android.os.Bundle
import android.provider.CalendarContract
import android.support.v4.app.*
import android.support.v4.content.Loader
import android.support.v7.app.AlertDialog
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.app.ShareCompat
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentTransaction
import androidx.loader.app.LoaderManager
import androidx.loader.content.Loader
import at.bitfire.ical4android.CalendarStorageException
import at.bitfire.icsdroid.AppAccount
import at.bitfire.icsdroid.Constants
......@@ -64,7 +68,7 @@ class EditCalendarActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<L
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED)
// load calendar from provider
supportLoaderManager.initLoader(0, null, this)
LoaderManager.getInstance(this).initLoader(0, null, this)
else
finish()
}
......@@ -183,7 +187,7 @@ class EditCalendarActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<L
/* loader callbacks */
override fun onCreateLoader(id: Int, args: Bundle?) =
CalendarLoader(this, intent.data)
CalendarLoader(this, intent.data!!)
override fun onLoadFinished(loader: Loader<LocalCalendar>, calendar: LocalCalendar?) {
if (calendar == null)
......@@ -249,7 +253,9 @@ class EditCalendarActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<L
context: Context,
private val uri: Uri
): Loader<LocalCalendar>(context) {
val TAG = "ICSdroid.Calendar"
companion object {
const val TAG = "ICSdroid.Calendar"
}
private var loaded = false
......
......@@ -13,18 +13,18 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.app.LoaderManager
import android.support.v4.content.AsyncTaskLoader
import android.support.v4.content.Loader
import android.support.v7.app.AppCompatActivity
import android.text.Html
import android.text.Spanned
import android.text.util.Linkify
import android.util.Log
import android.view.*
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import androidx.loader.app.LoaderManager
import androidx.loader.content.AsyncTaskLoader
import androidx.loader.content.Loader
import at.bitfire.icsdroid.BuildConfig
import at.bitfire.icsdroid.Constants
import at.bitfire.icsdroid.R
......@@ -113,13 +113,13 @@ class InfoActivity: AppCompatActivity() {
// load and format license text
val args = Bundle(1)
args.putString(KEY_LICENSE_FILE, "license/${info[4]}")
loaderManager.initLoader(0, args, this)
LoaderManager.getInstance(this).initLoader(0, args, this)
return v
}
override fun onCreateLoader(id: Int, args: Bundle?) =
LicenseLoader(requireActivity(), args!!.getString(KEY_LICENSE_FILE))
LicenseLoader(requireActivity(), args!!.getString(KEY_LICENSE_FILE)!!)
override fun onLoadFinished(loader: Loader<Spanned?>, text: Spanned?) {
text?.let {
......@@ -152,7 +152,7 @@ class InfoActivity: AppCompatActivity() {
override fun loadInBackground(): Spanned? {
try {
context.resources.assets.open(fileName)?.use {
context.resources.assets.open(fileName).use {
val html = IOUtils.toString(it, StandardCharsets.UTF_8)
text = Html.fromHtml(html)
return text
......
......@@ -12,7 +12,7 @@ import android.annotation.SuppressLint
import android.app.AlertDialog
import android.app.Dialog
import android.os.Bundle
import android.support.v4.app.DialogFragment
import androidx.fragment.app.DialogFragment
import at.bitfire.icsdroid.AppAccount
import at.bitfire.icsdroid.R
import kotlinx.android.synthetic.main.set_sync_interval.view.*
......
......@@ -9,7 +9,7 @@
package at.bitfire.icsdroid.ui
import android.os.Bundle
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
......
......@@ -11,35 +11,35 @@
~ PURPOSE. See the GNU General Public License for more details.
-->
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
<android.support.design.widget.TabLayout
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
app:tabMode="scrollable"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout >
<android.support.v4.view.ViewPager
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
......@@ -10,14 +10,14 @@
~ PURPOSE. See the GNU General Public License for more details.
-->
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -28,7 +28,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.SwipeRefreshLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<TextView
android:id="@+id/emptyInfo"
......@@ -39,12 +39,13 @@
android:layout_margin="16dp"
android:text="@string/calendar_list_empty_info"/>
<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:focusable="true"
android:src="@drawable/ic_add"
app:layout_anchor="@id/calendar_list"
app:layout_anchorGravity="bottom|right|end"
......@@ -52,4 +53,4 @@
app:elevation="5dp"
app:borderWidth="0dp"/>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -24,7 +24,7 @@
android:text="@string/add_calendar_title"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"/>
<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
......@@ -68,6 +68,6 @@
tools:ignore="RtlHardcoded"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>
</LinearLayout>
\ No newline at end of file
......@@ -48,16 +48,16 @@
android:visibility="gone"
android:id="@+id/password_label"/>
<android.support.design.widget.TextInputLayout
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:maxLines="1" />
</android.support.design.widget.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
\ No newline at end of file
......@@ -7,14 +7,14 @@
*/
buildscript {
ext.kotlin_version = '1.2.70'
ext.kotlin_version = '1.3.10'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
......
Subproject commit 9817b3ca6f7247d9c9552510aed247c17070dfe6
Subproject commit 4fac9b14bc4e35fd317bcb75ae5e7f39c22b3c75
org.gradle.configureondemand=false
android.useAndroidX=true
# remove this as soon as android.arch.work uses AndroidX LifeCycle
android.enableJetifier=true
Subproject commit ae363b6ee2eb9216d2ed04c453c82efd44daa525
Subproject commit 913105c5f33528b64b34ad4273050d149c750234
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment