-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android 15 Support - Part 2 of 2 #2624
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:id="@+id/sf__status_bar_background" android:height="100dp" > | ||
<shape android:shape="rectangle"> | ||
<size android:height="100dp" android:width="100dp"/> | ||
<solid android:color="@color/sf__primary_color"/> | ||
</shape> | ||
</item> | ||
|
||
<item android:id="@+id/sf__nav_bar_background" android:height="100dp"> | ||
<shape android:shape="rectangle"> | ||
<size android:height="100dp" android:width="100dp"/> | ||
<solid android:color="@android:color/transparent"/> | ||
</shape> | ||
</item> | ||
</layer-list> | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,6 @@ internal class IDPManager( | |
spConfig, | ||
codeChallenge | ||
) { result -> | ||
authCodeActivity.finish() | ||
onResult(result) | ||
} | ||
} | ||
|
@@ -214,6 +213,7 @@ internal class IDPManager( | |
addCategory(Intent.CATEGORY_DEFAULT) | ||
} | ||
startActivity(activeFlow.context, launchIntent) | ||
activeFlow.authCodeActivity?.finish() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The IDP fix. |
||
} else { | ||
activeFlow.onStatusUpdate(Status.ERROR_RECEIVED_FROM_SP) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.salesforce.androidsdk.ui | ||
|
||
import android.graphics.drawable.LayerDrawable | ||
import android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE | ||
import android.view.View | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.res.ResourcesCompat | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import androidx.core.view.updatePadding | ||
import com.salesforce.androidsdk.R.drawable.sf__fix_status_bar | ||
import com.salesforce.androidsdk.R.id.sf__status_bar_background | ||
|
||
// TODO: Remove this in 13.0 after rewriting screens in compose. | ||
internal fun AppCompatActivity.fixEdgeToEdge(view: View) { | ||
if (application.applicationInfo.targetSdkVersion > UPSIDE_DOWN_CAKE) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should actually check this and |
||
enableEdgeToEdge() | ||
ViewCompat.setOnApplyWindowInsetsListener(view) { listenerView, windowInsets -> | ||
val insets = windowInsets.getInsets( | ||
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout() | ||
) | ||
|
||
// Fix screens being drawn behind status and navigation bars | ||
listenerView.updatePadding(insets.left, insets.top, insets.right, insets.bottom) | ||
|
||
// Fix transparent status bar not matching action bar | ||
val background = ResourcesCompat.getDrawable(resources, sf__fix_status_bar, null) | ||
wmathurin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val statusBarFiller = (background as LayerDrawable).findDrawableByLayerId(sf__status_bar_background) | ||
statusBarFiller.setBounds(0, 0, insets.right, insets.bottom) | ||
view.setBackgroundResource(sf__fix_status_bar) | ||
wmathurin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
WindowInsetsCompat.CONSUMED | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where all of UX magic happens 🪄 ✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sort of a hack to fill in the status and navigation bars with the appropriate color since they are now forced transparent and completely unsettable in Edge to Edge. Note that I am changing the height of the top rectangle to match the device status bar height in code!