forked from organicmaps/organicmaps
[android] Simplified enable logging feature
This commit is contained in:
parent
c67fbb8901
commit
03acd28207
2 changed files with 6 additions and 38 deletions
|
@ -23,7 +23,6 @@ import android.view.ViewGroup;
|
|||
|
||||
import com.google.android.gms.ads.search.SearchAdView;
|
||||
import com.mapswithme.maps.MwmActivity;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.base.BaseMwmFragment;
|
||||
import com.mapswithme.maps.base.OnBackPressListener;
|
||||
|
@ -41,7 +40,6 @@ import com.mapswithme.util.SharedPropertiesUtils;
|
|||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.concurrency.UiThread;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
import com.mapswithme.util.statistics.Statistics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -55,7 +53,6 @@ public class SearchFragment extends BaseMwmFragment
|
|||
CategoriesAdapter.OnCategorySelectedListener,
|
||||
HotelsFilterHolder, NativeBookingFilterListener
|
||||
{
|
||||
public static final String PREFS_SHOW_ENABLE_LOGGING_SETTING = "ShowEnableLoggingSetting";
|
||||
private static final int MIN_QUERY_LENGTH_FOR_AD = 3;
|
||||
private static final long ADS_DELAY_MS = 200;
|
||||
private static final long RESULTS_DELAY_MS = 400;
|
||||
|
@ -518,19 +515,6 @@ public class SearchFragment extends BaseMwmFragment
|
|||
|
||||
private boolean tryRecognizeLoggingCommand(@NonNull String str)
|
||||
{
|
||||
if (str.equals("?enableLogging"))
|
||||
{
|
||||
MwmApplication.prefs().edit().putBoolean(PREFS_SHOW_ENABLE_LOGGING_SETTING, true).apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str.equals("?disableLogging"))
|
||||
{
|
||||
LoggerFactory.INSTANCE.setFileLoggingEnabled(false);
|
||||
MwmApplication.prefs().edit().putBoolean(PREFS_SHOW_ENABLE_LOGGING_SETTING, false).apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (str.equals("?emulateBadStorage"))
|
||||
{
|
||||
SharedPropertiesUtils.setShouldShowEmulateBadStorageSetting(true);
|
||||
|
|
|
@ -22,7 +22,6 @@ import android.text.style.ForegroundColorSpan;
|
|||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.mapswithme.maps.BuildConfig;
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.MwmApplication;
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -31,7 +30,6 @@ import com.mapswithme.maps.downloader.OnmapDownloader;
|
|||
import com.mapswithme.maps.editor.ProfileActivity;
|
||||
import com.mapswithme.maps.location.LocationHelper;
|
||||
import com.mapswithme.maps.location.TrackRecorder;
|
||||
import com.mapswithme.maps.search.SearchFragment;
|
||||
import com.mapswithme.maps.sound.LanguageData;
|
||||
import com.mapswithme.maps.sound.TtsPlayer;
|
||||
import com.mapswithme.util.Config;
|
||||
|
@ -516,30 +514,16 @@ public class SettingsPrefsFragment extends BaseXmlSettingsFragment
|
|||
if (pref == null)
|
||||
return;
|
||||
|
||||
if (!MwmApplication.prefs().getBoolean(SearchFragment.PREFS_SHOW_ENABLE_LOGGING_SETTING,
|
||||
BuildConfig.BUILD_TYPE.equals("beta")))
|
||||
{
|
||||
removePreference(getString(R.string.pref_settings_general), pref);
|
||||
}
|
||||
else
|
||||
{
|
||||
final boolean isLoggingEnabled = LoggerFactory.INSTANCE.isFileLoggingEnabled();
|
||||
((TwoStatePreference) pref).setChecked(isLoggingEnabled);
|
||||
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
final boolean isLoggingEnabled = LoggerFactory.INSTANCE.isFileLoggingEnabled();
|
||||
((TwoStatePreference) pref).setChecked(isLoggingEnabled);
|
||||
pref.setOnPreferenceChangeListener(
|
||||
(preference, newValue) ->
|
||||
{
|
||||
boolean oldVal = isLoggingEnabled;
|
||||
boolean newVal = (Boolean) newValue;
|
||||
if (oldVal != newVal)
|
||||
{
|
||||
if (isLoggingEnabled != newVal)
|
||||
LoggerFactory.INSTANCE.setFileLoggingEnabled(newVal);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initEmulationBadStorage()
|
||||
|
|
Loading…
Add table
Reference in a new issue