Forráskód Böngészése

Merge pull request #11228 from nextcloud/e2eOffline

E2E setup is only possible with internet connection
Andy Scherzinger 2 éve
szülő
commit
23b9bc9ece

+ 10 - 4
app/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java

@@ -56,6 +56,7 @@ import com.nextcloud.client.di.Injectable;
 import com.nextcloud.client.etm.EtmActivity;
 import com.nextcloud.client.logger.ui.LogsActivity;
 import com.nextcloud.client.network.ClientFactory;
+import com.nextcloud.client.network.ConnectivityService;
 import com.nextcloud.client.preferences.AppPreferences;
 import com.nextcloud.client.preferences.AppPreferencesImpl;
 import com.nextcloud.client.preferences.DarkMode;
@@ -148,6 +149,7 @@ public class SettingsActivity extends PreferenceActivity
     @Inject UserAccountManager accountManager;
     @Inject ClientFactory clientFactory;
     @Inject ViewThemeUtils viewThemeUtils;
+    @Inject ConnectivityService connectivityService;
 
 
     @SuppressWarnings("deprecation")
@@ -436,10 +438,14 @@ public class SettingsActivity extends PreferenceActivity
                 preferenceCategoryMore.removePreference(preference);
             } else {
                 preference.setOnPreferenceClickListener(p -> {
-                    Intent i = new Intent(MainApp.getAppContext(), SetupEncryptionActivity.class);
-                    i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
-                    i.putExtra("EXTRA_USER", user);
-                    startActivityForResult(i, ACTION_E2E);
+                    if (connectivityService.getConnectivity().isConnected()) {
+                        Intent i = new Intent(MainApp.getAppContext(), SetupEncryptionActivity.class);
+                        i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+                        i.putExtra("EXTRA_USER", user);
+                        startActivityForResult(i, ACTION_E2E);
+                    } else {
+                        DisplayUtils.showSnackMessage(this, R.string.e2e_offline);
+                    }
 
                     return true;
                 });

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -1068,6 +1068,7 @@
     <string name="error_showing_encryption_dialog">Error showing encryption setup dialog!</string>
     <string name="prefs_keys_exist">Add end-to-end encryption to this client</string>
     <string name="add_new_secure_file_drop">Add new secure file drop</string>
+    <string name="e2e_offline">Not possible without internet connection</string>
     <string name="scan_page">Scan page</string>
     <string name="done">Done</string>
     <string name="document_scan_pdf_generation_in_progress">Generating PDF…</string>