Skip to content

Commit 2af57fc

Browse files
Rulinomaskaravivek
authored andcommitted
Empty screen if no upload fix (#1940)
* Updated contribution screen to show message for no uploads by default, message gets wiped after any picture is inserted into the list * Changed string as suggested * Added margin
1 parent 6bee914 commit 2af57fc

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
256256
((CursorAdapter) contributionsList.getAdapter()).swapCursor(cursor);
257257
}
258258

259+
if(contributionsList.getAdapter().getCount()>0){
260+
contributionsList.changeEmptyScreen(false);
261+
}
259262
contributionsList.clearSyncMessage();
260263
notifyAndMigrateDataSetObservers();
261264
}

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment {
4747
TextView waitingMessage;
4848
@BindView(R.id.loadingContributionsProgressBar)
4949
ProgressBar progressBar;
50+
@BindView(R.id.noDataYet)
51+
TextView noDataYet;
5052

5153
@Inject
5254
@Named("prefs")
@@ -79,6 +81,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
7981
waitingMessage.setVisibility(GONE);
8082
}
8183

84+
changeEmptyScreen(true);
8285
changeProgressBarVisibility(true);
8386
return v;
8487
}
@@ -95,6 +98,10 @@ public void setAdapter(ListAdapter adapter) {
9598
}
9699
}
97100

101+
public void changeEmptyScreen(boolean isEmpty){
102+
this.noDataYet.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
103+
}
104+
98105
public void changeProgressBarVisibility(boolean isVisible) {
99106
this.progressBar.setVisibility(isVisible ? View.VISIBLE : View.GONE);
100107
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
android:background="?attr/mainBackground"
88
>
99

10+
<TextView
11+
android:id="@+id/noDataYet"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:text="@string/no_uploads"
15+
android:gravity="center"
16+
android:layout_centerInParent="true"
17+
android:visibility="gone"
18+
android:layout_marginRight="@dimen/tiny_gap"
19+
android:layout_marginEnd="@dimen/tiny_gap"
20+
/>
21+
1022
<TextView
1123
android:layout_width="wrap_content"
1224
android:layout_height="wrap_content"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,6 @@
358358
<string name="write_storage_permission_rationale_for_image_share">We need your permission to access the external storage of your device in order to upload images.</string>
359359

360360
<string name="log_collection_started">Log collection started. Please RESTART the app, perform action that you wish to log, and then tap \'Send Logs\' again</string>
361+
<string name="no_uploads">Welcome to Commons!\n
362+
Upload your first media by touching the camera or gallery icon above.</string>
361363
</resources>

0 commit comments

Comments
 (0)