Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Update to release 1.1.0
Browse files Browse the repository at this point in the history
- Fixed #7
- Fixed #8
- Fixed #9
- Fixed inbuilt wallpaper crop
- Fixed splash screen loading time
- Improved wallpaper preview
- Code cleanup
- Updated dependency
- Redesigned settings and about
- On API 24 (Nougat) apply wallpaper set for both home and lockscreen
  • Loading branch information
danimahardhika authored Apr 3, 2017
1 parent b017c31 commit 56517e4
Show file tree
Hide file tree
Showing 91 changed files with 2,252 additions and 1,319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
Expand All @@ -27,7 +26,6 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.graphics.drawable.DrawerArrowDrawable;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import android.webkit.URLUtil;
import android.widget.ImageView;
Expand Down Expand Up @@ -57,6 +55,7 @@
import com.dm.wallpaper.board.services.WallpaperBoardService;
import com.dm.wallpaper.board.utils.Extras;
import com.dm.wallpaper.board.utils.ImageConfig;
import com.dm.wallpaper.board.utils.LogUtil;
import com.dm.wallpaper.board.utils.listeners.InAppBillingListener;
import com.dm.wallpaper.board.utils.listeners.SearchListener;
import com.dm.wallpaper.board.utils.listeners.WallpaperBoardListener;
Expand Down Expand Up @@ -97,6 +96,8 @@ public class WallpaperBoardActivity extends AppCompatActivity implements Activit
NavigationView mNavigationView;
@BindView(R2.id.drawer_layout)
DrawerLayout mDrawerLayout;
@BindView(R2.id.appbar)
AppBarLayout mAppBar;

private BillingProcessor mBillingProcessor;
private ActionBarDrawerToggle mDrawerToggle;
Expand All @@ -119,9 +120,10 @@ public void initMainActivity(@Nullable Bundle savedInstanceState, boolean isLice
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wallpaper_board);
ButterKnife.bind(this);
ViewHelper.setApplicationWindowColor(this);

ViewHelper.resetNavigationBarTranslucent(this,
getResources().getConfiguration().orientation);
ColorHelper.setStatusBarIconColor(this);
registerBroadcastReceiver();

SoftKeyboardHelper softKeyboardHelper = new SoftKeyboardHelper(this,
Expand All @@ -133,34 +135,31 @@ public void initMainActivity(@Nullable Bundle savedInstanceState, boolean isLice
mDonationProductsId = donationProductsId;

Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
AppBarLayout appBar = ButterKnife.findById(this, R.id.appbar);
toolbar.setTitle("");

ViewHelper.setupToolbar(toolbar, true);
setSupportActionBar(toolbar);
appBar.setExpanded(false);

initNavigationView(toolbar);
initNavigationViewHeader();
initTheme();
initInAppBilling();

mPosition = mLastPosition = 0;
if (savedInstanceState != null) {
mPosition = mLastPosition = savedInstanceState.getInt("position", 0);
mPosition = mLastPosition = savedInstanceState.getInt(Extras.EXTRA_POSITION, 0);
}

setFragment(getFragment(mPosition));
checkWallpapers();

if (Preferences.getPreferences(this).isFirstRun()) {
if (isLicenseCheckerEnabled) {
LicenseHelper.getLicenseChecker(this).checkLicense(mLicenseKey, salt);
return;
}
if (Preferences.getPreferences(this).isFirstRun() && isLicenseCheckerEnabled) {
LicenseHelper.getLicenseChecker(this).checkLicense(mLicenseKey, salt);
return;
}

if (isLicenseCheckerEnabled) {
if (!Preferences.getPreferences(this).isLicensed())
finish();
checkWallpapers();

if (isLicenseCheckerEnabled && !Preferences.getPreferences(this).isLicensed()) {
finish();
}
}

Expand Down Expand Up @@ -191,12 +190,6 @@ protected void onDestroy() {
super.onDestroy();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
ViewHelper.disableAppBarDrag(ButterKnife.findById(this, R.id.appbar));
return super.onCreateOptionsMenu(menu);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Expand All @@ -215,6 +208,12 @@ public void onBackPressed() {
mDrawerLayout.closeDrawers();
return;
}

if (!mFragmentTag.equals(Extras.TAG_WALLPAPERS)) {
mPosition = mLastPosition = 0;
setFragment(getFragment(mPosition));
return;
}
super.onBackPressed();
}

Expand Down Expand Up @@ -243,8 +242,19 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}

@Override
public void OnWallpapersChecked(@Nullable Intent intent) {
public void onWallpapersChecked(@Nullable Intent intent) {
if (intent != null) {
String packageName = intent.getStringExtra("packageName");
LogUtil.d("Broadcast received from service with packageName: " +packageName);

if (packageName == null)
return;

if (!packageName.equals(getPackageName())) {
LogUtil.d("Received broadcast from different packageName, expected: " +getPackageName());
return;
}

int size = intent.getIntExtra(Extras.EXTRA_SIZE, 0);
Database database = new Database(this);
int offlineSize = database.getWallpapersCount();
Expand Down Expand Up @@ -279,18 +289,18 @@ public void OnWallpapersChecked(@Nullable Intent intent) {
}

@Override
public void OnInAppBillingInitialized(boolean success) {
public void onInAppBillingInitialized(boolean success) {
if (!success) mBillingProcessor = null;
}

@Override
public void OnInAppBillingSelected(InAppBilling product) {
public void onInAppBillingSelected(InAppBilling product) {
if (mBillingProcessor == null) return;
mBillingProcessor.purchase(this, product.getProductId());
}

@Override
public void OnInAppBillingConsume(String productId) {
public void onInAppBillingConsume(String productId) {
if (mBillingProcessor == null) return;
if (mBillingProcessor.consumePurchase(productId)) {
new MaterialDialog.Builder(this)
Expand All @@ -302,26 +312,17 @@ public void OnInAppBillingConsume(String productId) {
}

@Override
public void OnSearchExpanded(boolean expand) {
public void onSearchExpanded(boolean expand) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout)
findViewById(R.id.collapsing_toolbar);

if (expand) {
int color = ColorHelper.getAttributeColor(this, R.attr.search_toolbar_color);
ViewHelper.changeSearchViewActionModeColor(this,
collapsingToolbar, R.attr.toolbar_color, R.attr.search_toolbar_color);
ColorHelper.setStatusBarColor(this, color);

int iconColor = ColorHelper.getAttributeColor(this, R.attr.search_toolbar_icon);
int icon = ColorHelper.getAttributeColor(this, R.attr.toolbar_icon);
toolbar.setNavigationIcon(DrawableHelper.getTintedDrawable(
this, R.drawable.ic_toolbar_back, iconColor));
this, R.drawable.ic_toolbar_back, icon));
toolbar.setNavigationOnClickListener(view -> onBackPressed());
} else {
SoftKeyboardHelper.closeKeyboard(this);
ColorHelper.setTransparentStatusBar(this, Color.TRANSPARENT);
collapsingToolbar.setContentScrim(new ColorDrawable(
ColorHelper.getAttributeColor(this, R.attr.toolbar_color)));

mDrawerToggle.setDrawerArrowDrawable(new DrawerArrowDrawable(this));
toolbar.setNavigationOnClickListener(view ->
mDrawerLayout.openDrawer(GravityCompat.START));
Expand Down Expand Up @@ -367,6 +368,11 @@ public void onDrawerClosed(View drawerView) {
getResources().getBoolean(R.bool.enable_donation));
mNavigationView.setItemTextColor(colorStateList);
mNavigationView.setItemIconTintList(colorStateList);
Drawable background = ContextCompat.getDrawable(this,
Preferences.getPreferences(this).isDarkTheme() ?
R.drawable.navigation_view_item_background_dark :
R.drawable.navigation_view_item_background);
mNavigationView.setItemBackground(background);
mNavigationView.setNavigationItemSelectedListener(item -> {
int id = item.getItemId();
if (id == R.id.navigation_view_wallpapers) mPosition = 0;
Expand All @@ -381,12 +387,6 @@ public void onDrawerClosed(View drawerView) {
});
}

private void initTheme() {
getWindow().getDecorView().setBackgroundColor(
ColorHelper.getAttributeColor(this, R.attr.main_background));
ColorHelper.setStatusBarIconColor(this);
}

private void initNavigationViewHeader() {
String imageUrl = getResources().getString(R.string.navigation_view_header);
String titleText = getResources().getString(R.string.navigation_view_header_title);
Expand Down Expand Up @@ -417,7 +417,7 @@ private void initNavigationViewHeader() {
}

ImageLoader.getInstance().displayImage(imageUrl, new ImageViewAware(image),
ImageConfig.getDefaultImageOptions(true), new ImageSize(720, 720), null, null);
ImageConfig.getDefaultImageOptions(), new ImageSize(720, 720), null, null);
}

private void initInAppBilling() {
Expand Down Expand Up @@ -448,7 +448,7 @@ private void checkWallpapers() {

int size = Preferences.getPreferences(this).getAvailableWallpapersCount();
if (size > 0) {
OnWallpapersChecked(new Intent().putExtra(Extras.EXTRA_SIZE, size));
onWallpapersChecked(new Intent().putExtra(Extras.EXTRA_SIZE, size));
}
}

Expand All @@ -468,9 +468,11 @@ private void setFragment(Fragment fragment) {
if (fragment == null) return;
clearBackStack();

mAppBar.setExpanded(true);

FragmentTransaction ft = mFragManager.beginTransaction().replace(
R.id.container, fragment, mFragmentTag);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
//ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
try {
ft.commit();
} catch (Exception e) {
Expand Down Expand Up @@ -508,7 +510,7 @@ private void resetToolbarLogo() {
private void clearBackStack() {
if (mFragManager.getBackStackEntryCount() > 0) {
mFragManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
OnSearchExpanded(false);
onSearchExpanded(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void initMuzeiActivity(@Nullable Bundle savedInstanceState, @NonNull Clas
ViewCompat.setNestedScrollingEnabled(mScrollView, false);
ViewHelper.disableTranslucentNavigationBar(this);
ColorHelper.setStatusBarColor(this,
ColorHelper.getAttributeColor(this, R.attr.toolbar_color));
ColorHelper.getAttributeColor(this, R.attr.colorPrimary));
ColorHelper.setStatusBarIconColor(this);
ColorHelper.setNavigationBarColor(this, ColorHelper.getDarkerColor(
ColorHelper.getAttributeColor(this, R.attr.colorAccent), 0.8f));
Expand Down Expand Up @@ -117,8 +117,7 @@ protected void attachBaseContext(Context newBase) {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ViewHelper.resetNavigationBarBottomPadding(this, mScrollView,
getResources().getConfiguration().orientation);
ViewHelper.resetViewBottomPadding(mScrollView, false);
}

@Override
Expand Down Expand Up @@ -149,7 +148,7 @@ public void onClick(View view) {
}

@Override
public void OnRefreshDurationSet(int rotateTime, boolean isMinute) {
public void onRefreshDurationSet(int rotateTime, boolean isMinute) {
mRotateTime = rotateTime;
mIsMinute = isMinute;
initRefreshDuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.widget.TextView;

import com.danimahardhika.cafebar.CafeBar;
import com.danimahardhika.cafebar.CafeBarTheme;
import com.dm.wallpaper.board.R;
import com.dm.wallpaper.board.R2;
import com.dm.wallpaper.board.adapters.WallpapersAdapter;
Expand Down Expand Up @@ -107,15 +108,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_wallpaper_preview);
ButterKnife.bind(this);
ViewHelper.setApplicationWindowColor(this);
ViewHelper.resetNavigationBarTranslucent(this,
getResources().getConfiguration().orientation);
ViewHelper.resetViewBottomMargin(mFab);
ColorHelper.setTransparentStatusBar(this,
ContextCompat.getColor(this, R.color.wallpaperStatusBar));
mIsEnter = true;

Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
TextView toolbarTitle = ButterKnife.findById(this, R.id.toolbar_title);
TextView toolbarSubTitle = ButterKnife.findById(this, R.id.toolbar_subtitle);
ColorHelper.setTransparentStatusBar(this,
ContextCompat.getColor(this, R.color.wallpaperStatusBar));

mColor = ColorHelper.getAttributeColor(this, R.attr.colorAccent);
mProgress.getIndeterminateDrawable().setColorFilter(mColor, PorterDuff.Mode.SRC_IN);

Expand Down Expand Up @@ -159,8 +160,7 @@ public void onTransitionStart(Transition transition) {
public void onTransitionEnd(Transition transition) {
if (mIsEnter) {
mIsEnter = false;
Animator.startSlideDownAnimation(WallpaperBoardPreviewActivity.this,
toolbar, null);
Animator.startSlideDownAnimation(toolbar, View.VISIBLE);
loadWallpaper(mUrl);
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@ public void onTransitionResume(Transition transition) {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ViewHelper.resetNavigationBarTranslucent(this, newConfig.orientation);
ViewHelper.resetViewBottomMargin(mFab);
}

@Override
Expand Down Expand Up @@ -249,11 +249,10 @@ public boolean onOptionsItemSelected(MenuItem item) {

if (target.exists()) {
CafeBar.builder(this)
.to(findViewById(R.id.rootview))
.theme(new CafeBarTheme.Custom(ColorHelper.getAttributeColor(this, R.attr.card_background)))
.autoDismiss(false)
.swipeToDismiss(false)
.floating(true)
.maxLines(4)
.fitSystemWindow(true)
.content(String.format(getResources().getString(R.string.wallpaper_download_exist),
("\"" +mName + FileHelper.IMAGE_EXTENSION+ "\"")))
.icon(R.drawable.ic_toolbar_download)
Expand Down Expand Up @@ -331,7 +330,7 @@ public void onLoadingFailed(String imageUri, View view, FailReason failReason) {

int color = ColorHelper.getAttributeColor(
WallpaperBoardPreviewActivity.this, R.attr.main_background);
FrameLayout container = (FrameLayout) findViewById(R.id.container);
FrameLayout container = ButterKnife.findById(WallpaperBoardPreviewActivity.this, R.id.container);
ObjectAnimator colorFade = ObjectAnimator.ofObject(
container, "backgroundColor", new ArgbEvaluator(),
Color.TRANSPARENT, color);
Expand All @@ -353,9 +352,7 @@ public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
int color = palette.getVibrantColor(accent);
mColor = color;
int text = ColorHelper.getTitleTextColor(color);
mFab.setBackgroundTintList(ColorHelper.getColorStateList(
android.R.attr.state_pressed,
color, ColorHelper.getDarkerColor(color, 0.9f)));
mFab.setBackgroundTintList(ColorHelper.getColorStateList(color));
OnWallpaperLoaded(text);
});
}
Expand Down
Loading

0 comments on commit 56517e4

Please sign in to comment.