InstabugFeaturesManager.java
6.39 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.instabug.library;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.instabug.library.util.InstabugSDKLogger;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
public class InstabugFeaturesManager
{
private static final String AVAILABILITY_PREFIX = "AVAIL";
private static final boolean DEFAULT_FEATURE_AVAILABILITY = true;
public static final Feature.State DEFAULT_FEATURE_STATE = Feature.State.ENABLED;
private static InstabugFeaturesManager INSTANCE;
private static final String STATE_PREFIX = "STATE";
private HashMap<Feature, Boolean> featuresAvailability = new HashMap();
private HashMap<Feature, Feature.State> featuresState = new HashMap();
public static InstabugFeaturesManager getInstance()
{
if (INSTANCE == null) {
INSTANCE = new InstabugFeaturesManager();
}
return INSTANCE;
}
public Feature.State getFeatureState(Feature paramFeature)
{
if ((isFeatureAvailable(paramFeature)) && (isFeatureAvailable(Feature.INSTABUG))) {}
for (boolean bool = true;; bool = false)
{
InstabugSDKLogger.d(this, "Feature " + paramFeature + " isAvailable = " + bool + ", and it's state is " + this.featuresState.get(paramFeature));
if (bool) {
break;
}
InstabugSDKLogger.d(this, "Feature " + paramFeature + " isn't available, returning " + Feature.State.DISABLED);
return Feature.State.DISABLED;
}
if (this.featuresState.containsKey(paramFeature)) {
return (Feature.State)this.featuresState.get(paramFeature);
}
InstabugSDKLogger.d(this, "Feature " + paramFeature + " is available, but no specific state is set. Returning " + DEFAULT_FEATURE_STATE);
return DEFAULT_FEATURE_STATE;
}
public boolean isFeatureAvailable(Feature paramFeature)
{
if (this.featuresAvailability.containsKey(paramFeature))
{
InstabugSDKLogger.d(this, "Feature " + paramFeature + " availability is " + this.featuresAvailability.get(paramFeature));
return ((Boolean)this.featuresAvailability.get(paramFeature)).booleanValue();
}
InstabugSDKLogger.d(this, "Feature " + paramFeature + " availability not found, returning true");
return true;
}
public void restoreFeaturesFromSharedPreferences(Context paramContext)
{
int i = 0;
paramContext = paramContext.getSharedPreferences("instabug", 0);
Feature[] arrayOfFeature = Feature.values();
int j = arrayOfFeature.length;
if (i < j)
{
Feature localFeature = arrayOfFeature[i];
Object localObject = localFeature.name() + "AVAIL";
boolean bool = paramContext.getBoolean(localFeature.name() + "AVAIL", true);
if (paramContext.contains((String)localObject))
{
this.featuresAvailability.put(localFeature, Boolean.valueOf(bool));
InstabugSDKLogger.d(this, "Feature " + localFeature + " saved availability " + bool + " restored from shared preferences");
label149:
if (this.featuresState.containsKey(localFeature)) {
break label363;
}
localObject = Feature.State.valueOf(paramContext.getString(localFeature.name() + "STATE", DEFAULT_FEATURE_STATE.name()));
this.featuresState.put(localFeature, localObject);
InstabugSDKLogger.d(this, "Restored feature " + localFeature + " state " + localObject + " from shared preferences");
}
for (;;)
{
i += 1;
break;
if (!this.featuresAvailability.containsKey(localFeature))
{
this.featuresAvailability.put(localFeature, Boolean.valueOf(bool));
InstabugSDKLogger.d(this, "Restored feature " + localFeature + " availability " + bool + " from shared preferences");
break label149;
}
InstabugSDKLogger.d(this, "Not restoring feature " + localFeature + " availability as it's already set to " + this.featuresAvailability.get(localFeature));
break label149;
label363:
InstabugSDKLogger.d(this, "Not restoring feature " + localFeature + " state as it's already set to " + this.featuresState.get(localFeature));
}
}
}
void saveFeaturesToSharedPreferences(Context paramContext)
{
paramContext = paramContext.getSharedPreferences("instabug", 0).edit();
Iterator localIterator = this.featuresAvailability.keySet().iterator();
Feature localFeature;
while (localIterator.hasNext())
{
localFeature = (Feature)localIterator.next();
paramContext.putBoolean(localFeature.name() + "AVAIL", ((Boolean)this.featuresAvailability.get(localFeature)).booleanValue());
InstabugSDKLogger.d(this, "Saved feature " + localFeature + " availability " + this.featuresAvailability.get(localFeature) + " to shared preferences");
}
localIterator = this.featuresState.keySet().iterator();
while (localIterator.hasNext())
{
localFeature = (Feature)localIterator.next();
paramContext.putString(localFeature.name() + "STATE", ((Feature.State)this.featuresState.get(localFeature)).name());
InstabugSDKLogger.d(this, "Saved feature " + localFeature + " state " + this.featuresState.get(localFeature) + " to shared preferences");
}
paramContext.apply();
}
public void setFeatureState(Feature paramFeature, Feature.State paramState)
{
if ((this.featuresState.containsKey(paramFeature)) && (this.featuresState.get(paramFeature) == paramState))
{
InstabugSDKLogger.d(this, "Feature " + paramFeature + " state is already " + paramState + " ignoring");
return;
}
InstabugSDKLogger.d(this, "Setting " + paramFeature + " state to " + paramState);
this.featuresState.put(paramFeature, paramState);
}
void updateFeatureAvailability(Feature paramFeature, boolean paramBoolean)
{
if ((this.featuresAvailability.containsKey(paramFeature)) && (((Boolean)this.featuresAvailability.get(paramFeature)).booleanValue() == paramBoolean))
{
InstabugSDKLogger.d(this, "Feature " + paramFeature + " availability is already " + paramBoolean + " ignoring");
return;
}
InstabugSDKLogger.d(this, "Setting feature " + paramFeature + " availability to " + paramBoolean);
this.featuresAvailability.put(paramFeature, Boolean.valueOf(paramBoolean));
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/instabug/library/InstabugFeaturesManager.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/