Skip to content

Commit

Permalink
docs: Move Documentation to docs.page (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
ABausG authored Aug 28, 2024
1 parent f23c63e commit 52ee746
Show file tree
Hide file tree
Showing 29 changed files with 1,273 additions and 657 deletions.
18 changes: 18 additions & 0 deletions .github/.cspell/names_dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# specific people's names and/or usernames
mchudy # github.com/mchudy
milindgoel15 # github.com/milindgoel15
mattrltrent # github.com/mattrltrent
eliasto # github.com/eliasto
leighajarett # github.com/leighajarett
ColinSchmale # github.com/ColinSchmale
linziyou # github.com/linziyou0601
roly # github.com/roly151
aaronkelton # github.com/aaronkelton
hadysata # github.com/hadysata
Verbeeck # github.com/NicolaVerbeeck
ronnieeeeee # github.com/ronnieeeeee
josepedromonteiro # github.com/josepedromonteiro
stepushchik # github.com/stepushchik-denis-gismart
gismart # github.com/stepushchik-denis-gismart
aljkor # github.com/aljkor
mgonzalezc # github.com/mgonzalezc
66 changes: 66 additions & 0 deletions .github/cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: "0.2"
ignorePaths:
[
"**/coverage",
"**/*.xcscheme",
"**/*.storyboard",
"**/GeneratedPluginRegistrant.m",
"**/GeneratedPluginRegistrant.java",
"**/*.pbxproj",
"**/*.xcconfig",
"**/**/*.podspec",
"**/Info.plist",
"**/*.xcassets",
"**/*.xcworkspace",
"**/*.xcodeproj",
"**/Pods/Target Support Files/",
"**/Pods/Local Podspecs",
"**/gradlew",
"**/gradlew.bat",
"**/gradle-wrapper.properties",
"**/AppFrameworkInfo.plist",
"**/gradle.properties",
"cspell.yaml",
"**/build.gradle",
"**/proguard-rules.pro",
]
dictionaries:
- names
dictionaryDefinitions:
- name: names
path: .cspell/names_dictionary.txt
words:
- antonborries
- Borries
- abausg
- antonborri
- mocktail
- Goldens
- cupertino
- workmanager
- cocoapods
- renderview
- appex
- pinability
- chào
- titleclicked
- NSURL
- xcconfig
- podhelper
- podfile
- realpath
- appwidget
- Millis # abbreviation for Milliseconds
- androidx
- Jetpack
- kotlinx
- lateinit
- prefs # short for preferences
- mipmap # android image format
- nullsafety
- Deeplinks
- Deque
- ktfmt
- libexec
- SRCROOT
- Codelab
17 changes: 17 additions & 0 deletions .github/workflows/spellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Spellcheck

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: streetsidesoftware/cspell-action@v6
with:
config: .github/cspell.yaml
95 changes: 95 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"name": "home_widget",
"theme": "##567acb",
"twitter": "abausg",
"sidebar": [
[
"Overview",
"/"
],
[
"Usage",
[
[
"Sync Data",
"/usage/sync-data"
],
[
"Update Widget",
"/usage/update-widget"
]
]
],
[
"Platform Setup",
[
[
"iOS",
"/setup/ios"
],
[
"Android",
"/setup/android"
]
]
],
[
"Features",
[
[
"Render Flutter Widgets",
"/features/render-flutter-widgets"
],
[
"Interactive Widgets",
"/features/interactive-widgets"
],
[
"Detect Clicks",
"/features/detect-clicks"
],
[
"Analytics",
"/features/analytics"
],
[
"iOS Lock Screen Widgets",
"/features/ios-lock-screen"
],
[
"Pin Widget (Android)",
"/features/pin-widget"
],
[
"Background Updates",
"/features/background-updates"
]
]
],
[
"Android XML",
[
[
"Overview",
"/android-xml/overview"
],
[
"Setup",
"/android-xml/setup"
],
[
"Render Flutter Widgets",
"/android-xml/render-flutter-widgets"
],
[
"Interactive Widgets",
"/android-xml/interactive-widgets"
],
[
"Detect Clicks",
"/android-xml/detect-clicks"
]
]
]
]
}
22 changes: 22 additions & 0 deletions docs/android-xml/detect-clicks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Detect Clicks
description: Detecting Clicks on Android Widgets
---

# Detect Clicks on with Android XML Widgets

Add an `IntentFilter` to the `Activity` Section in your `AndroidManifest`
```
<intent-filter>
<action android:name="es.antonborri.home_widget.action.LAUNCH" />
</intent-filter>
```

In your WidgetProvider add a PendingIntent to your View using `HomeWidgetLaunchIntent.getActivity`
```kotlin
val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
context,
MainActivity::class.java,
Uri.parse("homeWidgetExample://message?message=$message"))
setOnClickPendingIntent(R.id.widget_message, pendingIntentWithData)
```
27 changes: 27 additions & 0 deletions docs/android-xml/interactive-widgets.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Interactive Widgets
description: How to create interactive Widgets with home_widget and Android XML Widgets
---

# Interactive Widgets

Follow the necessary steps to set up everything on the Flutter Side as described [here](/features/interactive-widgets#flutter-setup).

1. Add the necessary Receiver and Service to your `AndroidManifest.xml` file
```
<receiver android:name="es.antonborri.home_widget.HomeWidgetBackgroundReceiver" android:exported="true">
<intent-filter>
<action android:name="es.antonborri.home_widget.action.BACKGROUND" />
</intent-filter>
</receiver>
<service android:name="es.antonborri.home_widget.HomeWidgetBackgroundService"
android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"/>
```
2. Add a `HomeWidgetBackgroundIntent.getBroadcast` PendingIntent to the View you want to add a click listener to
```kotlin
val backgroundIntent = HomeWidgetBackgroundIntent.getBroadcast(
context,
Uri.parse("homeWidgetExample://titleClicked")
)
setOnClickPendingIntent(R.id.widget_title, backgroundIntent)
```
12 changes: 12 additions & 0 deletions docs/android-xml/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Android XML
description: home_widget and Android XML Widgets
---

# Android XML Support

home_widget supports Android Widgets created with XML. This allows you to create Widgets for your Android App using the home_widget Plugin.
However going forward it is recommended to use the [Jetpack Glance](/setup/android) way to create Widgets home_widget.

In the following pages you can still find information on how to use respective Features of home_widget with Android XML Widgets.

58 changes: 58 additions & 0 deletions docs/android-xml/render-flutter-widget.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Render Flutter Widget
description: Render Flutter Widgets in Android XML Widgets
---

# Render Flutter Widgets

1. Add an image UI element to your xml file:
```xml
<ImageView
android:id="@+id/widget_image"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="@+id/headline_description"
android:layout_alignBottom="@+id/headline_title"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="-134dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="@android:color/white"
android:scaleType="fitCenter"
android:src="@android:drawable/star_big_on"
android:visibility="visible"
tools:visibility="visible" />
```
2. Update your Kotlin code to get the chart image and put it into the widget, if it exists.
```kotlin
class NewsWidget : AppWidgetProvider() {
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray,
) {
for (appWidgetId in appWidgetIds) {
// Get reference to SharedPreferences
val widgetData = HomeWidgetPlugin.getData(context)
val views = RemoteViews(context.packageName, R.layout.news_widget).apply {
// Get chart image and put it in the widget, if it exists
val imagePath = widgetData.getString("lineChart", null)
val imageFile = File(imagePath)
val imageExists = imageFile.exists()
if (imageExists) {
val myBitmap: Bitmap = BitmapFactory.decodeFile(imageFile.absolutePath)
setImageViewBitmap(R.id.widget_image, myBitmap)
} else {
println("image not found!, looked @: $imagePath")
}
// End new code
}
appWidgetManager.updateAppWidget(appWidgetId, views)
}
}
}
```
Loading

0 comments on commit 52ee746

Please sign in to comment.