正在查看: Tasker v6.5.11 应用的 MacroEdit.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.5.11 应用的 MacroEdit.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package net.dinglisch.android.taskerm;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.SpannableStringBuilder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import cyanogenmod.app.ProfileManager;
import java.util.Iterator;
import java.util.List;
import net.dinglisch.android.taskerm.ExecuteService;
import net.dinglisch.android.taskerm.MacroEditView;
import net.dinglisch.android.taskerm.c;
import net.dinglisch.android.taskerm.fn;
public class MacroEdit extends MyActivity implements View.OnClickListener, pf.a {
private MacroEditView C;
private ImageView w;
private ImageView x;
com.joaomgcd.taskerm.helper.n v = new com.joaomgcd.taskerm.helper.n(this);
private wh y = null;
private ExecuteService.q z = null;
private Integer A = null;
private List<Integer> B = null;
private int D = -1;
private int E = -1;
class a implements MacroEditView.k {
a() {
}
@Override
public void a() {
MacroEdit.this.w1();
}
@Override
public void b() {
MacroEdit.this.Q0();
}
@Override
public void onCancel() {
MacroEdit.this.finish();
}
}
class b implements View.OnLongClickListener {
b() {
}
@Override
public boolean onLongClick(View view) {
if (MacroEdit.this.L0()) {
MacroEdit.this.s1(1);
}
return true;
}
}
class c implements View.OnLongClickListener {
c() {
}
@Override
public boolean onLongClick(View view) {
if (!MacroEdit.this.L0()) {
return true;
}
MacroEdit.this.s1(0);
return true;
}
}
class d implements fn.b {
final int a;
final fn b;
d(int i, fn fnVar) {
this.a = i;
this.b = fnVar;
}
@Override
public void a(int i) {
}
@Override
public void b(int i) {
MacroEdit.this.T0(this.a, i);
this.b.dismiss();
}
}
class e extends Handler {
e() {
}
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == 0) {
r7.f("MacroEdit", "connected to exe service");
if (MacroEdit.this.J0()) {
MacroEdit.this.r1();
return;
}
return;
}
if (i == 2) {
if (MacroEdit.this.J0()) {
MacroEdit.this.x1("service connection failure");
}
MacroEdit.this.y = null;
r7.G("MacroEdit", "exe service connection error");
return;
}
if (i == 1 && MacroEdit.this.J0()) {
MacroEdit.this.x1("service disconnected");
}
}
}
class f implements Runnable {
final String i;
f(String str) {
this.i = str;
}
@Override
public void run() {
MacroEdit.this.w1();
MacroEdit.this.t1(this.i);
}
}
class g implements Runnable {
final Boolean i;
final Boolean q;
g(Boolean bool, Boolean bool2) {
this.i = bool;
this.q = bool2;
}
@Override
public void run() {
if (this.i != null && MacroEdit.this.x != null) {
MacroEdit.this.x.setEnabled(this.i.booleanValue());
}
if (this.q == null || MacroEdit.this.w == null) {
return;
}
MacroEdit.this.w.setEnabled(this.q.booleanValue());
}
}
class h implements ExecuteService.q {
private long a = System.currentTimeMillis();
class a implements Runnable {
final int i;
final int q;
final int r;
a(int i, int i2, int i3) {
this.i = i;
this.q = i2;
this.r = i3;
}
@Override
public void run() {
if (MacroEdit.this.C != null) {
MacroEdit.this.C.K0(false, h.this.f(this.i, this.q));
MacroEdit.this.C.R(this.r);
}
}
}
h() {
}
public boolean f(int i, int i2) {
boolean z = (i & 64) == 0 && System.currentTimeMillis() - this.a < 1000 && i2 != 30 && i2 != 35;
this.a = System.currentTimeMillis();
return z;
}
@Override
public void a(int i, int i2) {
r7.f("MacroEdit", "task finished, exeID " + i + " flags: " + i2);
if (MacroEdit.this.C == null || !MacroEdit.this.c1(i)) {
return;
}
MacroEdit.this.k1();
MacroEdit.this.A = null;
MacroEdit.this.B = null;
MacroEdit.this.C.setCurrentAction(-1);
MacroEdit.this.C.setNextAction(-1);
MacroEdit.this.C.K0(true, false);
MacroEdit.this.o1(true);
MacroEdit macroEdit = MacroEdit.this;
Boolean bool = Boolean.TRUE;
macroEdit.p1(bool, bool, true, "onTaskFinished");
}
@Override
public void b(int i, int i2, int i3, c.b bVar, SpannableStringBuilder spannableStringBuilder, int i4, int i5) {
r7.f("MacroEdit", "action finished exeID " + i + " action no " + i2 + " code " + i3 + " status: " + bVar + " next " + i5);
if (MacroEdit.this.C == null || !MacroEdit.this.c1(i)) {
return;
}
MacroEdit macroEdit = MacroEdit.this;
Boolean bool = Boolean.TRUE;
macroEdit.p1(bool, bool, true, "actionFinished");
int i1 = MacroEdit.this.i1(i2, i3);
if (i1 > -1) {
tn selected = MacroEdit.this.C.getSelected();
if (i1 >= selected.c1()) {
if (i3 == 38 || i3 == 40) {
r7.f("MacroEdit", "skip appended block end action");
return;
} else {
MacroEdit.this.x1("finished action > task action max");
return;
}
}
int j = selected.A0(i1).j();
if (i3 != j) {
MacroEdit.this.x1("index " + i2 + ", actionCode " + i3 + " != expected " + j);
return;
}
selected.h2(i1, bVar);
MacroEdit.this.C.setCurrentAction(-1);
int i12 = (i5 == -1 || (MacroEdit.this.B != null && i5 >= MacroEdit.this.B.size())) ? -1 : MacroEdit.this.i1(i5, i3);
if (i12 != -1) {
MacroEdit.this.C.setNextAction(i12);
selected.i2(i12 + 1, Integer.MAX_VALUE, null);
}
if (bVar == c.b.Err || bVar == c.b.Exception) {
selected.A0(i1).x1(spannableStringBuilder);
}
MacroEdit.this.runOnUiThread(new a(i4, i3, i1));
}
}
@Override
public void c(int i, int i2, int i3) {
r7.f("MacroEdit", "new task ID " + i + " exeID: " + i2 + " flags: " + i3);
if (MacroEdit.this.I0() && MacroEdit.this.a1(i3)) {
MacroEdit.this.A = Integer.valueOf(i2);
MacroEdit.this.o1(true);
MacroEdit.this.p1(Boolean.TRUE, null, true, "onNewTask");
}
}
@Override
public void d(int i, int i2, int i3, int i4) {
r7.f("MacroEdit", "action started exe ID " + i + " action no " + i2 + " code " + i3);
if (MacroEdit.this.C == null || !MacroEdit.this.c1(i)) {
return;
}
MacroEdit.this.C.setCurrentAction(MacroEdit.this.i1(i2, i3));
MacroEdit.this.C.setNextAction(-1);
MacroEdit.this.C.K0(true, f(i4, i3));
MacroEdit.this.p1(null, Boolean.valueOf(!((i4 & 64) > 0)), true, "onActionStarted");
}
}
public boolean I0() {
return J0() && this.A.intValue() == -1;
}
public boolean J0() {
return this.A != null;
}
private void K0() {
if (Y0()) {
return;
}
wh whVar = new wh(this, new e());
this.y = whVar;
if (whVar.d(ExecuteService.class, 33)) {
return;
}
r7.G("MacroEdit", "failed to bind to " + this.y.toString());
this.y = null;
}
public boolean L0() {
tn selected = this.C.getSelected();
if (selected != null && selected.c1() > 0) {
Iterator<net.dinglisch.android.taskerm.c> it = selected.D0().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
if (kq.u(it.next(), true)) {
if (!lp.e(this, 1, 2131890958, 1)) {
break;
}
}
}
return true;
}
dq.a0(this, 2131888038, new Object[0]);
return false;
}
private void M0() {
this.C.setCurrentAction(-1);
this.C.setNextAction(-1);
tn selected = this.C.getSelected();
if (selected != null) {
selected.k0();
}
this.C.T();
}
private void N0() {
this.A = null;
this.B = null;
this.C.K0(false, false);
o1(false);
Boolean bool = Boolean.TRUE;
p1(bool, bool, false, "stopTest");
}
private void O0() {
MacroEditView macroEditView = this.C;
if (macroEditView != null) {
macroEditView.M0();
this.C = null;
}
this.x = null;
this.w = null;
System.gc();
}
private void P0() {
if (!Z0()) {
r7.f("MacroEdit", "acquireExistingTask: no service");
return;
}
ExecuteService W0 = W0("acquireExisting");
if (W0 != null) {
List<Integer> Y5 = W0.Y5(16, false);
final MacroEditView macroEditView = this.C;
if (macroEditView == null) {
return;
}
int selectedID = macroEditView.getSelectedID();
if (dq.F(Y5)) {
return;
}
for (Integer num : Y5) {
int intValue = num.intValue();
if (W0.U4(intValue) == selectedID) {
int R4 = W0.R4(intValue);
this.A = num;
if ((W0.S4(intValue) & 32) > 0) {
macroEditView.setNextAction(R4);
} else {
macroEditView.setCurrentAction(R4);
}
c.b[] V4 = W0.V4(intValue, R4);
if (V4 != null) {
tn selected = macroEditView.getSelected();
for (int i = 0; i < V4.length; i++) {
selected.h2(i, V4[i]);
}
}
this.v.m(new Runnable() {
@Override
public final void run() {
MacroEditView.this.K0(false, false);
}
});
this.v.m(new Runnable() {
@Override
public final void run() {
MacroEdit.this.e1();
}
});
r1();
return;
}
}
}
}
public void Q0() {
int selectedID = this.C.getSelectedID();
Intent intent = new Intent();
intent.putExtra("taskidr", selectedID);
MyActivity.X(this, -1, intent);
finish();
}
private void R0(int i) {
if (J0()) {
w1();
} else {
u1(false, i);
}
}
private boolean S0(boolean z) {
boolean z2 = false;
if (this.C.n1(false)) {
if (this.C.getSelectedNoActions() > 0) {
this.C.f0(-1);
if (z) {
this.C.X0();
} else {
Q0();
}
z2 = true;
} else {
finish();
}
}
r7.f("MacroEdit", "doSaveAndExit done: " + z2);
return z2;
}
public void T0(int i, int i2) {
r7.f("MacroEdit", "do service action " + i + " / " + i2);
if (i == 0) {
U0(i2);
} else if (i == 1) {
R0(i2);
}
}
private void U0(int i) {
Integer num;
ImageView imageView;
Boolean bool = Boolean.FALSE;
p1(bool, bool, false, "doStep");
if (dq.N3(this) && (imageView = this.w) != null) {
imageView.performHapticFeedback(0, 2);
}
if (!J0()) {
u1(true, i);
return;
}
ExecuteService W0 = W0("doStep");
if (W0 == null || (num = this.A) == null) {
return;
}
r7.f("MacroEdit", "do step: task ID: " + num);
if ((W0.S4(num.intValue()) & 64) > 0) {
W0.I7(num.intValue(), false);
return;
}
r7.f("MacroEdit", "not stepping, switch to stepped");
W0.J7(num.intValue(), true);
W0.w5();
}
private ExecuteService W0(String str) {
wh whVar = this.y;
if (whVar != null) {
return (ExecuteService) whVar.e();
}
r7.G("MacroEdit", "getService: no connection");
return null;
}
private boolean Y0() {
return this.y != null;
}
private boolean Z0() {
return Y0() && this.y.f();
}
public boolean a1(int i) {
return (i & 16) > 0;
}
private void b1() {
this.v.l(new Runnable() {
@Override
public final void run() {
MacroEdit.this.f1();
}
});
}
public void e1() {
o1(false);
}
public void f1() {
int i = 0;
while (!Z0()) {
com.joaomgcd.taskerm.util.k8.P(300L);
i++;
if (i > 3) {
break;
}
}
P0();
}
public lj.e0 g1() {
this.C.setTitleView();
return lj.e0.a;
}
public void h1() {
boolean J0 = J0();
int i = J0 ? 2130969151 : 2130969291;
ImageView imageView = this.x;
if (imageView != null) {
imageView.setImageResource(tp.J(this, i));
}
n1(!J0);
}
public int i1(int i, int i2) {
if (dq.F(this.B)) {
return i;
}
if (i != this.B.size()) {
if (i < this.B.size()) {
return this.B.get(i).intValue();
}
if (i2 != 40 && i2 != 38) {
x1("mapAction: bad index " + i + ", max " + this.B.size());
}
}
return -1;
}
private void j1() {
MacroEditView macroEditView = new MacroEditView(this);
this.C = macroEditView;
macroEditView.setId(2131297324);
this.C.setProjectId(this.E);
setContentView(this.C);
ImageView imageView = (ImageView) findViewById(2131296993);
this.x = imageView;
imageView.setOnClickListener(this);
this.x.setVisibility(0);
ImageView imageView2 = (ImageView) findViewById(2131296994);
this.w = imageView2;
imageView2.setOnClickListener(this);
this.w.setVisibility(0);
this.w.setImageResource(tp.J(this, 2130969150));
dq.O2(this.x, 2131891218);
dq.O2(this.w, 2131891252);
ImageView[] imageViewArr = {this.x, this.w};
for (int i = 0; i < 2; i++) {
ImageView imageView3 = imageViewArr[i];
up.x(this, imageView3, up.b(this));
up.A(imageView3);
}
o1(false);
}
public void k1() {
if (Y0() && Z0() && this.z != null) {
r7.f("MacroEdit", "remove exe listener");
ExecuteService W0 = W0("removeListener");
if (W0 != null) {
W0.d7(this.z);
this.z = null;
}
}
}
private void n1(boolean z) {
if (z) {
ImageView imageView = this.x;
if (imageView != null) {
imageView.setOnLongClickListener(new b());
}
ImageView imageView2 = this.w;
if (imageView2 != null) {
imageView2.setOnLongClickListener(new c());
return;
}
return;
}
ImageView imageView3 = this.x;
if (imageView3 != null) {
imageView3.setLongClickable(false);
}
ImageView imageView4 = this.w;
if (imageView4 != null) {
imageView4.setLongClickable(false);
}
}
public void o1(boolean z) {
Runnable runnable = new Runnable() {
@Override
public final void run() {
MacroEdit.this.h1();
}
};
if (z) {
runOnUiThread(runnable);
} else {
runnable.run();
}
}
public void p1(Boolean bool, Boolean bool2, boolean z, String str) {
g gVar = new g(bool, bool2);
if (z) {
runOnUiThread(gVar);
} else {
gVar.run();
}
}
private void q1() {
this.A = -1;
}
public boolean r1() {
ExecuteService W0 = W0("setupListener");
if (W0 == null) {
r7.G("MacroEdit", "setupExeServiceEventListener: no service");
} else {
h hVar = new h();
this.z = hVar;
W0.x0(hVar);
}
return this.z != null;
}
public void s1(int i) {
fn fnVar = new fn(this);
fnVar.a(2131890140, 100, 0, 100, new d(i, fnVar)).show();
}
public void t1(String str) {
dq.b0(this, vh.g(this, 2131887901, new Object[0]) + ": " + str, new Object[0]);
}
private void u1(boolean z, int i) {
tn selected = this.C.getSelected();
selected.k0();
tn R = to.u1(this.C.getContext()).R(selected.P0());
if (R == null) {
R = to.h2(this.C.getContext()).R(selected.P0());
}
if (R != null) {
selected.H(R.M());
}
if (this.C.q0()) {
List<Integer> selectedActionIndices = this.C.getSelectedActionIndices();
if (!dq.F(selectedActionIndices) && selectedActionIndices.size() < selected.c1()) {
this.B = selectedActionIndices;
selected = selected.r0();
for (int c1 = selected.c1() - 1; c1 >= 0; c1--) {
if (!selectedActionIndices.contains(Integer.valueOf(c1))) {
selected.s0(c1);
}
}
}
this.C.h0();
}
selected.D2(i);
if (!r1()) {
t1("no service");
} else {
selected.w0(this, z, this.D, this.E);
q1();
}
}
private void v1() {
ExecuteService W0;
Integer num = this.A;
if (num == null || !Z0() || (W0 = W0("stopTestingTasks")) == null) {
return;
}
W0.s8(W0.T4(num.intValue()), false, true);
}
public void w1() {
if (J0()) {
k1();
v1();
N0();
}
M0();
}
public void x1(String str) {
r7.k("MacroEdit", "tracking failure: " + str);
runOnUiThread(new f(str));
}
private void y1() {
if (J0() && !dq.F(this.B)) {
v1();
dq.j0(this, 2131887897, new Object[0]);
}
z1();
}
private void z1() {
k1();
if (Y0()) {
r7.f("MacroEdit", "unbind exe service");
this.y.g();
this.y = null;
}
}
public void V0() {
this.C.k0();
}
public tn X0() {
return this.C.getTask();
}
public boolean c1(int i) {
Integer num = this.A;
return num != null && num.intValue() == i;
}
@Override
public void g(com.joaomgcd.taskerm.util.e5 e5Var, com.joaomgcd.taskerm.util.t6 t6Var) {
}
public void l1() {
tn task = this.C.getTask();
if (task != null) {
this.v.C0(task, w(), this.C.getData(), new xj.a() {
@Override
public final Object invoke() {
lj.e0 g1;
g1 = MacroEdit.this.g1();
return g1;
}
});
}
}
protected void m1(Bundle bundle, boolean z) {
if (this.C.getSelected() == null) {
r7.f("MacroEdit", "store null");
com.joaomgcd.taskerm.util.g8.l(this, "amac");
bundle.remove("amac");
} else {
r7.f("MacroEdit", "store non-null");
bundle.putBoolean("amac", true);
this.C.getSelected().U(0).d0(this, "amac", 0);
}
}
@Override
protected void onActivityResult(int i, int i2, Intent intent) {
this.C.L0(i, i2, intent);
}
@Override
public void onBackPressed() {
S0(false);
}
@Override
public void onClick(View view) {
if (this.C.i) {
return;
}
if (this.w.equals(view) && this.w.isEnabled()) {
if (L0()) {
T0(0, 100);
}
} else if (this.x.equals(view) && this.x.isEnabled() && L0()) {
T0(1, 100);
}
}
@Override
public void onCreate(Bundle bundle) {
qi g2;
super.onCreate(bundle);
MyActivity.W(this, 0);
Bundle extras = getIntent().getExtras();
if (extras == null) {
extras = new Bundle();
}
Bundle bundle2 = extras;
this.E = bundle2.getInt("projectid");
this.D = bundle2.getInt("profileid", -1);
j1();
net.dinglisch.android.taskerm.a.T(this, true);
int i = bundle2.getInt("tid", -1);
int i2 = bundle2.getInt("amt");
boolean z = bundle2.getBoolean("son");
tn tnVar = null;
if (bundle != null) {
if (bundle.containsKey("amac") && (g2 = qi.g(this, "amac", true)) != null) {
tnVar = new tn(g2);
}
if (bundle.containsKey("sti")) {
i = bundle.getInt("sti");
}
}
int i3 = i;
tn tnVar2 = tnVar;
r7.f("MacroEdit", "start task ID: " + i3 + " stop selected: " + z + " mtype: " + i2);
StringBuilder sb = new StringBuilder();
sb.append("have restore: ");
sb.append(tnVar2 != null);
r7.f("MacroEdit", sb.toString());
getActionBar().setTitle(vh.g(this, 2131886733, new Object[0]));
this.C.s0(this, new a(), -1, (z ? 1 : 0) | (i2 != -1 ? 2 : 0) | 12, true);
boolean containsKey = bundle2.containsKey(ProfileManager.EXTRA_PROFILE_NAME);
String string = bundle2.getString(ProfileManager.EXTRA_PROFILE_NAME);
boolean z2 = bundle != null;
boolean z3 = i3 != -1;
boolean z4 = i3 == -1;
if (!z2 || z3) {
if (z4 && i2 == -1) {
this.C.W0(string);
} else if (z4 && containsKey) {
this.C.o0(string);
} else {
this.C.setTask(tnVar2, i3);
}
} else if (tnVar2 != null) {
this.C.setTask(tnVar2, i3);
}
if (bundle2.containsKey("actioncode")) {
int i4 = bundle2.getInt("actioncode");
bundle2.remove("actioncode");
this.C.setTopAction(i4);
this.C.k1(i4);
}
}
@Override
public void onDestroy() {
super.onDestroy();
y1();
O0();
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (!this.C.N0(menuItem, "activity_taskedit.html")) {
int itemId = menuItem.getItemId();
if (itemId == 1) {
finish();
} else {
if (itemId == 2) {
l1();
return true;
}
if (itemId == 16908332) {
S0(false);
return true;
}
this.v.G1(menuItem);
}
}
return true;
}
@Override
protected void onPause() {
super.onPause();
this.C.O0();
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
menu.clear();
net.dinglisch.android.taskerm.a.c(this, 1, 6, 2131886867, menu);
net.dinglisch.android.taskerm.a.z(this, 2, menu, 2131889790, 2130969236, 5);
this.v.E1(menu);
this.C.P0(menu);
return true;
}
@Override
protected void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
m1(bundle, true);
}
@Override
public void onStart() {
super.onStart();
K0();
b1();
}
@Override
public void onStop() {
super.onStop();
y1();
N0();
M0();
}
}