Skip to content

Commit

Permalink
Added the app's version number to the bottom of the home screen
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Aug 4, 2021
1 parent 974c428 commit 178ba91
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 54 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ are a list of other projects that might be of interest to you.

## Changelog

##### [0.3.0](https://github.com/christianrowlands/android-network-survey-rooted/releases/tag/v0.2.0) - 2021-07-12
##### [0.4.0](https://github.com/christianrowlands/android-network-survey-rooted/releases/tag/v0.4.0) - 2021-08-04
* Added support for logging GSM RR Signaling messages to pcap records.
* Added the version number to the home screen.

##### [0.3.0](https://github.com/christianrowlands/android-network-survey-rooted/releases/tag/v0.3.0) - 2021-07-12
* Added support for logging UMTS NAS and WCDMA RRC messages to pcap records.

##### [0.2.0](https://github.com/christianrowlands/android-network-survey-rooted/releases/tag/v0.2.0) - 2021-01-29
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdkVersion 26
targetSdkVersion 29
versionCode 6
versionName "0.4.0-alpha01"
versionName "0.4.0"
setProperty("archivesBaseName", "$applicationName-$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
Expand Down Expand Up @@ -55,6 +56,10 @@ public View onCreateView(@NonNull LayoutInflater inflater,
recordCount -> binding.tvRecordCount.setText(String.format(Locale.US, "%d", recordCount)));
homeViewModel.getProviderStatus().observe(viewLifecycleOwner, this::updateLocationProviderStatus);

homeViewModel.getAppVersion().observe(viewLifecycleOwner, versionName -> binding.appVersionName.setText(getString(R.string.app_version, versionName)));

setAppVersionNumber();

return binding.getRoot();
}

Expand Down Expand Up @@ -210,4 +215,22 @@ private void updateLocationProviderStatus(ServiceStatusMessage.LocationProviderS
break;
}
}

/**
* Get the app version number and set it at the bottom of the view.
*
* @since 0.4.0
*/
private void setAppVersionNumber()
{
try
{
final Context context = requireContext();
final PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
binding.getVm().setAppVersion(info.versionName);
} catch (Exception e)
{
Timber.wtf(e, "Could not set the app version number");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class HomeViewModel extends ViewModel implements IServiceStatusListener
private final MutableLiveData<Location> location = new MutableLiveData<>();
private final MutableLiveData<Integer> recordCount = new MutableLiveData<>();
private final MutableLiveData<ServiceStatusMessage.LocationProviderStatus> providerStatus = new MutableLiveData<>();
private final MutableLiveData<String> appVersion = new MutableLiveData<>();

public LiveData<Location> getLocation()
{
Expand Down Expand Up @@ -58,4 +59,14 @@ public void onServiceStatusMessage(ServiceStatusMessage serviceMessage)
break;
}
}

public LiveData<String> getAppVersion()
{
return appVersion;
}

public void setAppVersion(String version)
{
appVersion.postValue(version);
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />

Expand Down
118 changes: 67 additions & 51 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
@@ -1,86 +1,102 @@
<layout 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">
xmlns:tools="http://schemas.android.com/tools">

<data>

<variable
name="vm"
type="com.craxiom.networksurveyplus.ui.home.HomeViewModel" />
name="vm"
type="com.craxiom.networksurveyplus.ui.home.HomeViewModel" />
</data>

<androidx.core.widget.NestedScrollView
android:id="@+id/home_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/fragment_padding_top"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".ui.home.HomeFragment">
<LinearLayout
android:id="@+id/home_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="@dimen/fragment_padding_top"
tools:context=".ui.home.HomeFragment">

<androidx.cardview.widget.CardView
android:id="@+id/status_card_view"
style="?attr/cardStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/status_card_view"
style="?attr/cardStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">

<LinearLayout
android:id="@+id/ll_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:id="@+id/ll_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:text="@string/location_placeholder"
android:textAppearance="@style/StatusText" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:text="@string/location_placeholder"
android:textAppearance="@style/StatusText" />

<TextView
android:id="@+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textAppearance="@style/StatusText" />
android:id="@+id/tv_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textAppearance="@style/StatusText" />

</LinearLayout>


<LinearLayout
android:id="@+id/ll_recordCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:id="@+id/ll_recordCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/records_logged_placeholder"
android:textAppearance="@style/StatusText" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/records_logged_placeholder"
android:textAppearance="@style/StatusText" />

<TextView
android:id="@+id/tv_recordCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/StatusText" />
android:id="@+id/tv_recordCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/StatusText" />

</LinearLayout>

</LinearLayout>

</androidx.cardview.widget.CardView>

</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:gravity="bottom"
android:orientation="vertical">

<TextView
android:id="@+id/app_version_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="" />

</LinearLayout>

</LinearLayout>

</layout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<string name="title_settings">Settings</string>
<string name="title_mqtt">MQTT</string>

<string name="app_version">v%1$s</string>

<string name="permissions_rationale_title">Network Survey+ Permissions</string>
<string name="permissions_rationale">The Network Survey+ app requires a couple permissions to work. Denying these permissions will result in the app not functioning properly.
\n\n1. <b>Access this Device\'s Location</b>: This app creates a log file which includes the location at which the cellular record was captured.
Expand Down

0 comments on commit 178ba91

Please sign in to comment.