Target SDK 30

This commit is contained in:
Sylvain Berfini 2020-08-21 10:40:27 +02:00
parent 7ee8ba34b0
commit d611d20cfd
11 changed files with 94 additions and 26 deletions

View file

@ -2,7 +2,7 @@ job-android:
stage: build
tags: [ "docker-android" ]
image: gitlab.linphone.org:4567/bc/public/linphone-android/bc-dev-android:29
image: gitlab.linphone.org:4567/bc/public/linphone-android/bc-dev-android:30
before_script:
- if ! [ -z ${SCP_PRIVATE_KEY+x} ]; then eval $(ssh-agent -s); fi

View file

@ -53,8 +53,8 @@ project.tasks['preBuild'].dependsOn 'getGitVersion'
project.tasks['preBuild'].dependsOn 'linphoneSdkSource'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion 30
buildToolsVersion '30.0.2'
defaultConfig {
minSdkVersion 23
targetSdkVersion 29

View file

@ -119,7 +119,7 @@ class ChatRoomsListViewModel : ErrorReportingViewModel() {
chatRoomsToDeleteCount = 1
if (chatRoom != null) {
coreContext.notificationsManager.dismissChatNotification(chatRoom)
Compatibility.removeChatRoomShortcut(chatRoom)
Compatibility.removeChatRoomShortcut(coreContext.context, chatRoom)
chatRoom.addListener(chatRoomListener)
coreContext.core.deleteChatRoom(chatRoom)
}
@ -133,7 +133,7 @@ class ChatRoomsListViewModel : ErrorReportingViewModel() {
}
coreContext.notificationsManager.dismissChatNotification(chatRoom)
Compatibility.removeChatRoomShortcut(chatRoom)
Compatibility.removeChatRoomShortcut(coreContext.context, chatRoom)
chatRoom.addListener(chatRoomListener)
chatRoom.core.deleteChatRoom(chatRoom)
}

View file

@ -12,7 +12,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.R
class SyncAccountAdapter : BaseAdapter() {
private var accounts: ArrayList<Triple<String, String, Drawable>> = arrayListOf()
private var accounts: ArrayList<Triple<String, String, Drawable?>> = arrayListOf()
init {
accounts.addAll(coreContext.contactsManager.getAvailableSyncAccounts())
@ -30,7 +30,7 @@ class SyncAccountAdapter : BaseAdapter() {
return view
}
override fun getItem(position: Int): Triple<String, String, Drawable> {
override fun getItem(position: Int): Triple<String, String, Drawable?> {
return accounts[position]
}

View file

@ -137,19 +137,19 @@ class RecordingViewModel(val path: String) : ViewModel(), Comparable<RecordingVi
} else {
textureView.surfaceTextureListener = object : TextureView.SurfaceTextureListener {
override fun onSurfaceTextureSizeChanged(
surface: SurfaceTexture?,
surface: SurfaceTexture,
width: Int,
height: Int
) { }
override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) { }
override fun onSurfaceTextureUpdated(surface: SurfaceTexture) { }
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture?): Boolean {
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture): Boolean {
return true
}
override fun onSurfaceTextureAvailable(
surface: SurfaceTexture?,
surface: SurfaceTexture,
width: Int,
height: Int
) {

View file

@ -137,8 +137,10 @@ class Compatibility {
}
}
fun removeChatRoomShortcut(chatRoom: ChatRoom) {
// TODO Use removeLongLivedShortcuts() starting Android R (API 30)
fun removeChatRoomShortcut(context: Context, chatRoom: ChatRoom) {
if (Version.sdkAboveOrEqual(Version.API30_ANDROID_11)) {
// TODO Use removeLongLivedShortcuts()
}
}
suspend fun addImageToMediaStore(context: Context, content: Content): Boolean {

View file

@ -276,12 +276,12 @@ class ContactsManager(private val context: Context) {
}
}
fun getAvailableSyncAccounts(): List<Triple<String, String, Drawable>> {
fun getAvailableSyncAccounts(): List<Triple<String, String, Drawable?>> {
val accountManager = context.getSystemService(Context.ACCOUNT_SERVICE) as AccountManager
val packageManager = context.packageManager
val syncAdapters = ContentResolver.getSyncAdapterTypes()
val authenticators: Array<AuthenticatorDescription> = accountManager.authenticatorTypes
val available = arrayListOf<Triple<String, String, Drawable>>()
val available = arrayListOf<Triple<String, String, Drawable?>>()
for (syncAdapter in syncAdapters) {
if (syncAdapter.authority == "com.android.contacts" && syncAdapter.isUserVisible) {

View file

@ -47,14 +47,23 @@ class NativeContactEditor(val contact: NativeContact) {
val contentResolver = coreContext.context.contentResolver
val results = contentResolver.applyBatch(ContactsContract.AUTHORITY, changes)
for (result in results) {
Log.i("[Native Contact Editor] Contact creation result is ${result.uri}")
val cursor = contentResolver.query(result.uri, arrayOf(RawContacts.CONTACT_ID), null, null, null)
if (cursor != null) {
cursor.moveToNext()
val contactId: Long = cursor.getLong(0)
Log.i("[Native Contact Editor] New contact id is $contactId")
cursor.close()
return contactId
val uri = result.uri
Log.i("[Native Contact Editor] Contact creation result is $uri")
if (uri != null) {
val cursor = contentResolver.query(
uri,
arrayOf(RawContacts.CONTACT_ID),
null,
null,
null
)
if (cursor != null) {
cursor.moveToNext()
val contactId: Long = cursor.getLong(0)
Log.i("[Native Contact Editor] New contact id is $contactId")
cursor.close()
return contactId
}
}
}
@ -301,9 +310,10 @@ class NativeContactEditor(val contact: NativeContact) {
val contentResolver = coreContext.context.contentResolver
val results = contentResolver.applyBatch(ContactsContract.AUTHORITY, changes)
for (result in results) {
Log.i("[Native Contact Editor] Result is ${result.uri}")
if (updateSyncAccountRawId && syncAccountRawId == null && result?.uri != null) {
syncAccountRawId = ContentUris.parseId(result.uri).toString()
val uri = result.uri
Log.i("[Native Contact Editor] Result is $uri")
if (uri != null && updateSyncAccountRawId && syncAccountRawId == null) {
syncAccountRawId = ContentUris.parseId(uri).toString()
Log.i("[Native Contact Editor] Sync account raw id is $syncAccountRawId")
}
}

View file

@ -47,6 +47,10 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
return
}
if (localIdentity == null) {
Log.e("[Notification Broadcast Receiver] Local identity is null for notification id $notificationId")
return
}
val localAddress = core.interpretUrl(localIdentity)
if (localAddress == null) {
Log.e("[Notification Broadcast Receiver] Couldn't interpret local address $localIdentity")

View file

@ -54,6 +54,7 @@
glideAvatarFallback="@{viewModel.defaultAccountAvatar}" />
<ImageView
android:visibility="@{viewModel.defaultAccountFound ? View.VISIBLE : View.GONE}"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:adjustViewBounds="true"
@ -74,6 +75,7 @@
android:textColor="?attr/lightToolbarTextColor"
android:textStyle="bold"
android:textSize="18sp"
android:padding="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

View file

@ -0,0 +1,50 @@
FROM debian:stretch
MAINTAINER Ghislain MARY <ghislain.mary@belledonne-communications.com>
# Configure locale
RUN apt-get update && \
apt-get install -y locales && \
apt-get clean && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
ENV SHELL=/bin/bash
# Define environment
ENV ANDROID_SDK 25.2.5
ENV ANDROID_HOME /opt/android-sdk-linux
# Install common general tools
RUN apt-get update && \
apt-get install -y curl nano sudo unzip vim wget openjdk-8-jdk-headless rsync ssh git && \
apt-get clean
# Get the Android tools
RUN wget https://dl.google.com/android/repository/tools_r$ANDROID_SDK-linux.zip && \
unzip tools_r$ANDROID_SDK-linux.zip -d $ANDROID_HOME && \
rm -f tools_r$ANDROID_SDK-linux.zip
ENV PATH $ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH
# Get the Android SDK
RUN echo "y" | sdkmanager "platforms;android-30" "build-tools;30.0.2" "extras;android;m2repository" "extras;google;m2repository" "platform-tools" "tools"
# Accept Android SDK licenses
RUN yes | sdkmanager --licenses
# Update if needed
RUN echo y | android update sdk --no-ui --all --filter platform-tools
RUN echo y | android update sdk --no-ui --all --filter android-30
RUN echo y | android update sdk --no-ui --all --filter build-tools-30.0.2
# Configure user bc
RUN useradd -ms /bin/bash bc && \
echo 'bc:cotcot' | chpasswd && \
echo 'bc ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER bc
WORKDIR /home/bc
ENV PS1='\[\e[34m\]\u@bc-dev-android>\[\e[0m\] '
CMD bash