Skip to content

Commit

Permalink
Added version number to main screen
Browse files Browse the repository at this point in the history
Added version number to main screen
  • Loading branch information
valley-fordham authored Jun 20, 2020
2 parents a4d29c1 + f412590 commit c6f4560
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
14 changes: 9 additions & 5 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {
applicationId 'com.glenfordham.carportopener'
minSdkVersion 26
targetSdkVersion 29
versionName '2020.'+gitCommitNumber()
versionName getYear()+'.'+gitCommitNumber()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -28,14 +28,18 @@ static def gitCommitNumber() {
}
}

static def getYear() {
return new Date().format('yyyy')
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.navigation:navigation-fragment:2.2.2'
implementation 'androidx.navigation:navigation-ui:2.2.2'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import androidx.preference.PreferenceManager;

import com.glenfordham.carportopener.BuildConfig;
import com.glenfordham.carportopener.R;
import com.glenfordham.carportopener.carport.DoorManager;
import com.glenfordham.carportopener.carport.DoorStatusService;
Expand All @@ -19,6 +20,7 @@ public class MainScreen extends Activity {

private TextView txtDoorStatus;
private TextView txtTriggerStatus;
private TextView txtVersionNumber;

private DoorManager doorManager = DoorManager.getInstance();

Expand All @@ -31,13 +33,23 @@ public class MainScreen extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

doorManager.setHomeScreen(this);

// Set up configuration
PreferenceManager.setDefaultValues(this, R.xml.root_preferences, false);

// Render screen
setContentView(R.layout.main_activity);
txtTriggerStatus = findViewById(R.id.txt_trigger_status);

ImageView btnSettings = findViewById(R.id.btn_settings);
btnSettings.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainScreen.this, SettingsScreen.class);
startActivity(intent);
}
});

txtDoorStatus = findViewById(R.id.txt_door_status);
doorManager.setHomeScreen(this);

Button btnStartStop = findViewById(R.id.btn_opendoor);
btnStartStop.setOnClickListener(new View.OnClickListener() {
Expand All @@ -47,13 +59,10 @@ public void onClick(View v) {
}
});

ImageView btnSettings = findViewById(R.id.btn_settings);
btnSettings.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(MainScreen.this, SettingsScreen.class);
startActivity(intent);
}
});
txtTriggerStatus = findViewById(R.id.txt_trigger_status);

txtVersionNumber = findViewById(R.id.lbl_version_number);
txtVersionNumber.setText(getString(R.string.gui_version, BuildConfig.VERSION_NAME));

startForegroundService(new Intent(this, DoorStatusService.class));
}
Expand Down
12 changes: 12 additions & 0 deletions mobile/src/main/res/layout-land/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,16 @@
app:layout_constraintRight_toRightOf="@+id/btn_opendoor"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/lbl_version_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#505050"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/txt_trigger_status"
app:layout_constraintTop_toBottomOf="@+id/txt_trigger_status"
app:layout_constraintHorizontal_bias=".75" />

</androidx.constraintlayout.widget.ConstraintLayout>
12 changes: 12 additions & 0 deletions mobile/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,16 @@
app:layout_constraintRight_toRightOf="@+id/btn_opendoor"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/lbl_version_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#505050"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/txt_trigger_status"
app:layout_constraintTop_toBottomOf="@+id/txt_trigger_status"
app:layout_constraintHorizontal_bias=".75" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions mobile/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<string name="gui_settings">Settings</string>
<string name="gui_settings_tooltip">Opens the Settings Screen</string>
<string name="gui_unknown">Unknown</string>
<string name="gui_version">v%1$s</string>

<!-- Toast notifications-->
<string name="toast_fail">Unable to get status of door</string>
Expand Down

0 comments on commit c6f4560

Please sign in to comment.