mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-09 09:44:42 +00:00
63 lines
1.9 KiB
Java
63 lines
1.9 KiB
Java
package com.topjohnwu.magisk.components;
|
|
|
|
import android.content.res.Configuration;
|
|
import android.os.Bundle;
|
|
import android.support.annotation.Nullable;
|
|
import android.support.v7.app.AppCompatActivity;
|
|
import android.view.WindowManager;
|
|
|
|
import com.topjohnwu.magisk.MagiskManager;
|
|
import com.topjohnwu.magisk.R;
|
|
import com.topjohnwu.magisk.utils.Shell;
|
|
import com.topjohnwu.magisk.utils.Topic;
|
|
|
|
public class Activity extends AppCompatActivity {
|
|
|
|
public Activity() {
|
|
super();
|
|
Configuration configuration = new Configuration();
|
|
configuration.setLocale(MagiskManager.locale);
|
|
applyOverrideConfiguration(configuration);
|
|
}
|
|
|
|
@Override
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
if (this instanceof Topic.Subscriber) {
|
|
((Topic.Subscriber) this).subscribeTopics();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
if (this instanceof Topic.Subscriber) {
|
|
((Topic.Subscriber) this).unsubscribeTopics();
|
|
}
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override
|
|
public MagiskManager getApplicationContext() {
|
|
return (MagiskManager) super.getApplicationContext();
|
|
}
|
|
|
|
public Shell getShell() {
|
|
return Shell.getShell(this);
|
|
}
|
|
|
|
protected void setFloating() {
|
|
boolean isTablet = getResources().getBoolean(R.bool.isTablet);
|
|
if (isTablet) {
|
|
WindowManager.LayoutParams params = getWindow().getAttributes();
|
|
params.height = getResources().getDimensionPixelSize(R.dimen.floating_height);
|
|
params.width = getResources().getDimensionPixelSize(R.dimen.floating_width);
|
|
params.alpha = 1.0f;
|
|
params.dimAmount = 0.6f;
|
|
params.flags |= 2;
|
|
getWindow().setAttributes(params);
|
|
setFinishOnTouchOutside(true);
|
|
}
|
|
}
|
|
|
|
}
|