3232import com .zebra .ai_multibarcodes_capture .adapters .LanguageAdapter ;
3333import com .zebra .ai_multibarcodes_capture .filemanagement .EExportMode ;
3434import com .zebra .ai_multibarcodes_capture .helpers .EProcessingMode ;
35- import com .zebra .ai_multibarcodes_capture .helpers .KeystoreHelper ;
3635import com .zebra .ai_multibarcodes_capture .helpers .LocaleHelper ;
3736import com .zebra .ai_multibarcodes_capture .helpers .LogUtils ;
3837import com .zebra .ai_multibarcodes_capture .managedconfig .ManagedConfigurationReceiver ;
@@ -66,11 +65,10 @@ public class SettingsActivity extends AppCompatActivity {
6665
6766 private static final String TAG = "SettingsActivity" ;
6867
69- private EditText etPrefix , etHttpsEndpoint , etUsername , etPassword ;
68+ private EditText etPrefix , etHttpsEndpoint ;
7069 private RadioButton rbCSV , rbTXT , rbXSLX ;
71- private CheckBox cbAuthentication ;
7270 private ImageView ivToggleSymbologies , ivToggleFileTypes , ivToggleAdvanced , ivToggleHttpsPost ;
73- private LinearLayout llSymbologies , llAdvancedContent , llFileProcessingContent , llHttpsPost , llAuthenticationGroup , llFileProcessing , llHttpsPostContent ;
71+ private LinearLayout llSymbologies , llAdvancedContent , llFileProcessingContent , llHttpsPost , llFileProcessing , llHttpsPostContent ;
7472 private RadioGroup rgFileTypes , rgModelInputSize , rgCameraResolution , rgInferenceType ;
7573 private RadioButton rbSmallInputSize , rbMediumInputSize , rbLargeInputSize ;
7674 private RadioButton rb1MPResolution , rb2MPResolution , rb4MPResolution , rb8MPResolution ;
@@ -84,8 +82,6 @@ public class SettingsActivity extends AppCompatActivity {
8482 private LanguageAdapter languageAdapter ;
8583 private List <LanguageItem > languageList ;
8684 private String pendingLanguageCode = null ; // Track pending language changes
87- private KeystoreHelper keystoreHelper ;
88- private String originalDummyPassword = null ; // Track original dummy password to detect changes
8985 private CheckBox cbAUSTRALIAN_POSTAL , cbAZTEC , cbCANADIAN_POSTAL , cbCHINESE_2OF5 , cbCODABAR ;
9086 private CheckBox cbCODE11 , cbCODE39 , cbCODE93 , cbCODE128 , cbCOMPOSITE_AB , cbCOMPOSITE_C ;
9187 private CheckBox cbD2OF5 , cbDATAMATRIX , cbDOTCODE , cbDUTCH_POSTAL , cbEAN_8 , cbEAN_13 ;
@@ -130,14 +126,8 @@ protected void onCreate(Bundle savedInstanceState) {
130126 Toolbar toolbar = findViewById (R .id .toolbar );
131127 setSupportActionBar (toolbar );
132128
133- // Initialize KeystoreHelper
134- keystoreHelper = new KeystoreHelper (this );
135-
136129 etPrefix = findViewById (R .id .etPrefix );
137130 etHttpsEndpoint = findViewById (R .id .etHttpsEndpoint );
138- etUsername = findViewById (R .id .etUsername );
139- etPassword = findViewById (R .id .etPassword );
140- cbAuthentication = findViewById (R .id .cbAuthentication );
141131 rbCSV = findViewById (R .id .rbCSV );
142132 rbTXT = findViewById (R .id .rbTxt );
143133 rbXSLX = findViewById (R .id .rbXSLX );
@@ -151,7 +141,6 @@ protected void onCreate(Bundle savedInstanceState) {
151141 llFileProcessing = findViewById (R .id .llFileProcessing );
152142 llHttpsPost = findViewById (R .id .llHttpsPost );
153143 llHttpsPostContent = findViewById (R .id .llHttpsPostContent );
154- llAuthenticationGroup = findViewById (R .id .llAuthenticationGroup );
155144 rgFileTypes = findViewById (R .id .rgFileTypes );
156145 rgModelInputSize = findViewById (R .id .rgModelInputSize );
157146 rgCameraResolution = findViewById (R .id .rgCameraResolution );
@@ -279,27 +268,6 @@ public void onClick(View v) {
279268 }
280269 });
281270
282- // Set up authentication checkbox listener
283- cbAuthentication .setOnCheckedChangeListener (new CompoundButton .OnCheckedChangeListener () {
284- @ Override
285- public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
286- if (isChecked ) {
287- llAuthenticationGroup .setVisibility (View .VISIBLE );
288- } else {
289- llAuthenticationGroup .setVisibility (View .GONE );
290- // Clear credentials when authentication is disabled for security
291- etUsername .setText ("" );
292- etPassword .setText ("" );
293- originalDummyPassword = "" ;
294- try {
295- keystoreHelper .clearAllCredentials ();
296- LogUtils .d (TAG , "Cleared credentials when authentication disabled" );
297- } catch (Exception e ) {
298- LogUtils .e (TAG , "Error clearing credentials: " + e .getMessage ());
299- }
300- }
301- }
302- });
303271
304272 // Setup symbology checkboxes change listeners
305273 setupSymbologyListeners ();
@@ -782,81 +750,14 @@ private void saveProcessingMode(SharedPreferences.Editor editor) {
782750
783751 private void loadHttpsPostSettings (SharedPreferences sharedPreferences ) {
784752 String endpoint = sharedPreferences .getString (SHARED_PREFERENCES_HTTPS_ENDPOINT , SHARED_PREFERENCES_HTTPS_ENDPOINT_DEFAULT );
785- boolean authentication = sharedPreferences .getBoolean (SHARED_PREFERENCES_HTTPS_AUTHENTICATION , SHARED_PREFERENCES_HTTPS_AUTHENTICATION_DEFAULT );
786753
787754 // Load endpoint as-is, supporting both HTTP and HTTPS
788-
789755 etHttpsEndpoint .setText (endpoint );
790- cbAuthentication .setChecked (authentication );
791-
792- // Load username from secure keystore and show dummy password
793- try {
794- String username = keystoreHelper .getUsername ();
795- etUsername .setText (username );
796-
797- // Show dummy characters matching the stored password length for security
798- int passwordLength = keystoreHelper .getPasswordLength ();
799- if (passwordLength > 0 ) {
800- // Create dummy password with bullet characters (•)
801- StringBuilder dummyPassword = new StringBuilder ();
802- for (int i = 0 ; i < passwordLength ; i ++) {
803- dummyPassword .append ("•" );
804- }
805- originalDummyPassword = dummyPassword .toString ();
806- etPassword .setText (originalDummyPassword );
807- LogUtils .d (TAG , "Loaded username and displayed dummy password with length: " + passwordLength );
808- } else {
809- originalDummyPassword = "" ;
810- etPassword .setText ("" );
811- LogUtils .d (TAG , "No stored password found" );
812- }
813- } catch (Exception e ) {
814- LogUtils .e (TAG , "Error loading credentials from keystore: " + e .getMessage ());
815- etUsername .setText ("" );
816- etPassword .setText ("" );
817- originalDummyPassword = "" ;
818- }
819-
820- // Set initial visibility of authentication group
821- if (authentication ) {
822- llAuthenticationGroup .setVisibility (View .VISIBLE );
823- } else {
824- llAuthenticationGroup .setVisibility (View .GONE );
825- }
826756 }
827757
828758 private void saveHttpsPostSettings (SharedPreferences .Editor editor ) {
829759 String endpoint = etHttpsEndpoint .getText ().toString ();
830- boolean authentication = cbAuthentication .isChecked ();
831- String username = etUsername .getText ().toString ();
832- String password = etPassword .getText ().toString ();
833-
834760 editor .putString (SHARED_PREFERENCES_HTTPS_ENDPOINT , endpoint );
835- editor .putBoolean (SHARED_PREFERENCES_HTTPS_AUTHENTICATION , authentication );
836-
837- // Save username and password securely in keystore
838- try {
839- boolean usernameStored = keystoreHelper .storeUsername (username );
840- boolean passwordStored = true ;
841-
842- // Only save password if it has been modified by the user (not the dummy password)
843- if (!password .equals (originalDummyPassword )) {
844- passwordStored = keystoreHelper .storePassword (password );
845- LogUtils .d (TAG , "Password was modified, storing new password" );
846- } else {
847- LogUtils .d (TAG , "Password unchanged (dummy), keeping existing stored password" );
848- }
849-
850- if (usernameStored && passwordStored ) {
851- LogUtils .d (TAG , "Successfully stored credentials in keystore" );
852- } else {
853- LogUtils .w (TAG , "Warning: Some credentials may not have been stored properly" );
854- }
855- } catch (Exception e ) {
856- LogUtils .e (TAG , "Error storing credentials in keystore: " + e .getMessage ());
857- // Show user-friendly error message
858- Toast .makeText (this , "Warning: Could not securely store credentials" , Toast .LENGTH_LONG ).show ();
859- }
860761 }
861762
862763 private String getSelectedExtension ()
0 commit comments