[android] Make 'Save maps to' menu item always visible

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin 2022-04-22 20:41:10 +03:00 committed by Alexander Borsuk
parent 130caabdb6
commit eef2d289fa
2 changed files with 1 additions and 66 deletions

View file

@ -1,6 +1,5 @@
package com.mapswithme.maps.settings;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@ -51,8 +50,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
{
private static final int REQUEST_INSTALL_DATA = 1;
@NonNull
private final StoragePathManager mPathManager = new StoragePathManager();
@Nullable
private Preference mStoragePref;
@ -71,31 +68,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
private LanguageData mCurrentLanguage;
private String mSelectedLanguage;
private boolean singleStorageOnly()
{
return !mPathManager.hasMoreThanOneStorage();
}
private void updateStoragePrefs()
{
Preference old = findPreference(getString(R.string.pref_storage));
if (singleStorageOnly())
{
if (old != null)
{
removePreference(getString(R.string.pref_settings_general), old);
}
}
else
{
if (old == null && mStoragePref != null)
{
getPreferenceScreen().addPreference(mStoragePref);
}
}
}
private final Preference.OnPreferenceChangeListener mEnabledListener = new Preference.OnPreferenceChangeListener()
{
@Override
@ -285,7 +257,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
mLangInfo = findPreference(getString(R.string.pref_tts_info));
mLangInfoLink = findPreference(getString(R.string.pref_tts_info_link));
initLangInfoLink();
updateStoragePrefs();
initStoragePrefCallbacks();
initMeasureUnitsPrefsCallbacks();
initZoomPrefsCallbacks();
@ -820,31 +791,6 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
category.removePreference(preference);
}
@Override
public void onAttach(Context context)
{
super.onAttach(context);
if (!(context instanceof Activity))
return;
mPathManager.startExternalStorageWatching((Activity) context, new StoragePathManager.OnStorageListChangedListener()
{
@Override
public void onStorageListChanged(List<StorageItem> storageItems, int currentStorageIndex)
{
updateStoragePrefs();
}
}, null);
}
@Override
public void onDetach()
{
super.onDetach();
mPathManager.stopExternalStorageWatching();
}
enum ThemeMode
{
DEFAULT(R.string.theme_default),

View file

@ -131,11 +131,6 @@ public class StoragePathManager
}
}
boolean hasMoreThanOneStorage()
{
return mItems.size() > 1;
}
List<StorageItem> getStorageItems()
{
return mItems;
@ -228,13 +223,6 @@ public class StoragePathManager
continue;
}
final long freeSize = StorageUtils.getFreeBytesAtPath(path);
if (freeSize <= 0)
{
LOGGER.i(TAG, "Rejected " + path + ": not enough space");
continue;
}
if (!dir.canWrite() || !StorageUtils.isDirWritable(path))
{
LOGGER.i(TAG, "Rejected " + path + ": not writable");
@ -247,6 +235,7 @@ public class StoragePathManager
continue;
}
final long freeSize = StorageUtils.getFreeBytesAtPath(path);
StorageItem item = new StorageItem(path, freeSize);
if (!TextUtils.isEmpty(configDir) && configDir.equals(path))
{