Skip to content
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

How to use a single library, just for "Material-Design" ? #2

Closed
AndroidDeveloperLB opened this issue Oct 24, 2014 · 23 comments
Closed

Comments

@AndroidDeveloperLB
Copy link

Since I am willing to use only the material design, is it possible to avoid using the rest of the files (of Holo) ?
Is it possible for me to merge the 2 libraries, and use a single one?
If so, please show all the steps I need to perform.

@fengdai
Copy link
Owner

fengdai commented Oct 24, 2014

  1. Delete all the Holo drawables and layouts and copy all Material drawables and layouts.

  2. Change the defValues to Material's. In AlertController.java, the constructor method, replace some lines with below code:

     mAlertDialogLayout = a.getResourceId(R.styleable.AlertDialogProStyle_adpLayout,
            R.layout.alert_dialog_material);
     mListLayout = a.getResourceId(
            R.styleable.AlertDialogProStyle_adpListLayout,
            R.layout.select_dialog_material)
     mMultiChoiceItemLayout = a.getResourceId(
            R.styleable.AlertDialogProStyle_adpMultiChoiceItemLayout,
            R.layout.select_dialog_multichoice_material);
     mSingleChoiceItemLayout = a.getResourceId(
            R.styleable.AlertDialogProStyle_adpSingleChoiceItemLayout,
            R.layout.select_dialog_singlechoice_material)
     mListItemLayout = a.getResourceId(R.styleable.AlertDialogProStyle_adpListItemLayout,
            R.layout.select_dialog_item_material);
    
  3. Delete all styles and theme contain "Holo" in the styles.xml and themes.xml, and copy the Material styles and themes to them.

  4. Replace colors.xml and dimens.xml directly.

  5. Since you delete the holo theme. The demo module which use the holo theme will build fail. You should also delete the related code in it.

There may be other things to do, you can have a try first.

@AndroidDeveloperLB
Copy link
Author

What do you mean by "replace the holo resources" ? copy the new files of the material library to the new one (overriding them when possible), or should I delete the whole content of the holo library and then copy?

EDIT: both caused errors.
I think I need to perform careful merging of them.

@fengdai
Copy link
Owner

fengdai commented Oct 24, 2014

You should't delete the whole content of the holo lib. It contains the core codes of the project. Only the resource files and a little code should be modified.
I have updated my answer.

@AndroidDeveloperLB
Copy link
Author

I'm have issues even after I've carefully removed and merged the files as you've written.
Here's the current library:
https://drive.google.com/file/d/0B-PZZGk2vPohQzdxenBfUE44czA

In my app (link here, BTW: https://play.google.com/store/apps/details?id=com.lb.app_manager ) , even though it seems to compile fine, for some reason I can't use it, as it tells me :
java.lang.NoClassDefFoundError: com.alertdialogpro.AlertDialogPro$Builder

Using the demo of the library, for some reason it can't import the library at all:
style cannot be resolved or is not a field

Could it be an SDK bug?

@fengdai
Copy link
Owner

fengdai commented Oct 24, 2014

Can't open the link: https://drive.google.com/file/d/0B-PZZGk2vPohQzdxenBfUE44czA
I'm in China. Sad story.

@AndroidDeveloperLB
Copy link
Author

try again.

@AndroidDeveloperLB
Copy link
Author

Anyway, since I have too many issues, I've decided to avoid using the material library, but since the other one works, I decided to use it instead.

@fengdai
Copy link
Owner

fengdai commented Oct 25, 2014

I have downloaded your project and fixed it. Please follow the steps below:

  1. Delete the android-support-v4 lib in your demo module.

  2. In demo module, the styles.xml file should be like this:

      <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"></style>
    
      <!-- Application theme. -->
      <style name="AppTheme" parent="AppBaseTheme">
          <item name="alertDialogProTheme">@style/AppTheme.AlertDialogProTheme</item>
      </style>
    
      <style name="AppTheme.AlertDialogProTheme" parent=“AlertDialogProTheme.Material”></style>
    
  3. In demo module’s AndroidManifest.xml, use the AppTheme style as the application’s theme.

  4. In alertdialogpro module’s layout/alert_dialog_material.xml file, change the custom view FrameLayout’s id from @+android:id/custom to @+id/custom. This is my mistake. And I have fixed it in the master.

Then it will work.

@AndroidDeveloperLB
Copy link
Author

After re-installing the SDK, and following what you've written, it worked.
I wonder why it had SDK problems, while other projects didn't..

Also, did you remember to change the id as you've written?

@fengdai
Copy link
Owner

fengdai commented Oct 26, 2014

I tried to build it both in Android Studio and Eclipse. No exception occurred. I think it doesn't have "SDK problems".

Also, did you remember to change the id as you've written?

Yes.

@AndroidDeveloperLB
Copy link
Author

Now that I think about it, seeing that you have ported the code directly from Android, I think you could have just used the original IDs of Android, and not create your own.

@fengdai
Copy link
Owner

fengdai commented Oct 26, 2014

Not all the IDs of Android are public. I think it's better to create my own IDs.

@AndroidDeveloperLB
Copy link
Author

Oh, I see. Ok. Thanks.

On Sun, Oct 26, 2014 at 10:31 AM, Feng Dai notifications@github.com wrote:

Not all the IDs of Android are public. I think it's better to create my
own IDs.


Reply to this email directly or view it on GitHub
#2 (comment)
.

fengdai added a commit that referenced this issue Oct 30, 2014
@fengdai
Copy link
Owner

fengdai commented Oct 30, 2014

I have separated holo theme resources and code from the core project.

@AndroidDeveloperLB
Copy link
Author

@fengdai what does it mean?

@fengdai
Copy link
Owner

fengdai commented Oct 30, 2014

The holo theme files have been moved to a individual module: alertdialogpro-theme-holo. Anyone who want material theme but don't want to contain the holo files can use "alertdialogpro-core + alertdialogpro-theme-material".

@AndroidDeveloperLB
Copy link
Author

@fengdai I see, so you won't end up with unused resources inside the app, just what you want to use.
Good.
Say, have you found out how come the dialog text color doesn't quite look like on Android Lollipop?

@fengdai
Copy link
Owner

fengdai commented Nov 2, 2014

I developed the material theme base on the “preview” L code sometimes ago. It seems that Google made some changes when launched 5.0. I'm trying to let it match the official version's style.

@AndroidDeveloperLB
Copy link
Author

Nice. Thank you for your efforts.
Where exactly do you look at ? in the SDK folder ?

On Sun, Nov 2, 2014 at 12:05 PM, Feng Dai notifications@github.com wrote:

I developed the material theme base on the “preview” L code sometimes ago.
It seems that Google made some changes when launched official 5.0. I'm
trying to let it match the official version's style.


Reply to this email directly or view it on GitHub
#2 (comment)
.

@fengdai
Copy link
Owner

fengdai commented Nov 2, 2014

I use Android Studio, and let my project target SDK 21. Then, I can search and look at the lollipop's source code in Android Studio.

@AndroidDeveloperLB
Copy link
Author

How do you do it from withing Android Studio? is there a button for it?
I thought you can just go to the folder of the SDK, as you can download the sources from the SDK-Manager...

@fengdai
Copy link
Owner

fengdai commented Nov 3, 2014

I just downloaded the sources from the SDK Manager. Android Studio attached the sources automatically. Looks like this:

f5326796-733f-49a7-add8-cfdeadc8a6ba

@AndroidDeveloperLB
Copy link
Author

Wow cool. So you can perform a full search on the jar file,to find the function/class you wish to check out, for example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants