commit 6c09f67e160f83dff115f3e7b49613b9146818ca Author: Hashik Donthineni hashikdonthineni@gmail.com Date: Thu Feb 27 21:50:18 2020 +0530
Extracted String Resources --- .../android/ui/onboarding/CustomSlideBigText.java | 12 ++++----- .../android/ui/onboarding/OnboardingActivity.java | 29 ++++++++++++---------- app/src/main/res/values/strings.xml | 7 ++++++ 3 files changed, 29 insertions(+), 19 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/CustomSlideBigText.java b/app/src/main/java/org/torproject/android/ui/onboarding/CustomSlideBigText.java index c010ce0d..17afebda 100644 --- a/app/src/main/java/org/torproject/android/ui/onboarding/CustomSlideBigText.java +++ b/app/src/main/java/org/torproject/android/ui/onboarding/CustomSlideBigText.java @@ -85,10 +85,10 @@ public class CustomSlideBigText extends Fragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { - savedInstanceState.getString("Title"); - tv.setText(savedInstanceState.getString("SubTitle")); + savedInstanceState.getString(getResources().getString(R.string.Title)); + tv.setText(savedInstanceState.getString(getResources().getString(R.string.SubTitle))); if (mButtonText != null) { - button.setText(savedInstanceState.getString("ButtonText")); + button.setText(savedInstanceState.getString(getResources().getString(R.string.ButtonText))); }
} @@ -97,10 +97,10 @@ public class CustomSlideBigText extends Fragment { @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putString("Title", mTitle); - outState.putString("SubTitle", mSubTitle); + outState.putString(getResources().getString(R.string.Title), mTitle); + outState.putString(getResources().getString(R.string.SubTitle), mSubTitle); if (mButtonText != null) { - outState.putString("ButtonText", mButtonText); + outState.putString(getResources().getString(R.string.ButtonText), mButtonText); } }
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java index a732e76d..3038f6de 100644 --- a/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java +++ b/app/src/main/java/org/torproject/android/ui/onboarding/OnboardingActivity.java @@ -4,12 +4,15 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; + import androidx.annotation.Nullable; import androidx.fragment.app.Fragment;
import android.util.Log; import android.view.View; + import com.github.paolorotolo.appintro.AppIntro; + import org.torproject.android.R; import org.torproject.android.service.util.Prefs; import org.torproject.android.settings.LocaleHelper; @@ -28,13 +31,13 @@ public class OnboardingActivity extends AppIntro { super.onCreate(savedInstanceState);
if (savedInstanceState != null) { - welcome = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, "welcome"); - intro2 = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, "intro2"); - cs2 = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, "cs2"); + welcome = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, getResources().getString(R.string.WelcomeFragment)); + intro2 = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, getResources().getString(R.string.Intro2Fragment)); + cs2 = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, getResources().getString(R.string.CS2Fragment)); if (PermissionManager.isLollipopOrHigher()) - cs3 = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, "cs3"); + cs3 = (CustomSlideBigText) getSupportFragmentManager().getFragment(savedInstanceState, getResources().getString(R.string.CS3Fragment));
- }else{ + } else { // Instead of fragments, you can also use our default slide // Just set a title, description, background and image. AppIntro will do the rest. welcome = CustomSlideBigText.newInstance(R.layout.custom_slide_big_text); @@ -52,7 +55,7 @@ public class OnboardingActivity extends AppIntro { cs2.showButton(getString(R.string.action_more), new View.OnClickListener() { @Override public void onClick(View v) { - startActivity(new Intent(OnboardingActivity.this,BridgeWizardActivity.class)); + startActivity(new Intent(OnboardingActivity.this, BridgeWizardActivity.class)); } }); addSlide(cs2); @@ -113,13 +116,13 @@ public class OnboardingActivity extends AppIntro { }
//Should check if the fragment exists in the fragment manager or else it'll flag error - if(count >= 1) - getSupportFragmentManager().putFragment(outState, "welcome", welcome); - if(count >= 2) - getSupportFragmentManager().putFragment(outState, "intro2", intro2); - if(count >=3) - getSupportFragmentManager().putFragment(outState, "cs2", cs2); + if (count >= 1) + getSupportFragmentManager().putFragment(outState, getResources().getString(R.string.WelcomeFragment), welcome); + if (count >= 2) + getSupportFragmentManager().putFragment(outState, getResources().getString(R.string.Intro2Fragment), intro2); + if (count >= 3) + getSupportFragmentManager().putFragment(outState, getResources().getString(R.string.CS2Fragment), cs2); if (count >= 4 && PermissionManager.isLollipopOrHigher()) - getSupportFragmentManager().putFragment(outState, "cs3", cs3); + getSupportFragmentManager().putFragment(outState, getResources().getString(R.string.CS3Fragment), cs3); } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bff412a2..54a0f20a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -259,4 +259,11 @@ <string name="app_services">App services</string> <string name="default_socks_http">SOCKS: - HTTP: -</string> <string name="refresh_apps">Refresh Apps</string> + <string name="Title">Title</string> + <string name="SubTitle">SubTitle</string> + <string name="ButtonText">ButtonText</string> + <string name="WelcomeFragment">welcome</string> + <string name="Intro2Fragment">intro2</string> + <string name="CS2Fragment">cs2</string> + <string name="CS3Fragment">cs3</string> </resources>
tor-commits@lists.torproject.org