mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Add: Share button (only works for fdroid repo apps)
Fix: Switch Colors
This commit is contained in:
parent
bafb2714cb
commit
59ebd3394f
@ -72,7 +72,8 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
|||||||
LAUNCH(R.string.launch),
|
LAUNCH(R.string.launch),
|
||||||
DETAILS(R.string.details),
|
DETAILS(R.string.details),
|
||||||
UNINSTALL(R.string.uninstall),
|
UNINSTALL(R.string.uninstall),
|
||||||
CANCEL(R.string.cancel)
|
CANCEL(R.string.cancel),
|
||||||
|
SHARE(R.string.share)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class Status {
|
sealed class Status {
|
||||||
|
@ -59,7 +59,8 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
|||||||
UPDATE(2, ProductAdapter.Action.UPDATE, R.drawable.ic_archive),
|
UPDATE(2, ProductAdapter.Action.UPDATE, R.drawable.ic_archive),
|
||||||
LAUNCH(3, ProductAdapter.Action.LAUNCH, R.drawable.ic_launch),
|
LAUNCH(3, ProductAdapter.Action.LAUNCH, R.drawable.ic_launch),
|
||||||
DETAILS(4, ProductAdapter.Action.DETAILS, R.drawable.ic_tune),
|
DETAILS(4, ProductAdapter.Action.DETAILS, R.drawable.ic_tune),
|
||||||
UNINSTALL(5, ProductAdapter.Action.UNINSTALL, R.drawable.ic_delete)
|
UNINSTALL(5, ProductAdapter.Action.UNINSTALL, R.drawable.ic_delete),
|
||||||
|
SHARE(6, ProductAdapter.Action.SHARE, R.drawable.ic_share)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Installed(
|
private class Installed(
|
||||||
@ -287,6 +288,7 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
|||||||
val canUninstall = product != null && installed != null && !installed.isSystem
|
val canUninstall = product != null && installed != null && !installed.isSystem
|
||||||
val canLaunch =
|
val canLaunch =
|
||||||
product != null && installed != null && installed.launcherActivities.isNotEmpty()
|
product != null && installed != null && installed.launcherActivities.isNotEmpty()
|
||||||
|
val canShare = product != null
|
||||||
|
|
||||||
val actions = mutableSetOf<Action>()
|
val actions = mutableSetOf<Action>()
|
||||||
if (canInstall) {
|
if (canInstall) {
|
||||||
@ -304,11 +306,15 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
|||||||
if (canUninstall) {
|
if (canUninstall) {
|
||||||
actions += Action.UNINSTALL
|
actions += Action.UNINSTALL
|
||||||
}
|
}
|
||||||
|
if (canShare) {
|
||||||
|
actions += Action.SHARE
|
||||||
|
}
|
||||||
val primaryAction = when {
|
val primaryAction = when {
|
||||||
canUpdate -> Action.UPDATE
|
canUpdate -> Action.UPDATE
|
||||||
canLaunch -> Action.LAUNCH
|
canLaunch -> Action.LAUNCH
|
||||||
canInstall -> Action.INSTALL
|
canInstall -> Action.INSTALL
|
||||||
installed != null -> Action.DETAILS
|
installed != null -> Action.DETAILS
|
||||||
|
canShare -> Action.SHARE
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +324,12 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
|||||||
|
|
||||||
val toolbar = toolbar
|
val toolbar = toolbar
|
||||||
if (toolbar != null) {
|
if (toolbar != null) {
|
||||||
for (action in sequenceOf(Action.INSTALL, Action.UPDATE, Action.UNINSTALL)) {
|
for (action in sequenceOf(
|
||||||
|
Action.INSTALL,
|
||||||
|
Action.SHARE,
|
||||||
|
Action.UPDATE,
|
||||||
|
Action.UNINSTALL
|
||||||
|
)) {
|
||||||
toolbar.menu.findItem(action.id).isEnabled = !downloading
|
toolbar.menu.findItem(action.id).isEnabled = !downloading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,6 +431,20 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
|
|||||||
binder.cancel(packageName)
|
binder.cancel(packageName)
|
||||||
} else Unit
|
} else Unit
|
||||||
}
|
}
|
||||||
|
ProductAdapter.Action.SHARE -> {
|
||||||
|
val sendIntent: Intent = Intent().apply {
|
||||||
|
this.action = Intent.ACTION_SEND
|
||||||
|
putExtra(
|
||||||
|
Intent.EXTRA_TEXT,
|
||||||
|
"https://www.f-droid.org/en/packages/${products[0].first.packageName}/"
|
||||||
|
)
|
||||||
|
type = "text/plain"
|
||||||
|
}
|
||||||
|
|
||||||
|
val shareIntent = Intent.createChooser(sendIntent, null)
|
||||||
|
startActivity(shareIntent)
|
||||||
|
|
||||||
|
}
|
||||||
}::class
|
}::class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
src/main/res/color/switch_thumb_tint.xml
Normal file
5
src/main/res/color/switch_thumb_tint.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:alpha="0.7" android:color="?android:attr/colorPrimary" android:state_checked="false" />
|
||||||
|
<item android:color="?android:attr/colorPrimary" android:state_checked="true" />
|
||||||
|
</selector>
|
5
src/main/res/color/switch_track_color.xml
Normal file
5
src/main/res/color/switch_track_color.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:alpha="0.3" android:color="?android:attr/colorPrimary" android:state_checked="false" />
|
||||||
|
<item android:alpha="1" android:color="?android:attr/colorPrimary" android:state_checked="true" />
|
||||||
|
</selector>
|
10
src/main/res/drawable/ic_share.xml
Normal file
10
src/main/res/drawable/ic_share.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92s2.92,-1.31 2.92,-2.92 -1.31,-2.92 -2.92,-2.92z" />
|
||||||
|
</vector>
|
@ -2,7 +2,6 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="54dp"
|
android:layout_height="54dp"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
@ -21,7 +20,6 @@
|
|||||||
android:id="@+id/enabled"
|
android:id="@+id/enabled"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:thumbTint="?android:attr/colorPrimary"
|
|
||||||
android:paddingStart="12dp"
|
android:paddingStart="12dp"
|
||||||
android:paddingEnd="12dp" />
|
android:paddingEnd="12dp" />
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
@ -21,7 +20,6 @@
|
|||||||
android:id="@+id/enabled"
|
android:id="@+id/enabled"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:thumbTint="?android:attr/colorPrimary"
|
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:paddingStart="12dp"
|
android:paddingStart="12dp"
|
||||||
android:paddingEnd="12dp" />
|
android:paddingEnd="12dp" />
|
||||||
|
@ -120,6 +120,7 @@
|
|||||||
<string name="screenshots">Capturas</string>
|
<string name="screenshots">Capturas</string>
|
||||||
<string name="search">Buscar</string>
|
<string name="search">Buscar</string>
|
||||||
<string name="select_mirror">Elegir espejo</string>
|
<string name="select_mirror">Elegir espejo</string>
|
||||||
|
<string name="share">Cuota</string>
|
||||||
<string name="show_more">Mostrar más</string>
|
<string name="show_more">Mostrar más</string>
|
||||||
<string name="show_older_versions">Mostrar versiones más antiguas</string>
|
<string name="show_older_versions">Mostrar versiones más antiguas</string>
|
||||||
<string name="signature_FORMAT">Firma %s</string>
|
<string name="signature_FORMAT">Firma %s</string>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="action_failed">A ação falhou</string>
|
<string name="action_failed">A ação falhou</string>
|
||||||
<string name="add_repository">Adicionar repositório</string>
|
<string name="add_repository">Adicionar repositório</string>
|
||||||
<string name="address">Endereço</string>
|
<string name="address">Endereço</string>
|
||||||
@ -131,6 +130,7 @@
|
|||||||
<string name="screenshots">Capturas de tela</string>
|
<string name="screenshots">Capturas de tela</string>
|
||||||
<string name="search">Pesquisar</string>
|
<string name="search">Pesquisar</string>
|
||||||
<string name="select_mirror">Selecione um mirror</string>
|
<string name="select_mirror">Selecione um mirror</string>
|
||||||
|
<string name="share">Compartilhado</string>
|
||||||
<string name="show_more">Mostrar mais</string>
|
<string name="show_more">Mostrar mais</string>
|
||||||
<string name="show_older_versions">Mostrar versões antigas</string>
|
<string name="show_older_versions">Mostrar versões antigas</string>
|
||||||
<string name="signature_FORMAT">Assinatura %s</string>
|
<string name="signature_FORMAT">Assinatura %s</string>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="action_failed">操作失败</string>
|
<string name="action_failed">操作失败</string>
|
||||||
<string name="add_repository">添加存储库</string>
|
<string name="add_repository">添加存储库</string>
|
||||||
<string name="address">地址</string>
|
<string name="address">地址</string>
|
||||||
@ -28,6 +27,7 @@
|
|||||||
<string name="could_not_download_FORMAT">无法下载 %s</string>
|
<string name="could_not_download_FORMAT">无法下载 %s</string>
|
||||||
<string name="could_not_sync_FORMAT">无法同步 %s</string>
|
<string name="could_not_sync_FORMAT">无法同步 %s</string>
|
||||||
<string name="could_not_validate_FORMAT">无法验证 %s</string>
|
<string name="could_not_validate_FORMAT">无法验证 %s</string>
|
||||||
|
<string name="credits">鸣谢</string>
|
||||||
<string name="dark">暗色</string>
|
<string name="dark">暗色</string>
|
||||||
<string name="date_added">添加日期</string>
|
<string name="date_added">添加日期</string>
|
||||||
<string name="delete">删除</string>
|
<string name="delete">删除</string>
|
||||||
@ -63,6 +63,7 @@
|
|||||||
<string name="incompatible_versions_summary">显示与设备不兼容的应用版本</string>
|
<string name="incompatible_versions_summary">显示与设备不兼容的应用版本</string>
|
||||||
<string name="incompatible_with_FORMAT">与 %s 不兼容</string>
|
<string name="incompatible_with_FORMAT">与 %s 不兼容</string>
|
||||||
<string name="install">安装</string>
|
<string name="install">安装</string>
|
||||||
|
<string name="install_types">安装类型</string>
|
||||||
<string name="installed">已安装</string>
|
<string name="installed">已安装</string>
|
||||||
<string name="integrity_check_error_DESC">无法检查完整性。</string>
|
<string name="integrity_check_error_DESC">无法检查完整性。</string>
|
||||||
<string name="invalid_address">地址无效</string>
|
<string name="invalid_address">地址无效</string>
|
||||||
@ -127,6 +128,7 @@
|
|||||||
<string name="screenshots">截图</string>
|
<string name="screenshots">截图</string>
|
||||||
<string name="search">搜索</string>
|
<string name="search">搜索</string>
|
||||||
<string name="select_mirror">选择一个镜像</string>
|
<string name="select_mirror">选择一个镜像</string>
|
||||||
|
<string name="share">分享</string>
|
||||||
<string name="show_more">显示更多</string>
|
<string name="show_more">显示更多</string>
|
||||||
<string name="show_older_versions">显示旧版本</string>
|
<string name="show_older_versions">显示旧版本</string>
|
||||||
<string name="signature_FORMAT">签名 %s</string>
|
<string name="signature_FORMAT">签名 %s</string>
|
||||||
@ -166,7 +168,4 @@
|
|||||||
<string name="root_permission">后台安装</string>
|
<string name="root_permission">后台安装</string>
|
||||||
<string name="root_permission_description">允许 Root 权限以启用后台安装</string>
|
<string name="root_permission_description">允许 Root 权限以启用后台安装</string>
|
||||||
<string name="themes">主题</string>
|
<string name="themes">主题</string>
|
||||||
<string name="credits">鸣谢</string>
|
|
||||||
<string name="install_types">安装类型</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="action_failed">Action failed</string>
|
<string name="action_failed">Action failed</string>
|
||||||
<string name="add_repository">Add repository</string>
|
<string name="add_repository">Add repository</string>
|
||||||
<string name="address">Address</string>
|
<string name="address">Address</string>
|
||||||
@ -132,6 +131,7 @@
|
|||||||
<string name="screenshots">Screenshots</string>
|
<string name="screenshots">Screenshots</string>
|
||||||
<string name="search">Search</string>
|
<string name="search">Search</string>
|
||||||
<string name="select_mirror">Select a mirror</string>
|
<string name="select_mirror">Select a mirror</string>
|
||||||
|
<string name="share">Share</string>
|
||||||
<string name="show_more">Show more</string>
|
<string name="show_more">Show more</string>
|
||||||
<string name="show_older_versions">Show older versions</string>
|
<string name="show_older_versions">Show older versions</string>
|
||||||
<string name="signature_FORMAT">Signature %s</string>
|
<string name="signature_FORMAT">Signature %s</string>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
||||||
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
|
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="switchStyle">@style/Theme.Switch</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Main.Dark" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Main.Dark" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
@ -43,6 +44,7 @@
|
|||||||
<item name="android:fastScrollThumbDrawable">@drawable/scrollbar_thumb</item>
|
<item name="android:fastScrollThumbDrawable">@drawable/scrollbar_thumb</item>
|
||||||
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="switchStyle">@style/Theme.Switch</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Main.Amoled" parent="Theme.Material3.Dark.NoActionBar">
|
<style name="Theme.Main.Amoled" parent="Theme.Material3.Dark.NoActionBar">
|
||||||
@ -63,6 +65,7 @@
|
|||||||
<item name="android:fastScrollThumbDrawable">@drawable/scrollbar_thumb</item>
|
<item name="android:fastScrollThumbDrawable">@drawable/scrollbar_thumb</item>
|
||||||
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
<item name="android:fastScrollTrackDrawable">@drawable/scrollbar_track</item>
|
||||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||||
|
<item name="switchStyle">@style/Theme.Switch</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.Main.Toolbar" parent="Widget.Material3.Toolbar">
|
<style name="Widget.Main.Toolbar" parent="Widget.Material3.Toolbar">
|
||||||
@ -84,4 +87,9 @@
|
|||||||
<item name="android:colorBackground">@color/black</item>
|
<item name="android:colorBackground">@color/black</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Theme.Switch" parent="Widget.Material3.CompoundButton.Switch">
|
||||||
|
<item name="trackTint">@color/switch_track_color</item>
|
||||||
|
<item name="thumbTint">@color/switch_thumb_tint</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user