Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit 33a3e44

Browse files
committed
Add: Started app version checking
1 parent bf59b24 commit 33a3e44

File tree

5 files changed

+83
-122
lines changed

5 files changed

+83
-122
lines changed

app/src/main/java/io/github/tavisco/rvglassistant/fragments/MainFragment.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import permissions.dispatcher.NeedsPermission;
4646
import permissions.dispatcher.OnPermissionDenied;
4747
import permissions.dispatcher.RuntimePermissions;
48+
import io.github.tavisco.rvglassistant.BuildConfig;
4849

4950
/**
5051
* A simple {@link Fragment} subclass.
@@ -59,16 +60,20 @@ public class MainFragment extends Fragment {
5960
// =-=-=-= Bindings =-=-=-=
6061
@BindView(R.id.card_main_updateStatus)
6162
CardView cardUpdate;
62-
@BindView(R.id.tv_main_installedVersion)
63+
@BindView(R.id.tv_main_game_installedVersion)
6364
TextView tvInstalledVersion;
64-
@BindView(R.id.tv_main_lastVersion)
65+
@BindView(R.id.tv_main_game_lastVersion)
6566
TextView tvLastVersion;
6667
@BindView(R.id.tv_main_updateStatus)
6768
TextView tvUpdateStatus;
6869
@BindView(R.id.img_main_updateStatus)
6970
ImageView imgUpdateStatus;
7071
@BindView(R.id.recycler_main_packages)
7172
RecyclerView mRecyclerView;
73+
@BindView(R.id.tv_main_app_installedVersion)
74+
TextView tvAppInstalledVersion;
75+
@BindView(R.id.tv_main_app_lastVersion)
76+
TextView tvAppLastVersion;
7277

7378

7479
// =-=-=-= Recycler =-=-=-=
@@ -129,8 +134,17 @@ public void onDestroy() {
129134

130135
@Override
131136
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
132-
//checkForUpdates();
137+
// checkForUpdates();
133138
MainFragmentPermissionsDispatcher.checkForUpdatesWithPermissionCheck(this);
139+
// createPackagesList();
140+
MainFragmentPermissionsDispatcher.createPackagesListWithPermissionCheck(this);
141+
142+
checkForAppUpdates();
143+
}
144+
145+
private void checkForAppUpdates() {
146+
tvAppInstalledVersion.setText(String.format(getString(R.string.main_installed_version),
147+
BuildConfig.VERSION_NAME));
134148
}
135149

136150
@Override
@@ -140,6 +154,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
140154
MainFragmentPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
141155
}
142156

157+
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
143158
public void createPackagesList() {
144159
//create our ItemAdapter which will host our items
145160
mItemAdapter = new ItemAdapter<>();
@@ -200,7 +215,7 @@ public void checkForUpdates(){
200215
if(activity != null){
201216
cardUpdate.setCardBackgroundColor(getResources().getColor(R.color.cardview_dark_background));
202217
tvUpdateStatus.setText(R.string.main_checking_updates);
203-
tvLastVersion.setText(String.format(getString(R.string.main_last_version), getString(R.string.main_checking)));
218+
tvLastVersion.setText(String.format(getString(R.string.main_game_last_version), getString(R.string.main_checking)));
204219
imgUpdateStatus.setImageDrawable(getResources().getDrawable(R.drawable.ic_cloud_sync));
205220

206221
Context ctx = this.getContext();
@@ -220,8 +235,6 @@ public void checkForUpdates(){
220235
queue.add(stringRequest);
221236
}
222237
}
223-
// Temporarily here 'cause permissions
224-
createPackagesList();
225238
}
226239

227240
public String getLocalGameVersion(){
@@ -276,9 +289,9 @@ public void compareWithLocalVersion(String localVersion, String lastVersion){
276289
}
277290

278291
if (lastVersion.equals("-1")){
279-
tvLastVersion.setText(String.format(getString(R.string.main_last_version), getString(R.string.main_error_getting_last_version)));
292+
tvLastVersion.setText(String.format(getString(R.string.main_game_last_version), getString(R.string.main_error_getting_last_version)));
280293
} else {
281-
tvLastVersion.setText(String.format(getString(R.string.main_last_version), lastVersion));
294+
tvLastVersion.setText(String.format(getString(R.string.main_game_last_version), lastVersion));
282295
}
283296

284297
if (!localVersion.equals("-1") && !lastVersion.equals("-1")){

app/src/main/res/layout/fragment_main.xml

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
android:layout_width="match_parent"
99
android:layout_height="match_parent"
1010
android:orientation="vertical"
11-
android:layout_margin="16dp">
11+
android:layout_margin="8dp">
1212

1313
<android.support.v7.widget.CardView
1414
android:layout_width="match_parent"
@@ -39,15 +39,15 @@
3939
android:layout_width="match_parent"
4040
android:layout_height="wrap_content"
4141
android:orientation="horizontal"
42-
android:weightSum="10"
43-
android:layout_marginTop="16dp">
42+
android:weightSum="12"
43+
android:layout_marginTop="8dp">
4444

4545
<android.support.v7.widget.CardView
4646
android:id="@+id/card_main_updateStatus"
4747
android:layout_width="0dp"
4848
android:layout_height="match_parent"
49-
android:layout_weight="5"
50-
android:layout_marginEnd="16dp">
49+
android:layout_weight="4"
50+
android:layout_marginEnd="8dp">
5151

5252
<LinearLayout
5353
android:layout_width="wrap_content"
@@ -77,29 +77,72 @@
7777
<android.support.v7.widget.CardView
7878
android:layout_width="0dp"
7979
android:layout_height="match_parent"
80-
android:layout_weight="5">
80+
android:layout_weight="4"
81+
android:layout_marginEnd="8dp">
8182

8283
<LinearLayout
8384
android:layout_width="wrap_content"
8485
android:layout_height="wrap_content"
8586
android:orientation="vertical"
8687
android:layout_margin="8dp"
87-
android:layout_gravity="start|center">
88+
android:layout_gravity="start">
8889

8990
<TextView
90-
android:id="@+id/tv_main_installedVersion"
91+
android:id="@+id/tv_main_game_version_title"
9192
android:layout_width="wrap_content"
9293
android:layout_height="wrap_content"
93-
android:text="RVGL Local: ---"/>
94+
android:text="RVGL version"
95+
android:textStyle="bold" />
9496

9597
<TextView
96-
android:id="@+id/tv_main_lastVersion"
98+
android:id="@+id/tv_main_game_installedVersion"
9799
android:layout_width="wrap_content"
98100
android:layout_height="wrap_content"
99-
android:text="RVGL I/O: ---"/>
101+
android:layout_marginTop="2dp"
102+
android:text="Local:\n ---"/>
100103

104+
<TextView
105+
android:id="@+id/tv_main_game_lastVersion"
106+
android:layout_width="wrap_content"
107+
android:layout_height="wrap_content"
108+
android:text="I/O: \n ---"/>
109+
</LinearLayout>
110+
</android.support.v7.widget.CardView>
111+
112+
<android.support.v7.widget.CardView
113+
android:layout_width="0dp"
114+
android:layout_height="match_parent"
115+
android:layout_weight="4">
116+
117+
<LinearLayout
118+
android:layout_width="wrap_content"
119+
android:layout_height="wrap_content"
120+
android:orientation="vertical"
121+
android:layout_margin="8dp"
122+
android:layout_gravity="start">
123+
124+
<TextView
125+
android:id="@+id/tv_main_app_version_title"
126+
android:layout_width="wrap_content"
127+
android:layout_height="wrap_content"
128+
android:text="App version"
129+
android:textStyle="bold" />
130+
131+
<TextView
132+
android:id="@+id/tv_main_app_installedVersion"
133+
android:layout_width="wrap_content"
134+
android:layout_height="wrap_content"
135+
android:layout_marginTop="2dp"
136+
android:text="Local:\n ---"/>
137+
138+
<TextView
139+
android:id="@+id/tv_main_app_lastVersion"
140+
android:layout_width="wrap_content"
141+
android:layout_height="wrap_content"
142+
android:text="Github:\n ---"/>
101143
</LinearLayout>
102144
</android.support.v7.widget.CardView>
145+
103146
</LinearLayout>
104147

105148
<android.support.v7.widget.RecyclerView

app/src/main/res/layout/package_item.xml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
android:id="@+id/card_package"
66
android:layout_width="match_parent"
77
android:layout_height="72dp"
8-
android:layout_margin="8dp"
8+
android:layout_marginTop="8dp"
9+
android:layout_marginStart="8dp"
10+
android:layout_marginEnd="8dp"
911
android:orientation="vertical"
1012
tools:ignore="MissingPrefix">
1113

@@ -20,7 +22,6 @@
2022
android:layout_height="match_parent"
2123
android:orientation="horizontal">
2224

23-
2425
<ImageView
2526
android:id="@+id/img_package_updateStatus"
2627
android:layout_width="45dp"
@@ -82,14 +83,6 @@
8283
app:layout_constraintEnd_toEndOf="parent"
8384
app:layout_constraintTop_toBottomOf="@+id/tv_package_local_version"
8485
tools:text="I/O: 18.0429" />
85-
86-
87-
8886
</android.support.constraint.ConstraintLayout>
89-
90-
91-
92-
93-
9487
</FrameLayout>
9588
</android.support.v7.widget.CardView>

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,7 @@
33
<string name="title_home">Home</string>
44
<string name="title_tracks">Tracks</string>
55
<string name="title_cars">Cars</string>
6-
<string name="hello_blank_fragment">Hello blank fragment</string>
76
<string name="title_activity_track_info">Track Info</string>
8-
<string name="large_text">
9-
"Material is the metaphor.\n\n"
10-
11-
"A material metaphor is the unifying theory of a rationalized space and a system of motion."
12-
"The material is grounded in tactile reality, inspired by the study of paper and ink, yet "
13-
"technologically advanced and open to imagination and magic.\n"
14-
"Surfaces and edges of the material provide visual cues that are grounded in reality. The "
15-
"use of familiar tactile attributes helps users quickly understand affordances. Yet the "
16-
"flexibility of the material creates new affordances that supercede those in the physical "
17-
"world, without breaking the rules of physics.\n"
18-
"The fundamentals of light, surface, and movement are key to conveying how objects move, "
19-
"interact, and exist in space and in relation to each other. Realistic lighting shows "
20-
"seams, divides space, and indicates moving parts.\n\n"
21-
22-
"Bold, graphic, intentional.\n\n"
23-
24-
"The foundational elements of print based design typography, grids, space, scale, color, "
25-
"and use of imagery guide visual treatments. These elements do far more than please the "
26-
"eye. They create hierarchy, meaning, and focus. Deliberate color choices, edge to edge "
27-
"imagery, large scale typography, and intentional white space create a bold and graphic "
28-
"interface that immerse the user in the experience.\n"
29-
"An emphasis on user actions makes core functionality immediately apparent and provides "
30-
"waypoints for the user.\n\n"
31-
32-
"Motion provides meaning.\n\n"
33-
34-
"Motion respects and reinforces the user as the prime mover. Primary user actions are "
35-
"inflection points that initiate motion, transforming the whole design.\n"
36-
"All action takes place in a single environment. Objects are presented to the user without "
37-
"breaking the continuity of experience even as they transform and reorganize.\n"
38-
"Motion is meaningful and appropriate, serving to focus attention and maintain continuity. "
39-
"Feedback is subtle yet clear. Transitions are efficient yet coherent.\n\n"
40-
41-
"3D world.\n\n"
42-
43-
"The material environment is a 3D space, which means all objects have x, y, and z "
44-
"dimensions. The z-axis is perpendicularly aligned to the plane of the display, with the "
45-
"positive z-axis extending towards the viewer. Every sheet of material occupies a single "
46-
"position along the z-axis and has a standard 1dp thickness.\n"
47-
"On the web, the z-axis is used for layering and not for perspective. The 3D world is "
48-
"emulated by manipulating the y-axis.\n\n"
49-
50-
"Light and shadow.\n\n"
51-
52-
"Within the material environment, virtual lights illuminate the scene. Key lights create "
53-
"directional shadows, while ambient light creates soft shadows from all angles.\n"
54-
"Shadows in the material environment are cast by these two light sources. In Android "
55-
"development, shadows occur when light sources are blocked by sheets of material at "
56-
"various positions along the z-axis. On the web, shadows are depicted by manipulating the "
57-
"y-axis only. The following example shows the card with a height of 6dp.\n\n"
58-
59-
"Resting elevation.\n\n"
60-
61-
"All material objects, regardless of size, have a resting elevation, or default elevation "
62-
"that does not change. If an object changes elevation, it should return to its resting "
63-
"elevation as soon as possible.\n\n"
64-
65-
"Component elevations.\n\n"
66-
67-
"The resting elevation for a component type is consistent across apps (e.g., FAB elevation "
68-
"does not vary from 6dp in one app to 16dp in another app).\n"
69-
"Components may have different resting elevations across platforms, depending on the depth "
70-
"of the environment (e.g., TV has a greater depth than mobile or desktop).\n\n"
71-
72-
"Responsive elevation and dynamic elevation offsets.\n\n"
73-
74-
"Some component types have responsive elevation, meaning they change elevation in response "
75-
"to user input (e.g., normal, focused, and pressed) or system events. These elevation "
76-
"changes are consistently implemented using dynamic elevation offsets.\n"
77-
"Dynamic elevation offsets are the goal elevation that a component moves towards, relative "
78-
"to the component’s resting state. They ensure that elevation changes are consistent "
79-
"across actions and component types. For example, all components that lift on press have "
80-
"the same elevation change relative to their resting elevation.\n"
81-
"Once the input event is completed or cancelled, the component will return to its resting "
82-
"elevation.\n\n"
83-
84-
"Avoiding elevation interference.\n\n"
85-
86-
"Components with responsive elevations may encounter other components as they move between "
87-
"their resting elevations and dynamic elevation offsets. Because material cannot pass "
88-
"through other material, components avoid interfering with one another any number of ways, "
89-
"whether on a per component basis or using the entire app layout.\n"
90-
"On a component level, components can move or be removed before they cause interference. "
91-
"For example, a floating action button (FAB) can disappear or move off screen before a "
92-
"user picks up a card, or it can move if a snackbar appears.\n"
93-
"On the layout level, design your app layout to minimize opportunities for interference. "
94-
"For example, position the FAB to one side of stream of a cards so the FAB won’t interfere "
95-
"when a user tries to pick up one of cards.\n\n"
96-
</string>
977
<string name="title_activity_install">Install Custom Content</string>
988
<string name="title_activity_car_info">Car Info</string>
999
<string name="channel_name">RVGL Butler downloads</string>
@@ -107,14 +17,15 @@
10717
<string name="download_speed_kb">%1$s KB/s</string>
10818
<string name="download_speed_mb">%1$s MB/s</string>
10919
<string name="main_checking_updates">Checking for updates…</string>
110-
<string name="main_installed_version">RVGL Local: %s</string>
111-
<string name="main_last_version">RVGL I/O: %1$s</string>
20+
<string name="main_installed_version">Local:\n %s</string>
21+
<string name="main_game_last_version">I/O:\n %1$s</string>
22+
<string name="main_app_last_version">Github:\n %s</string>
11223
<string name="main_checking">Checking…</string>
11324
<string name="main_error_getting_last_version">Oops! Error!</string>
11425
<string name="main_you_are_up_to_date">You are up to date!</string>
11526
<string name="main_update_avaiable">Version %s is avaiable to download! Click here for more info.</string>
11627
<string name="main_is_game_installed">Is the game installed?</string>
117-
<string name="dialog_positive_text">Ok</string>
28+
<string name="dialog_positive_text">OK</string>
11829
<string name="package_local_version">Local: %s</string>
11930
<string name="package_IO_version">I/O: %s</string>
12031
<string name="storage_permission_denied_dialog_title">Storage permission request</string>

last_version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
R18.0819

0 commit comments

Comments
 (0)