Ionic 3 - Hide status bar during splash screen show - ionic-framework

I have an app with Ionic 3 and in your app.component.ts, i using the Statusbar ionic plugin to hide that, but, this occurs only after platform ready is fired.
How do i hide that during splashscreen? I tried:
– Not hide during splashscreen, only after this hide
– Not change background color during splashscreen
Solutions?

Android
It seems that there is not elegant way to hide statusbar on app launch.
But there is an way to do that.
Find MainActivity.java (maybe platforms/android/src/io/ionic/starter)
Add the below code
import android.view.WindowManager;
public class MainActivity extends CordovaActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// [Hyuck] add this two line below
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
// [Hyuck] onStart() is totally new.
#Override
public void onStart()
{
super.onStart();
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
}
IOS
I can only test Android device. So, I just leave the link which may solve your issue

After addition of your code in MainActivity page
I run the command to build apk
I got this error
Task :app:compileDebugJavaWithJavac FAILED
E:\Ionic\AIOU_Solutions1\platforms\android\app\src\main\java\io\ionic\starter\MainActivity.java:38: error: package WindowManager does not exist
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

I got the same problem with a Cordova based app. I couldn't figure out how to hide the status bar during the Splashcreen (tried many things) until I found this solution.
Hide status bar during splashcreen
Option 1 - Edit files yourself
Find the file platforms/android/app/src/main/res/values/strings.xml
Add a custom theme with specific rules by editing the XML
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">My App Name</string>
<string name="launcher_name">#string/app_name</string>
<string name="activity_name">#string/launcher_name</string>
<!-- Add your custom theme rules -->
<style name="MyCustomTheme" parent="#style/Theme.AppCompat.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
Find the file platforms/android/app/src/main/AndroidManifest.xml
Find the <activity> tag and add the reference to "MyCustomTheme"
<activity android:theme="#style/MyCustomTheme" ...etc...
Option 2 - Edit files from the Cordova config.xml
You may prefer to manage this custom theme directly from your config.xml file without having to edit yourself the AndroidManifest.xml and strings.xml. It can be helpful in case of cordova platform remove android and cordova platform add android which will delete your changes.
Add this in your config.xml
<platform name="android">
<!-- Edit the activity tag fo your AndroidManifest.xml -->
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
<activity android:theme="#style/MyCustomTheme"/>
</edit-config>
<!-- Edit the strings.xml file -->
<edit-config file="strings.xml" mode="add" target="/resources">
<style name="MyCustomTheme" parent="#style/Theme.AppCompat.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
</edit-config>
</platform>
Last step, remember that for being able of using <edit-config> tag from your config.xml file, you need to add this xmlns attribute to your <widget> tag.
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns:android="http://schemas.android.com/apk/res/android" ...etc...
If you have better options, I'm curious to heard about it!

Related

Flutter add to app Android shows white screen on startActivity

I have an app where there are some screens that are made in Flutter (add2app). I have a class called CMFlutterActivity that is a subclass of io.flutter.embedding.android.FlutterActivity. I use this class to manage the method channels, but I am not too happy with how the screen is presented, because the first Flutter frame is not available when the Activity is presented. After some research I figured there is a method in the FlutterActivity that I can override to know when the first Flutter frame is available, it is called onFlutterUiDisplayed. The problem I have is: how do I manage to only make the Activity visible after this method has been called? Has anyone solved this problem already?
I am currently starting the activity in the following manner:
startActivity(Intent(context, CMFlutterActivity::class.java))
Here are some of my configurations:
AndroidManifest.xml:
<activity
android:name=".ui.flutter.CMFlutterActivity"
android:theme="#style/AppTheme.NoFullscreen"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait"
android:stateNotNeeded="true"
android:exported="true"
/>
styles.xml:
<style name="AppTheme.NoFullscreen">
<item name="android:windowFullscreen">false</item>
</style>

how to reduce Flutter launch_background.xml display time?

I have set an image in launch_background.xml file for splash screen. it takes around 5sec to switch to next page. how to reduce display time.
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <item android:drawable="#android:color/white" />-->
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#mipmap/splash_screen" />
</item>
</layer-list>
Please suggest how to reduce display time?
I think you are running app in debug mode so it will take time. I will suggest you run the app in release mode. by running this command in terminal.
flutter run --release
By default, flutter run compiles to debug mode. Your IDE supports this mode. Android Studio, for example, provides a Run > Debug… menu option, as well as a green bug icon overlayed with a small triangle on the project page.
Read more about Flutter's build modes here

Flutter: How to hide the progress circle while login using flutter_facebook_login

I am using the flutter_facebook_login package to login the app. This method shows a login progress bar everytime I login. I want to remove that progress bar and use my own progress indicator.
How can I do that?
I already have a working progress bar and have used it. All i want is to remove the progress indicator of flutter_facebook_plugin.
I used a method where i tweaked the AndroidManifest.xml file. but it didn't work.
AndroidManifest.xml
<activity
android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#style/LaunchTheme" />
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="LaunchTheme" parent="#android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:progressBarStyle">#style/InvisibleProgress</item>
<item name="android:windowBackground">#drawable/launch_background</item>
</style>
<style name="InvisibleProgress">
<item name="android:visibility">gone</item>
</style>
</resources>
Solution for Android is available here,
works fine for Flutter plugin also
Android: How to hide progress circle in Facebook login

change status bar color during splash screen in ionic 3

I already used
cordova-plugin-splashscreen
and in config.xml
<preference name="SplashStatusBarBackgroundColor" value="#b83500" />
<preference name="SplashNavigationBarBackgroundColor" value="#b83500" />
<platform name="android">
...
</platform>
it is not work
and in component.ts
this.statusBar.backgroundColorByHexString('#b83500');
but it change after splash screen.
so, how can i change status bar color during splash screen.
Remove the splash screen plugin and install this version of the plugin from
ionic cordova plugin rm cordova-plugin-splashscreen
ionic cordova plugin add https://github.com/goinnn/cordova-plugin-splashscreen.git#4.0.0#colors
Following this you can then add the preferences in you configx.xml file as you have already mentioned. However, do place them in the android section
<platform name="android">
<preference name="SplashStatusBarBackgroundColor" value="#b83500" />
<preference name="SplashNavigationBarBackgroundColor" value="#b83500" />
...
</platform>
This will solve you issue.
Do keep in mind this will cause issues with the ios version as this is an older version of the plugin itself. It however works perfectly on android.
This will only change color of status bar on splash screen. To keep the color changed you need to keep the following code in your app.component.ts file.
this.statusBar.backgroundColorByHexString('#b83500');
For Android, add following in styles.xml (I'm showing status bar with white background)
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
<item name="android:statusBarColor">#android:color/white</item>
</style>
<style name="AppTheme.NoActionBarLaunch" parent="AppTheme.NoActionBar">
<item name="android:statusBarColor">#android:color/white</item>
</style>

Android - Customizing the Spinner widget Look and Feel

Is it possible to change the color of the radio button in the Android spinner widget. By default it displays the green color for the radio button.
I need to change it to some other color, is it possible, and how?
I know this is an old question now, but here goes...
You will need to create a custom Theme and apply it to the Activity with your spinner.
First, you need to create images for the checked/unchecked states of the 'new' radio, you could just pull the given images btn_radio_on.png and btn_radio_off.png from the sdk's res/drawable-* folder(s). Edit them to look how you want (such as changing color or whatever) and save off to your project.
Next, create a new xml file in your res/values folder, and add the following:
<resources>
<style name="CustomSpinnerRadioTheme" parent="#android:style/Theme">
<item name="android:spinnerDropDownItemStyle">#style/EditedRadio</item>
</style>
<style name="EditedRadio" parent="#android:style/Widget.DropDownItem.Spinner">
<item name="android:checkMark">#drawable/edited_radio</item>
</style>
</resources>
Then, create another xml file in res/drawable named edited_radio.xml, and it should contain the following:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false" android:drawable="#drawable/btn_radio_off" />
<item android:state_checked="true" android:drawable="#drawable/btn_radio_on" />
</selector>
just be sure to reference your edited images for the checked states. Then you just have to apply the CustomSpinnerRadioTheme to your Activity and run!
A good resource I found is Applying Styles and Themes especially the additional reference on Android Styles (styles.xml) and Android Themes (themes.xml)