mirror of https://github.com/Xe/xesite_android
1.1.1.1
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
ea7c18723f
commit
c57c41ade0
|
@ -52,10 +52,10 @@ android {
|
|||
compileSdkVersion 29
|
||||
defaultConfig {
|
||||
applicationId "website.christine.xesite"
|
||||
minSdkVersion 19
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 6
|
||||
versionName "1.1.0.0"
|
||||
versionCode 8
|
||||
versionName "1.1.1.1"
|
||||
|
||||
// The name for the application
|
||||
resValue "string", "appName", twaManifest.name
|
||||
|
@ -153,6 +153,9 @@ android {
|
|||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
task generateShorcutsFile {
|
||||
|
@ -203,4 +206,9 @@ dependencies {
|
|||
implementation 'com.google.code.gson:gson:2.8.7'
|
||||
implementation 'com.google.androidbrowserhelper:locationdelegation:1.0.0'
|
||||
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.2.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
android:manageSpaceActivity="com.google.androidbrowserhelper.trusted.ManageDataLauncherActivity"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
|
||||
<receiver android:name=".NewPostWidget">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
|
@ -94,7 +95,7 @@
|
|||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data
|
||||
android:host="@string/hostName"
|
||||
android:host="christine.website"
|
||||
android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
|
|
@ -49,4 +49,3 @@ class Application : Application() {
|
|||
|
||||
internal val NEW_POST_CHANNEL = "New Posts";
|
||||
internal val NEW_POST_CHANNEL_DESC = "New posts on christine.website";
|
||||
internal val notificationId = 1;
|
|
@ -15,13 +15,6 @@
|
|||
*/
|
||||
package website.christine.xesite
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.google.androidbrowserhelper.trusted.LauncherActivity
|
||||
|
||||
class LauncherActivity : LauncherActivity() {
|
||||
override fun getLaunchingUrl(): Uri {
|
||||
// Get the original launch Url.
|
||||
return super.getLaunchingUrl()
|
||||
}
|
||||
}
|
||||
class LauncherActivity : LauncherActivity() {}
|
|
@ -1,11 +1,11 @@
|
|||
package website.christine.xesite
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.widget.RemoteViews
|
||||
import androidx.core.app.NotificationCompat
|
||||
|
@ -15,6 +15,7 @@ import com.android.volley.Response
|
|||
import com.android.volley.toolbox.BasicNetwork
|
||||
import com.android.volley.toolbox.DiskBasedCache
|
||||
import com.android.volley.toolbox.HurlStack
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
|
||||
/**
|
||||
* Implementation of App Widget functionality.
|
||||
|
@ -26,17 +27,22 @@ class NewPostWidget : AppWidgetProvider() {
|
|||
val pkgInfo = ctx.getPackageManager().getPackageInfo(ctx.packageName, 0)
|
||||
|
||||
return ctx.packageName.plus("/").plus(pkgInfo.versionName)
|
||||
.plus("(android; +https://christine.website/contact)")
|
||||
}
|
||||
|
||||
private fun notify(ctx: Context, newPost: NewPost) {
|
||||
val notificationIntent = Intent(Intent.ACTION_VIEW, Uri.parse(newPost.link))
|
||||
val pendingIntent: PendingIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0)
|
||||
|
||||
var builder = NotificationCompat.Builder(ctx, NEW_POST_CHANNEL)
|
||||
.setSmallIcon(R.drawable.splash)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setContentTitle(newPost.title)
|
||||
.setContentText(newPost.summary)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
|
||||
NotificationManagerCompat.from(ctx).apply {
|
||||
notify(notificationId, builder.build())
|
||||
notify(ThreadLocalRandom.current().nextInt(), builder.build())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +70,7 @@ class NewPostWidget : AppWidgetProvider() {
|
|||
|
||||
Log.println(Log.INFO, "new_post", response.toString())
|
||||
// There may be multiple widgets active, so update all of them
|
||||
for (appWidgetId in appWidgetIds) {
|
||||
appWidgetIds.forEach { appWidgetId ->
|
||||
this.updateAppWidget(ctx, appWidgetManager, appWidgetId, response)
|
||||
}
|
||||
}, Response.ErrorListener { error ->
|
||||
|
@ -99,32 +105,41 @@ class NewPostWidget : AppWidgetProvider() {
|
|||
|
||||
override fun onEnabled(ctx: Context) {
|
||||
this.makeQueue(ctx)
|
||||
//this.createNotificationChannel(ctx)
|
||||
savePref(ctx, "old_url", "http://google.com")
|
||||
}
|
||||
|
||||
override fun onDisabled(context: Context) {
|
||||
// Enter relevant functionality for when the last widget is disabled
|
||||
}
|
||||
|
||||
override fun onReceive(ctx: Context?, intent: Intent?) {
|
||||
super.onReceive(ctx, intent)
|
||||
}
|
||||
|
||||
private fun updateAppWidget(
|
||||
context: Context,
|
||||
ctx: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetId: Int,
|
||||
body: NewPost
|
||||
) {
|
||||
// Construct the RemoteViews object
|
||||
val views = RemoteViews(context.packageName, R.layout.new_post_widget)
|
||||
val views = RemoteViews(ctx.packageName, R.layout.new_post_widget)
|
||||
|
||||
views.setTextViewText(
|
||||
R.id.article_title,
|
||||
body.title
|
||||
)
|
||||
|
||||
views.setTextViewText(
|
||||
R.id.article_preview,
|
||||
body.summary
|
||||
)
|
||||
|
||||
val pendingIntent: PendingIntent = Intent(Intent.ACTION_VIEW, Uri.parse(body.link))
|
||||
.let { intent ->
|
||||
PendingIntent.getActivity(ctx, 0, intent, 0)
|
||||
}
|
||||
views.setOnClickPendingIntent(R.id.widget_parent, pendingIntent)
|
||||
|
||||
// Instruct the widget manager to update the widget
|
||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
android:theme="@style/ThemeOverlay.Xesite_android.AppWidgetContainer">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/widget_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
@ -15,24 +16,28 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="109dp"
|
||||
android:layout_height="174dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="92dp"
|
||||
android:layout_height="75dp"
|
||||
android:src="@drawable/splash"
|
||||
android:contentDescription="Logo" />
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:contentDescription="Logo"
|
||||
android:src="@drawable/splash" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/article_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:background="@color/gruvbox_dark_bg"
|
||||
android:contentDescription="@string/appwidget_title"
|
||||
android:text="@string/appwidget_title"
|
||||
|
@ -45,16 +50,16 @@
|
|||
<TextView
|
||||
android:id="@+id/article_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="117dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/gruvbox_dark_bg"
|
||||
android:contentDescription="@string/appwidget_body_preview"
|
||||
android:text="@string/appwidget_body_preview"
|
||||
android:scrollHorizontally="true"
|
||||
android:ellipsize="end"
|
||||
android:scrollHorizontally="true"
|
||||
android:text="@string/appwidget_body_preview"
|
||||
android:textColor="@color/gruvbox_dark_fg"
|
||||
android:textSize="16sp" />
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@ Refer to App Widget Documentation for margin information
|
|||
http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
|
||||
-->
|
||||
<dimen name="widget_margin">0dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
|
@ -5,4 +5,14 @@
|
|||
<string name="add_widget">Add widget</string>
|
||||
<string name="new_post_channel_name">New Posts</string>
|
||||
<string name="new_post_channel_desc">Brand new posts on christine.website</string>
|
||||
<string name="title_activity_test">TestActivity</string>
|
||||
<!-- Strings used for fragments for navigation -->
|
||||
<string name="first_fragment_label">First Fragment</string>
|
||||
<string name="second_fragment_label">Second Fragment</string>
|
||||
<string name="next">Next</string>
|
||||
<string name="previous">Previous</string>
|
||||
<string name="logo_description">Logo</string>
|
||||
|
||||
<string name="hello_first_fragment">Hello first fragment</string>
|
||||
<string name="hello_second_fragment">Hello second fragment. Arg: %1$s</string>
|
||||
</resources>
|
|
@ -4,4 +4,13 @@
|
|||
<item name="appWidgetBackgroundColor">@color/gruvbox_dark_bg</item>
|
||||
<item name="appWidgetTextColor">@color/gruvbox_dark_fg</item>
|
||||
</style>
|
||||
|
||||
<style name="NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
</resources>
|
|
@ -3,7 +3,7 @@
|
|||
android:initialKeyguardLayout="@layout/new_post_widget"
|
||||
android:initialLayout="@layout/new_post_widget"
|
||||
android:minWidth="250dp"
|
||||
android:minHeight="80dp"
|
||||
android:minHeight="40dp"
|
||||
android:previewImage="@drawable/example_appwidget_preview"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:updatePeriodMillis="28800000"
|
||||
|
|
Loading…
Reference in New Issue