mirror of
				https://framagit.org/tom79/fedilab-tube
				synced 2025-06-05 21:09:11 +02:00 
			
		
		
		
	Some fixes
This commit is contained in:
		| @@ -18,6 +18,9 @@ | |||||||
|     <string name="set_video_in_list">Vidéos dans une liste</string> |     <string name="set_video_in_list">Vidéos dans une liste</string> | ||||||
|     <string name="set_video_in_list_description">Change la mise en page pour afficher les vidéos dans une liste</string> |     <string name="set_video_in_list_description">Change la mise en page pour afficher les vidéos dans une liste</string> | ||||||
|  |  | ||||||
|  |     <string name="_retry">Réessayer</string> | ||||||
|  |     <string name="refresh_token_failed">Échec de rafraîchissement du jeton d\'accès</string> | ||||||
|  |     <string name="refresh_token_failed_message">Vous pouvez réessayer de le rafraîchir ou simplement déconnecter le compte</string> | ||||||
|     <string name="export_list">Exporter</string> |     <string name="export_list">Exporter</string> | ||||||
|     <string name="import_list">Importer</string> |     <string name="import_list">Importer</string> | ||||||
|     <string name="originally_published">Date de publication</string> |     <string name="originally_published">Date de publication</string> | ||||||
|   | |||||||
| @@ -105,6 +105,9 @@ | |||||||
|         <item>12 hours</item> |         <item>12 hours</item> | ||||||
|     </string-array> |     </string-array> | ||||||
|  |  | ||||||
|  |     <string name="_retry">Retry</string> | ||||||
|  |     <string name="refresh_token_failed">Token refresh failed!</string> | ||||||
|  |     <string name="refresh_token_failed_message">You can retry this action or simply disconnect the current account</string> | ||||||
|     <string name="yes">Yes</string> |     <string name="yes">Yes</string> | ||||||
|     <string name="no">No</string> |     <string name="no">No</string> | ||||||
|     <string name="cancel">Cancel</string> |     <string name="cancel">Cancel</string> | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ import android.net.Uri; | |||||||
| import android.os.Build; | import android.os.Build; | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.os.Handler; | import android.os.Handler; | ||||||
|  | import android.util.Log; | ||||||
| import android.view.Menu; | import android.view.Menu; | ||||||
| import android.view.MenuItem; | import android.view.MenuItem; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| @@ -194,6 +195,7 @@ public class MainActivity extends AppCompatActivity { | |||||||
|     @Override |     @Override | ||||||
|     protected void onCreate(Bundle savedInstanceState) { |     protected void onCreate(Bundle savedInstanceState) { | ||||||
|         super.onCreate(savedInstanceState); |         super.onCreate(savedInstanceState); | ||||||
|  |         Log.v(Helper.TAG, "onCreate: " + savedInstanceState); | ||||||
|         binding = ActivityMainBinding.inflate(getLayoutInflater()); |         binding = ActivityMainBinding.inflate(getLayoutInflater()); | ||||||
|         View view = binding.getRoot(); |         View view = binding.getRoot(); | ||||||
|         setContentView(view); |         setContentView(view); | ||||||
| @@ -238,7 +240,7 @@ public class MainActivity extends AppCompatActivity { | |||||||
|         mostLikedFragment.setArguments(bundle); |         mostLikedFragment.setArguments(bundle); | ||||||
|  |  | ||||||
|         overviewFragment = new DisplayOverviewFragment(); |         overviewFragment = new DisplayOverviewFragment(); | ||||||
|  |         Log.v(Helper.TAG, "Helper.isLoggedIn(MainActivity.this): " + Helper.isLoggedIn(MainActivity.this)); | ||||||
|         if (!Helper.isLoggedIn(MainActivity.this)) { |         if (!Helper.isLoggedIn(MainActivity.this)) { | ||||||
|             PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); |             PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); | ||||||
|             binding.viewpager.setAdapter(mPagerAdapter); |             binding.viewpager.setAdapter(mPagerAdapter); | ||||||
| @@ -278,6 +280,43 @@ public class MainActivity extends AppCompatActivity { | |||||||
|         if (Helper.isLoggedIn(MainActivity.this)) { |         if (Helper.isLoggedIn(MainActivity.this)) { | ||||||
|  |  | ||||||
|             navView.inflateMenu(R.menu.bottom_nav_menu_connected); |             navView.inflateMenu(R.menu.bottom_nav_menu_connected); | ||||||
|  |             refreshToken(); | ||||||
|  |  | ||||||
|  |         } else { | ||||||
|  |             navView.inflateMenu(R.menu.bottom_nav_menu); | ||||||
|  |         } | ||||||
|  |         peertubeInformation = new PeertubeInformation(); | ||||||
|  |         peertubeInformation.setCategories(new LinkedHashMap<>()); | ||||||
|  |         peertubeInformation.setLanguages(new LinkedHashMap<>()); | ||||||
|  |         peertubeInformation.setLicences(new LinkedHashMap<>()); | ||||||
|  |         peertubeInformation.setPrivacies(new LinkedHashMap<>()); | ||||||
|  |         peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>()); | ||||||
|  |         peertubeInformation.setTranslations(new LinkedHashMap<>()); | ||||||
|  |         startInForeground(); | ||||||
|  |  | ||||||
|  |         if (BuildConfig.google_restriction && BuildConfig.full_instances) { | ||||||
|  |             RateThisApp.onCreate(this); | ||||||
|  |             RateThisApp.showRateDialogIfNeeded(this); | ||||||
|  |         } | ||||||
|  |         if (!BuildConfig.full_instances) { | ||||||
|  |             PlaylistExportHelper.manageIntentUrl(MainActivity.this, getIntent()); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public DisplayVideosFragment getSubscriptionFragment() { | ||||||
|  |         return subscriptionFragment; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void startInForeground() { | ||||||
|  |         Intent notificationIntent = new Intent(this, RetrieveInfoService.class); | ||||||
|  |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||||||
|  |             startForegroundService(notificationIntent); | ||||||
|  |         } else { | ||||||
|  |             startService(notificationIntent); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void refreshToken() { | ||||||
|         new Thread(() -> { |         new Thread(() -> { | ||||||
|             final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); |             final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); | ||||||
|             String tokenStr = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); |             String tokenStr = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); | ||||||
| @@ -300,7 +339,22 @@ public class MainActivity extends AppCompatActivity { | |||||||
|                 try { |                 try { | ||||||
|                     Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams); |                     Token token = new RetrofitPeertubeAPI(MainActivity.this).manageToken(oauthParams); | ||||||
|                     if (token == null && Helper.instanceOnline(instance)) { |                     if (token == null && Helper.instanceOnline(instance)) { | ||||||
|                             runOnUiThread(() -> Helper.logoutCurrentUser(MainActivity.this, finalAccount)); |                         runOnUiThread(() -> { | ||||||
|  |                             AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); | ||||||
|  |                             alt_bld.setTitle(R.string.refresh_token_failed); | ||||||
|  |                             alt_bld.setMessage(R.string.refresh_token_failed_message); | ||||||
|  |                             alt_bld.setNegativeButton(R.string.action_logout, (dialog, id) -> { | ||||||
|  |                                 dialog.dismiss(); | ||||||
|  |                                 Helper.logoutCurrentUser(MainActivity.this, finalAccount); | ||||||
|  |                             }); | ||||||
|  |                             alt_bld.setPositiveButton(R.string._retry, (dialog, id) -> { | ||||||
|  |                                 dialog.dismiss(); | ||||||
|  |                                 refreshToken(); | ||||||
|  |                             }); | ||||||
|  |                             AlertDialog alert = alt_bld.create(); | ||||||
|  |                             alert.show(); | ||||||
|  |  | ||||||
|  |                         }); | ||||||
|                         return; |                         return; | ||||||
|                     } else if (token == null) { |                     } else if (token == null) { | ||||||
|                         return; |                         return; | ||||||
| @@ -345,40 +399,8 @@ public class MainActivity extends AppCompatActivity { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         }).start(); |         }).start(); | ||||||
|  |  | ||||||
|         } else { |  | ||||||
|             navView.inflateMenu(R.menu.bottom_nav_menu); |  | ||||||
|         } |  | ||||||
|         peertubeInformation = new PeertubeInformation(); |  | ||||||
|         peertubeInformation.setCategories(new LinkedHashMap<>()); |  | ||||||
|         peertubeInformation.setLanguages(new LinkedHashMap<>()); |  | ||||||
|         peertubeInformation.setLicences(new LinkedHashMap<>()); |  | ||||||
|         peertubeInformation.setPrivacies(new LinkedHashMap<>()); |  | ||||||
|         peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>()); |  | ||||||
|         peertubeInformation.setTranslations(new LinkedHashMap<>()); |  | ||||||
|         startInForeground(); |  | ||||||
|  |  | ||||||
|         if (BuildConfig.google_restriction && BuildConfig.full_instances) { |  | ||||||
|             RateThisApp.onCreate(this); |  | ||||||
|             RateThisApp.showRateDialogIfNeeded(this); |  | ||||||
|         } |  | ||||||
|         if (!BuildConfig.full_instances) { |  | ||||||
|             PlaylistExportHelper.manageIntentUrl(MainActivity.this, getIntent()); |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public DisplayVideosFragment getSubscriptionFragment() { |  | ||||||
|         return subscriptionFragment; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     private void startInForeground() { |  | ||||||
|         Intent notificationIntent = new Intent(this, RetrieveInfoService.class); |  | ||||||
|         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |  | ||||||
|             startForegroundService(notificationIntent); |  | ||||||
|         } else { |  | ||||||
|             startService(notificationIntent); |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCreateOptionsMenu(@NotNull Menu menu) { |     public boolean onCreateOptionsMenu(@NotNull Menu menu) { | ||||||
| @@ -610,6 +632,7 @@ public class MainActivity extends AppCompatActivity { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onNewIntent(Intent intent) { |     protected void onNewIntent(Intent intent) { | ||||||
|  |         Log.v(Helper.TAG, "onNewIntent: " + intent); | ||||||
|         super.onNewIntent(intent); |         super.onNewIntent(intent); | ||||||
|         if (intent == null) |         if (intent == null) | ||||||
|             return; |             return; | ||||||
|   | |||||||
| @@ -1519,7 +1519,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             case AUTONEXT: |             case AUTONEXT: | ||||||
|                 binding.subMenuTitle.setText(R.string.set_autoplay); |                 binding.subMenuTitle.setText(R.string.set_autoplay_next_video_settings); | ||||||
|                 SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); |                 SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); | ||||||
|                 boolean autoplayNextVideo = sharedpreferences.getBoolean(getString(R.string.set_autoplay_next_video_choice), true); |                 boolean autoplayNextVideo = sharedpreferences.getBoolean(getString(R.string.set_autoplay_next_video_choice), true); | ||||||
|                 items.add(new MenuItemView(0, getString(R.string.no), !autoplayNextVideo)); |                 items.add(new MenuItemView(0, getString(R.string.no), !autoplayNextVideo)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user