Skip to content

Commit

Permalink
Added version label text
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogeniola committed Jan 25, 2022
1 parent 44c8589 commit 4eacda5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ android {
targetSdkVersion 30
versionCode 8
versionName "0.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/albertogeniola/merossconf/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.Menu;
Expand Down Expand Up @@ -55,6 +57,14 @@ protected void onCreate(Bundle savedInstanceState) {
final NavigationView navigationView = findViewById(R.id.nav_view);
mPairMenuItem = navigationView.getMenu().findItem(R.id.pair_activity);
mDeviceMenuItem = navigationView.getMenu().findItem(R.id.devices_fragment);
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);
String version = pInfo.versionName;
((TextView)navigationView.getHeaderView(0).findViewById(R.id.appVersionTextView)).setText("v"+version);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}


// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
Expand Down
28 changes: 22 additions & 6 deletions app/src/main/res/layout/nav_header_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@
android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/nav_header_desc"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher_round" />
android:orientation="horizontal">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:contentDescription="@string/nav_header_desc"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher_round" />

<TextView
android:id="@+id/appVersionTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:text="X.X.X" />
</LinearLayout>

<TextView
android:id="@+id/navigation_header_http_endpoint_textview"
Expand Down

0 comments on commit 4eacda5

Please sign in to comment.