|
73 | 73 | import com.nextcloud.utils.extensions.IntentExtensionsKt;
|
74 | 74 | import com.nextcloud.utils.fileNameValidator.FileNameValidator;
|
75 | 75 | import com.nextcloud.utils.view.FastScrollUtils;
|
76 |
| -import com.owncloud.android.BuildConfig; |
77 | 76 | import com.owncloud.android.MainApp;
|
78 | 77 | import com.owncloud.android.R;
|
79 | 78 | import com.owncloud.android.databinding.FilesBinding;
|
80 | 79 | import com.owncloud.android.datamodel.FileDataStorageManager;
|
| 80 | +import com.owncloud.android.datamodel.MediaFolderType; |
81 | 81 | import com.owncloud.android.datamodel.OCFile;
|
82 | 82 | import com.owncloud.android.datamodel.SyncedFolder;
|
83 | 83 | import com.owncloud.android.datamodel.SyncedFolderProvider;
|
@@ -176,6 +176,7 @@ public class FileDisplayActivity extends FileActivity
|
176 | 176 | public static final String RESTART = "RESTART";
|
177 | 177 | public static final String ALL_FILES = "ALL_FILES";
|
178 | 178 | public static final String LIST_GROUPFOLDERS = "LIST_GROUPFOLDERS";
|
| 179 | + public static final String AUTO_UPLOAD_NOTIFICATION = "AUTO_UPLOAD_NOTIFICATION"; |
179 | 180 | public static final int SINGLE_USER_SIZE = 1;
|
180 | 181 | public static final String OPEN_FILE = "NC_OPEN_FILE";
|
181 | 182 |
|
@@ -283,15 +284,16 @@ protected void onCreate(Bundle savedInstanceState) {
|
283 | 284 | mPlayerConnection = new PlayerServiceConnection(this);
|
284 | 285 |
|
285 | 286 | checkStoragePath();
|
286 |
| - checkAutoUploadOnGPlay(); |
| 287 | + notifyGPlayPermissionChanges(); |
| 288 | + showAutoUploadWarningForGPlayFlavour(); |
287 | 289 |
|
288 | 290 | initSyncBroadcastReceiver();
|
289 | 291 | observeWorkerState();
|
290 | 292 | registerRefreshFolderEventReceiver();
|
291 | 293 | }
|
292 | 294 |
|
293 |
| - private void checkAutoUploadOnGPlay() { |
294 |
| - if (!BuildHelper.GPLAY.equals(BuildConfig.FLAVOR)) { |
| 295 | + private void notifyGPlayPermissionChanges() { |
| 296 | + if (!BuildHelper.INSTANCE.isFlavourGPlay() || MainApp.isClientBranded()) { |
295 | 297 | return;
|
296 | 298 | }
|
297 | 299 |
|
@@ -333,6 +335,41 @@ private void checkAutoUploadOnGPlay() {
|
333 | 335 | preferences.setAutoUploadGPlayWarningShown(true);
|
334 | 336 | }
|
335 | 337 |
|
| 338 | + private void showAutoUploadWarningForGPlayFlavour() { |
| 339 | + if (!BuildHelper.INSTANCE.isFlavourGPlay() || MainApp.isClientBranded()) { |
| 340 | + return; |
| 341 | + } |
| 342 | + |
| 343 | + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { |
| 344 | + return; |
| 345 | + } |
| 346 | + |
| 347 | + boolean showAutoUploadDialog = false; |
| 348 | + for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) { |
| 349 | + if (syncedFolder.getType() == MediaFolderType.CUSTOM) { |
| 350 | + showAutoUploadDialog = true; |
| 351 | + break; |
| 352 | + } |
| 353 | + } |
| 354 | + |
| 355 | + if (!preferences.isAutoUploadGPlayWarning2Shown()) { |
| 356 | + String title = showAutoUploadDialog ? getString(R.string.auto_upload_gplay) : getString(R.string.upload_gplay); |
| 357 | + String message = showAutoUploadDialog ? getString(R.string.auto_upload_gplay_desc2) : getString(R.string.upload_gplay_desc); |
| 358 | + |
| 359 | + new MaterialAlertDialogBuilder(this, R.style.Theme_ownCloud_Dialog) |
| 360 | + .setTitle(title) |
| 361 | + .setMessage(message) |
| 362 | + .setNegativeButton(R.string.dialog_close, (dialog, which) -> { |
| 363 | + PermissionUtil.requestMediaLocationPermission(this); |
| 364 | + preferences.setAutoUploadGPlayWarning2Shown(true); |
| 365 | + dialog.dismiss(); |
| 366 | + }) |
| 367 | + .setIcon(R.drawable.nav_synced_folders) |
| 368 | + .create() |
| 369 | + .show(); |
| 370 | + } |
| 371 | + } |
| 372 | + |
336 | 373 | @SuppressWarnings("unchecked")
|
337 | 374 | private void loadSavedInstanceState(Bundle savedInstanceState) {
|
338 | 375 | if (savedInstanceState != null) {
|
@@ -617,9 +654,24 @@ protected void onNewIntent(Intent intent) {
|
617 | 654 |
|
618 | 655 | setLeftFragment(new GroupfolderListFragment());
|
619 | 656 | getSupportFragmentManager().executePendingTransactions();
|
| 657 | + } else if (AUTO_UPLOAD_NOTIFICATION.equals(intent.getAction())) { |
| 658 | + handleAutoUploadNotification(); |
620 | 659 | }
|
621 | 660 | }
|
622 | 661 | }
|
| 662 | + |
| 663 | + private void handleAutoUploadNotification() { |
| 664 | + new MaterialAlertDialogBuilder(this, R.style.Theme_ownCloud_Dialog) |
| 665 | + .setTitle(R.string.re_enable_auto_upload) |
| 666 | + .setMessage(R.string.re_enable_auto_upload_desc) |
| 667 | + .setNegativeButton(R.string.dialog_close, (dialog, which) -> { |
| 668 | + dialog.dismiss(); |
| 669 | + preferences.setAutoUploadGPlayNotificationShown(true); |
| 670 | + }) |
| 671 | + .setIcon(R.drawable.nav_synced_folders) |
| 672 | + .create() |
| 673 | + .show(); |
| 674 | + } |
623 | 675 |
|
624 | 676 | private void onOpenFileIntent(Intent intent) {
|
625 | 677 | String extra = intent.getStringExtra(EXTRA_FILE);
|
|
0 commit comments