Skip to content

Commit

Permalink
Fixed bugs during language changing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrudul Tora committed Mar 1, 2021
1 parent 8041a63 commit 5f3a39d
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,12 @@ private void chooseLanguageDialog() {
builder.setSingleChoiceItems(languageList, pos, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changeLocale.setLocale(getResources().getStringArray(R.array.languageCodeList)[which]);
recreate();
if (!getResources().getStringArray(R.array.languageCodeList)[which].equals(preferences.getLocalePref())) {
changeLocale.setLocale(getResources().getStringArray(R.array.languageCodeList)[which]);
preferences.setLanguageChanged(true);
recreate();
}
dialog.dismiss();
}
});
builder.setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
Expand Down Expand Up @@ -383,53 +387,58 @@ protected void onResume() {
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent(SettingsActivity.this, MainActivity.class);
intent.putExtra("coresCount", coresCount);
intent.putExtra("drawableId", drawableId);
intent.putExtra("iconAvail", iconAvail);
intent.putExtra("totalRAM", totalRAM);
intent.putExtra("freeRam", freeRam);
intent.putExtra("usedRAM", usedRAM);
intent.putExtra("totalSys", totalSys);
intent.putExtra("usedSys", usedSys);
intent.putExtra("totalInternal", totalInternal);
intent.putExtra("usedInternal", usedInternal);
intent.putExtra("isExtAvail", isExtAvail);
if (isExtAvail) {
intent.putExtra("totalExternal", totalExternal);
intent.putExtra("usedExternal", usedExternal);
if (preferences.getLanguageChanged()) {
startActivity(new Intent(SettingsActivity.this, SplashActivity.class));
finishAffinity();
} else {
Intent intent = new Intent(SettingsActivity.this, MainActivity.class);
intent.putExtra("coresCount", coresCount);
intent.putExtra("drawableId", drawableId);
intent.putExtra("iconAvail", iconAvail);
intent.putExtra("totalRAM", totalRAM);
intent.putExtra("freeRam", freeRam);
intent.putExtra("usedRAM", usedRAM);
intent.putExtra("totalSys", totalSys);
intent.putExtra("usedSys", usedSys);
intent.putExtra("totalInternal", totalInternal);
intent.putExtra("usedInternal", usedInternal);
intent.putExtra("isExtAvail", isExtAvail);
if (isExtAvail) {
intent.putExtra("totalExternal", totalExternal);
intent.putExtra("usedExternal", usedExternal);
}
intent.putExtra("level", level);
intent.putExtra("voltage", voltage);
intent.putExtra("temp", temp);
intent.putExtra("status", status);
intent.putExtra("appCount", appCount);
intent.putExtra("sensorCount", sensorCount);
intent.putExtra("logoId", logoId);
intent.putExtra("wide", wide);
intent.putExtra("clearkey", clearkey);
intent.putExtra("processorName", processorName);
intent.putExtra("machine", machine);
intent.putExtra("family", family);
intent.putExtra("memory", memory);
intent.putExtra("bandwidth", bandwidth);
intent.putExtra("channel", channel);
intent.putExtra("cpuFamily", cpuFamily);
intent.putExtra("process", process);
intent.putParcelableArrayListExtra("cpuCoresList", cpuCoresList);
intent.putParcelableArrayListExtra("thermalList", thermalList);
intent.putParcelableArrayListExtra("deviceList", deviceList);
intent.putParcelableArrayListExtra("systemList", systemList);
intent.putParcelableArrayListExtra("cpuList", cpuList);
intent.putParcelableArrayListExtra("codecsList", codecsList);
intent.putParcelableArrayListExtra("displayList", displayList);
intent.putParcelableArrayListExtra("inputList", inputList);
intent.putParcelableArrayListExtra("sensorList", sensorList);
intent.putParcelableArrayListExtra("testList", testList);
ActivityOptions options =
ActivityOptions.makeCustomAnimation(SettingsActivity.this, android.R.anim.fade_in, android.R.anim.fade_out);
startActivity(intent, options.toBundle());
finish();
}
intent.putExtra("level", level);
intent.putExtra("voltage", voltage);
intent.putExtra("temp", temp);
intent.putExtra("status", status);
intent.putExtra("appCount", appCount);
intent.putExtra("sensorCount", sensorCount);
intent.putExtra("logoId", logoId);
intent.putExtra("wide", wide);
intent.putExtra("clearkey", clearkey);
intent.putExtra("processorName", processorName);
intent.putExtra("machine", machine);
intent.putExtra("family", family);
intent.putExtra("memory", memory);
intent.putExtra("bandwidth", bandwidth);
intent.putExtra("channel", channel);
intent.putExtra("cpuFamily", cpuFamily);
intent.putExtra("process", process);
intent.putParcelableArrayListExtra("cpuCoresList", cpuCoresList);
intent.putParcelableArrayListExtra("thermalList", thermalList);
intent.putParcelableArrayListExtra("deviceList", deviceList);
intent.putParcelableArrayListExtra("systemList", systemList);
intent.putParcelableArrayListExtra("cpuList", cpuList);
intent.putParcelableArrayListExtra("codecsList", codecsList);
intent.putParcelableArrayListExtra("displayList", displayList);
intent.putParcelableArrayListExtra("inputList", inputList);
intent.putParcelableArrayListExtra("sensorList", sensorList);
intent.putParcelableArrayListExtra("testList", testList);
ActivityOptions options =
ActivityOptions.makeCustomAnimation(SettingsActivity.this, android.R.anim.fade_in, android.R.anim.fade_out);
startActivity(intent, options.toBundle());
finish();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.toralabs.deviceinfo.R;
import com.toralabs.deviceinfo.impClasses.BuildInfo;
Expand Down Expand Up @@ -106,12 +107,13 @@ public class SplashActivity extends AppCompatActivity implements Runnable, Handl
RelativeLayout rlroot;
GLSurfaceView glSurfaceView;
ChangeLocale changeLocale;
TextView txtLoadingInLocalLang;
List<ApplicationInfo> packageList = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
preferences = new Preferences(SplashActivity.this);
changeLocale=new ChangeLocale(SplashActivity.this);
changeLocale = new ChangeLocale(SplashActivity.this);
changeLocale.setLocale(preferences.getLocalePref());
buildInfo = new BuildInfo(SplashActivity.this);
if (preferences.getMode()) {
Expand All @@ -127,6 +129,12 @@ protected void onCreate(Bundle savedInstanceState) {
}
if (getSupportActionBar() != null)
getSupportActionBar().hide();
if (preferences.getLanguageChanged()) {
txtLoadingInLocalLang = findViewById(R.id.txtLoadingInLocalLang);
txtLoadingInLocalLang.setText(getResources().getString(R.string.loading_in_local_lang));
txtLoadingInLocalLang.setVisibility(View.VISIBLE);
preferences.setLanguageChanged(false);
}
bundle = new Bundle();
message = new Message();
handlerThread.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import com.toralabs.deviceinfo.adapter.SimpleAdapter;
import com.toralabs.deviceinfo.impClasses.BuildInfo;
import com.toralabs.deviceinfo.menuItems.Preferences;
import com.toralabs.deviceinfo.models.ClickableModel;
import com.toralabs.deviceinfo.models.SimpleModel;

import java.lang.reflect.InvocationTargetException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public Preferences(Context context) {
this.sp = context.getSharedPreferences("MAP_PREF", MODE_PRIVATE);
}

public void setLanguageChanged(boolean bool) {
editor = sharedPreferences.edit();
editor.putBoolean("isLanguageChanged", bool).apply();
}

public boolean getLanguageChanged() {
return sharedPreferences.getBoolean("isLanguageChanged", false);
}

public boolean getPurchasePref() {
return sharedPreferences.getBoolean("purchase_state", false);
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ limitations under the License.
android:id="@+id/btnRemoveAds"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/button_border"
Expand All @@ -127,7 +127,7 @@ limitations under the License.
android:id="@+id/btnTranslate"
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/button_border"
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@ limitations under the License.
android:layout_marginTop="10dp"
android:fontFamily="sans-serif"
android:text="@string/app_name"
android:id="@+id/txtDeviceInfo"
android:textColor="@color/white"
android:textSize="28sp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txtDeviceInfo"
android:layout_centerHorizontal="true"
android:layout_marginTop="2dp"
android:fontFamily="sans-serif"
android:textColor="@color/white"
android:textSize="13sp"
android:id="@+id/txtLoadingInLocalLang"
android:visibility="gone"
android:textStyle="normal" />

<ProgressBar
android:id="@+id/progressSplash"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ limitations under the License.
<androidx.cardview.widget.CardView
android:id="@+id/cardSensors"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:padding="7dp"
Expand Down Expand Up @@ -594,7 +594,7 @@ limitations under the License.
<androidx.cardview.widget.CardView
android:id="@+id/cardApps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:padding="7dp"
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<string name="app_name">Device Info</string>
<string name="copyright">©ToraLabs</string>
<string name="app_name" translatable="false">Device Info</string>
<string name="copyright" translatable="false">©ToraLabs</string>
<string name="dashboard">Dashboard</string>
<string name="device">Device</string>
<string name="system">System</string>
Expand Down Expand Up @@ -386,6 +386,7 @@
<string name="allow">Allow</string>
<string name="choose_language">Choose Language</string>
<string name="confirm">Confirm</string>
<string name="loading_in_local_lang">Changing Language ...</string>

<!-- content description strings -->
<string name="desc_mode">Mode Type Image</string>
Expand All @@ -400,8 +401,8 @@
<string name="desc_icon">Splash Icon</string>
<string name="mode">Mode Type Image</string>

<string name="nativead1">182852390180298_182853473513523</string>
<string name="nativead2">182852390180298_184270953371775</string>
<string name="nativerectangle1">182852390180298_184834379982099</string>
<string name="fullscreenad1">182852390180298_182931730172364</string>
<string name="nativead1" translatable="false">182852390180298_182853473513523</string>
<string name="nativead2" translatable="false">182852390180298_184270953371775</string>
<string name="nativerectangle1" translatable="false">182852390180298_184834379982099</string>
<string name="fullscreenad1" translatable="false">182852390180298_182931730172364</string>
</resources>

0 comments on commit 5f3a39d

Please sign in to comment.