From 0f870f1b29e196fcef380808e58b2c1b642c662f Mon Sep 17 00:00:00 2001 From: Igor Popov Date: Thu, 15 Jun 2017 18:40:28 +0300 Subject: [PATCH 01/11] Improved translation. --- app/src/main/res/values-ru/strings.xml | 35 +++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 1d4cc2928..f7e8a0420 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -13,7 +13,7 @@ Войти Поделиться Обновить - Обвноления + Обновления Профиль Ошибка Нажмите ещё раз для выхода @@ -44,13 +44,13 @@ Подробности Обнаружен файл архива. Пожалуйста, скачайте этот файл, чтобы посмотреть его содержимое. Минимум 3 символа - Файлы не найдены - README не найден + Файлы отсутствуют + README отсутствует Скачивание… Скачивание файла… - выпустил - Черновые - Релизы + выпустил(а) + запланировал(а) + Сборки Содержимое отсутствует Вкладчики Вклады @@ -122,7 +122,7 @@ Очистить Пользователи Название - Тег + Цель Назначить себя Опубликовать Вопрос Ошибка создания Вопроса @@ -148,11 +148,11 @@ Описание Gist\'а Вы можете везде нажать на аватар пользователя, чтобы открыть его профиль Долгое нажатие на событие ответвления позволяет открыть орининальный или клонированный репозиторий. - Скачать релизы + Скачать сборки Опции Скачать файл или поделиться папкой - Нажатие на комментарий помечает его автора или изменяет его, если комментарий ваш. - \nДолгое нажатие на ваш комментарий удаляет его. + Нажатие на комментарий добавляет его автора к ответу или изменяет его, если комментарий ваш. + \nДлительное нажатие на ваш комментарий удаляет его. Добавить в Избранное/Удалить из Избранного Следить Следить/перестать следить за репозиторием @@ -199,12 +199,12 @@ \u2022 изменено Обновить Вопрос Обновить Запрос на слияние - Теги отсутствуют + Цели отсутствуют Добавить Завершено Начальный экран - Создать тег - Ошибка создания тега + Создать цель + Ошибка создания цели Due on Нет назначений этот @@ -280,7 +280,7 @@ Избранные репозитории отсутствуют Фиксации отсутствуют Вкладчики отсутствуют - Релизы отсутствуют + Сборки отсутствуют Закрытые Вопросы отсутствуют Открытые Вопросы отсутствуют События отсутствуют @@ -315,7 +315,7 @@ Анимации Включить всплывающие анимации Всплывающая анимация - Теги + Цели Назначенные Одна или несколько проверок не пройдены Ожидаются результаты проверок @@ -389,7 +389,7 @@ Элемент списка TODO с галочкой Элемент списка TODO без галочки Разделитель - Пользователи не найдены + Пользователи отсутствуют Тренды отсутствуют Сброс Применить @@ -398,6 +398,7 @@ Порядок сортировки Назначение успешно совершено Рецензент успешно добавлен - Тег успешно добавлен + Цель успешно добавлена Обновления + Премиальная тема оформления \ No newline at end of file From 8b7b0a3f0d856bbb7773d36ad79e53175da0307c Mon Sep 17 00:00:00 2001 From: Caio Roberto Date: Fri, 16 Jun 2017 11:32:56 -0300 Subject: [PATCH 02/11] Translation to Brazilian Portuguese --- app/src/main/res/values-pt-rBR/strings.xml | 483 +++++++++++++++++++++ 1 file changed, 483 insertions(+) create mode 100644 app/src/main/res/values-pt-rBR/strings.xml diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml new file mode 100644 index 000000000..4cef0b52f --- /dev/null +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -0,0 +1,483 @@ + + FastHub + FastHub for Android + com.fastaccess.ui.widgets.recyclerview.layout_manager.LinearManager + com.fastaccess.ui.widgets.recyclerview.layout_manager.GridManager + com.fastaccess.ui.widgets.recyclerview.layout_manager.StaggeredManager + @string/appbar_scrolling_view_behavior + com.fastaccess.ui.widgets.TabletBehavior + Carregando, por favor aguarde… + Ação + Configuraçoes + Descartar + Cancelar + OK + Sem dados disponíveis + Pesquisar + Por favor entre para continuar utilizando o Fasthub + Entre na sua conta github para extrair o melhor do FastHub + Falha no login + Entrar + Compartilhar + Recarregar + Feeds + Gists + Perfil + Erro + Toque novamente para sair + Readme + Aberto + Fechado + Escolher Repo + Commits + Seguidores + Seguindo + Visão geral + Repositories + Forked + Starred + Seguir + Parar de seguir + Usuário + profile_image_transition + profile_title_transition + Code + Issues + Pull Requests + Detalhes + Repository + Arquivo arquivado detectado, por favor baixe o arquivo para ver seu conteúdo + Mínimo de cacracteres (3) + Nenhum arquivo encontrado + Arquivo readme não encontrado + Baixando… + Baixando arquivo… + Liberado + Elaborado + Lançamentos + Sem corpo + Source code (zip) + Source code (tar.gz) + Contribuidores + Contribuiçoes + Merged + por + Star + Stars + Fork + Forks + Fechar Issue + Reabrir Issue + Reabrir + Fechar + Reaberto com sucesso + Travar a conversa significa:\n·Outros usuarios não podem adicionar novos comentários à esse issue.\n·Voce e outros + colaboradores com acesso à este repositorio ainda podem deixar comentarios que outros podem ver.\n·Você sempre pode desbloquear este issue novamento no + futuro.\n + Desbloquear a conversa significa:\n·Todo mundo podera comentar neste issue novamente.\n·Você sempre + pode bloquaear este issue novamente no futuro.\n + Travar conversa + Desbloquear conversa + Erro ao fechar o issue, por favor tente novamente mais tarde. + Erro ao reabrir o issue, por favor tente novamente mais tarde. + Issue fechado com sucesso +

Descrição não fornecida

+ Cabeçalho Um + Cabeçalho Dois + Cabeçalho Três + Negrito + Italico + Raspado + Lista por tópicos + Lista numerada + Cabeçalho + Citar + Link + Imagem + Deleção + Adição + Mudanças + Status + Tem certeza? + Sucesso + para + Erro ao deletar comentário + Excluir + Comentários + Comentar + Issue + Merge + Pull Request + Commit + Merge com sucesso + Menu arquivo + Arquivos + Baixar + Voltar + Diretório superior + Visualizador de código + Abrir no browser + Arquivo grande + O arquivo é grande demais para ser aberto.\nPressione "OK" para baixá-lo. + Visualizador + Markdown + Enviar + Digite aqui + Descrição + Nome do arquivo + Nome do arquivo com extensão + Gist Secreto + Gist Público + Enviar como + Excluir + Erro ao excluir gist + Sem arquivos + Campo necessário + Enviado com sucesso + Criar Gist + Gist + Limpar + Usuários + Título + Arquivo + Milestone + Assinar eu mesmo + Enviar Issue + Erro ao criar issue + Criar Issue + Por favor desmarque a parte destacada para continuar a editar. + Notificações + Você tem notificações não lidas + Abrir + Tipo de notificação + / + Rótulos + Sem rótulos + Rótulos adicionados com sucesso + Enviar opinião + Sair + Obrigado pela sua opinião! + Versão atual + Versão + Apoie o desenvolvimento, habilite as propagandas + Usuário + Senha + Código de autenticação de dois fatores + Entrar + Descrição do Gist + Sempre que houver um avatar de usuário, você pode clicá-lo para abrir o perfil do usuário + Toque e segure em um evento de fork para abrir o repo original ou o fork. + Baixar lançamentos + Opções + Baixar arquivo ou compartilhar diretório + Toque em um comentário para citar o seu autor ou editar seu comentário. + \nToque e segure no seu comentário para excluí-lo. + Favoritar/Desfavoritar repo + Vigiar + Vigiar/parar de vigiar repo + Fork repo + Marcar repos para acessá-los mais rápido a partir do menu lateral. + Dispensar Tudo + Nenuhma URL encontrada + Última atualização + Visualização + Marcador de sintaxe + Alternar marcador de sintaxe. + \nRole até os ícones do editor de Markdown para mais opções. + Data de criação + Quando o arquivo foi criado + Quando o arquivo foi atualizado por último + com.fastaccess.ui.widgets.FloatingActionButtonBehavior + Marcar tudo como lido + Todas as notificações + Não lidas + Todas + Excluir Repo + Excluir este repo não pode ser desfeito + 30 minutos + 20 minutos + 10 minutos + 5 minutos + 1 minuto + 1 hora + 2 horas + 3 horas + Criado + Commitado + Baixado + Seguido + @string/gist + Wiki + Comentar no Issue + Issue + Membro + Open-sourced + Comentário Pull Request + Pushe para + Time + Excluído + Desconhecido + Comentou no commit + Organization + Card + Project + Pull Request + Repository + Trocar de Branch + Administradores + Editar + \u2022 editado + Atualizar Issue + Atualizar Pull Request + Sem milestones + Adicionar + Pronto + Início + Criar Milestone + Erro ao criar milestone + Devido a + Sem administradores + este + Commits foram alterados para a branch selecionada + Geral + Mudar com que frequência o FastHub verifica por novas notificações + Intervalo de Sincronização de Notificação + A cada + Comportamento + Personalização + Habilitar animações de lista + Animações de Lista + Desabilitar diálogos para prevenir fechamento acidental do app + Toque em voltar para sair + Restaurar + Backup + Backup feito com sucesso! + Selecionar backup para restaurar + Permissão não concedida. + Última atualização: %s + Agora + Qualquer mudança não salva será descartada + Privado + Usar retângulos arredondados nos avatares no lugar de avatares circulares + Aparência dos avatares + Avaliar este app + Autor + Faça Fork no GitHub + Enviar um email + fastaccess.app@gmail.com + Problemas relacionados ao FastHub + Feedback + Reportar um issue + Tendo problemas? Reporte-o aqui + Sobre + Notificação + Desligar + Usuário não autorizado + OTP de dois fatores é necessário + Sem issue + Copiar + Copiado + Comitar mensagem + Ocorreu um erro enquanto se comunicava com o servidor + Erro inesperado enquanto estava requisitando a API + Erro ao requisitar o servidor, por favor tente novamente mais tarde + Marcar notificação como lida + Forking gist + Forking %s + Starring %s + Unstarring %s + Unwatching %s + Watching %s + Fazer login usando seu browser padrão (OAuth) + OU + Desabilitar o Estado de Leitura da Notificação + Desabilite marcar como lido ao clicar na notificação. + Light Theme + Dark Theme + Red + Pink + Purple + Deep Purple + Indigo + Blue + Light Blue + Cyan + Teal + Green + Light Green + Lime + Yellow + Amber + Orange + Deep Orange + Escolher Tema + Escolha seu tema padrão + Escolha a cor acentuada do tema + Cor Acentuada do Tema + Logo Designer (%s) + Google+ + Website + Twitter + Apoiar o Desenvolvimento + Obrigado por ser extremamente demais! + Se o tema não foi aplicado corretamente, por favor feche o app e abra-o manualmente. + Marcar + Marcado + Desmarcar + Nenhum repositório marcado, marcar alguns para vê-los aqui + Sim + Não + Sem feeds + Sem gists + Sem comentários + Sem notificações + Sem seguidores + Seguindo ninguém + Sem repositórios + Sem repositórios favoritados + Sem commits + Sem contribuidores + Sem lançamentos + Sem issues fechados + Sem issues abertos + Sem eventos + Sem pull requests abertos + Sem pull requests fechados + Sem resultados para a busca + Por favor aceite as permissões para permitir ao FastHub + armazenar os arquivos no seu dispositivo para poder visualizá-los + Gists Públicos + Habilitar Propagandas + Sem issues + Sem notificações novas. + Meus Gists + Changelog + Toque para abrir a lista de notificações ou deslize para ignorar + Postando reação %s + Toque e segure para ir para a tela principal, a partir de qualquer lugar + Criado + Atribuído + Mencionado + Nome + Cor + Criar Rótulo + Organização + Organizações + Pessoas + Equipes + Membros + Sem membros + Sem equipes + Sem Organizações + Marcar como lido + Animações + Habilitar animações popup + Animação popup + Milestones + Administrador + Todas as verificações falharam + Todas as verificações estão pendentes + Todas as verificações passaram + Ordenar + Mais novo + Mais antigo + Mais comentados + Menos comentados + Atualizado mais recentemente + Atualizado menos recentemente + Você está atualizado! + Uma nova versão está disponível. + O campo de pesquisa não pode estar vazio + Toque e segure para criar um issue ticket + Este pull request pode ser merged + revisado + rejeitou a revisão deles + aprovou estas mudanças + Sem reações + Reações + Envolver conteúdo + Envolva o código no visualizador de código por padrão + Envolver Código + Bibliotecas de código aberto + Habilitar som de notificação sempre que receber uma notificação. + Habilitar Som de Notificação + Habilitar Notificações + Entrar com token pessoal + Token Pessoal + Entra com autenticação básica + Se você está ligado a alguma organização e não consegue vê-las aqui, por favor entre no link abaixo. + \nhttps://help.github.com/articles/about-third-party-application-restrictions\nPS: Você poderia usar o token de acesso para entrar, o que vai + permitir acesso ao FastHub para poder ver a lista de seuas organizações. + Inserir + Selecionar + Selecionar Imagem + Apoiar com $2.00 + Apoiar com $5.00 + Apoiar com $10.00 + Apoiar com $20.00 + Idiooma do App + Idioma + Escolher Idioma + Escolha seu idioma preferido + Cancelar inscrição + de + em + Inscrever-se + O repo não tem aba de issues + Token de Acesso + Autenticação Básica + Escolha como vai entrar + Em Arquivos + Em Caminhos/Diretórios + Revisar Requests + Entrar no Slack + Você gostaria de entrar no grupo FastHub do Slack? + Convidado com sucesso + Resposta + Falhou ao carregar a imagem. + quer fazer merge + Watchers + Reviewers + Sem reviewers + Enviado do meu %1$s usando %2$s%3$s + Habilitar Assinatura + Habilitar enviado via assinatura + Habilitar Caixa de Assinatura + Habilitar checkbox para alternar a assinatura no editor de texto + Tags + Adicionar comentário + Apresentando Banners + Com o FastHub 2.5.0, agora você pode se expressar melhor com banners + para a sua página de perfil.\n\nQualquer um usando o app FastHub, verá o seu cabeçalho, e você + começará a ver os cabeçalhos de outras pessoas também! Se você quiser criar um banner para si, + faça-o 1280x384 oi divisível, caso contrário, ele pode ser cortado.\n\nVocê pode adicionar ou mudar + o seu banner a qualquer momento, criando um gist descrito "header.fst" com um arquivo contendo um + link direto para a imagem de cabeçalho.\n\nOu ainda mais simples, use o escolhedor de imagens embutido! + + ESCOLHER BANNER + Erro ao carregar a imagem, por favor tente novamente. + Trending + Organizar por emojis ainda não está funcionando devido à limitações do GitHub + Rolar para cima + Rolar para baixo + Participou + Todo marcado + Todo desmarcado + Divisor + Nenhum usuário encontrado + Sem trending + Daily + Weekly + Monthly + Restaurar + Aplicar + Filtrar + Tipo + Ordenar + Direção do ordenamento + Administrador adicionado com sucesso + Reviewer adicionado com sucesso + Milestone adicionado com sucesso + Feed + Tema Premium +
From c80a6a8872a6fff62c6281cd545a70460afdcaa8 Mon Sep 17 00:00:00 2001 From: Caio Roberto Date: Fri, 16 Jun 2017 11:51:56 -0300 Subject: [PATCH 03/11] Translation to Brazilian Portuguese --- app/src/main/res/values-pt-rBR/strings.xml | 75 ---------------------- 1 file changed, 75 deletions(-) diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 4cef0b52f..51d7ce781 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1,11 +1,4 @@ - FastHub - FastHub for Android - com.fastaccess.ui.widgets.recyclerview.layout_manager.LinearManager - com.fastaccess.ui.widgets.recyclerview.layout_manager.GridManager - com.fastaccess.ui.widgets.recyclerview.layout_manager.StaggeredManager - @string/appbar_scrolling_view_behavior - com.fastaccess.ui.widgets.TabletBehavior Carregando, por favor aguarde… Ação Configuraçoes @@ -21,31 +14,19 @@ Compartilhar Recarregar Feeds - Gists Perfil Erro Toque novamente para sair - Readme Aberto Fechado Escolher Repo - Commits Seguidores Seguindo Visão geral - Repositories - Forked - Starred Seguir Parar de seguir Usuário - profile_image_transition - profile_title_transition - Code - Issues - Pull Requests Detalhes - Repository Arquivo arquivado detectado, por favor baixe o arquivo para ver seu conteúdo Mínimo de cacracteres (3) Nenhum arquivo encontrado @@ -56,16 +37,9 @@ Elaborado Lançamentos Sem corpo - Source code (zip) - Source code (tar.gz) Contribuidores Contribuiçoes - Merged por - Star - Stars - Fork - Forks Fechar Issue Reabrir Issue Reabrir @@ -105,10 +79,6 @@ Excluir Comentários Comentar - Issue - Merge - Pull Request - Commit Merge com sucesso Menu arquivo Arquivos @@ -120,7 +90,6 @@ Arquivo grande O arquivo é grande demais para ser aberto.\nPressione "OK" para baixá-lo. Visualizador - Markdown Enviar Digite aqui Descrição @@ -135,7 +104,6 @@ Campo necessário Enviado com sucesso Criar Gist - Gist Limpar Usuários Título @@ -150,7 +118,6 @@ Você tem notificações não lidas Abrir Tipo de notificação - / Rótulos Sem rótulos Rótulos adicionados com sucesso @@ -175,7 +142,6 @@ Favoritar/Desfavoritar repo Vigiar Vigiar/parar de vigiar repo - Fork repo Marcar repos para acessá-los mais rápido a partir do menu lateral. Dispensar Tudo Nenuhma URL encontrada @@ -187,7 +153,6 @@ Data de criação Quando o arquivo foi criado Quando o arquivo foi atualizado por último - com.fastaccess.ui.widgets.FloatingActionButtonBehavior Marcar tudo como lido Todas as notificações Não lidas @@ -206,23 +171,14 @@ Commitado Baixado Seguido - @string/gist - Wiki Comentar no Issue - Issue Membro - Open-sourced Comentário Pull Request Pushe para Time Excluído Desconhecido Comentou no commit - Organization - Card - Project - Pull Request - Repository Trocar de Branch Administradores Editar @@ -264,7 +220,6 @@ Autor Faça Fork no GitHub Enviar um email - fastaccess.app@gmail.com Problemas relacionados ao FastHub Feedback Reportar um issue @@ -283,41 +238,15 @@ Erro ao requisitar o servidor, por favor tente novamente mais tarde Marcar notificação como lida Forking gist - Forking %s - Starring %s - Unstarring %s - Unwatching %s - Watching %s Fazer login usando seu browser padrão (OAuth) OU Desabilitar o Estado de Leitura da Notificação Desabilite marcar como lido ao clicar na notificação. - Light Theme - Dark Theme - Red - Pink - Purple - Deep Purple - Indigo - Blue - Light Blue - Cyan - Teal - Green - Light Green - Lime - Yellow - Amber - Orange - Deep Orange Escolher Tema Escolha seu tema padrão Escolha a cor acentuada do tema Cor Acentuada do Tema - Logo Designer (%s) - Google+ Website - Twitter Apoiar o Desenvolvimento Obrigado por ser extremamente demais! Se o tema não foi aplicado corretamente, por favor feche o app e abra-o manualmente. @@ -353,7 +282,6 @@ Meus Gists Changelog Toque para abrir a lista de notificações ou deslize para ignorar - Postando reação %s Toque e segure para ir para a tela principal, a partir de qualquer lugar Criado Atribuído @@ -466,9 +394,6 @@ Divisor Nenhum usuário encontrado Sem trending - Daily - Weekly - Monthly Restaurar Aplicar Filtrar From 2e571972a9b781cd6762e5ced011887bc3842936 Mon Sep 17 00:00:00 2001 From: yakov116 Date: Fri, 16 Jun 2017 11:15:01 -0400 Subject: [PATCH 04/11] Add @caiorrs for Portuguese (#664) Signed-off-by: Yakov --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9be7df5aa..bf6b7d87a 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Read the [**contribution guide**](.github/CONTRIBUTING.md) for more detailed inf - Italian [@Raffaele74](https://github.com/Raffaele74) - Lithuanian [@mistermantas](https://github.com/mistermantas) - Traditional Chinese [@maple3142](https://github.com/maple3142) +- Portuguese [@caiorrs](https://github.com/caiorrs) # License From c0326c759c2b4c4457933721b7d65c5df21710e8 Mon Sep 17 00:00:00 2001 From: Caio Roberto Date: Fri, 16 Jun 2017 13:04:04 -0300 Subject: [PATCH 05/11] Included pt-br on languages arrays Added the Brazilian Portuguese to 2 language arrays --- app/src/main/res/values/arrays.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 6e706b6ef..2683d508e 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -125,6 +125,7 @@ Italian Japanese Lithuanian + Brazilian Portuguese @@ -138,6 +139,7 @@ it ja lt + br From 04244d50cba1b6335faeca51a4a6769a2fe967f6 Mon Sep 17 00:00:00 2001 From: Kosh Date: Sat, 17 Jun 2017 19:58:01 +0800 Subject: [PATCH 06/11] this commit fixes #666 and fixes #244 fixes #667 fixes #611 and improves PR/Issues labels and some layout enhancement --- .../check_translations.cs | 2 +- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 7 +- .../com/fastaccess/data/dao/LabelModel.java | 8 + .../data/dao/LanguageColorModel.java | 4 +- .../fastaccess/data/dao/TimelineModel.java | 100 +++++------- .../data/dao/model/AbstractIssueEvent.java | 7 +- .../com/fastaccess/helper/PrefGetter.java | 8 +- .../provider/scheme/SchemeParser.java | 8 +- .../NotificationSchedulerJobTask.java | 152 ++++++++++-------- .../provider/timeline/HtmlHelper.java | 14 +- .../provider/timeline/TimelineProvider.java | 6 + .../timeline/handler/PreTagHandler.java | 8 +- .../viewholder/IssueTimelineViewHolder.java | 32 ++-- .../gist/files/GistFilesListFragment.java | 1 - .../commit/details/CommitPagerActivity.java | 6 +- .../code/prettifier/ViewerPresenter.java | 16 +- .../issues/create/CreateIssueActivity.java | 1 - .../issue/details/IssuePagerActivity.java | 5 +- .../details/PullRequestPagerActivity.java | 7 +- .../files/PullRequestFilesFragment.java | 1 - .../search/code/SearchCodeFragment.java | 4 +- .../search/issues/SearchIssuesFragment.java | 4 +- .../search/repos/SearchReposFragment.java | 4 +- .../search/users/SearchUsersFragment.java | 4 +- .../category/SettingsCategoryFragment.java | 7 +- .../ui/modules/trending/TrendingActivity.kt | 111 +++++++++---- .../ui/modules/trending/TrendingMvp.kt | 7 +- .../ui/modules/trending/TrendingPresenter.kt | 23 ++- .../ui/modules/user/UserPagerActivity.java | 16 +- .../pretty/helper/GithubHelper.java | 14 +- .../layout-land/repo_file_header_layout.xml | 9 +- .../repo_file_header_layout.xml | 11 +- .../layout/activity_search_file.xml | 2 +- .../layout/commit_with_branch_layout.xml | 2 +- .../layout/filter_issues_prs_layout.xml | 2 +- .../layout/gists_pager_layout.xml | 8 +- .../layout/issue_pager_activity.xml | 5 +- .../layout/repo_file_header_layout.xml | 10 +- .../layout/repo_header_icons_layout.xml | 12 +- .../main_layouts/layout/search_layout.xml | 2 +- .../layout/trending_activity_layout.xml | 44 +++++ .../layout/simple_footer_list_dialog.xml | 7 +- .../layout/notifications_row_item.xml | 4 +- .../row_layouts/layout/releases_row_item.xml | 2 +- .../layout/repo_files_row_item.xml | 6 +- appveyor.yml | 2 +- build.gradle | 8 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 49 files changed, 449 insertions(+), 282 deletions(-) rename check_translations.cs => .github/check_translations.cs (95%) diff --git a/check_translations.cs b/.github/check_translations.cs similarity index 95% rename from check_translations.cs rename to .github/check_translations.cs index b609d1e23..6a0130ef9 100644 --- a/check_translations.cs +++ b/.github/check_translations.cs @@ -53,7 +53,7 @@ void Main(string[] args) if (TotalIssues != 0) { PowerShell ps = PowerShell.Create(); ps.AddCommand("Add-AppveyorMessage"); - ps.AddArgument(@"Please, remove this/these string(s) and commit this change."); + ps.AddArgument(@"Please, remove the string(s) and commit again."); ps.Invoke(); Environment.Exit(101); } diff --git a/app/build.gradle b/app/build.gradle index 52c87966a..4c99cdb28 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,7 +23,7 @@ android { } } compileSdkVersion 25 - buildToolsVersion "26.0.0-rc2" + buildToolsVersion "26.0.0" defaultConfig { applicationId "com.fastaccess.github" minSdkVersion 21 @@ -141,9 +141,9 @@ dependencies { implementation 'net.sourceforge.htmlcleaner:htmlcleaner:2.2' implementation 'com.github.matthiasrobbers:shortbread:1.0.1' implementation 'com.atlassian.commonmark:commonmark:0.9.0' - implementation 'com.firebase:firebase-jobdispatcher:0.6.0' implementation "com.google.firebase:firebase-messaging:${gms}" implementation "com.google.android.gms:play-services-ads:${gms}" + implementation "com.google.android.gms:play-services-gcm:${gms}" implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true } implementation "com.github.miguelbcr:RxBillingService:0.0.3" implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 04d3510e9..23098522b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -179,7 +179,8 @@ + android:parentActivityName=".ui.modules.main.MainActivity" + android:windowSoftInputMode="stateAlwaysHidden"> @@ -236,9 +237,9 @@ + android:permission="com.google.android.gms.permission.BIND_NETWORK_TASK_SERVICE"> - + diff --git a/app/src/main/java/com/fastaccess/data/dao/LabelModel.java b/app/src/main/java/com/fastaccess/data/dao/LabelModel.java index db99e51cd..68c4068f3 100644 --- a/app/src/main/java/com/fastaccess/data/dao/LabelModel.java +++ b/app/src/main/java/com/fastaccess/data/dao/LabelModel.java @@ -49,4 +49,12 @@ protected LabelModel(Parcel in) { @Override public int hashCode() { return name != null ? name.hashCode() : 0; } + + @Override public String toString() { + return "LabelModel{" + + "url='" + url + '\'' + + ", name='" + name + '\'' + + ", color='" + color + '\'' + + '}'; + } } diff --git a/app/src/main/java/com/fastaccess/data/dao/LanguageColorModel.java b/app/src/main/java/com/fastaccess/data/dao/LanguageColorModel.java index e98b309d5..15c89e64f 100644 --- a/app/src/main/java/com/fastaccess/data/dao/LanguageColorModel.java +++ b/app/src/main/java/com/fastaccess/data/dao/LanguageColorModel.java @@ -12,8 +12,8 @@ */ @Getter @Setter @ToString public class LanguageColorModel implements Parcelable { - private String color; - private String url; + public String color; + public String url; @Override public int describeContents() { return 0; } diff --git a/app/src/main/java/com/fastaccess/data/dao/TimelineModel.java b/app/src/main/java/com/fastaccess/data/dao/TimelineModel.java index 36fc8ea4d..5cbabdc86 100644 --- a/app/src/main/java/com/fastaccess/data/dao/TimelineModel.java +++ b/app/src/main/java/com/fastaccess/data/dao/TimelineModel.java @@ -1,6 +1,5 @@ package com.fastaccess.data.dao; -import android.graphics.Color; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; @@ -15,9 +14,6 @@ import com.fastaccess.data.dao.types.IssueEventType; import com.fastaccess.data.dao.types.ReviewStateType; import com.fastaccess.helper.InputHelper; -import com.fastaccess.helper.ParseDateFormat; -import com.fastaccess.ui.widgets.LabelSpan; -import com.fastaccess.ui.widgets.SpannableBuilder; import java.util.ArrayList; import java.util.Date; @@ -180,64 +176,40 @@ private TimelineModel(GroupedReviewModel groupedReview) { } return issueEvent.getActor().getLogin(); })); - for (List issueEvents : issueEventMap.values()) { - IssueEvent toAdd = null; - SpannableBuilder spannableBuilder = SpannableBuilder.builder(); - for (IssueEvent issueEventModel : issueEvents) { - if (issueEventModel != null) { - IssueEventType event = issueEventModel.getEvent(); - if (event != null) { + if (issueEventMap != null && !issueEventMap.isEmpty()) { + for (Map.Entry> stringListEntry : issueEventMap.entrySet()) { + List labelModels = new ArrayList<>(); + List events = stringListEntry.getValue(); + IssueEvent toAdd = null; + for (IssueEvent event : events) { + if (event.getEvent() == IssueEventType.labeled || event.getEvent() == IssueEventType.unlabeled) { if (toAdd == null) { - toAdd = issueEventModel; + toAdd = event; } - long time = toAdd.getCreatedAt().after(issueEventModel.getCreatedAt()) ? (toAdd.getCreatedAt().getTime() - issueEventModel - .getCreatedAt().getTime()) : (issueEventModel.getCreatedAt().getTime() - toAdd.getCreatedAt().getTime()); - if (TimeUnit.MINUTES.toMinutes(time) <= 2 && toAdd.getEvent() == event) { - if (event == IssueEventType.labeled || event == IssueEventType.unlabeled) { - LabelModel labelModel = issueEventModel.getLabel(); - int color = Color.parseColor("#" + labelModel.getColor()); - spannableBuilder.append(" ") - .append(" " + labelModel.getName() + " ", new LabelSpan(color)) - .append(" "); - } else if (event == IssueEventType.assigned || event == IssueEventType.unassigned) { - spannableBuilder.append(" ") - .bold(issueEventModel.getAssignee() != null ? issueEventModel.getAssignee().getLogin() : "", - new LabelSpan(Color.TRANSPARENT)) - .append(" "); - } + long time = toAdd.getCreatedAt().after(event.getCreatedAt()) ? (toAdd.getCreatedAt().getTime() - event + .getCreatedAt().getTime()) : (event.getCreatedAt().getTime() - toAdd.getCreatedAt().getTime()); + if (TimeUnit.MINUTES.toMinutes(time) <= 2 && toAdd.getEvent() == event.getEvent()) { + labelModels.add(event.getLabel()); } else { - models.add(new TimelineModel(issueEventModel)); + models.add(new TimelineModel(event)); } } else { - models.add(new TimelineModel(issueEventModel)); + models.add(new TimelineModel(event)); } } - } - if (toAdd != null) { - SpannableBuilder builder = SpannableBuilder.builder(); - if (toAdd.getAssignee() != null && toAdd.getAssigner() != null) { - builder.bold(toAdd.getAssigner().getLogin(), new LabelSpan(Color.TRANSPARENT)); - } else { - if (toAdd.getActor() != null) { - builder.bold(toAdd.getActor().getLogin(), new LabelSpan(Color.TRANSPARENT)); - } + if (toAdd != null) { + toAdd.setLabels(labelModels); + models.add(new TimelineModel(toAdd)); } - builder.append(" ") - .append(toAdd.getEvent().name().replaceAll("_", " "), new LabelSpan(Color.TRANSPARENT)); - toAdd.setLabels(SpannableBuilder.builder() - .append(builder) - .append(spannableBuilder) - .append(" ") - .append(ParseDateFormat.getTimeAgo(toAdd.getCreatedAt()), new LabelSpan(Color.TRANSPARENT))); - models.add(new TimelineModel(toAdd)); } } return Stream.of(models) - .sortBy(timelineModel -> timelineModel.getEvent().getCreatedAt()) - .collect(Collectors.toList()); + .sortBy(TimelineModel::getSortedDate) + .toList(); } - @NonNull private static List constructReviews(@NonNull List reviews, @Nullable List comments) { + @NonNull private static List constructReviews + (@NonNull List reviews, @Nullable List comments) { List models = new ArrayList<>(); if (comments == null || comments.isEmpty()) { models.addAll(Stream.of(reviews) @@ -249,19 +221,23 @@ private TimelineModel(GroupedReviewModel groupedReview) { Collectors.mapping(o -> o, toList()))); for (Map.Entry> entry : mappedComments.entrySet()) { List reviewCommentModels = entry.getValue(); - models.add(new TimelineModel(Stream.of(reviewCommentModels) - .filter(value -> value.getCreatedAt() != null) - .findFirst() - .map(reviewCommentModel -> { - GroupedReviewModel groupedReviewModel = new GroupedReviewModel(); - groupedReviewModel.setPath(reviewCommentModel.getPath()); - groupedReviewModel.setDiffText(reviewCommentModel.getDiffHunk()); - groupedReviewModel.setDate(reviewCommentModel.getCreatedAt()); - groupedReviewModel.setPosition(reviewCommentModel.getOriginalPosition()); - groupedReviewModel.setId(reviewCommentModel.getId()); - groupedReviewModel.setComments(reviewCommentModels); - return new GroupedReviewModel(); - }).get())); + GroupedReviewModel groupedReviewModel = new GroupedReviewModel(); + if (!reviewCommentModels.isEmpty()) { + ReviewCommentModel reviewCommentModel = reviewCommentModels.get(0); + groupedReviewModel.setPath(reviewCommentModel.getPath()); + groupedReviewModel.setDiffText(reviewCommentModel.getDiffHunk()); + groupedReviewModel.setDate(reviewCommentModel.getCreatedAt()); + groupedReviewModel.setPosition(reviewCommentModel.getOriginalPosition()); + groupedReviewModel.setId(reviewCommentModel.getId()); + } + for (ReviewCommentModel reviewCommentModel : reviewCommentModels) { + if (reviewCommentModel.getCreatedAt() != null) { + groupedReviewModel.setDate(reviewCommentModel.getCreatedAt()); + break; + } + } + groupedReviewModel.setComments(reviewCommentModels); + models.add(new TimelineModel(groupedReviewModel)); } models.addAll(Stream.of(reviews) .filter(reviewModel -> !InputHelper.isEmpty(reviewModel.getBody()) || reviewModel.getState() == ReviewStateType.APPROVED) diff --git a/app/src/main/java/com/fastaccess/data/dao/model/AbstractIssueEvent.java b/app/src/main/java/com/fastaccess/data/dao/model/AbstractIssueEvent.java index c43157d23..91cf492e9 100644 --- a/app/src/main/java/com/fastaccess/data/dao/model/AbstractIssueEvent.java +++ b/app/src/main/java/com/fastaccess/data/dao/model/AbstractIssueEvent.java @@ -3,7 +3,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; -import android.text.TextUtils; import com.fastaccess.App; import com.fastaccess.data.dao.LabelModel; @@ -58,7 +57,7 @@ String issueId; String repoId; String login; - @Transient CharSequence labels; + @Transient List labels; public Single save(IssueEvent entity) { return RxHelper.getSingle(App.getInstance().getDataStore().upsert(entity)); @@ -116,7 +115,7 @@ public static Single> get(@NonNull String repoId, @NonNull Stri dest.writeString(this.issueId); dest.writeString(this.repoId); dest.writeString(this.login); - TextUtils.writeToParcel(labels, dest, flags); + dest.writeTypedList(this.labels); } protected AbstractIssueEvent(Parcel in) { @@ -139,7 +138,7 @@ protected AbstractIssueEvent(Parcel in) { this.issueId = in.readString(); this.repoId = in.readString(); this.login = in.readString(); - this.labels = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); + this.labels = in.createTypedArrayList(LabelModel.CREATOR); } public static final Creator CREATOR = new Creator() { diff --git a/app/src/main/java/com/fastaccess/helper/PrefGetter.java b/app/src/main/java/com/fastaccess/helper/PrefGetter.java index 1171753d9..20ff8941e 100644 --- a/app/src/main/java/com/fastaccess/helper/PrefGetter.java +++ b/app/src/main/java/com/fastaccess/helper/PrefGetter.java @@ -6,6 +6,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import com.fastaccess.App; import com.fastaccess.BuildConfig; import com.fastaccess.R; @@ -46,7 +47,7 @@ public class PrefGetter { AMLOD, MID_NIGHT_BLUE }) - @Retention(RetentionPolicy.SOURCE) @interface ThemeType {} + @Retention(RetentionPolicy.SOURCE) public @interface ThemeType {} @IntDef({ RED, @@ -239,6 +240,10 @@ public static boolean isSentViaBoxEnabled() { return getThemeType(context.getResources()); } + @ThemeType public static int getThemeType() { + return getThemeType(App.getInstance().getResources()); + } + @ThemeColor public static int getThemeColor(@NonNull Context context) { return getThemeColor(context.getResources()); } @@ -339,6 +344,7 @@ public static void enableAmlodTheme() { public static boolean isAmlodEnabled() { return PrefHelper.getBoolean(AMLOD_THEME_ENABLED); } + public static void enableMidNightBlueTheme() { PrefHelper.set(MIDNIGHTBLUE_THEME_ENABLED, true); } diff --git a/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java b/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java index e583e3dc5..95d980dec 100644 --- a/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java +++ b/app/src/main/java/com/fastaccess/provider/scheme/SchemeParser.java @@ -216,7 +216,6 @@ public static void launchUri(@NonNull Context context, @NonNull Uri data, boolea return null; } - /** * [[k0shk0sh, FastHub, issues], k0shk0sh/fastHub/(issues,pulls,commits, etc)] */ @@ -274,7 +273,12 @@ public static void launchUri(@NonNull Context context, @NonNull Uri data, boolea @Nullable private static String getGistId(@NonNull Uri uri) { List segments = uri.getPathSegments(); - return segments != null && !segments.isEmpty() ? segments.get(0) : null; + if (segments.size() != 1 && segments.size() != 2) return null; + String gistId = segments.get(segments.size() - 1); + if (InputHelper.isEmpty(gistId)) return null; + if (TextUtils.isDigitsOnly(gistId)) return gistId; + else if (gistId.matches("[a-fA-F0-9]+")) return gistId; + else return null; } @Nullable private static Intent getUser(@NonNull Context context, @NonNull Uri uri) { diff --git a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java index be0f2c4b2..2833b445e 100644 --- a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java +++ b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java @@ -11,6 +11,7 @@ import android.support.v4.app.NotificationCompat; import android.support.v4.content.ContextCompat; import android.view.View; +import android.widget.Toast; import com.annimon.stream.Stream; import com.fastaccess.R; @@ -24,15 +25,13 @@ import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; -import com.firebase.jobdispatcher.Constraint; -import com.firebase.jobdispatcher.FirebaseJobDispatcher; -import com.firebase.jobdispatcher.GooglePlayDriver; -import com.firebase.jobdispatcher.Job; -import com.firebase.jobdispatcher.JobParameters; -import com.firebase.jobdispatcher.JobService; -import com.firebase.jobdispatcher.Lifetime; -import com.firebase.jobdispatcher.RetryStrategy; -import com.firebase.jobdispatcher.Trigger; +import com.fastaccess.ui.modules.notification.NotificationActivity; +import com.google.android.gms.common.ConnectionResult; +import com.google.android.gms.common.GoogleApiAvailability; +import com.google.android.gms.gcm.GcmNetworkManager; +import com.google.android.gms.gcm.GcmTaskService; +import com.google.android.gms.gcm.PeriodicTask; +import com.google.android.gms.gcm.TaskParams; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.assist.ImageSize; @@ -41,83 +40,69 @@ import java.util.List; import io.reactivex.Observable; +import io.reactivex.Single; +import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; +import static com.google.android.gms.gcm.GcmNetworkManager.RESULT_SUCCESS; + /** * Created by Kosh on 19 Feb 2017, 6:32 PM */ -public class NotificationSchedulerJobTask extends JobService { +public class NotificationSchedulerJobTask extends GcmTaskService { private final static String JOB_ID = "fasthub_notification"; private final static int THIRTY_MINUTES = 30 * 60; private static final String NOTIFICATION_GROUP_ID = "FastHub"; - @Override public boolean onStartJob(JobParameters job) { - if (PrefGetter.getNotificationTaskDuration() == -1) { - scheduleJob(this, -1, false); - finishJob(job); - return true; - } - Login login = null; - try { - login = Login.getUser(); - } catch (Exception ignored) {} - if (login != null) { - RestProvider.getNotificationService() - .getNotifications(ParseDateFormat.getLastWeekDate()) - .subscribeOn(Schedulers.io()) - .subscribe(item -> { - AppHelper.cancelAllNotifications(getApplicationContext()); - if (item != null) { - onSave(item.getItems(), job); - } else { - finishJob(job); - } - }, throwable -> jobFinished(job, true)); - } else { - finishJob(job); - } - return true; - } - - @Override public boolean onStopJob(JobParameters jobParameters) { - return false; - } - public static void scheduleJob(@NonNull Context context) { int duration = PrefGetter.getNotificationTaskDuration(); scheduleJob(context, duration, false); } public static void scheduleJob(@NonNull Context context, int duration, boolean cancel) { - FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context)); - if (cancel) dispatcher.cancel(JOB_ID); - if (duration == -1) { - dispatcher.cancel(JOB_ID); - return; - } - duration = duration <= 0 ? THIRTY_MINUTES : duration; - Job.Builder builder = dispatcher - .newJobBuilder() - .setTag(JOB_ID) - .setRetryStrategy(RetryStrategy.DEFAULT_LINEAR) - .setLifetime(Lifetime.FOREVER) - .setRecurring(true) - .setConstraints(Constraint.ON_ANY_NETWORK) - .setTrigger(Trigger.executionWindow(10, duration)) - .setService(NotificationSchedulerJobTask.class); - dispatcher.mustSchedule(builder.build()); + Single.create(singleEmitter -> { + if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS) { + GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(context); + if (cancel) gcmNetworkManager.cancelAllTasks(NotificationSchedulerJobTask.class); + if (duration == -1) { + gcmNetworkManager.cancelAllTasks(NotificationSchedulerJobTask.class); + return; + } + final long finalDuration = duration <= 0 ? THIRTY_MINUTES : duration; + PeriodicTask task = new PeriodicTask.Builder() + .setTag(JOB_ID) + .setUpdateCurrent(true) + .setPersisted(true) + .setRequiresCharging(false) + .setRequiredNetwork(PeriodicTask.NETWORK_STATE_ANY) + .setPeriod(finalDuration) + .setFlex(finalDuration) + .setService(NotificationSchedulerJobTask.class) + .build(); + gcmNetworkManager.schedule(task); + singleEmitter.onSuccess(true); + } + singleEmitter.onSuccess(false); + }) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(o -> { + if (!o) { + Toast.makeText(context, "No Google API Service", Toast.LENGTH_SHORT).show(); + } + }, Throwable::printStackTrace); } - private void onSave(@Nullable List notificationThreadModels, JobParameters job) { + private void onSave(@Nullable List notificationThreadModels, TaskParams job) { if (notificationThreadModels != null) { RxHelper.safeObservable(Notification.save(notificationThreadModels)).subscribe(notification -> {/**/}, Throwable::printStackTrace); onNotifyUser(notificationThreadModels, job); } } - private void onNotifyUser(@NonNull List notificationThreadModels, JobParameters job) { + private void onNotifyUser(@NonNull List notificationThreadModels, TaskParams job) { long count = Stream.of(notificationThreadModels) .filter(Notification::isUnread) .count(); @@ -164,15 +149,13 @@ private void onNotifyUser(@NonNull List notificationThreadModels, } }, throwable -> finishJob(job), () -> { - android.app.Notification grouped = getSummaryGroupNotification(first, accentColor); + android.app.Notification grouped = getSummaryGroupNotification(first, accentColor, notificationThreadModels.size() > 1); showNotification(first.getId(), grouped); finishJob(job); }); } - private void finishJob(JobParameters job) { - jobFinished(job, false); - } + private void finishJob(TaskParams job) {} private void showNotificationWithoutComment(Context context, int accentColor, Notification thread, String iconUrl) { if (!InputHelper.isEmpty(iconUrl)) { @@ -255,10 +238,12 @@ private void withComments(Bitmap bitmap, Comment comment, Context context, Notif showNotification(thread.getId(), toAdd); } - private android.app.Notification getSummaryGroupNotification(@NonNull Notification thread, int accentColor) { + private android.app.Notification getSummaryGroupNotification(@NonNull Notification thread, int accentColor, boolean toNotificationActivity) { + PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, + new Intent(getApplicationContext(), NotificationActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); return getNotification(thread.getSubject().getTitle(), thread.getRepository().getFullName()) .setDefaults(PrefGetter.isNotificationSoundEnabled() ? NotificationCompat.DEFAULT_ALL : 0) - .setContentIntent(getPendingIntent(thread.getId(), thread.getSubject().getUrl())) + .setContentIntent(toNotificationActivity ? pendingIntent : getPendingIntent(thread.getId(), thread.getSubject().getUrl())) .addAction(R.drawable.ic_github, getString(R.string.open), getPendingIntent(thread.getId(), thread .getSubject().getUrl())) .addAction(R.drawable.ic_eye_off, getString(R.string.mark_as_read), getReadOnlyPendingIntent(thread.getId(), thread @@ -296,6 +281,39 @@ private PendingIntent getPendingIntent(long id, @NonNull String url) { PendingIntent.FLAG_UPDATE_CURRENT); } + @Override public int onRunTask(TaskParams job) { + if (PrefGetter.getNotificationTaskDuration() == -1) { + scheduleJob(this, -1, false); + finishJob(job); + return RESULT_SUCCESS; + } + Login login = null; + try { + login = Login.getUser(); + } catch (Exception ignored) {} + if (login != null) { + RestProvider.getNotificationService() + .getNotifications(ParseDateFormat.getLastWeekDate()) + .subscribeOn(Schedulers.io()) + .subscribe(item -> { + AppHelper.cancelAllNotifications(getApplicationContext()); + if (item != null) { + onSave(item.getItems(), job); + } else { + finishJob(job); + } + }, Throwable::printStackTrace); + } else { + finishJob(job); + } + return RESULT_SUCCESS; + } + + @Override public void onInitializeTasks() { + super.onInitializeTasks(); + scheduleJob(this); + } + private static class CustomNotificationModel { public String url; public Notification notification; diff --git a/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java b/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java index a30d215bb..6c57e5e9b 100644 --- a/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java +++ b/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java @@ -1,6 +1,7 @@ package com.fastaccess.provider.timeline; import android.content.Context; +import android.graphics.Color; import android.graphics.Point; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -11,7 +12,7 @@ import android.widget.TextView; import com.fastaccess.R; -import com.fastaccess.helper.AppHelper; +import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.ViewHelper; import com.fastaccess.provider.scheme.SchemeParser; import com.fastaccess.provider.timeline.handler.BetterLinkMovementExtended; @@ -53,15 +54,16 @@ private static void registerClickEvent(@NonNull TextView textView) { } private static HtmlSpanner initHtml(@NonNull TextView textView) { - boolean isDark = AppHelper.isNightMode(textView.getResources()); - @ColorInt int windowBackground = isDark ? ViewHelper.getWindowBackground(textView.getContext()) : - ContextCompat.getColor(textView.getContext(), R.color.light_patch_ref_color); + @PrefGetter.ThemeType int theme = PrefGetter.getThemeType(); + @ColorInt int windowBackground = theme == PrefGetter.DARK ? ViewHelper.getWindowBackground(textView.getContext()) : + theme == PrefGetter.LIGHT ? ContextCompat.getColor(textView.getContext(), R.color.light_patch_ref_color) : + Color.LTGRAY; Drawable checked = ContextCompat.getDrawable(textView.getContext(), R.drawable.ic_checkbox_small); Drawable unchecked = ContextCompat.getDrawable(textView.getContext(), R.drawable.ic_checkbox_empty_small); HtmlSpanner mySpanner = new HtmlSpanner(); mySpanner.setStripExtraWhiteSpace(true); - mySpanner.registerHandler("pre", new PreTagHandler(windowBackground, true, isDark)); - mySpanner.registerHandler("code", new PreTagHandler(windowBackground, false, isDark)); + mySpanner.registerHandler("pre", new PreTagHandler(windowBackground, true, theme)); + mySpanner.registerHandler("code", new PreTagHandler(windowBackground, false, theme)); mySpanner.registerHandler("img", new DrawableHandler(textView)); mySpanner.registerHandler("g-emoji", new EmojiHandler()); mySpanner.registerHandler("blockquote", new QouteHandler(windowBackground)); diff --git a/app/src/main/java/com/fastaccess/provider/timeline/TimelineProvider.java b/app/src/main/java/com/fastaccess/provider/timeline/TimelineProvider.java index 61c78c74f..1997b28f7 100644 --- a/app/src/main/java/com/fastaccess/provider/timeline/TimelineProvider.java +++ b/app/src/main/java/com/fastaccess/provider/timeline/TimelineProvider.java @@ -12,6 +12,7 @@ import com.fastaccess.helper.Logger; import com.fastaccess.helper.ParseDateFormat; import com.fastaccess.helper.ViewHelper; +import com.fastaccess.ui.widgets.LabelSpan; import com.fastaccess.ui.widgets.SpannableBuilder; import com.zzhoujay.markdown.style.CodeSpan; @@ -108,6 +109,11 @@ public class TimelineProvider { return spannableBuilder; } + public static void appendLabels(@NonNull LabelModel labelModel, @NonNull SpannableBuilder spannableBuilder) { + int color = Color.parseColor("#" + labelModel.getColor()); + spannableBuilder.append(" ").append(" " + labelModel.getName() + " ", new LabelSpan(color)); + } + @NonNull private static CharSequence getDate(@Nullable Date date) { return ParseDateFormat.getTimeAgo(date); } diff --git a/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java b/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java index 730f1feb7..737feab3f 100644 --- a/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java +++ b/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java @@ -7,6 +7,8 @@ import android.text.style.ForegroundColorSpan; import android.text.style.TypefaceSpan; +import com.fastaccess.helper.PrefGetter; + import net.nightwhistler.htmlspanner.handlers.PreHandler; import org.htmlcleaner.ContentNode; @@ -24,7 +26,7 @@ @ColorInt private final int color; private final boolean isPre; - private boolean isDark; + @PrefGetter.ThemeType private int theme; private void getPlainText(StringBuffer buffer, Object node) { if (node instanceof ContentNode) { @@ -76,8 +78,10 @@ private String replace(String text) { final int stringStart = start + 1; final int stringEnd = builder.length() - 1; builder.setSpan(new BackgroundColorSpan(color), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); - if (!isDark) { + if (theme == PrefGetter.LIGHT) { builder.setSpan(new ForegroundColorSpan(Color.RED), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); + } else if (theme == PrefGetter.AMLOD) { + builder.setSpan(new ForegroundColorSpan(Color.BLUE), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); } builder.setSpan(new TypefaceSpan("monospace"), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); } diff --git a/app/src/main/java/com/fastaccess/ui/adapter/viewholder/IssueTimelineViewHolder.java b/app/src/main/java/com/fastaccess/ui/adapter/viewholder/IssueTimelineViewHolder.java index 122ccda8d..be70dc27e 100644 --- a/app/src/main/java/com/fastaccess/ui/adapter/viewholder/IssueTimelineViewHolder.java +++ b/app/src/main/java/com/fastaccess/ui/adapter/viewholder/IssueTimelineViewHolder.java @@ -1,19 +1,24 @@ package com.fastaccess.ui.adapter.viewholder; +import android.graphics.Color; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; import android.view.ViewGroup; import com.fastaccess.R; +import com.fastaccess.data.dao.LabelModel; import com.fastaccess.data.dao.TimelineModel; import com.fastaccess.data.dao.model.IssueEvent; import com.fastaccess.data.dao.types.IssueEventType; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.ParseDateFormat; import com.fastaccess.provider.timeline.TimelineProvider; import com.fastaccess.ui.widgets.AvatarLayout; import com.fastaccess.ui.widgets.FontTextView; import com.fastaccess.ui.widgets.ForegroundImageView; +import com.fastaccess.ui.widgets.LabelSpan; +import com.fastaccess.ui.widgets.SpannableBuilder; import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter; import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder; @@ -50,15 +55,10 @@ public static IssueTimelineViewHolder newInstance(ViewGroup viewGroup, BaseRecyc } } if (event != null) { - if (isMerged && event == IssueEventType.closed) { - stateImage.setContentDescription(IssueEventType.merged.name()); - stateImage.setImageResource(IssueEventType.merged.getIconResId()); - } else { - stateImage.setContentDescription(event.name()); - stateImage.setImageResource(event.getIconResId()); - } + stateImage.setContentDescription(event.name()); + stateImage.setImageResource(event.getIconResId()); } - if (issueEventModel.getLabels() == null) { + if (issueEventModel.getLabels() == null || issueEventModel.getLabels().isEmpty()) { if (event != null) { stateText.setText(TimelineProvider.getStyledEvents(issueEventModel, itemView.getContext(), isMerged)); } else { @@ -66,7 +66,21 @@ public static IssueTimelineViewHolder newInstance(ViewGroup viewGroup, BaseRecyc stateImage.setImageResource(R.drawable.ic_label); } } else { - stateText.setText(issueEventModel.getLabels()); + if (event != null) { + SpannableBuilder spannableBuilder = SpannableBuilder.builder(); + if (issueEventModel.getAssignee() != null && issueEventModel.getAssigner() != null) { + spannableBuilder.bold(issueEventModel.getAssigner().getLogin(), new LabelSpan(Color.TRANSPARENT)); + } else if (issueEventModel.getActor() != null) { + spannableBuilder.bold(issueEventModel.getActor().getLogin(), new LabelSpan(Color.TRANSPARENT)); + } + spannableBuilder.append(" ").append(event.name().replaceAll("_", " "), new LabelSpan(Color.TRANSPARENT)); + for (LabelModel labelModel : issueEventModel.getLabels()) { + TimelineProvider.appendLabels(labelModel, spannableBuilder); + } + spannableBuilder.append(" ").append(ParseDateFormat.getTimeAgo(issueEventModel.getCreatedAt()), new LabelSpan(Color.TRANSPARENT)); + stateText.setText(spannableBuilder); + stateImage.setImageResource(R.drawable.ic_label); + } } itemView.setEnabled(!InputHelper.isEmpty(issueEventModel.getCommitUrl())); } diff --git a/app/src/main/java/com/fastaccess/ui/modules/gists/gist/files/GistFilesListFragment.java b/app/src/main/java/com/fastaccess/ui/modules/gists/gist/files/GistFilesListFragment.java index dfd4a1733..705a54864 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/gists/gist/files/GistFilesListFragment.java +++ b/app/src/main/java/com/fastaccess/ui/modules/gists/gist/files/GistFilesListFragment.java @@ -65,7 +65,6 @@ public static GistFilesListFragment newInstance(@NonNull GithubFileModel gistsMo } if (!filesListModel.isEmpty()) { recycler.setAdapter(new GistFilesAdapter(filesListModel, getPresenter())); - recycler.addKeyLineDivider(); } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerActivity.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerActivity.java index 86e7c1bd6..fe4ebae04 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/commit/details/CommitPagerActivity.java @@ -163,9 +163,11 @@ public static void createIntentForOffline(@NonNull Context context, @NonNull Com HtmlHelper.htmlIntoTextView(title, commit.getGitCommit().getMessage()); detailsIcon.setVisibility(View.VISIBLE); size.setVisibility(View.GONE); - date.setText(SpannableBuilder.builder().append(ParseDateFormat.getTimeAgo(dateValue)) + date.setText(SpannableBuilder.builder() + .bold(getPresenter().repoId) .append(" ") - .bold(getPresenter().repoId)); + .append(" ") + .append(ParseDateFormat.getTimeAgo(dateValue))); avatarLayout.setUrl(avatar, login); addition.setText(String.valueOf(commit.getStats() != null ? commit.getStats().getAdditions() : 0)); deletion.setText(String.valueOf(commit.getStats() != null ? commit.getStats().getDeletions() : 0)); diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java index a0a4db03d..6b1405d88 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/code/prettifier/ViewerPresenter.java @@ -1,16 +1,15 @@ package com.fastaccess.ui.modules.repos.code.prettifier; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.fastaccess.R; import com.fastaccess.data.dao.MarkdownModel; -import com.fastaccess.data.dao.NameParser; import com.fastaccess.data.dao.model.ViewerFile; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; -import com.fastaccess.helper.Logger; import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.markdown.MarkDownProvider; import com.fastaccess.provider.rest.RestProvider; @@ -121,13 +120,14 @@ class ViewerPresenter extends BasePresenter implements ViewerMvp if (isMarkdown) { MarkdownModel model = new MarkdownModel(); model.setText(downloadedStream); - NameParser parser = new NameParser(url); - if (parser.getUsername() != null && parser.getName() != null) { - model.setContext(parser.getUsername() + "/" + parser.getName()); - } else { - model.setContext(""); + Uri uri = Uri.parse(url); + StringBuilder baseUrl = new StringBuilder(); + for (String s : uri.getPathSegments()) { + if (!s.equalsIgnoreCase(uri.getLastPathSegment())) { + baseUrl.append("/").append(s); + } } - Logger.e(model.getContext()); + model.setContext(baseUrl.toString()); makeRestCall(RestProvider.getRepoService().convertReadmeToHtml(model), string -> { isMarkdown = true; downloadedStream = string; diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/create/CreateIssueActivity.java b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/create/CreateIssueActivity.java index 064e4fa53..3fd7ba33e 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/issues/create/CreateIssueActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/issues/create/CreateIssueActivity.java @@ -38,7 +38,6 @@ public class CreateIssueActivity extends BaseActivity(), TrendingMvp.View { - private var trendingFragment: TrendingFragment? = null val navMenu: NavigationView by bindView(R.id.navMenu) @@ -33,22 +40,28 @@ class TrendingActivity : BaseActivity(), Tr val weekly: TextView by bindView(R.id.weekly) val monthly: TextView by bindView(R.id.monthly) val drawerLayout: DrawerLayout by bindView(R.id.drawer) + val clear: View by bindView(R.id.clear) + val searchEditText: FontEditText by bindView(R.id.searchEditText) @State var selectedTitle: String = "All Language" - companion object { - fun getTrendingIntent(context: Context, lang: String?, query: String?): Intent { - val intent = Intent(context, TrendingActivity::class.java) - intent.putExtras(Bundler.start() - .put(BundleConstant.EXTRA, lang) - .put(BundleConstant.EXTRA_TWO, query) - .end()) - return intent + @OnTextChanged(value = R.id.searchEditText, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) fun onTextChange(s: Editable) { + val text = s.toString() + if (text.isEmpty()) { + AnimHelper.animateVisibility(clear, false) + } else { + AnimHelper.animateVisibility(clear, true) } } - fun onDailyClicked() { + @OnEditorAction(R.id.searchEditText) fun onSearch(): Boolean { + presenter.onFilterLanguage(InputHelper.toString(searchEditText)) + ViewHelper.hideKeyboard(searchEditText) + return true + } + + @OnClick(R.id.daily) fun onDailyClicked() { Logger.e() daily.isSelected = true weekly.isSelected = false @@ -56,52 +69,58 @@ class TrendingActivity : BaseActivity(), Tr setValues() } - fun onWeeklyClicked() { + @OnClick(R.id.weekly) fun onWeeklyClicked() { weekly.isSelected = true daily.isSelected = false monthly.isSelected = false setValues() } - fun onMonthlyClicked() { + @OnClick(R.id.monthly) fun onMonthlyClicked() { monthly.isSelected = true weekly.isSelected = false daily.isSelected = false setValues() } - override fun layout(): Int { - return R.layout.trending_activity_layout + @OnClick(R.id.clear) fun onClearSearch() { + ViewHelper.hideKeyboard(searchEditText) + searchEditText.setText("") + onClearMenu() + presenter.onLoadLanguage() } - override fun isTransparent(): Boolean { - return true - } + override fun layout(): Int = R.layout.trending_activity_layout - override fun canBack(): Boolean { - return true - } + override fun isTransparent(): Boolean = true - override fun isSecured(): Boolean { - return false - } + override fun canBack(): Boolean = true - override fun providePresenter(): TrendingPresenter { - return TrendingPresenter() - } + override fun isSecured(): Boolean = false + + override fun providePresenter(): TrendingPresenter = TrendingPresenter() override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + navMenu.itemIconTintList = null trendingFragment = supportFragmentManager.findFragmentById(R.id.trendingFragment) as TrendingFragment? - daily.setOnClickListener { onDailyClicked() } - weekly.setOnClickListener { onWeeklyClicked() } - monthly.setOnClickListener { onMonthlyClicked() } navMenu.setNavigationItemSelectedListener({ item -> closeDrawerLayout() onItemClicked(item) }) setupIntent(savedInstanceState) - presenter.onLoadLanguage() + if (savedInstanceState == null) { + presenter.onLoadLanguage() + } else { + Handler().postDelayed({ + Logger.e(searchEditText.text) + if (InputHelper.isEmpty(searchEditText)) { //searchEditText.text is always empty even tho there is a text in it !!!!!!! + presenter.onLoadLanguage() + } else { + presenter.onFilterLanguage(InputHelper.toString(searchEditText)) + } + }, 300) + } onSelectTrending() } @@ -125,12 +144,17 @@ class TrendingActivity : BaseActivity(), Tr } } - override fun onAppend(title: String) { + override fun onAppend(title: String, color: Int) { navMenu.menu.add(R.id.languageGroup, title.hashCode(), Menu.NONE, title) .setCheckable(true) + .setIcon(createOvalShape(color)) .isChecked = title.toLowerCase() == selectedTitle.toLowerCase() } + override fun onClearMenu() { + navMenu.menu.clear() + } + private fun onItemClicked(item: MenuItem?): Boolean { when (item?.title.toString()) { "All Language" -> selectedTitle = "" @@ -188,4 +212,23 @@ class TrendingActivity : BaseActivity(), Tr setValues() } } + + private fun createOvalShape(@ColorInt color: Int): GradientDrawable { + val drawable = GradientDrawable() + drawable.shape = GradientDrawable.OVAL + drawable.setSize(24, 24) + drawable.setColor(if (color == 0) Color.LTGRAY else color) + return drawable + } + + companion object { + fun getTrendingIntent(context: Context, lang: String?, query: String?): Intent { + val intent = Intent(context, TrendingActivity::class.java) + intent.putExtras(Bundler.start() + .put(BundleConstant.EXTRA, lang) + .put(BundleConstant.EXTRA_TWO, query) + .end()) + return intent + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingMvp.kt b/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingMvp.kt index 576146287..1bf46c6f9 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingMvp.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingMvp.kt @@ -7,11 +7,14 @@ import com.fastaccess.ui.base.mvp.BaseMvp */ interface TrendingMvp { - interface View : BaseMvp.FAView{ - fun onAppend(title: String) + interface View : BaseMvp.FAView { + fun onAppend(title: String, color: Int) + fun onClearMenu() } interface Presenter { fun onLoadLanguage() + + fun onFilterLanguage(key: String) } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingPresenter.kt b/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingPresenter.kt index a400d57a7..1e86d9dd9 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingPresenter.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/trending/TrendingPresenter.kt @@ -1,5 +1,6 @@ package com.fastaccess.ui.modules.trending +import android.graphics.Color import com.fastaccess.helper.RxHelper import com.fastaccess.provider.colors.ColorsProvider import com.fastaccess.ui.base.mvp.presenter.BasePresenter @@ -10,8 +11,28 @@ import io.reactivex.Observable */ class TrendingPresenter : BasePresenter(), TrendingMvp.Presenter { + override fun onFilterLanguage(key: String) { + manageObservable(RxHelper.getObserver(Observable.fromIterable(ColorsProvider.languages())) + .doOnSubscribe { sendToView { it.onClearMenu() } } + .filter { it.toLowerCase().contains(key.toLowerCase()) } + .doOnNext({ t: String -> sendWithColor(t) })) + } + + private fun sendWithColor(t: String) { + val color = ColorsProvider.getColor(t) + if (color != null) { + try { + val lanColor = Color.parseColor(color.color) + sendToView { it.onAppend(t, lanColor) } + } catch (e: Exception) { + e.printStackTrace() + sendToView { it.onAppend(t, 0) } + } + } + } + override fun onLoadLanguage() { manageObservable(RxHelper.getObserver(Observable.fromIterable(ColorsProvider.languages())) - .doOnNext({ t: String -> sendToView({ it.onAppend(t) }) })) + .doOnNext({ t: String -> sendWithColor(t) })) } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerActivity.java b/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerActivity.java index 7d5b073fb..8c4ebd14e 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerActivity.java @@ -209,14 +209,18 @@ public static Intent createIntent(@NonNull Context context, @NonNull String logi private void hideShowFab(int position) { if (isOrg) { - int orgPosition = position; if (getPresenter().getIsMember() == 1) { - orgPosition = 2; - } - if (orgPosition == 1 || orgPosition == 2) { - fab.show(); + if (position == 2) { + fab.show(); + } else { + fab.hide(); + } } else { - fab.hide(); + if (position == 1) { + fab.show(); + } else { + fab.hide(); + } } } else { if (position == 2) { diff --git a/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java b/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java index 31a852778..68b9191b6 100755 --- a/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java +++ b/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java @@ -41,8 +41,15 @@ public class GithubHelper { if (src.startsWith("http://") || src.startsWith("https://")) { continue; } - String finalSrc = "https://raw.githubusercontent.com/" + owner + "/" + repoName + "/master/" + src; - source = source.replace("src=\"" + src + "\"", "src=\"" + finalSrc + "\""); + String finalSrc; + Logger.e(src); + if (src.startsWith("/" + owner + "/" + repoName)) { + finalSrc = "https://raw.githubusercontent.com/" + src; + } else { + finalSrc = "https://raw.githubusercontent.com/" + owner + "/" + repoName + "/master/" + src; + } + source = source.replace("src=\"" + src + "\"", "src=\"" + finalSrc + .replace("raw/", "master/").replaceAll("//", "/") + "\""); } return validateLinks(source, baseUrl); } @@ -62,8 +69,7 @@ public class GithubHelper { link = "https://raw.githubusercontent.com/" + owner + "/" + repoName + "/master/" + href; //assuming always master is bad :'( } else { String formattedLink = href.replaceFirst("./", "/"); - link = "https://api.github.com/repos/" + owner + "/" + repoName + - (formattedLink.startsWith("/") ? formattedLink : ("/" + formattedLink)); + link = ("https://api.github.com/repos/" + owner + "/" + repoName + formattedLink).replaceAll("//", "/"); } source = source.replace("href=\"" + href + "\"", "href=\"" + link + "\""); } diff --git a/app/src/main/res/layouts/main_layouts/layout-land/repo_file_header_layout.xml b/app/src/main/res/layouts/main_layouts/layout-land/repo_file_header_layout.xml index 9f03cb141..bbb0243e4 100644 --- a/app/src/main/res/layouts/main_layouts/layout-land/repo_file_header_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout-land/repo_file_header_layout.xml @@ -7,7 +7,6 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:paddingBottom="@dimen/spacing_micro" - android:paddingEnd="@dimen/spacing_normal" android:paddingTop="@dimen/spacing_micro" tools:ignore="RtlSymmetry" tools:showIn="@layout/repo_file_layout"> @@ -28,7 +27,7 @@ android:layout_marginStart="@dimen/avatar_margin" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/home" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_home"/> @@ -76,7 +75,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:contentDescription="@string/switch_branch" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_branch"/> @@ -28,7 +28,7 @@ android:layout_marginStart="@dimen/avatar_margin" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/home" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_home"/> @@ -78,7 +79,7 @@ android:layout_marginEnd="@dimen/avatar_margin_end" android:layout_marginStart="@dimen/avatar_margin" android:contentDescription="@string/switch_branch" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_branch"/> diff --git a/app/src/main/res/layouts/main_layouts/layout/commit_with_branch_layout.xml b/app/src/main/res/layouts/main_layouts/layout/commit_with_branch_layout.xml index 9cca6ae15..1dc9b4b9f 100644 --- a/app/src/main/res/layouts/main_layouts/layout/commit_with_branch_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout/commit_with_branch_layout.xml @@ -24,7 +24,7 @@ android:layout_gravity="center" android:layout_marginEnd="@dimen/spacing_xs_large" android:contentDescription="@string/switch_branch" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_branch"/> diff --git a/app/src/main/res/layouts/main_layouts/layout/gists_pager_layout.xml b/app/src/main/res/layouts/main_layouts/layout/gists_pager_layout.xml index 4d69d5636..ad916bb38 100644 --- a/app/src/main/res/layouts/main_layouts/layout/gists_pager_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout/gists_pager_layout.xml @@ -41,29 +41,31 @@ android:layout_gravity="center|end" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/open_in_browser" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:scaleType="centerCrop" android:src="@drawable/ic_brower"/> diff --git a/app/src/main/res/layouts/main_layouts/layout/issue_pager_activity.xml b/app/src/main/res/layouts/main_layouts/layout/issue_pager_activity.xml index 89c583b63..15403861d 100644 --- a/app/src/main/res/layouts/main_layouts/layout/issue_pager_activity.xml +++ b/app/src/main/res/layouts/main_layouts/layout/issue_pager_activity.xml @@ -42,7 +42,7 @@ android:layout_gravity="center|end" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/star" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:scaleType="centerCrop" android:src="@drawable/ic_star"/> @@ -50,10 +50,11 @@ android:id="@+id/forkGist" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/spacing_micro" android:layout_gravity="center|end" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/fork" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:scaleType="centerCrop" android:src="@drawable/ic_fork"/> diff --git a/app/src/main/res/layouts/main_layouts/layout/repo_file_header_layout.xml b/app/src/main/res/layouts/main_layouts/layout/repo_file_header_layout.xml index 00444d84b..ba6b14708 100644 --- a/app/src/main/res/layouts/main_layouts/layout/repo_file_header_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout/repo_file_header_layout.xml @@ -7,7 +7,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:paddingBottom="@dimen/spacing_micro" - android:paddingEnd="@dimen/spacing_xs_large" + android:paddingEnd="@dimen/spacing_micro" android:paddingStart="@dimen/spacing_xs_large" android:paddingTop="@dimen/spacing_micro" tools:showIn="@layout/repo_file_layout"> @@ -24,7 +24,7 @@ android:layout_gravity="center" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/home" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_home"/> @@ -70,7 +70,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:contentDescription="@string/switch_branch" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:layout_marginEnd="@dimen/spacing_xs_large" android:src="@drawable/ic_branch"/> diff --git a/app/src/main/res/layouts/main_layouts/layout/repo_header_icons_layout.xml b/app/src/main/res/layouts/main_layouts/layout/repo_header_icons_layout.xml index 2311d2bed..0c2c85f00 100644 --- a/app/src/main/res/layouts/main_layouts/layout/repo_header_icons_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout/repo_header_icons_layout.xml @@ -29,7 +29,7 @@ android:id="@+id/watchRepoImage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_eye"/> diff --git a/app/src/main/res/layouts/main_layouts/layout/trending_activity_layout.xml b/app/src/main/res/layouts/main_layouts/layout/trending_activity_layout.xml index 8b8dca2f1..5ec103fc8 100644 --- a/app/src/main/res/layouts/main_layouts/layout/trending_activity_layout.xml +++ b/app/src/main/res/layouts/main_layouts/layout/trending_activity_layout.xml @@ -100,6 +100,50 @@ android:textColor="@color/search_tab_highlighter"/> + + + + + + + + + + @@ -56,7 +56,8 @@ android:layout_gravity="center" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/add" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" + android:layout_marginEnd="@dimen/spacing_micro" android:scaleType="centerCrop" android:src="@drawable/ic_add" android:visibility="gone"/> @@ -68,7 +69,7 @@ android:layout_gravity="center" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/submit" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:scaleType="centerCrop" android:src="@drawable/ic_send"/> diff --git a/app/src/main/res/layouts/row_layouts/layout/notifications_row_item.xml b/app/src/main/res/layouts/row_layouts/layout/notifications_row_item.xml index ad4877b86..c2841267f 100644 --- a/app/src/main/res/layouts/row_layouts/layout/notifications_row_item.xml +++ b/app/src/main/res/layouts/row_layouts/layout/notifications_row_item.xml @@ -109,7 +109,7 @@ android:layout_height="wrap_content" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/un_subscribe" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:src="@drawable/ic_unsubscribe"/> diff --git a/app/src/main/res/layouts/row_layouts/layout/releases_row_item.xml b/app/src/main/res/layouts/row_layouts/layout/releases_row_item.xml index 1ba8150da..80f92e496 100644 --- a/app/src/main/res/layouts/row_layouts/layout/releases_row_item.xml +++ b/app/src/main/res/layouts/row_layouts/layout/releases_row_item.xml @@ -60,7 +60,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:background="?selectableItemBackgroundBorderless" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" android:scaleType="centerCrop" android:src="@drawable/ic_download" tools:src="@drawable/ic_notification"/> diff --git a/app/src/main/res/layouts/row_layouts/layout/repo_files_row_item.xml b/app/src/main/res/layouts/row_layouts/layout/repo_files_row_item.xml index 1c2a597c8..35fb5f029 100644 --- a/app/src/main/res/layouts/row_layouts/layout/repo_files_row_item.xml +++ b/app/src/main/res/layouts/row_layouts/layout/repo_files_row_item.xml @@ -7,7 +7,7 @@ android:layout_margin="@dimen/grid_spacing" android:foreground="?android:selectableItemBackground" android:paddingBottom="@dimen/spacing_normal" - android:paddingEnd="@dimen/spacing_xs_large" + android:paddingEnd="@dimen/spacing_micro" android:paddingTop="@dimen/spacing_normal" tools:ignore="RtlSymmetry"> @@ -25,7 +25,7 @@ android:layout_marginStart="@dimen/avatar_margin" android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/file" - android:padding="@dimen/spacing_normal" + android:padding="@dimen/spacing_micro" tools:src="@drawable/ic_file_document"/> diff --git a/appveyor.yml b/appveyor.yml index d375f4fbe..8f6451c64 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,7 @@ install: - ps: 'echo "y" | & C:/Android/android-sdk/tools/bin/sdkmanager.bat "platforms;android-25"' build_script: - - cmd: IF NOT [%APPVEYOR_PULL_REQUEST_NUMBER%] == [] cscs /ac check_translations.cs + - cmd: IF NOT [%APPVEYOR_PULL_REQUEST_NUMBER%] == [] cscs /ac C:\FH\.github\check_translations.cs - cmd: gradlew clean assembleDebug --stacktrace test: off diff --git a/build.gradle b/build.gradle index 5052836dc..fdd4bbe9b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,10 @@ buildscript { ext { butterKnifeVersion = '8.5.1' - state_version = '1.0.6' + state_version = '1.1.0' lombokVersion = '1.12.6' - supportVersion = "25.3.1" - gms = "11.0.0" + supportVersion = "25.4.0" + gms = "11.0.1" thirtyinchVersion = '0.8.0' retrofit = '2.3.0' junitVersion = '4.12' @@ -23,7 +23,7 @@ buildscript { maven { url 'https://maven.google.com' } } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0-alpha3' + classpath 'com.android.tools.build:gradle:3.0.0-alpha4' classpath 'com.google.gms:google-services:3.0.0' classpath 'com.novoda:gradle-build-properties-plugin:0.3' classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b4b0423b9..ed84fc39d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed May 17 17:59:48 EDT 2017 +#Fri Jun 16 09:16:40 MYT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip From 185b0d05b7b2469ce2790ae91f730b30757f3592 Mon Sep 17 00:00:00 2001 From: Kosh Date: Sun, 18 Jun 2017 00:06:30 +0800 Subject: [PATCH 07/11] added new theme, customized about screen to meet FastHub themes & for good made the last updated filter to be inline with the other items. --- app/build.gradle | 2 +- app/src/debug/res/values/secrets.xml | 1 + app/src/main/AndroidManifest.xml | 11 +- app/src/main/java/com/fastaccess/App.java | 4 +- .../data/dao/FragmentPagerAdapterModel.java | 4 +- .../java/com/fastaccess/helper/AppHelper.java | 4 +- .../com/fastaccess/helper/PrefGetter.java | 19 +- ...bTask.java => NotificationJobService.java} | 8 +- .../fastaccess/provider/theme/ThemeEngine.kt | 39 +++ .../provider/timeline/HtmlHelper.java | 17 +- .../timeline/handler/PreTagHandler.java | 2 - .../com/fastaccess/ui/base/BaseActivity.java | 3 +- .../modules/about/FastHubAboutActivity.java | 36 ++- .../ui/modules/editor/EditorActivity.java | 75 +++--- .../ui/modules/main/MainActivity.java | 5 + .../modules/main/donation/DonateActivity.kt | 29 ++- .../main/donation/DonationActivity.java | 26 +- .../overview/ProfileOverviewFragment.java | 1 + .../category/SettingsCategoryFragment.java | 8 +- .../modules/theme/fragment/ThemeFragment.kt | 24 +- .../layout/filter_issues_popup.xml | 7 +- .../layout/repo_header_icons_layout.xml | 15 +- app/src/main/res/values/colors.xml | 2 +- app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/theme_amlod.xml | 9 +- app/src/main/res/values/theme_bluish.xml | 227 ++++++++++++++++++ app/src/main/res/values/theme_dark.xml | 1 + app/src/main/res/values/theme_light.xml | 1 + 28 files changed, 469 insertions(+), 112 deletions(-) rename app/src/main/java/com/fastaccess/provider/tasks/notification/{NotificationSchedulerJobTask.java => NotificationJobService.java} (98%) create mode 100644 app/src/main/res/values/theme_bluish.xml diff --git a/app/build.gradle b/app/build.gradle index 4c99cdb28..749d226e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -133,7 +133,7 @@ dependencies { implementation 'com.github.GrenderG:Toasty:1.1.3' implementation 'com.github.JediBurrell:MaterialTapTargetPrompt:-SNAPSHOT' implementation 'com.github.k0shk0sh:RetainedDateTimePickers:1.0.2' - implementation 'com.github.daniel-stoneuk:material-about-library:1.8.1' + implementation 'com.github.k0shk0sh:material-about-library:master-SNAPSHOT' implementation "io.requery:requery:${requery}" implementation "io.requery:requery-android:${requery}" implementation('com.mikepenz:aboutlibraries:5.9.5@aar') { transitive = true } diff --git a/app/src/debug/res/values/secrets.xml b/app/src/debug/res/values/secrets.xml index 9ecf93051..e4bfb6119 100644 --- a/app/src/debug/res/values/secrets.xml +++ b/app/src/debug/res/values/secrets.xml @@ -8,4 +8,5 @@ android.test.item_unavailable android.test.purchased android.test.purchased + android.test.purchased \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 23098522b..0c81f5082 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -235,7 +235,7 @@ @@ -258,6 +258,15 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/fastaccess/App.java b/app/src/main/java/com/fastaccess/App.java index 30451bb13..477a6b6fd 100644 --- a/app/src/main/java/com/fastaccess/App.java +++ b/app/src/main/java/com/fastaccess/App.java @@ -9,7 +9,7 @@ import com.fastaccess.helper.TypeFaceHelper; import com.fastaccess.provider.colors.ColorsProvider; import com.fastaccess.provider.emoji.EmojiManager; -import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask; +import com.fastaccess.provider.tasks.notification.NotificationJobService; import com.fastaccess.provider.uil.UILProvider; import com.miguelbcr.io.rx_billing_service.RxBillingService; @@ -55,7 +55,7 @@ private void init() { setupPreference(); UILProvider.initUIL(this); TypeFaceHelper.generateTypeface(this); - NotificationSchedulerJobTask.scheduleJob(this); + NotificationJobService.scheduleJob(this); Shortbread.create(this); EmojiManager.load(); ColorsProvider.load(); diff --git a/app/src/main/java/com/fastaccess/data/dao/FragmentPagerAdapterModel.java b/app/src/main/java/com/fastaccess/data/dao/FragmentPagerAdapterModel.java index c42dbf853..3be0c8417 100644 --- a/app/src/main/java/com/fastaccess/data/dao/FragmentPagerAdapterModel.java +++ b/app/src/main/java/com/fastaccess/data/dao/FragmentPagerAdapterModel.java @@ -214,8 +214,8 @@ public static List buildForRepoCode(@NonNull Context @NonNull public static List buildForTheme() { return Stream.of(new FragmentPagerAdapterModel("", ThemeFragment.Companion.newInstance(R.style.ThemeLight)), new FragmentPagerAdapterModel("", ThemeFragment.Companion.newInstance(R.style.ThemeDark)), - new FragmentPagerAdapterModel("", ThemeFragment.Companion.newInstance(R.style.ThemeAmlod))) -// new FragmentPagerAdapterModel("", ThemeFragment.Companion.newInstance(R.style.ThemeMidNighBlue))) + new FragmentPagerAdapterModel("", ThemeFragment.Companion.newInstance(R.style.ThemeAmlod)), + new FragmentPagerAdapterModel("", ThemeFragment.Companion.newInstance(R.style.ThemeBluish))) .collect(Collectors.toList()); } } diff --git a/app/src/main/java/com/fastaccess/helper/AppHelper.java b/app/src/main/java/com/fastaccess/helper/AppHelper.java index 2ed5494f6..089af02c5 100644 --- a/app/src/main/java/com/fastaccess/helper/AppHelper.java +++ b/app/src/main/java/com/fastaccess/helper/AppHelper.java @@ -58,8 +58,8 @@ public static void copyToClipboard(@NonNull Context context, @NonNull String uri } public static boolean isNightMode(@NonNull Resources resources) { - int themeType = PrefGetter.getThemeType(resources); - return themeType == PrefGetter.DARK || themeType == PrefGetter.AMLOD; + @PrefGetter.ThemeType int themeType = PrefGetter.getThemeType(resources); + return themeType == PrefGetter.DARK || themeType == PrefGetter.AMLOD || themeType == PrefGetter.BLUISH; } @SuppressWarnings("StringBufferReplaceableByString") public static String getFastHubIssueTemplate() { diff --git a/app/src/main/java/com/fastaccess/helper/PrefGetter.java b/app/src/main/java/com/fastaccess/helper/PrefGetter.java index 20ff8941e..ef5c76f82 100644 --- a/app/src/main/java/com/fastaccess/helper/PrefGetter.java +++ b/app/src/main/java/com/fastaccess/helper/PrefGetter.java @@ -23,6 +23,7 @@ public class PrefGetter { public static final int DARK = 2; public static final int AMLOD = 3; public static final int MID_NIGHT_BLUE = 4; + public static final int BLUISH = 5; public static final int RED = 1; public static final int PINK = 2; @@ -45,7 +46,8 @@ public class PrefGetter { LIGHT, DARK, AMLOD, - MID_NIGHT_BLUE + MID_NIGHT_BLUE, + BLUISH }) @Retention(RetentionPolicy.SOURCE) public @interface ThemeType {} @@ -90,6 +92,7 @@ public class PrefGetter { private static final String PROFILE_BACKGROUND_URL = "profile_background_url"; private static final String AMLOD_THEME_ENABLED = "amlod_theme_enabled"; private static final String MIDNIGHTBLUE_THEME_ENABLED = "midnightblue_theme_enabled"; + private static final String BLUISH_THEME_ENABLED = "bluish_theme_enabled"; private static final String PRO_ITEMS = "pro_items"; public static void setToken(@NonNull String token) { @@ -259,6 +262,8 @@ public static boolean isSentViaBoxEnabled() { return AMLOD; } else if (appTheme.equalsIgnoreCase(resources.getString(R.string.mid_night_blue_theme_mode))) { return MID_NIGHT_BLUE; + } else if (appTheme.equalsIgnoreCase(resources.getString(R.string.bluish_theme))) { + return BLUISH; } } return LIGHT; @@ -353,6 +358,14 @@ public static boolean isMidNightBlueThemeEnabled() { return PrefHelper.getBoolean(MIDNIGHTBLUE_THEME_ENABLED); } + public static boolean isBluishEnabled() { + return PrefHelper.getBoolean(BLUISH_THEME_ENABLED); + } + + public static void enableBluishTheme() { + PrefHelper.set(BLUISH_THEME_ENABLED, true); + } + public static void setProItems() { PrefHelper.set(PRO_ITEMS, true); enableAmlodTheme(); @@ -361,4 +374,8 @@ public static void setProItems() { public static boolean isProEnabled() { return PrefHelper.getBoolean(PRO_ITEMS); } + + public static boolean hasSupported() { + return isProEnabled() || isAmlodEnabled() || isBluishEnabled(); + } } diff --git a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationJobService.java similarity index 98% rename from app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java rename to app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationJobService.java index 2833b445e..c20167cc7 100644 --- a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java +++ b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationJobService.java @@ -50,7 +50,7 @@ * Created by Kosh on 19 Feb 2017, 6:32 PM */ -public class NotificationSchedulerJobTask extends GcmTaskService { +public class NotificationJobService extends GcmTaskService { private final static String JOB_ID = "fasthub_notification"; private final static int THIRTY_MINUTES = 30 * 60; @@ -65,9 +65,9 @@ public static void scheduleJob(@NonNull Context context, int duration, boolean c Single.create(singleEmitter -> { if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS) { GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(context); - if (cancel) gcmNetworkManager.cancelAllTasks(NotificationSchedulerJobTask.class); + if (cancel) gcmNetworkManager.cancelAllTasks(NotificationJobService.class); if (duration == -1) { - gcmNetworkManager.cancelAllTasks(NotificationSchedulerJobTask.class); + gcmNetworkManager.cancelAllTasks(NotificationJobService.class); return; } final long finalDuration = duration <= 0 ? THIRTY_MINUTES : duration; @@ -79,7 +79,7 @@ public static void scheduleJob(@NonNull Context context, int duration, boolean c .setRequiredNetwork(PeriodicTask.NETWORK_STATE_ANY) .setPeriod(finalDuration) .setFlex(finalDuration) - .setService(NotificationSchedulerJobTask.class) + .setService(NotificationJobService.class) .build(); gcmNetworkManager.schedule(task); singleEmitter.onSuccess(true); diff --git a/app/src/main/java/com/fastaccess/provider/theme/ThemeEngine.kt b/app/src/main/java/com/fastaccess/provider/theme/ThemeEngine.kt index cb43f3d96..219d0c184 100644 --- a/app/src/main/java/com/fastaccess/provider/theme/ThemeEngine.kt +++ b/app/src/main/java/com/fastaccess/provider/theme/ThemeEngine.kt @@ -3,8 +3,10 @@ package com.fastaccess.provider.theme import android.app.ActivityManager import android.graphics.BitmapFactory import android.support.annotation.StyleRes +import com.danielstone.materialaboutlibrary.MaterialAboutActivity import com.fastaccess.R +import com.fastaccess.helper.Logger import com.fastaccess.helper.PrefGetter import com.fastaccess.helper.ViewHelper import com.fastaccess.ui.base.BaseActivity @@ -28,7 +30,25 @@ object ThemeEngine { BitmapFactory.decodeResource(activity.getResources(), R.mipmap.ic_launcher), ViewHelper.getPrimaryColor(activity))) } + fun applyForAbout(activity: MaterialAboutActivity) { + val themeMode = PrefGetter.getThemeType(activity) + if (themeMode == PrefGetter.LIGHT) { + activity.setTheme(R.style.AppTheme_AboutActivity_Light) + } else if (themeMode == PrefGetter.DARK) { + activity.setTheme(R.style.AppTheme_AboutActivity_Dark) + } else if (themeMode == PrefGetter.AMLOD) { + activity.setTheme(R.style.AppTheme_AboutActivity_Amlod) + } else if (themeMode == PrefGetter.MID_NIGHT_BLUE) { + activity.setTheme(R.style.AppTheme_AboutActivity_MidNightBlue) + } else if (themeMode == PrefGetter.BLUISH) { + activity.setTheme(R.style.AppTheme_AboutActivity_Bluish) + } + activity.setTaskDescription(ActivityManager.TaskDescription(activity.getString(R.string.app_name), + BitmapFactory.decodeResource(activity.resources, R.mipmap.ic_launcher), ViewHelper.getPrimaryColor(activity))) + } + @StyleRes fun getTheme(themeMode: Int, themeColor: Int): Int { + Logger.e(themeMode, themeColor) // I wish if I could simplify this :'( too many cases for the love of god. if (themeMode == PrefGetter.LIGHT) { when (themeColor) { @@ -107,6 +127,25 @@ object ThemeEngine { PrefGetter.DEEP_ORANGE -> return R.style.ThemeMidNighBlue_DeepOrange else -> return R.style.ThemeMidNighBlue } + } else if (themeMode == PrefGetter.BLUISH) { + when (themeColor) { + PrefGetter.RED -> return R.style.ThemeBluish_Red + PrefGetter.PINK -> return R.style.ThemeBluish_Pink + PrefGetter.PURPLE -> return R.style.ThemeBluish_Purple + PrefGetter.DEEP_PURPLE -> return R.style.ThemeBluish_DeepPurple + PrefGetter.INDIGO -> return R.style.ThemeBluish_Indigo + PrefGetter.BLUE -> return R.style.ThemeBluish + PrefGetter.LIGHT_BLUE -> return R.style.ThemeBluish_LightBlue + PrefGetter.CYAN -> return R.style.ThemeBluish_Cyan + PrefGetter.TEAL, PrefGetter.GREEN -> return R.style.ThemeBluish_Green + PrefGetter.LIGHT_GREEN -> return R.style.ThemeBluish_LightGreen + PrefGetter.LIME -> return R.style.ThemeBluish_Lime + PrefGetter.YELLOW -> return R.style.ThemeBluish_Yellow + PrefGetter.AMBER -> return R.style.ThemeBluish_Amber + PrefGetter.ORANGE -> return R.style.ThemeBluish_Orange + PrefGetter.DEEP_ORANGE -> return R.style.ThemeBluish_DeepOrange + else -> return R.style.ThemeBluish + } } return R.style.ThemeLight } diff --git a/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java b/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java index 6c57e5e9b..e22dfaaec 100644 --- a/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java +++ b/app/src/main/java/com/fastaccess/provider/timeline/HtmlHelper.java @@ -55,9 +55,7 @@ private static void registerClickEvent(@NonNull TextView textView) { private static HtmlSpanner initHtml(@NonNull TextView textView) { @PrefGetter.ThemeType int theme = PrefGetter.getThemeType(); - @ColorInt int windowBackground = theme == PrefGetter.DARK ? ViewHelper.getWindowBackground(textView.getContext()) : - theme == PrefGetter.LIGHT ? ContextCompat.getColor(textView.getContext(), R.color.light_patch_ref_color) : - Color.LTGRAY; + @ColorInt int windowBackground = getWindowBackground(theme); Drawable checked = ContextCompat.getDrawable(textView.getContext(), R.drawable.ic_checkbox_small); Drawable unchecked = ContextCompat.getDrawable(textView.getContext(), R.drawable.ic_checkbox_empty_small); HtmlSpanner mySpanner = new HtmlSpanner(); @@ -92,6 +90,19 @@ private static HtmlSpanner initHtml(@NonNull TextView textView) { return mySpanner; } + @ColorInt private static int getWindowBackground(@PrefGetter.ThemeType int theme) { + switch (theme) { + case PrefGetter.AMLOD: + return Color.parseColor("#0B162A"); + case PrefGetter.BLUISH: + return Color.parseColor("#111C2C"); + case PrefGetter.DARK: + return Color.parseColor("#22252A"); + default: + return Color.parseColor("#EEEEEE"); + } + } + private static final String TOGGLE_START = ""; private static final String TOGGLE_END = ""; diff --git a/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java b/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java index 737feab3f..e1f40a747 100644 --- a/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java +++ b/app/src/main/java/com/fastaccess/provider/timeline/handler/PreTagHandler.java @@ -80,8 +80,6 @@ private String replace(String text) { builder.setSpan(new BackgroundColorSpan(color), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); if (theme == PrefGetter.LIGHT) { builder.setSpan(new ForegroundColorSpan(Color.RED), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); - } else if (theme == PrefGetter.AMLOD) { - builder.setSpan(new ForegroundColorSpan(Color.BLUE), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); } builder.setSpan(new TypefaceSpan("monospace"), stringStart, stringEnd, SPAN_EXCLUSIVE_EXCLUSIVE); } diff --git a/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java b/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java index 2c148cfc0..bfd2b5458 100644 --- a/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java +++ b/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java @@ -452,8 +452,7 @@ protected void setupNavigationView(@Nullable NavigationView extraNav) { view.findViewById(R.id.email).setVisibility(View.GONE); } view.findViewById(R.id.userHolder).setOnClickListener(v -> UserPagerActivity.startActivity(this, userModel.getLogin())); - view.findViewById(R.id.donatedIcon).setVisibility(PrefGetter.isProEnabled() || PrefGetter.isAmlodEnabled() - ? View.VISIBLE : View.GONE); + view.findViewById(R.id.donatedIcon).setVisibility(PrefGetter.hasSupported() ? View.VISIBLE : View.GONE); } } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/about/FastHubAboutActivity.java b/app/src/main/java/com/fastaccess/ui/modules/about/FastHubAboutActivity.java index 785a54d69..91cc4b960 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/about/FastHubAboutActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/about/FastHubAboutActivity.java @@ -3,6 +3,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.view.MenuItem; @@ -19,8 +20,8 @@ import com.fastaccess.helper.ActivityHelper; import com.fastaccess.helper.AppHelper; import com.fastaccess.helper.BundleConstant; -import com.fastaccess.helper.PrefGetter; import com.fastaccess.provider.tasks.version.CheckVersionService; +import com.fastaccess.provider.theme.ThemeEngine; import com.fastaccess.ui.modules.changelog.ChangelogBottomSheetDialog; import com.fastaccess.ui.modules.repos.RepoPagerActivity; import com.fastaccess.ui.modules.repos.issues.create.CreateIssueActivity; @@ -39,21 +40,12 @@ public class FastHubAboutActivity extends MaterialAboutActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { - int themeMode = PrefGetter.getThemeType(getApplicationContext()); - if (themeMode == PrefGetter.LIGHT) { - setTheme(R.style.AppTheme_AboutActivity_Light); - } else if (themeMode == PrefGetter.DARK) { - setTheme(R.style.AppTheme_AboutActivity_Dark); - } else if (themeMode == PrefGetter.AMLOD) { - setTheme(R.style.AppTheme_AboutActivity_Amlod); - } else if (themeMode == PrefGetter.MID_NIGHT_BLUE) { - setTheme(R.style.AppTheme_AboutActivity_MidNightBlue); - } + ThemeEngine.INSTANCE.applyForAbout(this); super.onCreate(savedInstanceState); malRecyclerview = findViewById(R.id.mal_recyclerview); } - @Override protected MaterialAboutList getMaterialAboutList(Context context) { + @NonNull @Override protected MaterialAboutList getMaterialAboutList(@NonNull Context context) { MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder(); buildApp(context, appCardBuilder); MaterialAboutCard.Builder miscCardBuilder = new MaterialAboutCard.Builder(); @@ -88,17 +80,17 @@ private void buildLogo(Context context, MaterialAboutCard.Builder logoAuthor) { logoAuthor.addItem(new MaterialAboutActionItem.Builder() .text(R.string.google_plus) .icon(ContextCompat.getDrawable(context, R.drawable.ic_profile)) - .setOnClickListener(b -> ActivityHelper.startCustomTab(this, "https://plus.google.com/+KevinAguilarC")) + .setOnClickAction(() -> ActivityHelper.startCustomTab(this, "https://plus.google.com/+KevinAguilarC")) .build()) .addItem(new MaterialAboutActionItem.Builder() .text(R.string.twitter) .icon(ContextCompat.getDrawable(context, R.drawable.ic_profile)) - .setOnClickListener(b -> ActivityHelper.startCustomTab(this, "https://twitter.com/kevttob")) + .setOnClickAction(() -> ActivityHelper.startCustomTab(this, "https://twitter.com/kevttob")) .build()) .addItem(new MaterialAboutActionItem.Builder() .text(R.string.website) .icon(ContextCompat.getDrawable(context, R.drawable.ic_brower)) - .setOnClickListener(b -> ActivityHelper.startCustomTab(this, "https://www.221pixels.com/")) + .setOnClickAction(() -> ActivityHelper.startCustomTab(this, "https://www.221pixels.com/")) .build()); } @@ -108,12 +100,12 @@ private void buildAuthor(Context context, MaterialAboutCard.Builder authorCardBu .text("Kosh Sergani") .subText("k0shk0sh") .icon(ContextCompat.getDrawable(context, R.drawable.ic_profile)) - .setOnClickListener(b -> UserPagerActivity.startActivity(context, "k0shk0sh")) + .setOnClickAction(() -> UserPagerActivity.startActivity(context, "k0shk0sh")) .build()) .addItem(new MaterialAboutActionItem.Builder() .text(R.string.fork_github) .icon(ContextCompat.getDrawable(context, R.drawable.ic_github)) - .setOnClickListener(b -> startActivity(RepoPagerActivity.createIntent(this, "FastHub", "k0shk0sh"))) + .setOnClickAction(() -> startActivity(RepoPagerActivity.createIntent(this, "FastHub", "k0shk0sh"))) .build()) .addItem(ConvenienceBuilder.createEmailItem(context, ContextCompat.getDrawable(context, R.drawable.ic_email), getString(R.string.send_email), true, getString(R.string.email_address), getString(R.string.question_concerning_fasthub))); @@ -124,17 +116,17 @@ private void buildMisc(Context context, MaterialAboutCard.Builder miscCardBuilde .addItem(new MaterialAboutActionItem.Builder() .text(R.string.changelog) .icon(ContextCompat.getDrawable(context, R.drawable.ic_track_changes)) - .setOnClickListener(b -> new ChangelogBottomSheetDialog().show(getSupportFragmentManager(), "ChangelogBottomSheetDialog")) + .setOnClickAction(() -> new ChangelogBottomSheetDialog().show(getSupportFragmentManager(), "ChangelogBottomSheetDialog")) .build()) .addItem(new MaterialAboutActionItem.Builder() .text(R.string.join_slack) .icon(ContextCompat.getDrawable(context, R.drawable.ic_slack)) - .setOnClickListener(b -> ActivityHelper.startCustomTab(this, "http://rebrand.ly/fasthub")) + .setOnClickAction(() -> ActivityHelper.startCustomTab(this, "http://rebrand.ly/fasthub")) .build()) .addItem(new MaterialAboutActionItem.Builder() .text(R.string.open_source_libs) .icon(ContextCompat.getDrawable(context, R.drawable.ic_github)) - .setOnClickListener(b -> new LibsBuilder() + .setOnClickAction(() -> new LibsBuilder() .withActivityStyle(AppHelper.isNightMode(getResources()) ? Libs.ActivityStyle.DARK : Libs.ActivityStyle.LIGHT) .withAutoDetect(true) .withAboutIconShown(true) @@ -148,7 +140,7 @@ private void buildApp(Context context, MaterialAboutCard.Builder appCardBuilder) .text(getString(R.string.version)) .icon(ContextCompat.getDrawable(context, R.drawable.ic_update)) .subText(BuildConfig.VERSION_NAME) - .setOnClickListener(b -> startService(new Intent(this, CheckVersionService.class))) + .setOnClickAction(() -> startService(new Intent(this, CheckVersionService.class))) .build()) .addItem(ConvenienceBuilder.createRateActionItem(context, ContextCompat.getDrawable(context, R.drawable.ic_star_filled), getString(R.string.rate_app), null)) @@ -156,7 +148,7 @@ private void buildApp(Context context, MaterialAboutCard.Builder appCardBuilder) .text(R.string.report_issue) .subText(R.string.report_issue_here) .icon(ContextCompat.getDrawable(context, R.drawable.ic_bug)) - .setOnClickListener(b -> CreateIssueActivity.startForResult(this, CreateIssueActivity.startForResult(this), malRecyclerview)) + .setOnClickAction(() -> CreateIssueActivity.startForResult(this, CreateIssueActivity.startForResult(this), malRecyclerview)) .build()); } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java b/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java index ac0dfb025..8a2f05b50 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java @@ -103,44 +103,17 @@ public class EditorActivity extends BaseActivity 0) lastChar = charSequence.charAt(charSequence.length() - 1); - if (lastChar != 0) { - if (lastChar == '@') { - inMentionMode = editText.getSelectionEnd(); - mention.setVisibility(GONE); - listDivider.setVisibility(GONE); - return; - } else if (lastChar == ' ') - inMentionMode = -1; - else if (inMentionMode > -1) - updateMentionList(charSequence.toString().substring(inMentionMode, editText.getSelectionEnd())); - else { - String copy = editText.getText().toString().substring(0, editText.getSelectionEnd()); - String[] list = copy.split("\\s+"); - String last = list[list.length - 1]; - if (last.startsWith("@")) { - inMentionMode = copy.lastIndexOf("@") + 1; - updateMentionList(charSequence.toString().substring(inMentionMode, editText.getSelectionEnd())); - } - } - } else { - inMentionMode = -1; - } - if (inMentionMode > -1) - if (mention != null) { - mention.setVisibility(inMentionMode > 0 ? View.VISIBLE : GONE); - listDivider.setVisibility(mention.getVisibility()); - } - + mention(charSequence); } } @OnItemClick(R.id.autocomplete) void onMentionSelection(int position) { - String complete = mention.getAdapter().getItem(position).toString() + " "; - int end = editText.getSelectionEnd(); - editText.getText().replace(inMentionMode, end, complete, 0, complete.length()); - inMentionMode = -1; + try { + String complete = mention.getAdapter().getItem(position).toString() + " "; + int end = editText.getSelectionEnd(); + editText.getText().replace(inMentionMode, end, complete, 0, complete.length()); + inMentionMode = -1; + } catch (IndexOutOfBoundsException ignored) {} mention.setVisibility(GONE); listDivider.setVisibility(GONE); } @@ -374,4 +347,38 @@ private void updateMentionList(@NonNull String mentioning) { } } + private void mention(CharSequence charSequence) { + try { + char lastChar = 0; + if (charSequence.length() > 0) lastChar = charSequence.charAt(charSequence.length() - 1); + if (lastChar != 0) { + if (lastChar == '@') { + inMentionMode = editText.getSelectionEnd(); + mention.setVisibility(GONE); + listDivider.setVisibility(GONE); + return; + } else if (lastChar == ' ') + inMentionMode = -1; + else if (inMentionMode > -1) + updateMentionList(charSequence.toString().substring(inMentionMode, editText.getSelectionEnd())); + else { + String copy = editText.getText().toString().substring(0, editText.getSelectionEnd()); + String[] list = copy.split("\\s+"); + String last = list[list.length - 1]; + if (last.startsWith("@")) { + inMentionMode = copy.lastIndexOf("@") + 1; + updateMentionList(charSequence.toString().substring(inMentionMode, editText.getSelectionEnd())); + } + } + } else { + inMentionMode = -1; + } + if (inMentionMode > -1) + if (mention != null) { + mention.setVisibility(inMentionMode > 0 ? View.VISIBLE : GONE); + listDivider.setVisibility(mention.getVisibility()); + } + } catch (ArrayIndexOutOfBoundsException ignored) {} + } + } diff --git a/app/src/main/java/com/fastaccess/ui/modules/main/MainActivity.java b/app/src/main/java/com/fastaccess/ui/modules/main/MainActivity.java index 4869e4f86..1c66a6373 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/main/MainActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/main/MainActivity.java @@ -11,9 +11,11 @@ import android.view.MenuItem; import com.evernote.android.state.State; +import com.fastaccess.BuildConfig; import com.fastaccess.R; import com.fastaccess.data.dao.model.Notification; import com.fastaccess.helper.BundleConstant; +import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.TypeFaceHelper; import com.fastaccess.helper.ViewHelper; import com.fastaccess.ui.base.BaseActivity; @@ -23,6 +25,9 @@ import com.fastaccess.ui.modules.notification.NotificationActivity; import com.fastaccess.ui.modules.search.SearchActivity; import com.fastaccess.ui.modules.settings.SlackBottomSheetDialog; +import com.miguelbcr.io.rx_billing_service.RxBillingService; +import com.miguelbcr.io.rx_billing_service.entities.ProductType; +import com.miguelbcr.io.rx_billing_service.entities.Purchase; import butterknife.BindView; import butterknife.OnClick; diff --git a/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt b/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt index 4cf2f08c3..d155f6fa1 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt @@ -13,6 +13,7 @@ import com.fastaccess.ui.base.BaseActivity import com.fastaccess.ui.base.mvp.BaseMvp import com.fastaccess.ui.base.mvp.presenter.BasePresenter import com.miguelbcr.io.rx_billing_service.RxBillingService +import com.miguelbcr.io.rx_billing_service.RxBillingServiceError import com.miguelbcr.io.rx_billing_service.RxBillingServiceException import com.miguelbcr.io.rx_billing_service.entities.ProductType import com.miguelbcr.io.rx_billing_service.entities.Purchase @@ -56,20 +57,19 @@ class DonateActivity : BaseActivity PrefGetter.enableAmlodTheme() + getString(R.string.midnight_blue_theme_purchase) -> PrefGetter.enableMidNightBlueTheme() + getString(R.string.theme_bluish_purchase) -> PrefGetter.enableBluishTheme() + else -> PrefGetter.setProItems() + } + } + override fun onDestroy() { if (subscription != null && !subscription?.isDisposed!!) { subscription?.dispose() diff --git a/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonationActivity.java b/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonationActivity.java index 14df12340..c2eb8d2e9 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonationActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonationActivity.java @@ -5,10 +5,15 @@ import android.support.design.widget.AppBarLayout; import android.view.View; +import com.fastaccess.BuildConfig; import com.fastaccess.R; import com.fastaccess.helper.AnimHelper; +import com.fastaccess.helper.PrefGetter; import com.fastaccess.ui.base.BaseActivity; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; +import com.miguelbcr.io.rx_billing_service.RxBillingService; +import com.miguelbcr.io.rx_billing_service.entities.ProductType; +import com.miguelbcr.io.rx_billing_service.entities.Purchase; import net.grandcentrix.thirtyinch.TiPresenter; @@ -23,7 +28,6 @@ public class DonationActivity extends BaseActivity { @BindView(R.id.cardsHolder) View cardsHolder; @BindView(R.id.appbar) AppBarLayout appBarLayout; - @Override protected int layout() { return R.layout.support_development_layout; } @@ -43,6 +47,7 @@ public class DonationActivity extends BaseActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AnimHelper.animateVisibility(cardsHolder, true); + checkPurchase(); } @OnClick(R.id.two) public void onTwoClicked(View v) { @@ -69,4 +74,23 @@ private void onProceed(@NonNull String productKey) { DonateActivity.Companion.start(this, productKey); } + protected void checkPurchase() { + ((BasePresenter) getPresenter()).manageViewDisposable(RxBillingService.getInstance(this, BuildConfig.DEBUG) + .getPurchases(ProductType.IN_APP) + .subscribe((purchases, throwable) -> { + if (purchases != null && !purchases.isEmpty()) { + for (Purchase purchase : purchases) { + String sku = purchase.sku(); + if (sku != null) { + if (sku.equalsIgnoreCase(getString(R.string.donation_product_1))) { + PrefGetter.enableAmlodTheme(); + } else { + PrefGetter.setProItems(); + } + } + } + } + })); + } + } diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewFragment.java b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewFragment.java index 9b609ac93..f4000ca46 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewFragment.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewFragment.java @@ -238,6 +238,7 @@ public static ProfileOverviewFragment newInstance(@NonNull String login) { } @Override public void onInitContributions(boolean show) { + if (contributionView == null) return; if (show) { contributionView.onResponse(); } diff --git a/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java b/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java index 4d43ea5cc..1c90cae63 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java +++ b/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java @@ -19,7 +19,7 @@ import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.PrefHelper; -import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask; +import com.fastaccess.provider.tasks.notification.NotificationJobService; import com.fastaccess.ui.base.mvp.BaseMvp; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -106,17 +106,17 @@ public interface SettingsCallback { getPreferenceScreen().addPreference(notificationTime); getPreferenceScreen().addPreference(notificationRead); getPreferenceScreen().addPreference(notificationSound); - NotificationSchedulerJobTask.scheduleJob(App.getInstance(), + NotificationJobService.scheduleJob(App.getInstance(), PrefGetter.getNotificationTaskDuration(), true); } else { getPreferenceScreen().removePreference(notificationTime); getPreferenceScreen().removePreference(notificationRead); getPreferenceScreen().removePreference(notificationSound); - NotificationSchedulerJobTask.scheduleJob(App.getInstance(), -1, true); + NotificationJobService.scheduleJob(App.getInstance(), -1, true); } return true; } else if (preference.getKey().equalsIgnoreCase("notificationTime")) { - NotificationSchedulerJobTask.scheduleJob(App.getInstance(), + NotificationJobService.scheduleJob(App.getInstance(), PrefGetter.notificationDurationMillis((String) newValue), true); return true; } else if (preference.getKey().equalsIgnoreCase("recylerViewAnimation")) { diff --git a/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt b/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt index ae60a3d8e..6874c5e4b 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt @@ -26,6 +26,7 @@ class ThemeFragment : BaseFragment { - PrefHelper.set("appTheme", getString(R.string.light_theme_mode)) + PrefHelper.set(THEME, getString(R.string.light_theme_mode)) themeListener?.onThemeApplied() } R.style.ThemeDark -> { - PrefHelper.set("appTheme", getString(R.string.dark_theme_mode)) + PrefHelper.set(THEME, getString(R.string.dark_theme_mode)) themeListener?.onThemeApplied() } R.style.ThemeAmlod -> { if (PrefGetter.isAmlodEnabled() || PrefGetter.isProEnabled()) { - PrefHelper.set("appTheme", getString(R.string.amlod_theme_mode)) + PrefHelper.set(THEME, getString(R.string.amlod_theme_mode)) themeListener?.onThemeApplied() } else { DonateActivity.start(this, getString(R.string.amlod_theme_purchase)) } } R.style.ThemeMidNighBlue -> { - if (PrefGetter.isAmlodEnabled() || PrefGetter.isProEnabled()) { - PrefHelper.set("appTheme", getString(R.string.mid_night_blue_theme_mode)) + if (PrefGetter.isMidNightBlueThemeEnabled() || PrefGetter.isProEnabled()) { + PrefHelper.set(THEME, getString(R.string.mid_night_blue_theme_mode)) themeListener?.onThemeApplied() } else { DonateActivity.start(this, getString(R.string.midnight_blue_theme_purchase)) } } + R.style.ThemeBluish -> { + if (PrefGetter.isBluishEnabled() || PrefGetter.isProEnabled()) { + PrefHelper.set(THEME, getString(R.string.bluish_theme)) + themeListener?.onThemeApplied() + } else { + DonateActivity.start(this, getString(R.string.theme_bluish_purchase)) + } + } } } - private fun isPremiumTheme(): Boolean = theme == R.style.ThemeAmlod || theme == R.style.ThemeMidNighBlue + private fun isPremiumTheme(): Boolean = theme != R.style.ThemeLight && theme != R.style.ThemeDark } diff --git a/app/src/main/res/layouts/main_layouts/layout/filter_issues_popup.xml b/app/src/main/res/layouts/main_layouts/layout/filter_issues_popup.xml index 2858c423a..6b77bb955 100644 --- a/app/src/main/res/layouts/main_layouts/layout/filter_issues_popup.xml +++ b/app/src/main/res/layouts/main_layouts/layout/filter_issues_popup.xml @@ -12,9 +12,12 @@ android:layout_height="wrap_content" android:background="?selectableItemBackground" android:button="@color/transparent" - android:drawablePadding="12sp" + android:drawablePadding="12dp" android:drawableStart="?android:attr/listChoiceIndicatorMultiple" - android:padding="@dimen/spacing_xs_large" + android:paddingBottom="@dimen/spacing_xs_large" + android:paddingEnd="@dimen/spacing_xs_large" + android:paddingStart="@dimen/spacing_normal" + android:paddingTop="@dimen/spacing_xs_large" android:text="@string/last_updated"/> + tools:showIn="@layout/repo_pager_activity"> + tools:text="180"/> @@ -64,7 +64,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" - tools:text="100,000"/> + tools:text="1648"/> @@ -89,7 +89,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" - tools:text="100,000"/> + tools:text="197"/> @@ -101,8 +101,7 @@ android:background="?selectableItemBackgroundBorderless" android:gravity="center" android:orientation="vertical" - android:visibility="gone" - tools:visibility="visible"> + android:visibility="gone"> @@ -171,7 +172,7 @@ android:gravity="center" android:maxLength="6" android:maxLines="1" - tools:text="Apache"/> + tools:text="GPL-3."/> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 57901f410..8cef23d7e 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,5 +1,6 @@ + #00000000 #FF000000 #FFFFFF @@ -255,5 +256,4 @@ #FFFF00 #FFEA00 #FFD600 - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0ad6d289b..3caa78e31 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -54,6 +54,7 @@ Dark Theme Amlod Theme Mid Night Blue + Bluish Theme Red Pink Purple diff --git a/app/src/main/res/values/theme_amlod.xml b/app/src/main/res/values/theme_amlod.xml index f32ca071a..46aee6237 100644 --- a/app/src/main/res/values/theme_amlod.xml +++ b/app/src/main/res/values/theme_amlod.xml @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/app/src/main/res/values/theme_bluish.xml b/app/src/main/res/values/theme_bluish.xml new file mode 100644 index 000000000..68fb52e32 --- /dev/null +++ b/app/src/main/res/values/theme_bluish.xml @@ -0,0 +1,227 @@ + + + + + #111C2C + #FF2A456B + #213755 + #448AFF + + @color/bluish_background + #80949494 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/theme_dark.xml b/app/src/main/res/values/theme_dark.xml index 8985906d3..8eee44cb1 100644 --- a/app/src/main/res/values/theme_dark.xml +++ b/app/src/main/res/values/theme_dark.xml @@ -218,6 +218,7 @@ false #eee #ffe0e0e0 + #2D3035 \ No newline at end of file diff --git a/app/src/main/res/values/theme_light.xml b/app/src/main/res/values/theme_light.xml index 78e594061..0cb7941c7 100644 --- a/app/src/main/res/values/theme_light.xml +++ b/app/src/main/res/values/theme_light.xml @@ -215,6 +215,7 @@ #212121 #727272 true + @color/cardview_light_background From f442ca33e1d87ad2b5a8a35db7d142bbfb661213 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Sat, 17 Jun 2017 18:39:31 +0100 Subject: [PATCH 08/11] Added material-about-library to README.md Don't worry if you feel like it's too minor of a library to include - I don't mind. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bf6b7d87a..bfeb45639 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Ads are no longer available until further notice - [**Toasty**](https://github.com/GrenderG/Toasty) for displaying error/success messages - [**ShapedImageView**](https://github.com/gavinliu/ShapedImageView) for round avatars - [**MaterialTapTargetPrompt**](https://github.com/sjwall/MaterialTapTargetPrompt) for displaying tips throughout the app +- [**Material-About-Library**](https://github.com/daniel-stoneuk/material-about-library) for the about screen - **Fabric** analytics & crash reporting. - **Android Support Libraries**, the almighty ;-) From 5b3ee6d6bca39aedd5761bf56779f3c589898fe4 Mon Sep 17 00:00:00 2001 From: Kosh Date: Sun, 18 Jun 2017 14:04:52 +0800 Subject: [PATCH 09/11] this commit fixes br language & fixes readme links base on new readme links --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 16 +- app/src/main/java/com/fastaccess/App.java | 4 +- ...java => NotificationSchedulerJobTask.java} | 143 ++++++++---------- .../com/fastaccess/ui/base/BaseActivity.java | 6 +- .../ui/modules/repos/wiki/WikiPresenter.kt | 10 +- .../category/SettingsCategoryFragment.java | 8 +- .../pretty/helper/GithubHelper.java | 31 +++- app/src/main/res/values/arrays.xml | 2 +- 9 files changed, 114 insertions(+), 108 deletions(-) rename app/src/main/java/com/fastaccess/provider/tasks/notification/{NotificationJobService.java => NotificationSchedulerJobTask.java} (83%) diff --git a/app/build.gradle b/app/build.gradle index 749d226e1..7f8112f8a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -143,7 +143,7 @@ dependencies { implementation 'com.atlassian.commonmark:commonmark:0.9.0' implementation "com.google.firebase:firebase-messaging:${gms}" implementation "com.google.android.gms:play-services-ads:${gms}" - implementation "com.google.android.gms:play-services-gcm:${gms}" + implementation 'com.firebase:firebase-jobdispatcher:0.6.0' implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true } implementation "com.github.miguelbcr:RxBillingService:0.0.3" implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0c81f5082..84a16b1dd 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -235,13 +235,13 @@ + android:name=".provider.tasks.notification.NotificationSchedulerJobTask" + android:exported="false"> - + + @@ -259,14 +259,6 @@ android:name="io.fabric.ApiKey" android:value="6ed82b6e0756853d7d782a3f547f84f9ecba217e"/> - - - - \ No newline at end of file diff --git a/app/src/main/java/com/fastaccess/App.java b/app/src/main/java/com/fastaccess/App.java index 477a6b6fd..30451bb13 100644 --- a/app/src/main/java/com/fastaccess/App.java +++ b/app/src/main/java/com/fastaccess/App.java @@ -9,7 +9,7 @@ import com.fastaccess.helper.TypeFaceHelper; import com.fastaccess.provider.colors.ColorsProvider; import com.fastaccess.provider.emoji.EmojiManager; -import com.fastaccess.provider.tasks.notification.NotificationJobService; +import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask; import com.fastaccess.provider.uil.UILProvider; import com.miguelbcr.io.rx_billing_service.RxBillingService; @@ -55,7 +55,7 @@ private void init() { setupPreference(); UILProvider.initUIL(this); TypeFaceHelper.generateTypeface(this); - NotificationJobService.scheduleJob(this); + NotificationSchedulerJobTask.scheduleJob(this); Shortbread.create(this); EmojiManager.load(); ColorsProvider.load(); diff --git a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationJobService.java b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java similarity index 83% rename from app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationJobService.java rename to app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java index c20167cc7..cca135963 100644 --- a/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationJobService.java +++ b/app/src/main/java/com/fastaccess/provider/tasks/notification/NotificationSchedulerJobTask.java @@ -11,7 +11,6 @@ import android.support.v4.app.NotificationCompat; import android.support.v4.content.ContextCompat; import android.view.View; -import android.widget.Toast; import com.annimon.stream.Stream; import com.fastaccess.R; @@ -26,12 +25,15 @@ import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.modules.notification.NotificationActivity; -import com.google.android.gms.common.ConnectionResult; -import com.google.android.gms.common.GoogleApiAvailability; -import com.google.android.gms.gcm.GcmNetworkManager; -import com.google.android.gms.gcm.GcmTaskService; -import com.google.android.gms.gcm.PeriodicTask; -import com.google.android.gms.gcm.TaskParams; +import com.firebase.jobdispatcher.Constraint; +import com.firebase.jobdispatcher.FirebaseJobDispatcher; +import com.firebase.jobdispatcher.GooglePlayDriver; +import com.firebase.jobdispatcher.Job; +import com.firebase.jobdispatcher.JobParameters; +import com.firebase.jobdispatcher.JobService; +import com.firebase.jobdispatcher.Lifetime; +import com.firebase.jobdispatcher.RetryStrategy; +import com.firebase.jobdispatcher.Trigger; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.assist.ImageSize; @@ -40,69 +42,83 @@ import java.util.List; import io.reactivex.Observable; -import io.reactivex.Single; -import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; -import static com.google.android.gms.gcm.GcmNetworkManager.RESULT_SUCCESS; - /** * Created by Kosh on 19 Feb 2017, 6:32 PM */ -public class NotificationJobService extends GcmTaskService { +public class NotificationSchedulerJobTask extends JobService { private final static String JOB_ID = "fasthub_notification"; private final static int THIRTY_MINUTES = 30 * 60; private static final String NOTIFICATION_GROUP_ID = "FastHub"; + @Override public boolean onStartJob(JobParameters job) { + if (PrefGetter.getNotificationTaskDuration() == -1) { + scheduleJob(this, -1, false); + finishJob(job); + return true; + } + Login login = null; + try { + login = Login.getUser(); + } catch (Exception ignored) {} + if (login != null) { + RestProvider.getNotificationService() + .getNotifications(ParseDateFormat.getLastWeekDate()) + .subscribeOn(Schedulers.io()) + .subscribe(item -> { + AppHelper.cancelAllNotifications(getApplicationContext()); + if (item != null) { + onSave(item.getItems(), job); + } else { + finishJob(job); + } + }, throwable -> jobFinished(job, true)); + } else { + finishJob(job); + } + return true; + } + + @Override public boolean onStopJob(JobParameters jobParameters) { + return false; + } + public static void scheduleJob(@NonNull Context context) { int duration = PrefGetter.getNotificationTaskDuration(); scheduleJob(context, duration, false); } public static void scheduleJob(@NonNull Context context, int duration, boolean cancel) { - Single.create(singleEmitter -> { - if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS) { - GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(context); - if (cancel) gcmNetworkManager.cancelAllTasks(NotificationJobService.class); - if (duration == -1) { - gcmNetworkManager.cancelAllTasks(NotificationJobService.class); - return; - } - final long finalDuration = duration <= 0 ? THIRTY_MINUTES : duration; - PeriodicTask task = new PeriodicTask.Builder() - .setTag(JOB_ID) - .setUpdateCurrent(true) - .setPersisted(true) - .setRequiresCharging(false) - .setRequiredNetwork(PeriodicTask.NETWORK_STATE_ANY) - .setPeriod(finalDuration) - .setFlex(finalDuration) - .setService(NotificationJobService.class) - .build(); - gcmNetworkManager.schedule(task); - singleEmitter.onSuccess(true); - } - singleEmitter.onSuccess(false); - }) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(o -> { - if (!o) { - Toast.makeText(context, "No Google API Service", Toast.LENGTH_SHORT).show(); - } - }, Throwable::printStackTrace); + FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context)); + if (cancel) dispatcher.cancel(JOB_ID); + if (duration == -1) { + dispatcher.cancel(JOB_ID); + return; + } + duration = duration <= 0 ? THIRTY_MINUTES : duration; + Job.Builder builder = dispatcher + .newJobBuilder() + .setTag(JOB_ID) + .setRetryStrategy(RetryStrategy.DEFAULT_LINEAR) + .setLifetime(Lifetime.FOREVER) + .setRecurring(true) + .setConstraints(Constraint.ON_ANY_NETWORK) + .setTrigger(Trigger.executionWindow(10, duration)) + .setService(NotificationSchedulerJobTask.class); + dispatcher.mustSchedule(builder.build()); } - private void onSave(@Nullable List notificationThreadModels, TaskParams job) { + private void onSave(@Nullable List notificationThreadModels, JobParameters job) { if (notificationThreadModels != null) { RxHelper.safeObservable(Notification.save(notificationThreadModels)).subscribe(notification -> {/**/}, Throwable::printStackTrace); onNotifyUser(notificationThreadModels, job); } } - private void onNotifyUser(@NonNull List notificationThreadModels, TaskParams job) { + private void onNotifyUser(@NonNull List notificationThreadModels, JobParameters job) { long count = Stream.of(notificationThreadModels) .filter(Notification::isUnread) .count(); @@ -155,7 +171,9 @@ private void onNotifyUser(@NonNull List notificationThreadModels, }); } - private void finishJob(TaskParams job) {} + private void finishJob(JobParameters job) { + jobFinished(job, false); + } private void showNotificationWithoutComment(Context context, int accentColor, Notification thread, String iconUrl) { if (!InputHelper.isEmpty(iconUrl)) { @@ -281,39 +299,6 @@ private PendingIntent getPendingIntent(long id, @NonNull String url) { PendingIntent.FLAG_UPDATE_CURRENT); } - @Override public int onRunTask(TaskParams job) { - if (PrefGetter.getNotificationTaskDuration() == -1) { - scheduleJob(this, -1, false); - finishJob(job); - return RESULT_SUCCESS; - } - Login login = null; - try { - login = Login.getUser(); - } catch (Exception ignored) {} - if (login != null) { - RestProvider.getNotificationService() - .getNotifications(ParseDateFormat.getLastWeekDate()) - .subscribeOn(Schedulers.io()) - .subscribe(item -> { - AppHelper.cancelAllNotifications(getApplicationContext()); - if (item != null) { - onSave(item.getItems(), job); - } else { - finishJob(job); - } - }, Throwable::printStackTrace); - } else { - finishJob(job); - } - return RESULT_SUCCESS; - } - - @Override public void onInitializeTasks() { - super.onInitializeTasks(); - scheduleJob(this); - } - private static class CustomNotificationModel { public String url; public Notification notification; diff --git a/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java b/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java index bfd2b5458..9e198ae01 100644 --- a/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java +++ b/app/src/main/java/com/fastaccess/ui/base/BaseActivity.java @@ -293,9 +293,9 @@ public abstract class BaseActivity(), WikiMvp.Presenter { if (bottomRightBar.isNotEmpty()) { bottomRightBar.remove() } + val headerHtml = wikiWrapper.select(".gh-header") + val revision = headerHtml.select("a.history") + if (revision.isNotEmpty()) { + revision.remove() + } + val header = headerHtml.html() + "

" val wikiContent = wikiWrapper.select(".wiki-content") - val content = wikiContent.select(".markdown-body").html() + val content = header + wikiContent.select(".markdown-body").html() val rightBarList = wikiContent.select(".wiki-pages").select("li") val sidebarList = arrayListOf() if (rightBarList.isNotEmpty()) { @@ -63,6 +69,8 @@ class WikiPresenter : BasePresenter(), WikiMvp.Presenter { } } s.onNext(WikiContentModel(content, "", sidebarList)) + } else { + s.onNext(WikiContentModel("

No Wiki

", "", arrayListOf())) } s.onComplete() } diff --git a/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java b/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java index 1c90cae63..4d43ea5cc 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java +++ b/app/src/main/java/com/fastaccess/ui/modules/settings/category/SettingsCategoryFragment.java @@ -19,7 +19,7 @@ import com.fastaccess.helper.InputHelper; import com.fastaccess.helper.PrefGetter; import com.fastaccess.helper.PrefHelper; -import com.fastaccess.provider.tasks.notification.NotificationJobService; +import com.fastaccess.provider.tasks.notification.NotificationSchedulerJobTask; import com.fastaccess.ui.base.mvp.BaseMvp; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -106,17 +106,17 @@ public interface SettingsCallback { getPreferenceScreen().addPreference(notificationTime); getPreferenceScreen().addPreference(notificationRead); getPreferenceScreen().addPreference(notificationSound); - NotificationJobService.scheduleJob(App.getInstance(), + NotificationSchedulerJobTask.scheduleJob(App.getInstance(), PrefGetter.getNotificationTaskDuration(), true); } else { getPreferenceScreen().removePreference(notificationTime); getPreferenceScreen().removePreference(notificationRead); getPreferenceScreen().removePreference(notificationSound); - NotificationJobService.scheduleJob(App.getInstance(), -1, true); + NotificationSchedulerJobTask.scheduleJob(App.getInstance(), -1, true); } return true; } else if (preference.getKey().equalsIgnoreCase("notificationTime")) { - NotificationJobService.scheduleJob(App.getInstance(), + NotificationSchedulerJobTask.scheduleJob(App.getInstance(), PrefGetter.notificationDurationMillis((String) newValue), true); return true; } else if (preference.getKey().equalsIgnoreCase("recylerViewAnimation")) { diff --git a/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java b/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java index 68b9191b6..0c27bc17f 100755 --- a/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java +++ b/app/src/main/java/com/prettifier/pretty/helper/GithubHelper.java @@ -65,11 +65,24 @@ public class GithubHelper { continue; } String link; - if (!InputHelper.isEmpty(MimeTypeMap.getFileExtensionFromUrl(href))) { - link = "https://raw.githubusercontent.com/" + owner + "/" + repoName + "/master/" + href; //assuming always master is bad :'( + if (href.startsWith("/" + owner + "/" + repoName)) { + if (!InputHelper.isEmpty(MimeTypeMap.getFileExtensionFromUrl(href))) { + link = ("https://raw.githubusercontent.com/" + href) + .replace("blob/", "master/") + .replaceAll("//", "/"); + } else { + String formattedLink = href.replaceFirst("./", "/"); + link = "https://api.github.com/repos/" + formattedLink + .replace("blob/", "master/") + .replaceAll("//", "/"); + } } else { - String formattedLink = href.replaceFirst("./", "/"); - link = ("https://api.github.com/repos/" + owner + "/" + repoName + formattedLink).replaceAll("//", "/"); + if (!InputHelper.isEmpty(MimeTypeMap.getFileExtensionFromUrl(href))) { + link = "https://raw.githubusercontent.com/" + owner + "/" + repoName + "/master/" + href; //assuming always master is bad :'( + } else { + String formattedLink = href.replaceFirst("./", "/"); + link = ("https://api.github.com/repos/" + owner + "/" + repoName + formattedLink).replaceAll("//", "/"); + } } source = source.replace("href=\"" + href + "\"", "href=\"" + link + "\""); } @@ -101,7 +114,7 @@ public class GithubHelper { @NonNull private static String getCodeStyle(@NonNull Context context, boolean isDark) { if (!isDark) return ""; - String primaryColor = "#" + Integer.toHexString(ViewHelper.getPrimaryColor(context)).substring(2).toUpperCase(); + String primaryColor = getCodeBackgroundColor(context); String accentColor = "#" + Integer.toHexString(ViewHelper.getAccentColor(context)).substring(2).toUpperCase(); Logger.e(primaryColor, accentColor); return ""; } + @NonNull private static String getCodeBackgroundColor(@NonNull Context context) { + @PrefGetter.ThemeType int themeType = PrefGetter.getThemeType(); + if (themeType == PrefGetter.BLUISH) { + return "#" + Integer.toHexString(ViewHelper.getPrimaryDarkColor(context)).substring(2).toUpperCase(); + } + return "#" + Integer.toHexString(ViewHelper.getPrimaryColor(context)).substring(2).toUpperCase(); + } + } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 2683d508e..e83778d22 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -139,7 +139,7 @@ it ja lt - br + pt-rBR From 5e1fcc484b3d53efbf5b90243f2eacc25bb6a2ed Mon Sep 17 00:00:00 2001 From: Kosh Date: Sun, 18 Jun 2017 17:41:08 +0800 Subject: [PATCH 10/11] released 3.2.0 --- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 4 +- app/src/main/assets/md/github.css | 6 +++ app/src/main/assets/md/github_dark.css | 6 +++ .../provider/rest/RestProvider.java | 9 +++- .../viewholder/PullStatusViewHolder.java | 16 +++++-- .../changelog/ChangelogBottomSheetDialog.java | 3 +- .../ui/modules/editor/EditorActivity.java | 9 ++-- .../ui/modules/login/LoginActivity.java | 1 + .../modules/main/donation/DonateActivity.kt | 8 +++- .../ui/modules/repos/wiki/WikiActivity.kt | 6 ++- .../ui/modules/repos/wiki/WikiPresenter.kt | 6 ++- .../ui/modules/search/SearchActivity.java | 14 ++---- .../modules/theme/fragment/ThemeFragment.kt | 29 ++++++----- .../ui/widgets/dialog/MessageDialogView.java | 2 +- .../prettifier/pretty/PrettifyWebView.java | 6 ++- app/src/main/res/raw/changelog.html | 48 ++++++++----------- 17 files changed, 103 insertions(+), 74 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7f8112f8a..8e90381bf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,8 +28,8 @@ android { applicationId "com.fastaccess.github" minSdkVersion 21 targetSdkVersion 26 - versionCode 310 - versionName "3.1.0" + versionCode 320 + versionName "3.2.0" signingConfig signingConfigs.signing buildConfigString "GITHUB_CLIENT_ID", (buildProperties.secrets['github_client_id'] | buildProperties.notThere['github_client_id']).string buildConfigString "GITHUB_SECRET", (buildProperties.secrets['github_secret'] | buildProperties.notThere['github_secret']).string diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 84a16b1dd..34fa636d5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -195,10 +195,10 @@ + android:parentActivityName=".ui.modules.repos.RepoPagerActivity"> + android:value=".ui.modules.repos.RepoPagerActivity"/> statusesModel.getState() != null) - .forEach(statusesModel -> builder - .append(ContextCompat.getDrawable(statuses.getContext(), statusesModel.getState().getDrawableRes())) - .append(" ") - .url(statusesModel.getDescription(), v -> SchemeParser.launchUri(v.getContext(), Uri.parse(statusesModel.getTargetUrl()))) - .append("\n")); + .forEach(statusesModel -> { + builder.append(ContextCompat.getDrawable(statuses.getContext(), statusesModel.getState().getDrawableRes())); + if (!InputHelper.isEmpty(statusesModel.getTargetUrl())) { + builder.append(" ") + .url(statusesModel.getDescription(), v -> SchemeParser.launchUri(v.getContext(), + Uri.parse(statusesModel.getTargetUrl()))) + .append("\n"); + } else { + builder.append("\n"); + } + }); if (!InputHelper.isEmpty(builder)) { statuses.setMovementMethod(LinkMovementMethod.getInstance()); statuses.setText(builder); diff --git a/app/src/main/java/com/fastaccess/ui/modules/changelog/ChangelogBottomSheetDialog.java b/app/src/main/java/com/fastaccess/ui/modules/changelog/ChangelogBottomSheetDialog.java index a91ca3eaa..c88089a79 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/changelog/ChangelogBottomSheetDialog.java +++ b/app/src/main/java/com/fastaccess/ui/modules/changelog/ChangelogBottomSheetDialog.java @@ -62,11 +62,12 @@ public class ChangelogBottomSheetDialog extends BaseMvpBottomSheetDialogFragment } private void showChangelog(String html) { + if (prettifyWebView == null) return; webProgress.setVisibility(View.GONE); if (html != null) { message.setVisibility(View.GONE); prettifyWebView.setVisibility(View.VISIBLE); - prettifyWebView.setGithubContent(html, null); + prettifyWebView.setGithubContent(html, null, false, false); prettifyWebView.setNestedScrollingEnabled(false); } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java b/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java index 8a2f05b50..97674252c 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/editor/EditorActivity.java @@ -113,7 +113,7 @@ public class EditorActivity extends BaseActivity adapter = new ArrayAdapter(this, - android.R.layout.simple_list_item_1, android.R.id.text1, mentions.subList(0, Math.min(mentions.size(), 3))); - + ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, + android.R.id.text1, mentions.subList(0, Math.min(mentions.size(), 3))); mention.setAdapter(adapter); Log.d(getLoggingTag(), mentions.toString()); } @@ -378,7 +377,7 @@ else if (inMentionMode > -1) mention.setVisibility(inMentionMode > 0 ? View.VISIBLE : GONE); listDivider.setVisibility(mention.getVisibility()); } - } catch (ArrayIndexOutOfBoundsException ignored) {} + } catch (Exception ignored) {} } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/login/LoginActivity.java b/app/src/main/java/com/fastaccess/ui/modules/login/LoginActivity.java index 63e341242..6c56044cb 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/login/LoginActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/login/LoginActivity.java @@ -206,6 +206,7 @@ public static void start(@NonNull Activity activity, boolean isBasicAuth) { @Override public void onBackPressed() { if (!(this instanceof LoginChooserActivity)) { startActivity(new Intent(this, LoginChooserActivity.class)); + finish(); } else { finish(); } diff --git a/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt b/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt index d155f6fa1..9bb0adda8 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/main/donation/DonateActivity.kt @@ -58,13 +58,17 @@ class DonateActivity : BaseActivity(), WikiMvp.View { return true } android.R.id.home -> { - startActivity(Intent(this, MainActivity::class.java)) + if (!presenter.login.isNullOrEmpty() && !presenter.repoId.isNullOrEmpty()) { + startActivity(RepoPagerActivity.createIntent(this, presenter.repoId!!, presenter.login!!)) + } finish() return true } diff --git a/app/src/main/java/com/fastaccess/ui/modules/repos/wiki/WikiPresenter.kt b/app/src/main/java/com/fastaccess/ui/modules/repos/wiki/WikiPresenter.kt index a933d3f40..30a9408ec 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/repos/wiki/WikiPresenter.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/repos/wiki/WikiPresenter.kt @@ -4,6 +4,7 @@ import android.content.Intent import com.fastaccess.data.dao.wiki.WikiContentModel import com.fastaccess.data.dao.wiki.WikiSideBarModel import com.fastaccess.helper.BundleConstant +import com.fastaccess.helper.Logger import com.fastaccess.helper.RxHelper import com.fastaccess.provider.rest.jsoup.JsoupProvider import com.fastaccess.ui.base.mvp.presenter.BasePresenter @@ -51,12 +52,12 @@ class WikiPresenter : BasePresenter(), WikiMvp.Presenter { if (bottomRightBar.isNotEmpty()) { bottomRightBar.remove() } - val headerHtml = wikiWrapper.select(".gh-header") + val headerHtml = wikiWrapper.select(".gh-header .gh-header-meta") val revision = headerHtml.select("a.history") if (revision.isNotEmpty()) { revision.remove() } - val header = headerHtml.html() + "

" + val header = "
${headerHtml.html()}
" val wikiContent = wikiWrapper.select(".wiki-content") val content = header + wikiContent.select(".markdown-body").html() val rightBarList = wikiContent.select(".wiki-pages").select("li") @@ -68,6 +69,7 @@ class WikiPresenter : BasePresenter(), WikiMvp.Presenter { sidebarList.add(WikiSideBarModel(sidebarTitle, sidebarLink)) } } + Logger.d(header) s.onNext(WikiContentModel(content, "", sidebarList)) } else { s.onNext(WikiContentModel("

No Wiki

", "", arrayListOf())) diff --git a/app/src/main/java/com/fastaccess/ui/modules/search/SearchActivity.java b/app/src/main/java/com/fastaccess/ui/modules/search/SearchActivity.java index b68900d62..3b5c96977 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/search/SearchActivity.java +++ b/app/src/main/java/com/fastaccess/ui/modules/search/SearchActivity.java @@ -7,12 +7,11 @@ import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.text.Editable; -import android.view.KeyEvent; import android.view.View; -import android.view.inputmethod.EditorInfo; import android.widget.ArrayAdapter; import android.widget.TextView; +import com.evernote.android.state.State; import com.fastaccess.R; import com.fastaccess.data.dao.FragmentPagerAdapterModel; import com.fastaccess.data.dao.TabsCountStateModel; @@ -34,7 +33,6 @@ import butterknife.OnClick; import butterknife.OnEditorAction; import butterknife.OnTextChanged; -import com.evernote.android.state.State; /** * Created by Kosh on 08 Dec 2016, 8:22 PM @@ -62,13 +60,9 @@ void onTextChange(Editable s) { } } - @OnEditorAction(R.id.searchEditText) boolean onEditor(int actionId, KeyEvent keyEvent) { - if (keyEvent != null && keyEvent.getAction() == KeyEvent.KEYCODE_SEARCH) { - getPresenter().onSearchClicked(pager, searchEditText); - } else if (actionId == EditorInfo.IME_ACTION_SEARCH) { - getPresenter().onSearchClicked(pager, searchEditText); - } - return false; + @OnEditorAction(R.id.searchEditText) boolean onEditor() { + getPresenter().onSearchClicked(pager, searchEditText); + return true; } @OnClick(value = {R.id.clear}) void onClear(View view) { diff --git a/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt b/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt index 6874c5e4b..f275c278e 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt +++ b/app/src/main/java/com/fastaccess/ui/modules/theme/fragment/ThemeFragment.kt @@ -83,7 +83,14 @@ class ThemeFragment : BaseFragment setTheme(getString(R.string.amlod_theme_mode)) + getString(R.string.midnight_blue_theme_purchase) -> setTheme(getString(R.string.mid_night_blue_theme_mode)) + getString(R.string.theme_bluish_purchase) -> setTheme(getString(R.string.bluish_theme)) + } + } } } } @@ -101,33 +108,28 @@ class ThemeFragment : BaseFragment { - PrefHelper.set(THEME, getString(R.string.light_theme_mode)) - themeListener?.onThemeApplied() + setTheme(getString(R.string.light_theme_mode)) } R.style.ThemeDark -> { - PrefHelper.set(THEME, getString(R.string.dark_theme_mode)) - themeListener?.onThemeApplied() + setTheme(getString(R.string.dark_theme_mode)) } R.style.ThemeAmlod -> { if (PrefGetter.isAmlodEnabled() || PrefGetter.isProEnabled()) { - PrefHelper.set(THEME, getString(R.string.amlod_theme_mode)) - themeListener?.onThemeApplied() + setTheme(getString(R.string.amlod_theme_mode)) } else { DonateActivity.start(this, getString(R.string.amlod_theme_purchase)) } } R.style.ThemeMidNighBlue -> { if (PrefGetter.isMidNightBlueThemeEnabled() || PrefGetter.isProEnabled()) { - PrefHelper.set(THEME, getString(R.string.mid_night_blue_theme_mode)) - themeListener?.onThemeApplied() + setTheme(getString(R.string.mid_night_blue_theme_mode)) } else { DonateActivity.start(this, getString(R.string.midnight_blue_theme_purchase)) } } R.style.ThemeBluish -> { if (PrefGetter.isBluishEnabled() || PrefGetter.isProEnabled()) { - PrefHelper.set(THEME, getString(R.string.bluish_theme)) - themeListener?.onThemeApplied() + setTheme(getString(R.string.bluish_theme)) } else { DonateActivity.start(this, getString(R.string.theme_bluish_purchase)) } @@ -135,6 +137,11 @@ class ThemeFragment : BaseFragment loadDataWithBaseURL("file:///android_asset/md/", page, "text/html", "utf-8", null)); } diff --git a/app/src/main/res/raw/changelog.html b/app/src/main/res/raw/changelog.html index 10abcb92d..94e8f2995 100644 --- a/app/src/main/res/raw/changelog.html +++ b/app/src/main/res/raw/changelog.html @@ -1,40 +1,32 @@ - - - Untitled Document.md - - -

FastHub changelog -

-

Version 3.1.0 (Amlod Theme Premium) -

-

Bugs , Enhancements & New Features (3.1.0) -

+

FastHub changelog

+

Version 3.2.0 (Wiki Support)

+

Bugs , Enhancements & new Features (3.2.0)

    -
  • (New) Amlod Theme (those who has supported FastHub development will get it for free 😉 ).
  • -
  • (New) You’ll be seeing a heart next to your name in the drawer menu to indicates that you supported FastHub before.
  • -
  • (New) Repo readme header & footer now will disappear on scroll & only appear when you reach top to improve reading experience.
  • -
  • (Enhancement) Feeds now should be displaying the feed almost like GitHub website.
  • -
  • (Enhancement) Issue tab should be disabled if the Repo doesn’t have issues enabled.
  • -
  • (Enhancement) Revamp of the whole code syntax highlighting, also now the auto scrolled line number would be highlighted.
  • -
  • (Enhancement) Revamp of selecting Themes UI, now you should have proper display of what you going to see before applying the theme. -
  • -
  • (Enhancement) Display accent color theme instead of text when selecting accent color. thanks to @Dreamersoul
  • -
  • (Fix) No newline showing in wrong place. - (again) -
  • -
  • (Fix) Clicking version number now should make a proper API call to determine if there is new update for FastHub.
  • +
  • (New) Wiki Support
  • +
  • (New) Bluish Theme (Premium)
  • +
  • (New) Search Trending language
  • +
  • (New) Traditional Chinese Language support (thanks to @maple3142)
  • +
  • (New) Brazilian Portuguese language support (thanks to @caiorrs)
  • +
  • (Enhancement) Amlod Theme code highlighting
  • +
  • (Enhancement) Overall layouts improvements
  • +
  • (Enhancement) Animate Repo Header on show/hide
  • +
  • (Enhancement) About screen to follow overall selected theme
  • +
  • (Fix) Gists deeplinks
  • +
  • (Fix) Release description scrolling
  • +
  • (Fix) Filter repos for orgs shows in other tabs
  • +
  • (Fix) Readme images disappeared two days ago, due to GitHub changing implementation for relative paths!
  • +
  • (Fix) PR reviews sort order
  • +
  • (Fix) Auto scrolling line for small files may cause the file to not be scrollable
  • +
  • (Fix) Some crashes from the crash report
  • There are more stuff are not mentioned, find them out :p
  • (Fix) Lots of bug fixes

Thanks to everyone who contributed either via reporting bugs or via code contribution

-

- Thank you very much -

- +

Thank you very much

\ No newline at end of file From b0ecb5376237b9b444d86a59d4cbd80f45793e76 Mon Sep 17 00:00:00 2001 From: Caio Roberto Date: Sun, 18 Jun 2017 12:19:47 -0300 Subject: [PATCH 11/11] Fixed Typos - Translation to Brazilian Portuguese --- app/src/main/res/values-pt-rBR/strings.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 51d7ce781..5d99ec837 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -222,7 +222,7 @@ Enviar um email Problemas relacionados ao FastHub Feedback - Reportar um issue + Reportar um problema Tendo problemas? Reporte-o aqui Sobre Notificação @@ -253,7 +253,7 @@ Marcar Marcado Desmarcar - Nenhum repositório marcado, marcar alguns para vê-los aqui + Nenhum repositório marcado, marque alguns para vê-los aqui Sim Não Sem feeds @@ -335,7 +335,7 @@ Entra com autenticação básica Se você está ligado a alguma organização e não consegue vê-las aqui, por favor entre no link abaixo. \nhttps://help.github.com/articles/about-third-party-application-restrictions\nPS: Você poderia usar o token de acesso para entrar, o que vai - permitir acesso ao FastHub para poder ver a lista de seuas organizações. + permitir acesso ao FastHub para poder ver a lista de suas organizações.
Inserir Selecionar Selecionar Imagem @@ -343,7 +343,7 @@ Apoiar com $5.00 Apoiar com $10.00 Apoiar com $20.00 - Idiooma do App + Idioma do App Idioma Escolher Idioma Escolha seu idioma preferido @@ -384,7 +384,7 @@
ESCOLHER BANNER Erro ao carregar a imagem, por favor tente novamente. - Trending + Em alta Organizar por emojis ainda não está funcionando devido à limitações do GitHub Rolar para cima Rolar para baixo