Git Product home page Git Product logo

Comments (14)

DearZack avatar DearZack commented on September 22, 2024 1

@tuyafeng 方便提供一个测试apk给我么,就gopeed而言的话,

packageName: com.gopeed
downloadComponentName: com.gopeed.MainActivity
mainComponentName: com.gopeed.MainActivity

我修改一下,到时候提个PR上来

from gopeed.

tuyafeng avatar tuyafeng commented on September 22, 2024 1

@monkeyWie 好的,我已经把 Gopeed 加到 Via 的下载器支持列表里,你可以在 Telegram@ViaAPKs 频道下载测试包,5.5.0.b7 及之后的版本都是支持的。

from gopeed.

monkeyWie avatar monkeyWie commented on September 22, 2024

这个得研究一下

from gopeed.

DearZack avatar DearZack commented on September 22, 2024

https://github.com/MrBoomDeveloper/Awery/blob/ce8d79e8e5f3cd934ee4f02f1f57645ca852c3da/app/src/main/java/ani/awery/others/Download.kt#L191

不知道这是不是一个合理的方案。com.dv.adm 是adm的包名

from gopeed.

DearZack avatar DearZack commented on September 22, 2024

看了一下via的逻辑,via内部有个写死的名单,在名单里&已安装才会显示,然后有下载任务后发给指定的界面。估计得两边联调了。

from gopeed.

monkeyWie avatar monkeyWie commented on September 22, 2024

那我还是提供一个schema链接,去支持第三方来接入吧

from gopeed.

DearZack avatar DearZack commented on September 22, 2024

adm有

<intent-filter>

                <action
                    android:name="android.intent.action.SEND" />

                <action
                    android:name="android.intent.action.SEND_MULTIPLE" />

                <category
                    android:name="android.intent.category.DEFAULT" />

                <data
                    android:mimeType="*/*" />
            </intent-filter>

然后via是这样发的

 public boolean m1073a(Context context, String str) {
        if (this.f8020c > 0 && !TextUtils.isEmpty(str)) {
            Intent intent = new Intent();
            intent.addFlags(268435456);
            intent.setType("text/plain");
            intent.setAction("android.intent.action.SEND");
            intent.putExtra("android.intent.extra.TEXT", str);
            String[][] strArr = f8019b;
            int i = this.f8020c;
            intent.setComponent(new ComponentName(strArr[i][0], strArr[i][2]));
            try {
                context.startActivity(intent);
                return true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return false;
    }

from gopeed.

tuyafeng avatar tuyafeng commented on September 22, 2024

我是 Via 的作者,今天正好看到相关反馈,下载了 Gopeed 应用打算适配,发现无法直接接入,还需要 Gopeed 做一些额外工作。

我先来解释下 Via 的做法,Via 调用一个第三方下载器,需要这么几个定义:

  • packageName: 包名
  • downloadComponentName: 新建任务的 Activity 入口
  • mainComponentName: 应用主 Activity 入口

对于 ADM 来说,各项定义如下:

packageName: com.dv.adm
downloadComponentName: com.dv.get.AEditor
mainComponentName: com.dv.get.Main

这也是 DearZack 所说 Via 内部有个写死名单的原因,对于不在名单中的下载器,Via 无法假定它的下载入口,所以只能事先主动适配将属性存在应用里。

monkeyWie 说的 schema 是一个好方案,很适合拿来做跨平台方案。但在 android 端,常见的做法,还是通过 Intent 调用。简单来说,Gopeed 只需要提供一个新建下载任务的 Activity 入口(当然复用 MainActivity 也是可以的),并在 Activity#onNewIntent 及 Acticity#onCreate 处理 Intent,将下载链接及其它各种参数提取出来丢给 Flutter 界面即可。

from gopeed.

monkeyWie avatar monkeyWie commented on September 22, 2024

@tuyafeng @DearZack 感谢两位热心的回复,由于我没有太多的安卓开发经验,有个问题咨询下。

目前我有一个MainActivity是支持进行跳转下载的,相关代码在这里可以看到:

<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleInstance"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="file"
android:host="*"
android:pathPattern=".*torrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="file"
android:host="*"
android:mimeType="application/x-bittorrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="content"
android:host="*"
android:pathPattern=".*torrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="content"
android:host="*"
android:mimeType="application/x-bittorrent" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="magnet" />
</intent-filter>
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

如果我只提供这一个Activity入口是否足够。

from gopeed.

tuyafeng avatar tuyafeng commented on September 22, 2024

这么做是没问题的,就是需要再在 MainActivity 里处理收到的 Intent。AndroidManifest.xml 的声明是告诉系统,应用可以处理关联的数据,但如何处理数据,需要应用在对应的 Activity(即 MainActivity)的 onNewIntent 和 onCreate 实现。

from gopeed.

DearZack avatar DearZack commented on September 22, 2024

image
缺少这个文件,编译不过诶。是漏上传了吗?

from gopeed.

DearZack avatar DearZack commented on September 22, 2024

我看了文档了,我理解了。
我再研究一下go的开发环境,不太擅长go。
@monkeyWie 方便留个联系方式么?

from gopeed.

monkeyWie avatar monkeyWie commented on September 22, 2024

我看了文档了,我理解了。 我再研究一下go的开发环境,不太擅长go。 @monkeyWie 方便留个联系方式么?

@DearZack 可以加下我微信(bGl3ZWktODQ2Ng==),或者在discord联系我

from gopeed.

monkeyWie avatar monkeyWie commented on September 22, 2024

1.5.6 已发布

from gopeed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.