Showing posts with label library. Show all posts

How to custom fonts to Views - Android


In this article, we will learn how to apply custom fonts to Views in Android like Toolbar, MenuItem apart from the views like TextView, EditText.

FontUtils:

FontUtils is a tiny font utility library used to apply custom fonts to Views. It supports the following views.
  • Toolbar
  • NavigationView
  • Menu
  • Submenu
  • Other Views like EditText, TextView, etc.
This library is support the following Languages.
  • Android – Java
  • Android – Kotlin
  • Android

Coding Part:

Steps:

I have split this part into 3 steps as in the following.
Step 1: Creating New Project with Empty Activity.
Step 2: Setting up the Library for Android Views.
Step 3: Applying Custom fonts to Android Views.

Step 1:Creating New Project with Empty Activity

  1. Open Android Studio and Select Create new project.
  2. Name the project as your wish and select Empty activity.
  3. Click “finish” button to create new project in Android Studio.

Step 2:Setting up the Library for Android Views

In this part, we will see how to setup the library for the project.
  1. Open your app level build.gradle file and add the following lines to download the library.
    …
    implementation 'com.ajts.androidmads.fontutils:fontutils:1.0.1'
    …
    
  2. Then Click “Sync Now” to download the library.
  3. We need to use “compile” instead of “implementation” if we have using Android Studio Version below 3.0.

Step 3:Applying Custom fonts to Android Views

In this part, we will see how to apply custom fonts to Views. Here, we have to use “Typeface” and to more about “TypeFace” Click here.
  1. In this article, I am assigning the fonts from Assets folder. To create assets folder, right on the app folder and select New. Then select Folder and click assets folder.
  2. Then Copy and Paste the fonts you want to use with your application.
  3. The following line shows how to initialize the library.
    // Applying Custom Font
    Typeface typeface = Typeface.createFromAsset(getAssets(), "custom_font.ttf");
    // Init Library
    FontUtils fontUtils = new FontUtils();
  4. Then Initialize your Views and apply the fonts to the Views. The following example shows how to apply the fonts to Toolbar of your application.
    // Apply font to Toolbar
    fontUtils.applyFontToToolbar(toolbar, typeface);
  5. You can apply custom fonts to other views like NavigationView, Menu, Submenu, TextView like in following example.
    // Apply font to NavigationView
    fontUtils.applyFontToNavigationView(navigationView, typeface);
    // Apply font to Menu
    fontUtils.applyFontToMenu(menu, typeface);
    // Apply font to Other Views like TextView...
    fontUtils.applyFontToView(textview, typeface);
    fontUtils.applyFontToView(editText, typeface);
    fontUtils.applyFontToView(radioButton, typeface);
    fontUtils.applyFontToView(checkBox, typeface);

For Kotlin

We need to do the same steps mentioned. But we need to include Kotlin support while creating the project. Apply font to Views in Kotlin as show below.
// Applying Custom Font
val typeface = Typeface.createFromAsset(assets, "custom_font.ttf")
// Init Library
val fontUtils = FontUtils()
// Apply font to Toolbar
fontUtils.applyFontToToolbar(toolbar, typeface)
// Apply font to NavigationView
fontUtils.applyFontToNavigationView(navigationView, typeface)
// Apply font to Menu
fontUtils.applyFontToMenu(menu, typeface)
// Apply font to Other Views like TextView...
fontUtils.applyFontToView(textview, typeface)
fontUtils.applyFontToView(editText, typeface)
fontUtils.applyFontToView(radioButton, typeface)
fontUtils.applyFontToView(checkBox, typeface)

For Xamarin.Android

We can apply the same with Xamarin.Android. To know more Click Here.


Download Code

The article is informative do like and star the repo in GitHub. You can download the code here.
Note:
Java and Kotlin Android Support
https://github.com/androidmads/FontUtils
Xamarin.Android Support
https://github.com/Xamarin-Gists/XAFontUtilsLibrary
Youtube Video link to mp3 file

Youtube Video link to mp3 file

It is a light weight library to download YouTube video as mp3 files

Created By

API

How to Download

Gradle:
compile 'com.ajts.androidmads.youtubemp3:youtubemp3:1.0.0'
Maven:
<dependency>
  <groupId>com.ajts.androidmads.youtubemp3</groupId>
  <artifactId>youtubemp3</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

How to use this Library:

This Library is used to download mp3 file from youtube video link.
new YTubeMp3Service.Builder(MainActivity.this)
    .setDownloadUrl("https://youtu.be/nZDGC-tXCo0")
    .setFolderPath(new File(Environment.getExternalStorageDirectory(), "/YTMp3/Downloads").getPath())
    .setOnDownloadListener(new YTubeMp3Service.Builder.DownloadListener() {
        @Override
        public void onSuccess(String savedPath) {
            Log.v("exce", savedPath);
            progressDialog.dismiss();
        }

        @Override
        public void onDownloadStarted() {
        }

        @Override
        public void onError(Exception e) {
            Log.v("exce", e.getMessage());
            progressDialog.dismiss();
        }
    }).build();

Download From Github

SQLite Importer Exporter - Library


A light weight library for exporting and importing sqlite database in android

Created By

API

How to Download

Gradle:
compile 'com.ajts.androidmads.sqliteimpex:library:1.0.0'
Maven:
<dependency>
  <groupId>com.ajts.androidmads.sqliteimpex</groupId>
  <artifactId>library</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

How to use this Library:

This Library is used to import SQLite Database from Assets or External path and Export/Backup SQLite Database to external path.
SQLiteImporterExporter sqLiteImporterExporter = new SQLiteImporterExporter(getApplicationContext(), db);

// Listeners for Import and Export DB
sqLiteImporterExporter.setOnImportListener(new SQLiteImporterExporter.ImportListener() {
    @Override
    public void onSuccess(String message) {
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onFailure(Exception exception) {
        Toast.makeText(getApplicationContext(), exception.getMessage(), Toast.LENGTH_SHORT).show();
    }
});

sqLiteImporterExporter.setOnExportListener(new SQLiteImporterExporter.ExportListener() {
    @Override
    public void onSuccess(String message) {
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onFailure(Exception exception) {
        Toast.makeText(getApplicationContext(), exception.getMessage(), Toast.LENGTH_SHORT).show();
    }
});

To Import SQLite from Assets

try {
    sqLiteImporterExporter.importDataBaseFromAssets();
} catch (Exception e) {
    e.printStackTrace();
}

To import from external storage

try {
    sqLiteImporterExporter.importDataBase(path);
} catch (Exception e) {
    e.printStackTrace();
}

To export to external storage

try {
    sqLiteImporterExporter.exportDataBase(path);
} catch (Exception e) {
    e.printStackTrace();
}

Download From Github

SQLiteToExcel v1.0.1

SQLite2Excel
This is a Light weight Library to Convert SQLite Database to Excel and Convert Excel to SQLite. I have already released version 1.0.0. It is suitable to export SQLite Database to Excel. But, In version 1.0.1 I have Included following features

Features

  1. Added Functionality to Import Excel into SQLite Database.
  2. Added Functionality to Export Blob into Image.
  3. Added Functionality to Export List of tables specified.

Sample App

The sample app in the repository is available on Google Play:
Get it on Google Play

How to Download

Add the following library in your app level gradle file
compile 'com.ajts.androidmads.SQLite2Excel:library:1.0.1'

How to Use

Add Permission to Read External Storage in AndriodManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Export SQLite to Excel

This line is used to save the exported file in default location.
SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db");
This line is used to save the exported file in used preferred location.
SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db", directory_path);
This code snippet is used to Export a single table in a database to Excel Sheet
sqliteToExcel.exportSingleTable("table1", "table1.xls", new SQLiteToExcel.ExportListener() {
     @Override
     public void onStart() {

     }
     @Override
     public void onCompleted(String filePath) {

     }
     @Override
     public void onError(Exception e) {

     }
});
This following code snippet is used to Export a list of table in a database to Excel Sheet
sqliteToExcel.exportSpecificTables(tablesList, "table1.xls", new SQLiteToExcel.ExportListener() {
     @Override
     public void onStart() {

     }
     @Override
     public void onCompleted(String filePath) {

     }
     @Override
     public void onError(Exception e) {

     }
});
This code snippet is used to Export a every table in a database to Excel Sheet
sqliteToExcel.exportAllTables("table1.xls", new SQLiteToExcel.ExportListener() {
     @Override
     public void onStart() {

     }
     @Override
     public void onCompleted(String filePath) {

     }
     @Override
     public void onError(Exception e) {

     }
});

Import Excel into Database

The following snippet is used to initialize the library for Importing Excel
ExcelToSQLite excelToSQLite = new ExcelToSQLite(getApplicationContext(), "helloworld.db");
The following code is used to Import Excel from Assets
excelToSQLite.importFromAsset("assetFileName.xls", new ExcelToSQLite.ImportListener() {
    @Override
    public void onStart() {

    }

    @Override
    public void onCompleted(String dbName) {

    }

    @Override
    public void onError(Exception e) {

    }
});
The following code is used to Import Excel from user directory
excelToSQLite.importFromAsset(directory_path, new ExcelToSQLite.ImportListener() {
    @Override
    public void onStart() {

    }

    @Override
    public void onCompleted(String dbName) {

    }

    @Override
    public void onError(Exception e) {

    }
});
Please Visit the Wiki Link for full Guidance on SQLite2XL(v1.0.1).

Github Wiki Link

You can Download Full source code from Github. If you Like this library, Please star it in Github.

Github Link for Repo

SQLiteToExcel - v1.0.0

SQLite2Excel
SQLiteToExcel is a Light weight Library to Convert SQLite Database to Excel. I have Released Newer Version for this Library. If your Requirement is only to export your SQLite Database, then this library is very much suitable. Otherwise you requirement is to import or export excel to db or vice-versa, then you go for my newer release. Please visit here to see about SQLite2XL Version 1.0.1

How to Download

add the following library in your app level gradle file
compile 'com.ajts.androidmads.SQLite2Excel:library:1.0.0'

How to Use

1.AndroidManifest.xml
Add the following line in your Manifest file
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
2.Library Initialization 
This line is used to save the exported file in default location.
SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db");
This line is used to save the exported file in used preferred location.
SqliteToExcel sqliteToExcel = new SqliteToExcel(this, "helloworld.db", directory_path);
3.Export DB to Excel 
This code snippet is used to Export a single table in a database to Excel Sheet
sqliteToExcel.startExportSingleTable("table1", "table1.xls", new ExportListener() {
   
 @Override
 public void onStart() {
  
 }
   
 @Override
 public void onError() {
  
 }
   
 @Override
 public void onComplete() {
  
 }
});
This code snippet is used to Export a every table in a database to Excel Sheet
sqliteToExcel.startExportAllTables("helloworlddb.xls", new ExportListener() {
   
 @Override
 public void onStart() {
  
 }
   
 @Override
 public void onError() {
  
 }
   
 @Override
 public void onComplete() {
  
 }
});
Please Visit the Wiki Link for full Guidance on SQLite2XL(v1.0.0). If you Like this library, Please star it in Github.

Github Wiki Link

QR-Code Generator - Library

QR-CODE  GENERATOR - Library
In this Post, I introduce my new Gradle Library. This Library is used to Generate QR Code Automatically for our specified input.
How to Import the Library:
Gradle:
compile 'androidmads.library.qrgenearator:QRGenearator:1.0.0'
Permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
How to use this Library:
After importing this library, use the following lines to use this library. The following lines are used to generated the QR Code
// Initializing the QR Encoder with your value to be encoded, type you required and Dimension
QRGEncoder qrgEncoder = new QRGEncoder(inputValue, null, QRGContents.Type.TEXT, smallerDimension);
try {
  // Getting QR-Code as Bitmap
  bitmap = qrgEncoder.encodeAsBitmap();
  // Setting Bitmap to ImageView
  qrImage.setImageBitmap(bitmap);
} catch (WriterException e) {
  Log.v(TAG, e.toString());
}
Save QR Code as Image
// Save with location, value, bitmap returned and type of Image(JPG/PNG).
QRGSaver.save(savePath, edtValue.getText().toString().trim(), bitmap, QRGContents.ImageType.IMAGE_JPEG);
For more Details Visit Here
Github Link:
Open Github
Leave Comment about this Library.

Automatic Update Checker for Android - Library

Automatic Update Checker for Android - Library

Featured In 
Android Arsenal-UpdateHandler
Created By

How to use this Library:

Gradle: 
compile 'androidmads.updatehandler:updatehandler:1.0.3'
Maven:
<dependency>
  <groupId>androidmads.updatehandler</groupId>
  <artifactId>updatehandler</artifactId>
  <version>1.0.3</version>
  <type>pom</type>
</dependency>
How to use this Library: 
After importing this library, use the following lines to check version update for your application automatically.
/** 
* This library works in release mode only with the same JKS key used for 
* your Previous Version
*/
UpdateHandler updateHandler = new UpdateHandler(MainActivity.this);
// to start version checker
updateHandler.start();
// prompting intervals
updateHandler.setCount(2);
// to print new features added automatically
updateHandler.setWhatsNew(true);
// to enable or show default dialog prompt for version update
updateHandler.showDefaultAlert(true);
// listener for custom update prompt
updateHandler.setOnUpdateListener(new UpdateListener() {
    @Override
    public void onUpdateFound(boolean newVersion, String whatsNew) {
        Log.v("Update", String.valueOf(newVersion));
        Log.v("Update", whatsNew);
    }
});

Demo:
Alert Without What' New


Alert With What' New


Update Prompt with Custom Listener