Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Taskbar: Commit

packages/apps/Taskbar


Commit MetaInfo

Revisión7604af3300ce23994a962d499d3e3839b01c4054 (tree)
Tiempo2020-04-14 05:22:50
AutorBraden Farmer <farmerbb@gmai...>
CommiterBraden Farmer

Log Message

Split FavoriteAppTileService into three separate tiles

Cambiar Resumen

Diferencia incremental

--- a/app/src/androidx86/AndroidManifest.xml
+++ b/app/src/androidx86/AndroidManifest.xml
@@ -261,7 +261,7 @@
261261 android:name=".activity.PersistentShortcutSelectAppActivity"
262262 android:label="@string/tb_new_shortcut"
263263 android:excludeFromRecents="true"
264- android:launchMode="singleTask"
264+ android:launchMode="singleInstance"
265265 android:theme="@style/Taskbar.Dialog.Blacklist" >
266266 <intent-filter>
267267 <action android:name="android.intent.action.MAIN" />
@@ -312,7 +312,29 @@
312312 android:value="true" />
313313 </service>
314314 <service
315- android:name=".service.FavoriteAppTileService"
315+ android:name=".service.FavoriteApp1"
316+ android:label="@string/tb_new_shortcut"
317+ android:icon="@drawable/tb_favorite_app_tile"
318+ android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
319+ <intent-filter>
320+ <action android:name="android.service.quicksettings.action.QS_TILE" />
321+ </intent-filter>
322+ <meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
323+ android:value="true" />
324+ </service>
325+ <service
326+ android:name=".service.FavoriteApp2"
327+ android:label="@string/tb_new_shortcut"
328+ android:icon="@drawable/tb_favorite_app_tile"
329+ android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
330+ <intent-filter>
331+ <action android:name="android.service.quicksettings.action.QS_TILE" />
332+ </intent-filter>
333+ <meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
334+ android:value="true" />
335+ </service>
336+ <service
337+ android:name=".service.FavoriteApp3"
316338 android:label="@string/tb_new_shortcut"
317339 android:icon="@drawable/tb_favorite_app_tile"
318340 android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
--- a/app/src/nonlib/java/com/farmerbb/taskbar/activity/PersistentShortcutSelectAppActivity.java
+++ b/app/src/nonlib/java/com/farmerbb/taskbar/activity/PersistentShortcutSelectAppActivity.java
@@ -83,8 +83,9 @@ public class PersistentShortcutSelectAppActivity extends AbstractSelectAppActivi
8383 }
8484
8585 private void createShortcut(String windowSize) {
86- if(getIntent().getBooleanExtra("qs_tile", false))
87- createQuickSettingTileShortcut(windowSize);
86+ int num = getIntent().getIntExtra("qs_tile", 0);
87+ if(num > 0)
88+ createQuickSettingTileShortcut(windowSize, num);
8889 else
8990 createHomeScreenShortcut(windowSize);
9091
@@ -112,15 +113,17 @@ public class PersistentShortcutSelectAppActivity extends AbstractSelectAppActivi
112113 } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ }
113114 }
114115
115- private void createQuickSettingTileShortcut(String windowSize) {
116+ private void createQuickSettingTileShortcut(String windowSize, int num) {
117+ String prefix = "qs_tile_" + num + "_";
118+
116119 SharedPreferences pref = U.getSharedPreferences(this);
117120 SharedPreferences.Editor editor = pref.edit();
118121
119- editor.putString("qs_tile_package_name", selectedEntry.getPackageName());
120- editor.putString("qs_tile_component_name", selectedEntry.getComponentName());
121- editor.putString("qs_tile_label", selectedEntry.getLabel());
122- editor.putString("qs_tile_window_size", windowSize);
123- editor.putBoolean("qs_tile_added", true);
122+ editor.putString(prefix + "package_name", selectedEntry.getPackageName());
123+ editor.putString(prefix + "component_name", selectedEntry.getComponentName());
124+ editor.putString(prefix + "label", selectedEntry.getLabel());
125+ editor.putString(prefix + "window_size", windowSize);
126+ editor.putBoolean(prefix + "added", true);
124127 editor.apply();
125128
126129 U.sendBroadcast(this, TaskbarIntent.ACTION_UPDATE_FAVORITE_APP_TILE);
--- /dev/null
+++ b/app/src/nonlib/java/com/farmerbb/taskbar/service/FavoriteApp1.java
@@ -0,0 +1,23 @@
1+/* Copyright 2020 Braden Farmer
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+package com.farmerbb.taskbar.service;
17+
18+public class FavoriteApp1 extends FavoriteAppTileService {
19+ @Override
20+ protected int tileNumber() {
21+ return 1;
22+ }
23+}
\ No newline at end of file
--- /dev/null
+++ b/app/src/nonlib/java/com/farmerbb/taskbar/service/FavoriteApp2.java
@@ -0,0 +1,23 @@
1+/* Copyright 2020 Braden Farmer
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+package com.farmerbb.taskbar.service;
17+
18+public class FavoriteApp2 extends FavoriteAppTileService {
19+ @Override
20+ protected int tileNumber() {
21+ return 2;
22+ }
23+}
\ No newline at end of file
--- /dev/null
+++ b/app/src/nonlib/java/com/farmerbb/taskbar/service/FavoriteApp3.java
@@ -0,0 +1,23 @@
1+/* Copyright 2020 Braden Farmer
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+package com.farmerbb.taskbar.service;
17+
18+public class FavoriteApp3 extends FavoriteAppTileService {
19+ @Override
20+ protected int tileNumber() {
21+ return 3;
22+ }
23+}
\ No newline at end of file
--- a/app/src/nonlib/java/com/farmerbb/taskbar/service/FavoriteAppTileService.java
+++ b/app/src/nonlib/java/com/farmerbb/taskbar/service/FavoriteAppTileService.java
@@ -32,7 +32,11 @@ import com.farmerbb.taskbar.util.TaskbarIntent;
3232 import com.farmerbb.taskbar.util.U;
3333
3434 @TargetApi(Build.VERSION_CODES.N)
35-public class FavoriteAppTileService extends TileService {
35+public abstract class FavoriteAppTileService extends TileService {
36+
37+ protected abstract int tileNumber();
38+
39+ private String prefix = "qs_tile_" + tileNumber() + "_";
3640
3741 private BroadcastReceiver tileUpdateReceiver = new BroadcastReceiver() {
3842 @Override
@@ -61,13 +65,13 @@ public class FavoriteAppTileService extends TileService {
6165 @Override
6266 public void onTileRemoved() {
6367 SharedPreferences pref = U.getSharedPreferences(this);
64- pref.edit().putBoolean("qs_tile_added", false).apply();
68+ pref.edit().putBoolean(prefix + "added", false).apply();
6569 }
6670
6771 @Override
6872 public void onClick() {
6973 SharedPreferences pref = U.getSharedPreferences(this);
70- if(!pref.getBoolean("qs_tile_added", false)) {
74+ if(!pref.getBoolean(prefix + "added", false)) {
7175 selectApp();
7276 return;
7377 }
@@ -81,7 +85,7 @@ public class FavoriteAppTileService extends TileService {
8185 private void selectApp() {
8286 Intent intent = new Intent(this, PersistentShortcutSelectAppActivity.class);
8387 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
84- intent.putExtra("qs_tile", true);
88+ intent.putExtra("qs_tile", tileNumber());
8589 startActivityAndCollapse(intent);
8690 }
8791
@@ -91,9 +95,9 @@ public class FavoriteAppTileService extends TileService {
9195 Intent shortcutIntent = new Intent(this, PersistentShortcutLaunchActivity.class);
9296 shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
9397 shortcutIntent.setAction(Intent.ACTION_MAIN);
94- shortcutIntent.putExtra("package_name", pref.getString("qs_tile_package_name", null));
95- shortcutIntent.putExtra("component_name", pref.getString("qs_tile_component_name", null));
96- shortcutIntent.putExtra("window_size", pref.getString("qs_tile_window_size", null));
98+ shortcutIntent.putExtra("package_name", pref.getString(prefix + "package_name", null));
99+ shortcutIntent.putExtra("component_name", pref.getString(prefix + "component_name", null));
100+ shortcutIntent.putExtra("window_size", pref.getString(prefix + "window_size", null));
97101
98102 startActivityAndCollapse(shortcutIntent);
99103 }
@@ -105,9 +109,9 @@ public class FavoriteAppTileService extends TileService {
105109 SharedPreferences pref = U.getSharedPreferences(this);
106110 tile.setIcon(Icon.createWithResource(this, R.drawable.tb_favorite_app_tile));
107111
108- if(pref.getBoolean("qs_tile_added", false)) {
112+ if(pref.getBoolean(prefix + "added", false)) {
109113 tile.setState(Tile.STATE_ACTIVE);
110- tile.setLabel(pref.getString("qs_tile_label", getString(R.string.tb_new_shortcut)));
114+ tile.setLabel(pref.getString(prefix + "label", getString(R.string.tb_new_shortcut)));
111115 } else {
112116 tile.setState(Tile.STATE_INACTIVE);
113117 tile.setLabel(getString(R.string.tb_new_shortcut));
--- a/app/src/playstore/AndroidManifest.xml
+++ b/app/src/playstore/AndroidManifest.xml
@@ -314,7 +314,7 @@
314314 android:name=".activity.PersistentShortcutSelectAppActivity"
315315 android:label="@string/tb_new_shortcut"
316316 android:excludeFromRecents="true"
317- android:launchMode="singleTask"
317+ android:launchMode="singleInstance"
318318 android:theme="@style/Taskbar.Dialog.Blacklist" >
319319 <intent-filter>
320320 <action android:name="android.intent.action.MAIN" />
@@ -383,7 +383,29 @@
383383 android:value="true" />
384384 </service>
385385 <service
386- android:name=".service.FavoriteAppTileService"
386+ android:name=".service.FavoriteApp1"
387+ android:label="@string/tb_new_shortcut"
388+ android:icon="@drawable/tb_favorite_app_tile"
389+ android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
390+ <intent-filter>
391+ <action android:name="android.service.quicksettings.action.QS_TILE" />
392+ </intent-filter>
393+ <meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
394+ android:value="true" />
395+ </service>
396+ <service
397+ android:name=".service.FavoriteApp2"
398+ android:label="@string/tb_new_shortcut"
399+ android:icon="@drawable/tb_favorite_app_tile"
400+ android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
401+ <intent-filter>
402+ <action android:name="android.service.quicksettings.action.QS_TILE" />
403+ </intent-filter>
404+ <meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
405+ android:value="true" />
406+ </service>
407+ <service
408+ android:name=".service.FavoriteApp3"
387409 android:label="@string/tb_new_shortcut"
388410 android:icon="@drawable/tb_favorite_app_tile"
389411 android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
Show on old repository browser