Skip to content

Commit 0e6532a

Browse files
committed
Add option to hide the widget when tapped
1 parent 02ae378 commit 0e6532a

11 files changed

Lines changed: 55 additions & 20 deletions

File tree

floatstat/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
<queries>
5656
<package android:name="id.psw.floatstat"/>
5757
<intent>
58-
<category android:name="id.psw.floatstat.category.PLUGIN"/>
58+
<action android:name="id.psw.floatstat.category.START_PLUGIN"/>
59+
<category android:name="id.psw.floatstat.category.DATA_PLUGIN"/>
5960
</intent>
6061
</queries>
6162

floatstat/src/main/java/id/psw/floatstat/App.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class App : Application() {
4040
const val PK_ENABLED_PLUGIN = "TetambahanAktif"
4141
const val PK_DEFAULT_PLUGIN_DISPLAY = "TetambahanTampil"
4242
const val PK_RUN_ON_STARTUP = "MulaiPasHidup"
43+
const val PK_HIDE_ON_TAP = "HideTap"
4344
}
4445

4546

@@ -191,6 +192,7 @@ class App : Application() {
191192
var reReadPreference = false
192193
val activePlugins = arrayListOf<PluginId>()
193194
var defaultPlugin = PluginId("","")
195+
var hideOnTap = false
194196
lateinit var pref : SharedPreferences
195197

196198
@SuppressLint("ApplySharedPref")
@@ -225,6 +227,7 @@ class App : Application() {
225227
defaultPlugin = PluginId(defPlug)
226228
}
227229
startOnBoot = pref.getBoolean(PK_RUN_ON_STARTUP, false)
230+
hideOnTap = pref.getBoolean(PK_HIDE_ON_TAP, false)
228231
}
229232

230233
fun savePreferences(){
@@ -235,6 +238,7 @@ class App : Application() {
235238
.putString(PK_ENABLED_PLUGIN, activePluginIds.toString())
236239
.putString(PK_DEFAULT_PLUGIN_DISPLAY, defaultPlugin.toString())
237240
.putBoolean(PK_RUN_ON_STARTUP, startOnBoot)
241+
.putBoolean(PK_HIDE_ON_TAP, hideOnTap)
238242
.apply()
239243
}
240244

@@ -273,7 +277,7 @@ class App : Application() {
273277
it.binder.requestStop()
274278
}
275279
unbindService(pluginConnector)
276-
Log.d("", "Temperamon terminating...")
280+
Log.d("App", "Temperamon terminating...")
277281
super.onTerminate()
278282
}
279283

@@ -282,7 +286,9 @@ class App : Application() {
282286
}
283287

284288
fun openDonateUri() {
285-
289+
val i = Intent(Intent.ACTION_VIEW)
290+
i.data = Uri.parse("https://github.com/EmiyaSyahriel/floatstat/blob/master/readme/DONATE.MD")
291+
startActivity(i)
286292
}
287293

288294
}

floatstat/src/main/java/id/psw/floatstat/FloatWindowService.kt

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ class FloatWindowService : Service() {
9090
vWinMan = winMan
9191

9292
mainView.setOnClickListener {
93-
mainView.isExpanded = !mainView.isExpanded
94-
app().shouldUpdate = true
93+
val app = app()
94+
if(app.hideOnTap){
95+
vMainView?.visibility = View.GONE
96+
}else{
97+
mainView.isExpanded = !mainView.isExpanded
98+
app.shouldUpdate = true
99+
}
95100
}
96101

97102
mainView.setOnTouchListener { _, e ->
@@ -110,8 +115,13 @@ class FloatWindowService : Service() {
110115
viewParam.x = if(viewParam.x < 0) -w else w
111116

112117
if((currentTouch - mainView.initialTouch).length() < slop){ // Is Tap
113-
mainView.isExpanded = !mainView.isExpanded
114-
app().shouldUpdate = true
118+
val app = app()
119+
if(app.hideOnTap){
120+
vMainView?.visibility = View.GONE
121+
}else{
122+
mainView.isExpanded = !mainView.isExpanded
123+
app.shouldUpdate = true
124+
}
115125

116126
val sz = mainView.getSize()
117127
viewParam.width = sz.x
@@ -188,10 +198,14 @@ class FloatWindowService : Service() {
188198
openEditWindow()
189199
}
190200
ACTION_VISIBILITY -> {
191-
vMainView?.visibility = when(vMainView?.visibility){
192-
View.VISIBLE -> View.GONE
193-
View.GONE -> View.VISIBLE
194-
else -> View.VISIBLE
201+
if(app().hideOnTap){
202+
vMainView?.visibility = View.VISIBLE
203+
}else{
204+
vMainView?.visibility = when(vMainView?.visibility){
205+
View.VISIBLE -> View.GONE
206+
View.GONE -> View.VISIBLE
207+
else -> View.VISIBLE
208+
}
195209
}
196210
}
197211
}
@@ -244,9 +258,11 @@ class FloatWindowService : Service() {
244258
titleBar.findViewById<ImageButton>(R.id.menu_btn).apply {
245259
colorFilter = PorterDuffColorFilter(cfColor, PorterDuff.Mode.SRC_IN)
246260
setOnClickListener { btn ->
247-
PopupMenu(context, this).apply {
248-
menuInflater.inflate(R.menu.selector_menu, menu)
261+
PopupMenu(applicationContext, btn).apply {
262+
inflate(R.menu.selector_menu)
249263
menu.findItem(R.id.plugin_selector_bootstart).isChecked = app.startOnBoot
264+
menu.findItem(R.id.plugin_selector_hide_on_tap).isChecked = app.hideOnTap
265+
show()
250266

251267
setOnMenuItemClickListener {
252268
when(it.itemId){
@@ -265,10 +281,13 @@ class FloatWindowService : Service() {
265281
app.startOnBoot = !app.startOnBoot
266282
app.savePreferences()
267283
}
284+
R.id.plugin_selector_hide_on_tap -> {
285+
app.hideOnTap = !app.hideOnTap
286+
app.savePreferences()
287+
}
268288
}
269289
true
270290
}
271-
show()
272291
}
273292
}
274293
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
5+
</vector>

floatstat/src/main/res/menu/selector_menu.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414
android:icon="@drawable/ic_bootstart"
1515
android:checkable="true"
1616
android:title="@string/selector_bootstart" />
17+
<item
18+
android:id="@+id/plugin_selector_hide_on_tap"
19+
android:icon="@drawable/ic_hide_on_tap"
20+
android:checkable="true"
21+
android:title="@string/selector_hide_on_tap" />
1722
</menu>

floatstat/src/main/res/values-in/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
<string name="float_stat_notif_visibility">Tampil/Sembunyi</string>
2727
<string name="float_stat_notif_edit">Ubah</string>
2828
<string name="float_stat_notif_close">Tutup</string>
29+
<string name="selector_hide_on_tap">Sembunyi ktk Tap</string>
2930
</resources>

floatstat/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
<string name="float_stat_notif_visibility">表示/非表示</string>
2727
<string name="float_stat_notif_edit">編集する</string>
2828
<string name="float_stat_notif_close">終了する</string>
29+
<string name="selector_hide_on_tap">タップでかくして</string>
2930
</resources>

floatstat/src/main/res/values-jv/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
<string name="float_stat_notif_visibility">Katon/Singit</string>
2727
<string name="float_stat_notif_edit">Ubah</string>
2828
<string name="float_stat_notif_close">Tutup</string>
29+
<string name="selector_hide_on_tap">Singitaken ps. Tap</string>
2930
</resources>

floatstat/src/main/res/values-ms/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@
2626
<string name="float_stat_notif_visibility">Tunjukkan/Sembunyikan</string>
2727
<string name="float_stat_notif_edit">Sunting</string>
2828
<string name="float_stat_notif_close">Tutup</string>
29+
<string name="selector_hide_on_tap">Sembunyikan ktk Tap</string>
2930
</resources>

floatstat/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@
2929
<string name="float_stat_notif_visibility">Show/Hide</string>
3030
<string name="float_stat_notif_close">Close</string>
3131
<string name="float_stat_notif_edit">Edit</string>
32+
<string name="selector_hide_on_tap">Hide on Tap</string>
3233
</resources>

0 commit comments

Comments
 (0)