This repository was archived by the owner on Sep 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link 'Show Taps' option in settings to developer options, resolves #37
- Loading branch information
1 parent
9d111ce
commit 2c0dd60
Showing
10 changed files
with
137 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
common/src/main/java/com/afollestad/mnmlscreenrecord/common/intent/UrlLauncher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Designed and developed by Aidan Follestad (@afollestad) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.afollestad.mnmlscreenrecord.common.intent | ||
|
||
import android.app.Activity | ||
import android.content.ActivityNotFoundException | ||
import android.content.Intent | ||
import android.content.Intent.ACTION_VIEW | ||
import androidx.annotation.AttrRes | ||
import androidx.browser.customtabs.CustomTabsIntent | ||
import com.afollestad.mnmlscreenrecord.common.R | ||
import com.afollestad.mnmlscreenrecord.common.misc.toUri | ||
|
||
/** @author Aidan Follestad (@afollestad) */ | ||
interface UrlLauncher { | ||
fun viewUrl(url: String) | ||
} | ||
|
||
class RealUrlLauncher( | ||
private val currentActivity: Activity | ||
) : UrlLauncher { | ||
|
||
override fun viewUrl(url: String) { | ||
val customTabsIntent = CustomTabsIntent.Builder() | ||
.setToolbarColor(resolveColor(R.attr.colorPrimary)) | ||
.build() | ||
try { | ||
customTabsIntent.launchUrl(currentActivity, url.toUri()) | ||
} catch (_: ActivityNotFoundException) { | ||
val chooser = Intent.createChooser( | ||
Intent(ACTION_VIEW) | ||
.setData(url.toUri()), "View URL" | ||
) | ||
currentActivity.startActivity(chooser) | ||
} | ||
} | ||
|
||
private fun resolveColor(@AttrRes attr: Int): Int { | ||
val a = currentActivity.theme.obtainStyledAttributes(intArrayOf(attr)) | ||
try { | ||
return a.getColor(0, 0) | ||
} finally { | ||
a.recycle() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters