Git Product home page Git Product logo

typedpreferences's Introduction

Build Status Maven Central Apache License Methods count

Typed Preferences

Typed Preferences Icon

This library for Android provides classes which allow to store and retrieve settings from the preferences. There is an individual class for each native type:

Each class comes with two constructors - one of them allows to ommit the default value.

All classes declare the same methods: get(), isSet(), set() and delete(). Here are the method signatures as definied in the StringPreference class.

public class StringPreference {
    public String get() { ... }
    public boolean isSet() { ... }
    public void set(String value) { ... }
    public void delete() { ... }
}

Wrappers for frequently used classes can be found and added in the wiki. Take a look!

How to get the thing running?

Add the library as a dependency to your build.gradle in case you use Gradle:

dependencies {
    compile "info.metadude.android:typed-preferences:{$version}"
}

Or if you use Maven you should be looking for this:

<dependency>
    <groupId>info.metadude.android</groupId>
    <artifactId>typed-preferences</artifactId>
    <version>{$version}</version>
</dependency>

For anything else, go to Maven Central - or just build the library yourself.

Minimum SDK version / API level

The library is available in two different versions. If you need to support API level 8 in your project you must include the latest 1.x.x version. This library version persists the settings synchronously using the commit method of the SharedPreferences.Editor. If the minimum SDK version you need to support is API level 9 you can choose the latest 2.x.x version which relies on the apply method of the SharedPreferences.Editor. Thereby settings are persisted asynchronously.

For further information please stick to documentation of the SharedPreferences.Editor interface.

Demo project

Check out the demo project TypedPreferencesDemo which shows how to use the library.

Tests

Run ./gradlew clean test to execute the tests.

Feedback

If you use this library and you are happy with it please send a tweet to @tbsprs and feel free to announce your app. I will be happy to list it here.

In case you do not like the library please do not hesitate to open an issue and let me know what can be improved.

Which applications are using this library?

Reference

This library is mainly inspired by the classes which have been published by Jake Wharton in the u2020 project.

Authors

Contributors

License

Copyright 2014-2021 Tobias Preuss

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

typedpreferences's People

Contributors

johnjohndoe avatar ligi avatar mariusvolkhart avatar othreecodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typedpreferences's Issues

the library as a JAR instead of aar

I saw that the library is deployed to maven central as a AAR and not as a normal JAR.

Since the project has no res folder this is not needed and should be just a JAR which can be downloaded and used in normal non-gradle projects.

Broken test setup

Broken tests

Since the latest release v.1.1.0 of TypedPreferences Gradle, the Android Studio plugin and the Android SDK have evolved. For some reason the tests do no longer work. I got them running at some point in the past with Gradle 0.11 and also noticed the final release of novoda/robolectric-plugin 0.0.3-SNAPSHOT. However I cannot get them running now.

Updating the project

I already experimented with updating the project (Gradle plugin, Gradle wrapper, SDK, ...) on the feature/update-project branch. Without success with regards to running the tests.
Note, that this work relies on a locally deployed version of the novoda/robolectric-plugin as mentioned here.
Finally, before merging, this branch will be rebased or rewritten. Anyways, feel free to experiment with what I started off with.

Changing the test architecture

It might be worth looking into other test setup such as malmstein/testingarchitecture or novoda/gradle-android-test-plugin or something else since novoda/robolectric-plugin has been deprecated as of August 6, 2014.

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.