blob: a76e009dda3954430c7ec1f3d05baa8a67a7de97 (
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
|
package de.pixart.messenger.ui;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import androidx.annotation.BoolRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.WindowManager;
import de.pixart.messenger.R;
public abstract class ActionBarActivity extends AppCompatActivity {
public static void configureActionBar(ActionBar actionBar) {
configureActionBar(actionBar, true);
}
public static void configureActionBar(ActionBar actionBar, boolean upNavigation) {
if (actionBar != null) {
actionBar.setHomeButtonEnabled(upNavigation);
actionBar.setDisplayHomeAsUpEnabled(upNavigation);
}
}
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
break;
}
return super.onOptionsItemSelected(item);
}
void initializeScreenshotSecurity() {
try {
if (isScreenSecurityEnabled()) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean isScreenSecurityEnabled() {
return getBooleanPreference("screen_security", R.bool.screen_security);
}
protected SharedPreferences getPreferences() {
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
}
protected boolean getBooleanPreference(String name, @BoolRes int res) {
return getPreferences().getBoolean(name, getResources().getBoolean(res));
}
}
|