Giter VIP home page Giter VIP logo

androidx-ktx-extras's People

Watchers

 avatar

androidx-ktx-extras's Issues

[New Library] AndroidX WorkManager extensions

AndroidX WorkManager currently does have a KTX module, but it doesn't provide a lot of utilities :/

API suggestions

  • WorkInfo methods which return a Flow instead of LiveData (note: 2.9.0-alpha01 already offers such a feature, so we should provide a backwards-compatible Kotlin extension that emulates the 2.9.0-alpha01 methods on <=2.8.0)

  • #4

    val workData = buildData {
      // Perhaps we can have similar utilities to that of a MutableMap?
      this += "key" to 123
      this += workDataOf(/* ... */) // Add existing data
      addData {
        // Add data from a Data.Builder
        putBoolean("abc", false)
      }
    
      this -= workDataOf(/* ... */) // Remove the mutable data's properties that are present in the specified Data
    }
  • Add suspend methods for methods that return a LiveData

  • Add worker request methods that accept a java.time.Duration/kotlin.time.Duration instead of a Long + TimeUnit

  • Add top-level methods to create anonymous objects of interfaces (for e.g. RunnableScheduler)

[New Library] AndroidX RecyclerView extensions

AndroidX RecyclerView currently has no Kotlin extensions AFAICT.

API suggestions

  • Kotlin properties for getters/setters that don't automatically map to their property equivalent (see issue 204918397 on Google's IssueTracker)
  • ItemTouchHelper methods for:
    • Attaching a helper to a RecyclerView (this already exists from ItemTouchHelper -> RecyclerView via attachToRecyclerView, but there's no equivalent for the other direction - RecyclerView -> ItemTouchHelper)
    • Creating a SimpleCallback
    • Value class for specifying drag/swipe directions
  • Convenience method to create a DiffUtil.ItemCallback with lambdas

[Javadoc] Consider using Dokka HTML docs instead for Javadoc artifact

Is there an existing issue for this?

  • I have searched the existing issues

Library name

All

Library version

All

What happened?

It appears that Dokka's HTML format renders just fine if used as a "Javadoc" source - not sure if this is used internally for IntelliJ's quick documentation, but trying to open a Javadoc of for example the kotlin-logging library seems to work just fine.

Expected behaviour

No response

Reproduction steps

  1. Open the javadoc jar file for say, common-enums-jvm
  2. Note that the Javadoc-style format is used, instead of Dokka's HTML format

Relevant log output

No response

Possible solution

Switch to publishing 100% Dokka HTML docs, not sure if there'll be any unforeseen issues though

Additional context

While browsing the Javadocs for kotlin-logging, I noticed that they're using Dokka HTML docs and that it shows up just fine on https://javadoc.io

[New API] MDC Date Picker APIs should accept java.time equivalents

Is there an existing issue for this?

  • I have searched the existing issues

Library name

Material Components for Android extensions

Problem

Material Components for Android's Date Picker currently expects a long to be used, which isn't very intuitive as to what you should pass to their APIs, especially when their parameters don't have a suffix that tells you what the unit should be:

@NonNull
@CanIgnoreReturnValue
public Builder<S> setSelection(S selection) {
  this.selection = selection;
  return this;
}

The datePicker static method for MaterialDatePicker.Builder returns a Builder<Long>, so it would look like such:

@NonNull
@CanIgnoreReturnValue
public Builder<Long> setSelection(Long selection) {
  this.selection = selection;
  return this;
}

Which is still confusing as to what unit to pass the selection as (milliseconds? seconds? etc).

Description

There should be extension functions to accept the more suitable java.time APIs first introduced in Java 8, and are designed to resolve the issue Java developers have with dates (and any existing bugs in the old Calendar/Date APIs).

I believe, however, that the Material Components for Android devs didn't go with this as it was only first introduced in Android Oreo (which first brought Java 8 support), so without core library desugaring it isn't possible.

Anyways, here's some proposed APIs:

  • MaterialDatePicker.Builder.setSelection should take an Instant, or a Pair<Instant, Instant> for a single date/date-range picker respectively. This would proxy to calling its toEpochMilli method to get its milliseconds representation:

    fun MaterialSingleDatePickerBuilder.setSelection(instant: Instant) = setSelection(instant.toEpochMilli())
    fun MaterialDateRangePickerBuilder.setSelection(instants: Pair<Instant, Instant>) = setSelection(...)
  • CalendarConstraints.Builder should take an Instant for its respective APIs that take a long:

    • setStart
    • setEnd
    • setOpenAt
  • CalendarConstraints.Builder.setDayOfWeek should take a DayOfWeek

Alternatives?

Using the appropriate methods in the java.time APIs to retrieve its raw representation to then be passed to the existing Java API.

There are also already some example code snippets in some of the Javadocs for java.time.

Additional info

See EdricChan03/studybuddy-android@657c551 for context

[New Library] Android NotificationChannel extensions

I've noticed that the NotificationChannel class has some rather... interesting naming conventions for getters/setters of boolean properties:

/**
 * Sets whether notifications posted to this channel should display notification lights,
 * on devices that support that feature.
 *
 * Only modifiable before the channel is submitted to
 * {@link NotificationManager#createNotificationChannel(NotificationChannel)}.
 */
public void enableLights(boolean lights) {
    this.mLights = lights;
}

/**
 * Returns whether notifications posted to this channel trigger notification lights.
 */
public boolean shouldShowLights() {
    return mLights;
}

As a result, no synthetic Kotlin mutable properties are generated, resulting in having to use the Java getter/setter methods respectively.

Proposed extensions

(API names are currently tentative, the names will change as further experimentation is done)

Additional tasks

  • Add notice that the properties can't be modified once they have been submitted (perhaps a Kotlin opt-in annotation, something like ImmutableAfterCreation)

Update Dokka to 1.9.0

Dokka 1.9.0 was just released.

Updating it should be as simple as bumping the jetbrainsDokka Gradle lazy property for Dokkatoo:

dokkatoo {
  versions.jetbrainsDokka = "1.9.0" // Property.assign
}

Bump Gradle to 8.4

Tracking issue for bumping Gradle to v8.4. There shouldn't be any issues when migrating afaict, but this issue exists just in case

[Sonatype] Snapshots are published as releases

Overview

Currently, when attempting to publish snapshots to the Sonatype repository, it results in a HTTP 400 bad request error.

This is because of the way the precompiled scripts are used such that the version is not actually set at that time, resulting in the default value of "unspecified", hence when the isRelease check is done, it presumes that the version is not a snapshot and so publishes to the staging repository instead of the snapshots repository.

Proposed solution

I aim to resolve this by moving all of the precompiled scripts to a common binary plugin which can be used across modules, and should hopefully reduce the amount of precompiled scripts that all modules must apply.

Additionally, the binary plugin can be made configurable through the use of Gradle's extension feature, and with Kotlin DSL lazy property assignment support enabled by default in Gradle 8.2+ will be more concise.


Alternatively, the afterEvaluate block can be used, but where's the fun in that :P
(And we might want to additionally allow for isRelease to be configurable via the command-line, which may not be possible with afterEvaluate)

Checklist

  • Initial binary plugin
  • Add default conventions
  • Add Compose support (seems that this might not be possible as the AGP and KGP plugins aren't quite the same classpath? There's a Google IssueTracker link on this iirc) (fixed via b00b9a3)

[Browser KTX] Update API surface with 1.7.0

Is there an existing issue for this?

  • I have searched the existing issues

Library name

Browser KTX

Problem

AndroidX Browser has shipped a new stable 1.7.0 release, which includes new APIs that Browser KTX is now missing out on.

Description

From the 1.7.0 release notes:

Important changes since 1.6.0

  • Added CustomTabsIntent.Builder#setBookmarksButtonEnabled that enables the bookmarks button in the overflow menu. (Ia792e)
  • Added CustomTabsIntent.Builder#setDownloadButtonEnabled that enables the download button in the overflow menu. (Ia792e)
  • Added CustomTabsIntent.Builder#setSendToExtraDefaultHandlerEnabled that enables sending initial urls to external handler apps. (Ia792e)
  • Added CustomTabsIntent.Builder#setTranslateLanguage that specifies the target language that the Translate UI should be triggered with. (Ia792e)
  • Added CustomTabsIntent.Builder#setBackgroundInteractionEnabled that enables interactions with the background app when a partial Custom Tab is launched. (Ia792e)
  • Added CustomTabsIntent.Builder#setShareIdentityEnabled that allows Custom Tabs to obtain the caller's identity. (I7bf2b)
  • Added CustomTabsIntent.Builder#setSecondaryToolbarSwipeUpGesture that sets a PendingIntent to be sent when the user swipes up from the bottom toolbar. (Id42a2)

Alternatives?

No response

Additional info

No response

[Maintainence] Add issue templates

Having issue templates should standardise what to expect for a library/API request, or for bug fixes

New issue templates

  • New libraries
  • New APIs
  • Bugs

[Common Enums] Migrate to KMP

It might be useful for end consumers to be able to use the common-enums artifact without the Android requirement :P

Publish to Maven Central

GitHub Packages currently requires a GitHub personal access token to be used.

Publishing to Maven Central should hopefully alleviate this requirement, and additionally as most projects likely already have an existing mavenCentral() repository declared in their build scripts, there should also no longer be a requirement to add GitHub Packages as a repo.

Checklist

  • Attain access to publishing on Maven Central
  • Setup project for Maven Central publishing
  • #5
  • Publish initial release ๐Ÿ‘€
  • Fix broken precompiled scripts

[WorkManager] Better Kotlin DSL for `Data`

val workData = buildData {
  // Perhaps we can have similar utilities to that of a MutableMap?
  this += "key" to 123
  this += workDataOf(/* ... */) // Add existing data
  addData {
    // Add data from a Data.Builder
    putBoolean("abc", false)
  }

  this -= workDataOf(/* ... */) // Remove the mutable data's properties that are present in the specified Data
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.