Skip to content

Commit

Permalink
add no image hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mr committed Jan 21, 2023
1 parent 15e3d00 commit 38adf73
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/src/main/java/com/maary/shareas/HistoryActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,22 @@ class HistoryActivity : AppCompatActivity(){
}
}

@OptIn(DelicateCoroutinesApi::class)
private fun showImages() {
viewModel.loadImages()
GlobalScope.launch {
val list = withContext(Dispatchers.IO){
getUriList()
}
if (list.size == 0){
binding.layoutNoHistory.visibility = View.VISIBLE
binding.buttonClearAll.visibility = View.GONE
}else {
binding.layoutNoHistory.visibility = View.INVISIBLE
binding.buttonClearAll.visibility = View.VISIBLE
}
}

}

private fun openMediaStore() {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_no_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M18,15v4c0,0.55 -0.45,1 -1,1L5,20c-0.55,0 -1,-0.45 -1,-1L4,7c0,-0.55 0.45,-1 1,-1h3.02c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1L4,4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2v-5c0,-0.55 -0.45,-1 -1,-1s-1,0.45 -1,1zM15.5,18L6.52,18c-0.42,0 -0.65,-0.48 -0.39,-0.81l1.74,-2.23c0.2,-0.25 0.58,-0.26 0.78,-0.01l1.56,1.88 2.35,-3.02c0.2,-0.26 0.6,-0.26 0.79,0.01l2.55,3.39c0.25,0.32 0.01,0.79 -0.4,0.79zM19.3,8.89c0.48,-0.77 0.75,-1.67 0.69,-2.66 -0.13,-2.15 -1.84,-3.97 -3.97,-4.2C13.3,1.73 11,3.84 11,6.5c0,2.49 2.01,4.5 4.49,4.5 0.88,0 1.7,-0.26 2.39,-0.7l2.41,2.41c0.39,0.39 1.03,0.39 1.42,0 0.39,-0.39 0.39,-1.03 0,-1.42l-2.41,-2.4zM15.5,9C14.12,9 13,7.88 13,6.5S14.12,4 15.5,4 18,5.12 18,6.5 16.88,9 15.5,9z"/>
</vector>
30 changes: 30 additions & 0 deletions app/src/main/res/layout/activity_history.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,35 @@
android:clipToPadding="false"
android:paddingTop="?attr/actionBarSize" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_no_history"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">

<ImageView
android:id="@+id/icon_no_history"
android:layout_width="128dp"
android:layout_height="128dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:src="@drawable/ic_no_image"
app:tint="@color/colorAccent"/>

<TextView
android:layout_width="128dp"
android:layout_height="wrap_content"
android:text="@string/no_history"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@id/icon_no_history"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:textSize="16sp"/>

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
<string name="delete_all">Delete All</string>
<string name="delete_all_used_images">Delete all used wallpapers listed here.</string>
<string name="delete_all_dialog_message">Delete all used wallpapers?</string>
<string name="no_history">It seems that the history folder is empy, try setting a new wallpaper!</string>
</resources>

0 comments on commit 38adf73

Please sign in to comment.