Skip to content

Commit

Permalink
修复文字贴纸日期生成错误
Browse files Browse the repository at this point in the history
升级编译SDK版本和BUILD版本
优化AlbumModel
解决部分机型在全屏预览图片返回到相册选择界面时状态栏闪烁的问题
优化相册UI
可配置相册页清空按钮是否显示
如果清空按钮、原图按钮、拼图按钮都不显示,则隐藏掉相册页底部操作栏中间的编辑按钮(原来的版本是设置按钮的样式)
  • Loading branch information
HuanTanSheng committed Dec 12, 2018
1 parent a39a8fe commit 500b487
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,32 @@ public AlbumBuilder setOriginalMenu(boolean isChecked, boolean usable, String un
/**
* 是否显示拼图按钮
*
* @param isShow 是否显示
* @param shouldShow 是否显示
* @return AlbumBuilder
*/
public AlbumBuilder setPuzzleMenu(boolean isShow) {
Setting.showPuzzleMenu = isShow;
public AlbumBuilder setPuzzleMenu(boolean shouldShow) {
Setting.showPuzzleMenu = shouldShow;
return AlbumBuilder.this;
}

/**
* 是否显示gif图
*
* @param isShow 是否显示
* @param shouldShow 是否显示
* @return @return AlbumBuilder
*/
public AlbumBuilder setGif(boolean isShow) {
Setting.showGif = isShow;
public AlbumBuilder setGif(boolean shouldShow) {
Setting.showGif = shouldShow;
return AlbumBuilder.this;
}

/**
* 相册选择页是否显示清空按钮
* @param shouldShow
* @return
*/
public AlbumBuilder setCleanMenu(boolean shouldShow) {
Setting.showCleanMenu = shouldShow;
return AlbumBuilder.this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Setting {
public static boolean onlyStartCamera = false;
public static boolean showPuzzleMenu = true;
public static boolean showGif = true;
public static boolean showCleanMenu = true;
public static ImageEngine imageEngine = null;


Expand All @@ -53,6 +54,7 @@ public static void clear() {
onlyStartCamera = false;
showPuzzleMenu = true;
showGif = true;
showCleanMenu = true;
}

public static boolean hasPhotosAd() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
import java.util.Date;
import java.util.Locale;

public class EasyPhotosActivity extends AppCompatActivity implements AlbumItemsAdapter.OnClickListener, PhotosAdapter.OnClickListener, AdListener, View.OnClickListener {
public class EasyPhotosActivity extends AppCompatActivity implements AlbumItemsAdapter
.OnClickListener, PhotosAdapter.OnClickListener, AdListener, View.OnClickListener {

private File mTempImageFile;

Expand Down Expand Up @@ -130,8 +131,8 @@ protected void onCreate(Bundle savedInstanceState) {
private void adaptationStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int statusColor = getWindow().getStatusBarColor();
if(statusColor == Color.TRANSPARENT){
statusColor = ContextCompat.getColor(this, R.color.colorPrimaryDark);
if (statusColor == Color.TRANSPARENT) {
statusColor = ContextCompat.getColor(this, R.color.colorPrimaryDark);
}
if (ColorUtils.isWhiteColor(statusColor)) {
SystemUtils.getInstance().setStatusDark(this, true);
Expand All @@ -144,6 +145,8 @@ private void initSomeViews() {
permissionView = (RelativeLayout) findViewById(R.id.rl_permissions_view);
tvPermission = (TextView) findViewById(R.id.tv_permission);
rootViewAlbumItems = (RelativeLayout) findViewById(R.id.root_view_album_items);
findViewById(R.id.iv_second_menu).setVisibility(Setting.showPuzzleMenu || Setting
.showCleanMenu || Setting.showOriginalMenu ? View.VISIBLE : View.GONE);
setClick(R.id.iv_back);
}

Expand Down Expand Up @@ -171,23 +174,28 @@ public void run() {
protected String[] getNeedPermissions() {
if (Setting.isShowCamera) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
return new String[]{Manifest.permission.CAMERA, Manifest.permission
.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
}
return new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
return new String[]{Manifest.permission.CAMERA, Manifest.permission
.WRITE_EXTERNAL_STORAGE};
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest
.permission.READ_EXTERNAL_STORAGE};
}
return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
}
}


@Override
public void onRequestPermissionsResult(int requestCode, @NonNull final String[] permissions, @NonNull int[] grantResults) {
public void onRequestPermissionsResult(int requestCode, @NonNull final String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

PermissionUtil.onPermissionResult(this, permissions, grantResults, new PermissionUtil.PermissionCallBack() {
PermissionUtil.onPermissionResult(this, permissions, grantResults, new PermissionUtil
.PermissionCallBack() {
@Override
public void onSuccess() {
hasPermissions();
Expand All @@ -199,7 +207,8 @@ public void onShouldShow() {
permissionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (PermissionUtil.checkAndRequestPermissionsInActivity(EasyPhotosActivity.this, getNeedPermissions())) {
if (PermissionUtil.checkAndRequestPermissionsInActivity
(EasyPhotosActivity.this, getNeedPermissions())) {
hasPermissions();
}
}
Expand All @@ -213,7 +222,8 @@ public void onFailed() {
permissionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SettingsUtils.startMyApplicationDetailsForResult(EasyPhotosActivity.this, getPackageName());
SettingsUtils.startMyApplicationDetailsForResult(EasyPhotosActivity.this,
getPackageName());
}
});

Expand All @@ -236,7 +246,8 @@ private void launchCamera(int requestCode) {
permissionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SettingsUtils.startMyApplicationDetailsForResult(EasyPhotosActivity.this, getPackageName());
SettingsUtils.startMyApplicationDetailsForResult(EasyPhotosActivity.this,
getPackageName());
}
});
return;
Expand All @@ -257,7 +268,8 @@ private void toAndroidCamera(int requestCode) {

Uri imageUri = null;
if (Build.VERSION.SDK_INT >= 24) {
imageUri = FileProvider.getUriForFile(this, Setting.fileProviderAuthority, mTempImageFile);//通过FileProvider创建一个content类型的Uri
imageUri = FileProvider.getUriForFile(this, Setting.fileProviderAuthority,
mTempImageFile);//通过FileProvider创建一个content类型的Uri
} else {
imageUri = Uri.fromFile(mTempImageFile);
}
Expand All @@ -266,22 +278,26 @@ private void toAndroidCamera(int requestCode) {
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);//将拍取的照片保存到指定URI
startActivityForResult(cameraIntent, requestCode);
} else {
Toast.makeText(this, R.string.camera_temp_file_error_easy_photos, Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.camera_temp_file_error_easy_photos, Toast
.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, R.string.msg_no_camera_easy_photos, Toast.LENGTH_SHORT).show();
}
}

private void createCameraTempImageFile() {
File dir = new File(Environment.getExternalStorageDirectory(), File.separator + "DCIM" + File.separator + "Camera" + File.separator);
File dir = new File(Environment.getExternalStorageDirectory(), File.separator + "DCIM" +
File.separator + "Camera" + File.separator);
if (!dir.exists() || !dir.isDirectory()) {
if (!dir.mkdirs()) {
dir = getExternalFilesDir(null);
if (null == dir || !dir.exists()) {
dir = getFilesDir();
if (null == dir || !dir.exists()) {
String cacheDirPath = File.separator + "data" + File.separator + "data" + File.separator + getPackageName() + File.separator + "cache" + File.separator;
String cacheDirPath = File.separator + "data" + File.separator + "data" +
File.separator + getPackageName() + File.separator + "cache" +
File.separator;
dir = new File(cacheDirPath);
if (!dir.exists()) {
dir.mkdirs();
Expand Down Expand Up @@ -391,7 +407,9 @@ private void addNewPhoto(Photo photo) {
Result.addPhoto(photo);
} else {
if (Result.count() >= Setting.count) {
Toast.makeText(this, getString(R.string.selector_reach_max_image_hint_easy_photos, Setting.count), Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string
.selector_reach_max_image_hint_easy_photos, Setting.count), Toast
.LENGTH_SHORT).show();
} else {
Result.addPhoto(photo);
}
Expand All @@ -402,7 +420,8 @@ private void addNewPhoto(Photo photo) {
}

private void onCameraResult() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HH:mm:ss", Locale.getDefault());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HH:mm:ss", Locale.getDefault
());
String imageName = "IMG_%s.jpg";
String filename = String.format(imageName, dateFormat.format(new Date()));
File reNameFile = new File(mTempImageFile.getParentFile(), filename);
Expand All @@ -417,7 +436,9 @@ private void onCameraResult() {
if (Setting.onlyStartCamera || albumModel.getAlbumItems().isEmpty()) {
MediaScannerConnectionUtils.refresh(this, mTempImageFile);// 更新媒体库
Intent data = new Intent();
Photo photo = new Photo(mTempImageFile.getName(), mTempImageFile.getAbsolutePath(), mTempImageFile.lastModified() / 1000, options.outWidth, options.outHeight, mTempImageFile.length(), options.outMimeType);
Photo photo = new Photo(mTempImageFile.getName(), mTempImageFile.getAbsolutePath(),
mTempImageFile.lastModified() / 1000, options.outWidth, options.outHeight,
mTempImageFile.length(), options.outMimeType);
photo.selectedOriginal = Setting.selectedOriginal;
resultList.add(photo);

Expand All @@ -435,7 +456,9 @@ private void onCameraResult() {
return;
}

Photo photo = new Photo(mTempImageFile.getName(), mTempImageFile.getAbsolutePath(), mTempImageFile.lastModified() / 1000, options.outWidth, options.outHeight, mTempImageFile.length(), options.outMimeType);
Photo photo = new Photo(mTempImageFile.getName(), mTempImageFile.getAbsolutePath(),
mTempImageFile.lastModified() / 1000, options.outWidth, options.outHeight,
mTempImageFile.length(), options.outMimeType);
addNewPhoto(photo);

}
Expand Down Expand Up @@ -471,7 +494,8 @@ private void initView() {
tvAlbumItems.setText(albumModel.getAlbumItems().get(0).name);
tvDone = (PressedTextView) findViewById(R.id.tv_done);
rvPhotos = (RecyclerView) findViewById(R.id.rv_photos);
((SimpleItemAnimator) rvPhotos.getItemAnimator()).setSupportsChangeAnimations(false);//去除item更新的闪光
((SimpleItemAnimator) rvPhotos.getItemAnimator()).setSupportsChangeAnimations(false);
//去除item更新的闪光
photoList.clear();
photoList.addAll(albumModel.getCurrAlbumItemPhotos(0));
if (Setting.hasPhotosAd()) {
Expand Down Expand Up @@ -581,12 +605,10 @@ public void processSecondMenu() {
}
if (View.VISIBLE == mSecondMenus.getVisibility()) {
mSecondMenus.setVisibility(View.INVISIBLE);
if (Setting.isShowCamera)
ivCamera.setVisibility(View.VISIBLE);
if (Setting.isShowCamera) ivCamera.setVisibility(View.VISIBLE);
} else {
mSecondMenus.setVisibility(View.VISIBLE);
if (Setting.isShowCamera)
ivCamera.setVisibility(View.INVISIBLE);
if (Setting.isShowCamera) ivCamera.setVisibility(View.INVISIBLE);
}
}

Expand All @@ -611,9 +633,11 @@ private void processOriginalMenu() {
tvOriginal.setTextColor(ContextCompat.getColor(this, R.color.easy_photos_fg_accent));
} else {
if (Setting.originalMenuUsable) {
tvOriginal.setTextColor(ContextCompat.getColor(this, R.color.easy_photos_fg_primary));
tvOriginal.setTextColor(ContextCompat.getColor(this, R.color
.easy_photos_fg_primary));
} else {
tvOriginal.setTextColor(ContextCompat.getColor(this, R.color.easy_photos_fg_primary_dark));
tvOriginal.setTextColor(ContextCompat.getColor(this, R.color
.easy_photos_fg_primary_dark));
}
}
}
Expand All @@ -637,7 +661,8 @@ private void newAnimators() {
}

private void newShowAnim() {
ObjectAnimator translationShow = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", mBottomBar.getTop(), 0);
ObjectAnimator translationShow = ObjectAnimator.ofFloat(rvAlbumItems, "translationY",
mBottomBar.getTop(), 0);
ObjectAnimator alphaShow = ObjectAnimator.ofFloat(rootViewAlbumItems, "alpha", 0.0f, 1.0f);
translationShow.setDuration(300);
setShow = new AnimatorSet();
Expand All @@ -646,7 +671,8 @@ private void newShowAnim() {
}

private void newHideAnim() {
ObjectAnimator translationHide = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", 0, mBottomBar.getTop());
ObjectAnimator translationHide = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", 0,
mBottomBar.getTop());
ObjectAnimator alphaHide = ObjectAnimator.ofFloat(rootViewAlbumItems, "alpha", 1.0f, 0.0f);
translationHide.setDuration(200);
setHide = new AnimatorSet();
Expand Down Expand Up @@ -697,7 +723,8 @@ private void shouldShowMenuDone() {
tvDone.setVisibility(View.VISIBLE);
tvPreview.setVisibility(View.VISIBLE);
}
tvDone.setText(getString(R.string.selector_action_done_easy_photos, Result.count(), Setting.count));
tvDone.setText(getString(R.string.selector_action_done_easy_photos, Result.count(),
Setting.count));
}

@Override
Expand All @@ -708,7 +735,8 @@ public void onPhotoClick(int position, int realPosition) {

@Override
public void onSelectorOutOfMax() {
Toast.makeText(this, getString(R.string.selector_reach_max_image_hint_easy_photos, Setting.count), Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.selector_reach_max_image_hint_easy_photos,
Setting.count), Toast.LENGTH_SHORT).show();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
}
albumModel = AlbumModel.getInstance();
albumModel.query(this, null);
// albumModel.query(this, null);
if (null == albumModel||albumModel.getAlbumItems().isEmpty()) {
finish();
return;
Expand Down
12 changes: 12 additions & 0 deletions easyPhotos/src/main/res/drawable/ic_edit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="1024"
android:viewportHeight="1024">
<path
android:fillColor="@color/easy_photos_fg_primary"
android:pathData="M219.71,243.47c-47.72,0 -86.38,38.66 -86.38,86.38 0,47.72 38.67,86.38 86.38,86.38 47.72,0 86.38,-38.66 86.38,-86.38 0.13,-47.72 -38.53,-86.38 -86.38,-86.38zM1014.44,536.67l-30.55,-30.55c-12.17,-12.03 -31.77,-12.03 -43.93,0l-20.96,20.95 74.49,74.48 20.95,-20.95c12.16,-12.3 12.16,-31.9 0,-43.93zM609.03,837.18l-3.38,77.87 77.86,-3.38 295.37,-295.37 -74.35,-74.49L609.03,837.18zM609.03,837.18" />
<path
android:fillColor="@color/easy_photos_fg_primary"
android:pathData="M771.51,489.36L771.51,183.58c3.79,-40.15 -25.68,-75.83 -65.83,-79.75L73.44,103.82C33.02,103.69 0.17,136.27 0.04,176.69c0,2.3 0.14,4.59 0.27,6.89v651.58c-3.65,40.28 25.95,75.83 66.24,79.49 2.3,0.27 4.6,0.27 6.9,0.27h475.97l2.03,-78.4 220.21,-224.27 -0.14,-122.88zM731.64,482.74c-52.59,-48.94 -120.99,-77.19 -192.77,-79.76 -73.13,0 -146.26,66.51 -219.4,126.26 -53.12,39.88 -113.01,93.14 -152.89,93.14 -45.96,-4.46 -88.54,-25.68 -119.63,-59.88L46.94,183.58c0,-14.73 11.89,-26.63 26.63,-26.63h631.57c14.73,0 26.63,11.89 26.63,26.63l-0.13,299.16zM731.64,482.74" />
</vector>
3 changes: 2 additions & 1 deletion easyPhotos/src/main/res/layout/activity_easy_photos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/m_bottom_bar"
app:srcCompat="@drawable/ic_settings_easy_photos" />
app:srcCompat="@drawable/ic_edit" />

<com.huantansheng.easyphotos.ui.widget.PressedTextView
android:id="@+id/tv_preview"
Expand Down Expand Up @@ -246,6 +246,7 @@
<RelativeLayout
android:id="@+id/rl_permissions_view"
android:layout_width="0dp"
tools:visibility="gone"
android:layout_height="0dp"
android:background="@color/easy_photos_fg_primary"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down

0 comments on commit 500b487

Please sign in to comment.