Skip to content

Commit

Permalink
Customized theming related changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed May 16, 2023
1 parent 3e1f61a commit a87f483
Show file tree
Hide file tree
Showing 46 changed files with 719 additions and 265 deletions.
7 changes: 5 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@
android:exported="false" />
<activity
android:name="com.nextcloud.client.widget.DashboardWidgetConfigurationActivity"
android:exported="false">
android:exported="false"
android:enabled="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand All @@ -163,7 +164,8 @@
android:exported="false" />
<receiver
android:name="com.nextcloud.client.widget.DashboardWidgetProvider"
android:exported="false">
android:exported="false"
android:enabled="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
Expand Down Expand Up @@ -248,6 +250,7 @@
<service
android:name="com.nextcloud.client.widget.DashboardWidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS"
android:enabled="false"
android:exported="true" />

<provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public void setAutoUploadInit(boolean autoUploadInit) {

@Override
public int getUploaderBehaviour() {
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe

// generic file actions
EDIT(R.id.action_edit, R.string.action_edit, R.drawable.ic_edit),
SEE_DETAILS(R.id.action_see_details, R.string.actionbar_see_details, R.drawable.ic_information_outline),
SEE_DETAILS(R.id.action_see_details, R.string.actionbar_see_details, R.drawable.ic_share),
REMOVE_FILE(R.id.action_remove_file, R.string.common_remove, R.drawable.ic_delete),

// File moving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class FileActionsBottomSheet private constructor() : BottomSheetDialogFragment()
binding.thumbnailLayout.thumbnailShimmer,
null,
viewThemeUtils,
syncedFolderProvider
syncedFolderProvider,
false
)
}
}
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -852,16 +852,17 @@ public AndroidInjector<Object> androidInjector() {


public static void setAppTheme(DarkMode mode) {
switch (mode) {
/* switch (mode) {
case LIGHT:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
break;
case DARK:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
break;
case SYSTEM:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
break;
}
case SYSTEM:*/
//NMC Customization
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
/* break;
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -58,6 +59,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import javax.inject.Inject;

Expand Down Expand Up @@ -196,12 +198,26 @@ public void onCreate(Bundle savedInstanceState) {
binding.uploadFilesBtnUpload.setOnClickListener(this);
binding.uploadFilesBtnUpload.setEnabled(mLocalFolderPickerMode);

//reduce the button text size so that the text doesn't go to next line
//this should only happen for GERMAN language
//and device should not be tablet and should be in portrait mode
if (!DisplayUtils.isTablet() && !DisplayUtils.isLandscapeOrientation()) {
if (Locale.getDefault().getLanguage().equals(Locale.GERMAN.getLanguage())
|| Locale.getDefault().getLanguage().equals(Locale.GERMANY.getLanguage())) {
binding.uploadFilesBtnUpload.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimensionPixelSize(R.dimen.txt_size_13sp));
binding.uploadFilesBtnCancel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
getResources().getDimensionPixelSize(R.dimen.txt_size_13sp));
}
}

int localBehaviour = preferences.getUploaderBehaviour();

// file upload spinner
List<String> behaviours = new ArrayList<>();
behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
themeUtils.getDefaultDisplayNameForRootFolder(this)));
// Not required this option for NMC
// behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
// themeUtils.getDefaultDisplayNameForRootFolder(this)));
behaviours.add(getString(R.string.uploader_upload_files_behaviour_only_upload));
behaviours.add(getString(R.string.uploader_upload_files_behaviour_upload_and_delete_from_source));

Expand All @@ -210,6 +226,18 @@ public void onCreate(Bundle savedInstanceState) {
behaviourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
binding.uploadFilesSpinnerBehaviour.setAdapter(behaviourAdapter);
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
binding.uploadFilesSpinnerBehaviour.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
// store behaviour
preferences.setUploaderBehaviour(binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition());
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});

// setup the toolbar
setupToolbar();
Expand Down Expand Up @@ -272,7 +300,11 @@ public void showToolbarSpinner() {
private void fillDirectoryDropdown() {
File currentDir = mCurrentDir;
while (currentDir != null && currentDir.getParentFile() != null) {
mDirectories.add(currentDir.getName());
if (currentDir.getName().equals("0")) {
mDirectories.add(getResources().getString(R.string.storage_internal_storage));
} else {
mDirectories.add(currentDir.getName());
}
currentDir = currentDir.getParentFile();
}
mDirectories.add(File.separator);
Expand Down Expand Up @@ -501,15 +533,16 @@ public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String.

// set result code
switch (binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition()) {
case 0: // move to nextcloud folder
// Not required for NMC
/*case 0: // move to nextcloud folder
setResult(RESULT_OK_AND_MOVE, data);
break;
break;*/

case 1: // only upload
case 0: // only upload
setResult(RESULT_OK_AND_DO_NOTHING, data);
break;

case 2: // upload and delete from source
case 1: // upload and delete from source
setResult(RESULT_OK_AND_DELETE, data);
break;

Expand Down Expand Up @@ -577,7 +610,7 @@ private void checkWritableFolder(File folder) {
int localBehaviour = preferences.getUploaderBehaviour();
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
} else {
binding.uploadFilesSpinnerBehaviour.setSelection(1);
binding.uploadFilesSpinnerBehaviour.setSelection(0);
textView.setText(new StringBuilder().append(getString(R.string.uploader_upload_files_behaviour))
.append(' ')
.append(getString(R.string.uploader_upload_files_behaviour_not_writable))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
Expand All @@ -56,11 +57,14 @@
import com.owncloud.android.operations.CheckCurrentCredentialsOperation;
import com.owncloud.android.ui.adapter.UploadListAdapter;
import com.owncloud.android.ui.decoration.MediaGridItemDecoration;
import com.owncloud.android.ui.decoration.SimpleListItemDividerDecoration;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.FilesSyncHelper;
import com.owncloud.android.utils.theme.ViewThemeUtils;

import javax.inject.Inject;

import androidx.annotation.NonNull;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
Expand Down Expand Up @@ -108,6 +112,8 @@ public class UploadListActivity extends FileActivity {

private UploadListLayoutBinding binding;

private SimpleListItemDividerDecoration simpleListItemDividerDecoration;

public static Intent createIntent(OCFile file, User user, Integer flag, Context context) {
Intent intent = new Intent(context, UploadListActivity.class);
if (flag != null) {
Expand Down Expand Up @@ -172,6 +178,8 @@ private void setupContent() {
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
binding.list.addItemDecoration(new MediaGridItemDecoration(spacing));
binding.list.setLayoutManager(lm);
simpleListItemDividerDecoration = new SimpleListItemDividerDecoration(this, R.drawable.item_divider, true);
addListItemDecorator();
binding.list.setAdapter(uploadListAdapter);

viewThemeUtils.androidx.themeSwipeRefreshLayout(swipeListRefreshLayout);
Expand All @@ -180,6 +188,23 @@ private void setupContent() {
loadItems();
}

private void addListItemDecorator() {
if (DisplayUtils.isShowDividerForList()) {
//check and remove divider item decorator if exist then add item decorator
removeListDividerDecorator();
binding.list.addItemDecoration(simpleListItemDividerDecoration);
}
}

/**
* method to remove the divider item decorator
*/
private void removeListDividerDecorator() {
if (binding.list.getItemDecorationCount() > 0) {
binding.list.removeItemDecoration(simpleListItemDividerDecoration);
}
}

private void loadItems() {
uploadListAdapter.loadUploadItemsFromDb();

Expand Down Expand Up @@ -362,4 +387,20 @@ public void onReceive(Context context, Intent intent) {
});
}
}

@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
//this should only run when device is not tablet because we are adding dividers in tablet for both the
// orientations
if (!DisplayUtils.isTablet()) {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
//add the divider item decorator when orientation is landscape
addListItemDecorator();
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
//remove the divider item decorator when orientation is portrait
removeListDividerDecorator();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class GalleryAdapter(
transferServiceGetter,
showMetadata = false,
showShareAvatar = false,
viewThemeUtils
viewThemeUtils,
true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public OCFileListAdapter(
.getVersion()
.isShareesOnDavSupported(),
viewThemeUtils,
false,
syncedFolderProvider);

// initialise thumbnails cache on background thread
Expand Down Expand Up @@ -312,6 +313,8 @@ public boolean isEmpty() {
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (viewType) {
default:
// change required for NMC
case VIEWTYPE_IMAGE:
case VIEWTYPE_ITEM:
if (gridView) {
return new OCFileListGridItemViewHolder(
Expand All @@ -323,17 +326,6 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
);
}

case VIEWTYPE_IMAGE:
if (gridView) {
return new OCFileListGridImageViewHolder(
GridImageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)
);
} else {
return new OCFileListItemViewHolder(
ListItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)
);
}

case VIEWTYPE_FOOTER:
return new OCFileListFooterViewHolder(
ListFooterBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false)
Expand Down Expand Up @@ -502,15 +494,10 @@ private void bindListItemViewHolder(ListItemViewHolder holder, OCFile file) {
private void bindListGridItemViewHolder(ListGridItemViewHolder holder, OCFile file) {
holder.getFileName().setText(file.getDecryptedFileName());

boolean gridImage = MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file);
if (gridView && gridImage) {
if (gridView && ocFileListFragmentInterface.getColumnsCount() > showFilenameColumnThreshold) {
holder.getFileName().setVisibility(View.GONE);
} else {
if (gridView && ocFileListFragmentInterface.getColumnsCount() > showFilenameColumnThreshold) {
holder.getFileName().setVisibility(View.GONE);
} else {
holder.getFileName().setVisibility(View.VISIBLE);
}
holder.getFileName().setVisibility(View.VISIBLE);
}
}

Expand Down Expand Up @@ -585,7 +572,7 @@ public boolean shouldShowHeader() {
return false;
}

if (MainApp.isOnlyOnDevice()) {
if (MainApp.isOnlyOnDevice() || ocFileListFragmentInterface.isSearchFragment()) {
return false;
}

Expand Down Expand Up @@ -749,6 +736,8 @@ private void parseShares(List<Object> objects) {
}

List<OCFile> files = OCShareToOCFileConverter.buildOCFilesFromShares(shares);
//clearing list before adding all items to avoid duplicacy of elements in Shared Tab
mFiles.clear();
mFiles.addAll(files);
mStorageManager.saveShares(shares);
}
Expand Down Expand Up @@ -957,6 +946,7 @@ public void cancelAllPendingTasks() {

public void setGridView(boolean bool) {
gridView = bool;
ocFileListDelegate.setGridView(bool);
}

public void setShowMetadata(boolean bool) {
Expand Down
Loading

0 comments on commit a87f483

Please sign in to comment.