Custom Android Theme for Titanium (no ActionBar, custom splashscreen) - android-actionbar

im using Titanium SDK 3.3.0 and want to disable the "new" ActionBar in Android with the theme solution.
Besides a want to use a 9-Patch-Image as splashscreen/loadingscreen.
Referring to the docs and guides:
http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Action_Bar
http://docs.appcelerator.com/titanium/3.0/#!/guide/Android_Themes
I have the following Project-Setup:
files for splashscreens:
/platform/android/res/drawable-ldpi/splash.9.png
/platform/android/res/drawable-mdpi/splash.9.png
/platform/android/res/drawable-hdpi/splash.9.png
/platform/android/res/drawable-xhdpi/splash.9.png
theme file: /platform/android/res/values/gsgptheme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.GSGP" parent="Theme.AppCompat">
<!-- Depending on the parent theme, this may be called android:windowActionBar instead of windowActionBar -->
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>
tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:installLocation="auto"
android:versionCode="21" android:versionName="3.1.1">
<application android:theme="#style/Theme.GSGP"/>
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14"/>
<supports-screens android:anyDensity="false"/>
</manifest>
</android>
The Problem is: Titanium doesn't seem to load my theme. On startup I see the default loadingscreen and still have an actionbar. Can anyone see my mistake?

Need to add something similar to the following in your tiapp.xml file under the android application node. Replace "YourApp" in .YourAppActivity with whatever your app name is.
<activity android:name=".YourAppActivity" android:label="#string/app_name" android:theme="#style/Theme.GSGP" android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

Related

Nativescript-vue: how to change datepicker color?

In my setting page, a Settings.vue file I've my DatePicker
<template>
<Page>
<DatePicker/>
</Page>
</template>
I need to change the default style.
Note: actually I'm working specifically on Android, but please, answer keeping in mind I need the same colors on both Android and iOs; thanks,
I tried (in app.scss file
Datepicker {
color: white;
}
Without success, as you can see my android emulator is using a near-black color.
Following this guide, I changed colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ns_primary">#577eac</color>
<color name="ns_primaryDark">#577eac</color>
<color name="ns_accent">#ffffff</color>
<color name="ns_blue">#272734</color>
</resources>
Then I changed styles.xml
<style name="AppTheme" parent="AppThemeBase">
<item name="android:datePickerStyle">#style/SpinnerDatePicker</item>
</style>
<style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:datePickerMode">spinner</item>
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
</style>
Note: I specified I want the spinner, but it's actually the default, I think.
I did a clean run
tns debug --hmr --clean
The problem: actually, the android DatePicker is still rendered using default colors, no my primary or accent colors as defined.
Similar question:
Nativescript Datepicker change text color - Uses the same solution, so it's useless for me because this solution doesn't works (for me, actually)

Android RatingBar numStart not working

I have simple RatingBar in my app. and i set numStarts="5" but it show more then 5 star. when i set android:layout_width="match_parent" I tried to several tutorials but also did't work, as per doc numStarts for show number of starts but in my case it did't work. i go through doc and several tutorials but did't get any solution.
but i want to only 5 stars in rating bar.
my rating bar is given below.
<RatingBar
style="#style/customRatingBar"
android:id="#+id/course_rating_bar"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_marginRight="16dp"
android:layout_marginLeft="16dp"
android:numStars="5"
android:isIndicator="false"
android:stepSize="1.0"/>
This is my custom style
<style name="foodRatingBar" parent="#android:style/Widget.RatingBar">
<item name="android:progressDrawable">#drawable/ratingstars</item>
<item name="android:minHeight">22dip</item>
<item name="android:maxHeight">22dip</item>
</style>
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+android:id/background"
android:drawable="#drawable/star_empty" />
<item android:id="#+android:id/secondaryProgress"
android:drawable="#drawable/star_empty" />
<item android:id="#+android:id/progress"
android:drawable="#drawable/star" />
</layer-list>
You have to set android:layout_width="wrap_content" rather than "match_parent". Then you will get the 5 stars.

ActionBar logo not showing

i have declared the logo in the manifest file like this :
android:allowBackup="true"
android:logo="#drawable/ic_launcher"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/CustomActionBarTheme"
and the custom theme is like this :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">#drawable/actionbar_background</item>
<item name="android:icon">#drawable/ic_launcher</item>
<!-- Support library compatibility -->
<item name="background">#drawable/actionbar_background</item>
<item name="icon">#drawable/ic_launcher</item>
</style>
</resources>
but the logo is not showing in the actionbar, i have tried many ways but not working, can anybody pls help me ?
With the new appcompat 21, the pattern is changed.
The Action Bar follows the material design guidelines and uses a Toolbar.
As you can read here:
The use of application icon plus title as a standard layout is
discouraged on API 21 devices and newer.
If you would like an application icon, you can use the method setLogo().
You should read this official post.

Glass XE17.1 - Custom voice commands broken?

I have followed the exact steps from the official documentation, but I still cannot get my app to start using the custom voice command. The steps are followed are:
1 Add new string resource for custom voice command in strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Hello World!</string>
<string name="glass_voice_trigger">start example</string>
</resources>
2 Create a new XML file for voice startup definition:
<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="#string/glass_voice_trigger" />
3 Request proper permissions in AndroidManifest.xml:
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
4 The manifest part looks as follows:
<service
android:name="pl.infoshare.sample.helloworld.HelloWorldService"
android:icon="#drawable/ic_lap"
android:label="#string/app_name"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger_start" />
</service>
Still, I am not able to start the app using the voice command. If I change to one of the predefined voice commands the app shows up on the timeline and I can start it using the voice command. Did I miss anything?
Looking through the question, I didn't see anything jump out at me as incorrect. So, I created a small sample GDK project that is launched with a custom voice command, and runs just fine on my XE17.1 device. (Bonus, it demos a low-frequency LiveCard!)
Try pulling down my sample from GitHub, and see if you can launch it with the command:
'OK Glass, start my awesome app'
Below are some of the relevant bits.
AndroidManifest.xml:
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:immersive="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service
android:name=".LowFreqLiveCardService"
android:enabled="true"
android:exported="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<intent-filter>
<action android:name=
"com.google.android.glass.action.VOICE_TRIGGER"/>
</intent-filter>
<meta-data android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger"/>
</service>
</application>
</manifest>
res/xml/voice_trigger.xml:
<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="#string/custom_keyword" />
res/values/strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Low Freq Demo</string>
<string name="heart_rate">Heart Rate</string>
<string name="custom_keyword">start my awesome app</string>
</resources>
Here's a link to the voice command documentation, it still provides instructions on using custom voice commands. And, from my testing, they still do work.
Custom voice commands require, since a couple of versions ago, the aproval from google. You can send a request for that aproval from the glass developer site.
Review this.

Google Glass: Card not being displayed

Need help to display a sample card in the glass timeline(refer image). All i need is to launch the card when one taps when "ok glass" is displayed and scroll to view the card(image 2), the same via voice command also does not work.
I tried launching the same activity via adb shell it works perfectly fine, also i added an intent filter with MAIN/LAUNCHER category to the activity - it runs. I referred this link for this POC but nothing like the image is being displayed. Please help as to where am i going wrong - TIA
Activity:
package de.androidzeitgeist.glass.helloworld.immersion;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.glass.app.Card;
public class HelloWorldActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Card card = new Card(this);
card.setText("Hello world!");
card.setFootnote("android.com");
setContentView(cardroid.getView());
}
}
Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.androidzeitgeist.glass.helloworld.immersion"
android:versionCode="1"
android:versionName="1.0" >
<application
android:allowBackup="true"
android:icon="#drawable/helloworld_icon"
android:label="#string/app_name" >
<activity
android:name="de.androidzeitgeist.glass.helloworld.immersion.HelloWorldActivity"
android:icon="#drawable/helloworld_icon"
android:label="#string/app_name" >
<intent-filter>
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
</intent-filter>
<meta-data
android:name="com.google.android.glass.VoiceTrigger"
android:resource="#xml/voice_trigger" />
</activity>
</application>
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
</manifest>
voice_trigger.xml
<?xml version="1.0" encoding="utf-8"?>
<trigger keyword="#string/show_hello_word" />
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloWorldImmersion</string>
<string name="hello_world"></string>
<string name="show_hello_word">show hello world</string>
</resources>
If you are using an unregistered voice command, your manifest.xml must include
<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" />
See https://developers.google.com/glass/develop/gdk/starting-glassware for more details about using registered commands and unlisted commands and Why is my voice command missing from the ok glass menu in XE16? for some clarification and examples.