Giter Club home page Giter Club logo

patrons's Introduction

Patrons

Travis branch

Let your patron do the work.

A Patron is a preference wrapper. Come also with an encryption system.

Features

Use the adequate patron for the preference value type you would like to store.

Patrons handle all types handled by shared preferences:

  • boolean
  • float
  • float
  • int
  • String
  • StringSet

Patrons also provide an encrypted version of the shared preferences. Use patrons-conceal to encrypt your preference values.

Installation

Step 1. Add the JitPack repository to your build file

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Step 2. Add the dependency

dependencies {
  implementation 'com.github.prolificinteractive.patrons:patron:${patronsVersion}'

  // If you want patrons with encryption of your shared preferences
  implementation 'com.github.prolificinteractive.patrons:patron-conceal:${patronsVersion}'
}

Usage

A default patron exists for all shared preferences types.

Boolean

val boolPref: Preference<Boolean> = BooleanPreference(prefs, "key")

Float

val floatPref: Preference<Float> = FloatPreference(prefs, "key")

Integer

val intPref: Preference<Integer> = IntPreference(prefs, "key")

Long

val longPref: Preference<Long> = LongPreference(prefs, "key")

String

val stringPref: Preference<String> = StringPreference(prefs, "key")

String Set

val stringSetPref: Preference<Set<String>> = StringSetPreference(prefs, "key")

Conceal

Init Conceal in your application class:

import com.facebook.soloader.SoLoader;

public class MyApplication extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, false);
  }
}

Encryption

SharedPreferences Backed Keychain

val prefs = ConcealSharedPreferences(context)

Keystore Backed Keychain

By default, preference's key is NOT encrypted but the behaviour can be customized by passing your own custom KeyEncryption

val defaultPref = PreferenceManager.getDefaultSharedPreferences(context)
val concealedPrefs = ConcealSharedPreferences(
  this,
  defaultPref,
  NoKeyEncryption(),
  ConcealEncryption(
    context,
    "conceal_encryption",
    AndroidConceal
      .get()
      .createDefaultCrypto(KeystoreBackedKeychain(context, defaultPref))
    )
)

Proguard

TODO

Contributing to Patrons

To report a bug or enhancement request, feel free to file an issue under the respective heading.

If you wish to contribute to the project, fork this repo and submit a pull request. Code contributions should follow the standards specified in the Prolific Android Style Guide.

License

prolific

Copyright (c) 2018 Prolific Interactive

Patrons is maintained and sponsored by Prolific Interactive. It may be redistributed under the terms specified in the LICENSE file.

patrons's People

Contributors

quentin41500 avatar tevjef avatar

Stargazers

 avatar  avatar  avatar

Watchers

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

Forkers

isabella232

patrons's Issues

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.