Skip to content

Commit

Permalink
Adds demo image and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
blongho committed Jul 26, 2019
1 parent aec5085 commit fcea127
Show file tree
Hide file tree
Showing 46 changed files with 529 additions and 5,868 deletions.
114 changes: 114 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
**May 13 2019 : v1.2.0**

Stable release of v1.2.0-beta

---

**May 11 2019 : v1.2.0-beta**

Do you want to know the most populated country in the world or the smallest country of the world or you are planning on a vacation and you want to know the main city (capital city)?

In this release, you are now able to do the following

- get the country population
- get the capital city of the country
- get the surface area of the country
- get the continent of a country

==> Check the java documentation for more https://blongho.github.io/world-country-data/doc/

This is a pre-release, it has not been thoroughly tested. Report any bugs by creating an issue

In the future release, it will be possible to get the cities (all major cities) of any country and more more...

**Mar 14 2019: v1.1.0**

Changes made

1. Changed library package from `countryFlags` to `country_data`.
The latter better conveys the information contained in the library.
The former had only country flags as extra information apart from the
country identifiers. This version and upcoming versions will have more
information about a country.
2. Cleaned code base and improve documentation
The current version have the currency for each country. Subsequent
versions will have more country data
---

**Mar 11 2019: v1.1-beta**

It is now possible to get the list of currencies of the world
```java
World.init(getApplicationContext()); // initialize data
List<Currency> currencies = World.getAllCurrencies()
// Currency [country=NZ, name=New Zealand Dollars, code=NZD, symbol=$]
```
---
**Mar 8 2019: v1.1-alpha**

In this release, one a Country also has a Currency

Get the currency from a country by calling
```java
World.init(getApplicationContext());
Country cameroon = World.getCountryFrom("cm");
Currency curr = cameroon.getCurrency();
```
---

**Mar 5 2019 : v1.0**

This release is provides a more intuitive interface for the user.

Major changes include:

1. Removal of ability of user to create a country in their app.
In real world, countries are not created like that.

2. To get a country, a user has to know any of the four identifiers of the country

The country name eg Sweden

The country numeric code eg 752

The alpha2 of the country eg "se"

The alpha3 of the country eg "swe"

With these, Sweden can be created alongside its flag using

```java
World.init(getApplicationContext());
// you call this just once in your program. It wraps a singleton
// that initializes everything that the library is to offer
Country sweden = World.getCountryFrom("sweden"|"se"|"swe"|752);
```
4. To get the flag of a country, the user needs any of the identifiers mensioned in 2 above, then using two methods
```java
World.init(getApplicationContext());
final int swedishFlag = World.getFlagOf("sweden"|"se"|"swe"|752);
```
5. If you are interested in all the countries of the world
```java
World.init(getApplicationContext());
final List<Country> countries = World.getAllCountries();
// This list cannot be modified by adding, sorting or removing an element.
// You can only retrieve information therein
```
NB: All Country identifiers have getters so you can use that to retrieve a Country
from `List<Country> countries`
Give a star to the repository to get updates of new features.

---
**Feb 28 2019 : v0.1.1**
In this release, you can now get all the countries of the world and their flags by calling
```java
CountryFlag.getInstance(getApplicationContext()); // loads the countries and flags

final List<Country> countryList = CountryFlag.allCountriesAndFlags(); // all country list
```
Enjoy

---
**Feb 27 2019: v0.1.0**
* Get counry flag using country code or country name
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# World Country flags, currency and more - an open source android library for getting country flags and other country attributes
[![](https://jitpack.io/v/blongho/world-country-data.svg)](https://jitpack.io/#blongho/world-country-data)

An Android library that contains 'all' the flags of the countries of the world
This is to be used for android projects where the developer is interested in
getting the flag of a particular country for any reason.
An Android library that contains 'all' the flags of the countries of the world.
This can be used for android projects where the developer is interested in
getting the flag of a particular country for any reason (e.g for nationality, language, etc)

- A flag is obtained as a drawable resource (int).
- A flag can be set to an ImageView using XML
- There is possibility to get all the countries and their flags by invoking just two methods.

In addition, other country attributes like population, capital, currency, are provided.
---

## System requirement
- Android minSDKversion = 15
- Android targetSDKversion = 28

---

## Usage
Expand Down Expand Up @@ -129,9 +128,9 @@ final List<Country> countries = World.getAllCountries();

- Live demo

![Demonstrating dynamic retrieval of country flags](https://github.com/blongho/world-country-flag-demo/blob/master/world-country-flag-demo.gif)
![Demonstrating dynamic retrieval of country flags](world-country-data-demo.gif)

- Get the source code for the demo from [world country flag demo](https://github.com/blongho/world-country-flag-demo)
- Get the source code for the demo from [world country flag demo](app/))

---

Expand Down
24 changes: 17 additions & 7 deletions app/src/main/java/com/blongho/contryflagtest/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author Bernard Che Longho <blongho02@gmail.com>
* @brief Demonstration of com.blongho.world-country-data library
* @since March 23rd 2019
* @since 2019-07-26
*/
package com.blongho.contryflagtest;

Expand All @@ -40,6 +40,8 @@
import com.blongho.country_data.Currency;
import com.blongho.country_data.World;
import com.google.android.material.textfield.TextInputEditText;
import java.text.NumberFormat;
import java.util.Locale;

public class MainActivity extends AppCompatActivity {

Expand All @@ -50,6 +52,7 @@ public class MainActivity extends AppCompatActivity {
private TextView alpha3; // the country iso alpha3
private TextView code; // the country numeric code
private TextView currency; // the currency of the country
private TextView capital, area, population, continent;
private String entered; // the value entered by the user
private Country country;

Expand Down Expand Up @@ -84,7 +87,10 @@ protected void onCreate(Bundle savedInstanceState) {
alpha3 = (TextView) findViewById(R.id.alpha3);
code = (TextView) findViewById(R.id.numericCode);
currency = (TextView) findViewById(R.id.currency);

area = (TextView) findViewById(R.id.area);
population = (TextView) findViewById(R.id.population);
capital = (TextView) findViewById(R.id.capital);
continent = (TextView) findViewById(R.id.continent);
identifier.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(
Expand All @@ -95,7 +101,7 @@ public void beforeTextChanged(
@Override
public void onTextChanged(
final CharSequence s, final int start, final int before, final int count) {
entered = String.valueOf(s);
entered = String.valueOf(s).trim();
}

@SuppressLint("SetTextI18n")
Expand All @@ -109,10 +115,14 @@ public void afterTextChanged(final Editable s) {

// See what a country object is
if (country.getFlagResource() != World.getWorldFlag()) {
countryName.setText("Name: " + country.getName());
alpha2.setText("Alpha2: " + country.getAlpha2());
alpha3.setText("Alpha3: " + country.getAlpha3());
code.setText("Code: " + country.getId());
countryName.setText(country.getName());
alpha2.setText(country.getAlpha2());
alpha3.setText(country.getAlpha3());
code.setText(country.getId());
area.setText(NumberFormat.getInstance(Locale.getDefault()).format(country.getArea()) + " sq. km");
capital.setText(country.getCapital());
population.setText(NumberFormat.getInstance(Locale.getDefault()).format(country.getPopulation()));
continent.setText(country.getContinent().toUpperCase());
final Currency curr = country.getCurrency();
if (curr != null) {
currency.setText("Currency: " + curr.toString());
Expand Down
147 changes: 116 additions & 31 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ MIT License
~
~ Copyright (c) 2019 Bernard Che Longho
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
-->

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand Down Expand Up @@ -48,45 +72,106 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textInputLayout"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
style="@style/layout_linear_horizontal">
<TextView
style="@style/textViewStyle"
android:text="@string/numericCode"/>
<TextView
android:id="@+id/numericCode"
style="@style/textViewStyle"/>
</LinearLayout>

<TextView
android:id="@+id/numericCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/numericCode"/>

<TextView
android:id="@+id/countryName"
style="@style/textViewStyle"
android:text="@string/countryName"/>

<TextView
android:id="@+id/alpha3"
style="@style/textViewStyle"
android:text="@string/alpha3"/>

<TextView
android:id="@+id/alpha2"
style="@style/textViewStyle"
android:text="@string/alpha2"/>

<TextView
android:id="@+id/currency"
style="@style/textViewStyle"
android:text="@string/currency"/>
<LinearLayout style="@style/layout_linear_horizontal">
<TextView
style="@style/textViewStyle"
android:text="@string/countryName"/>
<TextView
android:id="@+id/countryName"
style="@style/textViewStyle"/>
</LinearLayout>

<LinearLayout style="@style/layout_linear_horizontal">
<TextView
style="@style/textViewStyle"
android:text="@string/alpha3"/>
<TextView
android:id="@+id/alpha3"
style="@style/textViewStyle"/>
</LinearLayout>

<LinearLayout style="@style/layout_linear_horizontal">
<TextView

style="@style/textViewStyle"
android:text="@string/alpha2"/>
<TextView
android:id="@+id/alpha2"
style="@style/textViewStyle"/>
</LinearLayout>
<LinearLayout style="@style/layout_linear_horizontal">
<TextView
style="@style/textViewStyle"
android:text="@string/capital"/>
<TextView
android:id="@+id/capital"
style="@style/textViewStyle"
/>
</LinearLayout>
<LinearLayout style="@style/layout_linear_horizontal">
<TextView
style="@style/textViewStyle"
android:text="@string/population"/>
<TextView
android:id="@+id/population"
style="@style/textViewStyle"
/>
</LinearLayout>

<LinearLayout style="@style/layout_linear_horizontal">

<TextView
style="@style/textViewStyle"
android:text="@string/area"/>

<TextView
android:id="@+id/area"
style="@style/textViewStyle"
/>
</LinearLayout>
<LinearLayout style="@style/layout_linear_horizontal">

<TextView
style="@style/textViewStyle"
android:text="@string/continent"/>

<TextView
android:id="@+id/continent"
style="@style/textViewStyle"
/>
</LinearLayout>

<LinearLayout style="@style/layout_linear_horizontal">
<TextView
style="@style/textViewStyle"
android:text="@string/currency"/>
<TextView
android:id="@+id/currency"
style="@style/textViewStyle"
/>
</LinearLayout>

</LinearLayout>

<ImageView
android:id="@+id/flag"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="@dimen/view_padding"
android:layout_marginStart="@dimen/view_padding"
android:layout_marginEnd="@dimen/view_padding"
android:layout_marginLeft="@dimen/view_padding"
android:layout_marginRight="@dimen/view_padding"
android:contentDescription="@string/demo_image"
android:src="@drawable/cm"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
Loading

0 comments on commit fcea127

Please sign in to comment.