Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BackupFolder #958

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e5999d2
Selecting a Backup Directory
maxiaoping Sep 22, 2022
e030f77
Add a folder backup module
maxiaoping Nov 11, 2022
a4dd5d3
The backup upload information is added to Settings
maxiaoping Dec 9, 2022
629c872
Update Select or cancel a backup folder
maxiaoping Jan 6, 2023
8c52068
Updating a backup folder
maxiaoping Jan 6, 2023
762fbbb
Updated the folder backup
maxiaoping Jan 6, 2023
04e0870
Update backup folder
maxiaoping Feb 1, 2023
0d2e842
update backup folder
maxiaoping Feb 1, 2023
f078f02
Updated folder backup and added global exception capture
maxiaoping Feb 8, 2023
ea8929a
Updated the backup folder name
maxiaoping Feb 10, 2023
c79956a
Folder backup reconstruction
maxiaoping Feb 11, 2023
793341d
Update folder backup
maxiaoping Feb 16, 2023
5fb7f9c
Updated the backup folder name
maxiaoping Feb 17, 2023
351d3cf
Update folder backup message notification
maxiaoping Feb 20, 2023
b4c6886
Update the display of folder backup status
maxiaoping Feb 25, 2023
7c07fcd
Update folder backup
maxiaoping Feb 25, 2023
1e1e1ac
Update folder backup
maxiaoping Feb 25, 2023
334f227
Update the folder backup logic
maxiaoping Feb 27, 2023
8a09388
Update the display of folder backup status
maxiaoping Mar 2, 2023
2eab112
Updated the folder backup and photo sync display status logic
maxiaoping Mar 2, 2023
1d18bbd
Update backup folder FileAlterationMonitor
maxiaoping Mar 2, 2023
114c7ba
Updated the folder backup interface
maxiaoping Mar 13, 2023
2d24915
Update folder backup observer
maxiaoping Mar 14, 2023
0ac4f40
Update the folder backup upload link
maxiaoping Mar 16, 2023
cbad36e
Update the folder backup transfer tag
maxiaoping Mar 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ android {
implementation 'com.yydcdut:markdown-processor:0.1.3'
implementation 'ren.qinc.edit:lib:0.0.5'//editor undo redo
implementation 'com.github.tiagohm.MarkdownView:library:0.19.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private SettingsManager() {
public static final String FOLDER_BACKUP_CATEGORY_KEY = "folder_backup_category_key";
public static final String FOLDER_BACKUP_MODE = "folder_backup_mode";
public static final String FOLDER_BACKUP_LIBRARY_KEY = "folder_backup_library_key";
public static final String SELECT_FOLDER_BACKUP_KEY = "select_folder_backup_key";
public static final String SELECTED_BACKUP_FOLDERS_KEY = "selected_backup_folders_key";
public static final String FOLDER_BACKUP_STATE = "folder_backup_state";
public static final String FOLDER_BACKUP_PATHS = "folder_backup_paths";

Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/com/seafile/seadroid2/data/CameraSyncEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@

public class CameraSyncEvent {
private String logInfo;
private int num;

public CameraSyncEvent(String logInfo) {
this.logInfo = logInfo;
}

public CameraSyncEvent(String logInfo, int number) {
this.logInfo = logInfo;
this.num = number;
}

public int getNum() {
return num;
}

public String getLogInfo() {
return logInfo;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.seafile.seadroid2.folderbackup;

public class FolderBackupEvent {
private String backupInfo;

public FolderBackupEvent(String backupInfo) {
this.backupInfo = backupInfo;
}

public String getBackupInfo() {
return backupInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.seafile.seadroid2.SettingsManager;
import com.seafile.seadroid2.account.Account;
import com.seafile.seadroid2.account.AccountManager;
import com.seafile.seadroid2.data.CameraSyncEvent;
import com.seafile.seadroid2.data.DataManager;
import com.seafile.seadroid2.data.SeafDirent;
import com.seafile.seadroid2.folderbackup.selectfolder.FileBean;
Expand Down Expand Up @@ -202,8 +201,7 @@ private void isFolder(String parentPath, String filePath) {
int taskID = txService.addTaskToUploadQue(currentAccount, repoConfig.getRepoID(),
repoConfig.getRepoName(), parentPath, fb.getFilePath(), false, true);
if (taskID != 0) {
EventBus.getDefault().post(new CameraSyncEvent("backupFolder", taskID));
Utils.utilsLogInfo(false, "isFolder===============" + taskID);
EventBus.getDefault().post(new FolderBackupEvent(taskID + ""));
FolderBackupInfo dirInfo = new FolderBackupInfo(repoConfig.getRepoID(), repoConfig.getRepoName(),
parentPath, fb.getFileName(), fb.getFilePath(), fb.getSimpleSize() + "");
fileUploaded.put(taskID + "", dirInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

accountManager = new AccountManager(this);
EventBus.getDefault().register(this);

// restart service should it have been stopped for some reason
Intent mediaObserver = new Intent(this, MediaObserverService.class);
startService(mediaObserver);
Expand Down Expand Up @@ -847,6 +847,8 @@ public void onServiceDisconnected(ComponentName arg0) {
public void onStart() {
Log.d(DEBUG_TAG, "onStart");
super.onStart();
EventBus.getDefault().register(this);

if (android.os.Build.VERSION.SDK_INT < 14
&& SettingsManager.instance().isGestureLockRequired()) {
Intent intent = new Intent(this, UnlockGesturePasswordActivity.class);
Expand Down Expand Up @@ -906,6 +908,7 @@ protected void onNewIntent(Intent intent) {
protected void onStop() {
Log.d(DEBUG_TAG, "onStop");
super.onStop();
EventBus.getDefault().unregister(this);

if (mTransferReceiver != null) {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mTransferReceiver);
Expand All @@ -915,7 +918,7 @@ protected void onStop() {
@Override
protected void onDestroy() {
Log.d(DEBUG_TAG, "onDestroy is called");
EventBus.getDefault().unregister(this);

if (txService != null) {
unbindService(mConnection);
txService = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
import com.seafile.seadroid2.account.Account;
import com.seafile.seadroid2.account.AccountInfo;
import com.seafile.seadroid2.account.AccountManager;
import com.seafile.seadroid2.folderbackup.FolderBackupConfigActivity;
import com.seafile.seadroid2.folderbackup.RepoConfig;
import com.seafile.seadroid2.folderbackup.selectfolder.StringTools;
import com.seafile.seadroid2.folderbackup.FolderBackupDBHelper;
import com.seafile.seadroid2.cameraupload.CameraUploadConfigActivity;
import com.seafile.seadroid2.cameraupload.CameraUploadManager;
import com.seafile.seadroid2.cameraupload.GalleryBucketUtils;
Expand All @@ -42,6 +38,11 @@
import com.seafile.seadroid2.data.DatabaseHelper;
import com.seafile.seadroid2.data.ServerInfo;
import com.seafile.seadroid2.data.StorageManager;
import com.seafile.seadroid2.folderbackup.FolderBackupConfigActivity;
import com.seafile.seadroid2.folderbackup.FolderBackupDBHelper;
import com.seafile.seadroid2.folderbackup.FolderBackupEvent;
import com.seafile.seadroid2.folderbackup.RepoConfig;
import com.seafile.seadroid2.folderbackup.selectfolder.StringTools;
import com.seafile.seadroid2.gesturelock.LockPatternUtils;
import com.seafile.seadroid2.ui.activity.BrowserActivity;
import com.seafile.seadroid2.ui.activity.CreateGesturePasswordActivity;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void onAttach(Activity activity) {
public void onCreate(Bundle savedInstanceState) {
Log.d(DEBUG_TAG, "onCreate");
super.onCreate(savedInstanceState);
EventBus.getDefault().register(this);

settingsMgr.registerSharedPreferencesListener(settingsListener);
Account account = accountMgr.getCurrentAccount();
if (!Utils.isNetworkOn()) {
Expand All @@ -156,7 +157,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);

Log.d(DEBUG_TAG, "onDestroy()");
settingsMgr.unregisterSharedPreferencesListener(settingsListener);
}
Expand Down Expand Up @@ -379,7 +380,7 @@ public boolean onPreferenceClick(Preference preference) {
// Change backup folder
cBackupFolderMode = findPreference(SettingsManager.FOLDER_BACKUP_MODE);
cBackupFolderRepo = findPreference(SettingsManager.FOLDER_BACKUP_LIBRARY_KEY);
cBackupFolderPref = findPreference(SettingsManager.SELECT_FOLDER_BACKUP_KEY);
cBackupFolderPref = findPreference(SettingsManager.SELECTED_BACKUP_FOLDERS_KEY);
cBackupFolderState = findPreference(SettingsManager.FOLDER_BACKUP_STATE);
cBackupFolderMode.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
Expand Down Expand Up @@ -1021,17 +1022,17 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin

private void showWifiDialog() {

String[]colors={"WIFI",getActivity().getString(R.string.folder_backup_mode)};
String[]buckModes={"WIFI",getActivity().getString(R.string.folder_backup_mode)};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"String[]buckModes=". 这里少了不少空格

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

new AlertDialog.Builder(getActivity())
.setCancelable(false)
.setTitle(getActivity().getString(R.string.folder_backup_mode_title))
.setPositiveButton(getActivity().getString(R.string.ok), null)
.setSingleChoiceItems(colors, 0, new DialogInterface.OnClickListener() {
.setSingleChoiceItems(buckModes, 0, new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialogInterface, int i) {

Toast.makeText(getActivity(), colors[i], Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), buckModes[i], Toast.LENGTH_SHORT).show();
if (i == 0) {
SettingsManager.instance().saveFolderBackupDataPlanAllowed(false);
} else {
Expand All @@ -1043,6 +1044,17 @@ public void onClick(DialogInterface dialogInterface, int i) {

}

@Override
public void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}

@Override
public void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(CameraSyncEvent result) {
Expand All @@ -1053,9 +1065,12 @@ public void onEvent(CameraSyncEvent result) {
}
cBackupRepoState.setSummary(Utils.getUploadStateShow(getActivity()));
}
if (result.getLogInfo().equals("backupFolder")) {
cBackupFolderState.setSummary(getActivity().getString(R.string.uploaded) + " " + result.getNum());
}

}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(FolderBackupEvent result) {
cBackupFolderState.setSummary(getActivity().getString(R.string.uploaded) + " " + result.getBackupInfo());
}

}
2 changes: 1 addition & 1 deletion app/src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
android:summary="@string/folder_backup_select_repo_hint"
android:title="@string/settings_folder_backup_library" />
<Preference
android:key="select_folder_backup_key"
android:key="selected_backup_folders_key"
android:summary="@string/settings_folder_backup_select_hint"
android:title="@string/settings_folder_backup_select_title" />
<Preference
Expand Down