MCPcopy Create free account
hub / github.com/M66B/NetGuard / onCreate

Method onCreate

app/src/main/java/eu/faircode/netguard/ActivityLog.java:89–299  ·  view source on GitHub ↗
(Bundle savedInstanceState)

Source from the content-addressed store, hash-verified

87 };
88
89 @Override
90 protected void onCreate(Bundle savedInstanceState) {
91 if (!IAB.isPurchased(ActivityPro.SKU_LOG, this)) {
92 startActivity(new Intent(this, ActivityPro.class));
93 finish();
94 }
95
96 Util.setTheme(this);
97 super.onCreate(savedInstanceState);
98 setContentView(R.layout.logging);
99 running = true;
100
101 // Action bar
102 View actionView = getLayoutInflater().inflate(R.layout.actionlog, null, false);
103 SwitchCompat swEnabled = actionView.findViewById(R.id.swEnabled);
104
105 getSupportActionBar().setDisplayShowCustomEnabled(true);
106 getSupportActionBar().setCustomView(actionView);
107
108 getSupportActionBar().setTitle(R.string.menu_log);
109 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
110
111 // Get settings
112 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
113 resolve = prefs.getBoolean("resolve", false);
114 organization = prefs.getBoolean("organization", false);
115 boolean log = prefs.getBoolean("log", false);
116
117 // Show disabled message
118 TextView tvDisabled = findViewById(R.id.tvDisabled);
119 tvDisabled.setVisibility(log ? View.GONE : View.VISIBLE);
120
121 // Set enabled switch
122 swEnabled.setChecked(log);
123 swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
124 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
125 prefs.edit().putBoolean("log", isChecked).apply();
126 }
127 });
128
129 // Listen for preference changes
130 prefs.registerOnSharedPreferenceChangeListener(this);
131
132 lvLog = findViewById(R.id.lvLog);
133
134 boolean udp = prefs.getBoolean("proto_udp", true);
135 boolean tcp = prefs.getBoolean("proto_tcp", true);
136 boolean other = prefs.getBoolean("proto_other", true);
137 boolean allowed = prefs.getBoolean("traffic_allowed", true);
138 boolean blocked = prefs.getBoolean("traffic_blocked", true);
139
140 adapter = new AdapterLog(this, DatabaseHelper.getInstance(this).getLog(udp, tcp, other, allowed, blocked), resolve, organization);
141 adapter.setFilterQueryProvider(new FilterQueryProvider() {
142 public Cursor runQuery(CharSequence constraint) {
143 return DatabaseHelper.getInstance(ActivityLog.this).searchLog(constraint.toString());
144 }
145 });
146

Callers

nothing calls this directly

Calls 5

isPurchasedMethod · 0.95
setThemeMethod · 0.95
getInstanceMethod · 0.95
getLogMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected