[android-developers] Re: Dynamic Application Theme

2013-02-04 Thread Pent
 No, I finish() the startup activity in onCreate() in which case it is never
 made visible.  This is documented somewhere.

Sure, but I couldn't manage to set the theme for the next activity
that way. No idea why it works for you.

Current (working) solution is to set the startup activity with the
same AB settings as the main activity, wait 350ms after layout then
start the main activity, but it has a nasty hacky feel to it, I'd much
rather hook off an OS event.

Pent

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-02 Thread Zsolt Vasvari
No, I finish() the startup activity in onCreate() in which case it is never 
made visible.  This is documented somewhere.

On Friday, February 1, 2013 9:18:10 PM UTC+8, Pent wrote:

  I have a StartUp Activity, which, based on user preference, can start 
 the 
  app in various real activity.  So, I guess, I effectively disabled the 
  preview screen, by doing this? 

 If animations are enabled in system prefs, you should get an animation 
 between the startup activity and the subactivity. Do you not ? 

 I couldn't disable that. 

 Intent.FLAG_ACTIVITY_NO_ANIMATION 

 in the intent to startActivity() is apparently just ignored. 

 Pent 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-01 Thread Zsolt Vasvari
It's interesting how my app doesn't have this issue.

I have a StartUp Activity, which, based on user preference, can start the 
app in various real activity.  So, I guess, I effectively disabled the 
preview screen, by doing this?


On Friday, February 1, 2013 3:43:03 PM UTC+8, Pent wrote:

  http://android.cyrilmottier.com/?p=873 

 Good link, thanks. Unfortunately it only helps with static 
 configuration, which is not the problem. The comments show that Romain 
 also doesn't have a solution for user-preference-based theming. 

 @Kostya: I know how to control the launch theme, the problem is doing 
 it dependent on user theme. If I misunderstood how the Chrome setup 
 might help, could you please let me know ? 

 Pent 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-01 Thread Kostya Vasilyev
Chrome (and Contacts) prevents its activity from being destroyed when he 
user presses Back (the normal code, in the framework, is to call finish 
then).

If you did the same, the mismatched animation won't happen so often, since 
when resuming an existing activity, the system will animate its actual 
content.

-- K

On Friday, February 1, 2013 11:43:03 AM UTC+4, Pent wrote:

  http://android.cyrilmottier.com/?p=873 

 Good link, thanks. Unfortunately it only helps with static 
 configuration, which is not the problem. The comments show that Romain 
 also doesn't have a solution for user-preference-based theming. 

 @Kostya: I know how to control the launch theme, the problem is doing 
 it dependent on user theme. If I misunderstood how the Chrome setup 
 might help, could you please let me know ? 

 Pent 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-01 Thread Pent
 I have a StartUp Activity, which, based on user preference, can start the
 app in various real activity.  So, I guess, I effectively disabled the
 preview screen, by doing this?

If animations are enabled in system prefs, you should get an animation
between the startup activity and the subactivity. Do you not ?

I couldn't disable that.

Intent.FLAG_ACTIVITY_NO_ANIMATION

in the intent to startActivity() is apparently just ignored.

Pent

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-01 Thread Pent
 Chrome (and Contacts) prevents its activity from being destroyed when he
 user presses Back (the normal code, in the framework, is to call finish
 then).

 If you did the same, the mismatched animation won't happen so often, since
 when resuming an existing activity, the system will animate its actual
 content.

Ah, that's what you meant. A small improvement I guess, but not very
satisfying somehow :-)

Thanks anyway!

Pent

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-01 Thread Pent
Progress! Don't know what I changed but managed to prevent the between
startup and main activity animation. So a startup activity works, but
only if there's a delay before
I call the main activity. Here's the code:

public class FrontDoor extends MyActivity {

@Override
public void onCreate( Bundle icicle ) {

super.onCreate( icicle );

MyFrameLayout v = new MyFrameLayout(this);

v.setLayoutParams( new
ViewGroup.LayoutParams( LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT ) );
setContentView( v );

v.setOnLayoutCallback( new MyFrameLayout.OnLayoutCallback() {
@Override
public void onLayout(int width, int height) {
new Handler() {
public void handleMessage( Message m ) {
 startActivity(
new Intent( FrontDoor.this, 
Tasker.class ).
setFlags( 
Intent.FLAG_ACTIVITY_NO_ANIMATION )
);
}
}.sendEmptyMessageDelayed( 0, 500 );
}
});
   }

(the theme-setting stuff is in MyActivity)

If there's no delay, the startup activity disappears immediately and
is not there while the main activity is loading. I put it in a layout
handler because that's the latest hook I can find into the activity
creation process so the time from there till the next activity is most
constant.

Anyone have a better hook where the activity has finished displaying
and I can safely start the sub-activity ? onResume() and
onPostResume() are not late enough.

Pent

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-02-01 Thread Kevin TeslaCoil Apps
For animations you can use
overridePendingTransition(0, 0); which I think is more reliable than the 
Intent flag.
http://developer.android.com/reference/android/app/Activity.html#overridePendingTransition(int,
 
int)
Do it right before the startActivity

As for when to start the activity you might have luck creating a handler 
and just posting a runnable to it in onCreate. I've done this in 
transparent activities to avoid a brief black screen.


On Friday, February 1, 2013 8:08:27 AM UTC-6, Pent wrote:

 Progress! Don't know what I changed but managed to prevent the between 
 startup and main activity animation. So a startup activity works, but 
 only if there's a delay before 
 I call the main activity. Here's the code: 

 public class FrontDoor extends MyActivity { 

 @Override 
 public void onCreate( Bundle icicle ) { 

 super.onCreate( icicle ); 

 MyFrameLayout v = new MyFrameLayout(this); 

 v.setLayoutParams( new 
 ViewGroup.LayoutParams( LayoutParams.FILL_PARENT, 
 LayoutParams.FILL_PARENT ) ); 
 setContentView( v ); 

 v.setOnLayoutCallback( new MyFrameLayout.OnLayoutCallback() { 
 @Override 
 public void onLayout(int width, int height) { 
 new Handler() { 
 public void handleMessage( Message 
 m ) { 
  startActivity( 
 new Intent( 
 FrontDoor.this, Tasker.class ). 
 setFlags( 
 Intent.FLAG_ACTIVITY_NO_ANIMATION ) 
 ); 
 } 
 }.sendEmptyMessageDelayed( 0, 500 ); 
 } 
 }); 
} 

 (the theme-setting stuff is in MyActivity) 

 If there's no delay, the startup activity disappears immediately and 
 is not there while the main activity is loading. I put it in a layout 
 handler because that's the latest hook I can find into the activity 
 creation process so the time from there till the next activity is most 
 constant. 

 Anyone have a better hook where the activity has finished displaying 
 and I can safely start the sub-activity ? onResume() and 
 onPostResume() are not late enough. 

 Pent 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-01-31 Thread Kostya Vasilyev
I see this in every app with theme switching, mine included.

My guess is that when Android performs an activity launch from nothing, 
it runs the launch animation using whatever theme is specified in the 
manifest, before any of the app's code is executed.

You can easily test this by setting a title for your activity in the 
manifest, and then setting a different one in your onCreate. You should see 
the title change (flash) after the animation completes.

It works differently in Chrome, where the launch animation has the recent 
sites tiles (Chrome does not have a light/dark theme, but we're talking 
about being able to control the launch animation).

I believe the reason for this is they handle the back key and use 
moveTaskToBackground rather than letting the activity get destroyed.

Again, easy to test: 1) kill Chrome in the app manager, relaunch, watch the 
first launch animation after that, it'll be just white without the recent 
sites tiles 2) press Back in Chrome, use adb shell dumpsys activity 
activities and you'll see the main Chrome activity in state=STOPPED, not 
destroyed.

And actually, it looks like it's not just Chrome DialtactsActivity.java 
(in Contacts):

@Override
public void onBackPressed() {
if (mInSearchUi) {
// We should let the user go back to usual screens with tabs.
exitSearchUi();
} else if (isTaskRoot()) {
// Instead of stopping, simply push this to the back of the 
stack.
// This is only done when running at the top of the stack;
// otherwise, we have been launched by someone else so need to
// allow the user to go back to the caller.
moveTaskToBack(false);
} else {
super.onBackPressed();
}
}

The tradeoff is of course a somewhat higher memory usage, and potentially 
emails from users asking why does your activity keep running, it's really 
affecting my battery and has been proven to cause baldness and insomnia.

-- K

On Thursday, January 31, 2013 8:35:32 PM UTC+4, Pent wrote:

 Tearing my hair out over this one. 

 I'm offering the user a choice of several dark or light themes. 
 Setting with getApplication().setTheme() and setTheme() in onCreate of 
 activity 
 (as the first thing in that function). 

 There's a period while the app loads when the screen goes black. If 
 you have a light desktop, it's very disconcerting (flashes). Of course 
 I could set a fixed white theme in the manifest, but then the inverse 
 problem occurs when user selects a dark theme. 

 Tried everything I can think of e.g. overrode Application, set in 
 Application:onCreate, created a FrontDoor activity that just sets the 
 theme then loads the relevant dedicated Light or Dark activity. 

 It appears Application:setTheme is completely ignored. 

 The current best solution I have is to set a manifest theme with a 
 grey background. Could create dedicated Dark and Light launcher icons, 
 but 

 Any tips ? 

 Pent 

 p.s. tried setting a transparent application theme in the manifest, 
 then you can get a huge delay while data loads. And if Android is 
 short of memory the user keeps seeing the desktop in-between 
 activities. 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-01-31 Thread Zsolt Vasvari
Funny  Here's a very recent article on this:

http://android.cyrilmottier.com/?p=873



On Friday, February 1, 2013 2:08:54 AM UTC+8, Kostya Vasilyev wrote:

 I see this in every app with theme switching, mine included.

 My guess is that when Android performs an activity launch from nothing, 
 it runs the launch animation using whatever theme is specified in the 
 manifest, before any of the app's code is executed.

 You can easily test this by setting a title for your activity in the 
 manifest, and then setting a different one in your onCreate. You should see 
 the title change (flash) after the animation completes.

 It works differently in Chrome, where the launch animation has the recent 
 sites tiles (Chrome does not have a light/dark theme, but we're talking 
 about being able to control the launch animation).

 I believe the reason for this is they handle the back key and use 
 moveTaskToBackground rather than letting the activity get destroyed.

 Again, easy to test: 1) kill Chrome in the app manager, relaunch, watch 
 the first launch animation after that, it'll be just white without the 
 recent sites tiles 2) press Back in Chrome, use adb shell dumpsys 
 activity activities and you'll see the main Chrome activity in 
 state=STOPPED, not destroyed.

 And actually, it looks like it's not just Chrome 
 DialtactsActivity.java (in Contacts):

 @Override
 public void onBackPressed() {
 if (mInSearchUi) {
 // We should let the user go back to usual screens with tabs.
 exitSearchUi();
 } else if (isTaskRoot()) {
 // Instead of stopping, simply push this to the back of the 
 stack.
 // This is only done when running at the top of the stack;
 // otherwise, we have been launched by someone else so need to
 // allow the user to go back to the caller.
 moveTaskToBack(false);
 } else {
 super.onBackPressed();
 }
 }

 The tradeoff is of course a somewhat higher memory usage, and potentially 
 emails from users asking why does your activity keep running, it's really 
 affecting my battery and has been proven to cause baldness and insomnia.

 -- K

 On Thursday, January 31, 2013 8:35:32 PM UTC+4, Pent wrote:

 Tearing my hair out over this one. 

 I'm offering the user a choice of several dark or light themes. 
 Setting with getApplication().setTheme() and setTheme() in onCreate of 
 activity 
 (as the first thing in that function). 

 There's a period while the app loads when the screen goes black. If 
 you have a light desktop, it's very disconcerting (flashes). Of course 
 I could set a fixed white theme in the manifest, but then the inverse 
 problem occurs when user selects a dark theme. 

 Tried everything I can think of e.g. overrode Application, set in 
 Application:onCreate, created a FrontDoor activity that just sets the 
 theme then loads the relevant dedicated Light or Dark activity. 

 It appears Application:setTheme is completely ignored. 

 The current best solution I have is to set a manifest theme with a 
 grey background. Could create dedicated Dark and Light launcher icons, 
 but 

 Any tips ? 

 Pent 

 p.s. tried setting a transparent application theme in the manifest, 
 then you can get a huge delay while data loads. And if Android is 
 short of memory the user keeps seeing the desktop in-between 
 activities. 



-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: Dynamic Application Theme

2013-01-31 Thread Pent
 http://android.cyrilmottier.com/?p=873

Good link, thanks. Unfortunately it only helps with static
configuration, which is not the problem. The comments show that Romain
also doesn't have a solution for user-preference-based theming.

@Kostya: I know how to control the launch theme, the problem is doing
it dependent on user theme. If I misunderstood how the Chrome setup
might help, could you please let me know ?

Pent

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.