Appcelerator Titanium: Open activity without animation - android

In Titanium Alloy I'm trying to open a controller which is a Window without animation.
What I've done is define a new style inside /platform/android/res/values/activity_no_animation.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.NoAnimation" parent="android:Theme">
<item name="android:windowAnimationStyle">#null</item>
</style>
</resources>
my controller filename is login.js, so in my tiapp.xml I've defined the activity like this (as explained here: http://docs.appcelerator.com/titanium/latest/#!/guide/tiapp.xml_and_timodule.xml_Reference-section-29004921_tiapp.xmlandtimodule.xmlReference-activities)
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.NoActionBar">
<activity url="login.js" android:theme="#style/Theme.NoAnimation" />
</application>
<!-- Need to specify at least API level 11 for Titanium SDK 3.2.x and prior -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19"/>
</manifest>
</android>
but when the app starts, after the splash screen I still see the activity animation. What I would expect is for the activity (window) to just show up.
what am I missing here?

For some strange reasons you cannot override all animations inside Titanium.
I've asked this question over here with no success.
I've tried patching ti mobile source code and making a custom build. As far as I could get was to disable the opening animation. Closing animation was still playing on some devices.

I found this by working backwards from SDK code, but when calling Ti.UI.Window.open() to actually open the window, supply the animated property set to false:
win = Ti.UI.createWindow(/* ... */);
win.open({ animated: false });
I'm not familiar with Alloy, but this should be reasonably easy to translate into Alloy.
This works at least in SDK 5.0.2.

Related

Android 12 Splash Screen Icon Not Displaying

I am seeing a weird issue with a new app that I am starting. I am utilizing the new Android 12 splash screen API to create my splash screen and I followed the guide provided by Google to do so. I included core-splashscreen in my project to provide compatibility with older versions of Android OS. When I run the app, I see the splash screen as expected on older OS versions like API 30, but when I run it on API 31, the splash screen icon that I provide is not displayed. The background color that I specify is displayed, but the icon is not there at all. I have tried this with a drawable asset as well as a mipmap and nothing is working. I am stumped as every tutorial I find shows the same steps I have followed and screenshots of their working splash screens, but I am not having any luck.
For context here is my splash screen style definition for v31:
<style name="Theme.Splash" parent="Theme.SplashScreen">
<item name="android:windowSplashScreenBackground">#color/orange_7A</item>
<item name="android:windowSplashScreenAnimatedIcon">#drawable/splash_foreground</item>
<item name="postSplashScreenTheme">#style/Theme.App</item>
</style>
I have an identical style for all other OS versions except I'm using "windowSplashScreenAnimatedIcon" instead of "android:windowSplashScreenAnimatedIcon". I have tried v31 with and without the "android:" in front of the item names and neither work. Here is my MainActivity.kt:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContent {
MyVeevaTheme {
Login()
}
}
}
I am also setting the "android:theme" property to my splash style in my AndroidManifest.xml. I know the splash style is being applied because it honors the background color, but it is not showing the icon for some reason even though the icon shows fine for older OS versions. Thanks in advance for any help you can give.
TL;DR kill the app and run from the launcher, icon does not show up when run from Android Studio.
Adding my comment here as an answer for better visibility.
I did figure out how to get it to show. I was following this tutorial to set up a base project to recreate the issue and I noticed the note the author put right near the bottom that mentions that just running the app doesn't show the full splash screen. You have to kill it and open the app from the launcher. Once I did that, I was able to see my splash screen. Annoying, but at least I have a way to test it now. I did go ahead and log a bug report for this as well, but I have a work around for now. Thanks for everyone's answers/comments!
folks as per the document installSplashScreen() should have been called prior to super.onCreate()
When you use the AndroidX SplashScreen Library, like you are doing (Theme.SplashScreen) you need to use the windowSplashScreen* attributes without the android: prefix.
The android: prefix is used to call the platform attributes, but in this case you are using the library and not the platform, so no need for the prefix:
res/values/themes.xml:
<style name="Theme.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/orange_7A</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/splash_foreground</item>
<item name="postSplashScreenTheme">#style/Theme.App</item>
</style>
For some reason when the app is launched through android studio it doesn't show the icon. Kill the app and launch app from the menu. Then the icon will appear.
This is true if you are not using Splash API: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
Icons are also not shown when navigating from the deeplink.
And It looks like its more then only not showing the icon. It also stops calling code for setOnExitAnimation lambda.
installSplashScreen().apply {
setOnAnimationListener { viewProvider ->
viewProvider.iconView
.animate()
.setDuration(500L)
.alpha(0f)
.withEndAnimation {
viewProvider.remove()
someActionCall()
}
.start()
}
If you relied upon this code to be always called it is not.
See mention in issue tracker: https://issuetracker.google.com/issues/207095799
The following instructions helped me, you may try this one. A few things need to keep in mind while working with the new splash screen API.
Keep updated on the latest library version. Follow this link (https://developer.android.com/jetpack/androidx/releases/core).
Put installSplashScreen() before setContentView()
Make a proper theme for the splash screen. You may try the following one.
Put this into your styles.xml or themes.xml folder and use it with your activity as the theme.
<!-- Splash Screen Theme. -->
<style name="Theme.AppSplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/white</item>
<item name="windowSplashScreenAnimatedIcon">#mipmap/ic_launcher_round</item>
<item name="windowSplashScreenAnimationDuration">1000</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
Make sure you set the theme to the MainActivity as well. For me that was the cause for the splash screen to now show. So you have to set the theme in both the application and the MainActivity
In addition to the other explanations above, I had the same issue but I realized that in my Manifest file I was setting the Splashscreen theme on my MainActivity which is correct, but my MainActivity was not having the main/launcher intent-filter which tells the android OS that this is the starting activity.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
So in your manifest, check that you are actually setting the Splashscreen theme on the Starting activity that is having the main/launcher intent-filter, and leave the Application tag to have your application theme and not the Splashscreen theme, to avoid having your app misbehave on other activities due to the theme because I experienced that too (This is especially for those migrating to the new splash screen).
Thank you, I hope someone finds this helpful
I had the same problem on my phone running Android 12. None of the above suggestions worked, (moving installSpashScreen() above super.onCreate etc...)
What fixed it for me was adding the android:theme attribute in the manifest to the Launching <activity> Tag, Not the <application> Tag, which is contrary to the documentation :
In the manifest, replace the theme of the starting activity to the theme you created in the previous step.
<manifest>
<application android:theme="#style/Theme.App.Starting">
<!-- or -->
<activity android:theme="#style/Theme.App.Starting">
Note, you still have to kill the activity and launch it from the launcher for this to work :(
In my case, the problem with the lack of a splash screen was the installation of the default activity theme:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name=".App"
android:theme="#style/Theme.Tracker.StartSplashScreen"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:allowBackup="true"
android:dataExtractionRules="#xml/data_extraction_rules"
android:fullBackupContent="#xml/backup_rules"
tools:targetApi="tiramisu">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="#style/Theme.Tracker"> <-------
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
When I deleted android:theme="#style/Theme.Tracker" line, it started working.

Android Studio Layout Preview Default Theme

Maybe this is well known option in Android Studio but I couldn't find it and Google has not helped me with this :( Every time I open a layout preview in Android Studio it's applying Material.Light theme to every layout in my project and I need manually apply my own theme to see how it will look like in a real app. Does somebody know how to change default Material.Light theme to be my custom theme when previewing layout with Layout Previewer in Android Studio so I don't need to apply it manually every time?
Thanks in advance.
Click here and change theme to your theme.
If you want a single theme to always open, give
android:theme="#style/YourTheme" in your <application> tag in Manifest file.
From next time onwards, when you create a new xml file, this will be your default theme.
You need to provide default theme on application tag in AndroidManifest.xml file. If you don't provide android:theme="#style/{themeName} there will be added Material.Light default theme.
Please check example of code snippet from my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage.iqall" >
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#drawable/iqall_main"
android:label="#string/app_name"
android:logo="#drawable/logo"
android:theme="#style/AppTheme" <!--in Preview you will see this as default preview-->
android:name=".IQallApp">
</application>
</manifest>
In all your manifests (in all modules), set
<application android:theme="#Theme/mainTheme">
</application
If you use Splashscreen theme (official way)
in your App module,
<application
android:theme="#style/SplashTheme"
tools:replace="android:theme">
</application>
AND RESTART Android Studio (very important)

disabling multitouch across the appwide in android xamarin

Xamarin forums question link:
https://forums.xamarin.com/discussion/60321/disabling-multitouch-across-the-appwide-in-android-xamarin#latest
Is there a way to disable multi-touch App wide in Xamarin Android.
I currently have a PCL, project. With shared code implemented using Xamarin forms UI.
I just want to prevent users from clicking more than 1 button in Android.
All our buttons are ICommand based and called from the viewModel. They are all async Tasks (we wanted to make them non-blocking and run in the background thread). --> This approach works fine in iOS, just want to disable it App wide in Android.
I tried the following in MainActivity.cs
public override bool OnTouchEvent(MotionEvent e)
{
if(e.PointerCount > 1)
{
return false;
}
else
{
return base.OnTouchEvent(e);
}
}
But it has not made any difference. Any help would be appreciated
public override void OnUserInteraction()
{
base.OnUserInteraction();
}
works but does not give me the number of touch events
Apply an application theme that disables multi-touch (derived from this answer).
Under Resources/Values add a file named Styles.xml with the following code:
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="MyAppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:windowEnableSplitTouch">false</item>
<item name="android:splitMotionEvents">false</item>
</style>
</resources>
android:windowEnableSplitTouch indicates if touches can be split across other windows that also support split touch.
android:splitMotionEvents indicates if a ViewGroup should split MotionEvents to separate child views during touch event dispatch.
Applying these at the application theme level will forced single touch for all views in your application.
And then in your applications manifest apply the style to the android:theme attribute on the application:
Sample manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0"
package="com.companyname.testapp">
<uses-sdk android:minSdkVersion="11" />
<application
android:allowBackup="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:theme="#style/MyAppTheme">
</application>
</manifest>
This will disable multi-touch throughout the application.

AppCompat v7 and DatePicker render issue

Recently I have read a chapter about dialogs in The Big Nerd Ranch Guide (2nd edition) and I have done everything by the book. However there are some issues, which are not mensioned in the book. Preview area of Intellij Idea doesn't work correctly with AppCompat themes.
This is my current theme:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
And this is what I have in preview area:
In the Internet I have read that using Base.Theme.AppCompat.Light.DarkActionBar may help. It removes the message, but ActionBar dissapeares also.
Oh, and DatePicker doesn't work with both and any Material Design:
This is just a render issue, because both themes work fine on devices. Can someone try to preview DatePicker in IDEA and Android Studio with AppCompat theme? May be this is just an IDEA issue.
P.S. dialog_date.xml
<?xml version="1.0" encoding="utf-8"?>
<DatePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/dialog_date_date_picker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:calendarViewShown="false"
/>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.criminalintent" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".CrimeListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CrimePagerActivity"
android:label="#string/app_name" >
</activity>
</application>
</manifest>
Whole project: https://onedrive.live.com/redir?resid=4653F2D263EA4131!21585&authkey=!AESze90_ZZ0p9WY&ithint=folder%2cproperties
Switching Themes
If you look at the declaration for Theme.AppCompat.Light.DarkActionBar, it aliases directly to Base.Theme.AppCompat.Light.DarkActionBar in AppCompat's values/themes.xml file:
<!-- Platform-independent theme providing an action bar in a dark-themed activity. -->
<style name="Theme.AppCompat.Light.DarkActionBar" parent="Base.Theme.AppCompat.Light.DarkActionBar" />
source
This isn't aliased in any of the other device configurations (e.g. values-v23/themes.xml, values-v18/themes.xml, etc). Have a look at the resouces for AppCompat here. This means that for every device, Theme.AppCompat.Light.DarkActionBar will always and only alias to Base.Theme.AppCompat.Light.DarkActionBar.
The docs for the Base theme make this even more clear:
Themes in the "Base.Theme" family vary based on the current
platform version to provide the correct basis on each device. You
probably don't want to use them directly in your apps.
Themes in the "Theme.AppCompat" family are meant to be extended or
used directly by apps.
source
So your switching from Theme.AppCompat.Light.DarkActionBar to Base.Theme.Light.DarkActionBar will never affect how things are displayed on actual devices and really isn't a change. The fact that Android Studio behaved differently is a problem with Android Studio (which I was unable to reproduce using your code on AS 2.0 preview 9).
Problem with Android Studio
I'll say that the Design tab has always been a bit flaky. It's getting better but hasn't always played nice, especially with support library stuff. To change your app's theme (even if what I said above wasn't true) just to make the Design tab look pretty is probably a bad idea. Think about your users. If you really want to know what your screen looks like, then deploy it to a real device or emulator.
Dialogs
I was also unable to reproduce your Dialog problem in AS 1.4 (stable) or AS 2.0 preview 9 (canary, ATM). But since your entire layout file is a DatePicker, I don't think you will get much benefit. This is even less beneficial when you consider that your DatePicker will be displayed in a dialog (which the Design tab is unable to simulate). I don't mean to sound harsh but you might just have to bite the bullet and use an emulator or physical device.
Make your style.xml look like this, toolbar will show up:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
And your DatePicker needs to loo like this:
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="spinner"
android:id="#+id/datePicker" />
If you need CalendarView in your xml add this insted of DatePicker:
<CalendarView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/calendarView1" />
Shitty Android Studio 1.5.0 should be updated to 1.5.1. So easy

Can't hide titlebar Titanium with Alloy

I have encounterd a problem in Titanium Appcelerator using Alloy MVC. This problem contains the following(see image)
I can't remove the black bar where the app name and logo is found. I am running the app on a device(Google Nexus, no simulator)
I have tried the following to remove this:
XML:
<Alloy>
<Window>
</Window>
</Alloy>
TSS:
"Window":
{
navBarHidden:true,
fullscreen:true,
backgroundColor:"Orange",
orientationModes:[Ti.UI.PORTRAIT],
}
TiApp.XML:
<statusbar-style>default</statusbar-style>
<statusbar-hidden>true</statusbar-hidden>
<fullscreen>true</fullscreen>
<navbar-hidden>true</navbar-hidden>
But none of these options are working to hide this black bar. In the iOS simulator it does remove the navigation bar by only setting the property fullscreen to true
Are there other options to get this away? Thanks in advance!
If you're using Titanium SDK 3.3.0, the Titanium theme, which is one of the default themes, now hides the action and status bar. To use it, just add this to your tiapp.xml.
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.Titanium"/>
</manifest>
</android>
You can read more about this and other themes that Titanium has for Android here: Android Themes.
Is it the ActionBar that's showing perhaps? Try hiding it.
To modify the theme to hide the action bar:
Add a custom theme file to your project:
platform/android/res/values/custom_theme.xml:
<?xml version="1.0" encoding="utf-8"?> <resources>
<style name="Theme.NoActionBar" parent="#style/Theme.Titanium">
<!-- Depending on the parent theme, this may be called android:windowActionBar instead of windowActionBar -->
<item name="windowActionBar">false</item>
</style> </resources>
Taken from: http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Action_Bar
I just added the code below in my TiApp.xml to hide the action bar that is where the name of my app and logo of Titanium were
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="#style/Theme.Titanium"/>
</manifest>
You can hide the status bar too (where the clock, battery level, notifications, etc. are) by adding the statusbar line
<fullscreen>false</fullscreen>
<statusbar-hidden>true</statusbar-hidden>
<analytics>true</analytics>

Categories

Resources