forked from Dev4Mod/WaEnhancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Dev4Mod:master' into theme
- Loading branch information
Showing
38 changed files
with
882 additions
and
482 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.wmods.wppenhacer; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.text.Html; | ||
|
||
import com.wmods.wppenhacer.xposed.core.WppCore; | ||
import com.wmods.wppenhacer.xposed.utils.Utils; | ||
|
||
import java.util.Objects; | ||
|
||
import de.robv.android.xposed.XposedBridge; | ||
import okhttp3.OkHttpClient; | ||
|
||
public class UpdateChecker implements Runnable { | ||
|
||
private final Activity mActivity; | ||
|
||
public UpdateChecker(Activity activity) { | ||
this.mActivity = activity; | ||
} | ||
|
||
|
||
@Override | ||
public void run() { | ||
try { | ||
var client = new OkHttpClient(); | ||
var request = new okhttp3.Request.Builder() | ||
.url("https://t.me/s/waenhancher") | ||
.build(); | ||
var response = client.newCall(request).execute(); | ||
var body = response.body(); | ||
if (body == null) return; | ||
var content = body.string(); | ||
var indexHash = content.lastIndexOf("WaEnhancer_debug_"); | ||
var lastindexHash = content.indexOf(".apk", indexHash); | ||
var hash = content.substring(indexHash + 17, lastindexHash); | ||
var appInfo = mActivity.getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0); | ||
if (!appInfo.versionName.toLowerCase().contains(hash.toLowerCase().trim()) && !Objects.equals(WppCore.getPrivString("ignored_version", ""), hash)) { | ||
var changelogIndex = content.indexOf("<div class=\"tgme_widget_message_text js-message_text\" dir=\"auto\">", lastindexHash); | ||
var closeTag = content.indexOf("</div>", changelogIndex); | ||
var changelogText = content.substring(changelogIndex, closeTag + 6); | ||
var changelog = Html.fromHtml(changelogText, Html.FROM_HTML_MODE_COMPACT).toString(); | ||
mActivity.runOnUiThread(() -> { | ||
AlertDialog.Builder dialog = new AlertDialog.Builder(mActivity); | ||
dialog.setTitle("WAE - New version available!"); | ||
dialog.setMessage("Changelog:\n\n" + changelog); | ||
dialog.setNegativeButton("Ignore", (dialog1, which) -> { | ||
WppCore.setPrivString("ignored_version", hash); | ||
dialog1.dismiss(); | ||
}); | ||
dialog.setPositiveButton("Update", (dialog1, which) -> { | ||
Utils.openLink(mActivity, "https://t.me/waenhancher"); | ||
dialog1.dismiss(); | ||
}); | ||
dialog.show(); | ||
}); | ||
} | ||
} catch (Exception e) { | ||
XposedBridge.log(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
app/src/main/java/com/wmods/wppenhacer/listeners/DoubleTapListener.java
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/wmods/wppenhacer/listeners/OnMultiClickListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.wmods.wppenhacer.listeners; | ||
|
||
import android.view.View; | ||
|
||
public abstract class OnMultiClickListener implements View.OnClickListener { | ||
|
||
private final int targetClicks; | ||
private final long delay; | ||
private long lastClick = 0; | ||
private int clicks = 0; | ||
|
||
public OnMultiClickListener(int targetClicks, long delay) { | ||
if (targetClicks < 2) { | ||
throw new IllegalArgumentException("targetClicks must be greater than 1"); | ||
} | ||
this.targetClicks = targetClicks; | ||
this.delay = delay; | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
if (this.lastClick == 0 || System.currentTimeMillis() - this.lastClick < this.delay) { | ||
this.lastClick = System.currentTimeMillis(); | ||
this.clicks++; | ||
} else { | ||
this.lastClick = 0; | ||
this.clicks = 0; | ||
} | ||
if (this.clicks >= this.targetClicks) { | ||
this.clicks = 0; | ||
this.lastClick = 0; | ||
onMultiClick(v); | ||
} | ||
} | ||
|
||
abstract public void onMultiClick(View v); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.