forked from Louvorg/ReaderForSelfoss-multiplatform
		
	Compare commits
	
		
			21 Commits
		
	
	
		
			v123010241
			...
			v123020491
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 15b9a2d935 | ||
|  | 5a8ce15961 | ||
| e1c64cef46 | |||
| ee064f3cb4 | |||
| 3e46e2ff29 | |||
| f28e702549 | |||
|  | fc31a4399c | ||
|  | 9b23053b66 | ||
| 389a04d250 | |||
|  | 40e1d1478b | ||
|  | 2154ff3c33 | ||
| 2245565f95 | |||
| 014858f06b | |||
| 3f1f86a78e | |||
| a549169a7c | |||
| be7cae365a | |||
| cef3b2e593 | |||
| ae927ebc57 | |||
| ddc72d85b0 | |||
| 68bbf5b2d3 | |||
| 2b6659f4ec | 
| @@ -35,6 +35,7 @@ steps: | ||||
| trigger: | ||||
|   event: | ||||
|     - push | ||||
|     - pull_request | ||||
|  | ||||
| --- | ||||
| kind: pipeline | ||||
|   | ||||
							
								
								
									
										37
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -1,3 +1,40 @@ | ||||
| **v123010301** | ||||
|  | ||||
| - Chore: acra config. | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v123010281** | ||||
|  | ||||
| - improvement: Improve right to left support (#130) Co-authored-by: davidoskky <davidoskky@hidden.hidden> Co-committed-by: davidoskky <davidoskky@hidden.hidden> | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v123010261** | ||||
|  | ||||
| - feat: Handle public instances (#126) Co-authored-by: davidoskky <davidoskky@hidden.hidden> Co-committed-by: davidoskky <davidoskky@hidden.hidden> | ||||
| - ci: Pull request should trigger ci. | ||||
| - fix: Complete the disconnection before redirecting to the login screen | ||||
| - Complete the disconnection before redirecting to the login screen | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v123010241** | ||||
|  | ||||
| - Merge pull request 'feat: swipe down to close images' (#122) from davidoskky/ReaderForSelfoss-multiplatform:swipe_down into master | ||||
| - Remove unnecessary definition | ||||
| - Remove unused import | ||||
| - Adjust the image closing animation | ||||
| - Add a dark hue to the underlying article when swiping to close images | ||||
| - Rename activity style to avoid interferences | ||||
| - Adapt the style of the image activity to the rest of the application | ||||
| - Resolve issues when swiping down to close images | ||||
| - Close the image fragment only if the image has been dragged down | ||||
| - Animate swipe down to close images | ||||
| - Swipe down to close images | ||||
|  | ||||
| -------------------------------------------------------------------- | ||||
|  | ||||
| **v123010041** | ||||
|  | ||||
| - Merge pull request 'scroll-tag-filters' (#124) from scroll-tag-filters into master | ||||
|   | ||||
| @@ -115,7 +115,6 @@ dependencies { | ||||
|     implementation(project(":shared")) | ||||
|     implementation("com.google.android.material:material:1.5.0") | ||||
|     implementation("androidx.appcompat:appcompat:1.4.1") | ||||
|     implementation("androidx.constraintlayout:constraintlayout:2.1.3") | ||||
|     implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0") | ||||
|  | ||||
|     implementation("androidx.preference:preference-ktx:1.1.1") | ||||
| @@ -131,7 +130,7 @@ dependencies { | ||||
|     implementation("androidx.cardview:cardview:1.0.0") | ||||
|     implementation("androidx.annotation:annotation:1.3.0") | ||||
|     implementation("androidx.work:work-runtime-ktx:2.7.1") | ||||
|     implementation("androidx.constraintlayout:constraintlayout:2.1.3") | ||||
|     implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||||
|     implementation("org.jsoup:jsoup:1.14.3") | ||||
|  | ||||
|     //multidex | ||||
|   | ||||
| @@ -70,7 +70,8 @@ | ||||
|             android:name=".ReaderActivity"> | ||||
|         </activity> | ||||
|         <activity | ||||
|             android:name=".ImageActivity"> | ||||
|             android:name=".ImageActivity" | ||||
|             android:theme="@style/Theme.AppCompat.ImageActivity"> | ||||
|         </activity> | ||||
|  | ||||
|         <meta-data android:name="android.webkit.WebView.MetricsOptOut" | ||||
|   | ||||
| @@ -36,6 +36,7 @@ import com.ashokvarma.bottomnavigation.TextBadgeItem | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import kotlinx.coroutines.Dispatchers | ||||
| import kotlinx.coroutines.launch | ||||
| import kotlinx.coroutines.runBlocking | ||||
| import org.kodein.di.DIAware | ||||
| import org.kodein.di.android.closestDI | ||||
| import org.kodein.di.instance | ||||
| @@ -114,10 +115,16 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         val swipeDirs = if (appSettingsService.getPublicAccess()) { | ||||
|             0 | ||||
|         } else { | ||||
|             ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT | ||||
|         } | ||||
|  | ||||
|         val simpleItemTouchCallback = | ||||
|             object : ItemTouchHelper.SimpleCallback( | ||||
|                 0, | ||||
|                 ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT | ||||
|                 swipeDirs | ||||
|             ) { | ||||
|                 override fun getSwipeDirs( | ||||
|                     recyclerView: RecyclerView, | ||||
| @@ -510,6 +517,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar | ||||
|     override fun onCreateOptionsMenu(menu: Menu): Boolean { | ||||
|         val inflater = menuInflater | ||||
|         inflater.inflate(R.menu.home_menu, menu) | ||||
|         if (appSettingsService.getPublicAccess()) { | ||||
|             menu.removeItem(R.id.readAll) | ||||
|             menu.removeItem(R.id.action_sources) | ||||
|         } | ||||
|  | ||||
|         val searchItem = menu.findItem(R.id.action_search) | ||||
|         val searchView = searchItem.getActionView() as SearchView | ||||
| @@ -588,12 +599,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar | ||||
|                 return true | ||||
|             } | ||||
|             R.id.action_disconnect -> { | ||||
|                 CoroutineScope(Dispatchers.Main).launch { | ||||
|                 runBlocking { | ||||
|                     repository.logout() | ||||
|                 } | ||||
|                 this@HomeActivity.finish() | ||||
|                 val intent = Intent(this, LoginActivity::class.java) | ||||
|                 this.startActivity(intent) | ||||
|                 finish() | ||||
|                 return true | ||||
|             } | ||||
|             R.id.action_settings -> { | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package bou.amine.apps.readerforselfossv2.android | ||||
| import android.os.Bundle | ||||
| import android.view.MenuItem | ||||
| import androidx.appcompat.app.AppCompatActivity | ||||
| import androidx.constraintlayout.motion.widget.MotionLayout | ||||
| import androidx.fragment.app.Fragment | ||||
| import androidx.fragment.app.FragmentActivity | ||||
| import androidx.viewpager2.adapter.FragmentStateAdapter | ||||
| @@ -23,7 +24,6 @@ class ImageActivity : AppCompatActivity() { | ||||
|         setContentView(view) | ||||
|  | ||||
|         setSupportActionBar(binding.toolBar) | ||||
|         supportActionBar?.setDisplayShowTitleEnabled(false) | ||||
|         supportActionBar?.setDisplayHomeAsUpEnabled(true) | ||||
|  | ||||
|         allImages = intent.getStringArrayListExtra("allImages") as ArrayList<String> | ||||
| @@ -31,12 +31,35 @@ class ImageActivity : AppCompatActivity() { | ||||
|  | ||||
|         binding.pager.adapter = ScreenSlidePagerAdapter(this) | ||||
|         binding.pager.setCurrentItem(position, false) | ||||
|  | ||||
|         val transitionListener = object : MotionLayout.TransitionListener { | ||||
|             override fun onTransitionStarted(motionLayout: MotionLayout?, startId: Int, endId: Int) { | ||||
|                 // Nothing | ||||
|             } | ||||
|  | ||||
|             override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float | ||||
|             ) { | ||||
|                 // Nothing | ||||
|             } | ||||
|  | ||||
|             override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) { | ||||
|                 if (motionLayout?.currentState == binding.root.endState) { | ||||
|                     onBackPressedDispatcher.onBackPressed() | ||||
|                     overridePendingTransition(0, 0) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             override fun onTransitionTrigger(motionLayout: MotionLayout?, triggerId: Int, positive: Boolean, progress: Float) { | ||||
|                 // Nothing | ||||
|             } | ||||
|         } | ||||
|         binding.root.setTransitionListener(transitionListener) | ||||
|     } | ||||
|  | ||||
|     override fun onOptionsItemSelected(item: MenuItem): Boolean { | ||||
|         when (item.itemId) { | ||||
|             android.R.id.home -> { | ||||
|                 onBackPressed() | ||||
|                 onBackPressedDispatcher.onBackPressed() | ||||
|                 return true | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -128,7 +128,7 @@ class LoginActivity : AppCompatActivity(), DIAware { | ||||
|  | ||||
|     private fun goToMain() { | ||||
|         CoroutineScope(Dispatchers.Main).launch { | ||||
|             repository.updateApiVersion() | ||||
|             repository.updateApiInformation() | ||||
|             ACRA.errorReporter.putCustomData("SELFOSS_API_VERSION", appSettingsService.getApiVersion().toString()) | ||||
|         } | ||||
|         val intent = Intent(this, HomeActivity::class.java) | ||||
|   | ||||
| @@ -130,8 +130,8 @@ class MyApp : MultiDexApplication(), DIAware { | ||||
|             httpSender { | ||||
|                 uri = | ||||
|                     "https://bugs.amine-louveau.fr/report" /*best guess, you may need to adjust this*/ | ||||
|                 basicAuthLogin = "LMTlLZuazADohTCm" | ||||
|                 basicAuthPassword = "he6ghHp83F0PYPfh" | ||||
|                 basicAuthLogin = "qMEscjj89Gwt6cPR" | ||||
|                 basicAuthPassword = "Yo58QFlGzFaWlBzP" | ||||
|                 httpMethod = HttpSender.Method.POST | ||||
|             } | ||||
|         } | ||||
|   | ||||
| @@ -84,7 +84,7 @@ class ReaderActivity : AppCompatActivity(), DIAware { | ||||
|     } | ||||
|  | ||||
|     private fun readItem(item: SelfossModel.Item) { | ||||
|         if (appSettingsService.isMarkOnScrollEnabled()) { | ||||
|         if (appSettingsService.isMarkOnScrollEnabled() && !appSettingsService.getPublicAccess()) { | ||||
|             CoroutineScope(Dispatchers.IO).launch { | ||||
|                 repository.markAsRead(item) | ||||
|             } | ||||
| @@ -137,28 +137,34 @@ class ReaderActivity : AppCompatActivity(), DIAware { | ||||
|         inflater.inflate(R.menu.reader_menu, menu) | ||||
|         toolbarMenu = menu | ||||
|  | ||||
|         if (allItems.isNotEmpty() && allItems[currentItem].starred) { | ||||
|             canRemoveFromFavorite() | ||||
|         } else { | ||||
|             canFavorite() | ||||
|         } | ||||
|         alignmentMenu() | ||||
|  | ||||
|         binding.pager.registerOnPageChangeCallback( | ||||
|             object : ViewPager2.OnPageChangeCallback() { | ||||
|  | ||||
|                 override fun onPageSelected(position: Int) { | ||||
|                     super.onPageSelected(position) | ||||
|  | ||||
|                     if (allItems[position].starred) { | ||||
|                         canRemoveFromFavorite() | ||||
|                     } else { | ||||
|                         canFavorite() | ||||
|                     } | ||||
|                     readItem(allItems[position]) | ||||
|                 } | ||||
|         if (appSettingsService.getPublicAccess()) { | ||||
|             menu.removeItem(R.id.star) | ||||
|         } else { | ||||
|             if (allItems.isNotEmpty() && allItems[currentItem].starred) { | ||||
|                 canRemoveFromFavorite() | ||||
|             } else { | ||||
|                 canFavorite() | ||||
|             } | ||||
|         ) | ||||
|  | ||||
|  | ||||
|             binding.pager.registerOnPageChangeCallback( | ||||
|                 object : ViewPager2.OnPageChangeCallback() { | ||||
|  | ||||
|                     override fun onPageSelected(position: Int) { | ||||
|                         super.onPageSelected(position) | ||||
|  | ||||
|                         if (allItems[position].starred) { | ||||
|                             canRemoveFromFavorite() | ||||
|                         } else { | ||||
|                             canFavorite() | ||||
|                         } | ||||
|                         readItem(allItems[position]) | ||||
|                     } | ||||
|                 } | ||||
|             ) | ||||
|         } | ||||
|  | ||||
|         return true | ||||
|     } | ||||
| @@ -177,7 +183,7 @@ class ReaderActivity : AppCompatActivity(), DIAware { | ||||
|  | ||||
|         when (item.itemId) { | ||||
|             android.R.id.home -> { | ||||
|                 onBackPressed() | ||||
|                 onBackPressedDispatcher.onBackPressed() | ||||
|                 return true | ||||
|             } | ||||
|             R.id.star -> { | ||||
|   | ||||
| @@ -56,6 +56,10 @@ class ItemCardAdapter( | ||||
|             val itm = items[position] | ||||
|  | ||||
|             binding.favButton.isSelected = itm.starred | ||||
|             if (appSettingsService.getPublicAccess()) { | ||||
|                 binding.favButton.visibility = View.GONE | ||||
|             } | ||||
|  | ||||
|             binding.title.text = itm.title.getHtmlDecoded() | ||||
|  | ||||
|             binding.title.setOnTouchListener(LinkOnTouchListener()) | ||||
|   | ||||
| @@ -195,6 +195,9 @@ class ArticleFragment : Fragment(), DIAware { | ||||
|  | ||||
|     private fun handleFloatingToolbar(): FloatingToolbar { | ||||
|         val floatingToolbar: FloatingToolbar = binding.floatingToolbar | ||||
|         if (appSettingsService.getPublicAccess()) { | ||||
|             floatingToolbar.setMenu(R.menu.reader_toolbar_no_read) | ||||
|         } | ||||
|         floatingToolbar.attachFab(fab) | ||||
|  | ||||
|         floatingToolbar.background = ColorDrawable(resources.getColor(R.color.colorAccent)) | ||||
|   | ||||
| @@ -1,13 +1,12 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.drawerlayout.widget.DrawerLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:id="@+id/drawerContainer" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     tools:context="bou.amine.apps.readerforselfossv2.android.HomeActivity" | ||||
|     android:fitsSystemWindows="true" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto"> | ||||
|     tools:context="bou.amine.apps.readerforselfossv2.android.HomeActivity"> | ||||
|  | ||||
|     <androidx.coordinatorlayout.widget.CoordinatorLayout | ||||
|         android:id="@+id/coordLayout" | ||||
| @@ -28,12 +27,14 @@ | ||||
|                     android:layout_width="match_parent" | ||||
|                     android:layout_height="wrap_content"> | ||||
|  | ||||
|                     <androidx.appcompat.widget.Toolbar app:popupTheme="?attr/toolbarPopupTheme" android:theme="@style/ToolBarStyle" | ||||
|                     <androidx.appcompat.widget.Toolbar | ||||
|                         android:id="@+id/toolBar" | ||||
|                         android:layout_width="match_parent" | ||||
|                         android:layout_height="?attr/actionBarSize" | ||||
|                         android:theme="@style/ToolBarStyle" | ||||
|                         app:popupTheme="?attr/toolbarPopupTheme" | ||||
|  | ||||
|                          /> | ||||
|                         /> | ||||
|  | ||||
|                 </com.google.android.material.appbar.AppBarLayout> | ||||
|  | ||||
| @@ -45,19 +46,19 @@ | ||||
|                     <LinearLayout | ||||
|                         android:layout_width="match_parent" | ||||
|                         android:layout_height="match_parent" | ||||
|                         android:orientation="vertical" | ||||
|                         android:background="?android:attr/windowBackground"> | ||||
|                         android:background="?android:attr/windowBackground" | ||||
|                         android:orientation="vertical"> | ||||
|  | ||||
|                         <TextView | ||||
|                             android:id="@+id/emptyText" | ||||
|                             android:layout_width="match_parent" | ||||
|                             android:layout_height="wrap_content" | ||||
|                             android:background="@android:color/transparent" | ||||
|                             android:gravity="center_horizontal" | ||||
|                             android:paddingTop="100dp" | ||||
|                             android:text="@string/nothing_here" | ||||
|                             android:textAlignment="center" | ||||
|                             android:textAppearance="@style/TextAppearance.AppCompat.Headline" | ||||
|                             android:background="@android:color/transparent" | ||||
|                             android:visibility="gone" /> | ||||
|  | ||||
|                         <androidx.recyclerview.widget.RecyclerView | ||||
| @@ -69,7 +70,7 @@ | ||||
|                             android:paddingBottom="60dp" | ||||
|                             android:scrollbars="vertical" | ||||
|                             app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||||
|                             tools:listitem="@layout/list_item"/> | ||||
|                             tools:listitem="@layout/list_item" /> | ||||
|                     </LinearLayout> | ||||
|  | ||||
|                 </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> | ||||
| @@ -77,6 +78,7 @@ | ||||
|             </LinearLayout> | ||||
|  | ||||
|         </androidx.coordinatorlayout.widget.CoordinatorLayout> | ||||
|  | ||||
|         <com.ashokvarma.bottomnavigation.BottomNavigationBar | ||||
|             android:id="@+id/bottomBar" | ||||
|             android:layout_width="match_parent" | ||||
|   | ||||
| @@ -1,33 +1,40 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:id="@+id/container" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent"> | ||||
|     android:layout_height="match_parent" | ||||
|     app:layoutDescription="@xml/image_close_scene"> | ||||
|  | ||||
|     <com.google.android.material.appbar.AppBarLayout | ||||
|         android:id="@+id/appBarLayout" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent"> | ||||
|         android:layout_height="wrap_content"> | ||||
|  | ||||
|         <androidx.appcompat.widget.Toolbar | ||||
|         <androidx.appcompat.widget.Toolbar android:theme="@style/ToolBarStyle" | ||||
|             android:id="@+id/toolBar" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="?attr/actionBarSize" | ||||
|  | ||||
|              /> | ||||
|             /> | ||||
|  | ||||
|     </com.google.android.material.appbar.AppBarLayout> | ||||
|  | ||||
|     <androidx.viewpager2.widget.ViewPager2 | ||||
|         android:id="@+id/pager" | ||||
|     <androidx.core.widget.NestedScrollView | ||||
|         android:id="@+id/scrollView" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="0dp" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/appBarLayout" /> | ||||
|         android:layout_height="match_parent" | ||||
|         android:fillViewport="true" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/appBarLayout"> | ||||
|  | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|         <androidx.viewpager2.widget.ViewPager2 | ||||
|             android:id="@+id/pager" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" /> | ||||
|     </androidx.core.widget.NestedScrollView> | ||||
|  | ||||
|  | ||||
| </androidx.constraintlayout.motion.widget.MotionLayout> | ||||
|   | ||||
| @@ -1,31 +1,30 @@ | ||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:gravity="center_horizontal" | ||||
|     android:orientation="vertical" | ||||
|     tools:context="bou.amine.apps.readerforselfossv2.android.LoginActivity"> | ||||
|  | ||||
|     <com.google.android.material.appbar.AppBarLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content"> | ||||
|  | ||||
|         <androidx.appcompat.widget.Toolbar app:popupTheme="?attr/toolbarPopupTheme" android:theme="@style/ToolBarStyle" | ||||
|         <androidx.appcompat.widget.Toolbar | ||||
|             android:id="@+id/toolbar" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="?attr/actionBarSize" | ||||
|  | ||||
|              /> | ||||
|             android:theme="@style/ToolBarStyle" | ||||
|             app:popupTheme="?attr/toolbarPopupTheme" /> | ||||
|  | ||||
|     </com.google.android.material.appbar.AppBarLayout> | ||||
|  | ||||
|     <LinearLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:orientation="vertical" | ||||
|         android:paddingBottom="@dimen/activity_vertical_margin" | ||||
|         android:paddingLeft="@dimen/activity_horizontal_margin" | ||||
|         android:paddingRight="@dimen/activity_horizontal_margin" | ||||
|         android:paddingTop="@dimen/activity_vertical_margin"> | ||||
|         android:padding="@dimen/activity_horizontal_margin"> | ||||
|         <!-- Login progress --> | ||||
|         <ProgressBar | ||||
|             android:id="@+id/loginProgress" | ||||
| @@ -33,67 +32,65 @@ | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_marginBottom="8dp" | ||||
|             android:visibility="gone"/> | ||||
|             android:visibility="gone" /> | ||||
|  | ||||
|         <ScrollView | ||||
|         <LinearLayout | ||||
|             android:id="@+id/loginForm" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent"> | ||||
|             android:layout_height="wrap_content" | ||||
|             android:orientation="vertical"> | ||||
|  | ||||
|             <LinearLayout | ||||
|             <EditText | ||||
|                 android:id="@+id/urlView" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:orientation="vertical"> | ||||
|                 android:hint="@string/prompt_url" | ||||
|                 android:imeOptions="actionUnspecified" | ||||
|                 android:importantForAutofill="no" | ||||
|                 android:inputType="textUri" | ||||
|                 android:maxLines="1" | ||||
|                 android:minHeight="48dp" /> | ||||
|  | ||||
|                 <EditText | ||||
|                     android:id="@+id/urlView" | ||||
|                     android:layout_width="match_parent" | ||||
|                     android:layout_height="wrap_content" | ||||
|                     android:hint="@string/prompt_url" | ||||
|                     android:imeOptions="actionUnspecified" | ||||
|                     android:importantForAutofill="no" | ||||
|                     android:inputType="textUri" | ||||
|                     android:maxLines="1" /> | ||||
|             <com.google.android.material.switchmaterial.SwitchMaterial | ||||
|                 android:id="@+id/withLogin" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:text="@string/withLoginSwitch" | ||||
|                 android:textAlignment="viewStart" /> | ||||
|  | ||||
|                 <com.google.android.material.switchmaterial.SwitchMaterial | ||||
|                     android:text="@string/withLoginSwitch" | ||||
|                     android:layout_width="match_parent" | ||||
|                     android:layout_height="0dp" | ||||
|                     android:id="@+id/withLogin" | ||||
|                     android:layout_weight="1"/> | ||||
|             <EditText | ||||
|                 android:id="@+id/loginView" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:autofillHints="username" | ||||
|                 android:hint="@string/prompt_login" | ||||
|                 android:inputType="text" | ||||
|                 android:maxLines="1" | ||||
|                 android:minHeight="48dp" | ||||
|                 android:visibility="gone" /> | ||||
|  | ||||
|                 <EditText | ||||
|                     android:id="@+id/loginView" | ||||
|                     android:layout_width="match_parent" | ||||
|                     android:layout_height="wrap_content" | ||||
|                     android:autofillHints="username" | ||||
|                     android:hint="@string/prompt_login" | ||||
|                     android:inputType="text" | ||||
|                     android:maxLines="1" | ||||
|                     android:visibility="gone" /> | ||||
|             <EditText | ||||
|                 android:id="@+id/passwordView" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:autofillHints="password" | ||||
|                 android:hint="@string/prompt_password" | ||||
|                 android:inputType="textPassword" | ||||
|                 android:maxLines="1" | ||||
|                 android:minHeight="48dp" | ||||
|                 android:visibility="gone" /> | ||||
|  | ||||
|                 <EditText | ||||
|                     android:id="@+id/passwordView" | ||||
|                     android:layout_width="match_parent" | ||||
|                     android:layout_height="wrap_content" | ||||
|                     android:autofillHints="password" | ||||
|                     android:hint="@string/prompt_password" | ||||
|                     android:inputType="textPassword" | ||||
|                     android:maxLines="1" | ||||
|                     android:visibility="gone" /> | ||||
|             <Button | ||||
|                 android:id="@+id/signInButton" | ||||
|                 style="?android:textAppearanceSmall" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 android:layout_marginBottom="16dp" | ||||
|                 android:text="@string/action_sign_in" | ||||
|                 android:textStyle="bold" /> | ||||
|  | ||||
|                 <Button | ||||
|                     android:id="@+id/signInButton" | ||||
|                     style="?android:textAppearanceSmall" | ||||
|                     android:layout_width="match_parent" | ||||
|                     android:layout_height="wrap_content" | ||||
|                     android:layout_marginTop="16dp" | ||||
|                     android:layout_marginBottom="16dp" | ||||
|                     android:text="@string/action_sign_in" | ||||
|                     android:textStyle="bold" /> | ||||
|  | ||||
|             </LinearLayout> | ||||
|         </ScrollView> | ||||
|         </LinearLayout> | ||||
|     </LinearLayout> | ||||
|  | ||||
| </LinearLayout> | ||||
|   | ||||
| @@ -24,7 +24,8 @@ | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:scrollbars="vertical" | ||||
|         app:layout_behavior="@string/appbar_scrolling_view_behavior"> | ||||
|         app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||||
|         tools:listitem="@layout/source_list_item"> | ||||
|     </androidx.recyclerview.widget.RecyclerView> | ||||
|  | ||||
|     <com.google.android.material.floatingactionbutton.FloatingActionButton | ||||
|   | ||||
| @@ -17,100 +17,83 @@ | ||||
|             <androidx.appcompat.widget.Toolbar app:popupTheme="?attr/toolbarPopupTheme" android:theme="@style/ToolBarStyle" | ||||
|                 android:id="@+id/toolbar" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="?attr/actionBarSize" | ||||
|  | ||||
|                  /> | ||||
|                 android:layout_height="?attr/actionBarSize" /> | ||||
|  | ||||
|         </com.google.android.material.appbar.AppBarLayout> | ||||
|  | ||||
|  | ||||
|  | ||||
|         <androidx.constraintlayout.widget.ConstraintLayout | ||||
|             android:paddingBottom="@dimen/activity_vertical_margin" | ||||
|             android:paddingLeft="@dimen/activity_horizontal_margin" | ||||
|             android:paddingRight="@dimen/activity_horizontal_margin" | ||||
|             android:paddingTop="@dimen/activity_vertical_margin" | ||||
|             android:layout_height="match_parent" | ||||
|             android:layout_width="match_parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" | ||||
|             app:layout_constraintRight_toRightOf="parent" | ||||
|             app:layout_constraintLeft_toLeftOf="parent" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             android:id="@+id/formContainer" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             android:padding="16dp" | ||||
|             android:visibility="gone" | ||||
|             app:layout_constraintHorizontal_bias="1.0" | ||||
|             app:layout_constraintVertical_bias="0.0"> | ||||
|             app:layout_constraintLeft_toLeftOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent"> | ||||
|  | ||||
|  | ||||
|             <EditText | ||||
|                 android:id="@+id/nameInput" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:minHeight="48dp" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 android:autofillHints="false" | ||||
|                 android:ems="10" | ||||
|                 android:hint="@string/add_source_hint_name" | ||||
|                 android:inputType="text" | ||||
|                 android:textColorHint="?android:textColorPrimary" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|             <EditText | ||||
|                 android:id="@+id/sourceUri" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:inputType="textUri" | ||||
|                 android:ems="10" | ||||
|                 android:id="@+id/sourceUri" | ||||
|                 android:hint="@string/add_source_hint_url" | ||||
|                 android:textColorHint="?android:textColorPrimary" | ||||
|                 android:minHeight="48dp" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/nameInput" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 android:autofillHints="false" | ||||
|                 android:hint="@string/add_source_hint_url" | ||||
|                 android:inputType="textUri" | ||||
|                 android:textColorHint="?android:textColorPrimary" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 android:autofillHints="false" /> | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/nameInput" /> | ||||
|  | ||||
|             <EditText | ||||
|                 android:id="@+id/tags" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:ems="10" | ||||
|                 android:id="@+id/tags" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 android:minHeight="48dp" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/sourceUri" | ||||
|                 android:autofillHints="false" | ||||
|                 android:hint="@string/add_source_hint_tags" | ||||
|                 android:textColorHint="?android:textColorPrimary" | ||||
|                 android:inputType="text" | ||||
|                 android:autofillHints="false" /> | ||||
|                 android:textColorHint="?android:textColorPrimary" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/sourceUri" /> | ||||
|  | ||||
|             <Spinner | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:id="@+id/spoutsSpinner" | ||||
|                 android:layout_width="match_parent" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:minHeight="48dp" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/tags" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 android:layout_height="40dp"/> | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/tags" /> | ||||
|  | ||||
|             <Button | ||||
|                 android:text="@string/add_source_save" | ||||
|                 android:id="@+id/saveBtn" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:id="@+id/saveBtn" | ||||
|                 android:elevation="5dp" | ||||
|                 android:textColor="?android:textColorPrimary" | ||||
|                 android:layout_marginEnd="16dp" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 android:layout_marginRight="16dp" | ||||
|                 android:layout_marginStart="16dp" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 android:layout_marginLeft="16dp" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/spoutsSpinner" | ||||
|                 android:elevation="5dp" | ||||
|                 android:text="@string/add_source_save" | ||||
|                 android:textColor="?android:textColorPrimary" | ||||
|                 app:layout_constraintBottom_toBottomOf="parent" | ||||
|                 android:layout_marginBottom="16dp" | ||||
|                 app:layout_constraintVertical_bias="0.0"/> | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/spoutsSpinner" /> | ||||
|  | ||||
|         </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|  | ||||
| @@ -119,8 +102,6 @@ | ||||
|             style="?android:attr/progressBarStyleLarge" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:visibility="visible" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             app:layout_constraintLeft_toLeftOf="parent" | ||||
|             app:layout_constraintRight_toRightOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" | ||||
|   | ||||
| @@ -1,18 +1,14 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.cardview.widget.CardView | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:card_view="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:id="@+id/card" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
|     android:layout_marginLeft="8dp" | ||||
|     android:layout_marginRight="8dp" | ||||
|     android:layout_marginTop="8dp" | ||||
|     app:layout_constraintHorizontal_bias="0.62" | ||||
|     app:layout_constraintLeft_toLeftOf="parent" | ||||
|     app:layout_constraintRight_toRightOf="parent" | ||||
|     android:layout_margin="8dp" | ||||
|     app:layout_constraintEnd_toEndOf="parent" | ||||
|     app:layout_constraintStart_toStartOf="parent" | ||||
|     app:layout_constraintTop_toTopOf="parent" | ||||
|     card_view:cardElevation="2dp" | ||||
|     card_view:cardUseCompatPadding="true" | ||||
| @@ -28,8 +24,8 @@ | ||||
|             android:layout_height="wrap_content" | ||||
|             android:adjustViewBounds="true" | ||||
|             android:cropToPadding="true" | ||||
|             app:layout_constraintLeft_toLeftOf="parent" | ||||
|             app:layout_constraintRight_toRightOf="parent" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toTopOf="parent" | ||||
|             app:srcCompat="@drawable/background_splash" | ||||
|             card_view:layout_constraintBottom_toTopOf="@+id/constraintLayout" /> | ||||
| @@ -39,18 +35,17 @@ | ||||
|             android:layout_width="0dp" | ||||
|             android:layout_height="wrap_content" | ||||
|             app:layout_constraintBottom_toBottomOf="parent" | ||||
|             app:layout_constraintLeft_toLeftOf="parent" | ||||
|             app:layout_constraintRight_toRightOf="parent" | ||||
|             app:layout_constraintEnd_toEndOf="parent" | ||||
|             app:layout_constraintStart_toStartOf="parent" | ||||
|             app:layout_constraintTop_toBottomOf="@+id/itemImage"> | ||||
|  | ||||
|             <ImageView | ||||
|                 android:id="@+id/sourceImage" | ||||
|                 android:layout_width="40dp" | ||||
|                 android:layout_height="40dp" | ||||
|                 android:layout_marginLeft="8dp" | ||||
|                 android:layout_marginStart="8dp" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|                 app:srcCompat="@drawable/background_splash" /> | ||||
|  | ||||
| @@ -58,70 +53,58 @@ | ||||
|                 android:id="@+id/title" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginEnd="8dp" | ||||
|                 android:layout_marginLeft="8dp" | ||||
|                 android:layout_marginRight="8dp" | ||||
|                 android:layout_marginStart="8dp" | ||||
|                 android:gravity="start" | ||||
|                 android:layout_margin="8dp" | ||||
|                 android:textAlignment="viewStart" | ||||
|                 android:textStyle="bold" | ||||
|                 android:textColor="?android:textColorPrimary" | ||||
|                 app:layout_constraintHorizontal_bias="0.0" | ||||
|                 app:layout_constraintLeft_toRightOf="@+id/sourceImage" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 android:textStyle="bold" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toEndOf="@+id/sourceImage" | ||||
|                 app:layout_constraintTop_toTopOf="@+id/sourceImage" | ||||
|                 tools:text="Titre" /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:id="@+id/sourceTitleAndDate" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 android:gravity="start" | ||||
|                 android:textAlignment="viewStart" | ||||
|                 android:textSize="14sp" | ||||
|                 android:textColor="?android:textColorPrimary" | ||||
|                 app:layout_constraintLeft_toLeftOf="@+id/title" | ||||
|                 android:textSize="14sp" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="@+id/title" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/title" | ||||
|                 tools:text="Google Actualité Il y a 5h" /> | ||||
|  | ||||
|             <RelativeLayout | ||||
|                 android:layout_width="0dp" | ||||
|             <LinearLayout | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginTop="16dp" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 android:layout_marginEnd="8dp" | ||||
|                 app:layout_constraintBottom_toBottomOf="parent" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/sourceTitleAndDate"> | ||||
|  | ||||
|                 <ImageButton | ||||
|                     android:id="@+id/favButton" | ||||
|                     android:id="@+id/browserBtn" | ||||
|                     android:layout_width="35dp" | ||||
|                     android:layout_height="35dp" | ||||
|                     android:layout_alignParentEnd="true" | ||||
|                     android:layout_alignParentRight="true" | ||||
|                     android:layout_centerVertical="true" | ||||
|                     android:layout_marginEnd="8dp" | ||||
|                     android:layout_marginRight="8dp" | ||||
|                     android:adjustViewBounds="true" | ||||
|                     android:background="@android:color/transparent" | ||||
|                     android:contentDescription="@string/reader_action_open" | ||||
|                     android:elevation="5dp" | ||||
|                     android:padding="4dp" | ||||
|                     android:scaleType="centerCrop" | ||||
|                     app:srcCompat="@drawable/ic_menu_heart_60dp" | ||||
|                     app:tint="@color/ic_menu_heart_color" /> | ||||
|                     app:srcCompat="@drawable/ic_open_in_browser_black_24dp" | ||||
|                     app:tint="?android:attr/textColorPrimary" /> | ||||
|  | ||||
|                 <ImageButton | ||||
|                     android:id="@+id/shareBtn" | ||||
|                     android:layout_width="35dp" | ||||
|                     android:layout_height="35dp" | ||||
|                     android:layout_centerVertical="true" | ||||
|                     android:layout_marginEnd="16dp" | ||||
|                     android:layout_marginRight="16dp" | ||||
|                     android:layout_toLeftOf="@+id/favButton" | ||||
|                     android:layout_toStartOf="@+id/favButton" | ||||
|                     android:layout_marginStart="16dp" | ||||
|                     android:adjustViewBounds="true" | ||||
|                     android:background="@android:color/transparent" | ||||
|                     android:contentDescription="@string/share" | ||||
|                     android:elevation="5dp" | ||||
|                     android:padding="4dp" | ||||
|                     android:scaleType="centerCrop" | ||||
| @@ -129,23 +112,21 @@ | ||||
|                     app:tint="?android:attr/textColorPrimary" /> | ||||
|  | ||||
|                 <ImageButton | ||||
|                     android:id="@+id/browserBtn" | ||||
|                     android:id="@+id/favButton" | ||||
|                     android:layout_width="35dp" | ||||
|                     android:layout_height="35dp" | ||||
|                     android:layout_centerVertical="true" | ||||
|                     android:layout_marginEnd="16dp" | ||||
|                     android:layout_marginRight="16dp" | ||||
|                     android:layout_toLeftOf="@+id/shareBtn" | ||||
|                     android:layout_toStartOf="@+id/shareBtn" | ||||
|                     android:layout_marginStart="16dp" | ||||
|                     android:adjustViewBounds="true" | ||||
|                     android:background="@android:color/transparent" | ||||
|                     android:contentDescription="@string/add_to_favs_reader" | ||||
|                     android:elevation="5dp" | ||||
|                     android:padding="4dp" | ||||
|                     android:scaleType="centerCrop" | ||||
|                     app:srcCompat="@drawable/ic_open_in_browser_black_24dp" | ||||
|                     app:tint="?android:attr/textColorPrimary" /> | ||||
|                     app:srcCompat="@drawable/ic_menu_heart_60dp" | ||||
|                     app:tint="@color/ic_menu_heart_color" /> | ||||
|  | ||||
|             </RelativeLayout> | ||||
|  | ||||
|             </LinearLayout> | ||||
|  | ||||
|         </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|     </androidx.constraintlayout.widget.ConstraintLayout> | ||||
|   | ||||
| @@ -1,6 +1,5 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <androidx.constraintlayout.widget.ConstraintLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
| @@ -80,10 +79,11 @@ | ||||
|                 android:id="@+id/floatingActionButton2" | ||||
|                 android:layout_width="wrap_content" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginEnd="16dp" | ||||
|  | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 android:layout_marginEnd="16dp" | ||||
|                 android:clickable="true" | ||||
|                 android:contentDescription="@string/menu_home_search" | ||||
|                 android:focusable="true" | ||||
|                 app:backgroundTint="@color/colorAccent" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| <androidx.coordinatorlayout.widget.CoordinatorLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
| @@ -22,10 +21,22 @@ | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="200dp" | ||||
|                 android:scaleType="centerCrop" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" | ||||
|                 /> | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:id="@+id/titleView" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginLeft="16dp" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 android:layout_marginRight="16dp" | ||||
|                 android:textAppearance="@style/TextAppearance.AppCompat.Headline" | ||||
|                 android:textStyle="bold" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/imageView" /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:id="@+id/source" | ||||
| @@ -36,40 +47,23 @@ | ||||
|                 android:layout_marginRight="16dp" | ||||
|                 android:textColor="?android:textColorSecondary" | ||||
|                 android:textSize="12sp" | ||||
|                 app:layout_constraintHorizontal_bias="0.0" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/titleView" /> | ||||
|  | ||||
|             <TextView | ||||
|                 android:id="@+id/titleView" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginLeft="16dp" | ||||
|                 android:layout_marginRight="16dp" | ||||
|                 android:layout_marginTop="8dp" | ||||
|                 android:textAppearance="@style/TextAppearance.AppCompat.Headline" | ||||
|                 android:textStyle="bold" | ||||
|                 app:layout_constraintHorizontal_bias="0.0" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/imageView" /> | ||||
|  | ||||
|  | ||||
|             <WebView | ||||
|                 android:id="@+id/webcontent" | ||||
|                 android:layout_width="0dp" | ||||
|                 android:layout_height="wrap_content" | ||||
|                 android:layout_marginLeft="16dp" | ||||
|                 android:layout_marginTop="24dp" | ||||
|                 android:layout_marginRight="16dp" | ||||
|                 android:background="?attr/webviewBackground" | ||||
|                 android:paddingBottom="48dp" | ||||
|                 android:textColorLink="?attr/colorAccent" | ||||
|                 android:visibility="gone" | ||||
|                 android:layout_marginLeft="16dp" | ||||
|                 android:layout_marginRight="16dp" | ||||
|                 android:layout_marginTop="24dp" | ||||
|                 android:paddingBottom="48dp" | ||||
|                 android:background="?attr/webviewBackground" | ||||
|                 app:layout_constraintHorizontal_bias="0.0" | ||||
|                 app:layout_constraintLeft_toLeftOf="parent" | ||||
|                 app:layout_constraintRight_toRightOf="parent" | ||||
|                 app:layout_constraintEnd_toEndOf="parent" | ||||
|                 app:layout_constraintStart_toStartOf="parent" | ||||
|                 app:layout_constraintTop_toBottomOf="@+id/source" | ||||
|                 tools:visibility="visible" /> | ||||
|  | ||||
| @@ -80,10 +74,10 @@ | ||||
|     <FrameLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_gravity="start|bottom|end" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintLeft_toLeftOf="parent" | ||||
|         android:layout_gravity="end|bottom|right"> | ||||
|         app:layout_constraintStart_toStartOf="parent"> | ||||
|  | ||||
|         <com.github.rubensousa.floatingtoolbar.FloatingToolbar | ||||
|             android:id="@+id/floatingToolbar" | ||||
| @@ -96,12 +90,11 @@ | ||||
|             android:id="@+id/fab" | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:layout_gravity="end|bottom|right" | ||||
|             android:layout_marginBottom="16dp" | ||||
|             android:layout_gravity="end|bottom" | ||||
|             android:layout_marginEnd="16dp" | ||||
|             android:layout_marginRight="16dp" | ||||
|             android:paddingBottom="@dimen/activity_vertical_margin" | ||||
|             android:layout_marginBottom="16dp" | ||||
|             android:paddingTop="@dimen/activity_vertical_margin" | ||||
|             android:paddingBottom="@dimen/activity_vertical_margin" | ||||
|             android:src="@drawable/ic_add_white_24dp" | ||||
|             app:backgroundTint="?attr/colorAccent" | ||||
|             app:fabSize="mini" | ||||
| @@ -112,11 +105,11 @@ | ||||
|         android:id="@+id/progressBar" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:visibility="gone" | ||||
|         android:animateLayoutChanges="true" | ||||
|         android:alpha="0.8" | ||||
|         android:animateLayoutChanges="true" | ||||
|         android:background="@color/black" | ||||
|         android:clickable="false"> | ||||
|         android:clickable="false" | ||||
|         android:visibility="gone"> | ||||
|  | ||||
|         <ProgressBar | ||||
|             style="?android:attr/progressBarStyleLarge" | ||||
|   | ||||
| @@ -1,16 +1,16 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent"> | ||||
|  | ||||
|     <com.github.chrisbanes.photoview.PhotoView | ||||
|         android:id="@+id/photoView" | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:layout_centerVertical="true" | ||||
|         android:adjustViewBounds="true" | ||||
|         android:background="@drawable/checkerboard" | ||||
|         app:srcCompat="@android:drawable/screen_background_dark" /> | ||||
|         <com.github.chrisbanes.photoview.PhotoView | ||||
|             android:id="@+id/photoView" | ||||
|             android:layout_width="match_parent" | ||||
|             android:layout_height="match_parent" | ||||
|             android:layout_centerVertical="true" | ||||
|             android:adjustViewBounds="true" | ||||
|             android:background="@drawable/checkerboard" | ||||
|             app:srcCompat="@android:drawable/screen_background_dark" /> | ||||
|  | ||||
| </RelativeLayout> | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
| @@ -3,17 +3,16 @@ | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="88dp"> | ||||
|     android:layout_height="wrap_content"> | ||||
|  | ||||
|     <ImageView | ||||
|         android:id="@+id/itemImage" | ||||
|         android:layout_width="46dp" | ||||
|         android:layout_height="46dp" | ||||
|         android:layout_marginStart="8dp" | ||||
|         android:layout_marginTop="21dp" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         android:layout_marginLeft="8dp" /> | ||||
|         app:layout_constraintTop_toTopOf="parent" /> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/title" | ||||
| @@ -24,39 +23,30 @@ | ||||
|         android:layout_marginEnd="16dp" | ||||
|         android:ellipsize="end" | ||||
|         android:fontFamily="sans-serif" | ||||
|         android:gravity="start" | ||||
|         android:maxLines="3" | ||||
|         android:textAlignment="viewStart" | ||||
|         android:textAllCaps="false" | ||||
|         android:textColor="?android:textColorPrimary" | ||||
|         android:textSize="16sp" | ||||
|         android:textStyle="bold" | ||||
|         android:textColor="?android:textColorPrimary" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintHorizontal_bias="0.0" | ||||
|         app:layout_constraintStart_toEndOf="@+id/itemImage" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         tools:text="Titre" | ||||
|         android:layout_marginLeft="8dp" | ||||
|         android:layout_marginRight="16dp" /> | ||||
|         tools:text="Titre" /> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/sourceTitleAndDate" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginStart="8dp" | ||||
|         android:layout_marginTop="66dp" | ||||
|         android:layout_marginEnd="16dp" | ||||
|         android:gravity="start" | ||||
|         android:maxLines="1" | ||||
|         android:textAlignment="viewStart" | ||||
|         android:textSize="14sp" | ||||
|         android:textColor="?android:textColorPrimary" | ||||
|         android:textSize="14sp" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintHorizontal_bias="0.0" | ||||
|         app:layout_constraintStart_toEndOf="@+id/itemImage" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         tools:text="Google Actualité Il y a 5h" | ||||
|         android:layout_marginLeft="8dp" | ||||
|         android:layout_marginRight="16dp" /> | ||||
|         app:layout_constraintTop_toBottomOf="@+id/itemImage" | ||||
|         tools:text="Google Actualité Il y a 5h" /> | ||||
|  | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
| @@ -12,9 +12,9 @@ | ||||
|         style="@style/Widget.AppCompat.Button.Borderless" | ||||
|         android:layout_width="48dp" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:layout_marginEnd="8dp" | ||||
|         android:layout_marginTop="8dp" | ||||
|         android:layout_marginEnd="8dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:background="@drawable/ic_remove_circle_outline_black_24dp" | ||||
|         android:backgroundTint="?android:textColorSecondary" | ||||
|         android:contentDescription="@string/remove_source" | ||||
| @@ -29,48 +29,48 @@ | ||||
|         android:id="@+id/itemImage" | ||||
|         android:layout_width="36dp" | ||||
|         android:layout_height="36dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:layout_marginLeft="8dp" | ||||
|         android:layout_marginStart="8dp" | ||||
|         android:layout_marginTop="8dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:importantForAccessibility="no" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintLeft_toLeftOf="parent" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         app:layout_constraintVertical_bias="0.0" /> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/sourceTitle" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="17dp" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginStart="8dp" | ||||
|         android:ellipsize="end" | ||||
|         android:gravity="start" | ||||
|         android:maxLines="1" | ||||
|         android:textAlignment="textStart" | ||||
|         android:textAlignment="viewStart" | ||||
|         android:textColor="?android:textColorPrimary" | ||||
|         android:textSize="13sp" | ||||
|         android:textSize="20sp" | ||||
|         android:textStyle="bold" | ||||
|         app:layout_constraintBottom_toTopOf="@+id/errorText" | ||||
|         app:layout_constraintEnd_toStartOf="@+id/deleteBtn" | ||||
|         app:layout_constraintStart_toEndOf="@+id/itemImage" | ||||
|         app:layout_constraintTop_toTopOf="parent" | ||||
|         tools:text="source title" /> | ||||
|         tools:text="Source title" /> | ||||
|  | ||||
|     <TextView | ||||
|         android:id="@+id/errorText" | ||||
|         android:layout_width="0dp" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:layout_marginEnd="16dp" | ||||
|         android:layout_marginStart="16dp" | ||||
|         android:layout_marginStart="10sp" | ||||
|         android:layout_marginTop="8dp" | ||||
|         android:layout_marginBottom="8dp" | ||||
|         android:textAppearance="@style/TextAppearance.AppCompat.Small" | ||||
|         android:textColor="@color/red" | ||||
|         android:textStyle="italic" | ||||
|         android:visibility="gone" | ||||
|         app:layout_constraintBottom_toBottomOf="parent" | ||||
|         app:layout_constraintEnd_toEndOf="parent" | ||||
|         app:layout_constraintEnd_toStartOf="@+id/deleteBtn" | ||||
|         app:layout_constraintStart_toStartOf="parent" | ||||
|         app:layout_constraintTop_toBottomOf="@+id/itemImage" | ||||
|         tools:text="Test" | ||||
|         tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." | ||||
|         tools:visibility="visible" /> | ||||
|  | ||||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||||
							
								
								
									
										16
									
								
								androidApp/src/main/res/menu/reader_toolbar_no_read.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								androidApp/src/main/res/menu/reader_toolbar_no_read.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto"> | ||||
|  | ||||
|     <item | ||||
|         android:id="@+id/open_action" | ||||
|         android:icon="@drawable/ic_open_in_browser_white_24dp" | ||||
|         android:title="@string/reader_action_open" | ||||
|         app:showAsAction="ifRoom" /> | ||||
|  | ||||
|     <item | ||||
|         android:id="@+id/share_action" | ||||
|         android:icon="@drawable/ic_share_white_24dp" | ||||
|         android:title="@string/reader_action_share" | ||||
|         app:showAsAction="ifRoom" /> | ||||
|  | ||||
| </menu> | ||||
| @@ -12,4 +12,5 @@ | ||||
|     <color name="refresh_progress_2">@color/colorAccent</color> | ||||
|     <color name="refresh_progress_3">@color/pink</color> | ||||
|     <color name="dark">#FF282828</color> | ||||
|     <color name="transparent_dark_background">#33000000</color> | ||||
| </resources> | ||||
|   | ||||
| @@ -26,4 +26,10 @@ | ||||
|         <item name="android:textColorSecondary">@color/white</item> | ||||
|         <item name="actionMenuTextColor">@color/white</item> | ||||
|     </style> | ||||
|  | ||||
|     <style name="Theme.AppCompat.ImageActivity" parent="NoBar"> | ||||
|         <item name="android:windowBackground">@color/transparent_dark_background</item> | ||||
|         <item name="android:colorBackgroundCacheHint">@null</item> | ||||
|         <item name="android:windowIsTranslucent">true</item> | ||||
|     </style> | ||||
| </resources> | ||||
|   | ||||
							
								
								
									
										41
									
								
								androidApp/src/main/res/xml/image_close_scene.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								androidApp/src/main/res/xml/image_close_scene.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <MotionScene xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:motion="http://schemas.android.com/apk/res-auto" | ||||
|     android:id="@+id/motionLayout"> | ||||
|  | ||||
|     <Transition | ||||
|         motion:constraintSetStart="@+id/start" | ||||
|         motion:constraintSetEnd="@+id/end" | ||||
|         motion:duration="500" | ||||
|         motion:motionInterpolator="linear"> | ||||
|  | ||||
|         <OnSwipe | ||||
|             motion:touchAnchorId="@+id/scrollView" | ||||
|             motion:touchAnchorSide="top" | ||||
|             motion:onTouchUp="autoCompleteToStart" /> | ||||
|     </Transition> | ||||
|  | ||||
|     <ConstraintSet android:id="@+id/start"> | ||||
|  | ||||
|         <Constraint | ||||
|             android:id="@id/scrollView" | ||||
|             motion:layout_constraintBottom_toBottomOf="parent" | ||||
|             motion:layout_constraintTop_toBottomOf="@+id/appBarLayout" | ||||
|             motion:layout_constraintEnd_toEndOf="parent" | ||||
|             motion:layout_constraintStart_toStartOf="parent"> | ||||
|         </Constraint> | ||||
|     </ConstraintSet> | ||||
|  | ||||
|     <ConstraintSet android:id="@+id/end"> | ||||
|  | ||||
|         <Constraint | ||||
|             android:id="@+id/scrollView" | ||||
|             android:layout_width="100dp" | ||||
|             android:layout_height="100dp" | ||||
|             android:layout_marginBottom="0dp" | ||||
|             motion:layout_constraintStart_toStartOf="parent" | ||||
|             motion:layout_constraintBottom_toBottomOf="parent" | ||||
|             motion:layout_constraintEnd_toEndOf="parent"> | ||||
|         </Constraint> | ||||
|     </ConstraintSet> | ||||
| </MotionScene> | ||||
| @@ -20,6 +20,8 @@ import org.junit.Test | ||||
|  | ||||
| private const val BASE_URL = "https://test.com/selfoss/" | ||||
|  | ||||
| private const val USERNAME = "username" | ||||
|  | ||||
| private const val SPOUT = "spouts\\rss\\fulltextrss" | ||||
|  | ||||
| private const val IMAGE_URL = "b3aa8a664d08eb15d6ff1db2fa83e0d9.png" | ||||
| @@ -49,7 +51,7 @@ class RepositoryTest { | ||||
|         repository = Repository(api, appSettingsService, isConnectionAvailable, db) | ||||
|  | ||||
|         runBlocking { | ||||
|             repository.updateApiVersion() | ||||
|             repository.updateApiInformation() | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -58,12 +60,13 @@ class RepositoryTest { | ||||
|         clearAllMocks() | ||||
|         every { appSettingsService.getApiVersion() } returns 4 | ||||
|         every { appSettingsService.getBaseUrl() } returns BASE_URL | ||||
|         every { appSettingsService.getUserName() } returns USERNAME | ||||
|         every { appSettingsService.isItemCachingEnabled() } returns false | ||||
|         every { appSettingsService.isUpdateSourcesEnabled() } returns false | ||||
|  | ||||
|         coEvery { api.version() } returns StatusAndData( | ||||
|         coEvery { api.apiInformation() } returns StatusAndData( | ||||
|             success = true, | ||||
|             data = SelfossModel.ApiVersion("2.19-ba1e8e3", "4.0.0") | ||||
|             data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(false, true)) | ||||
|         ) | ||||
|         coEvery { api.stats() } returns StatusAndData( | ||||
|             success = true, | ||||
| @@ -81,7 +84,7 @@ class RepositoryTest { | ||||
|     fun instantiate_repository() { | ||||
|         initializeRepository() | ||||
|  | ||||
|         coVerify(exactly = 1) { api.version() } | ||||
|         coVerify(exactly = 1) { api.apiInformation() } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
| @@ -90,7 +93,7 @@ class RepositoryTest { | ||||
|  | ||||
|         initializeRepository(MutableStateFlow(false)) | ||||
|  | ||||
|         coVerify(exactly = 0) { api.version() } | ||||
|         coVerify(exactly = 0) { api.apiInformation() } | ||||
|         coVerify(exactly = 0) { api.stats() } | ||||
|     } | ||||
|  | ||||
| @@ -110,10 +113,70 @@ class RepositoryTest { | ||||
|         verify(exactly = 1) { appSettingsService.updateApiVersion(4) } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun get_public_access() { | ||||
|         every { appSettingsService.updatePublicAccess(any()) } returns Unit | ||||
|         coEvery { api.apiInformation() } returns StatusAndData( | ||||
|             success = true, | ||||
|             data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(true, true)) | ||||
|         ) | ||||
|         every { appSettingsService.getUserName() } returns "" | ||||
|  | ||||
|         initializeRepository() | ||||
|  | ||||
|         coVerify(exactly = 1) { api.apiInformation() } | ||||
|         coVerify(exactly = 1) { appSettingsService.updatePublicAccess(true) } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun get_public_access_username_not_empty() { | ||||
|         every { appSettingsService.updatePublicAccess(any()) } returns Unit | ||||
|         coEvery { api.apiInformation() } returns StatusAndData( | ||||
|             success = true, | ||||
|             data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(true, true)) | ||||
|         ) | ||||
|         every { appSettingsService.getUserName() } returns "username" | ||||
|  | ||||
|         initializeRepository() | ||||
|  | ||||
|         coVerify(exactly = 1) { api.apiInformation() } | ||||
|         coVerify(exactly = 0) { appSettingsService.updatePublicAccess(true) } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun get_public_access_no_auth() { | ||||
|         every { appSettingsService.updatePublicAccess(any()) } returns Unit | ||||
|         coEvery { api.apiInformation() } returns StatusAndData( | ||||
|             success = true, | ||||
|             data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(true, false)) | ||||
|         ) | ||||
|         every { appSettingsService.getUserName() } returns "" | ||||
|  | ||||
|         initializeRepository() | ||||
|  | ||||
|         coVerify(exactly = 1) { api.apiInformation() } | ||||
|         coVerify(exactly = 0) { appSettingsService.updatePublicAccess(true) } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun get_public_access_disabled() { | ||||
|         every { appSettingsService.updatePublicAccess(any()) } returns Unit | ||||
|         coEvery { api.apiInformation() } returns StatusAndData( | ||||
|             success = true, | ||||
|             data = SelfossModel.ApiInformation("2.19-ba1e8e3", "4.0.0", SelfossModel.ApiConfiguration(false, true)) | ||||
|         ) | ||||
|         every { appSettingsService.getUserName() } returns "" | ||||
|  | ||||
|         initializeRepository() | ||||
|  | ||||
|         coVerify(exactly = 1) { api.apiInformation() } | ||||
|         coVerify(exactly = 0) { appSettingsService.updatePublicAccess(true) } | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     fun get_api_1_date_with_api_4_version_stored() { | ||||
|         every { appSettingsService.getApiVersion() } returns 4 | ||||
|         coEvery { api.version() } returns StatusAndData(success = false, null) | ||||
|         coEvery { api.apiInformation() } returns StatusAndData(success = false, null) | ||||
|         val itemParameters = FakeItemParameters() | ||||
|         itemParameters.datetime = "2021-04-23 11:45:32" | ||||
|         coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns | ||||
|   | ||||
| @@ -35,17 +35,32 @@ class SelfossModel { | ||||
|     ) | ||||
|  | ||||
|     @Serializable | ||||
|     data class ApiVersion( | ||||
|     data class ApiInformation( | ||||
|         val version: String?, | ||||
|         val apiversion: String? | ||||
|         val apiversion: String?, | ||||
|         val configuration: ApiConfiguration? | ||||
|     ) { | ||||
|         fun getApiMajorVersion() : Int { | ||||
|         fun getApiMajorVersion(): Int { | ||||
|             var versionNumber = 0 | ||||
|             if (apiversion != null) { | ||||
|                 versionNumber = apiversion.substringBefore(".").toInt() | ||||
|             } | ||||
|             return versionNumber | ||||
|         } | ||||
|  | ||||
|         fun getApiConfiguration() = configuration ?: ApiConfiguration(null, null) | ||||
|     } | ||||
|  | ||||
|     @Serializable | ||||
|     data class ApiConfiguration( | ||||
|         @Serializable(with = BooleanSerializer::class) | ||||
|         val publicMode: Boolean?, | ||||
|         @Serializable(with = BooleanSerializer::class) | ||||
|         val authEnabled: Boolean? | ||||
|     ) { | ||||
|         fun isAuthEnabled() = authEnabled ?: true | ||||
|  | ||||
|         fun isPublicModeEnabled() = publicMode ?: false | ||||
|     } | ||||
|  | ||||
|     @Serializable | ||||
|   | ||||
| @@ -439,13 +439,23 @@ class Repository( | ||||
|         api.refreshLoginInformation() | ||||
|     } | ||||
|  | ||||
|     suspend fun updateApiVersion() { | ||||
|     suspend fun updateApiInformation() { | ||||
|         val apiMajorVersion = appSettingsService.getApiVersion() | ||||
|  | ||||
|         if (isNetworkAvailable()) { | ||||
|             val fetchedVersion = api.version() | ||||
|             if (fetchedVersion.success && fetchedVersion.data != null && fetchedVersion.data.getApiMajorVersion() != apiMajorVersion) { | ||||
|                 appSettingsService.updateApiVersion(fetchedVersion.data.getApiMajorVersion()) | ||||
|             val fetchedInformation = api.apiInformation() | ||||
|             if (fetchedInformation.success && fetchedInformation.data != null) { | ||||
|                 if (fetchedInformation.data.getApiMajorVersion() != apiMajorVersion) { | ||||
|                     appSettingsService.updateApiVersion(fetchedInformation.data.getApiMajorVersion()) | ||||
|                 } | ||||
|                 // Check if we're accessing the instance in public mode | ||||
|                 // This happens when auth and public mode are enabled but | ||||
|                 // no credentials are provided to login | ||||
|                 if (appSettingsService.getUserName().isEmpty() | ||||
|                     && fetchedInformation.data.getApiConfiguration().isAuthEnabled() | ||||
|                     && fetchedInformation.data.getApiConfiguration().isPublicModeEnabled()) { | ||||
|                     appSettingsService.updatePublicAccess(true) | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -191,7 +191,7 @@ class SelfossApi(private val appSettingsService: AppSettingsService) { | ||||
|             } | ||||
|         }) | ||||
|  | ||||
|     suspend fun version(): StatusAndData<SelfossModel.ApiVersion> = | ||||
|     suspend fun apiInformation(): StatusAndData<SelfossModel.ApiInformation> = | ||||
|         bodyOrFailure(client.tryToGet(url("/api/about"))) | ||||
|  | ||||
|     suspend fun markAsRead(id: String): SuccessResponse = | ||||
|   | ||||
| @@ -7,6 +7,7 @@ class AppSettingsService { | ||||
|  | ||||
|     // Api related | ||||
|     private var _apiVersion: Int = -1 | ||||
|     private var _publicAccess: Boolean? = null | ||||
|     private var _baseUrl: String = "" | ||||
|     private var _userName: String = "" | ||||
|     private var _password: String = "" | ||||
| @@ -48,10 +49,32 @@ class AppSettingsService { | ||||
|         return _apiVersion | ||||
|     } | ||||
|  | ||||
|  | ||||
|     fun updateApiVersion(apiMajorVersion: Int) { | ||||
|         settings.putInt(API_VERSION_MAJOR, apiMajorVersion) | ||||
|         refreshApiVersion() | ||||
|     } | ||||
|  | ||||
|     private fun refreshApiVersion() { | ||||
|         _apiVersion = settings.getInt(API_VERSION_MAJOR, -1) | ||||
|     } | ||||
|  | ||||
|     fun getPublicAccess(): Boolean { | ||||
|         if (_publicAccess == null) { | ||||
|             refreshPublicAccess() | ||||
|         } | ||||
|         return _publicAccess!! | ||||
|     } | ||||
|  | ||||
|     fun updatePublicAccess(publicAccess: Boolean) { | ||||
|         settings.putBoolean(API_PUBLIC_ACCESS, publicAccess) | ||||
|         refreshPublicAccess() | ||||
|     } | ||||
|  | ||||
|     private fun refreshPublicAccess() { | ||||
|         _publicAccess = settings.getBoolean(API_PUBLIC_ACCESS, false) | ||||
|     } | ||||
|  | ||||
|     fun getBaseUrl(): String { | ||||
|         if (_baseUrl.isEmpty()) { | ||||
|             refreshBaseUrl() | ||||
| @@ -333,6 +356,7 @@ class AppSettingsService { | ||||
|         refreshUsername() | ||||
|         refreshBaseUrl() | ||||
|         refreshApiVersion() | ||||
|         refreshPublicAccess() | ||||
|     } | ||||
|  | ||||
|     fun refreshUserSettings() { | ||||
| @@ -376,11 +400,6 @@ class AppSettingsService { | ||||
|         refreshApiSettings() | ||||
|     } | ||||
|  | ||||
|     fun updateApiVersion(apiMajorVersion: Int) { | ||||
|         settings.putInt(API_VERSION_MAJOR, apiMajorVersion) | ||||
|         refreshApiVersion() | ||||
|     } | ||||
|  | ||||
|     fun clearAll() { | ||||
|         settings.clear() | ||||
|         refreshApiSettings() | ||||
| @@ -409,6 +428,8 @@ class AppSettingsService { | ||||
|  | ||||
|         const val API_VERSION_MAJOR = "apiVersionMajor" | ||||
|  | ||||
|         const val API_PUBLIC_ACCESS = "apiPublicAccess" | ||||
|  | ||||
|         const val API_ITEMS_NUMBER = "prefer_api_items_number" | ||||
|  | ||||
|         const val API_TIMEOUT = "api_timeout" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user