]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Fix "Format string ... is not valid format string..." error
authorTobias Brunner <tobias@strongswan.org>
Fri, 22 Jul 2022 12:10:45 +0000 (14:10 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 21 Sep 2022 13:15:18 +0000 (15:15 +0200)
The linter complained that two of the strings don't actually contain any
printf-specifiers (i.e. don't expect any arguments) and therefore
shouldn't be used with String.format().

src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java

index 5d5fd91443b37e230b22d7d99ce61fd6c1574392..06821c6a60884efaeda77da39af351b2249d0e90 100644 (file)
@@ -453,20 +453,20 @@ public class VpnProfileControlActivity extends AppCompatActivity
                {
                        final Bundle profileInfo = getArguments();
                        int icon = android.R.drawable.ic_dialog_alert;
-                       int title = R.string.connect_profile_question;
+                       String title = String.format(getString(R.string.connect_profile_question), profileInfo.getString(PROFILE_NAME));
                        int message = R.string.replaces_active_connection;
                        int button = R.string.connect;
 
                        if (profileInfo.getBoolean(PROFILE_RECONNECT))
                        {
                                icon = android.R.drawable.ic_dialog_info;
-                               title = R.string.vpn_connected;
+                               title = getString(R.string.vpn_connected);
                                message = R.string.vpn_profile_connected;
                                button = R.string.reconnect;
                        }
                        else if (profileInfo.getBoolean(PROFILE_DISCONNECT))
                        {
-                               title = R.string.disconnect_question;
+                               title = getString(R.string.disconnect_question);
                                message = R.string.disconnect_active_connection;
                                button = R.string.disconnect;
                        }
@@ -504,7 +504,7 @@ public class VpnProfileControlActivity extends AppCompatActivity
 
                        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
                                .setIcon(icon)
-                               .setTitle(String.format(getString(title), profileInfo.getString(PROFILE_NAME)))
+                               .setTitle(title)
                                .setMessage(message);
 
                        if (profileInfo.getBoolean(PROFILE_DISCONNECT))