blob: f94a792f5e92e4726d112a0980cba3bb2118ec6d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
package com.mapswithme.maps.settings;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.XmlRes;
import android.support.v4.content.ContextCompat;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.view.View;
import com.mapswithme.maps.R;
import com.mapswithme.util.Config;
import com.mapswithme.util.ThemeUtils;
import com.mapswithme.util.UiUtils;
import com.mapswithme.util.Utils;
abstract class BaseXmlSettingsFragment extends PreferenceFragmentCompat
{
protected abstract @XmlRes int getXmlResources();
@Override
public void onCreatePreferences(Bundle bundle, String root)
{
setPreferencesFromResource(getXmlResources(), root);
}
@Override
public void onAttach(Context context)
{
super.onAttach(context);
Utils.detachFragmentIfCoreNotInitialized(context, this);
}
@Override
public void onResume()
{
super.onResume();
org.alohalytics.Statistics.logEvent("$onResume", getClass().getSimpleName() + ":" +
UiUtils.deviceOrientationAsString(getActivity()));
}
@Override
public void onPause()
{
super.onPause();
org.alohalytics.Statistics.logEvent("$onPause", getClass().getSimpleName() + ":" +
UiUtils.deviceOrientationAsString(getActivity()));
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
String theme = Config.getCurrentUiTheme();
int color;
if (ThemeUtils.isDefaultTheme(theme))
color = ContextCompat.getColor(getContext(), R.color.bg_cards);
else
color = ContextCompat.getColor(getContext(), R.color.bg_cards_night);
view.setBackgroundColor(color);
}
protected SettingsActivity getSettingsActivity()
{
return (SettingsActivity) getActivity();
}
}
|