Skip to content

Commit

Permalink
Update to release 1.2.8
Browse files Browse the repository at this point in the history
- Fixed #26
- Added more translation (French and Russian)
- Added share app and rate & review to navigation drawer
- Redesigned about, iconized social buttons
- Removed default font to reduce library size
  • Loading branch information
danimahardhika authored Jun 11, 2017
1 parent cceb13b commit 6520149
Show file tree
Hide file tree
Showing 55 changed files with 1,049 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -156,6 +157,7 @@ public void initMainActivity(@Nullable Bundle savedInstanceState, boolean isLice
mPosition = mLastPosition = 0;
if (savedInstanceState != null) {
mPosition = mLastPosition = savedInstanceState.getInt(Extras.EXTRA_POSITION, 0);
onSearchExpanded(false);
}

setFragment(getFragment(mPosition));
Expand Down Expand Up @@ -231,6 +233,16 @@ public void onBackPressed() {
setFragment(getFragment(mPosition));
return;
}

if (mFragmentTag.equals(Extras.TAG_WALLPAPERS)) {
Fragment fragment = mFragManager.findFragmentByTag(Extras.TAG_WALLPAPERS);
if (fragment != null) {
if (fragment instanceof WallpapersFragment) {
WallpapersFragment wallpapersFragment = (WallpapersFragment) fragment;
if (wallpapersFragment.scrollWallpapersToTop()) return;
}
}
}
super.onBackPressed();
}

Expand Down Expand Up @@ -396,6 +408,24 @@ public void onDrawerClosed(View drawerView) {
else if (id == R.id.navigation_view_settings) mPosition = 2;
else if (id == R.id.navigation_view_about) mPosition = 3;
else if (id == R.id.navigation_view_donate) mPosition = 4;
else if (id == R.id.navigation_view_share) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.share_app_subject,
getResources().getString(R.string.app_name)));
intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_app_body,
getResources().getString(R.string.app_name),
"https://play.google.com/store/apps/details?id=" +getPackageName()));
startActivity(Intent.createChooser(intent, getResources().getString(R.string.email_client)));
return false;

} else if (id == R.id.navigation_view_rate) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
"https://play.google.com/store/apps/details?id=" +getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
startActivity(intent);
return false;
}

item.setChecked(true);
mDrawerLayout.closeDrawers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.dm.wallpaper.board.fragments.dialogs.WallpaperSettingsFragment;
import com.dm.wallpaper.board.helpers.LocaleHelper;
import com.dm.wallpaper.board.helpers.TapIntroHelper;
import com.dm.wallpaper.board.helpers.TypefaceHelper;
import com.dm.wallpaper.board.helpers.ViewHelper;
import com.dm.wallpaper.board.helpers.WallpaperHelper;
import com.dm.wallpaper.board.preferences.Preferences;
Expand Down Expand Up @@ -274,7 +275,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
.autoDismiss(false)
.maxLines(4)
.fitSystemWindow()
.typeface("Font-Regular.ttf", "Font-Bold.ttf")
.typeface(TypefaceHelper.getRegular(this), TypefaceHelper.getBold(this))
.content(String.format(getResources().getString(R.string.wallpaper_download_exist),
("\"" +mName + WallpaperHelper.IMAGE_EXTENSION+ "\"")))
.icon(R.drawable.ic_toolbar_download)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.CardView;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -60,7 +61,6 @@ public class AboutAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>

private int mItemCount;

private final boolean mCardMode;
private final boolean mShowContributors;

private static final int TYPE_HEADER = 0;
Expand All @@ -72,8 +72,8 @@ public AboutAdapter(@NonNull Context context, int spanCount) {
mContext = context;

mItemCount = 2;
mCardMode = (spanCount > 1);
if (!mCardMode) {
boolean cardMode = (spanCount > 1);
if (!cardMode) {
mItemCount += 1;
}

Expand Down Expand Up @@ -148,24 +148,36 @@ public int getItemViewType(int position) {
return TYPE_BOTTOM_SHADOW;
}

class HeaderViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
class HeaderViewHolder extends RecyclerView.ViewHolder {

@BindView(R2.id.image)
ImageView image;
@BindView(R2.id.profile)
CircularImageView profile;
@BindView(R2.id.subtitle)
HtmlTextView subtitle;
@BindView(R2.id.email)
AppCompatButton email;
@BindView(R2.id.link1)
AppCompatButton link1;
@BindView(R2.id.link2)
AppCompatButton link2;

HeaderViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
RecyclerView recyclerView = ButterKnife.findById(itemView, R.id.recyclerview);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, true));
recyclerView.setHasFixedSize(true);

String[] urls = mContext.getResources().getStringArray(R.array.about_social_links);
if (urls.length == 0) {
recyclerView.setVisibility(View.GONE);

subtitle.setPadding(
subtitle.getPaddingLeft(),
subtitle.getPaddingTop(),
subtitle.getPaddingRight(),
subtitle.getPaddingBottom() + mContext.getResources().getDimensionPixelSize(R.dimen.content_margin));
} else {
recyclerView.setAdapter(new AboutSocialAdapter(mContext, urls));
}

subtitle.setHtml(mContext.getResources().getString(R.string.about_desc));

CardView card = ButterKnife.findById(itemView, R.id.card);
Expand All @@ -175,59 +187,6 @@ class HeaderViewHolder extends RecyclerView.ViewHolder implements View.OnClickLi
profile.setShadowRadius(0f);
profile.setShadowColor(Color.TRANSPARENT);
}

if (!mCardMode) {
int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
int cardColor = ColorHelper.getAttributeColor(mContext, R.attr.card_background);
email.setTextColor(ColorHelper.getTitleTextColor(accent));
link1.setTextColor(ColorHelper.getTitleTextColor(cardColor));
link2.setTextColor(ColorHelper.getTitleTextColor(cardColor));
}

String emailText = mContext.getResources().getString(R.string.about_email);
if (emailText.length() == 0) email.setVisibility(View.GONE);
String link2Text = mContext.getResources().getString(R.string.about_link_2_url);
if (link2Text.length() == 0) link2.setVisibility(View.GONE);

email.setOnClickListener(this);
link1.setOnClickListener(this);
link2.setOnClickListener(this);
}

@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.email) {
try {
final Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", mContext.getResources().getString(
R.string.about_email), null));
email.putExtra(Intent.EXTRA_SUBJECT, (mContext.getResources().getString(
R.string.app_name)));
mContext.startActivity(Intent.createChooser(email,
mContext.getResources().getString(R.string.email_client)));
return;
}
catch (ActivityNotFoundException e) {
LogUtil.e(Log.getStackTraceString(e));
}
return;
}

Intent intent = null;
if (id == R.id.link1) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
mContext.getResources().getString(R.string.about_link_1_url)));
} else if (id == R.id.link2) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
mContext.getResources().getString(R.string.about_link_2_url)));
}

try {
mContext.startActivity(intent);
} catch (NullPointerException | ActivityNotFoundException e) {
LogUtil.e(Log.getStackTraceString(e));
}
}
}

Expand Down Expand Up @@ -260,9 +219,11 @@ public void onClick(View view) {
class FooterViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

@BindView(R2.id.about_dev_github)
AppCompatButton link1;
ImageView github;
@BindView(R2.id.about_dev_google_plus)
AppCompatButton link2;
ImageView googlePlus;
@BindView(R2.id.about_dev_instagram)
ImageView instagram;
@BindView(R2.id.about_dashboard_licenses)
TextView licenses;
@BindView(R2.id.about_dashboard_contributors)
Expand All @@ -280,19 +241,17 @@ class FooterViewHolder extends RecyclerView.ViewHolder implements View.OnClickLi
}

int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
TextView title = (TextView) itemView.findViewById(R.id.about_dashboard_title);
TextView title = ButterKnife.findById(itemView, R.id.about_dashboard_title);
title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);

if (!mCardMode) {
int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
int cardColor = ColorHelper.getAttributeColor(mContext, R.attr.card_background);
link1.setTextColor(ColorHelper.getTitleTextColor(accent));
link2.setTextColor(ColorHelper.getTitleTextColor(cardColor));
}
instagram.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_instagram, color));
googlePlus.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_google_plus, color));
github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));

link1.setOnClickListener(this);
link2.setOnClickListener(this);
instagram.setOnClickListener(this);
googlePlus.setOnClickListener(this);
github.setOnClickListener(this);
licenses.setOnClickListener(this);
contributors.setOnClickListener(this);
translator.setOnClickListener(this);
Expand Down Expand Up @@ -325,6 +284,9 @@ public void onClick(View view) {
} else if (id == R.id.about_dev_github) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mContext
.getResources().getString(R.string.about_dashboard_dev_github_url)));
} else if (id == R.id.about_dev_instagram) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mContext
.getResources().getString(R.string.about_dashboard_dev_instagram_url)));
}

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.dm.wallpaper.board.adapters;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.dm.wallpaper.board.R;
import com.dm.wallpaper.board.helpers.UrlHelper;
import com.dm.wallpaper.board.utils.LogUtil;

/*
* Wallpaper Board
*
* Copyright (c) 2017 Dani Mahardhika
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

public class AboutSocialAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

private final Context mContext;
private final String[] mUrls;

public AboutSocialAdapter(@NonNull Context context, @NonNull String[] urls) {
mContext = context;
mUrls = urls;
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(
R.layout.fragment_about_item_social, parent, false);
return new SocialViewHolder(view);
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
SocialViewHolder socialViewHolder = (SocialViewHolder) holder;
UrlHelper.Type type = UrlHelper.getType(mUrls[position]);
Drawable drawable = UrlHelper.getSocialIcon(mContext, type);

if (drawable != null && type != UrlHelper.Type.INVALID) {
socialViewHolder.image.setImageDrawable(drawable);
socialViewHolder.image.setVisibility(View.VISIBLE);
} else {
socialViewHolder.image.setVisibility(View.GONE);
}
}

@Override
public int getItemCount() {
return mUrls.length;
}

private class SocialViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {

private final ImageView image;

SocialViewHolder(View itemView) {
super(itemView);
image = (ImageView) itemView.findViewById(R.id.image);

image.setOnClickListener(this);
}

@Override
public void onClick(View view) {
int id = view.getId();
int position = getAdapterPosition();
if (position < 0 || position > mUrls.length) return;

if (id == R.id.image) {
UrlHelper.Type type = UrlHelper.getType(mUrls[position]);
if (type == UrlHelper.Type.INVALID) return;

if (type == UrlHelper.Type.EMAIL) {
try {
final Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", mUrls[position], null));
email.putExtra(Intent.EXTRA_SUBJECT, (mContext.getResources().getString(
R.string.app_name)));
mContext.startActivity(Intent.createChooser(email,
mContext.getResources().getString(R.string.email_client)));
}
catch (ActivityNotFoundException e) {
LogUtil.e(Log.getStackTraceString(e));
}
return;
}

try {
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(mUrls[position])));
} catch (ActivityNotFoundException e) {
LogUtil.e(Log.getStackTraceString(e));
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.dm.wallpaper.board.R;
import com.dm.wallpaper.board.R2;
import com.dm.wallpaper.board.fragments.dialogs.LanguagesFragment;
import com.dm.wallpaper.board.helpers.TypefaceHelper;
import com.dm.wallpaper.board.items.Setting;
import com.dm.wallpaper.board.preferences.Preferences;
import com.dm.wallpaper.board.utils.LogUtil;
Expand Down Expand Up @@ -174,7 +175,7 @@ public void onClick(View view) {
switch (setting.getType()) {
case CACHE:
new MaterialDialog.Builder(mContext)
.typeface("Font-Medium.ttf", "Font-Regular.ttf")
.typeface(TypefaceHelper.getMedium(mContext), TypefaceHelper.getRegular(mContext))
.content(R.string.pref_data_cache_clear_dialog)
.positiveText(R.string.clear)
.negativeText(android.R.string.cancel)
Expand Down
Loading

0 comments on commit 6520149

Please sign in to comment.