Skip to content

Added quick on shortcut to app icon #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'org.jetbrains:annotations:15.0'
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.core:core-google-shortcuts:1.1.0'
}

android {
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/be/ppareit/swiftp/gui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat;

import net.vrallev.android.cat.Cat;

import java.util.Arrays;

import be.ppareit.swiftp.App;
import be.ppareit.swiftp.BuildConfig;
import be.ppareit.swiftp.FsService;
import be.ppareit.swiftp.FsSettings;
import be.ppareit.swiftp.R;

Expand Down Expand Up @@ -77,6 +81,19 @@ public void onCreate(Bundle savedInstanceState) {
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PreferenceFragment())
.commit();

if (VERSION.SDK_INT >= 25) {
Intent intent = new Intent("Intent.QuickOn", null, MainActivity.this, MainActivity.class);
ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(getApplicationContext(), "id1forever")
.setShortLabel(getString(R.string.shortcut_on))
.setIcon(IconCompat.createWithResource(getApplicationContext(), R.drawable.widget_on))
.setIntent(intent)
.build();
ShortcutManagerCompat.pushDynamicShortcut(getApplicationContext(), shortcut);
if (getIntent().getAction() != null && getIntent().getAction().equals("Intent.QuickOn")) {
FsService.start();
}
}
}

private boolean haveReadWritePermissions() {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ Gemeldete Probleme und Verbesserungsvorschläge sind unter https://github.com/pp
<string name="mixed_theme">Gemischtes Thema</string>
<string name="app_theme">Thema...</string>

<string name="shortcut_on">Schnell weiter</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,6 @@ https://github.com/ppareit/swiftp/issues .\n\n
<string name="light_theme">Φωτεινό Θέμα</string>
<string name="mixed_theme">Ανάμεικτο Θέμα</string>

<string name="shortcut_on">Γρήγορη ενεργοποίηση</string>
</resources>

1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@ implementarán, mira el registro de incidencias en https://github.com/ppareit/sw
</string>
<string name="write_external_storage_old_android_version_summary">En estos dispositivos, toda lo guardado está disponible utilizando la jerarquía de archivos.</string>

<string name="shortcut_on">Rápido</string>
</resources>

1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
<string name="mixed_theme">Thème mixte</string>
<string name="app_theme">Thème...</string>

<string name="shortcut_on">Rapidement</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
<string name="mixed_theme">Tema misto</string>
<string name="app_theme">Tema...</string>

<string name="shortcut_on">Presto</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ https://github.com/ppareit/swiftp/issues を参照してください。\n\n
<string name="mixed_theme">混合テーマ</string>
<string name="app_theme">テーマ...</string>

<string name="shortcut_on">早速</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ van de volgende versie staan op https://github.com/ppareit/swiftp/issues .\n\n
<string name="mixed_theme">Gemengd thema</string>
<string name="app_theme">Thema...</string>

<string name="shortcut_on">Snel aan</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,5 @@ na stronie https://github.com/ppareit/swiftp/issues .\n\n
</string>
<string name="write_external_storage_old_android_version_summary">Na tych urządzeniach cały sklep jest dostępny przy użyciu hierarchii plików.</string>

<string name="shortcut_on">Szybko</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
<string name="mixed_theme">Смешанная тема</string>
<string name="app_theme">Тема...</string>

<string name="shortcut_on">Быстро</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-sq/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
</string>
<string name="write_external_storage_old_android_version_summary">Në këto pajisje, e gjithë dyqani është në dispozicion duke përdorur hierarkinë e skedarit.</string>

<string name="shortcut_on">Ndizni shpejt</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-sr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
<string name="mixed_theme">микед Тема</string>
<string name="app_theme">Тема...</string>

<string name="shortcut_on">Брзо</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
</string>
<string name="write_external_storage_old_android_version_summary">На цих пристроях вся пам\'ять доступна за допомогою ієрархії файлів.</string>


<string name="shortcut_on">Швидко</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ https://github.com/ppareit/swiftp/issues 提交您的建议。\n\n
<string name="storage_warning">警告:当前存储暂不可用,您可能需要取消挂载。</string>
<string name="widget_name">FTP Server Widget</string>

<string name="shortcut_on">快速启动</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,5 @@ https://github.com/ppareit/swiftp/issues 提交您的建議。\n\n
</string>
<string name="write_external_storage_old_android_version_summary">在這些裝置上,可以使用檔案階層標準來使用所有存儲空間。</string>

<string name="shortcut_on">快速啟動</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,5 @@ https://github.com/ppareit/swiftp/issues .\n\n
</string>
<string name="write_external_storage_old_android_version_summary">On these devices, all store is available using the file hierarchy.</string>

<string name="shortcut_on">Quick on</string>
</resources>