Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally.

Overview

Memo

Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally.

1. Depend on our library

Memo Library is available through Maven Repository. To use it:

  1. Open the build.gradle file for your application.
  2. Make sure that the repositories section includes Maven Repository mavenCentral(). For example:
  allprojects {
    repositories {
      mavenCentral()
    }
  }
  1. Add the library to the dependencies section:
dependencies {
    // ...

    // declare memo version
    def memo_version = "x.y.z"

    // Memo Library
    implementation("com.zeoflow:memo:$memo_version")
    // Required if you want to use the injector
    implementation("com.zeoflow:memo-annotation:$memo_version")
    annotationProcessor("com.zeoflow:memo-compiler:$memo_version")
    // For kotlin projects use kapt instead of annotationProcessor
    kapt("com.zeoflow:memo-compiler:$memo_version")

    // ...
}

2. Usage

2.1 Initialize

With Context

Memo.init(context).build();

Without Context (the context is retrieved from the ContextProvider at runtime)

Memo.init().build();

2.2 Library Calls

Save any type (Any object, primitives, lists, sets, maps ...)

Memo.put(key, T);

Get the original value with the original type

T value = Memo.get(key);

Delete any entry

Memo.delete(key);

Check if any key exists

Memo.contains(key);

Check total entry count

Memo.count();

Delete everything

Memo.deleteAll();

2.3 Customize the Library at initialisation

  • Everything is pluggable, therefore you can change any layer with your custom implementation.
  • NoEncryption implementation is provided out of box If you want to disable crypto.
Memo.init(context)
  .setEncryption(new NoEncryption())
  // encryption_string is used to encrypt the data and is required
  .setEncryption(new ConcealEncryption(encryption_string))
  .setLogInterceptor(new MyLogInterceptor())
  .setConverter(new MyConverter())
  .setParser(new MyParser())
  .setStorage(new MyStorage())
  .build();

3. Injector

3.1 Build MemoEntity Class

/**
 * the entity generated will be named UserProfile_MemoEntity
 * it was annotated with @MemoEntity("UserProfile")
 *
 * the entity will be encrypted using the "G15y3aV9M8d" key
 * it was annotated with @EncryptEntity("G15y3aV9M8d")
 */
@MemoEntity("UserProfile")
@EncryptEntity("G15y3aV9M8d")
public class User
{

    /**
     * the default value will be "zeoflow"
     *
     * generated field will be named username
     *
     * this field is observable
     * it was annotated with @Observable
     */
    @KeyName("username")
    @Observable
    protected final String userUsername = "zeoflow";

    /**
     * generated field name will be login - lowerCamel
     *
     * this field will have its own onChangedListener
     * it was annotated with @Listener
     */
    @Listener
    protected final boolean login = false;

    /* the default value will be 1 */
    @KeyName("views")
    protected final int viewsCount = 1;

    /* the default value will be null */
    @KeyName("userinfo")
    protected PrivateInfo privateInfo;

    /**
     * preference putter function for userUsername.
     *
     * @param userUsername function in
     *
     * @return function out
     */
    @MemoFunction("username")
    public String putUserUsernameFunction(String userUsername)
    {
        return "Hello, " + userUsername;
    }

    /**
     * preference getter function for userUsername.
     *
     * @param userUsername function in
     *
     * @return function out
     */
    @MemoFunction("username")
    public String getUserUsernameFunction(String userUsername)
    {
        return userUsername + "!!!";
    }

    /**
     * preference putter function example for visitCount's auto increment.
     *
     * @param count function in
     *
     * @return function out
     */
    @MemoFunction("views")
    public int putVisitCountFunction(int count)
    {
        return ++count;
    }

    /**
     * preference getter compound function for following fields.
     *
     * Params declared inside @MemoCompoundFunction's annotation
     * @param username function in
     * @param views function in
     *
     * @return $username $views
     */
    @MemoCompoundFunction(values = {"username", "views"})
    public String getUserViews(String username, int views)
    {
        return username + " " + views;
    }

    /**
     * preference getter compound function for following fields.
     *
     * Params declared inside @MemoCompoundFunction's annotation
     * @param userinfo function in
     *
     * @return $first_name $last_name
     */
    @MemoCompoundFunction(values = {"userinfo"})
    public String getFullName(PrivateInfo userinfo)
    {
        return userinfo.getFirstName() + " " + userinfo.getLastName();
    }

    /**
     * preference getter compound function for following fields.
     *
     * Params declared inside @MemoCompoundFunction's annotation
     * @param userinfo function in
     * @param views function in
     *
     * @return $first_name $last_name, views count $views
     */
    @MemoCompoundFunction(values = {"userinfo", "views"})
    public String getFullNameAndViews(PrivateInfo userinfo, int views)
    {
        return userinfo.getFirstName() + " " + userinfo.getLastName() + ", views count: " + views;
    }

}

3.2 Helper Class for Memo's injector

Create injector class

/**
 * Component that integrates memo entities; it must be an interface
 * and annotated with @MemoComponent. The generated class will end in
 * $_Memo (generated class for this interface will be AppStorage_Memo
 *
 * inside this Memo manager, the following MemoEntities are injected:
 * - User
 * - Country
 */
@MemoComponent(entities = {User.class, Country.class})
public interface AppStorage
{

    /**
     * declare dependency injection target MaiActivity.
     */
    void inject(MainActivity mainActivity);

    /**
     * declare dependency injection target LoginActivity.
     */
    void inject(LoginActivity loginActivity);

}

Create variables that needs to be injected by the AppStorage_Memo

@InjectPreference
public AppStorage_Memo component;
@InjectPreference
public UserProfile_MemoEntity userProfile;

Inject MainActivity in the AppStorage_Memo

AppStorage_Memo.getInstance().inject((MainActivity) this);

Access MemoEntity from Memo Component

component.userProfile();

Put value inside userProfile

userProfile.putUsername(inputUsername);

Add change listener for login

userProfile.addLoginListeners(new UserProfile_MemoEntity.LoginIOnChangedListener()
{
    @Override
    public void onChanged(boolean login)
    {
        // do something
    }
});

Add observable for the username field

component.userProfile().usernameObserver((LifecycleOwner) this, new Observer<String>()
{
    @Override
    public void onChanged(String username)
    {
        // do something here
    }
});

License

Copyright (C) 2021 ZeoFlow S.R.L.

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.

🏆 Contributors 🏆

Comments
  • AutoGenerate class-ready for `@Hilt`

    AutoGenerate class-ready for `@Hilt`

    Table of Contents

    Link to GitHub issues it solves

    closes #58

    Description

    AutoGenerate class-ready for @Hilt

    Contributing has more information and tips for a great pull request.
    @priority-low @issue @feature 
    opened by teogor 2
  • SDK & Environment Improvement

    SDK & Environment Improvement

    Table of Contents

    Link to GitHub issues it solves

    closes #52

    Description

    Migrated to java 11 and fixed the maven deployment

    Contributing has more information and tips for a great pull request.
    @environment @priority-high @issue @feature @dependency-update 
    opened by teogor 2
  • Fixed problem with casting int to long

    Fixed problem with casting int to long

    Table of Contents

    Link to GitHub issues it solves

    closes #53

    Description

    Fixed casting between Generic Type (T) stored as Integer to Long

    Contributing has more information and tips for a great pull request.
    @priority-high @issue @bug-fix 
    opened by teogor 2
  • InheritAnnotations from parent field

    InheritAnnotations from parent field

    Table of Contents

    Link to GitHub issues it solves

    closes #51

    Description

    InheritAnnotations from parent field

    Contributing has more information and tips for a great pull request.
    @priority-high @issue @bug-fix 
    opened by teogor 2
  • Changed the encryption/decryption procedure

    Changed the encryption/decryption procedure

    Table of Contents

    Link to GitHub issues it solves

    closes #49

    Description

    Changed the encryption/decryption procedure

    • removed facebook conceal
    Contributing has more information and tips for a great pull request.
    @priority-critical @issue @bug-fix 
    opened by teogor 2
  • Generate MemoClass of type `T`

    Generate MemoClass of type `T`

    Table of Contents

    Link to GitHub issues it solves

    closes #44

    Description

    Generate MemoClass of type T

    Contributing has more information and tips for a great pull request.
    @priority-low @issue @bug-fix 
    opened by teogor 2
  • JavaDoc improved for the generated classes

    JavaDoc improved for the generated classes

    Table of Contents

    Link to GitHub issues it solves

    closes #42

    Description

    Improved the javadoc for the generated classes

    Contributing has more information and tips for a great pull request.
    @documentation @priority-very-low @issue @bug-fix 
    opened by teogor 2
  • Added `I` before interface name

    Added `I` before interface name

    Table of Contents

    Link to GitHub issues it solves

    closes #17

    Description

    Added I before interface name

    Contributing has more information and tips for a great pull request.
    @priority-medium @issue @feature 
    opened by teogor 2
  • Created docs for the injector

    Created docs for the injector

    Table of Contents

    Link to GitHub issues it solves

    closes #8

    Description

    Created docs for the injector

    Contributing has more information and tips for a great pull request.
    @documentation @priority-high @issue 
    opened by teogor 2
  • Fixed LogInterceptor bug

    Fixed LogInterceptor bug

    Table of Contents

    Link to GitHub issues it solves

    closes #28

    Description

    Fixed LogInterceptor bug

    Contributing has more information and tips for a great pull request.
    @priority-very-low @issue @bug-fix 
    opened by teogor 2
  • `@KeyName` empty or null than the field will be camel-lowercase

    `@KeyName` empty or null than the field will be camel-lowercase

    Table of Contents

    Link to GitHub issues it solves

    closes #27

    Description

    @KeyName empty or null than the field will be camel-lowercase

    Contributing has more information and tips for a great pull request.
    @priority-very-low @issue @bug-fix 
    opened by teogor 2
  • Unsafe Encryption Mode Usage

    Unsafe Encryption Mode Usage

    Description: Remediation for Unsafe Encryption Mode Usage This information is intended for developers with app(s) that contain encryption employing the less secure mode AES/ECB. Encrypting content using this weak mode can lead to weak ciphertexts, and potentially put user data at risk. Location(s) of the less secure encryption modes in your app can be found in the Play Console notification for your app.

    https://support.google.com/faqs/answer/10046138

    To help us triage faster, please check to make sure you are using the latest version of the library.
    We also happily accept pull requests.
    @bug @security @priority-high 
    opened by teogor 0
  • `@KeyName` is not a suitable name

    `@KeyName` is not a suitable name

    Description: @KeyName is not a suitable name therefore it should be renamed to StoreKey because this element represents the value that binds the element to the storage

    To help us triage faster, please check to make sure you are using the latest version of the library.
    We also happily accept pull requests.
    @bug @priority-very-low 
    opened by teogor 0
  • Default value for injector

    Default value for injector

    Description: Default value for memo's injector

    To help us triage faster, please check to make sure you are using the latest version of the library.
    We also happily accept pull requests.
    @bug @priority-low 
    opened by teogor 0
  • @MemoCompoundFunction to set values

    @MemoCompoundFunction to set values

    Is your feature request related to a problem? Please describe. @MemoCompoundFunction to set values

    Describe the solution you'd like For the time being the @MemoCompoundFunction annotation can be used only for get methods

    We also happily accept pull requests.
    @priority-medium @feature 
    opened by teogor 0
Releases(v1.3.2)
  • v1.3.2(Oct 27, 2022)

    Changes

    - Bug Fixes

    Fixed bug that breaks the build when applying Hilt (#65) by @teogor

    - Others

    Updated algorithm for encryption (#64) by @teogor

    Full Changelog: https://github.com/zeoflow/memo/compare/v1.3.1...v1.3.2

    Source code(tar.gz)
    Source code(zip)
  • v1.3.1(Jul 3, 2022)

    Changes

    - Enhancement

    AutoGenerate class-ready for @Hilt (#59) by @teogor

    - Bug Fixes

    Fixed Wrong-Key format (#62) by @teogor

    Full Changelog: https://github.com/zeoflow/memo/compare/v1.3.0...v1.3.1

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jun 30, 2022)

    Changes

    - Maintenance

    Added kotlin modules (#57) by @teogor

    - Documentation

    Added kotlin modules (#57) by @teogor

    Full Changelog: https://github.com/zeoflow/memo/compare/v1.2.0...v1.3.0

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jan 13, 2022)

    Changes

    - Enhancement

    SDK & Environment Improvements (#56) by @TeodorHMX1

    - Bug Fixes

    Fixed problem with casting int to long (#55) by @TeodorHMX1 InheritAnnotations from parent field (#54) by @TeodorHMX1

    - Dependency Updates

    SDK & Environment Improvement (#56) by @TeodorHMX1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.7(Apr 24, 2021)

  • v1.1.6(Apr 15, 2021)

    Changes

    - Bug Fixes

    Generate MemoClass of type T (#46) by @TeodorHMX1 JavaDoc improved for the generated classes (#45) by @TeodorHMX1

    - Documentation

    JavaDoc improved for the generated classes (#45) by @TeodorHMX1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.5(Apr 13, 2021)

    Changes

    - Enhancement

    Added I before interface name (#41) by @TeodorHMX1

    - Documentation

    Created docs for the injector (#40) by @TeodorHMX1

    - Others

    Environment prepared for v1.1.5 (#43) by @TeodorHMX1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.4(Apr 12, 2021)

  • v1.1.3(Apr 12, 2021)

    Changes

    - Bug Fixes

    Fixed dependencies for the memo-annotation module (#36) by @TeodorHMX1 @KeyName empty or null than the field will be camel-lowercase (#35) by @TeodorHMX1

    - Dependency Updates

    Fixed dependencies for the memo-annotation module (#36) by @TeodorHMX1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Apr 11, 2021)

  • v1.1.1(Apr 11, 2021)

  • v1.1.0(Apr 11, 2021)

    Changes

    - Enhancement

    Camel low case name entity memo (#26) by @TeodorHMX1 Created @MemoCompoundFunction for getting values (#25) by @TeodorHMX1 Relevant names added (#16) by @TeodorHMX1

    - Bug Fixes

    Docs name mismatch fix (#20) by @TeodorHMX1 AES Encryptor Deleted (#14) by @TeodorHMX1 Removed TypeConverter (#13) by @TeodorHMX1 Private methods deleted (#11) by @TeodorHMX1

    - Documentation

    Demo content updated (#21) by @TeodorHMX1 Docs name mismatch fix (#20) by @TeodorHMX1 Docs created (#7) by @TeodorHMX1

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Apr 10, 2021)

    Changes

    - Maintenance

    Files deployed (#5) by @TeodorHMX1 add TeodorHMX1 as a contributor (#4) by @zeobot[bot] Created buildSrc folder (#2) by @TeodorHMX1 ZeoBot's Environment Prepared (#1) by @TeodorHMX1 and @zeobot[bot]

    - Documentation

    add TeodorHMX1 as a contributor (#4) by @zeobot[bot]

    Source code(tar.gz)
    Source code(zip)
Owner
ZeoFlow
From ZeoFlow with ❤️ to Developers
ZeoFlow
Screaming fast JSON parsing and serialization library for Android.

#LoganSquare The fastest JSON parsing and serializing library available for Android. Based on Jackson's streaming API, LoganSquare is able to consiste

BlueLine Labs 3.2k Dec 18, 2022
✔️ Simple, pretty and powerful logger for android

Logger Simple, pretty and powerful logger for android Setup Download implementation 'com.orhanobut:logger:2.2.0' Initialize Logger.addLogAdapter(new A

Orhan Obut 13.5k Jan 5, 2023
null 5 Jan 11, 2022
Bu repositorie Google'ın tamamıyla ücretsiz olarak sunduğu Android Kotlin Fundamentals içeriğindeki projelerin tamamıdır.

Bu repositorie Google'ın tamamıyla ücretsiz olarak sunduğu Android Kotlin Fundamentals içeriğindeki projelerin tamamıdır. Kotlin ile Android geliştiriciliğine başlayacaklara önerilir.

Serkan Alc 15 Dec 2, 2022
A declarative API to handle Android runtime permissions.

PermissionsDispatcher Fully Kotlin/Java support Special permissions support 100% reflection-free PermissionsDispatcher provides a simple annotation-ba

PermissionsDispatcher 11.1k Jan 5, 2023
A JSON Transmission Protocol and an ORM Library for automatically providing APIs and Docs.

?? 零代码、热更新、全自动 ORM 库,后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构。 ?? A JSON Transmission Protocol and an ORM Library for automatically providing APIs and Docs.

Tencent 14.4k Dec 31, 2022
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 8, 2023
A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Square 8.7k Dec 31, 2022
A modern and lightweight library for working with email addresses in Java

JMail A modern, fast, zero-dependency library for working with email addresses and performing email address validation in Java. Built for Java 8 and u

Rohan Nagar 67 Dec 22, 2022
A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back

A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back, with a transparent support of any kind of self-references and with a full Java 9 compatibility.

Andrey Mogilev 9 Dec 30, 2021
Jakarta money is a helpful library for a better developer experience when combining Money-API with Jakarta and MicroProfile API.

jakarta-money Jakarta money is a helpful library for a better developer experience when combining Money-API with Jakarta and MicroProfile API. The dep

Money and Currency API | JavaMoney 19 Aug 12, 2022
Java with functions is a small java tools and utils library.

Java with functions is a small java tools and utils library.

null 4 Oct 14, 2022
High performance JVM JSON library

DSL-JSON library Fastest JVM (Java/Android/Scala/Kotlin) JSON library with advanced compile-time databinding support. Compatible with DSL Platform. Ja

New Generation Software Ltd 835 Jan 2, 2023
JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Bazaarvoice 1.3k Dec 30, 2022
Sawmill is a JSON transformation Java library

Update: June 25, 2020 The 2.0 release of Sawmill introduces a breaking change to the GeoIpProcessor to comply with the updated license of the MaxMind

Logz.io 100 Jan 1, 2023
MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Andrei Ciobanu 59 Sep 17, 2022
Genson a fast & modular Java <> Json library

Genson Genson is a complete json <-> java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

null 212 Jan 3, 2023
Lean JSON Library for Java, with a compact, elegant API.

mJson is an extremely lightweight Java JSON library with a very concise API. The source code is a single Java file. The license is Apache 2.0. Because

Borislav Iordanov 77 Dec 25, 2022
Open NFCSense Library

OpenNFCSense API Open-source API of NFCSense for the Processing programming environment (http://processing.org/). Please refer to the following workfl

Rong-Hao Liang 13 Jul 25, 2022