Skip to content

Commit

Permalink
Issue #280 ignore this update
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed May 5, 2018
1 parent 22b59f5 commit 67d21ae
Show file tree
Hide file tree
Showing 26 changed files with 129 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/src/contemporary/res/menu/menu_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
android:title="@string/action_whitelist"
android:visible="false"
android:checkable="true" />
<item
android:id="@+id/action_ignore_this"
android:title="@string/action_ignore_this"
android:visible="false"
android:checkable="true" />
<item
android:id="@+id/action_manual"
android:title="@string/action_manual"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public class StringExtractor {
stringNames.put("interval_1w", "pref_background_update_interval_weekly"); // Weekly
stringNames.put("theme_light", "pref_ui_theme_light"); // Light
stringNames.put("theme_dark", "pref_ui_theme_dark"); // Dark
stringNames.put("menu_ignore_this", "action_ignore_this"); // Ignore This Update
}

private Map<String, String> englishStrings = new HashMap<>();
Expand Down Expand Up @@ -170,6 +171,7 @@ private Map<String, String> getStrings(File from) {
Map<String, String> wantedStrings = new HashMap<>();
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(from);
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName("resources").item(0).getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node stringNode = nodeList.item(i);
Expand All @@ -194,6 +196,7 @@ private Map<String, String> getEnglishStrings() {
File from = new File("src\\main\\res\\values\\strings.xml");
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(from);
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName("resources").item(0).getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node stringNode = nodeList.item(i);
Expand All @@ -212,6 +215,7 @@ private void putStrings(Map<String, String> wantedStrings, File to) {
Set<String> existingStrings = new HashSet<>();
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(to);
doc.getDocumentElement().normalize();
Node resources = doc.getElementsByTagName("resources").item(0);
NodeList nodeList = resources.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
Expand Down Expand Up @@ -208,6 +209,9 @@ protected void onPostExecute(App app) {
super.onPostExecute(app);
if (app != null) {
DetailsActivity.app = app;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
activity.invalidateOptionsMenu();
}
activity.redrawDetails(app);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ public void onRequestPermissionsResult(int requestCode, String permissions[], in
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
App app = getAppByListPosition(info.position);
if (item.getItemId() == R.id.action_ignore) {
String packageName = getAppByListPosition(info.position).getPackageName();
String packageName = app.getPackageName();
new BlackWhiteListManager(this).add(packageName);
removeApp(packageName);
return true;
} else if (item.getItemId() == R.id.action_ignore_this) {
new VersionIgnoreManager(this).add(app.getPackageName(), app.getVersionCode());
removeApp(app.getPackageName());
return true;
}
return super.onContextItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Yalp Store
* Copyright (C) 2018 Sergey Yeriomin <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

package com.github.yeriomin.yalpstore;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import java.util.Set;

public class VersionIgnoreManager {

static private final String PREFERENCE_VERSION_BLACK_LIST = "PREFERENCE_VERSION_BLACK_LIST";

private SharedPreferences preferences;
private Set<String> ignoredVersions;

public VersionIgnoreManager(Context context) {
preferences = PreferenceManager.getDefaultSharedPreferences(context);
ignoredVersions = PreferenceUtil.getStringSet(context, PREFERENCE_VERSION_BLACK_LIST);
}

public void add(String packageName, int versionCode) {
ignoredVersions.add(getKey(packageName, versionCode));
save();
}

public void remove(String packageName, int versionCode) {
ignoredVersions.add(getKey(packageName, versionCode));
save();
}

public boolean isUpdatable(String packageName, int versionCode) {
return !ignoredVersions.contains(getKey(packageName, versionCode));
}

private void save() {
PreferenceUtil.putStringSet(preferences, PREFERENCE_VERSION_BLACK_LIST, ignoredVersions);
}

static private String getKey(String packageName, int versionCode) {
return packageName + "|" + Integer.toString(versionCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.github.yeriomin.yalpstore.LocalWishlist;
import com.github.yeriomin.yalpstore.ManualDownloadActivity;
import com.github.yeriomin.yalpstore.R;
import com.github.yeriomin.yalpstore.VersionIgnoreManager;
import com.github.yeriomin.yalpstore.YalpStoreActivity;
import com.github.yeriomin.yalpstore.model.App;
import com.github.yeriomin.yalpstore.task.CheckShellTask;
Expand Down Expand Up @@ -87,6 +88,10 @@ public void onCreateOptionsMenu(Menu menu) {
}
setChecked(menu, R.id.action_ignore, isContained);
setChecked(menu, R.id.action_whitelist, isContained);
if (app.getVersionCode() > app.getInstalledVersionCode()) {
show(menu, R.id.action_ignore_this, true);
setChecked(menu, R.id.action_ignore_this, !new VersionIgnoreManager(activity).isUpdatable(app.getPackageName(), app.getVersionCode()));
}
if (isConvertible(app)) {
show(menu, R.id.action_make_system, !app.isSystem());
show(menu, R.id.action_make_normal, app.isSystem());
Expand Down Expand Up @@ -145,6 +150,14 @@ public boolean onContextItemSelected(MenuItem item) {
task.setPackageName(app.getPackageName());
task.execute();
return true;
case R.id.action_ignore_this:
if (item.isChecked()) {
new VersionIgnoreManager(activity).remove(app.getPackageName(), app.getVersionCode());
} else {
new VersionIgnoreManager(activity).add(app.getPackageName(), app.getVersionCode());
}
item.setChecked(!item.isChecked());
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.github.yeriomin.yalpstore.PlayStoreApiAuthenticator;
import com.github.yeriomin.yalpstore.PreferenceUtil;
import com.github.yeriomin.yalpstore.R;
import com.github.yeriomin.yalpstore.VersionIgnoreManager;
import com.github.yeriomin.yalpstore.model.App;
import com.github.yeriomin.yalpstore.task.InstalledAppsTask;

Expand Down Expand Up @@ -78,6 +79,18 @@ protected void processIOException(IOException e) {
}
}

@Override
protected List<App> getRemoteAppList(GooglePlayAPI api, List<String> packageNames) throws IOException {
List<App> appList = super.getRemoteAppList(api, packageNames);
VersionIgnoreManager versionIgnoreManager = new VersionIgnoreManager(context);
for (App app: appList.toArray(new App[appList.size()])) {
if (!versionIgnoreManager.isUpdatable(app.getPackageName(), app.getVersionCode())) {
appList.remove(app);
}
}
return appList;
}

private App addInstalledAppInfo(App appFromMarket, App installedApp) {
if (null != installedApp) {
appFromMarket.setPackageInfo(installedApp.getPackageInfo());
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/menu_download.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
android:title="@string/action_whitelist"
android:visible="false"
android:checkable="true" />
<item
android:id="@+id/action_ignore_this"
android:title="@string/action_ignore_this"
android:visible="false"
android:checkable="true" />
<item
android:id="@+id/action_manual"
android:title="@string/action_manual" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,5 @@
<string name="action_wishlist_remove">إزالة من قائمة المفضلات</string>
<string name="action_wishlist_add">إضافة إلى قائمة المفضلات</string>
<string name="action_wishlist">قائمة المفضلات</string>
<string name="action_ignore_this">"تجاهل هذا التحديث"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ast/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,5 @@ El procesu nun ye perfeutu y ye específicu pa cada preséu, asina que quiciabes
<string name="pref_use_tor_summary">"Forciar el tráficu de descarga per Tor pa mayor intimidá. Rique Orbot"</string>
<string name="pref_use_tor">"Usar Tor"</string>
<string name="no_permissions">"Nun s\'usaron permisos."</string>
<string name="action_ignore_this">"Inorar esti anovamientu"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,5 @@ Pokračovat?"</string>
<string name="action_wishlist_remove">Odebrat ze seznamu přání</string>
<string name="action_wishlist_add">Přidat do seznamu přání</string>
<string name="action_wishlist">Seznam přání</string>
<string name="action_ignore_this">"Ignorovat tuto aktualizaci"</string>
</resources>
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 @@ -292,4 +292,5 @@ Fortfahren?"</string>
<string name="action_wishlist_add">Auf die Wunschliste</string>
<string name="action_wishlist">Wunschliste</string>
<string name="details_video">"Film"</string>
<string name="action_ignore_this">"Diese Aktua. ignorieren"</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 @@ -300,4 +300,5 @@
<string name="action_wishlist_remove">Κατάργηση από λίστα επιθυμιών</string>
<string name="action_wishlist_add">Προσθήκη στη λίστα επιθυμητών</string>
<string name="action_wishlist">Λίστα επιθυμιών</string>
<string name="action_ignore_this">"Αγνόησε αυτή την ενημέρωση"</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 @@ -294,4 +294,5 @@ El proceso de conversión es imperfecto y específico para cada marca, así que
<string name="action_wishlist_remove">Quitar de la lista de deseos</string>
<string name="action_wishlist_add">Añadir a lista de deseos</string>
<string name="action_wishlist">Lista de deseos</string>
<string name="action_ignore_this">"Ignorar esta actualización"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-eu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,5 @@ Jarraitu?"</string>
<string name="action_wishlist_remove">Kendu nahien zerrendatik</string>
<string name="action_wishlist_add">Gehitu nahien zerrendan</string>
<string name="action_wishlist">Nahien zerrenda</string>
<string name="action_ignore_this">"Ezikusi eguneraketa hau"</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 @@ -270,4 +270,5 @@
<string name="action_wishlist_remove">Supprimer de liste de souhaits</string>
<string name="action_wishlist_add">Ajouter à la liste de souhaits</string>
<string name="action_wishlist">Liste de souhaits</string>
<string name="action_ignore_this">"Ignorer cette mise à jour"</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 @@ -293,4 +293,5 @@ Il processo non è perfetto o specifico per produttore: potrebbe non funzionare.
<string name="action_wishlist_remove">Rimuovi dalla lista desideri</string>
<string name="action_wishlist_add">Aggiungi alla lista desideri</string>
<string name="action_wishlist">Lista desideri</string>
<string name="action_ignore_this">"Ignora questo aggiornamento"</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 @@ -292,4 +292,5 @@ Google Play ストアでは、任意のバージョンのアプリをダウン
<string name="action_wishlist_remove">ほしいものリストから削除</string>
<string name="action_wishlist_add">ほしいものリストに追加</string>
<string name="action_wishlist">ほしいものリスト</string>
<string name="action_ignore_this">"今回のアップデートを無視"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,5 @@ Play 스토어 웹사이트로 이동할까요?"</string>
<string name="action_wishlist_remove">위시리스트에서 삭제</string>
<string name="action_wishlist_add">위시리스트에 추가</string>
<string name="action_wishlist">위시리스트</string>
<string name="action_ignore_this">"이 업데이트 무시"</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 @@ -296,4 +296,5 @@ Nu doen?"</string>
<string name="action_wishlist_add">Toevoegen aan verlanglijstje</string>
<string name="action_wishlist">Verlanglijstje</string>
<string name="details_download">"Downloaden"</string>
<string name="action_ignore_this">"Negeer deze update"</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 @@ -290,4 +290,5 @@ Nie rób tego z ciekawości. Może to zepsuć urządzenie. Zrób kopię zapasow
<string name="action_wishlist_remove">Usuń z listy życzeń</string>
<string name="action_wishlist_add">Dodaj do listy życzeń</string>
<string name="action_wishlist">Lista życzeń</string>
<string name="action_ignore_this">"Ignoruj tę aktualizację"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,5 @@ Fazer?"</string>

<string name="pref_ui_theme_dark">"Escuro"</string>
<string name="pref_ui_theme_light">"Claro"</string>
<string name="action_ignore_this">"Ignorar esta atualização"</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 @@ -268,4 +268,5 @@
<string name="action_wishlist_remove">Удалить из списка желаний</string>
<string name="action_wishlist_add">Добавить в список желаний</string>
<string name="action_wishlist">Список желаний</string>
<string name="action_ignore_this">"Игнорировать данное обновление"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,5 @@ Vykonať?"</string>
<string name="action_wishlist_remove">Odstrániť zo zoznamu želaní</string>
<string name="action_wishlist_add">Pridať do zoznamu želaní</string>
<string name="action_wishlist">Zoznam želaní</string>
<string name="action_ignore_this">"Ignorovať aktualizáciu"</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,5 @@ Do it?"</string>
<string name="action_wishlist_remove">Вилучити зі списку бажань</string>
<string name="action_wishlist_add">Додати в список бажань</string>
<string name="action_wishlist">Список бажань</string>
<string name="action_ignore_this">"Ігнорувати це оновлення"</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 @@ -33,6 +33,7 @@
<string name="action_search">Search</string>
<string name="action_updates">Updates</string>
<string name="action_ignore">Ignore updates</string>
<string name="action_ignore_this">Ignore this update</string>
<string name="action_whitelist">Whitelist for updates</string>
<string name="action_categories">Categories</string>
<string name="action_manual">Manual download</string>
Expand Down

0 comments on commit 67d21ae

Please sign in to comment.