Loading app/src/main/java/it/niedermann/owncloud/notes/share/NoteShareActivity.java +14 −7 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,13 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap Bundle bundler = getIntent().getExtras(); Bundle bundler = getIntent().getExtras(); note = BundleExtensionsKt.getSerializableArgument(bundler, ARG_NOTE, Note.class); note = BundleExtensionsKt.getSerializableArgument(bundler, ARG_NOTE, Note.class); account = BundleExtensionsKt.getSerializableArgument(bundler, ARG_ACCOUNT, Account.class); account = BundleExtensionsKt.getSerializableArgument(bundler, ARG_ACCOUNT, Account.class); if (note == null) { throw new IllegalArgumentException("Note cannot be null"); } if (account == null) { throw new IllegalArgumentException("Account cannot be null"); } clientFactory = new ClientFactoryImpl(this); clientFactory = new ClientFactoryImpl(this); new Thread(() -> {{ new Thread(() -> {{ Loading @@ -120,13 +127,6 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap throw new RuntimeException(e); throw new RuntimeException(e); } } }}).start(); }}).start(); if (note == null) { throw new IllegalArgumentException("Note cannot be null"); } if (account == null) { throw new IllegalArgumentException("Account cannot be null"); } } } @Override @Override Loading Loading @@ -178,6 +178,13 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap binding.searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); binding.searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); binding.searchView.setQueryHint(getResources().getString(R.string.note_share_activity_search_text)); binding.searchView.setQueryHint(getResources().getString(R.string.note_share_activity_search_text)); binding.searchView.setInputType(InputType.TYPE_NULL); binding.searchView.setInputType(InputType.TYPE_NULL); View closeButton = binding.searchView.findViewById(androidx.appcompat.R.id.search_close_btn); closeButton.setOnClickListener(v -> { binding.progressBar.setVisibility(View.GONE); binding.searchView.setQuery("", false); }); binding.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { binding.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override @Override public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) { Loading app/src/main/java/it/niedermann/owncloud/notes/share/repository/ShareRepository.kt +84 −71 Original line number Original line Diff line number Diff line Loading @@ -45,11 +45,13 @@ class ShareRepository(private val applicationContext: Context, private val accou page: Int, page: Int, perPage: Int perPage: Int ): Single<ArrayList<JSONObject>> { ): Single<ArrayList<JSONObject>> { return Single.fromCallable { return try { Single.fromCallable { val shareAPI = apiProvider.getShareAPI(applicationContext, account) val shareAPI = apiProvider.getShareAPI(applicationContext, account) val call = shareAPI.getSharees(search = searchString, page = page, perPage = perPage) val call = shareAPI.getSharees(search = searchString, page = page, perPage = perPage) val response = call.execute() val response = call.execute() if (response.isSuccessful) { val respJSON = JSONObject(response.body().toString()) val respJSON = JSONObject(response.body().toString()) val respOCS = respJSON.getJSONObject("ocs") val respOCS = respJSON.getJSONObject("ocs") val respData = respOCS.getJSONObject("data") val respData = respOCS.getJSONObject("data") Loading Loading @@ -109,7 +111,18 @@ class ShareRepository(private val applicationContext: Context, private val accou } } } } data data } else { Log_OC.d(tag, "Failed to update share: ${response.errorBody()?.string()}") ArrayList() } }.subscribeOn(Schedulers.io()) }.subscribeOn(Schedulers.io()) } catch (e: Exception) { Log_OC.d(tag, "Exception while get sharees", e) Single.fromCallable { ArrayList() } } } } fun getShares( fun getShares( Loading Loading @@ -152,13 +165,13 @@ class ShareRepository(private val applicationContext: Context, private val accou val call = shareAPI.removeShare(shareId) val call = shareAPI.removeShare(shareId) val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { Log.d("RemoveShare", "Share removed successfully.") Log_OC.d(tag, "Share removed successfully.") } else { } else { Log.e("RemoveShare", "Failed to remove share: ${response.errorBody()?.string()}") Log_OC.d(tag, "Failed to remove share: ${response.errorBody()?.string()}") } } response.isSuccessful response.isSuccessful } catch (e: Exception) { } catch (e: Exception) { Log.e("RemoveShare", "Exception while removing share", e) Log_OC.d(tag, "Exception while removing share", e) false false } } } } Loading @@ -173,10 +186,10 @@ class ShareRepository(private val applicationContext: Context, private val accou val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { val updateShareResponse = response.body() val updateShareResponse = response.body() Log.d("", "Response successful: $updateShareResponse") Log_OC.d(tag, "Response successful: $updateShareResponse") } else { } else { val errorBody = response.errorBody()?.string() val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") Log_OC.d(tag, "Response failed:$errorBody") } } return response.isSuccessful return response.isSuccessful Loading Loading @@ -212,10 +225,10 @@ class ShareRepository(private val applicationContext: Context, private val accou val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { val createShareResponse = response.body() val createShareResponse = response.body() Log.d("", "Response successful: $createShareResponse") Log_OC.d(tag, "Response successful: $createShareResponse") } else { } else { val errorBody = response.errorBody()?.string() val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") Log_OC.d(tag, "Response failed:$errorBody") } } return response.isSuccessful return response.isSuccessful Loading Loading @@ -255,13 +268,13 @@ class ShareRepository(private val applicationContext: Context, private val accou val call = shareAPI.updateShareInfo(shareId, requestBody) val call = shareAPI.updateShareInfo(shareId, requestBody) val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { Log.d("UpdateShare", "Share updated successfully: ${response.body()}") Log_OC.d(tag, "Share updated successfully: ${response.body()}") } else { } else { Log.e("UpdateShare", "Failed to update share: ${response.errorBody()?.string()}") Log_OC.d(tag, "Failed to update share: ${response.errorBody()?.string()}") } } response.isSuccessful response.isSuccessful } catch (e: Exception) { } catch (e: Exception) { Log.e("UpdateShare", "Exception while updating share", e) Log_OC.d(tag, "Exception while updating share", e) false false } } } } Loading @@ -277,13 +290,13 @@ class ShareRepository(private val applicationContext: Context, private val accou val call = shareAPI.updateSharePermission(shareId, requestBody) val call = shareAPI.updateSharePermission(shareId, requestBody) val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { Log.d("UpdateShare", "Share updated successfully: ${response.body()}") Log_OC.d(tag, "Share updated successfully: ${response.body()}") } else { } else { Log.e("UpdateShare", "Failed to update share: ${response.errorBody()?.string()}") Log_OC.d(tag, "Failed to update share: ${response.errorBody()?.string()}") } } response.isSuccessful response.isSuccessful } catch (e: Exception) { } catch (e: Exception) { Log.e("UpdateShare", "Exception while updating share", e) Log_OC.d(tag, "Exception while updating share", e) false false } } } } Loading Loading
app/src/main/java/it/niedermann/owncloud/notes/share/NoteShareActivity.java +14 −7 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,13 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap Bundle bundler = getIntent().getExtras(); Bundle bundler = getIntent().getExtras(); note = BundleExtensionsKt.getSerializableArgument(bundler, ARG_NOTE, Note.class); note = BundleExtensionsKt.getSerializableArgument(bundler, ARG_NOTE, Note.class); account = BundleExtensionsKt.getSerializableArgument(bundler, ARG_ACCOUNT, Account.class); account = BundleExtensionsKt.getSerializableArgument(bundler, ARG_ACCOUNT, Account.class); if (note == null) { throw new IllegalArgumentException("Note cannot be null"); } if (account == null) { throw new IllegalArgumentException("Account cannot be null"); } clientFactory = new ClientFactoryImpl(this); clientFactory = new ClientFactoryImpl(this); new Thread(() -> {{ new Thread(() -> {{ Loading @@ -120,13 +127,6 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap throw new RuntimeException(e); throw new RuntimeException(e); } } }}).start(); }}).start(); if (note == null) { throw new IllegalArgumentException("Note cannot be null"); } if (account == null) { throw new IllegalArgumentException("Account cannot be null"); } } } @Override @Override Loading Loading @@ -178,6 +178,13 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap binding.searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); binding.searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); binding.searchView.setQueryHint(getResources().getString(R.string.note_share_activity_search_text)); binding.searchView.setQueryHint(getResources().getString(R.string.note_share_activity_search_text)); binding.searchView.setInputType(InputType.TYPE_NULL); binding.searchView.setInputType(InputType.TYPE_NULL); View closeButton = binding.searchView.findViewById(androidx.appcompat.R.id.search_close_btn); closeButton.setOnClickListener(v -> { binding.progressBar.setVisibility(View.GONE); binding.searchView.setQuery("", false); }); binding.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { binding.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override @Override public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) { Loading
app/src/main/java/it/niedermann/owncloud/notes/share/repository/ShareRepository.kt +84 −71 Original line number Original line Diff line number Diff line Loading @@ -45,11 +45,13 @@ class ShareRepository(private val applicationContext: Context, private val accou page: Int, page: Int, perPage: Int perPage: Int ): Single<ArrayList<JSONObject>> { ): Single<ArrayList<JSONObject>> { return Single.fromCallable { return try { Single.fromCallable { val shareAPI = apiProvider.getShareAPI(applicationContext, account) val shareAPI = apiProvider.getShareAPI(applicationContext, account) val call = shareAPI.getSharees(search = searchString, page = page, perPage = perPage) val call = shareAPI.getSharees(search = searchString, page = page, perPage = perPage) val response = call.execute() val response = call.execute() if (response.isSuccessful) { val respJSON = JSONObject(response.body().toString()) val respJSON = JSONObject(response.body().toString()) val respOCS = respJSON.getJSONObject("ocs") val respOCS = respJSON.getJSONObject("ocs") val respData = respOCS.getJSONObject("data") val respData = respOCS.getJSONObject("data") Loading Loading @@ -109,7 +111,18 @@ class ShareRepository(private val applicationContext: Context, private val accou } } } } data data } else { Log_OC.d(tag, "Failed to update share: ${response.errorBody()?.string()}") ArrayList() } }.subscribeOn(Schedulers.io()) }.subscribeOn(Schedulers.io()) } catch (e: Exception) { Log_OC.d(tag, "Exception while get sharees", e) Single.fromCallable { ArrayList() } } } } fun getShares( fun getShares( Loading Loading @@ -152,13 +165,13 @@ class ShareRepository(private val applicationContext: Context, private val accou val call = shareAPI.removeShare(shareId) val call = shareAPI.removeShare(shareId) val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { Log.d("RemoveShare", "Share removed successfully.") Log_OC.d(tag, "Share removed successfully.") } else { } else { Log.e("RemoveShare", "Failed to remove share: ${response.errorBody()?.string()}") Log_OC.d(tag, "Failed to remove share: ${response.errorBody()?.string()}") } } response.isSuccessful response.isSuccessful } catch (e: Exception) { } catch (e: Exception) { Log.e("RemoveShare", "Exception while removing share", e) Log_OC.d(tag, "Exception while removing share", e) false false } } } } Loading @@ -173,10 +186,10 @@ class ShareRepository(private val applicationContext: Context, private val accou val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { val updateShareResponse = response.body() val updateShareResponse = response.body() Log.d("", "Response successful: $updateShareResponse") Log_OC.d(tag, "Response successful: $updateShareResponse") } else { } else { val errorBody = response.errorBody()?.string() val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") Log_OC.d(tag, "Response failed:$errorBody") } } return response.isSuccessful return response.isSuccessful Loading Loading @@ -212,10 +225,10 @@ class ShareRepository(private val applicationContext: Context, private val accou val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { val createShareResponse = response.body() val createShareResponse = response.body() Log.d("", "Response successful: $createShareResponse") Log_OC.d(tag, "Response successful: $createShareResponse") } else { } else { val errorBody = response.errorBody()?.string() val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") Log_OC.d(tag, "Response failed:$errorBody") } } return response.isSuccessful return response.isSuccessful Loading Loading @@ -255,13 +268,13 @@ class ShareRepository(private val applicationContext: Context, private val accou val call = shareAPI.updateShareInfo(shareId, requestBody) val call = shareAPI.updateShareInfo(shareId, requestBody) val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { Log.d("UpdateShare", "Share updated successfully: ${response.body()}") Log_OC.d(tag, "Share updated successfully: ${response.body()}") } else { } else { Log.e("UpdateShare", "Failed to update share: ${response.errorBody()?.string()}") Log_OC.d(tag, "Failed to update share: ${response.errorBody()?.string()}") } } response.isSuccessful response.isSuccessful } catch (e: Exception) { } catch (e: Exception) { Log.e("UpdateShare", "Exception while updating share", e) Log_OC.d(tag, "Exception while updating share", e) false false } } } } Loading @@ -277,13 +290,13 @@ class ShareRepository(private val applicationContext: Context, private val accou val call = shareAPI.updateSharePermission(shareId, requestBody) val call = shareAPI.updateSharePermission(shareId, requestBody) val response = call.execute() val response = call.execute() if (response.isSuccessful) { if (response.isSuccessful) { Log.d("UpdateShare", "Share updated successfully: ${response.body()}") Log_OC.d(tag, "Share updated successfully: ${response.body()}") } else { } else { Log.e("UpdateShare", "Failed to update share: ${response.errorBody()?.string()}") Log_OC.d(tag, "Failed to update share: ${response.errorBody()?.string()}") } } response.isSuccessful response.isSuccessful } catch (e: Exception) { } catch (e: Exception) { Log.e("UpdateShare", "Exception while updating share", e) Log_OC.d(tag, "Exception while updating share", e) false false } } } } Loading