Code Monkey home page Code Monkey logo

typedpreferences's Introduction

.github/workflows/main.yml Quality Gate Status

Typed Preferences

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

  • [BooleanPreference][boolean-pref] for a boolean value
  • [DoublePreference][double-pref] for a double value
  • [FloatPreference][float-pref] for a float value
  • [IntPreference][int-pref] for an int value
  • [LongPreference][long-pref] for a long value
  • [ShortPreference][short-pref] for a short value
  • [StringPreference][string-pref] for a String value

Source

Inspired by https://github.com/johnjohndoe/TypedPreferences - v2.1.0 version

Feature

Dependency

  1. For using typedpreferences module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
    implementation project(path: ':typedpreferences')
    testImplementation 'junit:junit:4.13'
    ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
}
  1. For using typedpreferences in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.har'])
    testImplementation 'junit:junit:4.13'
}
  1. For using TypedPreferences from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
    dependencies {
    implementation ('dev.applibgroup:typedpreferences:1.0.0')
    testCompile 'junit:junit:4.13'
}

Usage

In code

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() {  }
}

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

gleelakrishna avatar rahul1656 avatar

Watchers

 avatar

Forkers

rahul1656

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.