Skip to content

Commit

Permalink
2.1.7
Browse files Browse the repository at this point in the history
Fix app crashing if device language is not English
  • Loading branch information
AbdurazaaqMohammed committed Jan 25, 2025
1 parent 52f5b7f commit 8151405
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId = "com.abdurazaaqmohammed.AntiSplit"
minSdk = 19
targetSdk = 35
versionCode = 44
versionName = "2.1.6"
versionCode = 45
versionName = "2.1.7"
multiDexEnabled = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ public class MainActivity extends AppCompatActivity {
private String suffix;
private boolean systemTheme;

public void setRss(Resources rss) {
this.rss = rss;
}

private Resources rss;
private Handler handler;

public Resources getRss() {
return rss;
}
private Handler handler;

public Handler getHandler() {
return handler;
Expand All @@ -140,16 +144,19 @@ protected void onCreate(Bundle savedInstanceState) {

WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
SharedPreferences settings = getSharedPreferences("set", Context.MODE_PRIVATE);
lang = settings.getString("lang", "en");

setContentView(R.layout.activity_main);

String deviceLang = Locale.getDefault().getLanguage();
boolean supportedLang = deviceLang.equals("ar") || deviceLang.equals("es") || deviceLang.equals("fr") || deviceLang.equals("in") || deviceLang.equals("it") || deviceLang.equals("pt-rBR") || deviceLang.equals("ru") || deviceLang.equals("tr") || deviceLang.equals("uk") || deviceLang.equals("vi");
lang = settings.getString("lang", supportedLang ? deviceLang : "en");
if(lang.equals(Locale.getDefault().getLanguage())) rss = getResources();
else LanguageUtil.updateMain(rss = LocaleHelper.setLocale(this, lang).getResources(), this);
else LanguageUtil.updateMain(LocaleHelper.setLocale(this, lang).getResources(), this);

boolean dark = (rss.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
setTheme(theme = settings.getInt("theme", dark
? com.google.android.material.R.style.Theme_Material3_Dark_NoActionBar : com.google.android.material.R.style.Theme_Material3_Light_NoActionBar));

setContentView(R.layout.activity_main);

if(theme == R.style.Theme_MyApp_Black) findViewById(R.id.main).setBackgroundColor(Color.BLACK);
deviceSpecsUtil = new DeviceSpecsUtil(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void updateLang(Resources res, ScrollView settingsDialog, MainActi
}

public static void updateMain(Resources res, MainActivity context) {
context.setRss(res);
context.<TextView>findViewById(R.id.decodeButton).setText(res.getString(R.string.merge));
context.<TextView>findViewById(R.id.fromAppsButton).setText(res.getString(R.string.select_from_installed_apps));
context.findViewById(R.id.settingsButton).setContentDescription(res.getString(R.string.settings));
Expand Down

0 comments on commit 8151405

Please sign in to comment.