All Projects → zeoflow → memo

zeoflow / memo

Licence: Apache-2.0 License
Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to memo

Preferenceroom
🚚 Android processing library for managing SharedPreferences persistence efficiently and structurally.
Stars: ✭ 341 (+1794.44%)
Mutual labels:  sharedpreferences, storage, annotations
Binaryprefs
Rapidly fast and lightweight re-implementation of SharedPreferences which stores each preference in files separately, performs disk operations via NIO with memory mapped byte buffers and works IPC (between processes). Written from scratch.
Stars: ✭ 484 (+2588.89%)
Mutual labels:  sharedpreferences, storage
Hawk
✔️ Secure, simple key-value storage for Android
Stars: ✭ 3,827 (+21161.11%)
Mutual labels:  sharedpreferences, storage
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (+511.11%)
Mutual labels:  sharedpreferences, annotations
Rxkprefs
🛠 A small Kotlin library to make shared preferences easy + RxJava and Coroutines support
Stars: ✭ 264 (+1366.67%)
Mutual labels:  sharedpreferences, storage
stylar
An Android markdown library - it does not require WebView
Stars: ✭ 15 (-16.67%)
Mutual labels:  zeoflow, zeoflow-library
Oksharedprefs
通过注解生成SharedPreferences包装类,解决跨进程数据访问不同步的问题。
Stars: ✭ 183 (+916.67%)
Mutual labels:  sharedpreferences, annotations
kesho
store cache any data type string, boolean, jsonObject, jsonArray, .....
Stars: ✭ 19 (+5.56%)
Mutual labels:  sharedpreferences, storage
simple-preferences
Android Library to simplify SharedPreferences use with code generation.
Stars: ✭ 48 (+166.67%)
Mutual labels:  sharedpreferences, annotations
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (+1166.67%)
Mutual labels:  sharedpreferences, storage
bottom-dialogs
An Android Library that shows on the bottom of the screen a fully customisable dialog.
Stars: ✭ 14 (-22.22%)
Mutual labels:  zeoflow, zeoflow-library
flow-kit
An Android Library that comes with useful features and components.
Stars: ✭ 15 (-16.67%)
Mutual labels:  zeoflow, zeoflow-library
KVStorage
Android 结构化KV存储框架,基于 yaml 生成 java 结构化存储类
Stars: ✭ 228 (+1166.67%)
Mutual labels:  sharedpreferences, storage
spring4-hibernate5-example
Spring 4 and Hibernate 5 integration example using annotations.
Stars: ✭ 16 (-11.11%)
Mutual labels:  annotations
syncr
A rolling, append-only, local and remote data stream library for Go
Stars: ✭ 16 (-11.11%)
Mutual labels:  storage
videojs-annotation-comments
A plugin for video.js to add support for timeline moment/range comments and annotations
Stars: ✭ 129 (+616.67%)
Mutual labels:  annotations
DTC
DTC is a high performance Distributed Table Cache system designed by JD.com that offering hotspot data cache for databases in order to reduce pressure of database and improve QPS.
Stars: ✭ 21 (+16.67%)
Mutual labels:  storage
py2puml
Generate PlantUML class diagrams to document your Python application.
Stars: ✭ 51 (+183.33%)
Mutual labels:  annotations
dagger2-ktx
Kotlin extension bridge library for Dagger2 (proof-of-concept)
Stars: ✭ 41 (+127.78%)
Mutual labels:  annotations
incache
Powerful key/value in-memory storage or on disk to persist data
Stars: ✭ 16 (-11.11%)
Mutual labels:  storage

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 🏆

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].