* This service is started and stopped by the Android System.
*/
public class CameraSyncService extends Service {
@@ -16,6 +22,7 @@ public class CameraSyncService extends Service {
@Override
public void onCreate() {
+ Log.e(CameraSyncService.class.getName(), "CameraSyncService onCreate");
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new CameraSyncAdapter(getApplicationContext());
@@ -23,9 +30,15 @@ public void onCreate() {
}
}
+ @Override
+ public void onDestroy() {
+ Log.e(CameraSyncService.class.getName(), "CameraSyncService onDestroy");
+ super.onDestroy();
+ }
+
@Override
public IBinder onBind(Intent intent) {
+ Log.e(CameraSyncService.class.getName(), "CameraSyncService onBind");
return sSyncAdapter.getSyncAdapterBinder();
}
-
}
diff --git a/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadConfigActivity.java b/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadConfigActivity.java
index e077b6e74..42343f13d 100644
--- a/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadConfigActivity.java
+++ b/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadConfigActivity.java
@@ -17,10 +17,11 @@
import com.seafile.seadroid2.ui.activity.SeafilePathChooserActivity;
import com.seafile.seadroid2.ui.fragment.SettingsFragment;
import com.seafile.seadroid2.util.SystemSwitchUtils;
-import com.viewpagerindicator.LinePageIndicator;
import java.util.List;
+import me.relex.circleindicator.CircleIndicator;
+
/**
* Camera upload configuration helper
@@ -29,7 +30,8 @@ public class CameraUploadConfigActivity extends BaseActivity {
public String DEBUG_TAG = "CameraUploadConfigActivity";
private ViewPager mViewPager;
- private LinePageIndicator mIndicator;
+
+ private CircleIndicator magicIndicator;
private BucketsFragment mBucketsFragment;
private CloudLibraryFragment mCloudLibFragment;
private WhatToUploadFragment whatToUploadFragment;
@@ -63,15 +65,15 @@ public void onCreate(Bundle savedInstanceState) {
FragmentManager fm = getSupportFragmentManager();
mViewPager.setAdapter(new CameraUploadConfigAdapter(fm));
mViewPager.setOffscreenPageLimit(6);
+ mViewPager.addOnPageChangeListener(pageChangeListener);
- mIndicator = (LinePageIndicator) findViewById(R.id.cuc_indicator);
- mIndicator.setViewPager(mViewPager);
- mIndicator.setOnPageChangeListener(pageChangeListener);
+ magicIndicator = findViewById(R.id.cuc_indicator);
+ magicIndicator.setViewPager(mViewPager);
sm = SettingsManager.instance();
if (isChooseLibPage || isChooseDirPage) {
- mIndicator.setVisibility(View.GONE);
+ magicIndicator.setVisibility(View.GONE);
}
}
@@ -132,7 +134,7 @@ public void onBackPressed() {
} else {
// navigate to previous page when press back button
mCurrentPosition -= 1;
- mIndicator.setCurrentItem(mCurrentPosition);
+ mViewPager.setCurrentItem(mCurrentPosition);
}
}
diff --git a/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadManager.java b/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadManager.java
index 1d7da46f5..52c82ccf9 100644
--- a/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadManager.java
+++ b/app/src/main/java/com/seafile/seadroid2/cameraupload/CameraUploadManager.java
@@ -3,6 +3,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.os.Bundle;
+import android.util.Log;
import com.seafile.seadroid2.BuildConfig;
import com.seafile.seadroid2.account.Account;
@@ -67,6 +68,7 @@ public void performSync() {
public void performFullSync() {
Bundle b = new Bundle();
b.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true);
+ Log.d(CameraUploadManager.class.getName(),"performFullSync()~");
Account cameraAccount = getCameraAccount();
if (cameraAccount != null)
diff --git a/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaObserverService.java b/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaObserverService.java
index 9d12ea37c..20fd32270 100644
--- a/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaObserverService.java
+++ b/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaObserverService.java
@@ -7,6 +7,7 @@
import android.net.Uri;
import android.os.IBinder;
import android.provider.MediaStore;
+import android.util.Log;
import com.seafile.seadroid2.SettingsManager;
@@ -102,19 +103,19 @@ private void registerContentObservers() {
mediaObserver = new MediaObserver();
getApplicationContext().getContentResolver().registerContentObserver(
- MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, mediaObserver);
+ MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, mediaObserver);
-// getApplicationContext().getContentResolver().registerContentObserver
-// (MediaStore.Video.Media.EXTERNAL_CONTENT_URI, false, mediaObserver);
+ getApplicationContext().getContentResolver().registerContentObserver
+ (MediaStore.Video.Media.EXTERNAL_CONTENT_URI, true, mediaObserver);
- // Log.i(DEBUG_TAG, "Started watchting for new media content.");
+ Log.i(DEBUG_TAG, "Started watchting for new media content.");
}
private void unregisterContentObservers() {
this.getApplicationContext().getContentResolver()
.unregisterContentObserver(mediaObserver);
- // Log.i(DEBUG_TAG, "Stopped watchting for new media content.");
+ Log.i(DEBUG_TAG, "Stopped watchting for new media content.");
}
private class MediaObserver extends ContentObserver {
@@ -131,7 +132,7 @@ public void onChange(boolean selfChange) {
public void onChange(boolean selfChange, Uri changeUri) {
if (cameraManager.isCameraUploadEnabled()) {
- // Log.d(DEBUG_TAG, "Noticed a change in the media provider, scheduling sync.");
+ Log.d(DEBUG_TAG, "Noticed a change in the media provider, scheduling sync.");
cameraManager.performSync();
}
}
diff --git a/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaSchedulerService.java b/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaSchedulerService.java
index e36ad8d0f..c679d1e88 100644
--- a/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaSchedulerService.java
+++ b/app/src/main/java/com/seafile/seadroid2/cameraupload/MediaSchedulerService.java
@@ -6,13 +6,13 @@
import android.content.SharedPreferences;
import android.os.Build;
import android.support.annotation.RequiresApi;
+import android.util.Log;
import com.seafile.seadroid2.SettingsManager;
/**
* This service monitors the media provider content provider for new images/videos.
*/
-@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class MediaSchedulerService extends JobService {
private SettingsManager mSettingsManager;
private CameraUploadManager mCameraManager;
@@ -20,6 +20,7 @@ public class MediaSchedulerService extends JobService {
@Override
public boolean onStartJob(JobParameters jobParameters) {
+ Log.i(MediaSchedulerService.class.getName(),"MediaSchedulerService exec job");
mSettingsManager = SettingsManager.instance();
mSettingsManager.registerSharedPreferencesListener(settingsListener);
mCameraManager = new CameraUploadManager(getApplicationContext());
diff --git a/app/src/main/java/com/seafile/seadroid2/config/GlideLoadConfig.java b/app/src/main/java/com/seafile/seadroid2/config/GlideLoadConfig.java
index b8db37935..939a680ec 100644
--- a/app/src/main/java/com/seafile/seadroid2/config/GlideLoadConfig.java
+++ b/app/src/main/java/com/seafile/seadroid2/config/GlideLoadConfig.java
@@ -11,6 +11,10 @@
public class GlideLoadConfig {
public static GlideUrl getGlideUrl(String url) {
+ if (SupportAccountManager.getInstance().getCurrentAccount() == null) {
+ return new GlideUrl(url, new LazyHeaders.Builder().build());
+ }
+
String token = SupportAccountManager.getInstance().getCurrentAccount().token;
GlideUrl glideUrl = new GlideUrl(url, new LazyHeaders.Builder()
diff --git a/app/src/main/java/com/seafile/seadroid2/notification/DownloadNotificationProvider.java b/app/src/main/java/com/seafile/seadroid2/notification/DownloadNotificationProvider.java
index 7f1c5ca47..9adfafd8c 100644
--- a/app/src/main/java/com/seafile/seadroid2/notification/DownloadNotificationProvider.java
+++ b/app/src/main/java/com/seafile/seadroid2/notification/DownloadNotificationProvider.java
@@ -105,7 +105,7 @@ public void notifyStarted() {
PendingIntent dPendingIntent = PendingIntent.getActivity(SeadroidApplication.getAppContext(),
(int) System.currentTimeMillis(),
dIntent,
- 0);
+ PendingIntent.FLAG_IMMUTABLE);
mNotifBuilder = CustomNotificationBuilder.getNotificationBuilder(SeadroidApplication.getAppContext(),
CustomNotificationBuilder.CHANNEL_ID_DOWNLOAD)
.setSmallIcon(R.drawable.icon)
diff --git a/app/src/main/java/com/seafile/seadroid2/notification/UploadNotificationProvider.java b/app/src/main/java/com/seafile/seadroid2/notification/UploadNotificationProvider.java
index 74500d4d5..b6dd8e8af 100644
--- a/app/src/main/java/com/seafile/seadroid2/notification/UploadNotificationProvider.java
+++ b/app/src/main/java/com/seafile/seadroid2/notification/UploadNotificationProvider.java
@@ -1,5 +1,7 @@
package com.seafile.seadroid2.notification;
+import static android.app.PendingIntent.FLAG_IMMUTABLE;
+
import android.app.PendingIntent;
import android.content.Intent;
import com.seafile.seadroid2.R;
@@ -64,9 +66,7 @@ protected void notifyStarted() {
dIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent uPendingIntent = PendingIntent.getActivity(SeadroidApplication.getAppContext(),
- (int) System.currentTimeMillis(),
- dIntent,
- 0);
+ (int) System.currentTimeMillis(), dIntent, FLAG_IMMUTABLE);
mNotifBuilder = CustomNotificationBuilder.getNotificationBuilder(SeadroidApplication.getAppContext(),
CustomNotificationBuilder.CHANNEL_ID_UPLOAD)
.setSmallIcon(R.drawable.icon)
diff --git a/app/src/main/java/com/seafile/seadroid2/ui/WidgetUtils.java b/app/src/main/java/com/seafile/seadroid2/ui/WidgetUtils.java
index 0e0d66c45..0492a8a77 100644
--- a/app/src/main/java/com/seafile/seadroid2/ui/WidgetUtils.java
+++ b/app/src/main/java/com/seafile/seadroid2/ui/WidgetUtils.java
@@ -13,6 +13,7 @@
import com.seafile.seadroid2.R;
import com.seafile.seadroid2.SeadroidApplication;
+import com.seafile.seadroid2.SeafException;
import com.seafile.seadroid2.account.Account;
import com.seafile.seadroid2.ui.activity.BaseActivity;
import com.seafile.seadroid2.ui.activity.BrowserActivity;
@@ -25,6 +26,7 @@
import com.seafile.seadroid2.util.Utils;
import java.io.File;
+import java.net.HttpURLConnection;
import java.util.List;
/**
@@ -67,6 +69,17 @@ public void onTaskSuccess() {
// clipboard.setPrimaryClip(clip);
Toast.makeText(activity, R.string.link_ready_to_be_pasted, Toast.LENGTH_SHORT).show();
}
+
+ @Override
+ public void onTaskFailed(SeafException e) {
+ super.onTaskFailed(e);
+ gdialog.dismiss();
+ if (e.getCode() == HttpURLConnection.HTTP_FORBIDDEN) {
+ Toast.makeText(activity, R.string.share_link_no_permission, Toast.LENGTH_LONG).show();
+ } else {
+ Toast.makeText(activity, e.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ }
});
gdialog.show(activity.getSupportFragmentManager(), "DialogFragment");
}
@@ -78,7 +91,7 @@ public void onAppSelected(ResolveInfo appInfo) {
shareIntent.setClassName(packageName, className);
final GetShareLinkDialog gdialog = new GetShareLinkDialog();
- gdialog.init(repoID, path, isdir, account,password, days);
+ gdialog.init(repoID, path, isdir, account, password, days);
gdialog.setTaskDialogLisenter(new TaskDialog.TaskDialogListener() {
@Override
public void onTaskSuccess() {
@@ -97,17 +110,17 @@ public static void inputSharePassword(final BaseActivity activity,
final String repoID,
final String path,
final boolean isdir,
- final Account account){
+ final Account account) {
final GetShareLinkEncryptDialog dialog = new GetShareLinkEncryptDialog();
dialog.setTaskDialogLisenter(new TaskDialog.TaskDialogListener() {
@Override
public void onTaskSuccess() {
String password = dialog.getPassword();
String days = dialog.getDays();
- chooseShareApp(activity,repoID,path,isdir,account,password,days);
+ chooseShareApp(activity, repoID, path, isdir, account, password, days);
}
});
- dialog.show(activity.getSupportFragmentManager(),BrowserActivity.CHARE_LINK_PASSWORD_FRAGMENT_TAG);
+ dialog.show(activity.getSupportFragmentManager(), BrowserActivity.CHARE_LINK_PASSWORD_FRAGMENT_TAG);
}
diff --git a/app/src/main/java/com/seafile/seadroid2/ui/activity/BrowserActivity.java b/app/src/main/java/com/seafile/seadroid2/ui/activity/BrowserActivity.java
index 267936621..d67935ae4 100644
--- a/app/src/main/java/com/seafile/seadroid2/ui/activity/BrowserActivity.java
+++ b/app/src/main/java/com/seafile/seadroid2/ui/activity/BrowserActivity.java
@@ -1,8 +1,11 @@
package com.seafile.seadroid2.ui.activity;
+import static com.seafile.seadroid2.cameraupload.CameraUploadManager.AUTHORITY;
+
import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -47,8 +50,7 @@
import com.seafile.seadroid2.SettingsManager;
import com.seafile.seadroid2.account.Account;
import com.seafile.seadroid2.account.AccountManager;
-import com.seafile.seadroid2.folderbackup.FolderBackupService;
-import com.seafile.seadroid2.folderbackup.FolderBackupService.FileBackupBinder;
+import com.seafile.seadroid2.cameraupload.CameraSyncService;
import com.seafile.seadroid2.cameraupload.CameraUploadManager;
import com.seafile.seadroid2.cameraupload.MediaObserverService;
import com.seafile.seadroid2.data.CheckUploadServiceEvent;
@@ -60,6 +62,8 @@
import com.seafile.seadroid2.data.ServerInfo;
import com.seafile.seadroid2.data.StorageManager;
import com.seafile.seadroid2.fileschooser.MultiFileChooserActivity;
+import com.seafile.seadroid2.folderbackup.FolderBackupService;
+import com.seafile.seadroid2.folderbackup.FolderBackupService.FileBackupBinder;
import com.seafile.seadroid2.monitor.FileMonitorService;
import com.seafile.seadroid2.notification.DownloadNotificationProvider;
import com.seafile.seadroid2.notification.UploadNotificationProvider;
@@ -99,7 +103,6 @@
import com.seafile.seadroid2.util.ConcurrentAsyncTask;
import com.seafile.seadroid2.util.Utils;
import com.seafile.seadroid2.util.UtilsJellyBean;
-import com.viewpagerindicator.IconPagerAdapter;
import org.apache.commons.io.IOUtils;
import org.greenrobot.eventbus.EventBus;
@@ -697,7 +700,7 @@ private boolean checkSearchEnabled() {
return serverInfo.isSearchEnabled();
}
- private class SeafileTabsAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
+ private class SeafileTabsAdapter extends FragmentPagerAdapter {
public SeafileTabsAdapter(FragmentManager fm) {
super(fm);
}
@@ -754,10 +757,10 @@ public CharSequence getPageTitle(int position) {
}
}
- @Override
- public int getIconResId(int index) {
- return ICONS[index];
- }
+// @Override
+// public int getIconResId(int index) {
+// return ICONS[index];
+// }
@Override
public int getCount() {
@@ -2478,6 +2481,7 @@ public void onEvent(CheckUploadServiceEvent result) {
} else {
Log.d(DEBUG_TAG, "onEvent============true ");
}
+
if (!Utils.isServiceRunning(BrowserActivity.this, "com.seafile.seadroid2.monitor.FileMonitorService")) {
monitorIntent = new Intent(this, FileMonitorService.class);
startService(monitorIntent);
@@ -2489,6 +2493,5 @@ public void onEvent(CheckUploadServiceEvent result) {
startService(monitorIntent);
Log.d(DEBUG_TAG, "FolderBackupService============false ");
}
-
}
}
diff --git a/app/src/main/java/com/seafile/seadroid2/ui/activity/FileActivity.java b/app/src/main/java/com/seafile/seadroid2/ui/activity/FileActivity.java
index d4ac69781..b8034439f 100644
--- a/app/src/main/java/com/seafile/seadroid2/ui/activity/FileActivity.java
+++ b/app/src/main/java/com/seafile/seadroid2/ui/activity/FileActivity.java
@@ -76,7 +76,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
- mAccount = intent.getParcelableExtra("account");
+ mAccount = intent.getParcelableExtra("account");
mRepoName = intent.getStringExtra("repoName");
mRepoID = intent.getStringExtra("repoID");
mFilePath = intent.getStringExtra("filePath");
@@ -117,11 +117,11 @@ protected void onDestroy() {
}
private void initWidgets() {
- mFileNameText = (TextView)findViewById(R.id.file_name);
- mFileIcon = (ImageView)findViewById(R.id.file_icon);
- mButtonCancel = (Button)findViewById(R.id.op_cancel);
- mProgressBar = (ProgressBar)findViewById(R.id.progress_bar);
- mProgressText = (TextView)findViewById(R.id.progress_text);
+ mFileNameText = (TextView) findViewById(R.id.file_name);
+ mFileIcon = (ImageView) findViewById(R.id.file_icon);
+ mButtonCancel = (Button) findViewById(R.id.op_cancel);
+ mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
+ mProgressText = (TextView) findViewById(R.id.progress_text);
String fileName = Utils.fileNameFromPath(mFilePath);
mFileNameText.setText(fileName);
@@ -181,7 +181,7 @@ private void onFileDownloadProgress(DownloadTaskInfo info) {
if (fileSize == 0) {
percent = 100;
} else {
- percent = (int)(finished * 100 / fileSize);
+ percent = (int) (finished * 100 / fileSize);
}
mProgressBar.setProgress(percent);
@@ -211,8 +211,7 @@ private void onFileDownloaded() {
result.putExtra("path", file.getAbsolutePath());
result.putExtra("is_open_with", isOpenWith);
setResult(RESULT_OK, result);
- }
- else {
+ } else {
setResult(RESULT_CANCELED);
}
stopTimer();
@@ -292,7 +291,7 @@ else if (downloadTaskInfo.state == TaskState.FINISHED)
else if (downloadTaskInfo.state == TaskState.CANCELLED)
// do nothing when cancelled
- Log.d(DEBUG_TAG, "timer post refresh signal " + System.currentTimeMillis());
+ Log.d(DEBUG_TAG, "timer post refresh signal " + System.currentTimeMillis());
mTimer.postDelayed(this, 1 * 1000);
}
}, 1 * 1000);
diff --git a/app/src/main/java/com/seafile/seadroid2/ui/activity/MarkdownActivity.java b/app/src/main/java/com/seafile/seadroid2/ui/activity/MarkdownActivity.java
index 1cc690fc1..2c66347d6 100644
--- a/app/src/main/java/com/seafile/seadroid2/ui/activity/MarkdownActivity.java
+++ b/app/src/main/java/com/seafile/seadroid2/ui/activity/MarkdownActivity.java
@@ -100,13 +100,8 @@ private void edit() {
// First try to find an activity who can handle markdown edit
Intent editAsMarkDown = new Intent(Intent.ACTION_EDIT);
- Uri uri;
- if (android.os.Build.VERSION.SDK_INT > 23) {
- uri = FileProvider.getUriForFile(this, getPackageName() , new File(path));
- editAsMarkDown.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
- } else {
- uri = Uri.parse(path);
- }
+ Uri uri = FileProvider.getUriForFile(this, getPackageName(), new File(path));
+ editAsMarkDown.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
String mime = FileMimeUtils.getMimeType(new File(path));
editAsMarkDown.setDataAndType(uri, mime);
diff --git a/app/src/main/java/com/seafile/seadroid2/ui/fragment/SettingsFragment.java b/app/src/main/java/com/seafile/seadroid2/ui/fragment/SettingsFragment.java
index 649359d96..1c101528e 100644
--- a/app/src/main/java/com/seafile/seadroid2/ui/fragment/SettingsFragment.java
+++ b/app/src/main/java/com/seafile/seadroid2/ui/fragment/SettingsFragment.java
@@ -24,6 +24,7 @@
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback;
+import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.seafile.seadroid2.R;
import com.seafile.seadroid2.SeadroidApplication;
@@ -319,7 +320,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
cFolderBackupCategory.removePreference(cBackupFolderState);
SettingsManager.instance().saveFolderAutomaticBackup(false);
} else {
- XXPermissions.with(getActivity()).permission("android.permission.MANAGE_EXTERNAL_STORAGE").request(new OnPermissionCallback() {
+
+ XXPermissions.with(getActivity()).permission(Permission.MANAGE_EXTERNAL_STORAGE).request(new OnPermissionCallback() {
@Override
public void onGranted(List