Created BottomStatusBar custom view to be reused in various Activities

This commit is contained in:
Severiano Jaramillo 2018-01-24 22:28:53 -06:00
parent 05dc28aa63
commit 45657e414f
2 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,56 @@
package cy.agorise.crystalwallet.util;
import android.content.Context;
import android.support.constraint.ConstraintLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import cy.agorise.crystalwallet.BuildConfig;
import cy.agorise.crystalwallet.R;
/**
* Created by xd on 1/24/18.
* Status bar that shows the app version, block number and connection status
*/
public class BottomStatusBar extends ConstraintLayout{
@BindView(R.id.tvBuildVersion)
TextView tvBuildVersion;
@BindView(R.id.tvBlockNumber)
TextView tvBlockNumber;
@BindView(R.id.ivSocketConnected)
ImageView ivSocketConnected;
public BottomStatusBar(Context context) {
super(context);
init();
}
public BottomStatusBar(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
LayoutInflater inflater = LayoutInflater.from(getContext());
inflater.inflate(R.layout.bottom_status_bar, this);
ButterKnife.bind(this);
// Automatically get build version from app information
String buildVersion = "v";
buildVersion += BuildConfig.VERSION_NAME;
tvBuildVersion.setText(buildVersion);
// TODO update block number
// TODO update socket connection status
}
}

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="35dp"
android:background="@color/bottomBarColor">
<TextView
android:id="@+id/tvBuildVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:text="@string/version_placeholder"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvBlockNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/block_number_placeholder"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/ivSocketConnected"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="8dp"
android:src="@drawable/icon_connecting"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/connection_status" />
</android.support.constraint.ConstraintLayout>