Skip to content

Commit

Permalink
NMC-1920: Customized theming related changes for grid and list views.
Browse files Browse the repository at this point in the history
NMC-2121: Theming applied to passcode.
NMC-2374: Image edit functionality customized.
NMC-1941: Fixed error message coming after camera permission allowed.
NMC-2052: Fix back arrow appearing as hamburger icon. NC PR: nextcloud#11769
NMC-2465: Fix local db version to avoid crash during app upgrade.
NMC-2576: Disabled switch account SnackBar.
NMC-2123: Widget disabled.
NMC-2127: System default night mode.
NMC-1919: Backup Calendar-Contacts configured with test cases.
NMC-2089: Reduce log levels
  • Loading branch information
surinder-tsys committed Oct 28, 2024
1 parent 6e1483f commit b7f5fcf
Show file tree
Hide file tree
Showing 46 changed files with 625 additions and 279 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
android:exported="false" />
<activity
android:name="com.nextcloud.client.widget.DashboardWidgetConfigurationActivity"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
Expand All @@ -280,6 +281,7 @@
android:exported="false" />
<receiver
android:name="com.nextcloud.client.widget.DashboardWidgetProvider"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand Down Expand Up @@ -386,6 +388,7 @@
<service
android:name="com.nextcloud.client.widget.DashboardWidgetService"
android:exported="true"
android:enabled="false"
android:permission="android.permission.BIND_REMOTEVIEWS" />

<provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ abstract class NextcloudDatabase : RoomDatabase() {
abstract fun offlineOperationDao(): OfflineOperationDao

companion object {
const val FIRST_ROOM_DB_VERSION = 65
// NMC customization
// NMC play store version 7.21.9 had db version 64 before SqLite to Room migration
// Keeping it 65(as per NC) will lead to crash when user tried to upgrade the app
const val FIRST_ROOM_DB_VERSION = 64
private var instance: NextcloudDatabase? = null

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.nextcloud.client.editimage

import android.graphics.Bitmap
import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand All @@ -16,9 +17,6 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import com.canhub.cropper.CropImageView
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.jobs.upload.FileUploadHelper
Expand Down Expand Up @@ -73,21 +71,25 @@ class EditImageActivity :
file = intent.extras?.getParcelableArgument(EXTRA_FILE, OCFile::class.java)
?: throw IllegalArgumentException("Missing file argument")

setSupportActionBar(binding.toolbar)
supportActionBar?.apply {
title = file.fileName
setDisplayHomeAsUpEnabled(true)
}

val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView)
windowInsetsController.hide(WindowInsetsCompat.Type.statusBars())

window.statusBarColor = ContextCompat.getColor(this, R.color.black)
window.navigationBarColor = getColor(R.color.black)
//NMC Customization
setupToolbar()
setupActionBar()

setupCropper()
}

//NMC Customization
private fun setupActionBar() {
supportActionBar?.let {
viewThemeUtils.platform.themeStatusBar(this)
it.setDisplayHomeAsUpEnabled(true)
it.setDisplayShowTitleEnabled(true)
//custom color for back arrow for NMC
viewThemeUtils.files.themeActionBar(this, it, file.fileName)
it.setBackgroundDrawable(ColorDrawable(resources.getColor(R.color.bg_default, null)))
}
}

override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) {
if (!result.isSuccessful) {
DisplayUtils.showSnackMessage(this, getString(R.string.image_editor_unable_to_edit_image))
Expand Down Expand Up @@ -124,14 +126,20 @@ class EditImageActivity :
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
// add save button to action bar
menuInflater.inflate(R.menu.custom_menu_placeholder, menu)
val saveIcon = AppCompatResources.getDrawable(this, R.drawable.ic_check)?.also {
DrawableCompat.setTint(it, resources.getColor(R.color.white, theme))
}
// NMC: No need to apply NC tint here as we will be doing it later in code
val saveIcon = AppCompatResources.getDrawable(this, R.drawable.ic_tick)
menu?.findItem(R.id.custom_menu_placeholder_item)?.apply {
icon = saveIcon
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
contentDescription = getString(R.string.common_save)
}
// NMC customization
icon = icon?.let {
viewThemeUtils.platform.colorDrawable(
it,
ContextCompat.getColor(this@EditImageActivity, R.color.fontAppbar)
)
}
}
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
binding.thumbnailLayout.thumbnailShimmer,
syncedFolderProvider.preferences,
viewThemeUtils,
syncedFolderProvider
syncedFolderProvider,
false
)
}
}
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/com/nmc/android/ui/utils/Log_NMC.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.nmc.android.ui.utils

import com.owncloud.android.BuildConfig
import com.owncloud.android.lib.common.utils.Log_OC

/**
* NMC log interpreter class
* this class will be used whenever we have to reduce the logs writing
* this will avoid printing logs in release builds
* todo: can be extended later for more functions
*/
object Log_NMC {
@JvmStatic
fun v(tag: String?, msg: String?) {
if (BuildConfig.DEBUG) Log_OC.v(tag, msg)
}

@JvmStatic
fun d(tag: String?, msg: String?) {
if (BuildConfig.DEBUG) Log_OC.d(tag, msg)
}

@JvmStatic
fun d(tag: String, msg: String, e: Exception) {
if (BuildConfig.DEBUG) Log_OC.d(tag, msg, e)
}

@JvmStatic
fun i(tag: String?, msg: String?) {
if (BuildConfig.DEBUG) Log_OC.i(tag, msg)
}

@JvmStatic
fun e(tag: String?, msg: String?) {
if (BuildConfig.DEBUG) Log_OC.e(tag, msg)
}

@JvmStatic
fun w(tag: String?, msg: String?) {
if (BuildConfig.DEBUG) Log_OC.w(tag, msg)
}
}
7 changes: 2 additions & 5 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,8 @@ public AndroidInjector<Object> androidInjector() {
}

public static void setAppTheme(DarkMode mode) {
switch (mode) {
case LIGHT -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
case DARK -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
case SYSTEM -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
// NMC Customization -> Always follow system theme
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import android.net.Uri;
import android.provider.MediaStore;

import com.nmc.android.ui.utils.Log_NMC;
import com.owncloud.android.MainApp;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.theme.ViewThemeUtils;

Expand Down Expand Up @@ -107,7 +107,7 @@ public static List<MediaFolder> getImageFolders(ContentResolver contentResolver,
MediaStore.Images.Media.DATE_TAKEN,
ContentResolverHelper.SORT_DIRECTION_DESCENDING,
itemLimit);
Log_OC.d(TAG, "Reading images for " + mediaFolder.folderName);
Log_NMC.d(TAG, "Reading images for " + mediaFolder.folderName);

if (cursorImages != null) {
String filePath;
Expand Down Expand Up @@ -217,7 +217,7 @@ public static List<MediaFolder> getVideoFolders(ContentResolver contentResolver,
ContentResolverHelper.SORT_DIRECTION_DESCENDING,
itemLimit);

Log_OC.d(TAG, "Reading videos for " + mediaFolder.folderName);
Log_NMC.d(TAG, "Reading videos for " + mediaFolder.folderName);

if (cursorVideos != null) {
String filePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import com.nextcloud.client.account.User;
import com.nextcloud.client.network.ConnectivityService;
import com.nmc.android.ui.utils.Log_NMC;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.lib.common.OwnCloudAccount;
Expand Down Expand Up @@ -123,7 +124,7 @@ protected Void doInBackground(File... params) {
}

String cachePath = cacheDir.getPath() + File.separator + CACHE_FOLDER;
Log_OC.d(TAG, "thumbnail cache dir: " + cachePath);
Log_NMC.d(TAG, "thumbnail cache dir: " + cachePath);
File diskCacheDir = new File(cachePath);

// migrate from external cache to internal cache
Expand All @@ -140,7 +141,7 @@ protected Void doInBackground(File... params) {
mThumbnailCache = new DiskLruImageCache(diskCacheDir, DISK_CACHE_SIZE, mCompressFormat,
mCompressQuality);
} catch (Exception e) {
Log_OC.d(TAG, "Disk cache init failed", e);
Log_NMC.d(TAG, "Disk cache init failed", e);
mThumbnailCache = null;
}
}
Expand Down Expand Up @@ -723,7 +724,7 @@ private Bitmap doThumbnailFromOCFileInBackground() {
file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
}

Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
Log_NMC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
getMethod = new GetMethod(uri);
getMethod.setRequestHeader("Cookie",
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
Expand Down Expand Up @@ -756,7 +757,7 @@ private Bitmap doThumbnailFromOCFileInBackground() {

// Add thumbnail to cache
if (thumbnail != null) {
Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
Log_NMC.d(TAG, "add thumbnail to cache: " + file.getFileName());
addBitmapToCache(imageKey, thumbnail);
}
}
Expand Down Expand Up @@ -926,13 +927,13 @@ private Bitmap doFileInBackground(File file, Type type) {
thumbnail = retriever.getFrameAtTime(-1);
} catch (Exception ex) {
// can't create a bitmap
Log_OC.w(TAG, "Failed to create bitmap from video " + file.getAbsolutePath());
Log_NMC.w(TAG, "Failed to create bitmap from video " + file.getAbsolutePath());
} finally {
try {
retriever.release();
} catch (RuntimeException | IOException ex) {
// Ignore failure at this point.
Log_OC.w(TAG, "Failed release MediaMetadataRetriever for " + file.getAbsolutePath());
Log_NMC.w(TAG, "Failed release MediaMetadataRetriever for " + file.getAbsolutePath());
}
}

Expand Down Expand Up @@ -1051,7 +1052,7 @@ Drawable doAvatarInBackground() {

int px = mResources.getInteger(R.integer.file_avatar_px);
String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(mUserId) + "/" + px;
Log_OC.d("Avatar", "URI: " + uri);
Log_NMC.d("Avatar", "URI: " + uri);
get = new GetMethod(uri);

// only use eTag if available and corresponding avatar is still there
Expand Down Expand Up @@ -1325,7 +1326,7 @@ public static void generateThumbnailFromOCFile(OCFile file, User user, Context c
String uri = client.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" +
pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");

Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
Log_NMC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
getMethod = new GetMethod(uri);
getMethod.setRequestHeader("Cookie", "nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");

Expand All @@ -1348,7 +1349,7 @@ public static void generateThumbnailFromOCFile(OCFile file, User user, Context c
thumbnail = handlePNG(thumbnail, pxW, pxH);
}

Log_OC.d(TAG, "add thumbnail to cache: " + file.getFileName());
Log_NMC.d(TAG, "add thumbnail to cache: " + file.getFileName());
addBitmapToCache(imageKey, thumbnail);
}
} catch (Exception e) {
Expand Down Expand Up @@ -1402,7 +1403,7 @@ private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageMan
String uri = mClient.getBaseUri() + "/index.php/core/preview?fileId="
+ file.getRemoteId()
+ "&x=" + (pxW / 2) + "&y=" + (pxH / 2) + "&a=1&mode=cover&forceIcon=0";
Log_OC.d(TAG, "generate resized image: " + file.getFileName() + " URI: " + uri);
Log_NMC.d(TAG, "generate resized image: " + file.getFileName() + " URI: " + uri);
getMethod = new GetMethod(uri);

int status = mClient.executeMethod(getMethod);
Expand All @@ -1420,7 +1421,7 @@ private static Bitmap doResizedImageInBackground(OCFile file, FileDataStorageMan

// Add thumbnail to cache
if (thumbnail != null) {
Log_OC.d(TAG, "add resized image to cache: " + file.getFileName());
Log_NMC.d(TAG, "add resized image to cache: " + file.getFileName());
addBitmapToCache(imageKey, thumbnail);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ protected void onPostCreate(Bundle savedInstanceState) {
onOpenFileIntent(getIntent());
} else if (RESTART.equals(getIntent().getAction())) {
// most likely switched to different account
DisplayUtils.showSnackMessage(this, String.format(getString(R.string.logged_in_as), accountManager.getUser().getAccountName()));
// NMC-2576 --> Disabling switch account snackbar for NMC
/*DisplayUtils.showSnackMessage(this, String.format(getString(R.string.logged_in_as), accountManager.getUser().getAccountName()));*/
}

upgradeNotificationForInstantUpload();
Expand Down Expand Up @@ -468,6 +469,9 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
getOCFileListFragmentFromFile().directCameraUpload();
} else if (!shouldShowRequestPermissionRationale(permissions[0])) {
// user CHECKED "never ask again"
DisplayUtils.showSnackMessage(this, R.string.camera_permission_rationale);
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.google.android.material.snackbar.Snackbar
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.R
Expand Down Expand Up @@ -80,30 +79,18 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
setContentView(binding.root)

PassCodeManager.setSecureFlag(this, true)
applyTint()
setupPasscodeEditTexts()
setSoftInputMode()
setupUI(savedInstanceState)
setTextListeners()
}

private fun applyTint() {
viewThemeUtils.platform.colorViewBackground(binding.cardViewContent, ColorRole.SURFACE_VARIANT)
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.cancel)
}

private fun setupPasscodeEditTexts() {
passCodeEditTexts[0] = binding.txt0
passCodeEditTexts[1] = binding.txt1
passCodeEditTexts[2] = binding.txt2
passCodeEditTexts[3] = binding.txt3

passCodeEditTexts.forEach {
it?.let { editText ->
viewThemeUtils.platform.colorEditText(editText)
}
}

passCodeEditTexts[0]?.requestFocus()

binding.cardViewContent.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class GalleryAdapter(
transferServiceGetter,
showMetadata = false,
showShareAvatar = false,
viewThemeUtils
viewThemeUtils,
true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
if (isCheckedFile(file)) {
gridViewHolder.itemLayout.setBackgroundColor(ContextCompat.getColor(mContext, R.color.selected_item_background));

gridViewHolder.checkbox.setImageDrawable(
viewThemeUtils.platform.tintDrawable(mContext, R.drawable.ic_checkbox_marked, ColorRole.PRIMARY));
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_marked);
} else {
gridViewHolder.itemLayout.setBackgroundColor(mContext.getResources().getColor(R.color.bg_default));
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline);
Expand Down
Loading

0 comments on commit b7f5fcf

Please sign in to comment.