Skip to content

Commit a10ada5

Browse files
committed
Code cleanup as moved to other PRs.
1 parent d8e8726 commit a10ada5

26 files changed

+84
-390
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@
149149
android:exported="false" />
150150
<activity
151151
android:name="com.nextcloud.client.widget.DashboardWidgetConfigurationActivity"
152-
android:exported="false"
153-
android:enabled="false">
152+
android:exported="false">
154153
<intent-filter>
155154
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
156155
</intent-filter>
@@ -164,8 +163,7 @@
164163
android:exported="false" />
165164
<receiver
166165
android:name="com.nextcloud.client.widget.DashboardWidgetProvider"
167-
android:exported="false"
168-
android:enabled="false">
166+
android:exported="false">
169167
<intent-filter>
170168
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
171169
</intent-filter>
@@ -250,7 +248,6 @@
250248
<service
251249
android:name="com.nextcloud.client.widget.DashboardWidgetService"
252250
android:permission="android.permission.BIND_REMOTEVIEWS"
253-
android:enabled="false"
254251
android:exported="true" />
255252

256253
<provider

app/src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public void setAutoUploadInit(boolean autoUploadInit) {
413413

414414
@Override
415415
public int getUploaderBehaviour() {
416-
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 0);
416+
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
417417
}
418418

419419
@Override

app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe
3434

3535
// generic file actions
3636
EDIT(R.id.action_edit, R.string.action_edit, R.drawable.ic_edit),
37-
SEE_DETAILS(R.id.action_see_details, R.string.actionbar_see_details, R.drawable.ic_share),
37+
SEE_DETAILS(R.id.action_see_details, R.string.actionbar_see_details, R.drawable.ic_information_outline),
3838
REMOVE_FILE(R.id.action_remove_file, R.string.common_remove, R.drawable.ic_delete),
3939

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

4949
// Uploads and downloads
5050
DOWNLOAD_FILE(R.id.action_download_file, R.string.filedetails_download, R.drawable.ic_cloud_download),
51-
SYNC_FILE(R.id.action_sync_file, R.string.filedetails_sync_file, R.drawable.ic_cloud_download),
51+
SYNC_FILE(R.id.action_sync_file, R.string.filedetails_sync_file, R.drawable.ic_cloud_sync_on),
5252
CANCEL_SYNC(R.id.action_cancel_sync, R.string.common_cancel_sync, R.drawable.ic_cloud_sync_off),
5353

5454
// File sharing

app/src/main/java/com/nmc/android/utils/DisplayUtils.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

app/src/main/java/com/owncloud/android/MainApp.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -852,17 +852,16 @@ public AndroidInjector<Object> androidInjector() {
852852

853853

854854
public static void setAppTheme(DarkMode mode) {
855-
/* switch (mode) {
855+
switch (mode) {
856856
case LIGHT:
857857
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
858858
break;
859859
case DARK:
860860
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
861861
break;
862-
case SYSTEM:*/
863-
//NMC Customization
864-
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
865-
/* break;
866-
}*/
862+
case SYSTEM:
863+
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
864+
break;
865+
}
867866
}
868867
}

app/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import android.content.pm.PackageManager;
2828
import android.os.Bundle;
2929
import android.os.Environment;
30-
import android.util.TypedValue;
3130
import android.view.Menu;
3231
import android.view.MenuItem;
3332
import android.view.View;
@@ -59,7 +58,6 @@
5958
import java.io.File;
6059
import java.util.ArrayList;
6160
import java.util.List;
62-
import java.util.Locale;
6361

6462
import javax.inject.Inject;
6563

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

201-
//reduce the button text size so that the text doesn't go to next line
202-
//this should only happen for GERMAN language
203-
//and device should not be tablet and should be in portrait mode
204-
if (!com.nmc.android.utils.DisplayUtils.isTablet() && !com.nmc.android.utils.DisplayUtils.isLandscapeOrientation()) {
205-
if (Locale.getDefault().getLanguage().equals(Locale.GERMAN.getLanguage())
206-
|| Locale.getDefault().getLanguage().equals(Locale.GERMANY.getLanguage())) {
207-
binding.uploadFilesBtnUpload.setTextSize(TypedValue.COMPLEX_UNIT_PX,
208-
getResources().getDimensionPixelSize(R.dimen.txt_size_13sp));
209-
binding.uploadFilesBtnCancel.setTextSize(TypedValue.COMPLEX_UNIT_PX,
210-
getResources().getDimensionPixelSize(R.dimen.txt_size_13sp));
211-
}
212-
}
213-
214199
int localBehaviour = preferences.getUploaderBehaviour();
215200

216201
// file upload spinner
217202
List<String> behaviours = new ArrayList<>();
218-
// Not required this option for NMC
219-
// behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
220-
// themeUtils.getDefaultDisplayNameForRootFolder(this)));
203+
behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
204+
themeUtils.getDefaultDisplayNameForRootFolder(this)));
221205
behaviours.add(getString(R.string.uploader_upload_files_behaviour_only_upload));
222206
behaviours.add(getString(R.string.uploader_upload_files_behaviour_upload_and_delete_from_source));
223207

@@ -226,18 +210,6 @@ public void onCreate(Bundle savedInstanceState) {
226210
behaviourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
227211
binding.uploadFilesSpinnerBehaviour.setAdapter(behaviourAdapter);
228212
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
229-
binding.uploadFilesSpinnerBehaviour.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
230-
@Override
231-
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
232-
// store behaviour
233-
preferences.setUploaderBehaviour(binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition());
234-
}
235-
236-
@Override
237-
public void onNothingSelected(AdapterView<?> adapterView) {
238-
239-
}
240-
});
241213

242214
// setup the toolbar
243215
setupToolbar();
@@ -300,11 +272,7 @@ public void showToolbarSpinner() {
300272
private void fillDirectoryDropdown() {
301273
File currentDir = mCurrentDir;
302274
while (currentDir != null && currentDir.getParentFile() != null) {
303-
if (currentDir.getName().equals("0")) {
304-
mDirectories.add(getResources().getString(R.string.storage_internal_storage));
305-
} else {
306-
mDirectories.add(currentDir.getName());
307-
}
275+
mDirectories.add(currentDir.getName());
308276
currentDir = currentDir.getParentFile();
309277
}
310278
mDirectories.add(File.separator);
@@ -533,16 +501,15 @@ public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String.
533501

534502
// set result code
535503
switch (binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition()) {
536-
// Not required for NMC
537-
/*case 0: // move to nextcloud folder
504+
case 0: // move to nextcloud folder
538505
setResult(RESULT_OK_AND_MOVE, data);
539-
break;*/
506+
break;
540507

541-
case 0: // only upload
508+
case 1: // only upload
542509
setResult(RESULT_OK_AND_DO_NOTHING, data);
543510
break;
544511

545-
case 1: // upload and delete from source
512+
case 2: // upload and delete from source
546513
setResult(RESULT_OK_AND_DELETE, data);
547514
break;
548515

@@ -610,7 +577,7 @@ private void checkWritableFolder(File folder) {
610577
int localBehaviour = preferences.getUploaderBehaviour();
611578
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
612579
} else {
613-
binding.uploadFilesSpinnerBehaviour.setSelection(0);
580+
binding.uploadFilesSpinnerBehaviour.setSelection(1);
614581
textView.setText(new StringBuilder().append(getString(R.string.uploader_upload_files_behaviour))
615582
.append(' ')
616583
.append(getString(R.string.uploader_upload_files_behaviour_not_writable))

app/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import android.content.Intent;
3131
import android.content.IntentFilter;
3232
import android.content.ServiceConnection;
33-
import android.content.res.Configuration;
3433
import android.os.Bundle;
3534
import android.os.IBinder;
3635
import android.view.Menu;
@@ -57,13 +56,11 @@
5756
import com.owncloud.android.operations.CheckCurrentCredentialsOperation;
5857
import com.owncloud.android.ui.adapter.UploadListAdapter;
5958
import com.owncloud.android.ui.decoration.MediaGridItemDecoration;
60-
import com.owncloud.android.ui.decoration.SimpleListItemDividerDecoration;
6159
import com.owncloud.android.utils.FilesSyncHelper;
6260
import com.owncloud.android.utils.theme.ViewThemeUtils;
6361

6462
import javax.inject.Inject;
6563

66-
import androidx.annotation.NonNull;
6764
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
6865
import androidx.recyclerview.widget.GridLayoutManager;
6966
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
@@ -111,8 +108,6 @@ public class UploadListActivity extends FileActivity {
111108

112109
private UploadListLayoutBinding binding;
113110

114-
private SimpleListItemDividerDecoration simpleListItemDividerDecoration;
115-
116111
public static Intent createIntent(OCFile file, User user, Integer flag, Context context) {
117112
Intent intent = new Intent(context, UploadListActivity.class);
118113
if (flag != null) {
@@ -177,8 +172,6 @@ private void setupContent() {
177172
int spacing = getResources().getDimensionPixelSize(R.dimen.media_grid_spacing);
178173
binding.list.addItemDecoration(new MediaGridItemDecoration(spacing));
179174
binding.list.setLayoutManager(lm);
180-
simpleListItemDividerDecoration = new SimpleListItemDividerDecoration(this, R.drawable.item_divider, true);
181-
addListItemDecorator();
182175
binding.list.setAdapter(uploadListAdapter);
183176

184177
viewThemeUtils.androidx.themeSwipeRefreshLayout(swipeListRefreshLayout);
@@ -187,23 +180,6 @@ private void setupContent() {
187180
loadItems();
188181
}
189182

190-
private void addListItemDecorator() {
191-
if (com.nmc.android.utils.DisplayUtils.isShowDividerForList()) {
192-
//check and remove divider item decorator if exist then add item decorator
193-
removeListDividerDecorator();
194-
binding.list.addItemDecoration(simpleListItemDividerDecoration);
195-
}
196-
}
197-
198-
/**
199-
* method to remove the divider item decorator
200-
*/
201-
private void removeListDividerDecorator() {
202-
if (binding.list.getItemDecorationCount() > 0) {
203-
binding.list.removeItemDecoration(simpleListItemDividerDecoration);
204-
}
205-
}
206-
207183
private void loadItems() {
208184
uploadListAdapter.loadUploadItemsFromDb();
209185

@@ -386,20 +362,4 @@ public void onReceive(Context context, Intent intent) {
386362
});
387363
}
388364
}
389-
390-
@Override
391-
public void onConfigurationChanged(@NonNull Configuration newConfig) {
392-
super.onConfigurationChanged(newConfig);
393-
//this should only run when device is not tablet because we are adding dividers in tablet for both the
394-
// orientations
395-
if (!com.nmc.android.utils.DisplayUtils.isTablet()) {
396-
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
397-
//add the divider item decorator when orientation is landscape
398-
addListItemDecorator();
399-
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
400-
//remove the divider item decorator when orientation is portrait
401-
removeListDividerDecorator();
402-
}
403-
}
404-
}
405365
}

app/src/main/java/com/owncloud/android/ui/decoration/SimpleListItemDividerDecoration.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import android.util.DisplayMetrics;
2929
import android.view.View;
3030

31-
import androidx.core.content.ContextCompat;
3231
import androidx.recyclerview.widget.DividerItemDecoration;
3332
import androidx.recyclerview.widget.RecyclerView;
3433

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

4140
private final Rect bounds = new Rect();
4241
private Drawable divider;
43-
private int leftPadding = 0;
44-
private boolean hasFooter;
42+
private int leftPadding;
4543

4644
/**
4745
* Default divider will be used
@@ -54,17 +52,6 @@ public SimpleListItemDividerDecoration(Context context) {
5452
styledAttributes.recycle();
5553
}
5654

57-
/**
58-
* Custom divider will be used
59-
*
60-
* @param hasFooter if recyclerview has footer and no divider should be shown for footer then pass true else false
61-
*/
62-
public SimpleListItemDividerDecoration(Context context, int resId, boolean hasFooter) {
63-
super(context, DividerItemDecoration.VERTICAL);
64-
this.hasFooter = hasFooter;
65-
divider = ContextCompat.getDrawable(context, resId);
66-
}
67-
6855
@Override
6956
public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
7057
canvas.save();
@@ -78,12 +65,7 @@ public void onDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state)
7865
right = parent.getWidth();
7966
}
8067

81-
int childCount = parent.getChildCount();
82-
83-
if (hasFooter) {
84-
childCount = childCount - 1;
85-
}
86-
68+
final int childCount = parent.getChildCount();
8769
for (int i = 0; i < childCount; i++) {
8870
final View child = parent.getChildAt(i);
8971
parent.getDecoratedBoundsWithMargins(child, bounds);

app/src/main/java/com/owncloud/android/ui/dialog/LocalStoragePathPickerDialogFragment.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,12 @@ private List<StoragePathItem> getPathList() {
140140
Environment.getExternalStoragePublicDirectory(standardDirectory.getName()).getAbsolutePath());
141141
}
142142

143+
String sdCard = getString(R.string.storage_internal_storage);
143144
for (String dir : FileStorageUtils.getStorageDirectories(requireActivity())) {
144-
//NMC Customisation
145145
if (internalStoragePaths.contains(dir)) {
146-
String internalStorage = getString(R.string.storage_internal_storage);
147-
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, internalStorage, dir);
146+
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, sdCard, dir);
148147
} else {
149-
String sdCard = getString(R.string.storage_sd_card);
150-
addIfExists(storagePathItems, R.drawable.ic_sd, sdCard, dir);
148+
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, new File(dir).getName(), dir);
151149
}
152150
}
153151

0 commit comments

Comments
 (0)