Android - Stripe - Applying style to PaymentMethodsActivity - android

I'm currently implementing Stripe into my application.
And using the example code from their documentation, I'm starting their PaymentMethodsActivity like this.
private fun startPaymentSelectActivity() {
val intent = PaymentMethodsActivity.newIntent(this#PaymentActivity)
startActivityForResult(intent, REQUEST_CODE_SELECT_SOURCE)
}
However, the created PaymentMethodsActivity's theme does not follow my app's theme, it's using their blue Toolbar. Like this
How do I apply a Theme to this Activity?

ScreenShot attached here
1.Download Stripe from here
"https://github.com/stripe/stripe-android"
2.import stripe module in your project and Update UI as you want from it's res folder

You can add this into your styles.xml and customize the colors
<style name="StripeDefaultTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#0091ea</item>
<item name="colorAccent">#color/accent_color_default</item>
<item name="colorControlNormal">#color/control_normal_color_default</item>
<item name="titleTextColor">#android:color/white</item>
<item name="android:textColorSecondary">#android:color/secondary_text_light</item>
</style>
Be careful to keep the style name ( name="StripeDefaultTheme" )
I'm using 'com.stripe:stripe-android:6.1.2' and that's work fine.
Source: https://github.com/stripe/stripe-android/issues/414

Related

Android: windowLightNavigationBar not working

Background: My background is in web development, ruby and javascript. I'm working on a mostly react-native app, so very likely I'm missing something basic.
What I want
android navigation bar to be white with dark system buttons see image in link white navigation bar
My Current Code
res/values/style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:navigationBarColor">#FFFFFF</item>
</style>
</resources>
What is happening instead
The background AND the buttons are white. which is not so great for UX.
** What I have Tried **
this is what got me where I am now Change navigation bar icon color on Android
I have tried putting style.xml in a values-v27 folder.
I just worked on this same topic and found out you need to run at least Android 9.0 (or API level 28) on the device/emulator for this to work.
Also, I had to add this to the color of the bar:
<item name="android:navigationBarColor">#android:color/white</item>
So, recommended steps:
Create a values-v28 folder
Insert the style:
<item name="android:navigationBarColor">#android:color/white</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowLightNavigationBar">true</item>
In your other values folder, you kind of have to live with the fact that this windowsLightNavigationBar doesn't apply...
Small remark
I also found a bug on this change, when putting app in background and then opening it again, the navbar buttons stay white for a second before getting the dark color
Your code is working as intended for me. Make sure you have the file name and file path written correctly:
https://imgur.com/xclYDuZ
A new approach would be:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.navigationBarColor = ContextCompat.getColor(this, android.R.color.white)
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightNavigationBars = true
}

How can I call the style of a new Library as parent in style.xml?

I am building a new library for Android and a demo project that I am using to test the library.
The library that I made has a style called Light and in the demo I am applying this style in Java using setTheme(R.style.Light) but I would like to replace it calling the theme directly in style.xml. What I have right now in the demo/res/values/style.xml is
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
and I would like to replace it with something similar to:
<style name="AppTheme" parent="myLibrary.Light">
I have tried with parent="#style/Light" but it's not working.
Does anyone know how I can do it?
To inherit styles from a library or your own project, declare the parent style name without the #android:style/ part. For example, the following example inherits text appearance styles from the support library:
<style name="GreenText" parent="TextAppearance.AppCompat">
<item name="android:textColor">#00FF00</item>
</style>
For more details
I found the solution,
My problem was that in my library I had different styles depending on the version of Android. For each version of Android my main theme was referred to different parents by mistake. I just changed the parents in my library making sure that they are referring to the same one and it fixed my problem. Now in my app I can refer to the theme created in my library without crashing the application.

Firebase UI - Auth - Custom Background only for AuthMethodPicker

Is it possible to use a custom background for the FirebaseUI.AuthMethodPicker ONLY?
I know you can use <item name="android:windowBackground">#drawable/my_background</item> in the firebase ui theme, but this changes the background for all activities (e.g. register email, etc.), and thats not what I want.
Thank you already!
You can customize them in the theme with your own style (for firebase UI version 0.6.0 and above) where the theme parent are:-
FirebaseUI.AuthMethodPicker.Logo ,
FirebaseUI.AuthMethodPicker etc.
OR refer to nice github link :-
https://github.com/firebase/FirebaseUI-Android/tree/master/auth
This helped me change the ui of the screens that follow the sign in screen
<style name="FirebaseUI.WrapperStyle">
<item name="android:background">#mipmap/bg_login_flow</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">match_parent</item>
<item name="android:paddingTop">16dp</item>
<item name="android:paddingLeft">
#dimen/fui_wrapper_padding_horiz
</item>
<item name="android:paddingRight">#dimen/fui_wrapper_padding_horiz
</item>
</style>
The thing that allowed me to change only the AuthMethodPicker activity background was to override the whole layout resource file. In essence, you need to copy the fui_auth_method_picker_layout.xml from the FirebaseAuthUI github repository and set the background in there. The change there will not result in any of the other activities.

Change Text for loading screen in ActionBar-PullToRefresh library

I have successfully implemented ActionBar-PullToRefresh in my code. Now whenever I refresh the list it shows "Loading ..." text in ActionBar.
So how to change that text in ActionBar. Do I directly change the string in the library or is there any other way to do that...
Approved approach from the samples
Source: https://github.com/chrisbanes/ActionBar-PullToRefresh/tree/master/samples
Create a theme with text overrides (e.g. ptrPullText),
that is, res/values/styles.xml:
<resources>
<style name="Theme.Holo.CustomPtrHeader" parent="android:Theme.Holo">
<item name="ptrHeaderStyle">#style/Widget.Custom.PtrHeader</item>
</style>
<style name="Widget.Custom.PtrHeader" parent="android:Widget">
<item name="ptrRefreshingText">Pulling down the internet</item>
</style>
</resources>
Apply the custom theme to your activity in AndroidManifest.xml
<activity
...
android:theme="#style/Theme.Holo.CustomPtrHeader" />
or Register you own HeaderTransformer
For the example on how to do this, please see the GridView sample.
or A little hackier way
Please note that setPullText is not on the HeaderTransformer interface, it's an instance method of DefaultHeaderTransformer:
attacher = PullToRefreshAttacher.get(this);
attacher.addRefreshableView(listView, this);
transformer = ((DefaultHeaderTransformer)attacher.getHeaderTransformer());
transformer.setRefreshingText("Pulling down the internet");

How to set the background screen as Wallpaper all the time?

Currently, I'm using this to show my application background as phone wallpaper.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER,
WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
But for some reason when I start my application by pressing the icon. It just shows the activity screen with the icons on the home screen. I didn't use dialog but it looks like a dialog because layout is just set that way. So I just want to show the wallpaper whenever this activity is running. But it only shows the wallpaper only after the next event occurs such as switching to different activity. I already put that code on onCreate() and whenever I do setContentView()..... Is there way to do such thing or there is just no way?
For users of AppCompat, just use the following in your styles.xml, no need for code:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
After long search and trial and error. I've found the solution to what I wanted. It was just creating separate themes.xml file and just tweak the Theme.Dialog which is already defined in default android themes.xml. All I did was change the Animation part. Originally in android themes.xml the line looks like this.
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
but since modifying in android themes.xml doesn't take the effect. I just created my own themes.xml as I said above and just set parent as android:Theme.Dialog. And added a line like this.
<item name="android:windowAnimationStyle">#android:style/Animation</item>
Thanks for the help and I hope this solution helps others.
Use following code -
rl = (RelativeLayout)findViewById(R.id.someid);
//relative layout is my root node in main.xml (yours may be linearlayout)
WallpaperManager wm = WallpaperManager.getInstance(this);
Drawable d = wm.peekDrawable();
rl.setBackgroundDrawable(d);// You can also use rl.setBackgroundDrawable(getWallpaper);

Categories

Resources