mirror of https://github.com/Xe/xesite_android
user-agent attribution fun times
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
c4f70c465e
commit
fa86abe59a
|
@ -17,6 +17,12 @@ import com.android.volley.toolbox.HurlStack
|
||||||
class NewPostWidget : AppWidgetProvider() {
|
class NewPostWidget : AppWidgetProvider() {
|
||||||
private lateinit var requestQueue: RequestQueue
|
private lateinit var requestQueue: RequestQueue
|
||||||
|
|
||||||
|
private fun userAgent(ctx: Context): String {
|
||||||
|
val pkgInfo = ctx.getPackageManager().getPackageInfo(ctx.packageName, 0)
|
||||||
|
|
||||||
|
return ctx.packageName.plus("/").plus(pkgInfo.versionName)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onUpdate(
|
override fun onUpdate(
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
appWidgetManager: AppWidgetManager,
|
appWidgetManager: AppWidgetManager,
|
||||||
|
@ -24,10 +30,13 @@ class NewPostWidget : AppWidgetProvider() {
|
||||||
) {
|
) {
|
||||||
val url = "https://christine.website/.within/website.within.xesite/new_post"
|
val url = "https://christine.website/.within/website.within.xesite/new_post"
|
||||||
|
|
||||||
|
val headers: MutableMap<String, String> = mutableMapOf()
|
||||||
|
headers.put("User-Agent", this.userAgent(ctx));
|
||||||
|
|
||||||
val jor: GsonGetRequest<NewPost> = GsonGetRequest(
|
val jor: GsonGetRequest<NewPost> = GsonGetRequest(
|
||||||
url,
|
url,
|
||||||
NewPost::class.java,
|
NewPost::class.java,
|
||||||
null,
|
headers,
|
||||||
Response.Listener<NewPost> { response ->
|
Response.Listener<NewPost> { response ->
|
||||||
Log.println(Log.INFO, "new_post", response.toString())
|
Log.println(Log.INFO, "new_post", response.toString())
|
||||||
// There may be multiple widgets active, so update all of them
|
// There may be multiple widgets active, so update all of them
|
||||||
|
|
Loading…
Reference in New Issue