Coder Social home page Coder Social logo

adam-zielonka / unit-converter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.86 MB

Home Page: https://play.google.com/store/apps/details?id=pro.adamzielonka.converter&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1

License: MIT License

Java 100.00%

unit-converter's Introduction

Unit Converter

Get it on Google Play

Table of contents

Project structure

  • app - contain base code
  • file - android library for internal/external file operations
  • items - android library that contain ItemsView
  • java - java library that contain supporting code
  • verification - java library that support code to make interface to verify objects

Measure File Format

To add custom measures you can use editor build in app or you can prepare the json file:

{
  "name": {
    "en": "Area",
    "pl": "Powierzchnia"
  },
  "version": 1,
  "author": [
    "root"
  ],
  "global": "en",
  "units": [
    {
      "symbol": "",
      "descriptionPrefix": {
        "en": "square ",
        "pl": ""
      },
      "description": {
        "en": "meter",
        "pl": "metr kwadratowy"
      },
      "one": 1,
      "prefixes": [
        {
          "symbol": "k",
          "description": {
            "en": "kilo"
          },
          "exp": 6,
          "position": 3
        },
        {
          "symbol": "d",
          "description": {
            "en": "deci",
            "pl": "decy"
          },
          "exp": -2
        },
        {
          "symbol": "c",
          "description": {
            "en": "centi",
            "pl": "centy"
          },
          "": -4
        },
      ]
    },
    {
      "symbol": "in²",
      "description": {
        "en": "square inch",
        "pl": "cal kwadratowy"
      },
      "one": 0.00064516
    }
  ]
}

You can find more measures files on this folder: ./app/src/main/assets/converters

Properties

property value
file {name, version, author, global, units}
name {"country_code" : "measure name"}
version integer
author ["author name"]
global base country code name
units [{symbol, descriptionPrefix, description, one, shift, shift2, expBase, prefixes}]
symbol base unit symbol
descriptionPrefix {"country_code" : "description prefix"}
description {"country_code" : "description"}
one number of multiples of base unit, default is 1
shift number of shift to the basic unit, default is 0
shift2 number of shift to the basic unit, default is 0
expBase exponent base for prefixes, default is 10
prefixes [{symbol, description, exp}]
symbol prefix symbol
description {"country_code" : "prefix description"}
exp prefix exponent

Equations

In the file you define parameters for the equation that calculate target unit value from base unit:

$$ y = \alpha * (x + \Delta_1) + \Delta_2 $$

where:

  • $x$ - value of base unit
  • $y$ - value of target unit
  • $\alpha$ - one - multiply of base value
  • $\Delta_1$ - shift_1 - shift base value before multiply
  • $\Delta_2$ - shift_2 - shift base value after multiply

For calculate base unit value form target unit, the equation is:

$$ x = \frac{1}{\alpha} * (y - \Delta_2) - \Delta_1 $$

To calculate from one unit to another, it used this formula:

$$ f(x) = \frac{1}{\alpha^T} * (\alpha^S * (x + \Delta_1^S) + \Delta_2^S - \Delta_2^T) - \Delta_1^T $$

where:

  • $x$ - value of source unit
  • $f(x)$ - value of target unit
  • $\alpha^S$ - one from source unit
  • $\Delta_1^S$ - shift_1 from source unit
  • $\Delta_2^S$ - shift_2 from source unit
  • $\alpha^T$ - one from target unit
  • $\Delta_1^T$ - shift_1 from target unit
  • $\Delta_2^T$ - shift_2 from target unit

Screens

License

MIT

Legal attribution

Google Play and the Google Play logo are trademarks of Google LLC.

unit-converter's People

Contributors

adam-zielonka avatar

Watchers

 avatar

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.