Browse Source

Merge pull request #9528 from nextcloud/huaweiFlavor

Huawei flavor
Álvaro Brey 3 years ago
parent
commit
82a53642a9

+ 1 - 1
.github/workflows/assembleFlavors.yml

@@ -10,7 +10,7 @@ jobs:
         strategy:
             fail-fast: false
             matrix:
-                flavor: [ Generic, Gplay ]
+                flavor: [ Generic, Gplay, Huawei ]
         steps:
             -   uses: actions/checkout@v2
             -   name: set up JDK 11

+ 5 - 0
build.gradle

@@ -164,6 +164,11 @@ android {
                 applicationId 'com.nextcloud.client'
                 dimension "default"
             }
+            
+            huawei {
+                applicationId 'com.nextcloud.client'
+                dimension "default"
+            }
 
             versionDev {
                 applicationId "com.nextcloud.android.beta"

+ 10 - 1
fastlane/Fastfile

@@ -94,6 +94,9 @@ lane :makeReleases do
 
     SignedRelease(flavor:"Gplay")
     sh("cp ../build/outputs/apk/gplay/release/*.apk ../release/")
+    
+    SignedRelease(flavor:"Huawei")
+        sh("cp ../build/outputs/apk/huawei/release/*.apk ../release/")
 end
 
 desc "Create GPlay release"
@@ -108,6 +111,12 @@ lane :createGenericRelease do |options|
     sh("mv ../build/outputs/apk/generic/release/*.apk ../release/")
 end
 
+desc "Create Huawei release"
+lane :createHuaweiRelease do |options|
+    SignedRelease(flavor:"Huawei")
+    sh("mv ../build/outputs/apk/huawei/release/*.apk ../release/")
+end
+
 desc "Create Dev release"
 lane :createDevRelease do |options|
     SignedRelease(flavor:"VersionDev")
@@ -131,7 +140,7 @@ private_lane :uploadToHuawei_Final do |options|
         client_id: ENV["FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_ID"],
         client_secret: ENV["FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_SECRET"],
         app_id: ENV["FASTLANE_NEXTCLOUD_HUAWEI_APP_ID"],
-        apk_path: "release/nextcloud-" + options["versionCode"] + ".apk",
+        apk_path: "release/huawei-release-" + options["versionCode"] + ".apk",
         submit_for_review: true,
     )
 end

+ 47 - 0
src/huawei/AndroidManifest.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  Nextcloud Android client application
+
+  @author Tobias Kaminsky
+  Copyright (C) 2021 Tobias Kaminsky
+  Copyright (C) 2021 Nextcloud GmbH
+ 
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU Affero General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+ 
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU Affero General Public License for more details.
+ 
+  You should have received a copy of the GNU Affero General Public License
+  along with this program. If not, see <https://www.gnu.org/licenses/>.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="com.owncloud.android">
+
+    <application
+        android:name=".MainApp"
+        android:fullBackupContent="@xml/backup_config"
+        android:icon="@mipmap/ic_launcher"
+        android:label="@string/app_name"
+        android:manageSpaceActivity="com.owncloud.android.ui.activity.ManageSpaceActivity"
+        android:theme="@style/Theme.ownCloud.Toolbar">
+
+        <activity
+            android:name=".ui.activity.HuaweiCommunityActivity"
+            android:exported="false" />
+
+        <activity-alias
+            android:name=".ui.activity.CommunityActivity"
+            android:targetActivity=".ui.activity.HuaweiCommunityActivity"
+            tools:replace="android:targetActivity" />
+
+        <activity
+            tools:node="remove"
+            android:name=".ui.activity.CommunityActivity" />
+    </application>
+
+</manifest>

+ 31 - 0
src/huawei/java/com/nextcloud/client/di/VariantComponentsModule.java

@@ -0,0 +1,31 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Chris Narkiewicz
+ * Copyright (C) 2919 Chris Narkiewicz <hello@ezaquarii.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.nextcloud.client.di;
+
+import com.owncloud.android.ui.activity.HuaweiCommunityActivity;
+
+import dagger.Module;
+import dagger.android.ContributesAndroidInjector;
+
+@Module
+abstract class VariantComponentsModule {
+    @ContributesAndroidInjector
+    abstract HuaweiCommunityActivity participateActivity();
+}

+ 32 - 0
src/huawei/java/com/owncloud/android/ui.activity/HuaweiCommunityActivity.kt

@@ -0,0 +1,32 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2021 Nextcloud
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.owncloud.android.ui.activity
+
+import android.view.View
+
+/**
+ * Activity providing information about ways to participate in the app's development.
+ */
+class HuaweiCommunityActivity : CommunityActivity() {
+    override fun setupContent() {
+        super.setupContent()
+        binding.communityReleaseCandidatePlaystore.visibility = View.GONE
+    }
+}

+ 58 - 0
src/huawei/java/com/owncloud/android/utils/PushUtils.java

@@ -0,0 +1,58 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Mario Danic
+ * @author Chris Narkiewicz Copyright (C) 2017 Mario Danic Copyright (C) 2019 Chris Narkiewicz
+ * <p>
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
+ * Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any
+ * later version.
+ * <p>
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+ * details.
+ * <p>
+ * You should have received a copy of the GNU Affero General Public License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+package com.owncloud.android.utils;
+
+import android.content.Context;
+
+import com.nextcloud.client.account.UserAccountManager;
+import com.nextcloud.client.preferences.AppPreferencesImpl;
+import com.owncloud.android.MainApp;
+import com.owncloud.android.datamodel.SignatureVerification;
+
+import java.security.Key;
+
+public final class PushUtils {
+    public static final String KEY_PUSH = "push";
+
+    private PushUtils() {
+    }
+
+    public static void pushRegistrationToServer(final UserAccountManager accountManager, final String pushToken) {
+        // do nothing
+    }
+
+    public static void reinitKeys(UserAccountManager accountManager) {
+        Context context = MainApp.getAppContext();
+        AppPreferencesImpl.fromContext(context).setKeysReInitEnabled();
+    }
+
+    public static Key readKeyFromFile(boolean readPublicKey) {
+        return null;
+    }
+
+    public static SignatureVerification verifySignature(
+        final Context context,
+        final UserAccountManager accountManager,
+        final byte[] signatureBytes,
+        final byte[] subjectBytes
+                                                       ) {
+        return null;
+    }
+
+}

+ 20 - 0
src/huawei/java/com/owncloud/android/utils/SecurityUtils.java

@@ -0,0 +1,20 @@
+/**
+ * Nextcloud Android client application
+ *
+ * @author Mario Danic Copyright (C) 2018 Mario Danic
+ * <p>
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
+ * Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any
+ * later version.
+ * <p>
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+ * details.
+ * <p>
+ * You should have received a copy of the GNU Affero General Public License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+package com.owncloud.android.utils;
+
+public class SecurityUtils {
+}

+ 23 - 0
src/huawei/res/values/bools.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  Nextcloud Android client application
+
+  @author Tobias Kaminsky
+  Copyright (C) 2021 Tobias Kaminsky
+  Copyright (C) 2021 Nextcloud GmbH
+ 
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU Affero General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+ 
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU Affero General Public License for more details.
+ 
+  You should have received a copy of the GNU Affero General Public License
+  along with this program. If not, see <https://www.gnu.org/licenses/>.
+-->
+<resources>
+    <bool name="show_push_warning">false</bool>
+</resources>

+ 2 - 2
src/main/java/com/owncloud/android/ui/activity/CommunityActivity.java

@@ -39,7 +39,7 @@ import com.owncloud.android.utils.theme.ThemeColorUtils;
  */
 public class CommunityActivity extends DrawerActivity {
 
-    private CommunityLayoutBinding binding;
+    protected CommunityLayoutBinding binding;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -59,7 +59,7 @@ public class CommunityActivity extends DrawerActivity {
         setupContent();
     }
 
-    private void setupContent() {
+    protected void setupContent() {
         binding.communityReleaseCandidateText.setMovementMethod(LinkMovementMethod.getInstance());
 
         TextView contributeIrcView = binding.communityContributeIrcText;

+ 3 - 0
src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java

@@ -132,6 +132,9 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
     }
 
     private void setupPushWarning() {
+        if (!getResources().getBoolean(R.bool.show_push_warning)) {
+            return;
+        }
         if (snackbar != null) {
             if (!snackbar.isShown()) {
                 snackbar.show();

+ 1 - 0
src/main/res/values/bools.xml

@@ -19,4 +19,5 @@
 <!-- Default boolean values -->
 <resources>
     <bool name="large_land_layout">false</bool>
+    <bool name="show_push_warning">true</bool>
 </resources>