Skip to content

Commit ea1eca0

Browse files
committed
bugfix for local framgment preference crash
Signed-off-by: Akhil Kedia <akhil.kedia@samsung.com>
1 parent 16de853 commit ea1eca0

File tree

6 files changed

+217
-66
lines changed

6 files changed

+217
-66
lines changed

PlayStore/Description.html

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,19 @@
11
<u><b>AllTrans - Completely Translate Apps</b></u>
2-
<br>a la Chrome translation of webpages, but for Android apps.
3-
<br>
4-
<br><u><b>What AllTrans does</b></u>
5-
<br>It replaces <b>all text in an app</b> in a language from one language to another at runtime.
6-
<br>Say for example an app you want to use is in German, but you know only English.
7-
<br>Then whenever you open the required app, all the text in the app, <b>anywhere</b>, will be replaced by its English equivalents.
8-
<br>This is something similar to the way Automatic Translate works in Chrome.
9-
<br>
10-
<br><u><b>Requirements</b></u>
11-
<br>• Android 4.1 or later.
12-
<br><b>Xposed Framework</b> or <b>VirtualXposed</b> installed and running.
13-
<br><b>IF YOU DON'T KNOW WHAT XPOSED OR VIRTUALXPOSED IS, THIS APP IS NOT FOR YOU</b>
14-
<br>
15-
<br><u><b>How to use AllTrans</b></u>
16-
<br>• In "Global Settings" tab, tap "Enter Microsoft/Yandex Subscription Key", input the corresponding key (see Instructions from below).
17-
<br>• Choose the "Translate from Language" and "Translate to Language".
18-
<br>• In the "Apps to Translate" tab, find the app you want to translate, click the checkbox next to it.
19-
<br>• Close and restart the app you want translated - it should be translated!
20-
<br>
21-
<br><u><b>How to sign up for Microsoft Azure Translate</b></u>
22-
<br>Microsoft Translate requires a credit card to sign up. (But don’t worry, nothing will be charged.)</p>
23-
<br>• Sign up for a Microsoft Azure account.
24-
If you don’t already have an Azure account, sign up for a Microsoft Azure
25-
account at azure.com
26-
<br> • After you have an account, sign into portal.azure.com. Sign up for a
27-
subcription by following the steps below.
28-
<br> • Click “Subscriptions”. It has a key icon.
29-
<br> • Click the “+ Add” at the top
30-
<br> • Choose a “pay-as-you-go” subscription. Will require a credit card, but don’t worry, nothing will be
31-
charged.
32-
<br> • Verify your identity, add in the credit card information. You will not be charged.
33-
<br> • In “Add Technical Support”, select “No technical support”. <b>You will have to pay if you select
34-
any other</b>. Accept the “Agreement”, and click “Sign up”.
35-
<br> • Click “Home” at the top after you finish signing up.
36-
<br>• Add a translate API resource by following the steps below.
37-
<br> • Select the “+ Create a resource” option.
38-
<br> • In the search box saying “Search the Marketplace” type “translator” on the left, and select “Translator”
39-
from the search results.
40-
<br> • Click the blue “Create” button.
41-
<br> • In the “Resource group” field, type in any name, it does not matter.
42-
<br><b>In the “Region” Section, select “Global”</b>
43-
<br> • Type in any name in “Name” field, type in any name, it does not matter.
44-
<br> • In the “Pricing Tier” section, select the “F0 (2M Up to 2M characters translated per month)”. <b>You will have to
45-
pay if you select any other</b>.
46-
<br> • Click “Next: Tags”, then click “Next: Review + Create”, then click “Create”.
47-
<br> • Wait 1 minute for Microsoft to process your request, then go to “Home”.
48-
<br>• Copy your key from Microsoft and add it to AllTrans by following the steps below.
49-
<br> • Under the “Recent Resource” section, click the name of the resource you just created.
50-
<br> • Click “Keys and Endpoint” on the left. It has a key icon.
51-
<br> • Copy “KEY 1”. This is the key you need to add to AllTrans.
52-
<br>
2+
Like translation of webpages, but for Android apps.
3+
<u><b>What AllTrans does</b></u>
4+
It replaces <b>all text in an app</b> in a language from one language to another at runtime.
5+
Say for example an app you want to use is in German, but you know only English.
6+
Then whenever you open the required app, all the text in the app, <b>anywhere</b>, will be replaced by its English
7+
equivalents.
8+
This is something similar to the way Automatic Translate works in browsers.
9+
<u><b>Requirements</b></u>
10+
<b>Xposed Framework</b> or <b>VirtualXposed</b> or <b>Taichi</b> installed and running.
11+
<b>If you don't know what Xposed or Virtualxposed is, this app is probably not for you</b>
12+
<u><b>If you have a locked BootLoader or a non-rooted phone</b></u>
13+
You can download Taichi (an xposed emulator) from https://github.com/taichi-framework/TaiChi/releases/
14+
Alternatively you can download VirtualXposed (an xposed emulator like parallel space, dual apps) from https://github.com/android-hacker/VirtualXposed/releases
15+
<u><b>How to use AllTrans</b></u>
16+
• Make sure AllTrans is turned on in XposedInstaller / Taichi.
17+
• In "Global Settings" tab, choose the "Translate from Language" and "Translate to Language".
18+
• In the "Apps to Translate" tab, find the app you want to translate, click the checkbox next to it.
19+
• Close and restart the app you want translated - it should be translated!

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ This is something similar to the way Google Translate works in Chrome.
6060

6161
### Videos
6262

63-
A video (in English) showing how to use AllTrans by Gadget Hacks on Youtube [https://www.youtube.com/watch?v=sKDtkmISi6k](https://www.youtube.com/watch?v=sKDtkmISi6k)
63+
A video (in English) showing how to use AllTrans by Gadget Hacks on Youtube [https://www.youtube.com/watch?v=sKDtkmISi6k](https://www.youtube.com/watch?v=sKDtkmISi6k). This video is for an older version of the app, you no longer need API keys.
6464

6565
[![Alt text](https://img.youtube.com/vi/sKDtkmISi6k/0.jpg)](https://www.youtube.com/watch?v=sKDtkmISi6k)
6666

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ android {
2929
applicationId "akhil.alltrans"
3030
minSdkVersion 16
3131
targetSdkVersion 30
32-
versionCode 11
33-
versionName "1.7.0"
32+
versionCode 18
33+
versionName "1.8.0"
3434
multiDexEnabled true
3535
}
3636
buildTypes {

app/src/main/java/akhil/alltrans/AttachBaseContextHookHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ protected void beforeHookedMethod(MethodHookParam methodHookParam) {
133133

134134
if (PreferenceList.DrawText) {
135135
findAndHookMethod(Canvas.class, "drawText", CharSequence.class, int.class, int.class, float.class, float.class, Paint.class, alltrans.drawTextHook);
136+
findAndHookMethod(Canvas.class, "drawText", char[].class, int.class, int.class, float.class,
137+
float.class, Paint.class, alltrans.drawTextHook);
136138
findAndHookMethod(Canvas.class, "drawText", String.class, float.class, float.class, Paint.class, alltrans.drawTextHook);
137139
findAndHookMethod(Canvas.class, "drawText", String.class, int.class, int.class, float.class, float.class, Paint.class, alltrans.drawTextHook);
138140
}

app/src/main/java/akhil/alltrans/LocalPreferenceFragment.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ private void sortListPreferenceByEntries(String preferenceKey) {
114114
}
115115

116116
private void downloadModel(String translateLanguageSelected, boolean isFromLanguage){
117-
ListPreference translatorProvider1 = findPreference("TranslatorProvider");
118-
assert translatorProvider1 != null;
119-
String translatorProviderSelected1 = translatorProvider1.getValue();
120-
if (!translatorProviderSelected1.equals("g")) {
117+
118+
settings = getContext().getSharedPreferences("AllTransPref", Context.MODE_PRIVATE);
119+
String translatorProvider = settings.getString("TranslatorProvider", "g");
120+
assert translatorProvider != null;
121+
if (!translatorProvider.equals("g")) {
121122
return;
122123
}
123124
utils.debugLog("Downloading Translation model for Language " + translateLanguageSelected + " isFromLanguage " + isFromLanguage);
@@ -187,6 +188,14 @@ public void onClick(DialogInterface dialogInterface, int which) {
187188
public void onCreatePreferences(Bundle bundle, String rootKey) {
188189
//noinspection ConstantConditions
189190
settings = this.getActivity().getSharedPreferences("AllTransPref", Context.MODE_PRIVATE);
191+
if (applicationInfo == null) {
192+
Context context = getContext();
193+
CharSequence text = getString(R.string.wut_why_null);
194+
int duration = Toast.LENGTH_SHORT;
195+
Toast toast = Toast.makeText(context, text, duration);
196+
toast.show();
197+
return;
198+
}
190199
final PreferenceManager preferenceManager = getPreferenceManager();
191200
preferenceManager.setSharedPreferencesName(applicationInfo.packageName);
192201

@@ -196,14 +205,6 @@ public void onCreatePreferences(Bundle bundle, String rootKey) {
196205
} else {
197206
preferenceManager.getSharedPreferences().edit().putBoolean("LocalEnabled", false).apply();
198207
}
199-
if (applicationInfo == null) {
200-
Context context = getContext();
201-
CharSequence text = getString(R.string.wut_why_null);
202-
int duration = Toast.LENGTH_SHORT;
203-
Toast toast = Toast.makeText(context, text, duration);
204-
toast.show();
205-
return;
206-
}
207208
addPreferencesFromResource(R.xml.perappprefs);
208209

209210
SwitchPreference drawText = findPreference("DrawText");

0 commit comments

Comments
 (0)