-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-16436] Integrate appcompat themes to SDK #5348
Changes from all commits
bbf23c5
0bf19dd
3b5881b
e4c4c84
4e8d5bc
8619d48
2c06b05
13c36f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="Theme.Titanium" parent="android:<%- flags %>"> | ||
<style name="Theme.AppCompat.NoTitleBar"> | ||
<item name="android:windowNoTitle">true</item> | ||
</style> | ||
|
||
<style name="Theme.AppCompat.NoTitleBar.Fullscreen"> | ||
<item name="android:windowFullscreen">true</item> | ||
<item name="android:windowContentOverlay">@null</item> | ||
</style> | ||
|
||
<style name="Theme.Titanium" parent="@style/<%- flags %>"> | ||
<item name="android:windowBackground">@drawable/background</item> | ||
<item name="android:windowActionBar">false</item> | ||
</style> | ||
|
||
<style name="Theme.AppCompat.Translucent"> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<item name="android:colorBackgroundCacheHint">@null</item> | ||
<item name="android:windowIsTranslucent">true</item> | ||
<item name="android:actionBarStyle">@style/Widget.AppCompat.Base.ActionBar.Solid</item> | ||
<!-- AppCompat Compatibility --> | ||
<item name="actionBarStyle">@style/Widget.AppCompat.Base.ActionBar.Solid</item> | ||
</style> | ||
|
||
<style name="Theme.AppCompat.Translucent.NoTitleBar"> | ||
<item name="android:windowNoTitle">true</item> | ||
<item name="android:windowContentOverlay">@null</item> | ||
</style> | ||
|
||
<style name="Theme.AppCompat.Translucent.NoTitleBar.Fullscreen"> | ||
<item name="android:windowFullscreen">true</item> | ||
</style> | ||
</resources> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
import org.appcelerator.titanium.util.TiActivitySupport; | ||
import org.appcelerator.titanium.util.TiActivitySupportHelper; | ||
|
||
import android.support.v7.app.ActionBarActivity; | ||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
|
@@ -245,11 +246,10 @@ public TiWindowProxy getWindow() | |
@Kroll.method @Kroll.getProperty | ||
public ActionBarProxy getActionBar() | ||
{ | ||
Activity activity = getWrappedActivity(); | ||
if (actionBarProxy == null && activity != null && Build.VERSION.SDK_INT >= TiC.API_LEVEL_HONEYCOMB) { | ||
ActionBarActivity activity = (ActionBarActivity) getWrappedActivity(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to cast this one to an ActionBarActivity ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, getWrappedActivity() returns type Activity. We only cast to ActionBarActivity when an action bar is involved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh also because ActionBarProxy constructor requires type ActionBarActivity |
||
if (actionBarProxy == null && activity != null) { | ||
actionBarProxy = new ActionBarProxy(activity); | ||
} | ||
|
||
return actionBarProxy; | ||
} | ||
|
||
|
@@ -266,12 +266,10 @@ public void openOptionsMenu() | |
@Kroll.method | ||
public void invalidateOptionsMenu() | ||
{ | ||
if (Build.VERSION.SDK_INT >= TiC.API_LEVEL_HONEYCOMB) { | ||
if (TiApplication.isUIThread()) { | ||
if (TiApplication.isUIThread()) { | ||
handleInvalidateOptionsMenu(); | ||
} else { | ||
} else { | ||
getMainHandler().obtainMessage(MSG_INVALIDATE_OPTIONS_MENU).sendToTarget(); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -286,8 +284,8 @@ private void handleOpenOptionsMenu() | |
private void handleInvalidateOptionsMenu() | ||
{ | ||
Activity activity = getWrappedActivity(); | ||
if (activity != null) { | ||
activity.invalidateOptionsMenu(); | ||
if (activity != null && activity instanceof ActionBarActivity) { | ||
((ActionBarActivity)activity).supportInvalidateOptionsMenu(); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of applying theme to the application I would instead apply theme to TiActivity.
That way any modules that have their own activities that do not extend TiBaseActivity will continue to work as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme to application includes all sub activities that don't have a theme set, so TiActivity will be using the theme set for application as well... It's a good default to have, i.e even new activities from modules will use the application theme as default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we decide to apply the theme to TiActivity, we will also need to do it for activities like JSActivity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested and confirmed that AppCompat theme works with non-actionbar activities (i.e activites that do not extend TiBaseActivity), so we should be fine using it as a default theme.