2015-02-08 13:53:12 -08:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2019-09-18 15:40:18 +10:00
|
|
|
import android.app.ActivityManager;
|
2019-03-25 17:23:38 -03:00
|
|
|
import android.content.Context;
|
2019-09-18 15:40:18 +10:00
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.graphics.BitmapFactory;
|
2015-02-10 15:33:57 -08:00
|
|
|
import android.os.Bundle;
|
2020-12-07 11:21:03 +11:00
|
|
|
import android.view.WindowManager;
|
|
|
|
|
2020-09-17 15:11:05 +10:00
|
|
|
import androidx.appcompat.app.ActionBar;
|
2020-08-19 10:06:26 +10:00
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2015-02-10 15:33:57 -08:00
|
|
|
|
2015-09-30 20:42:39 -03:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2019-03-25 17:23:38 -03:00
|
|
|
import org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageActivityHelper;
|
|
|
|
import org.thoughtcrime.securesms.util.dynamiclanguage.DynamicLanguageContextWrapper;
|
2015-09-30 20:42:39 -03:00
|
|
|
|
2019-09-18 15:40:18 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2015-06-09 07:37:20 -07:00
|
|
|
public abstract class BaseActionBarActivity extends AppCompatActivity {
|
2015-02-10 15:33:57 -08:00
|
|
|
private static final String TAG = BaseActionBarActivity.class.getSimpleName();
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2020-09-17 15:11:05 +10:00
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
actionBar.setHomeButtonEnabled(true);
|
|
|
|
}
|
|
|
|
|
2015-02-10 15:33:57 -08:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
}
|
|
|
|
|
2015-09-30 20:42:39 -03:00
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
initializeScreenshotSecurity();
|
2019-03-25 17:23:38 -03:00
|
|
|
DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage(this, TextSecurePreferences.getLanguage(this));
|
2019-09-18 15:40:18 +10:00
|
|
|
String name = getResources().getString(R.string.app_name);
|
|
|
|
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground);
|
2020-01-09 11:35:43 +11:00
|
|
|
int color = getResources().getColor(R.color.app_icon_background);
|
2019-09-18 15:40:18 +10:00
|
|
|
setTaskDescription(new ActivityManager.TaskDescription(name, icon, color));
|
2020-03-19 13:45:55 +11:00
|
|
|
}
|
|
|
|
|
2020-09-17 15:11:05 +10:00
|
|
|
@Override
|
|
|
|
public boolean onSupportNavigateUp() {
|
|
|
|
if (super.onSupportNavigateUp()) return true;
|
|
|
|
|
|
|
|
onBackPressed();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-30 20:42:39 -03:00
|
|
|
private void initializeScreenshotSecurity() {
|
2019-03-20 15:09:27 -07:00
|
|
|
if (TextSecurePreferences.isScreenSecurityEnabled(this)) {
|
2015-09-30 20:42:39 -03:00
|
|
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
|
|
} else {
|
|
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-25 17:23:38 -03:00
|
|
|
@Override
|
|
|
|
protected void attachBaseContext(Context newBase) {
|
|
|
|
super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(newBase, TextSecurePreferences.getLanguage(newBase)));
|
|
|
|
}
|
2015-02-08 13:53:12 -08:00
|
|
|
}
|