When I was trying to solve the integral $\int\frac{\sin x+\cos x}{\sqrt{1+\sin2x}}dx$ by using $(1+\sin2x)=(\sin x+\cos x)^2$, I obtained this integral $\int\frac{\sin x+\cos x}{|\sin x+\cos x|}dx$ where $|\cdot|$ is the absolute value function. If this problem were a definite integral then I would have simplified the denominator by removing the absolute value function. But here it's an indefinite integral. So, how to proceed further?
In my book, the integral $\int\frac{\sin x+\cos x}{\sqrt{1+\sin2x}}dx$ was solved by expressing the denominator of the integrand as $\sqrt{2-(\sin x-\cos x)^2}$ and then using the method of substitution $t=(\sin x-\cos x)$, $dt=(\sin x+\cos x)dx$ and so on. I totally understood this method but I'm interested in solving the integral $\int\frac{\sin x+\cos x}{|\sin x+\cos x|}dx$ to obtain the final result.
The final result obtained by the method outlined in the book is $\sin^{-1}\sin(x-\pi/4)+C$. It would be helpful if you could explain how to obtain this result by evaluating the integral in the question.
I'll convert my comment into an answer with more details.
One can have $$\int\frac{\sin x+\cos x}{|\sin x+\cos x|}dx=x\times\frac{\sin x+\cos x}{|\sin x+\cos x|}+C$$
You've written the following as an answer : $$\int\frac{\sin x+\cos x}{|\sin x+\cos x|}dx=\sin^{-1}\bigg(\sin\bigg(x-\frac{\pi}{4}\bigg)\bigg)+C$$
For $m\in\mathbb Z$, we have $$\begin{align}&x\times\frac{\sin x+\cos x}{|\sin x+\cos x|} \\\\&=\begin{cases}x&\text{if $\quad\sin x+\cos x\gt 0$}\\ -x&\text{if $\quad\sin x+\cos x\lt 0$}\end{cases} \\\\&=\begin{cases}x&\text{if $\quad 2m\pi-\frac{\pi}{4}\lt x\lt 2m\pi+\frac{3}{4}\pi$}\\ -x&\text{if $\quad 2m\pi-\frac{5}{4}\pi\lt x\lt 2m\pi -\frac{\pi}{4}$}\end{cases} \\\\&=\begin{cases}(x-\frac{\pi}{4})-2m\pi+\frac{\pi}{4}+2m\pi&\text{if $\quad 2m\pi-\frac{\pi}{4}\lt x\lt 2m\pi+\frac{3}{4}\pi$}\\ -(x-\frac{\pi}{4})+(2m-1)\pi-\frac{\pi}{4}-(2m-1)\pi&\text{if $\quad 2m\pi-\frac{5}{4}\pi\lt x\lt 2m\pi -\frac{\pi}{4}$}\end{cases} \\\\&=\begin{cases}\sin^{-1}(\sin(x-\frac{\pi}{4}))+\frac{\pi}{4}+2m\pi&\text{if $\quad 2m\pi-\frac{\pi}{4}\lt x\lt 2m\pi+\frac{3}{4}\pi$}\\ \sin^{-1}(\sin(x-\frac{\pi}{4}))-\frac{\pi}{4}-(2m-1)\pi&\text{if $\quad 2m\pi-\frac{5}{4}\pi\lt x\lt 2m\pi -\frac{\pi}{4}$}\end{cases} \\\\&=\sin^{-1}\bigg(\sin\bigg(x-\frac{\pi}{4}\bigg)\bigg)+(\text{constant})\end{align}$$