-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
212 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Contributing to DuckDuckGo | ||
|
||
Thank you for taking the time to contribute to DuckDuckGo! :sparkles: | ||
|
||
We are pleased to open up the project to you - our community. How can you contribute? | ||
|
||
## Share feedback and bug reports | ||
See [README.md](README.md) | ||
|
||
## Contribute Code | ||
|
||
We have labeled tasks you can help with as [help wanted](https://github.com/duckduckgo/Android/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). | ||
As we are still opening up our repo, we cannot yet accept PRs outside this list. If you have a great idea | ||
you really want to implement, start by logging an issue for us and mention that you are interested in helping. | ||
If it fits with our product direction and is a good candidate for community development we may be able to bend | ||
the rules and work with you to develop it. | ||
|
||
## Style Guide | ||
|
||
We care about clean code. Refer to our [style guide](styleguide/STYLEGUIDE.md). | ||
|
||
|
||
## Commit Messages | ||
|
||
See Chris Beams' guide to writing good commit messages https://chris.beams.io/posts/git-commit/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
# DuckDuckGo Android | ||
|
||
Welcome to our android application. While it is still too early to accept contributions, we are excited to engage the community in development and will open up this project to contributions in the future. | ||
Welcome to our android application. We are excited to engage the community in development, see [CONTRIBUTING.md](CONTRIBUTING.md). | ||
|
||
If you are trying to contribute in other ways, that happens over at [DuckDuckHack](http://duckduckhack.com) or on [GitHub](http://github.com/duckduckgo). | ||
|
||
## Discuss | ||
|
||
Contact us at [email protected] if you want to get more involved, have questions or want to chat. | ||
Contact us at [email protected] if you have questions, feedback or want to chat. | ||
|
||
## Reporting Bugs | ||
|
||
We want our app to be as stable as possible thus your bug reports are immensely valuable. When reporting bugs let us know the: | ||
* App version | ||
* Device make and model | ||
* Android version | ||
* Steps to reproduce the bug | ||
* Expected behavior | ||
* Actual behavior | ||
|
||
Email bug reports to [email protected] | ||
|
||
|
||
## License | ||
DuckDuckGo android is distributed under the Apache 2.0 [license](https://github.com/duckduckgo/ios/blob/master/LICENSE). | ||
DuckDuckGo android is distributed under the Apache 2.0 [license](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/duckduckgo/app/tabs/ui/TabIconRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2018 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.app.tabs.ui | ||
|
||
import android.content.Context | ||
import android.graphics.* | ||
import android.graphics.drawable.Drawable | ||
import android.support.v4.content.ContextCompat | ||
import androidx.graphics.drawable.toBitmap | ||
import androidx.graphics.drawable.toDrawable | ||
import com.duckduckgo.app.browser.R | ||
|
||
class TabIconRenderer { | ||
|
||
companion object { | ||
|
||
fun icon(context: Context, count: Int): Drawable { | ||
val text = if (count < 100) "$count" else "~" | ||
return makeDrawable(context, text) | ||
} | ||
|
||
private fun makeDrawable(context: Context, text: String): Drawable { | ||
val drawable = context.getDrawable(R.drawable.ic_tabs_gray_24dp) | ||
val bitmap = drawable.toBitmap().copy(Bitmap.Config.ARGB_8888, true) | ||
val paint = createPaint(context) | ||
val bounds = Rect() | ||
paint.getTextBounds(text, 0, text.length, bounds) | ||
|
||
val canvas = Canvas(bitmap) | ||
val x = (bitmap.width / 2f) - bounds.centerX() - xOffset(context) | ||
val y = (bitmap.height / 2f) - bounds.centerY() + yOffset(context) | ||
canvas.drawText(text, x, y, paint) | ||
return bitmap.toDrawable(context.resources) | ||
} | ||
|
||
private fun createPaint(context: Context): Paint { | ||
val paint = Paint() | ||
paint.apply { | ||
color = ContextCompat.getColor(context, R.color.colorPrimary) | ||
style = Paint.Style.FILL | ||
textSize = context.resources.getDimensionPixelSize(R.dimen.tabIconTextSize).toFloat() | ||
isAntiAlias = true | ||
typeface = Typeface.DEFAULT_BOLD | ||
} | ||
return paint | ||
} | ||
|
||
private fun xOffset(context: Context): Int { | ||
return context.resources.getDimensionPixelSize(R.dimen.tabIconXOffset) | ||
} | ||
|
||
private fun yOffset(context: Context): Int { | ||
return context.resources.getDimensionPixelSize(R.dimen.tabIconYOffset) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.