mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 13:35:27 +00:00
Code clean-up
This commit is contained in:
parent
b1ef9361f3
commit
16c804106a
@ -77,6 +77,7 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
set.add("com.google.android.apps.walletnfcrel");
|
set.add("com.google.android.apps.walletnfcrel");
|
||||||
set.add("com.google.android.gms");
|
set.add("com.google.android.gms");
|
||||||
|
set.add("com.google.commerce.tapandpay");
|
||||||
editor.putStringSet("auto_blacklist", set);
|
editor.putStringSet("auto_blacklist", set);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import android.widget.Switch;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.receivers.Receiver;
|
|
||||||
import com.topjohnwu.magisk.services.MonitorService;
|
import com.topjohnwu.magisk.services.MonitorService;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.PrefHelper;
|
import com.topjohnwu.magisk.utils.PrefHelper;
|
||||||
@ -35,7 +34,7 @@ import butterknife.BindColor;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class RootFragment extends Fragment implements Receiver {
|
public class RootFragment extends Fragment {
|
||||||
|
|
||||||
public SharedPreferences prefs;
|
public SharedPreferences prefs;
|
||||||
@BindView(R.id.progressBar)
|
@BindView(R.id.progressBar)
|
||||||
@ -108,10 +107,7 @@ public class RootFragment extends Fragment implements Receiver {
|
|||||||
autoRootToggle.setChecked(autoRootStatus);
|
autoRootToggle.setChecked(autoRootStatus);
|
||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
|
|
||||||
rootToggle.setOnClickListener(toggle -> {
|
rootToggle.setOnClickListener(toggle -> Utils.toggleRoot(((CompoundButton) toggle).isChecked(), getActivity()));
|
||||||
Utils.toggleRoot(((CompoundButton) toggle).isChecked(), getActivity());
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
autoRootToggle.setOnClickListener(toggle -> {
|
autoRootToggle.setOnClickListener(toggle -> {
|
||||||
if (!Utils.hasServicePermission(getActivity())) {
|
if (!Utils.hasServicePermission(getActivity())) {
|
||||||
@ -128,7 +124,6 @@ public class RootFragment extends Fragment implements Receiver {
|
|||||||
|
|
||||||
listener = (prefs1, key) -> {
|
listener = (prefs1, key) -> {
|
||||||
|
|
||||||
|
|
||||||
if ((key.contains("autoRootEnable")) | (key.equals("root"))) {
|
if ((key.contains("autoRootEnable")) | (key.equals("root"))) {
|
||||||
Logger.dh("RootFragmnet, keychange detected for " + key);
|
Logger.dh("RootFragmnet, keychange detected for " + key);
|
||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
@ -186,8 +181,6 @@ public class RootFragment extends Fragment implements Receiver {
|
|||||||
rootToggle.setEnabled(true);
|
rootToggle.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -197,11 +190,6 @@ public class RootFragment extends Fragment implements Receiver {
|
|||||||
new updateUI().execute();
|
new updateUI().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResult() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class updateUI extends AsyncTask<Void, Void, Void> {
|
public class updateUI extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -219,10 +207,8 @@ public class RootFragment extends Fragment implements Receiver {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
super.onPostExecute(v);
|
super.onPostExecute(v);
|
||||||
|
|
||||||
autoRootToggle.setChecked(autoRootStatus);
|
autoRootToggle.setChecked(autoRootStatus);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
rootStatusView.setVisibility(View.VISIBLE);
|
rootStatusView.setVisibility(View.VISIBLE);
|
||||||
safetynetStatusView.setVisibility(View.VISIBLE);
|
safetynetStatusView.setVisibility(View.VISIBLE);
|
||||||
selinuxStatusView.setVisibility(View.VISIBLE);
|
selinuxStatusView.setVisibility(View.VISIBLE);
|
||||||
|
@ -2,10 +2,8 @@ package com.topjohnwu.magisk;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentManager;
|
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -24,7 +22,6 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.module.RepoHelper;
|
|
||||||
import com.topjohnwu.magisk.services.MonitorService;
|
import com.topjohnwu.magisk.services.MonitorService;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
@ -39,7 +36,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
private final Handler mDrawerHandler = new Handler();
|
private final Handler mDrawerHandler = new Handler();
|
||||||
private String currentTitle;
|
private String currentTitle;
|
||||||
private String tag;
|
|
||||||
|
|
||||||
@BindView(R.id.toolbar)
|
@BindView(R.id.toolbar)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@ -57,10 +53,8 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
setContentView(R.layout.activity_welcome);
|
setContentView(R.layout.activity_welcome);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
|
||||||
// Startups
|
// Startups
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||||
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
||||||
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
||||||
@ -76,72 +70,52 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
this.getFragmentManager().addOnBackStackChangedListener(
|
this.getFragmentManager().addOnBackStackChangedListener(
|
||||||
() -> {
|
() -> {
|
||||||
FragmentManager fragmentManager = getFragmentManager();
|
|
||||||
Fragment hm = getFragmentManager().findFragmentByTag("root");
|
Fragment hm = getFragmentManager().findFragmentByTag("root");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.root);
|
navigationView.setCheckedItem(R.id.root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hm = getFragmentManager().findFragmentByTag("autoroot");
|
hm = getFragmentManager().findFragmentByTag("autoroot");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.autoroot);
|
navigationView.setCheckedItem(R.id.autoroot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hm = getFragmentManager().findFragmentByTag("magisk");
|
hm = getFragmentManager().findFragmentByTag("magisk");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.magisk);
|
navigationView.setCheckedItem(R.id.magisk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hm = getFragmentManager().findFragmentByTag("modules");
|
hm = getFragmentManager().findFragmentByTag("modules");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.modules);
|
navigationView.setCheckedItem(R.id.modules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hm = getFragmentManager().findFragmentByTag("downloads");
|
hm = getFragmentManager().findFragmentByTag("downloads");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.downloads);
|
navigationView.setCheckedItem(R.id.downloads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hm = getFragmentManager().findFragmentByTag("log");
|
hm = getFragmentManager().findFragmentByTag("log");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.log);
|
navigationView.setCheckedItem(R.id.log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hm = getFragmentManager().findFragmentByTag("settings");
|
hm = getFragmentManager().findFragmentByTag("settings");
|
||||||
if(hm!=null)
|
if (hm != null) {
|
||||||
{
|
if (hm.isVisible()) {
|
||||||
if(hm.isVisible())
|
|
||||||
{
|
|
||||||
navigationView.setCheckedItem(R.id.settings);
|
navigationView.setCheckedItem(R.id.settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Utils.init(this);
|
Utils.init(this);
|
||||||
new Async.CheckUpdates(this).execute();
|
new Async.CheckUpdates(this).execute();
|
||||||
RepoHelper.TaskDelegate delegate = result -> {
|
|
||||||
//Do a thing here when we get a result we want
|
|
||||||
};
|
|
||||||
new Async.LoadModules(this).execute();
|
new Async.LoadModules(this).execute();
|
||||||
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
@ -178,7 +152,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -195,7 +168,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
|
||||||
|
|
||||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||||
drawer.closeDrawer(GravityCompat.START);
|
drawer.closeDrawer(GravityCompat.START);
|
||||||
} else {
|
} else {
|
||||||
@ -208,9 +180,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -231,7 +200,7 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
public void navigate(final int itemId) {
|
public void navigate(final int itemId) {
|
||||||
Fragment navFragment = null;
|
Fragment navFragment = null;
|
||||||
tag = "";
|
String tag = "";
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case R.id.magisk:
|
case R.id.magisk:
|
||||||
setTitle(R.string.magisk);
|
setTitle(R.string.magisk);
|
||||||
@ -275,7 +244,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
|
|
||||||
if (navFragment != null) {
|
if (navFragment != null) {
|
||||||
|
|
||||||
|
|
||||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||||
transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
|
transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
|
||||||
try {
|
try {
|
||||||
|
@ -20,6 +20,7 @@ public class AutoStartReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
if (PrefHelper.CheckBool("enable_quicktile",context)) {
|
if (PrefHelper.CheckBool("enable_quicktile",context)) {
|
||||||
Utils.SetupQuickSettingsTile(context);
|
Utils.SetupQuickSettingsTile(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.receivers;
|
|
||||||
|
|
||||||
public interface Receiver {
|
|
||||||
void onResult();
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.receivers;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
public class RootFragmentReceiver extends BroadcastReceiver {
|
|
||||||
|
|
||||||
private Receiver mFragment;
|
|
||||||
public RootFragmentReceiver(Receiver fragment) {
|
|
||||||
mFragment = fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (intent.getAction().equals(420)) {
|
|
||||||
mFragment.onResult();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.receivers;
|
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.topjohnwu.magisk.services.TileServiceCompat;
|
|
||||||
|
|
||||||
public class TileReceiver extends BroadcastReceiver {
|
|
||||||
private static final String TAG = "MainReceiver";
|
|
||||||
public TileReceiver() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
Log.d(TAG,"RECEIVED");
|
|
||||||
String action = intent.getAction();
|
|
||||||
|
|
||||||
if (action.equals(Intent.ACTION_BOOT_COMPLETED) || action.equals(Intent.ACTION_USER_PRESENT) || action.equals(Intent.ACTION_SCREEN_ON)) {
|
|
||||||
context.startService(new Intent(context,TileServiceCompat.class));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,6 @@ import android.app.PendingIntent;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -25,7 +24,6 @@ import com.topjohnwu.magisk.utils.Utils;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MonitorService extends AccessibilityService {
|
public class MonitorService extends AccessibilityService {
|
||||||
private static final String TAG = "MonitorService";
|
|
||||||
private Boolean disableroot;
|
private Boolean disableroot;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,11 +62,8 @@ public class MonitorService extends AccessibilityService {
|
|||||||
event.getPackageName().toString(),
|
event.getPackageName().toString(),
|
||||||
event.getClassName().toString()
|
event.getClassName().toString()
|
||||||
);
|
);
|
||||||
|
Logger.dh("MonitorService: CurrentActivity: " + event.getPackageName());
|
||||||
|
|
||||||
ActivityInfo activityInfo = tryGetActivity(componentName);
|
|
||||||
boolean isActivity = activityInfo != null;
|
|
||||||
if (isActivity) {
|
|
||||||
Logger.dh("MonitorService: CurrentActivity: " + componentName.getPackageName());
|
|
||||||
String mPackage = componentName.getPackageName();
|
String mPackage = componentName.getPackageName();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||||
@ -83,7 +78,6 @@ public class MonitorService extends AccessibilityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private String getAppName(String packageName) {
|
private String getAppName(String packageName) {
|
||||||
PackageManager pkManager = getPackageManager();
|
PackageManager pkManager = getPackageManager();
|
||||||
@ -98,14 +92,6 @@ public class MonitorService extends AccessibilityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityInfo tryGetActivity(ComponentName componentName) {
|
|
||||||
try {
|
|
||||||
return getPackageManager().getActivityInfo(componentName, 0);
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ForceRoot(Boolean rootToggle) {
|
private void ForceRoot(Boolean rootToggle) {
|
||||||
|
|
||||||
String rootString = rootToggle ? "on" : "off";
|
String rootString = rootToggle ? "on" : "off";
|
||||||
@ -120,14 +106,6 @@ public class MonitorService extends AccessibilityService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ForceEnableRoot() {
|
|
||||||
Log.d("Magisk", "MonitorService: ForceEnable called.");
|
|
||||||
Utils.toggleRoot(true,getApplicationContext());
|
|
||||||
if (!Utils.rootEnabled()) {
|
|
||||||
Utils.toggleRoot(true,getApplicationContext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ShowNotification(boolean rootAction, String packageName) {
|
private void ShowNotification(boolean rootAction, String packageName) {
|
||||||
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||||
NotificationCompat.Builder mBuilder;
|
NotificationCompat.Builder mBuilder;
|
||||||
|
@ -5,7 +5,6 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder;
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.animation.Animation;
|
|
||||||
import android.view.animation.Transformation;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
public class AnimationHelper {
|
|
||||||
public static void expand(final View v) {
|
|
||||||
v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
||||||
final int targetHeight = v.getMeasuredHeight();
|
|
||||||
|
|
||||||
v.getLayoutParams().height = 0;
|
|
||||||
v.setVisibility(View.VISIBLE);
|
|
||||||
Animation a = new Animation() {
|
|
||||||
@Override
|
|
||||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
|
||||||
v.getLayoutParams().height = interpolatedTime == 1
|
|
||||||
? LinearLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
: (int) (targetHeight * interpolatedTime);
|
|
||||||
v.requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean willChangeBounds() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 1dp/ms
|
|
||||||
a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
|
|
||||||
v.startAnimation(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void collapse(final View v) {
|
|
||||||
final int initialHeight = v.getMeasuredHeight();
|
|
||||||
|
|
||||||
Animation a = new Animation() {
|
|
||||||
@Override
|
|
||||||
protected void applyTransformation(float interpolatedTime, Transformation t) {
|
|
||||||
if (interpolatedTime == 1) {
|
|
||||||
v.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
|
|
||||||
v.requestLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean willChangeBounds() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// 1dp/ms
|
|
||||||
a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
|
|
||||||
v.startAnimation(a);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,5 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
@ -17,7 +15,7 @@ public class PrefHelper {
|
|||||||
|
|
||||||
public static void SetBool(String key, Boolean value, Context context) {
|
public static void SetBool(String key, Boolean value, Context context) {
|
||||||
|
|
||||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).commit();
|
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(key, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,6 +293,7 @@ public class Utils {
|
|||||||
.setVisible(true)
|
.setVisible(true)
|
||||||
.build();
|
.build();
|
||||||
mContext.sendBroadcast(tileConfigurationIntent);
|
mContext.sendBroadcast(tileConfigurationIntent);
|
||||||
|
mContext.startService(new Intent(mContext, TileServiceCompat.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user