From 4b06cdbb9697fe84556b8599648f52166f836d67 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:16:05 +0200 Subject: [PATCH 01/23] Fix custom server name in drawer_header.xml Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- app/src/main/res/layout/drawer_header.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index ecc396f1a1..f7cf25e556 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> - - + \ No newline at end of file From 75315555335372f4030a07f10e09d6a83b0c69ae Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Tue, 27 Jun 2023 17:17:26 +0200 Subject: [PATCH 02/23] Add ecosystem icons Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- app/src/main/res/drawable/ic_more_apps.xml | 38 ++++++++++++++++++++++ app/src/main/res/drawable/ic_notes.xml | 29 +++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 app/src/main/res/drawable/ic_more_apps.xml create mode 100644 app/src/main/res/drawable/ic_notes.xml diff --git a/app/src/main/res/drawable/ic_more_apps.xml b/app/src/main/res/drawable/ic_more_apps.xml new file mode 100644 index 0000000000..0f857b81ea --- /dev/null +++ b/app/src/main/res/drawable/ic_more_apps.xml @@ -0,0 +1,38 @@ + + + + + + + diff --git a/app/src/main/res/drawable/ic_notes.xml b/app/src/main/res/drawable/ic_notes.xml new file mode 100644 index 0000000000..1f1c9d27f1 --- /dev/null +++ b/app/src/main/res/drawable/ic_notes.xml @@ -0,0 +1,29 @@ + + + + \ No newline at end of file From 2b1b163b536fe0d8a4b651a51abb7c2609357d96 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Wed, 28 Jun 2023 10:44:39 +0200 Subject: [PATCH 03/23] Add ecosystem apps to drawer_header.xml - introduce is_branded_client variable - ecosystem apps will only be displayed in vanilla client - fix layout of drawer_header.xml Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../android/ui/activity/DrawerActivity.java | 20 ++-- app/src/main/res/layout/drawer_header.xml | 101 +++++++++++++----- app/src/main/res/values/strings.xml | 3 + 3 files changed, 86 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index d47ad343c8..80a1e752cf 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -48,9 +48,8 @@ import android.text.TextUtils; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.ViewGroup.LayoutParams; -import android.view.ViewGroup.MarginLayoutParams; import android.webkit.URLUtil; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -297,6 +296,11 @@ public abstract class DrawerActivity extends ToolbarActivity } public void updateHeader() { + // hide ecosystem apps when in branded client + if (getResources().getBoolean(R.bool.is_branded_client)) { + mNavigationViewHeader.findViewById(R.id.drawer_ecosystem_apps).setVisibility(View.GONE); + } + if (getAccount() != null && getCapabilities().getServerBackground() != null) { @@ -305,7 +309,7 @@ public abstract class DrawerActivity extends ToolbarActivity int primaryColor = themeColorUtils.unchangedPrimaryColor(getAccount(), this); // set background to primary color - LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view); + FrameLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view); drawerHeader.setBackgroundColor(primaryColor); if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) { @@ -320,7 +324,7 @@ public abstract class DrawerActivity extends ToolbarActivity .decoder(new SvgOrImageDecoder()); // background image - SimpleTarget target = new SimpleTarget() { + SimpleTarget target = new SimpleTarget<>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) { @@ -356,14 +360,6 @@ public abstract class DrawerActivity extends ToolbarActivity imageHeader.setMaxWidth(DisplayUtils.convertDpToPixel(100f, this)); - MarginLayoutParams oldParam = (MarginLayoutParams) imageHeader.getLayoutParams(); - MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.MATCH_PARENT); - params.leftMargin = oldParam.leftMargin; - params.rightMargin = oldParam.rightMargin; - - imageHeader.setLayoutParams(new LinearLayout.LayoutParams(params)); - if (!TextUtils.isEmpty(name)) { TextView serverName = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name); serverName.setText(name); diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index f7cf25e556..9df7b50cc6 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -1,5 +1,4 @@ - - - + android:layout_height="wrap_content" + android:background="@color/primary" + android:orientation="vertical"> - + android:layout_height="@dimen/drawer_header_height" + android:fitsSystemWindows="true" + android:orientation="horizontal"> - - \ No newline at end of file + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c316680fb..11be57d084 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1088,4 +1088,7 @@ Flip vertically Unable to edit image. edited + Nextcloud Notes + Nextcloud Talk + More Nextcloud Apps From 8506251cb61075be4371d7eebe59e8d6140edd79 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Wed, 28 Jun 2023 13:52:31 +0200 Subject: [PATCH 04/23] Add actions for ecosystem apps Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../android/ui/activity/DrawerActivity.java | 61 +++++++++++++++++-- app/src/main/res/layout/drawer_header.xml | 3 + 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 80a1e752cf..0d8a09ab46 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -296,11 +296,6 @@ public abstract class DrawerActivity extends ToolbarActivity } public void updateHeader() { - // hide ecosystem apps when in branded client - if (getResources().getBoolean(R.bool.is_branded_client)) { - mNavigationViewHeader.findViewById(R.id.drawer_ecosystem_apps).setVisibility(View.GONE); - } - if (getAccount() != null && getCapabilities().getServerBackground() != null) { @@ -350,6 +345,62 @@ public abstract class DrawerActivity extends ToolbarActivity .into(target); } } + + // hide ecosystem apps when in branded client + LinearLayout ecosystemApps = mNavigationViewHeader.findViewById(R.id.drawer_ecosystem_apps); + if (getResources().getBoolean(R.bool.is_branded_client)) { + ecosystemApps.setVisibility(View.GONE); + } else { + ecosystemApps.findViewById(R.id.drawer_ecosystem_notes).setOnClickListener(v -> { + openAppOrStore("it.niedermann.owncloud.notes", + "it.niedermann.owncloud.notes.main.MainActivity"); + }); + ecosystemApps.findViewById(R.id.drawer_ecosystem_talk).setOnClickListener(v -> { + openAppOrStore("com.nextcloud.talk2", + "com.nextcloud.talk.activities.MainActivity"); + }); + ecosystemApps.findViewById(R.id.drawer_ecosystem_more).setOnClickListener(v -> { + openAppStore("Nextcloud", true); + }); + } + } + + /** + * Open specified app and, if not installed redirect to corresponding download. + * + * @param packageName of app to be opened + * @param className of app for intent to be called + */ + private void openAppOrStore(String packageName, String className) { + try { + // attempt to open app directly + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setClassName(packageName, className); + startActivity(intent); + } catch (android.content.ActivityNotFoundException activityNotFoundException) { + // attempt to open market (Google Play Store, F-Droid, etc.) + openAppStore(packageName, false); + } + } + + /** + * + * @param string packageName or url-encoded search string + * @param search false -> show app corresponding to packageName; true -> open search for string + */ + private void openAppStore(String string, Boolean search) { + String suffix = (search ? "search?q=" : "details?id=") + string; + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://" + suffix)); + try { + startActivity(intent); + } catch (android.content.ActivityNotFoundException activityNotFoundException1) { + // all is lost: open google play store web page for app + if (!search) { + suffix = "apps/" + suffix; + } + intent.setData(Uri.parse("https://play.google.com/store/" + suffix)); + startActivity(intent); + } } private void setDrawerHeaderLogo(Drawable drawable, String name) { diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index 9df7b50cc6..98d929362e 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -65,6 +65,7 @@ android:orientation="horizontal"> Date: Thu, 29 Jun 2023 11:54:34 +0200 Subject: [PATCH 05/23] Adapt layout in drawer_header Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../android/ui/activity/DrawerActivity.java | 14 ++++---- app/src/main/res/layout/drawer_header.xml | 35 +++++++++++-------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 0d8a09ab46..822a1b259a 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -49,7 +49,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.webkit.URLUtil; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -304,7 +303,7 @@ public abstract class DrawerActivity extends ToolbarActivity int primaryColor = themeColorUtils.unchangedPrimaryColor(getAccount(), this); // set background to primary color - FrameLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view); + LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view); drawerHeader.setBackgroundColor(primaryColor); if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) { @@ -403,7 +402,7 @@ public abstract class DrawerActivity extends ToolbarActivity } } - private void setDrawerHeaderLogo(Drawable drawable, String name) { + private void setDrawerHeaderLogo(Drawable drawable, String serverName) { ImageView imageHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_logo); imageHeader.setImageDrawable(drawable); imageHeader.setScaleType(ImageView.ScaleType.FIT_START); @@ -411,10 +410,11 @@ public abstract class DrawerActivity extends ToolbarActivity imageHeader.setMaxWidth(DisplayUtils.convertDpToPixel(100f, this)); - if (!TextUtils.isEmpty(name)) { - TextView serverName = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name); - serverName.setText(name); - serverName.setTextColor(themeColorUtils.unchangedFontColor(this)); + if (!TextUtils.isEmpty(serverName)) { + TextView serverNameView = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name); + serverNameView.setVisibility(View.VISIBLE); + serverNameView.setText(serverName); + serverNameView.setTextColor(themeColorUtils.unchangedFontColor(this)); } } diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index 98d929362e..6524af21ba 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -21,47 +21,52 @@ - + + android:textStyle="bold" + android:visibility="gone" + tools:ignore="RtlHardcoded" + tools:text="Nextcloud" /> - + Date: Fri, 30 Jun 2023 10:00:41 +0200 Subject: [PATCH 06/23] Fix intent to open ecosystem apps Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../android/ui/activity/DrawerActivity.java | 21 ++++++++----------- .../ui/activity/FileDisplayActivity.java | 2 ++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 822a1b259a..bf861c6ccf 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -351,12 +351,10 @@ public abstract class DrawerActivity extends ToolbarActivity ecosystemApps.setVisibility(View.GONE); } else { ecosystemApps.findViewById(R.id.drawer_ecosystem_notes).setOnClickListener(v -> { - openAppOrStore("it.niedermann.owncloud.notes", - "it.niedermann.owncloud.notes.main.MainActivity"); + openAppOrStore("it.niedermann.owncloud.notes"); }); ecosystemApps.findViewById(R.id.drawer_ecosystem_talk).setOnClickListener(v -> { - openAppOrStore("com.nextcloud.talk2", - "com.nextcloud.talk.activities.MainActivity"); + openAppOrStore("com.nextcloud.talk2"); }); ecosystemApps.findViewById(R.id.drawer_ecosystem_more).setOnClickListener(v -> { openAppStore("Nextcloud", true); @@ -368,16 +366,15 @@ public abstract class DrawerActivity extends ToolbarActivity * Open specified app and, if not installed redirect to corresponding download. * * @param packageName of app to be opened - * @param className of app for intent to be called */ - private void openAppOrStore(String packageName, String className) { - try { - // attempt to open app directly - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setClassName(packageName, className); + private void openAppOrStore(String packageName) { + Intent intent = getPackageManager().getLaunchIntentForPackage(packageName); + if (intent != null) { + // app installed - open directly + intent.putExtra(FileDisplayActivity.KEY_ACTIVE_USER, getUser().get().hashCode()); startActivity(intent); - } catch (android.content.ActivityNotFoundException activityNotFoundException) { - // attempt to open market (Google Play Store, F-Droid, etc.) + } else { + // app not found - open market (Google Play Store, F-Droid, etc.) openAppStore(packageName, false); } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 9162852ef9..d505d95037 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -191,6 +191,7 @@ public class FileDisplayActivity extends FileActivity public static final String KEY_FILE_ID = "KEY_FILE_ID"; public static final String KEY_FILE_PATH = "KEY_FILE_PATH"; public static final String KEY_ACCOUNT = "KEY_ACCOUNT"; + public static final String KEY_ACTIVE_USER = "KEY_ACTIVE_USER"; private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW"; @@ -2491,6 +2492,7 @@ public class FileDisplayActivity extends FileActivity String userName = intent.getStringExtra(KEY_ACCOUNT); String fileId = intent.getStringExtra(KEY_FILE_ID); String filePath = intent.getStringExtra(KEY_FILE_PATH); + String activeUser = intent.getStringExtra(KEY_ACTIVE_USER); if (userName == null && fileId == null && intent.getData() != null) { openDeepLink(intent.getData()); From 56b512ba45450d795faeb5db767445f9704d750f Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Tue, 4 Jul 2023 11:48:20 +0200 Subject: [PATCH 07/23] WIP: adapt ecosystem icons Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- app/src/main/res/layout/drawer_header.xml | 128 ++++++++++++++++------ 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/app/src/main/res/layout/drawer_header.xml b/app/src/main/res/layout/drawer_header.xml index 6524af21ba..9b7c0f5ee2 100644 --- a/app/src/main/res/layout/drawer_header.xml +++ b/app/src/main/res/layout/drawer_header.xml @@ -21,18 +21,19 @@ + android:id="@+id/drawer_header_view" + android:layout_width="match_parent" + android:layout_height="96dp" + android:background="@color/primary" + android:gravity="center" + android:padding="@dimen/standard_padding"> - + android:clickable="true" + android:focusable="true" + android:orientation="vertical"> - + + + + + + + android:clickable="true" + android:focusable="true" + android:orientation="vertical"> - + + + + + + + android:clickable="true" + android:focusable="true" + android:orientation="vertical"> + +