Skip to content

Commit

Permalink
Code cleanup as moved to other PRs.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed May 25, 2023
1 parent d8e8726 commit 1d222ad
Show file tree
Hide file tree
Showing 25 changed files with 83 additions and 387 deletions.
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@
android:exported="false" />
<activity
android:name="com.nextcloud.client.widget.DashboardWidgetConfigurationActivity"
android:exported="false"
android:enabled="false">
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
Expand All @@ -164,8 +163,7 @@
android:exported="false" />
<receiver
android:name="com.nextcloud.client.widget.DashboardWidgetProvider"
android:exported="false"
android:enabled="false">
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
Expand Down Expand Up @@ -250,7 +248,6 @@
<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, 0);
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt
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_share),
SEE_DETAILS(R.id.action_see_details, R.string.actionbar_see_details, R.drawable.ic_information_outline),
REMOVE_FILE(R.id.action_remove_file, R.string.common_remove, R.drawable.ic_delete),

// File moving
Expand All @@ -48,7 +48,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe

// Uploads and downloads
DOWNLOAD_FILE(R.id.action_download_file, R.string.filedetails_download, R.drawable.ic_cloud_download),
SYNC_FILE(R.id.action_sync_file, R.string.filedetails_sync_file, R.drawable.ic_cloud_download),
SYNC_FILE(R.id.action_sync_file, R.string.filedetails_sync_file, R.drawable.ic_cloud_sync_on),
CANCEL_SYNC(R.id.action_cancel_sync, R.string.common_cancel_sync, R.drawable.ic_cloud_sync_off),

// File sharing
Expand Down
18 changes: 0 additions & 18 deletions app/src/main/java/com/nmc/android/utils/DisplayUtils.kt

This file was deleted.

11 changes: 5 additions & 6 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -852,17 +852,16 @@ 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:*/
//NMC Customization
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
/* break;
}*/
case SYSTEM:
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
break;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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 @@ -59,7 +58,6 @@
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import javax.inject.Inject;

Expand Down Expand Up @@ -198,26 +196,12 @@ 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 (!com.nmc.android.utils.DisplayUtils.isTablet() && !com.nmc.android.utils.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<>();
// 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_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 @@ -226,18 +210,6 @@ 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 @@ -300,11 +272,7 @@ public void showToolbarSpinner() {
private void fillDirectoryDropdown() {
File currentDir = mCurrentDir;
while (currentDir != null && currentDir.getParentFile() != null) {
if (currentDir.getName().equals("0")) {
mDirectories.add(getResources().getString(R.string.storage_internal_storage));
} else {
mDirectories.add(currentDir.getName());
}
mDirectories.add(currentDir.getName());
currentDir = currentDir.getParentFile();
}
mDirectories.add(File.separator);
Expand Down Expand Up @@ -533,16 +501,15 @@ public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String.

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

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

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

Expand Down Expand Up @@ -610,7 +577,7 @@ private void checkWritableFolder(File folder) {
int localBehaviour = preferences.getUploaderBehaviour();
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
} else {
binding.uploadFilesSpinnerBehaviour.setSelection(0);
binding.uploadFilesSpinnerBehaviour.setSelection(1);
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,7 +30,6 @@
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 @@ -57,13 +56,11 @@
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.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 @@ -111,8 +108,6 @@ 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 @@ -177,8 +172,6 @@ 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 @@ -187,23 +180,6 @@ private void setupContent() {
loadItems();
}

private void addListItemDecorator() {
if (com.nmc.android.utils.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 @@ -386,20 +362,4 @@ 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 (!com.nmc.android.utils.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 @@ -28,7 +28,6 @@
import android.util.DisplayMetrics;
import android.view.View;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.RecyclerView;

Expand All @@ -40,8 +39,7 @@ public class SimpleListItemDividerDecoration extends DividerItemDecoration {

private final Rect bounds = new Rect();
private Drawable divider;
private int leftPadding = 0;
private boolean hasFooter;
private int leftPadding;

/**
* Default divider will be used
Expand All @@ -54,17 +52,6 @@ public SimpleListItemDividerDecoration(Context context) {
styledAttributes.recycle();
}

/**
* Custom divider will be used
*
* @param hasFooter if recyclerview has footer and no divider should be shown for footer then pass true else false
*/
public SimpleListItemDividerDecoration(Context context, int resId, boolean hasFooter) {
super(context, DividerItemDecoration.VERTICAL);
this.hasFooter = hasFooter;
divider = ContextCompat.getDrawable(context, resId);
}

@Override
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
canvas.save();
Expand All @@ -78,12 +65,7 @@ public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state)
right = parent.getWidth();
}

int childCount = parent.getChildCount();

if (hasFooter) {
childCount = childCount - 1;
}

final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
parent.getDecoratedBoundsWithMargins(child, bounds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,12 @@ private List<StoragePathItem> getPathList() {
Environment.getExternalStoragePublicDirectory(standardDirectory.getName()).getAbsolutePath());
}

String sdCard = getString(R.string.storage_internal_storage);
for (String dir : FileStorageUtils.getStorageDirectories(requireActivity())) {
//NMC Customisation
if (internalStoragePaths.contains(dir)) {
String internalStorage = getString(R.string.storage_internal_storage);
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, internalStorage, dir);
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, sdCard, dir);
} else {
String sdCard = getString(R.string.storage_sd_card);
addIfExists(storagePathItems, R.drawable.ic_sd, sdCard, dir);
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, new File(dir).getName(), dir);
}
}

Expand Down
Loading

0 comments on commit 1d222ad

Please sign in to comment.