Giter VIP home page Giter VIP logo

localazy-card's Introduction

Localazy-Card

Localazy Card

License: GPL v3 Hits

This is a small library to help the developers who already using Localazy to localize their apps, aside that library support app language changing directly from it

In order to use this library, you need to setup Localazy Gradle Plugin. Guide can be found on official website Localazy Gradle Plugin

IMPORTANT THING Do not apply this configuration to the Localazy Gradle Plugin, because injection and download is important to retrieve your Language pack

localazy {
    injection {
            enabledForRelease false
            enabledForDebug false
            library "none"
        }
    
        download {
            enabledForRelease false
            enabledForDebug false
        }
    }

Since Localazy Card rely on Localazys OTA app needs INTERNET permission in order to work, add this code snippet to your Android Manifest, if you already done Localazy Gradle Plugin setup from the link above, you have done this step.

    <uses-permission android:name="android.permission.INTERNET" />

Add it in your root build.gradle at the end of repositories:

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

Include the library as a local library project or add the dependency in your build.gradle.

dependencies {
            implementation 'com.github.Paget96:Localazy-Card:1.2'
}

Setup

By the default library will set a default view, you can easily manipulate it over xml or inside class.

Step 1

Include the view defined as below in your layout. And you can customize it like this.

    <com.paget96.localazycard.LocalazyCard
        android:id="@+id/localazyCard"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        app:localazy_icon="@drawable/ic_localazy"
        app:localazy_invitation_message="@string/localazy_default_invitation_text"
        app:localazy_summary="@string/localazy_default_summary"
        app:localazy_title="@string/localazy_default_title" />

Step 2

(Optional) Add this to your activity if you want language changer feature
override fun attachBaseContext(base: Context) {
        super.attachBaseContext(onAttach(base))
}

Add this to the class which own the xml you set in Step 1

val localazyCard = findViewById<LocalazyCard>(R.id.localazyCard)

// IMPORTANT, define activity for language changing
localazyCard.setActivity(this)

// Set card icon
localazyCard.setIcon(R.drawable.ic_localazy_no_bgd)

// Title text
localazyCard.setTitle(getString(R.string.translate) + " " + getString(R.string.app_name))
localazyCard.setTitleTextSize(18f)
localazyCard.setTitleTextStyle(Typeface.BOLD)

// Summary text
localazyCard.setSummaryText(getString(R.string.summary_text, getString(R.string.app_name)))
localazyCard.setSummaryTextSize(14f)
localazyCard.setSummaryTextStyle(Typeface.NORMAL)

// Open translation link
localazyCard.setTranslateButton()

// Invite to translate
localazyCard.setInviteButton(getString(R.string.invitation_text, getString(R.string.app_name)))
localazyCard.radius = 24f
localazyCard.strokeColor = ContextCompat.getColor(this, R.color.design_default_color_primary)
localazyCard.strokeWidth = 2
localazyCard.elevation = 0f

Step 3 (Strings)

Add this to your strings file (those are default strings if you use configuration from step 2, this can be changed)

<string name="app_name">Localazy-Card</string>

<string name="translate">Translate</string>
<string name="summary_text">Help us to make %1$s app multilingual, translate it to 50+ languages</string>
<string name="invitation_text">I\'m inviting you to help translating %1$s</string>
<string name="this_is_test_1">This is test 1</string>
<string name="this_is_test_2">This is test 2</string>
<string name="this_is_test_3">This is test 3</string>

Step 4 (style)

Since this library is basically an extended view of a MaterialCardView, you can use pretty much the same features as the default material card have

localazyCard.radius = 24f // Set card corner radius
localazyCard.setStrokeColor(ContextCompat.getColor(this, R.color.design_default_color_primary)) // Set stroke color
localazyCard.strokeWidth = 2 // Set stroke width
localazyCard.elevation = 0f // Set card elevation
// And much more

Changelog

1.2 (4-May-2021)

  • Converted code to Kotlin

1.1.1 (4-May-2021)

  • Design overhaul

1.1 (4-May-2021)

  • Updated implementation
  • Changed base functionality
  • Added Localazy library to get and set languages
  • Removed useless parts of the code
  • Set buttons to public, manipulation on them "enabled"
  • Updated card design

1.0.4 (20-Mar-2021)

  • Added feature to change app language directly from the app
  • Updated library code
  • Exported strings

1.0.3 (20-Mar-2021)

  • Added invitation button
  • Slightly updated card view
  • Updated app example

1.0.2 (19-Mar-2021)

  • Added changing text size and style

localazy-card's People

Contributors

kojofosu avatar paget96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.