Advertisement
DragonData

Menu Layout

Aug 16th, 2019
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.90 KB | None | 0 0
  1. package com.mrikso.modmenu;
  2.  
  3. import android.app.ActivityManager;
  4. import android.app.ActivityManager.RunningAppProcessInfo;
  5. import android.app.AlertDialog;
  6. import android.app.AlertDialog.Builder;
  7. import android.app.Service;
  8. import android.content.Context;
  9. import android.content.Intent;
  10. import android.graphics.Color;
  11. import android.graphics.Paint.Style;
  12. import android.graphics.Typeface;
  13. import android.graphics.drawable.Drawable;
  14. import android.graphics.drawable.LayerDrawable;
  15. import android.graphics.drawable.ShapeDrawable;
  16. import android.graphics.drawable.shapes.RoundRectShape;
  17. import android.os.Build.VERSION;
  18. import android.os.Handler;
  19. import android.os.IBinder;
  20. import android.text.Html;
  21. import android.net.Uri;
  22. import android.view.MotionEvent;
  23. import android.view.View;
  24. import android.view.View.OnClickListener;
  25. import android.view.View.OnTouchListener;
  26. import android.view.WindowManager;
  27. import android.webkit.WebView;
  28. import android.widget.Button;
  29. import android.widget.CheckBox;
  30. import android.widget.Checkable;
  31. import android.widget.CompoundButton;
  32. import android.widget.FrameLayout;
  33. import android.widget.FrameLayout.LayoutParams;
  34. import android.widget.ImageView;
  35. import android.widget.LinearLayout;
  36. import android.widget.RelativeLayout;
  37. import android.widget.ScrollView;
  38. import android.widget.SeekBar;
  39. import android.widget.Switch;
  40. import android.widget.TextView;
  41. import android.widget.Toast;
  42. import java.io.IOException;
  43. import java.io.InputStream;
  44. import java.util.Random;
  45.  
  46. public class FloatingModMenuService extends Service {
  47.  
  48.     public View mFloatingView;
  49.     private LinearLayout modBody;
  50.     public WindowManager windowManager;
  51.  
  52.  
  53.     //инициализируем методы из нативной библиотеки
  54.    // private native String toastFromJNI();
  55.  
  56.     private native void anticheat_on();
  57.     private native void anticheat_off();
  58.  
  59.     private native void negativeAmmo_on();
  60.     private native void negativeAmmo_off();
  61.  
  62.     private native void respawnCharge_on();
  63.     private native void respawnCharge_off();
  64.  
  65.     private native void noGravity_on();
  66.     private native void noGravity_off();
  67.  
  68.     private native void godmode_on();
  69.     private native void godmode_off();
  70.  
  71.     private native void abilityCharge_on();
  72.     private native void abilityCharge_off();
  73.  
  74.     private native void superSpeed_on();
  75.     private native void superSpeed_off();
  76.  
  77.     private native void noSpook_on();
  78.     private native void noSpook_off();
  79.  
  80.     private native void noAbilityCooldown_on();
  81.     private native void noAbilityCooldown_off();
  82.  
  83.     private native void noGrenadeCooldown_on();
  84.     private native void noGrenadeCooldown_off();
  85.  
  86.     private native void godmode2_on();
  87.     private native void godmode2_off();
  88.  
  89.     private native void noPolymorph_on();
  90.     private native void noPolymorph_off();
  91.  
  92.     private native void propValue_on();
  93.     private native void propValue_off();
  94.  
  95.     private native void noPassword_on();
  96.     private native void noPassword_off();
  97.  
  98.     private native void bigReward_on();
  99.     private native void bigReward_off();
  100.  
  101.  
  102.  
  103.     @Override
  104.     public IBinder onBind(Intent intent) {
  105.         return null;
  106.     }
  107.  
  108.     @Override
  109.     public void onCreate() {
  110.         super.onCreate();
  111.         InstallMenu();
  112.         final Handler handler = new Handler();
  113.         handler.post(new Runnable() {
  114.             public void run() {
  115.                 FloatingModMenuService.this.Thread();
  116.                 handler.postDelayed(this, 1000);
  117.             }
  118.         });
  119.     }
  120.  
  121.  
  122.     private void InstallMenu() {
  123.         int i = VERSION.SDK_INT >= 26 ? 2038 : 2002;
  124.         FrameLayout frameLayout = new FrameLayout(this);
  125.         frameLayout.setLayoutParams(new LayoutParams(-2, -2));
  126.         RelativeLayout relativeLayout = new RelativeLayout(this);
  127.         relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
  128.         ImageView imageView = new ImageView(this);
  129.         imageView.setLayoutParams(new RelativeLayout.LayoutParams(convertDipToPixels(50.0f), convertDipToPixels(50.0f)));
  130.         try {
  131.             InputStream open = getAssets().open("floating.png");
  132.             InputStream background = getAssets().open("background.png");
  133.             imageView.setImageDrawable(Drawable.createFromStream(open, null));
  134.             open.close();
  135.             relativeLayout.addView(imageView);
  136.             this.mFloatingView = relativeLayout;
  137.             LinearLayout linearLayout = new LinearLayout(this);
  138.             linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
  139.             linearLayout.setBackground(Drawable.createFromStream(background, null));
  140.             linearLayout.setOrientation(LinearLayout.VERTICAL);
  141.             TextView textView = new TextView(this);
  142.             textView.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
  143.             textView.setGravity(1);
  144.             textView.setTextColor(Color.parseColor("#000000"));
  145.             textView.setText("Menu v1.4");
  146.             textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
  147.             textView.setTextSize(20.0f);
  148.             ScrollView scrollView = new ScrollView(this);
  149.             scrollView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  150.             scrollView.setScrollBarSize(convertDipToPixels(5.0f));
  151.             this.modBody = new LinearLayout(this);
  152.             this.modBody.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  153.             this.modBody.setOrientation(LinearLayout.VERTICAL);
  154.             scrollView.addView(this.modBody);
  155.             linearLayout.addView(textView);
  156.             linearLayout.addView(scrollView);
  157.             frameLayout.addView(linearLayout);
  158.             final AlertDialog create = new Builder(this, 2).create();
  159.             create.getWindow().setType(i);
  160.             create.setView(frameLayout);
  161.             final WindowManager.LayoutParams layoutParams3 = new WindowManager.LayoutParams( -2, -2, i, 8, -3);
  162.             layoutParams3.gravity = 51;
  163.             layoutParams3.x = 0;
  164.             layoutParams3.y = 100;
  165.             this.windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
  166.             this.windowManager.addView(this.mFloatingView, layoutParams3);
  167.             this.mFloatingView.setOnTouchListener(new OnTouchListener() {
  168.                 private float initialTouchX;
  169.                 private float initialTouchY;
  170.                 private int initialX;
  171.                 private int initialY;
  172.  
  173.                 public boolean onTouch(View view, MotionEvent motionEvent) {
  174.                     switch (motionEvent.getAction()) {
  175.                         case 0:
  176.                             this.initialX = layoutParams3.x;
  177.                             this.initialY = layoutParams3.y;
  178.                             this.initialTouchX = motionEvent.getRawX();
  179.                             this.initialTouchY = motionEvent.getRawY();
  180.                             return true;
  181.                         case 1:
  182.                             create.show();
  183.                             return true;
  184.                         case 2:
  185.                             float round = (float) Math.round(motionEvent.getRawX() - this.initialTouchX);
  186.                             float round2 = (float) Math.round(motionEvent.getRawY() - this.initialTouchY);
  187.                             layoutParams3.x = this.initialX + ((int) round);
  188.                             layoutParams3.y = this.initialY + ((int) round2);
  189.                             FloatingModMenuService.this.windowManager.updateViewLayout(FloatingModMenuService.this.mFloatingView, layoutParams3);
  190.                             return true;
  191.                         default:
  192.                             return false;
  193.                     }
  194.                 }
  195.             });
  196.  
  197.         } catch (IOException unused) {
  198.         }
  199.         modMenu();
  200.     }
  201.  
  202.  
  203.     private void modMenu() {
  204.  
  205.         addCheckbox("Function", new CB() {
  206.             public void OnWrite(boolean isChecked) {
  207.                 if (isChecked)
  208.                 {
  209.                     Function();
  210.  
  211.                 }
  212.                 else
  213.                 {
  214.                     Function();
  215.  
  216.                 }
  217.             }
  218.         });
  219.  
  220.         addCheckbox("Function", new CB() {
  221.             public void OnWrite(boolean isChecked) {
  222.                 if (isChecked)
  223.                 {
  224.                     Function();
  225.  
  226.                 }
  227.                 else
  228.                 {
  229.                     Function();
  230.  
  231.                 }
  232.             }
  233.         });
  234.  
  235.  
  236.         addCheckbox("Function", new CB() {
  237.             public void OnWrite(boolean isChecked) {
  238.                 if (isChecked)
  239.                 {
  240.                     Function();
  241.  
  242.                 }
  243.                 else
  244.                 {
  245.  
  246.                 }
  247.             }
  248.         });
  249.  
  250.         addCheckbox("Function]", new CB(){
  251.             public  void OnWrite(boolean isChecked) {
  252.                 if (isChecked)
  253.                 {
  254.                     Function();
  255.  
  256.                 }
  257.                 else
  258.                 {
  259.                     Function();
  260.  
  261.                 }
  262.             }
  263.         });
  264.  
  265.  
  266.         addCheckbox("Function", new CB(){
  267.             public  void OnWrite(boolean isChecked) {
  268.                 if (isChecked)
  269.                 {
  270.                     Function();
  271.  
  272.                 }
  273.                 else
  274.                 {
  275.                     Function();
  276.  
  277.                 }
  278.             }
  279.         });
  280.  
  281.  
  282.         addCheckbox("Function [Function]", new CB(){
  283.             public  void OnWrite(boolean isChecked) {
  284.                 if (isChecked)
  285.                 {
  286.                     Function();
  287.  
  288.                 }
  289.                 else
  290.                 {
  291.                     Function();
  292.  
  293.                 }
  294.             }
  295.         });
  296.  
  297.         addCheckbox("Function [Function]", new CB(){
  298.             public  void OnWrite(boolean isChecked) {
  299.                 if (isChecked)
  300.                 {
  301.                     Function();
  302.  
  303.                 }
  304.                 else
  305.                 {
  306.                     Function();
  307.  
  308.                 }
  309.             }
  310.         });
  311.  
  312.         addCheckbox("Function]", new CB(){
  313.             public  void OnWrite(boolean isChecked) {
  314.                 if (isChecked)
  315.                 {
  316.                     Function();
  317.  
  318.                 }
  319.                 else
  320.                 {
  321.                     Function();
  322.  
  323.                 }
  324.             }
  325.         });
  326.  
  327.  
  328.         addCheckbox("Function]", new CB(){
  329.             public  void OnWrite(boolean isChecked) {
  330.                 if (isChecked)
  331.                 {
  332.                     Function();
  333.  
  334.                 }
  335.                 else
  336.                 {
  337.                     Function();
  338.  
  339.                 }
  340.             }
  341.  
  342.  
  343.         });
  344.  
  345.         addCheckbox("Function]", new CB(){
  346.             public  void OnWrite(boolean isChecked) {
  347.                 if (isChecked)
  348.                 {
  349.                     Function();
  350.  
  351.                 }
  352.                 else
  353.                 {
  354.                     Function();
  355.  
  356.                 }
  357.             }
  358.         });
  359.  
  360.         addCheckbox("Function]", new CB(){
  361.             public  void OnWrite(boolean isChecked) {
  362.                 if (isChecked)
  363.                 {
  364.                     Function();
  365.  
  366.                 }
  367.                 else
  368.                 {
  369.                     Function();
  370.  
  371.                 }
  372.             }
  373.         });
  374.  
  375.         addCheckbox("Function]", new CB(){
  376.             public  void OnWrite(boolean isChecked) {
  377.                 if (isChecked)
  378.                 {
  379.                     Function();
  380.  
  381.                 }
  382.                 else
  383.                 {
  384.                     Function();
  385.  
  386.                 }
  387.             }
  388.         });
  389.  
  390.  
  391.     }
  392.  
  393.     //метод для быстрого добавления свичей в меню патчей
  394.  
  395.  
  396.     private void addCheckbox(String name, final CB listner) {
  397.         CheckBox cb = new CheckBox(this);
  398.         LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
  399.         layoutParams.setMargins(0, 2, 0, 1);
  400.         cb.setLayoutParams(layoutParams);
  401.         cb.setBackgroundColor(Color.parseColor("#00000000"));
  402.         cb.setPadding(20, 5, 20, 5);
  403.         cb.setText(name);
  404.         cb.setTextColor(Color.parseColor("#000000"));
  405.         cb.setTextSize(20.0f);
  406.         cb.setWidth(2);
  407.         cb.setHighlightColor(Color.parseColor("#FFFFFF"));
  408.         cb.setTypeface(cb.getTypeface(), Typeface.NORMAL);
  409.         cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  410.             @Override
  411.             public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
  412.                 listner.OnWrite(isChecked);
  413.             }
  414.         });
  415.         this.modBody.addView(cb);
  416.     }
  417.  
  418.     private int convertDipToPixels(float f) {
  419.         return (int) ((f * getResources().getDisplayMetrics().density) + 0.5f);
  420.     }
  421.  
  422.     private LayerDrawable GetlayerDrawable() {
  423.         float[] fArr = {75.0f, 75.0f, 75.0f, 75.0f, 75.0f, 75.0f, 75.0f, 75.0f};
  424.         float[] fArr2 = {75.0f, 75.0f, 75.0f, 75.0f, 75.0f, 75.0f, 75.0f, 75.0f};
  425.         ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(fArr, null, fArr2));
  426.         shapeDrawable.getPaint().setColor(Color.parseColor("#ff000000"));
  427.         shapeDrawable.getPaint().setStyle(Style.FILL);
  428.         shapeDrawable.setPadding(1, 1, 1, 1);
  429.         ShapeDrawable shapeDrawable2 = new ShapeDrawable(new RoundRectShape(fArr, null, fArr2));
  430.         shapeDrawable2.getPaint().setColor(Color.parseColor("#ff1f2b3f"));
  431.         shapeDrawable2.getPaint().setStyle(Style.FILL);
  432.         shapeDrawable2.getPaint().setAntiAlias(true);
  433.         Drawable[] drawableArr = {shapeDrawable, shapeDrawable2};
  434.         shapeDrawable2.setPadding(5, 5, 5, 5);
  435.         return new LayerDrawable(drawableArr);
  436.     }
  437.  
  438.     public void onDestroy() {
  439.         super.onDestroy();
  440.         if (this.mFloatingView != null) {
  441.             this.windowManager.removeView(this.mFloatingView);
  442.         }
  443.     }
  444.  
  445.     private boolean isChayNgam() {
  446.         RunningAppProcessInfo runningAppProcessInfo = new RunningAppProcessInfo();
  447.         ActivityManager.getMyMemoryState(runningAppProcessInfo);
  448.         return runningAppProcessInfo.importance != 100;
  449.     }
  450.  
  451.     /* access modifiers changed from: private */
  452.     public void Thread() {
  453.         if (this.mFloatingView == null) {
  454.             return;
  455.         }
  456.         if (isChayNgam()) {
  457.             this.mFloatingView.setVisibility(View.INVISIBLE);
  458.         } else {
  459.             this.mFloatingView.setVisibility(View.VISIBLE);
  460.         }
  461.     }
  462.  
  463.     private interface SW {
  464.         void OnWrite(boolean z);
  465.     }
  466.  
  467.     private interface CB {
  468.         void OnWrite (boolean z);
  469.     }
  470. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement