-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from amardeshbd/develop
Tagging for release 1.1
- Loading branch information
Showing
27 changed files
with
975 additions
and
75 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
27 changes: 27 additions & 0 deletions
27
example/src/main/java/dev/hossain/yaash/example/ui/MainActivity.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,27 @@ | ||
package dev.hossain.yaash.example.ui | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.widget.Button | ||
import androidx.appcompat.app.AppCompatActivity | ||
import dev.hossain.yaash.example.R | ||
import dev.hossain.yaash.example.ui.demohighlightjs.HighlightJsDemoActivity | ||
import dev.hossain.yaash.example.ui.demoprismjs.PrismJsDemoActivity | ||
|
||
/** | ||
* Main activity to showcase both fragment based and custom view based syntax highlighting. | ||
*/ | ||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
findViewById<Button>(R.id.highlightjs_demo_button).setOnClickListener { | ||
startActivity(Intent(this, HighlightJsDemoActivity::class.java)) | ||
} | ||
|
||
findViewById<Button>(R.id.prismjs_demo_button).setOnClickListener { | ||
startActivity(Intent(this, PrismJsDemoActivity::class.java)) | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
example/src/main/java/dev/hossain/yaash/example/ui/common/IntentAction.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,30 @@ | ||
package dev.hossain.yaash.example.ui.common | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.widget.Toast | ||
import timber.log.Timber | ||
|
||
object IntentAction { | ||
/** | ||
* Loads an external web URL. | ||
* https://developer.android.com/guide/components/intents-common#ViewUrl | ||
*/ | ||
fun openWebPage(context: Context, url: String) { | ||
val webPage: Uri = Uri.parse(url) | ||
val intent = Intent(Intent.ACTION_VIEW, webPage) | ||
if (intent.resolveActivity(context.packageManager) != null) { | ||
context.startActivity(intent) | ||
} else { | ||
Timber.w("Unable to find any app that can open web URL") | ||
|
||
// Instead of keeping user in dark, show them feedback about the issue. | ||
Toast.makeText( | ||
context, | ||
"Ops! We're unable to open the URL as we can't find default browser app :-(", | ||
Toast.LENGTH_SHORT | ||
).show() | ||
} | ||
} | ||
} |
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
Oops, something went wrong.