diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5523d65a..871de9e72 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,8 @@ Changelog
* Handling *Camera.stopPreview*
* Handling *MediaRecorder.prepare* and *MediaRecorder.stop*
* Handling *Audio.stop*
+* Option to select time to allow/deny once ([issue](/../../issues/1873))
+* Updated Dutch translation
* Updated Japanese translation
[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
diff --git a/res/layout/ondemand.xml b/res/layout/ondemand.xml
index 5ed6d040d..418dfabb3 100644
--- a/res/layout/ondemand.xml
+++ b/res/layout/ondemand.xml
@@ -203,13 +203,29 @@
android:visibility="gone" >
-
-
+ android:orientation="horizontal" >
+
+
+
+
+
+
وظيفة:
مدخلات:
تطبيق على الفئة بأكملها
- مرة واحدة ل %s ثانية
+ Once for
القائمة البيضاء \'%s\'
تمكين
منع
diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml
index a49014f2b..1d64e1192 100644
--- a/res/values-bg/strings.xml
+++ b/res/values-bg/strings.xml
@@ -156,7 +156,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index 13976f1d4..fd9088ab7 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -154,7 +154,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml
index d0a909047..35f8e01eb 100644
--- a/res/values-cs/strings.xml
+++ b/res/values-cs/strings.xml
@@ -156,7 +156,7 @@ nicméně je nemožné zaručit bezchybnou funkčnost na všech zařízeních a
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 02fa5c3a4..dbb6c5840 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -154,7 +154,7 @@
Funktion:
Parametre:
Anvend for hele kategorien
- En gang hvert %s sekunder
+ Once for
White liste \'%s\'
Tillad
Afvis
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml
index f43b3c7e5..9100e1c2b 100644
--- a/res/values-de/strings.xml
+++ b/res/values-de/strings.xml
@@ -156,7 +156,7 @@ dass es einwandfrei auf wirklich JEDEM einzelnen Gerät und für JEDE einzelne A
Funktion:
Parameter:
Auf die gesamte Kategorie anwenden
- Nur einmal für %1$s Sekunden
+ Once for
Positivliste \'%1$s\'
Zulassen
Blockieren
diff --git a/res/values-ee/strings.xml b/res/values-ee/strings.xml
index bbab476f7..b5c69f740 100644
--- a/res/values-ee/strings.xml
+++ b/res/values-ee/strings.xml
@@ -156,7 +156,7 @@ kuid on võimatu garanteerida, et see töötab igal seadmel ja iga rakendusega.
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml
index 73de6295c..4893202f6 100644
--- a/res/values-el/strings.xml
+++ b/res/values-el/strings.xml
@@ -156,7 +156,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index 3a179704b..809e843e5 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -156,7 +156,7 @@ sin embargo no puedo garantizar que funcione sin ningún fallo para cada disposi
Función:
Parámetros:
Aplicar a toda la categoría
- Recordar por %s segundos
+ Once for
White/blacklist \'%s\'
Permitir
Denegar
diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml
index 556cd7e82..4bf314eba 100644
--- a/res/values-fa/strings.xml
+++ b/res/values-fa/strings.xml
@@ -158,7 +158,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml
index beb34807d..101dcf2b3 100644
--- a/res/values-fi/strings.xml
+++ b/res/values-fi/strings.xml
@@ -155,7 +155,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index f63eec54e..8507b8345 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -156,7 +156,7 @@ il est impossible de garantir un fonctionnement parfait sur chaque appareil et p
Fonction :
Paramètres :
Appliquer à toute la catégorie
- Une fois pendant %1$s secondes
+ Once for
Se souvenir de \'%1$s\'
Permettre
Bloquer
diff --git a/res/values-ga/strings.xml b/res/values-ga/strings.xml
index 2b63d8f67..86828a369 100644
--- a/res/values-ga/strings.xml
+++ b/res/values-ga/strings.xml
@@ -156,7 +156,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-he/strings.xml b/res/values-he/strings.xml
index 336e2fa11..c6d1e4f99 100644
--- a/res/values-he/strings.xml
+++ b/res/values-he/strings.xml
@@ -156,7 +156,7 @@ however it is impossible to guarantee it will work flawless on each and every de
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml
index 1a6101d2c..60e790370 100644
--- a/res/values-hi/strings.xml
+++ b/res/values-hi/strings.xml
@@ -156,7 +156,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-hr/strings.xml b/res/values-hr/strings.xml
index 2407aa958..62d23b624 100644
--- a/res/values-hr/strings.xml
+++ b/res/values-hr/strings.xml
@@ -155,7 +155,7 @@
Funkcija:
Parametri:
Primijeni na cijelu kategoriju
- Jednom svakih %1$s sekundi
+ Once for
Dodaj na listu dopuštenih/ograničenih ‘%1$s’
Dopusti
Zabrani
diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml
index 7454f326a..5c0bf39f3 100644
--- a/res/values-hu/strings.xml
+++ b/res/values-hu/strings.xml
@@ -156,7 +156,7 @@ de lehetetlen garantálni hogy tökéletesen működjön az összes eszközön
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml
index d76a047dc..1611f519b 100644
--- a/res/values-it/strings.xml
+++ b/res/values-it/strings.xml
@@ -156,7 +156,7 @@ tuttavia non è possibile garantire che funzioni perfettamente su qualunque disp
Funzione:
Parametri:
Applica a intera categoria
- Una volta per %1$s secondi
+ Once for
White/blacklist \'%s\'
Consenti
Rifiuta
diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml
index c1a0a6d97..3c45678c0 100644
--- a/res/values-iw/strings.xml
+++ b/res/values-iw/strings.xml
@@ -156,7 +156,7 @@ however it is impossible to guarantee it will work flawless on each and every de
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index 88592112b..9b1ee1d0d 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -156,7 +156,7 @@
機能 :
パラメーター :
カテゴリ全体に設定する
- 今回のみ%1$s秒間だけ設定する
+ Once for
ホワイトリスト/ブラックリスト ‘%1$s’
許可
拒否
diff --git a/res/values-ku-rIQ/strings.xml b/res/values-ku-rIQ/strings.xml
index 8fed64b1d..ceed741f4 100644
--- a/res/values-ku-rIQ/strings.xml
+++ b/res/values-ku-rIQ/strings.xml
@@ -155,7 +155,7 @@
ئيش:
Parameters:
بو هه موو به شه که
- ته نیا جاریک بو %s چرکه
+ Once for
White/blacklist \'%s\'
ریگه دان
ریگه نه دان
diff --git a/res/values-ku-rIR/strings.xml b/res/values-ku-rIR/strings.xml
index 8fed64b1d..ceed741f4 100644
--- a/res/values-ku-rIR/strings.xml
+++ b/res/values-ku-rIR/strings.xml
@@ -155,7 +155,7 @@
ئيش:
Parameters:
بو هه موو به شه که
- ته نیا جاریک بو %s چرکه
+ Once for
White/blacklist \'%s\'
ریگه دان
ریگه نه دان
diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml
index 494c89b07..1cbf7bcc6 100644
--- a/res/values-lt/strings.xml
+++ b/res/values-lt/strings.xml
@@ -156,7 +156,7 @@ Tačiau neįmanoma garantuoti, kad dirbs nepriekaištingai su kiekvienu prietais
Funkcija:
Parameterai:
Taikyti esamoje kategorijoje
- Vieną kartą %s sekundžių
+ Once for
Baltasis sąrašas \'%s\'
Leisti
Drausti
diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml
index 1a9c1dfb3..7b4e669af 100644
--- a/res/values-ms/strings.xml
+++ b/res/values-ms/strings.xml
@@ -156,7 +156,7 @@ namun ia adalah mustahil untuk menjaminkan penggunaan sempurna untuk setiap pera
Fungsi:
Parameter:
Laksanakan ke seluruh kategori
- Sekali untuk %s saat
+ Once for
White/blacklist \'%s\'
Benarkan
Tidak dibenarkan
diff --git a/res/values-nb-rNO/strings.xml b/res/values-nb-rNO/strings.xml
index ab1442172..5e3153252 100644
--- a/res/values-nb-rNO/strings.xml
+++ b/res/values-nb-rNO/strings.xml
@@ -154,7 +154,7 @@
Funksjon:
Parametere:
Bruk for hele kategorien
- En gang i %s sekunder
+ Once for
Positivliste \'%s\'
Tillat
Nekt
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index 0fb622727..f6bc3a05c 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -156,7 +156,7 @@ maar het is onmogelijk om te garanderen dat het op elk apparaat en voor elke app
Functie:
Parameters:
Pas toe op gehele categorie
- Één keer voor %1$s seconden
+ Eén keer voor
Negeerlijst ‘%1$s’
Toestaan
Blokkeren
diff --git a/res/values-nn-rNO/strings.xml b/res/values-nn-rNO/strings.xml
index ab1442172..5e3153252 100644
--- a/res/values-nn-rNO/strings.xml
+++ b/res/values-nn-rNO/strings.xml
@@ -154,7 +154,7 @@
Funksjon:
Parametere:
Bruk for hele kategorien
- En gang i %s sekunder
+ Once for
Positivliste \'%s\'
Tillat
Nekt
diff --git a/res/values-no-rNO/strings.xml b/res/values-no-rNO/strings.xml
index ab1442172..5e3153252 100644
--- a/res/values-no-rNO/strings.xml
+++ b/res/values-no-rNO/strings.xml
@@ -154,7 +154,7 @@
Funksjon:
Parametere:
Bruk for hele kategorien
- En gang i %s sekunder
+ Once for
Positivliste \'%s\'
Tillat
Nekt
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
index c3976e72d..07f6e6696 100644
--- a/res/values-pl/strings.xml
+++ b/res/values-pl/strings.xml
@@ -156,7 +156,7 @@
Funkcja:
Parametry:
Zastosuj do całej kategorii
- Jednorazowo na %s sekund
+ Once for
Biała lista \'%s\'
Pozwól
Zabroń
diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml
index dc2cb6e89..d8b992768 100644
--- a/res/values-pt/strings.xml
+++ b/res/values-pt/strings.xml
@@ -156,7 +156,7 @@ porém é impossível garantir que irá funcionar sem problemas em todos os disp
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml
index 198dc8f4a..6661c3181 100644
--- a/res/values-ro/strings.xml
+++ b/res/values-ro/strings.xml
@@ -156,7 +156,7 @@ however it is impossible to guarantee it will work flawless on each and every de
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index f477d2905..a05eec52f 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -156,7 +156,7 @@
Функция:
Параметры:
Применить ко всей категории
- Раз в %1$s сек.
+ Once for
Белый список \'%1$s\'
Разрешить
Запретить
diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml
index 9e4cccd7b..605628592 100644
--- a/res/values-sk/strings.xml
+++ b/res/values-sk/strings.xml
@@ -156,7 +156,7 @@ avšak nie je nemožné zaručiť, že bude fungovať bezchybne na každom zaria
Funkcia:
Parametre:
Použiť na celú kategóriu
- Raz za %s sekúnd
+ Once for
Biela/čierna listina \'%1$s\'
Povoliť
Odmietnuť
diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml
index 3f41ef8cb..21dfc6dd0 100644
--- a/res/values-sl/strings.xml
+++ b/res/values-sl/strings.xml
@@ -156,7 +156,7 @@
Funkcija:
Parametri:
Uveljavi za celotno kategorijo
- Enkrat na %1$s sekund
+ Once for
Dodaj \'%1$s\' na belo listo
Dovoli
Zavrni
diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml
index 5264fc3ff..e88aa51cf 100644
--- a/res/values-sr/strings.xml
+++ b/res/values-sr/strings.xml
@@ -156,7 +156,7 @@ however it is impossible to guarantee it will work flawless on each and every de
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml
index 430600b39..a74620305 100644
--- a/res/values-sv/strings.xml
+++ b/res/values-sv/strings.xml
@@ -156,7 +156,7 @@ Det är emellertid omöjligt att garantera att appen fungerar på alla enheter o
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-tl-rPH/strings.xml b/res/values-tl-rPH/strings.xml
index e09fe8b31..0f68dcc0d 100644
--- a/res/values-tl-rPH/strings.xml
+++ b/res/values-tl-rPH/strings.xml
@@ -156,7 +156,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml
index bdd3f25ec..70482da82 100644
--- a/res/values-tr/strings.xml
+++ b/res/values-tr/strings.xml
@@ -155,7 +155,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-ua/strings.xml b/res/values-ua/strings.xml
index b4fa65633..2531ee5f3 100644
--- a/res/values-ua/strings.xml
+++ b/res/values-ua/strings.xml
@@ -156,7 +156,7 @@
Function:
Parameters:
Apply to entire category
- Once for %s seconds
+ Once for
White/blacklist \'%s\'
Allow
Deny
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index eb4fb87c2..423c66bd7 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -155,7 +155,7 @@
Chức năng:
Các thông số:
Áp dụng cho toàn bộ danh mục
- Một lần cho %s giây
+ Once for
Danh sách cho phép \'%s\'
Cho phép
Từ chối
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 79bd08b5a..2af84bf19 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -156,7 +156,7 @@
功能:
参数:
应用到整个权限类别
- 一次操作生效%1$s秒
+ Once for
白名单/黑名单‘%1$s’
允许
拒绝
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index d1cca5971..0d0b88035 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -156,7 +156,7 @@
功能:
參數:
套用至整個限制分類
- %s 秒後再次詢問
+ Once for
白名單 \'%s\'
允許
封鎖
diff --git a/res/values/strings.xml b/res/values/strings.xml
index adf2e57aa..0f29187b6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -165,7 +165,7 @@ however it is impossible to guarantee it will work flawlessly on each and every
Function:
Parameters:
Apply to entire category
- Once for %1$s seconds
+ Once for
White/blacklist ‘%1$s’
Allow
Deny
diff --git a/src/biz/bokhorst/xprivacy/PrivacyManager.java b/src/biz/bokhorst/xprivacy/PrivacyManager.java
index 89bb66c0b..fd0506bde 100644
--- a/src/biz/bokhorst/xprivacy/PrivacyManager.java
+++ b/src/biz/bokhorst/xprivacy/PrivacyManager.java
@@ -135,6 +135,7 @@ public class PrivacyManager {
public final static String cSettingODExpert = "ODExpert";
public final static String cSettingODCategory = "ODCategory";
public final static String cSettingODOnce = "ODOnce";
+ public final static String cSettingODOnceDuration = "ODOnceDuration";
// Special value names
public final static String cValueRandom = "#Random#";
diff --git a/src/biz/bokhorst/xprivacy/PrivacyService.java b/src/biz/bokhorst/xprivacy/PrivacyService.java
index 837bc4ff6..b13dc7374 100644
--- a/src/biz/bokhorst/xprivacy/PrivacyService.java
+++ b/src/biz/bokhorst/xprivacy/PrivacyService.java
@@ -59,6 +59,7 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
+import android.widget.Spinner;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
@@ -1502,9 +1503,7 @@ private OnDemandResult onDemandDialog(final Hook hook, final PRestriction restri
}
}
- // Build dialog view
final OnDemandDialogHolder holder = new OnDemandDialogHolder();
- holder.dialog = getOnDemandView(restriction, hook, appInfo, result, context, holder, oResult);
// Build dialog parameters
final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
@@ -1525,50 +1524,68 @@ private OnDemandResult onDemandDialog(final Hook hook, final PRestriction restri
mHandler.post(new Runnable() {
@Override
public void run() {
- wm.addView(holder.dialog, params);
- }
- });
-
- // Update progress bar
- Runnable runProgress = new Runnable() {
- @Override
- public void run() {
- // Update progress bar
- ProgressBar progressBar = (ProgressBar) holder.dialog.findViewById(R.id.pbProgress);
- if (holder.dialog != null && holder.dialog.isShown() && progressBar.getProgress() > 0) {
- progressBar.incrementProgressBy(-1);
- mHandler.postDelayed(this, 50);
- }
+ try {
+ // Build dialog
+ holder.dialog = getOnDemandView(restriction, hook, appInfo, result, context, holder,
+ oResult);
+
+ // Handle reset button
+ ((Button) holder.dialog.findViewById(R.id.btnReset))
+ .setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ ((ProgressBar) holder.dialog.findViewById(R.id.pbProgress))
+ .setProgress(cMaxOnDemandDialog * 20);
+ holder.reset = true;
+ holder.latch.countDown();
+ }
+ });
+
+ // Make dialog visible
+ wm.addView(holder.dialog, params);
+
+ // Update progress bar
+ Runnable runProgress = new Runnable() {
+ @Override
+ public void run() {
+ if (holder.dialog != null && holder.dialog.isShown()) {
+ // Update progress bar
+ ProgressBar progressBar = (ProgressBar) holder.dialog
+ .findViewById(R.id.pbProgress);
+ if (progressBar.getProgress() > 0) {
+ progressBar.incrementProgressBy(-1);
+ mHandler.postDelayed(this, 50);
+ }
+
+ // Check if activity manager locked
+ if (isAMLocked()) {
+ Util.log(null, Log.WARN, "On demand dialog locked " + restriction);
+ ((Button) holder.dialog.findViewById(R.id.btnDontKnow)).callOnClick();
+ }
+ }
+ }
+ };
+ mHandler.postDelayed(runProgress, 50);
+
+ // Enabled buttons after one second
+ boolean repeat = (SystemClock.elapsedRealtime() - mOnDemandLastAnswer < 1000);
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (holder.dialog != null && holder.dialog.isShown()) {
+ holder.dialog.findViewById(R.id.btnAllow).setEnabled(true);
+ holder.dialog.findViewById(R.id.btnDontKnow).setEnabled(true);
+ holder.dialog.findViewById(R.id.btnDeny).setEnabled(true);
+ }
+ }
+ }, repeat ? 0 : 1000);
- // Check if activity manager locked
- if (isAMLocked()) {
- Util.log(null, Log.WARN, "On demand dialog locked " + restriction);
- ((Button) holder.dialog.findViewById(R.id.btnDontKnow)).callOnClick();
+ } catch (NameNotFoundException ex) {
+ Util.log(null, Log.WARN, ex.toString());
+ } catch (Throwable ex) {
+ Util.bug(null, ex);
}
}
- };
- mHandler.postDelayed(runProgress, 50);
-
- // Enabled buttons after one second
- boolean repeat = (SystemClock.elapsedRealtime() - mOnDemandLastAnswer < 1000);
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- holder.dialog.findViewById(R.id.btnAllow).setEnabled(true);
- holder.dialog.findViewById(R.id.btnDontKnow).setEnabled(true);
- holder.dialog.findViewById(R.id.btnDeny).setEnabled(true);
- }
- }, repeat ? 0 : 1000);
-
- // Handle reset button
- ((Button) holder.dialog.findViewById(R.id.btnReset)).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- ((ProgressBar) holder.dialog.findViewById(R.id.pbProgress))
- .setProgress(cMaxOnDemandDialog * 20);
- holder.reset = true;
- holder.latch.countDown();
- }
});
// Wait for choice, reset or timeout
@@ -1601,8 +1618,6 @@ public void run() {
} finally {
Binder.restoreCallingIdentity(token);
}
- } catch (NameNotFoundException ex) {
- Util.log(null, Log.WARN, ex.toString());
} catch (Throwable ex) {
Util.bug(null, ex);
}
@@ -1632,6 +1647,7 @@ private View getOnDemandView(final PRestriction restriction, final Hook hook, Ap
final CheckBox cbExpert = (CheckBox) view.findViewById(R.id.cbExpert);
final CheckBox cbCategory = (CheckBox) view.findViewById(R.id.cbCategory);
final CheckBox cbOnce = (CheckBox) view.findViewById(R.id.cbOnce);
+ final Spinner spOnce = (Spinner) view.findViewById(R.id.spOnce);
final LinearLayout llWhiteList = (LinearLayout) view.findViewById(R.id.llWhiteList);
final CheckBox cbWhitelist = (CheckBox) view.findViewById(R.id.cbWhitelist);
final CheckBox cbWhitelistExtra1 = (CheckBox) view.findViewById(R.id.cbWhitelistExtra1);
@@ -1691,8 +1707,9 @@ private View getOnDemandView(final PRestriction restriction, final Hook hook, Ap
// Once
cbOnce.setChecked(once);
- cbOnce.setText(String.format(resources.getString(R.string.title_once),
- PrivacyManager.cRestrictionCacheTimeoutMs / 1000));
+ int osel = Integer
+ .parseInt(getSetting(new PSetting(userId, "", PrivacyManager.cSettingODOnceDuration, "0")).value);
+ spOnce.setSelection(osel);
// Whitelisting
if (hook != null && hook.whitelist() != null && restriction.extra != null) {
@@ -1834,7 +1851,7 @@ else if (cbWhitelistExtra3.isChecked())
setSettingBool(userId, "", PrivacyManager.cSettingODOnce, cbOnce.isChecked());
if (cbOnce.isChecked())
- onDemandOnce(restriction, cbCategory.isChecked(), result, oResult);
+ onDemandOnce(restriction, cbCategory.isChecked(), result, oResult, spOnce);
else
onDemandChoice(restriction, cbCategory.isChecked(), false);
}
@@ -1848,7 +1865,7 @@ public void onClick(View v) {
// Deny once
result.restricted = !(hook != null && hook.isDangerous());
result.asked = true;
- onDemandOnce(restriction, false, result, oResult);
+ onDemandOnce(restriction, false, result, oResult, spOnce);
holder.latch.countDown();
}
});
@@ -1873,7 +1890,7 @@ else if (cbWhitelistExtra3.isChecked())
setSettingBool(userId, "", PrivacyManager.cSettingODOnce, cbOnce.isChecked());
if (cbOnce.isChecked())
- onDemandOnce(restriction, cbCategory.isChecked(), result, oResult);
+ onDemandOnce(restriction, cbCategory.isChecked(), result, oResult, spOnce);
else
onDemandChoice(restriction, cbCategory.isChecked(), true);
}
@@ -1954,12 +1971,35 @@ private void onDemandWhitelist(PRestriction restriction, String xextra, PRestric
}
}
- private void onDemandOnce(PRestriction restriction, boolean category, PRestriction result, OnDemandResult oResult) {
- Util.log(null, Log.WARN, (result.restricted ? "Deny" : "Allow") + " once " + restriction + " category="
- + category);
-
+ private void onDemandOnce(PRestriction restriction, boolean category, PRestriction result, OnDemandResult oResult,
+ Spinner spOnce) {
oResult.once = true;
- result.time = new Date().getTime() + PrivacyManager.cRestrictionCacheTimeoutMs;
+
+ // Get duration
+ String value = (String) spOnce.getSelectedItem();
+ if (value == null)
+ result.time = new Date().getTime() + PrivacyManager.cRestrictionCacheTimeoutMs;
+ else {
+ char unit = value.charAt(value.length() - 1);
+ value = value.substring(0, value.length() - 1);
+ if (unit == 's')
+ result.time = new Date().getTime() + Integer.parseInt(value) * 1000;
+ else if (unit == 'm')
+ result.time = new Date().getTime() + Integer.parseInt(value) * 60 * 1000;
+ else
+ result.time = new Date().getTime() + PrivacyManager.cRestrictionCacheTimeoutMs;
+
+ try {
+ int userId = Util.getUserId(restriction.uid);
+ String sel = Integer.toString(spOnce.getSelectedItemPosition());
+ setSettingInternal(new PSetting(userId, "", PrivacyManager.cSettingODOnceDuration, sel));
+ } catch (Throwable ex) {
+ Util.bug(null, ex);
+ }
+ }
+
+ Util.log(null, Log.WARN, (result.restricted ? "Deny" : "Allow") + " once " + restriction + " category="
+ + category + " until=" + new Date(result.time));
CRestriction key = new CRestriction(result, null);
if (category) {
diff --git a/tools/addstring.sh b/tools/addstring.sh
index 779349307..7042abc13 100755
--- a/tools/addstring.sh
+++ b/tools/addstring.sh
@@ -1,8 +1,8 @@
#!/bin/bash
-grep -RIl "\XPrivacy 2 is not supported anymore, please consider upgrading to XPrivacy 3'
+grep -RIl "\Once for'
#grep -RIl "\