Custom Navigation Bar across application - java

I'm interested in an app that customizes the Android NavigationBar across all my applications. The same way that, i.e. NavBar Apps does it.
This far, I found two possibilities, but it doesn't fit exactly what I'm looking for:
SystemBarTint library (here)
It only works if you set your app to translucent, and display a background "tint" behind the NavigationBar.
setNavigationBarColor(int color) (here)
You can only use a color (and not a drawable) for the NavigationBar.
I want do an app that is always running and can set a drawable instead of the black color of the NavigationBar

I found out a way to customize the NavigationBar in (almost) all apps. (following this)
Using this permission:
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Then I created a Service that calls:
WindowManager.addView(View v, LayoutParams p)
And my MainActivity starts this Service.

You cannot change the status/navigation bars color on all apps unless you are a rooted user and your custom rom / custom launcher supports this.
You can only change this inside you own application with any of the links you provided. But this will not extend to the rest of the device apps.
If the case is inside your own app you can do this by using setNavigationBarColor for the nacigation bar and the material design library for the status bar (set the secondaryColor on the material design.

Related

How to make side menu using browse fragment like netflix in android tv?

Attached screenshot of netflix app with left side menu I am able to develop a side menu with customized icon and header in it. I want, when the focus comes on header fragment it should expand on top of row fragment, that is not collapsing the row fragment, the same as Netflix and hotstar are doing. How can I achieve it?
unfortunately, the HeaderSupportFragment used in the BrowseSupportFragment is not configurable enough to achieve this kind of design. Leanback is great to build quickly and easily media browser app but when it comes to "complex" design, it's easier to use custom component.
The major difference also here, is that the left menu of the BrowseSupportFragment show each rows header name displayed in the screen (that's why it's called HeaderSupportFragment). Here you want to show different entries like search, home, settings, etc.
To make this kind of view, I would suggest creating your own custom view and use a basic Fragment. I followed this tutorial which can be useful to handle menu open/close animation (I mixed it with a ConstraintLayout to simplify the animation and I made the menu overlap the rest of the screen instead of moving everything.)
See the tutorial: https://medium.com/building-for-android-tv/building-for-android-tv-episode-3-381e041dfec7

Card.io custom keyboard, manual entry screen, screen after scan

Since using Card.io for credit card scanning,
I had to face with some limitations and looking for alternative solutions.
The issues;
1- Is there any way to customize 'KEYBOARD' button on scanning screen?
2- Is there a way to start my own view after clicking on 'KEYBOARD' button?
3- Is there any way to start my own view after scanning the card for entering expiration date, cvv, card holder name?
It doesn't look like the Card.io library provides any way to modify the text of that button.
It doesn't look like they provide any way to hook your own logic into the button either.
On iOS, it's possible to use the CardIOView class to integrate a card scanning component into your own view which would allow you to implement whatever flow you'd like... but on Android, there doesn't seem to be an equivalent to that class.
It seems like the Card.io library is rather limited on Android, but I haven't yet been able to find any viable alternatives that support both iOS and Android.

Transparent Status Bar Android 4.3

In the 'new' Android Version 4.3 there is a new feature. The status Bar on the top of the screen is transparent in the launcher (I'm using Samsung TouchWiz on Galaxy S3) and in some other Apps too I think (looks a little bit like the iOS 7 style).
Can you tell me how I can make the Status Bar transparent (or colored) in my own App (Eclipse, Java)?
Theme.Holo.NoActionBar.TranslucentDecor
Theme.Holo.Light.NoActionBar.TranslucentDecor
Based on the best answer here: How to make the navigation bar transparent
I'm not sure about the transparency but as of API 10 you can set a background drawable for the actionBar. (and thus a color)
In the following codesnippet I get a color based on an attribute (depending on the theme chosen)
TypedArray a = getTheme().obtainStyledAttributes(new int[]{R.attr.background_activity_color});
actionBar.setBackgroundDrawable(a.getDrawable(0));

How to change app theme from ordinary "Blank Activity" to "Master/Detail Flow"

I have an application that works on the basic theme "Blank Activity" and what i would like to do is to change it to a "Master/Detail Flow" theme. I do know that this will make my application work on android SDK 11 + (android 3.0 Honeycomb +), that is OK with me. The issue is i don't know where to start from, what are the basic steps to make this BIG conversion? I couldn't find any example to help me out with this issue. What should i be looking for. i am sure this has been done, can you at least please give me some pointer on how to do this?
my Application is not that complicated it uses activities, async tasks, DB, custom lists,... it is very basic. I use the custom list to display data and when i click on it it displays much more details, so I thought what better way to do this in a more professorial matter than the "Master/Detail Flow". If you have any tutorial regarding the "Master/Detail Flow" that you can hook me up with that might help.
I have an application that works on the basic theme "Blank Activity"
and what i would like to do is to change it to a Master/Detail Flow"
theme.
I think a change of the application flow would be more appropriate then a change of theme. Two obvious questions that would appear are why do you suddenly want to make this change and are sure your app makes sense in a master/detail flow? The answer would most likely be positive but you should answer them nonetheless.
I do know that this will make my application work on android SDK 11 +
(android 3.0 Honeycomb +), that is OK with me
I don't see why you're app couldn't run on versions below with the new master/detail stuff.
The issue is i don't know where to start from, what are the basic
steps to make this BIG conversion? I couldn't find any example to help
me out with this issue. What should i be looking for. i am sure this
has been done, can you at least please give me some pointer on how to
do this?
You haven't provided details about how is your app implemented. The change would revolve around fragments so a BIG question would be if the current single pane version is built using the fragments framework.
If your app is built using fragments then making the change shouldn't be too hard. You'd need to:
establish which parts(fragments) should be combined in an activity(from your old ones) to make the master/detail(when the space would allow it)
change the multi pane activity to accommodate the new fragment(s). This should be easy to do but it would depend on the size of the features exposed by each of those fragments.
modify the rest of the activities(for when the app will not run in the multi pane mode), this would be small changes as the activities would mainly remain as the current version
If your app isn't built using fragments, then what I said above still applies but you'd need to also actually make the required fragments wrapping whatever functionality your app has. This would most likely result in a big code refactoring.
Here is a tutorial about the Master/Detail template in Android - An Android Master/Detail Flow Tutorial.
As far as I understand your application is up and running - so I'm not sure whether it is worth it to try rewriting it, unless you are experiencing some problems of course. :)
In general the master/details flow requires the following steps:
Implement a ListFragment showing basic information of your items
Implement a Fragment showing detailed information about a particular item
Make an xml layout file for large devices (located in layout-sw600dp folder for example). In this layout you have to put both your fragments.
Write a general version of this layout file (i.e. file with the same name but located in the layout folder), which contains only the ListFragment.
Let your activity handle onItemClick event from the ListFragment. Each time an item is clicked, you have to check if the activity is showing both fragments or only the ListFragment. If both are visible, you have to notify the details fragment that new item is selected so it can show its data. Otherwise you have to create new details fragment (you reuse it of course), pass it some information about the selected item (so it can show the item's data) and replace the ListFragment with the new one.
That a basic overview, but it should be enough to give you some idea about this flow. If you need any more details - just let me know. :)
Master/detail flow and blank activity is not same as you want to change by only changing app theme or app base theme. It will be better, if you first design master/detail flow template using UI fragments, then according integrate you blank activity with the master template making necessary changes. And for master/detail flow tutorial just google it, you will find lots of example there.
Here are some links from developer.android.com fragment-ui and adaptui
These are some guidelines about fragments but they are told using a master/Detail app.
Also dont forget to checkout the news reader app provided as sample in the second link.
If you have a recent version of the Android SDK, you should be able to create a new Android application and during that process you can elect to have the wizard create a Master/Detail Flow app for you. It will create a basic working app so that you can look through the code and understand the necessary parts.
Then, depending on how simple your app is, you may want to move all your present code to the new application or vise versa.
Macro changes that will happen:
Change all your current Activities to extend Fragment instead.
You will have to create a FragmentActivity to call your Fragments. This will basically be the boilerplate code, with just the names of your Fragments added to it.
Don't forget to double check your Manifest!
In your converted Fragments that previously extended Activity:
Everywhere you needed a Context, switch that with getActivty() (or create a global variable so that it is only called once)
Change onCreate() to
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_signals, container, false);
setHasOptionsMenu(true); // Add if you want to display a Menu
// Your initiation code here
return mView;
}
If you have a menu, change it to
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.activity_main, menu);
super.onCreateOptionsMenu(menu, inflater);
}
And that's it for basic applications. When you first change Activities to Fragments, there will be many errors. But, they are all easy to fix.

How do you make custom widgets?

When using developing Widgets for Android it seems you are not able to add your own custom View classes to a AppWidgetProvider.
For example I created a custom class which extends View, this works fine when used within an Activity but the moment I add it to a Widget I get a "ClassNotFoundException" because Android seems to only allow a set of certain system widgets to be added.
I have seen some apps which look like they have made there own custom widgets. For example there is one that brings up a radial menu when clicked which shows application shortcuts. How are these being implemented? Is there a work around to using my own custom widget? They seem to have a canvas which they are able to draw on within the widget.
Okay quick example https://market.android.com/details?id=zombiesinthelab.widgets.droidpetwidget&feature=top-paid
So this widget is being done by just drawing ImageViews and updating them periodically opposed to using a canvas to draw the frames?
Android Widgets can only contain Layout-Widgets supported by RemoteViews. See this list:
A RemoteViews object (and,
consequently, an App Widget) can
support the following layout classes:
FrameLayout
LinearLayout
RelativeLayout
And the following widget classes:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
> Descendants of these classes are not
supported.
Pay attention to the last sentence. You can not change this behaviour, it is hard coded in android.
I have not much idea on how to create widgets but following links can definitely help you:
1) http://developer.android.com/guide/topics/appwidgets/index.html
2) http://developer.android.com/guide/practices/ui_guidelines/widget_design.html

Categories