packages/apps/Taskbar
Revisión | 7604af3300ce23994a962d499d3e3839b01c4054 (tree) |
---|---|
Tiempo | 2020-04-14 05:22:50 |
Autor | Braden Farmer <farmerbb@gmai...> |
Commiter | Braden Farmer |
Split FavoriteAppTileService into three separate tiles
@@ -261,7 +261,7 @@ | ||
261 | 261 | android:name=".activity.PersistentShortcutSelectAppActivity" |
262 | 262 | android:label="@string/tb_new_shortcut" |
263 | 263 | android:excludeFromRecents="true" |
264 | - android:launchMode="singleTask" | |
264 | + android:launchMode="singleInstance" | |
265 | 265 | android:theme="@style/Taskbar.Dialog.Blacklist" > |
266 | 266 | <intent-filter> |
267 | 267 | <action android:name="android.intent.action.MAIN" /> |
@@ -312,7 +312,29 @@ | ||
312 | 312 | android:value="true" /> |
313 | 313 | </service> |
314 | 314 | <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" | |
316 | 338 | android:label="@string/tb_new_shortcut" |
317 | 339 | android:icon="@drawable/tb_favorite_app_tile" |
318 | 340 | android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> |
@@ -83,8 +83,9 @@ public class PersistentShortcutSelectAppActivity extends AbstractSelectAppActivi | ||
83 | 83 | } |
84 | 84 | |
85 | 85 | 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); | |
88 | 89 | else |
89 | 90 | createHomeScreenShortcut(windowSize); |
90 | 91 |
@@ -112,15 +113,17 @@ public class PersistentShortcutSelectAppActivity extends AbstractSelectAppActivi | ||
112 | 113 | } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ } |
113 | 114 | } |
114 | 115 | |
115 | - private void createQuickSettingTileShortcut(String windowSize) { | |
116 | + private void createQuickSettingTileShortcut(String windowSize, int num) { | |
117 | + String prefix = "qs_tile_" + num + "_"; | |
118 | + | |
116 | 119 | SharedPreferences pref = U.getSharedPreferences(this); |
117 | 120 | SharedPreferences.Editor editor = pref.edit(); |
118 | 121 | |
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); | |
124 | 127 | editor.apply(); |
125 | 128 | |
126 | 129 | U.sendBroadcast(this, TaskbarIntent.ACTION_UPDATE_FAVORITE_APP_TILE); |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -32,7 +32,11 @@ import com.farmerbb.taskbar.util.TaskbarIntent; | ||
32 | 32 | import com.farmerbb.taskbar.util.U; |
33 | 33 | |
34 | 34 | @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() + "_"; | |
36 | 40 | |
37 | 41 | private BroadcastReceiver tileUpdateReceiver = new BroadcastReceiver() { |
38 | 42 | @Override |
@@ -61,13 +65,13 @@ public class FavoriteAppTileService extends TileService { | ||
61 | 65 | @Override |
62 | 66 | public void onTileRemoved() { |
63 | 67 | SharedPreferences pref = U.getSharedPreferences(this); |
64 | - pref.edit().putBoolean("qs_tile_added", false).apply(); | |
68 | + pref.edit().putBoolean(prefix + "added", false).apply(); | |
65 | 69 | } |
66 | 70 | |
67 | 71 | @Override |
68 | 72 | public void onClick() { |
69 | 73 | SharedPreferences pref = U.getSharedPreferences(this); |
70 | - if(!pref.getBoolean("qs_tile_added", false)) { | |
74 | + if(!pref.getBoolean(prefix + "added", false)) { | |
71 | 75 | selectApp(); |
72 | 76 | return; |
73 | 77 | } |
@@ -81,7 +85,7 @@ public class FavoriteAppTileService extends TileService { | ||
81 | 85 | private void selectApp() { |
82 | 86 | Intent intent = new Intent(this, PersistentShortcutSelectAppActivity.class); |
83 | 87 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
84 | - intent.putExtra("qs_tile", true); | |
88 | + intent.putExtra("qs_tile", tileNumber()); | |
85 | 89 | startActivityAndCollapse(intent); |
86 | 90 | } |
87 | 91 |
@@ -91,9 +95,9 @@ public class FavoriteAppTileService extends TileService { | ||
91 | 95 | Intent shortcutIntent = new Intent(this, PersistentShortcutLaunchActivity.class); |
92 | 96 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
93 | 97 | 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)); | |
97 | 101 | |
98 | 102 | startActivityAndCollapse(shortcutIntent); |
99 | 103 | } |
@@ -105,9 +109,9 @@ public class FavoriteAppTileService extends TileService { | ||
105 | 109 | SharedPreferences pref = U.getSharedPreferences(this); |
106 | 110 | tile.setIcon(Icon.createWithResource(this, R.drawable.tb_favorite_app_tile)); |
107 | 111 | |
108 | - if(pref.getBoolean("qs_tile_added", false)) { | |
112 | + if(pref.getBoolean(prefix + "added", false)) { | |
109 | 113 | 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))); | |
111 | 115 | } else { |
112 | 116 | tile.setState(Tile.STATE_INACTIVE); |
113 | 117 | tile.setLabel(getString(R.string.tb_new_shortcut)); |
@@ -314,7 +314,7 @@ | ||
314 | 314 | android:name=".activity.PersistentShortcutSelectAppActivity" |
315 | 315 | android:label="@string/tb_new_shortcut" |
316 | 316 | android:excludeFromRecents="true" |
317 | - android:launchMode="singleTask" | |
317 | + android:launchMode="singleInstance" | |
318 | 318 | android:theme="@style/Taskbar.Dialog.Blacklist" > |
319 | 319 | <intent-filter> |
320 | 320 | <action android:name="android.intent.action.MAIN" /> |
@@ -383,7 +383,29 @@ | ||
383 | 383 | android:value="true" /> |
384 | 384 | </service> |
385 | 385 | <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" | |
387 | 409 | android:label="@string/tb_new_shortcut" |
388 | 410 | android:icon="@drawable/tb_favorite_app_tile" |
389 | 411 | android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> |