63 lines
1.9 KiB
Java
Raw Normal View History

2017-02-07 02:01:32 +08:00
package com.topjohnwu.magisk.components;
2017-07-22 22:14:02 +08:00
import android.content.res.Configuration;
2017-07-23 00:12:15 +08:00
import android.os.Bundle;
import android.support.annotation.Nullable;
2017-02-07 02:01:32 +08:00
import android.support.v7.app.AppCompatActivity;
2017-05-24 21:21:15 +02:00
import android.view.WindowManager;
2017-02-07 02:01:32 +08:00
import com.topjohnwu.magisk.MagiskManager;
2017-05-24 21:21:15 +02:00
import com.topjohnwu.magisk.R;
2017-08-28 00:27:10 +08:00
import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Topic;
2017-02-07 02:01:32 +08:00
public class Activity extends AppCompatActivity {
2017-07-22 22:14:02 +08:00
public Activity() {
super();
Configuration configuration = new Configuration();
configuration.setLocale(MagiskManager.locale);
applyOverrideConfiguration(configuration);
}
2017-07-23 00:12:15 +08:00
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (this instanceof Topic.Subscriber) {
((Topic.Subscriber) this).subscribeTopics();
2017-07-23 00:12:15 +08:00
}
}
@Override
protected void onDestroy() {
if (this instanceof Topic.Subscriber) {
((Topic.Subscriber) this).unsubscribeTopics();
2017-07-23 00:12:15 +08:00
}
super.onDestroy();
}
2017-02-17 08:51:51 +08:00
@Override
public MagiskManager getApplicationContext() {
2017-02-22 04:13:21 +08:00
return (MagiskManager) super.getApplicationContext();
2017-02-07 02:01:32 +08:00
}
2017-05-24 21:21:15 +02:00
2017-08-28 00:27:10 +08:00
public Shell getShell() {
return Shell.getShell(this);
}
2017-05-24 21:21:15 +02:00
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);
}
}
2017-02-07 02:01:32 +08:00
}