mirror of
				https://codeberg.org/tom79/Fedilab.git
				synced 2025-10-20 11:20:16 +03:00 
			
		
		
		
	Fix #1120 - Display a message when clicking a link without Internet connection
This commit is contained in:
		
							parent
							
								
									97e30e00b4
								
							
						
					
					
						commit
						fc24e63319
					
				
					 3 changed files with 10 additions and 3 deletions
				
			
		|  | @ -22,6 +22,7 @@ import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; | |||
| import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; | ||||
| import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_SOFTWARE; | ||||
| import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_TOKEN; | ||||
| import static app.fedilab.android.mastodon.helper.Helper.TAG; | ||||
| import static app.fedilab.android.mastodon.helper.Helper.displayReleaseNotesIfNeeded; | ||||
| import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor; | ||||
| import static app.fedilab.android.mastodon.ui.drawer.StatusAdapter.sendAction; | ||||
|  | @ -1372,6 +1373,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt | |||
|         filterFetched = false; | ||||
|         networkStateReceiver = new NetworkStateReceiver(); | ||||
|         networkStateReceiver.addListener(this); | ||||
|         registerReceiver(networkStateReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION)); | ||||
|         binding = ActivityMainBinding.inflate(getLayoutInflater()); | ||||
|         setContentView(binding.getRoot()); | ||||
|         setSupportActionBar(binding.toolbar); | ||||
|  | @ -1944,10 +1946,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt | |||
|         } | ||||
|         if (networkStateReceiver != null) { | ||||
|             try { | ||||
|                 networkStateReceiver.removeListener(this); | ||||
|                 unregisterReceiver(networkStateReceiver); | ||||
|             } catch (IllegalArgumentException e) { | ||||
|                 e.printStackTrace(); | ||||
|             } | ||||
|             } catch (Exception ignored) {} | ||||
|         } | ||||
|         SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); | ||||
|         boolean clearCacheExit = sharedpreferences.getBoolean(getString(R.string.SET_CLEAR_CACHE_EXIT), false); | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ package app.fedilab.android.mastodon.helper; | |||
|  * see <http://www.gnu.org/licenses>. */ | ||||
| 
 | ||||
| import static android.content.Context.DOWNLOAD_SERVICE; | ||||
| import static app.fedilab.android.BaseMainActivity.networkAvailable; | ||||
| import static app.fedilab.android.mastodon.activities.BaseActivity.currentThemeId; | ||||
| import static app.fedilab.android.mastodon.helper.LogoHelper.getNotificationIcon; | ||||
| import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor; | ||||
|  | @ -684,6 +685,10 @@ public class Helper { | |||
|         if (url == null) { | ||||
|             return; | ||||
|         } | ||||
|         if(networkAvailable == BaseMainActivity.status.DISCONNECTED){ | ||||
|             Toasty.warning(context, context.getString(R.string.toast_error_internet), Toast.LENGTH_LONG).show(); | ||||
|             return; | ||||
|         } | ||||
|         SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); | ||||
|         boolean customTab = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOM_TABS), true); | ||||
|         if (customTab) { | ||||
|  |  | |||
|  | @ -197,6 +197,7 @@ | |||
|     <string name="toast_bookmark">The message was added to your bookmarks!</string> | ||||
|     <string name="toast_unbookmark">The message was removed from your bookmarks!</string> | ||||
|     <string name="toast_error">Oops ! An error occurred!</string> | ||||
|     <string name="toast_error_internet">There is no Internet connection!</string> | ||||
|     <string name="toast_code_error">An error occurred! The instance did not return an authorisation code!</string> | ||||
|     <string name="toast_error_instance">The instance domain does not seem to be valid!</string> | ||||
|     <string name="toast_error_loading_account">An error occurred while switching between accounts!</string> | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue