Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwanng committed Jan 6, 2025
1 parent 91d31fa commit f05fca6
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 31 deletions.
15 changes: 15 additions & 0 deletions app/src/main/java/com/seafile/seadroid2/annotation/NotSupport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.seafile.seadroid2.annotation;

import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;

import java.lang.annotation.Target;

/**
* There are no plans to develop this feature.
*/
@Target({TYPE, METHOD, CONSTRUCTOR, FIELD})
public @interface NotSupport {
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ public void onFirstResume() {

private void initAdapter() {
adapter = new ActivityAdapter();

TextView tipView = TipsViews.getTipTextView(requireContext());
tipView.setText(R.string.no_starred_file);
tipView.setOnClickListener(v -> reload());
adapter.setStateView(tipView);
adapter.setStateViewEnable(false);
adapter.setAnimationEnable(true);

adapter.setOnItemClickListener((baseQuickAdapter, view, i) -> {
ActivityModel activityModel = (ActivityModel) adapter.getItems().get(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@

import com.seafile.seadroid2.R;
import com.seafile.seadroid2.SeafException;
import com.seafile.seadroid2.ui.base.fragment.BaseFragmentWithVM;
import com.seafile.seadroid2.annotation.NotSupport;
import com.seafile.seadroid2.databinding.LayoutFrameSwipeRvBinding;
import com.seafile.seadroid2.framework.data.model.activities.ActivityModel;
import com.seafile.seadroid2.ui.base.fragment.BaseFragmentWithVM;
import com.seafile.seadroid2.view.TipsViews;

import java.util.List;

import kotlin.Pair;

@NotSupport
@Deprecated
public class MineActivitiesFragment extends BaseFragmentWithVM<ActivityViewModel> {

Expand Down
31 changes: 27 additions & 4 deletions app/src/main/java/com/seafile/seadroid2/ui/main/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1047,15 +1047,38 @@ public void accept(Boolean aBoolean) {
private int permission_media_select_type = -1;

private void takePhoto() {
permission_media_select_type = 0;
cameraPermissionLauncher.launch(Manifest.permission.CAMERA);
checkCurrentPathHasWritePermission(new java.util.function.Consumer<Boolean>() {
@Override
public void accept(Boolean aBoolean) {
if (!aBoolean) {
ToastUtils.showLong(R.string.library_read_only);
return;
}

permission_media_select_type = 0;
cameraPermissionLauncher.launch(Manifest.permission.CAMERA);
}
});

}

private void takeVideo() {
permission_media_select_type = 1;
cameraPermissionLauncher.launch(Manifest.permission.CAMERA);
checkCurrentPathHasWritePermission(new java.util.function.Consumer<Boolean>() {
@Override
public void accept(Boolean aBoolean) {
if (!aBoolean) {
ToastUtils.showLong(R.string.library_read_only);
return;
}

permission_media_select_type = 1;
cameraPermissionLauncher.launch(Manifest.permission.CAMERA);
}
});

}


private void takeFile(boolean isSingleSelect) {
String[] mimeTypes = new String[]{"*/*"};
if (isSingleSelect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,7 @@ private void onBindRepos(RepoViewHolder holder, RepoModel model, @NonNull List<?

// holder.binding.getRoot().setChecked(model.is_checked);

int color;
if (isChecked) {
color = ContextCompat.getColor(getContext(), R.color.fancy_orange);
holder.binding.itemMultiSelect.setImageResource(R.drawable.ic_checkbox_checked);
} else {
color = ContextCompat.getColor(getContext(), R.color.material_grey_666);
holder.binding.itemMultiSelect.setImageResource(R.drawable.ic_checkbox_unchecked);
}
holder.binding.itemMultiSelect.setImageTintList(ColorStateList.valueOf(color));
updateItemMultiSelectViewWithPayload(holder.binding.itemMultiSelect,isChecked);
return;
}

Expand All @@ -347,12 +339,12 @@ private void onBindRepos(RepoViewHolder holder, RepoModel model, @NonNull List<?
color = ContextCompat.getColor(getContext(), R.color.fancy_orange);
holder.binding.itemMultiSelect.setImageResource(R.drawable.ic_checkbox_checked);
} else {
color = ContextCompat.getColor(getContext(), R.color.material_grey_666);
color = ContextCompat.getColor(getContext(), R.color.bottom_sheet_pop_disable_color);
holder.binding.itemMultiSelect.setImageResource(R.drawable.ic_checkbox_unchecked);
}
holder.binding.itemMultiSelect.setImageTintList(ColorStateList.valueOf(color));
} else {
color = ContextCompat.getColor(getContext(), R.color.material_grey_666);
color = ContextCompat.getColor(getContext(), R.color.bottom_sheet_pop_disable_color);
holder.binding.itemMultiSelect.setVisibility(View.GONE);
// holder.binding.getRoot().setChecked(false);
}
Expand All @@ -370,8 +362,6 @@ private void onBindRepos(RepoViewHolder holder, RepoModel model, @NonNull List<?
}

private void onBindDirents(DirentViewHolder holder, DirentModel model, @NonNull List<?> payloads) {
int color;

if (!CollectionUtils.isEmpty(payloads)) {
Bundle bundle = (Bundle) payloads.get(0);
boolean isChecked = bundle.getBoolean("is_check");
Expand Down Expand Up @@ -520,7 +510,7 @@ private void updateItemMultiSelectViewWithPayload(ImageView imageView, boolean i
color = ContextCompat.getColor(getContext(), R.color.fancy_orange);
imageView.setImageResource(R.drawable.ic_checkbox_checked);
} else {
color = ContextCompat.getColor(getContext(), R.color.material_grey_666);
color = ContextCompat.getColor(getContext(), R.color.bottom_sheet_pop_disable_color);
imageView.setImageResource(R.drawable.ic_checkbox_unchecked);
}
imageView.setImageTintList(ColorStateList.valueOf(color));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,20 @@ private void navTo(BaseModel model) {

private void navToForSearch(SearchModel searchModel) {
if (searchModel.isDir() && "/".equals(searchModel.fullpath)) {
RepoModel repoModel = SearchModel.convert2RepoModel(searchModel);
getNavContext().push(repoModel);
loadDataAsFirst();
getViewModel().getRepoModelEntity(searchModel.repo_id, new Consumer<RepoModel>() {
@Override
public void accept(RepoModel repoModel) throws Exception {
if (repoModel == null) {
ToastUtils.showLong(R.string.repo_not_found);
return;
}

getNavContext().push(repoModel);
loadDataAsFirst();
}
});


} else {
DirentModel direntModel = SearchModel.convert2DirentModel(searchModel);
if (direntModel.isDir()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,21 @@ public void accept(Throwable throwable) throws Exception {
});
}

public void getRepoModelEntity(String repoId, Consumer<RepoModel> consumer) {
Single<List<RepoModel>> r = AppDatabase.getInstance().repoDao().getRepoById(repoId);
addSingleDisposable(r, new Consumer<List<RepoModel>>() {
@Override
public void accept(List<RepoModel> rs) throws Exception {
if (consumer != null) {
if (CollectionUtils.isEmpty(rs)) {
consumer.accept(null);
} else {
consumer.accept(rs.get(0));
}
}
}
});
}

public void getRepoModelAndPermissionEntity(String repoId, Consumer<Pair<RepoModel, PermissionEntity>> consumer) {
Single<Pair<RepoModel, PermissionEntity>> r = getRepoModelAndAllPermissionSingle(repoId);
Expand Down Expand Up @@ -618,7 +633,7 @@ public void accept(Throwable throwable) throws Exception {
public void inflateDirentMenu(Context context) {
removeNonRepoPermission();

toParseMenu(context, R.menu.bottom_sheet_op_dirent, null,null, CollectionUtils.newArrayList(R.id.unstar));
toParseMenu(context, R.menu.bottom_sheet_op_dirent, null, null, CollectionUtils.newArrayList(R.id.unstar));
}

public void inflateDirentMenuWithSelected(Context context, List<DirentModel> selectedDirentList, List<Integer> disableMenuIds, List<Integer> removedMenuIds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
Drawable drawable = BackgroundShapeUtils.genBackgroundDrawable(radiusPosition, backgroundColor, backgroundRadius);
holder.itemView.setBackground(drawable);

TextView textView = (TextView) holder.findViewById(android.R.id.title);
textView.setTextColor(titleTextColor);
TextView titleTextView = (TextView) holder.findViewById(android.R.id.title);
if (titleTextView != null) {
titleTextView.setTextColor(titleTextColor);
}

MaterialDivider topDivider = (MaterialDivider) holder.findViewById(R.id.top_divider);
MaterialDivider bottomDivider = (MaterialDivider) holder.findViewById(R.id.bottom_divider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public BackgroundShapePreference(@NonNull Context context) {
public abstract int getLayoutId();

private int titleTextColor = 0;
private int summaryTextColor = 0;
//default all
private int radiusPosition = 0;
private int backgroundColor = 0;
Expand All @@ -60,6 +61,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr) {
R.styleable.PrefShape, defStyleAttr, 0);

titleTextColor = typedArray.getColor(R.styleable.PrefShape_titleTextColor, ContextCompat.getColor(getContext(), R.color.item_title_color));
summaryTextColor = typedArray.getColor(R.styleable.PrefShape_summaryTextColor, ContextCompat.getColor(getContext(), R.color.item_subtitle_color));
radiusPosition = typedArray.getInt(R.styleable.PrefShape_radiusPosition, 0);

backgroundColor = typedArray.getColor(R.styleable.PrefShape_backgroundColor, ContextCompat.getColor(getContext(), R.color.bar_background_color));
Expand All @@ -81,8 +83,16 @@ public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
Drawable drawable = BackgroundShapeUtils.genBackgroundDrawable(radiusPosition, backgroundColor, backgroundRadius);
holder.itemView.setBackground(drawable);

TextView textView = (TextView) holder.findViewById(android.R.id.title);
textView.setTextColor(titleTextColor);
TextView titleTextView = (TextView) holder.findViewById(android.R.id.title);
if (titleTextView != null) {
titleTextView.setTextColor(titleTextColor);
}

TextView summaryTextView = (TextView) holder.findViewById(android.R.id.summary);
if (summaryTextView != null) {
summaryTextView.setTextColor(summaryTextColor);
}


MaterialDivider topDivider = (MaterialDivider) holder.findViewById(R.id.top_divider);
MaterialDivider bottomDivider = (MaterialDivider) holder.findViewById(R.id.bottom_divider);
Expand Down Expand Up @@ -127,6 +137,7 @@ public void setDividerPosition(int dividerPosition) {
this.dividerPosition = dividerPosition;
notifyChanged();
}

public void setTitleTextColor(int titleTextColor) {
this.titleTextColor = titleTextColor;
notifyChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public void onBindViewHolder(@NonNull PreferenceViewHolder holder) {
Drawable drawable = BackgroundShapeUtils.genBackgroundDrawable(radiusPosition, backgroundColor, backgroundRadius);
holder.itemView.setBackground(drawable);

TextView textView = (TextView) holder.findViewById(android.R.id.title);
textView.setTextColor(titleTextColor);
TextView titleTextView = (TextView) holder.findViewById(android.R.id.title);
if (titleTextView != null) {
titleTextView.setTextColor(titleTextColor);
}

MaterialDivider topDivider = (MaterialDivider) holder.findViewById(R.id.top_divider);
MaterialDivider bottomDivider = (MaterialDivider) holder.findViewById(R.id.bottom_divider);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@

<declare-styleable name="PrefShape">
<attr name="titleTextColor" format="color" />
<attr name="summaryTextColor" format="color" />
<attr name="backgroundRadius" format="dimension" />
<attr name="backgroundColor" format="color" />
<attr name="dividerColor" format="color" />
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/xml/prefs_settings_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
app:dividerColor="@color/pref_divider_color"
app:dividerPosition="bottom"
app:iconSpaceReserved="false"
app:radiusPosition="top" />
app:radiusPosition="top"
app:summaryTextColor="@color/fancy_orange" />

<com.seafile.seadroid2.widget.prefs.TextTitleSummaryPreference
android:key="@string/pref_key_user_server"
Expand Down

0 comments on commit f05fca6

Please sign in to comment.