Skip to content

Fixes #4589 :- The empty screen while no images found in custom picture selector #4858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Rishavgupta12345
Copy link
Contributor

The empty screen while no images found in custom picture selector #4589 is fixed now

@codecov
Copy link

codecov bot commented Feb 25, 2022

Codecov Report

Merging #4858 (2d207a1) into master (87b9648) will decrease coverage by 0.11%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4858      +/-   ##
============================================
- Coverage     50.66%   50.54%   -0.12%     
+ Complexity     2231     2223       -8     
============================================
  Files           338      338              
  Lines         15531    15552      +21     
  Branches       1358     1361       +3     
============================================
- Hits           7869     7861       -8     
- Misses         7079     7104      +25     
- Partials        583      587       +4     
Impacted Files Coverage Δ
...ommons/customselector/ui/selector/ImageFragment.kt 54.54% <0.00%> (-5.46%) ⬇️
.../nrw/commons/category/CategoryContentProvider.java 12.50% <0.00%> (-14.29%) ⬇️
...ree/nrw/commons/contributions/ContributionDao.java 6.25% <0.00%> (-12.50%) ⬇️
...w/commons/upload/categories/BaseDelegateAdapter.kt 35.29% <0.00%> (-11.77%) ⬇️
...commons/contributions/ContributionsRepository.java 41.66% <0.00%> (-8.34%) ⬇️
...ns/contributions/ContributionsLocalDataSource.java 16.66% <0.00%> (-4.17%) ⬇️
...r/free/nrw/commons/explore/media/MediaConverter.kt 92.85% <0.00%> (-2.39%) ⬇️
...va/fr/free/nrw/commons/category/CategoriesModel.kt 57.62% <0.00%> (-1.70%) ⬇️
...ns/upload/categories/UploadCategoriesFragment.java 86.95% <0.00%> (-1.45%) ⬇️
.../commons/contributions/ContributionViewHolder.java 79.16% <0.00%> (-0.48%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 87b9648...2d207a1. Read the comment docs.

Copy link
Contributor

@4D17Y4 4D17Y4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested it and it works.
But I don't think this is the best way to handle such exceptions. It would be better if the logic is added in folder and image fragments. There is a handleResult function in both fragments which could be all you need.

Let me know if you think otherwise.

val lastOpenFolderId: Long = prefs.getLong(FOLDER_ID, 0L)
val lastOpenFolderName: String? = prefs.getString(FOLDER_NAME, null)
val lastItemId: Long = prefs.getLong(ITEM_ID, 0)
lastOpenFolderName?.let { onFolderClick(lastOpenFolderId, it, lastItemId) }
}

if(isImageGalleryEmpty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment for this if statement, similar to the one above.
Indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

/**
* Checks for no image in gallery.
*/
private fun isImageGalleryEmpty(): Boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be only 4 spaces before private (same number as before /**).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay got it

app:layout_constraintHorizontal_bias="0.66"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/fragment_container"
app:layout_constraintVertical_bias="0.481"></LinearLayout>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use /> when element is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
val linearLayout: LinearLayout = findViewById<View>(R.id.linear_layout_noimage) as LinearLayout
val textView = TextView(this)
textView.text = "No Image Found"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use string localization for the text.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can I translate this string to all possible languages, translation is done by other capable contributors, creating other issues in the repo , and moreover not all the strings have been localized yet , its still in progress

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check how localization is done in other parts of the app. It is the standard Android way, so if you are not familiar with it I recommend doing a tutorial to get the idea. If you find strings in the app UI that are not localized, please create an issue to flag them, thanks a lot! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-raoul I have seen youtube tutorial which says that I have to manually translate the text in all the different languages by searching in google translator , but there is no automatic translation feature so it will be a very hectic task to manually translate in all languages

Copy link
Contributor Author

@Rishavgupta12345 Rishavgupta12345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
val linearLayout: LinearLayout = findViewById<View>(R.id.linear_layout_noimage) as LinearLayout
val textView = TextView(this)
textView.text = "No Image Found"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check how localization is done in other parts of the app. It is the standard Android way, so if you are not familiar with it I recommend doing a tutorial to get the idea. If you find strings in the app UI that are not localized, please create an issue to flag them, thanks a lot! :-)

Copy link
Contributor Author

@Rishavgupta12345 Rishavgupta12345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
val linearLayout: LinearLayout = findViewById<View>(R.id.linear_layout_noimage) as LinearLayout
val textView = TextView(this)
textView.text = "No Image Found"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-raoul I have seen youtube tutorial which says that I have to manually translate the text in all the different languages by searching in google translator , but there is no automatic translation feature so it will be a very hectic task to manually translate in all languages

/**
* Checks for no image in gallery.
*/
private fun isImageGalleryEmpty(): Boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay got it

@4D17Y4
Copy link
Contributor

4D17Y4 commented Feb 26, 2022

Just tested it and it works. But I don't think this is the best way to handle such exceptions. It would be better if the logic is added in folder and image fragments. There is a handleResult function in both fragments which could be all you need.

Let me know if you think otherwise.

@Rishavgupta12345

@Rishavgupta12345
Copy link
Contributor Author

Rishavgupta12345 commented Feb 27, 2022

Just tested it and it works. But I don't think this is the best way to handle such exceptions. It would be better if the logic is added in folder and image fragments. There is a handleResult function in both fragments which could be all you need.
Let me know if you think otherwise.

@Rishavgupta12345

@4D17Y4 @nicolas-raoul done in a simpler way as you have said me to do, also the localization issue is also solved.🙂

Copy link
Contributor

@4D17Y4 4D17Y4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on Image fragment.
Image fragment is the one you see when you tap on a specific folder in custom selector. We can do this same thing in folder fragment in case there are no folders.


<LinearLayout
android:id="@+id/linear_layout_noimage"
android:layout_width="204dp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not hardcode the values. As android screens have varied dimensions it might not look perfect on some screen sizes. Instead you can use match_parent or wrap_content that way the layout adjusts depending on the screen size.


<TextView
android:id="@+id/no_images_found"
android:layout_width="172dp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hardcoded values.

@Rishavgupta12345
Copy link
Contributor Author

a problem occured in this brach so I am closing this pull request and creating a fresh one , Sorry for the Inconvenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants