rdoeffinger / Dictionary

"QuickDic" offline Dictionary App for Android. Provided downloadable dictionaries are based on Wiktionaries but can also be created from other sources (see DictionaryPC). Remember to use --recursive when cloning! Fork of project that used to be hosted at code.google.com/p/quickdic-dictionary.
Apache License 2.0
325 stars 69 forks source link

Unable to change configuration #75

Closed DirkSchmitt closed 4 years ago

DirkSchmitt commented 7 years ago

Changing the dictionary directory to /storage/6cc44171-88ee-40d2-b464-0d229d438e8b/Android/data/de.reimardoeffinger.quickdic/files doesn't work. The path points to an existing directory on the sdcard.

After reboot the location is lost and points back to the default `/storage/emulated/0/…´ Also after reboot the application thanks again for update to 5.1.0

ls -lZ /storage/6cc44171-88ee-40d2-b464-0d229d438e8b/Android/data/de.reimardoeffinger.quickdic/files                    
total 52732
-rwxrwx--x 1 u0_a140 sdcard_rw u:object_r:sdcardfs:s0 53932864 2017-10-26 13:45 DE.quickdic

I'm using: Version 5.4.0 (93) - Hinzugefügt am 2017-09-10 from the fdroid repository. (→ https://f-droid.org/wiki/page/de.reimardoeffinger.quickdic )

rdoeffinger commented 7 years ago

Do other settings get stored? E.g. font? Which location does it restore to? Something under /storage/emulated/0/Android/.. or /storage/emulated/0/quickDic? It might be something wrong with the code auto-detecting the location. If the path is /storage/emulated/0/quickDic, did you try deleting it? What happens if you force close the app and restart it? If it doesn't reset then, maybe the sdcard doesn't get properly mounted automatically after a reboot so the app thinks the path is invalid (though there is supposed to be an error message for that...)? Did the app request and get permission to access external storage? For some Android versions that is necessary, for some it isn't.

DirkSchmitt commented 7 years ago

Do other settings get stored? E.g. font?

No I retested the stuff on another device. The font is also reset.

Which location does it restore to?

/storage/emulated/0/Android/data/de.reimardoeffinger.quickdic/files*

What happens if you force close the app and restart it?

The effect is the same if I reboot the device or invoke am force-stop de.reimardoeffinger.quickdic

DirkSchmitt commented 7 years ago

The problem could be solved on this device by removing shared_prefs/de.reimardoeffinger.quickdic_preferences.xml

I haven't created a backup. But I will look in the next day on another device with the same problem.

DirkSchmitt commented 7 years ago

I reproduced the problem on another device. The „immutable“ configuration is

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<map>
  <boolean name="showLocal" value="true"/>
  <string name="searchToken"/>
  <boolean name="showPrevNextButtons" value="true"/>
  <boolean name="saveOnlyFirstSubentry" value="false"/>
  <boolean name="clickOpensContextMenu" value="false"/>
  <string name="theme">themeLight</string>
  <string name="fontSize">14</string>
  <string name="font">FreeSerif.otf.jpg</string>
  <string name="thanksForUpdatingVersion">5.1.0</string>
  <string name="indexShortName">EN</string>
  <string name="wordListFile">/storage/emulated/0/Android/data/de.reimardoeffinger.quickdic/files/wordList.txt</string>
  <string name="quickdicDirectory">/storage/5c7bf80d-0b32-4cdd-b8a4-1344b0ba2b6d/Android/data/de.reimardoeffinger.quickdic/files</string>
</map>

Woking mitigation is: Deleting the file and recreate it by starting the QuickDic app creates a mutable configuration. After customisation it is now:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<map>
  <boolean name="showLocal" value="true"/>
  <string name="theme">themeLight</string>
  <string name="fontSize">14</string>
  <string name="font">FreeSerif.otf.jpg</string>
  <string name="thanksForUpdatingVersion">5.1.0</string>
  <boolean name="showPrevNextButtons" value="true"/>
  <boolean name="saveOnlyFirstSubentry" value="true"/>
  <boolean name="clickOpensContextMenu" value="false"/>
  <string name="quickdicDirectory">/storage/30156ee5-0cad-45fc-958e-81072604e8f4/Android/data/de.reimardoeffinger.quickdic/files</string>
  <string name="wordListFile">/storage/30156ee5-0cad-45fc-958e-81072604e8f4/Android/data/de.reimardoeffinger.quickdic/files/wordList.txt</string>
</map>

Structural differences beetween the files is that the immutable version contains the entries:

rdoeffinger commented 7 years ago

Those configuration settings should appear again after you use the app again. They just store things like your last search term. Problem is, as far as I can tell all this is simply handled by android.content.SharedPreferences, not by any code specific to this app. So I am fairly tempted to just blame the Android version you are using for having a SharedPreferences that isn't working right (though admittedly it's very easy to be wrong about such things).

rdoeffinger commented 7 years ago

One thing that seems very wrong is that if "indexShortName" is set, "dictFile" should always be set as well... EDIT: Ah, that actually would happen if the dictionary failed to open the last time... Doesn't explain the issue though. I did make some commits to clean this up though, e.g. the searchToken is NEVER used, so we shouldn't be writing it really, but I doubt it will change anything.

rdoeffinger commented 6 years ago

I think I never managed to reproduce this, any idea if it still happens?

rdoeffinger commented 4 years ago

Closing on the assumption it was either a fluke, covered by my code cleanup or a Android bug from times long past.