WIP patches for com.frostwire.android
This commit is contained in:
parent
c97284a327
commit
4ae72c0b33
|
@ -36,8 +36,9 @@ echo -e "\nandroid.library.reference.1=$$MobAdMob$$" >> project.properties
|
||||||
Build Version:1.0.7,85,b1a6dde89,encoding=utf-8,srclibs=MobAdMob@2d5736,target=android-13,prebuild=\
|
Build Version:1.0.7,85,b1a6dde89,encoding=utf-8,srclibs=MobAdMob@2d5736,target=android-13,prebuild=\
|
||||||
rm -f libs/GoogleAdMob* && echo "android.library.reference.1=$$MobAdMob$$" >> project.properties && \
|
rm -f libs/GoogleAdMob* && echo "android.library.reference.1=$$MobAdMob$$" >> project.properties && \
|
||||||
echo "source.dir=src;common/components" >> ant.properties
|
echo "source.dir=src;common/components" >> ant.properties
|
||||||
Build Version:1.1.0,94,a608ec69a422c,encoding=utf-8,srclibs=MobAdMob@2d5736,prebuild=\
|
Build Version:1.1.1,96,!WIP patch at 1.1.1-b96,encoding=utf-8,\
|
||||||
rm -f libs/GoogleAdMob* && echo "android.library.reference.1=$$MobAdMob$$" >> project.properties && \
|
patch=update.patch;offercasts.patch,prebuild=\
|
||||||
|
rm libs/offercast-mobile-sdk.jar && \
|
||||||
echo "source.dir=src;common/components" >> ant.properties
|
echo "source.dir=src;common/components" >> ant.properties
|
||||||
|
|
||||||
Auto Update Mode:None
|
Auto Update Mode:None
|
||||||
|
|
166
metadata/com.frostwire.android/offercasts.patch
Normal file
166
metadata/com.frostwire.android/offercasts.patch
Normal file
|
@ -0,0 +1,166 @@
|
||||||
|
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
|
||||||
|
index fab6564..07b7e63 100644
|
||||||
|
--- a/AndroidManifest.xml
|
||||||
|
+++ b/AndroidManifest.xml
|
||||||
|
@@ -39,14 +39,6 @@
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="com.android.vending.BILLING" />
|
||||||
|
|
||||||
|
- <!-- offercast permissions -->
|
||||||
|
- <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||||
|
- <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
|
||||||
|
- <uses-permission
|
||||||
|
- android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS" />
|
||||||
|
- <uses-permission
|
||||||
|
- android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
|
||||||
|
-
|
||||||
|
<application android:name="com.frostwire.android.gui.MainApplication"
|
||||||
|
android:allowBackup="true" android:icon="@drawable/app_icon"
|
||||||
|
android:label="@string/application_label" android:theme="@style/FrostWireTheme">
|
||||||
|
@@ -161,34 +153,6 @@
|
||||||
|
<activity android:name="com.google.ads.AdActivity"
|
||||||
|
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
|
||||||
|
|
||||||
|
- <!-- offercast -->
|
||||||
|
- <activity android:name="com.offercast.android.sdk.TermsAndConditionsActivity"
|
||||||
|
- android:label="@string/application_label" />
|
||||||
|
- <service android:name="com.offercast.android.sdk.OCService" />
|
||||||
|
- <receiver android:name="com.offercast.android.sdk.OCBroadcastReceiver"
|
||||||
|
- android:enabled="true" android:exported="false">
|
||||||
|
- <intent-filter android:priority="1001">
|
||||||
|
- <action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
- </intent-filter>
|
||||||
|
- </receiver>
|
||||||
|
-
|
||||||
|
- <!-- offercast metadata development -->
|
||||||
|
- <!--
|
||||||
|
- <meta-data android:name="application-id" android:value="8"/> <meta-data
|
||||||
|
- android:name="access-token" android:value="805d0103-c3ab-4421-9708-cdc6328247fb"/>
|
||||||
|
- <meta-data android:name="store-name" android:value="Google"/> <meta-data
|
||||||
|
- android:name="store-category" android:value="Media & Video"/>
|
||||||
|
- -->
|
||||||
|
-
|
||||||
|
- <!-- offercast metadata production -->
|
||||||
|
- <!-- -->
|
||||||
|
- <meta-data android:name="application-id" android:value="7" />
|
||||||
|
- <meta-data android:name="access-token"
|
||||||
|
- android:value="5e6c1ceb-2b03-4b2e-a57f-0876395149ad" />
|
||||||
|
- <meta-data android:name="store-name" android:value="Google" />
|
||||||
|
- <meta-data android:name="store-category" android:value="Media & Video" />
|
||||||
|
- <!-- -->
|
||||||
|
-
|
||||||
|
<!-- providers -->
|
||||||
|
|
||||||
|
<provider android:name="com.frostwire.android.core.providers.DocumentsProvider"
|
||||||
|
@@ -223,4 +187,4 @@
|
||||||
|
</receiver>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
-</manifest>
|
||||||
|
\ No newline at end of file
|
||||||
|
+</manifest>
|
||||||
|
diff --git a/src/core/com/frostwire/android/core/ConfigurationDefaults.java b/src/core/com/frostwire/android/core/ConfigurationDefaults.java
|
||||||
|
index a4e5bc0..f207a31 100644
|
||||||
|
--- a/src/core/com/frostwire/android/core/ConfigurationDefaults.java
|
||||||
|
+++ b/src/core/com/frostwire/android/core/ConfigurationDefaults.java
|
||||||
|
@@ -66,7 +66,6 @@ final class ConfigurationDefaults {
|
||||||
|
defaultValues.put(Constants.PREF_KEY_GUI_SUPPORT_FROSTWIRE, true);
|
||||||
|
defaultValues.put(Constants.PREF_KEY_GUI_SUPPORT_FROSTWIRE_THRESHOLD, true);
|
||||||
|
defaultValues.put(Constants.PREF_KEY_GUI_SHOW_TV_MENU_ITEM,true);
|
||||||
|
- defaultValues.put(Constants.PREF_KEY_GUI_INITIALIZE_OFFERCAST,true);
|
||||||
|
|
||||||
|
defaultValues.put(Constants.PREF_KEY_SEARCH_COUNT_DOWNLOAD_FOR_TORRENT_DEEP_SCAN, 20);
|
||||||
|
defaultValues.put(Constants.PREF_KEY_SEARCH_COUNT_ROUNDS_FOR_TORRENT_DEEP_SCAN, 10);
|
||||||
|
diff --git a/src/core/com/frostwire/android/core/Constants.java b/src/core/com/frostwire/android/core/Constants.java
|
||||||
|
index 8e21b68..26ba5a6 100644
|
||||||
|
--- a/src/core/com/frostwire/android/core/Constants.java
|
||||||
|
+++ b/src/core/com/frostwire/android/core/Constants.java
|
||||||
|
@@ -85,7 +85,6 @@ public final class Constants {
|
||||||
|
public static final String PREF_KEY_GUI_SUPPORT_FROSTWIRE = "frostwire.prefs.gui.support_frostwire";
|
||||||
|
public static final String PREF_KEY_GUI_SUPPORT_FROSTWIRE_THRESHOLD = "frostwire.prefs.gui.support_frostwire_threshold";
|
||||||
|
public static final String PREF_KEY_GUI_SHOW_TV_MENU_ITEM = "frostwire.prefs.gui.show_tv_menu_item";
|
||||||
|
- public static final String PREF_KEY_GUI_INITIALIZE_OFFERCAST = "frostwire.prefs.gui.initialize_offercast";
|
||||||
|
|
||||||
|
public static final String PREF_KEY_TORRENT_MAX_DOWNLOAD_SPEED = "frostwire.prefs.torrent.max_download_speed";
|
||||||
|
public static final String PREF_KEY_TORRENT_MAX_UPLOAD_SPEED = "frostwire.prefs.torrent.max_upload_speed";
|
||||||
|
@@ -151,4 +150,4 @@ public final class Constants {
|
||||||
|
public static final int DEVICE_MAJOR_TYPE_DESKTOP = CommonConstants.DEVICE_MAJOR_TYPE_DESKTOP;
|
||||||
|
public static final int DEVICE_MAJOR_TYPE_PHONE = CommonConstants.DEVICE_MAJOR_TYPE_PHONE;
|
||||||
|
public static final int DEVICE_MAJOR_TYPE_TABLET = CommonConstants.DEVICE_MAJOR_TYPE_TABLET;
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
+}
|
||||||
|
diff --git a/src/gui/com/frostwire/android/gui/activities/MainActivity.java b/src/gui/com/frostwire/android/gui/activities/MainActivity.java
|
||||||
|
index fb76e43..1e131dc 100644
|
||||||
|
--- a/src/gui/com/frostwire/android/gui/activities/MainActivity.java
|
||||||
|
+++ b/src/gui/com/frostwire/android/gui/activities/MainActivity.java
|
||||||
|
@@ -65,7 +65,6 @@ import com.frostwire.android.gui.views.Refreshable;
|
||||||
|
import com.frostwire.android.gui.views.ShareIndicationDialog;
|
||||||
|
import com.frostwire.android.gui.views.TOS;
|
||||||
|
import com.frostwire.android.gui.views.TOS.OnTOSAcceptListener;
|
||||||
|
-import com.offercast.android.sdk.OffercastSDK;
|
||||||
|
import com.slidingmenu.lib.SlidingMenu;
|
||||||
|
import com.slidingmenu.lib.SlidingMenu.CanvasTransformer;
|
||||||
|
import com.slidingmenu.lib.SlidingMenu.OnOpenListener;
|
||||||
|
@@ -82,7 +81,6 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
private static final String FRAGMENT_STACK_TAG = "fragment_stack";
|
||||||
|
private static final String CURRENT_FRAGMENT_KEY = "current_fragment";
|
||||||
|
private static final String DUR_TOKEN_KEY = "dur_token";
|
||||||
|
- private static final String OFFERCAST_STARTED_KEY = "offercast_started";
|
||||||
|
|
||||||
|
private static boolean firstTime = true;
|
||||||
|
|
||||||
|
@@ -97,7 +95,6 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
// not sure about this variable, quick solution for now
|
||||||
|
private String durToken;
|
||||||
|
|
||||||
|
- private boolean offercastStarted = false;
|
||||||
|
|
||||||
|
public MainActivity() {
|
||||||
|
super(R.layout.activity_main, false, 2);
|
||||||
|
@@ -123,7 +120,6 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
durToken = savedInstanceState.getString(DUR_TOKEN_KEY);
|
||||||
|
- offercastStarted = savedInstanceState.getBoolean(OFFERCAST_STARTED_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
addRefreshable((Refreshable) findView(R.id.activity_main_player_notifier));
|
||||||
|
@@ -178,10 +174,6 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
- if (!offercastStarted && ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_INITIALIZE_OFFERCAST)) {
|
||||||
|
- startOffercast();
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
if (ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_TOS_ACCEPTED)) {
|
||||||
|
if (ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_GUI_INITIAL_SETTINGS_COMPLETE)) {
|
||||||
|
mainResume();
|
||||||
|
@@ -197,18 +189,6 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- private void startOffercast() {
|
||||||
|
- try {
|
||||||
|
- OffercastSDK offercast = OffercastSDK.getInstance(getApplicationContext());
|
||||||
|
- offercast.authorize();
|
||||||
|
- offercastStarted = true;
|
||||||
|
- LOG.info("Offercast started.");
|
||||||
|
- } catch (Exception e) {
|
||||||
|
- offercastStarted = false;
|
||||||
|
- LOG.error("Offercast could not start.",e);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
@@ -224,7 +204,6 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
saveLastFragment(outState);
|
||||||
|
|
||||||
|
outState.putString(DUR_TOKEN_KEY, durToken);
|
||||||
|
- outState.putBoolean(OFFERCAST_STARTED_KEY, offercastStarted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
468
metadata/com.frostwire.android/update.patch
Normal file
468
metadata/com.frostwire.android/update.patch
Normal file
|
@ -0,0 +1,468 @@
|
||||||
|
diff --git a/src/gui/com/frostwire/android/gui/SoftwareUpdater.java b/src/gui/com/frostwire/android/gui/SoftwareUpdater.java
|
||||||
|
deleted file mode 100644
|
||||||
|
index 21f26d7..0000000
|
||||||
|
--- a/src/gui/com/frostwire/android/gui/SoftwareUpdater.java
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,364 +0,0 @@
|
||||||
|
-/*
|
||||||
|
- * Created by Angel Leon (@gubatron), Alden Torres (aldenml)
|
||||||
|
- * Copyright (c) 2011, 2012, FrostWire(TM). All rights reserved.
|
||||||
|
- *
|
||||||
|
- * 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
- */
|
||||||
|
-
|
||||||
|
-package com.frostwire.android.gui;
|
||||||
|
-
|
||||||
|
-import java.io.BufferedInputStream;
|
||||||
|
-import java.io.File;
|
||||||
|
-import java.io.FileInputStream;
|
||||||
|
-import java.io.InputStream;
|
||||||
|
-import java.math.BigInteger;
|
||||||
|
-import java.security.MessageDigest;
|
||||||
|
-import java.util.HashSet;
|
||||||
|
-import java.util.Map;
|
||||||
|
-import java.util.Set;
|
||||||
|
-
|
||||||
|
-import android.content.Context;
|
||||||
|
-import android.content.DialogInterface;
|
||||||
|
-import android.content.DialogInterface.OnClickListener;
|
||||||
|
-import android.content.Intent;
|
||||||
|
-import android.net.Uri;
|
||||||
|
-import android.os.AsyncTask;
|
||||||
|
-import android.util.Log;
|
||||||
|
-
|
||||||
|
-import com.frostwire.android.R;
|
||||||
|
-import com.frostwire.android.core.ConfigurationManager;
|
||||||
|
-import com.frostwire.android.core.Constants;
|
||||||
|
-import com.frostwire.android.core.HttpFetcher;
|
||||||
|
-import com.frostwire.android.gui.services.Engine;
|
||||||
|
-import com.frostwire.android.gui.util.SystemUtils;
|
||||||
|
-import com.frostwire.android.gui.util.UIUtils;
|
||||||
|
-import com.frostwire.android.util.ByteUtils;
|
||||||
|
-import com.frostwire.android.util.StringUtils;
|
||||||
|
-import com.frostwire.util.JsonUtils;
|
||||||
|
-
|
||||||
|
-/**
|
||||||
|
- *
|
||||||
|
- * @author gubatron
|
||||||
|
- * @author aldenml
|
||||||
|
- *
|
||||||
|
- */
|
||||||
|
-public final class SoftwareUpdater {
|
||||||
|
-
|
||||||
|
- public interface ConfigurationUpdateListener {
|
||||||
|
- void onConfigurationUpdate();
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private static final String TAG = "FW.SoftwareUpdater";
|
||||||
|
-
|
||||||
|
- private static final long UPDATE_MESSAGE_TIMEOUT = 30 * 60 * 1000; // 30 minutes
|
||||||
|
-
|
||||||
|
- private static final String UPDATE_ACTION_OTA = "ota";
|
||||||
|
- private static final String UPDATE_ACTION_MARKET = "market";
|
||||||
|
-
|
||||||
|
- private boolean oldVersion;
|
||||||
|
- private String latestVersion;
|
||||||
|
- private Update update;
|
||||||
|
-
|
||||||
|
- private long updateTimestamp;
|
||||||
|
- private AsyncTask<Void, Void, Boolean> updateTask;
|
||||||
|
-
|
||||||
|
- private final Set<ConfigurationUpdateListener> configurationUpdateListeners;
|
||||||
|
-
|
||||||
|
- private static SoftwareUpdater instance;
|
||||||
|
-
|
||||||
|
- public static SoftwareUpdater instance() {
|
||||||
|
- if (instance == null) {
|
||||||
|
- instance = new SoftwareUpdater();
|
||||||
|
- }
|
||||||
|
- return instance;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private SoftwareUpdater() {
|
||||||
|
- this.oldVersion = false;
|
||||||
|
- this.latestVersion = Constants.FROSTWIRE_VERSION_STRING;
|
||||||
|
- this.configurationUpdateListeners = new HashSet<ConfigurationUpdateListener>();
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public boolean isOldVersion() {
|
||||||
|
- return oldVersion;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public String getLatestVersion() {
|
||||||
|
- return latestVersion;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public void checkForUpdate(final Context context) {
|
||||||
|
- long now = System.currentTimeMillis();
|
||||||
|
-
|
||||||
|
- if (now - updateTimestamp < UPDATE_MESSAGE_TIMEOUT) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- updateTimestamp = now;
|
||||||
|
- updateTask = new AsyncTask<Void, Void, Boolean>() {
|
||||||
|
- @Override
|
||||||
|
- protected Boolean doInBackground(Void... params) {
|
||||||
|
- try {
|
||||||
|
- byte[] jsonBytes = new HttpFetcher(Constants.SERVER_UPDATE_URL).fetch();
|
||||||
|
- update = JsonUtils.toObject(new String(jsonBytes), Update.class);
|
||||||
|
-
|
||||||
|
- latestVersion = update.v;
|
||||||
|
- String[] latestVersionArr = latestVersion.split("\\.");
|
||||||
|
-
|
||||||
|
- // lv = latest version
|
||||||
|
- byte[] lv = new byte[] { Byte.valueOf(latestVersionArr[0]), Byte.valueOf(latestVersionArr[1]), Byte.valueOf(latestVersionArr[2]) };
|
||||||
|
-
|
||||||
|
- // mv = my version
|
||||||
|
- byte[] mv = Constants.FROSTWIRE_VERSION;
|
||||||
|
-
|
||||||
|
- oldVersion = isFrostWireOld(mv, lv);
|
||||||
|
-
|
||||||
|
- updateConfiguration(update);
|
||||||
|
-
|
||||||
|
- if (oldVersion) {
|
||||||
|
- if (update.a == null) {
|
||||||
|
- update.a = UPDATE_ACTION_OTA; // make it the old behavior
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (update.a.equals(UPDATE_ACTION_OTA)) {
|
||||||
|
- // did we download the newest already?
|
||||||
|
- if (downloadedLatestFrostWire(update.md5)) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
- // didn't download it? go get it now
|
||||||
|
- else {
|
||||||
|
- new HttpFetcher(update.u).save(SystemUtils.getUpdateInstallerPath());
|
||||||
|
-
|
||||||
|
- if (downloadedLatestFrostWire(update.md5)) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- } else if (update.a.equals(UPDATE_ACTION_MARKET)) {
|
||||||
|
- return update.m != null;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- } catch (Throwable e) {
|
||||||
|
- Log.e(TAG, "Failed to check/retrieve/update the update information", e);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- @Override
|
||||||
|
- protected void onPostExecute(Boolean result) {
|
||||||
|
- if (result && !isCancelled()) {
|
||||||
|
- notifyUpdate(context);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- //nav menu always needs to be updated after we read the config.
|
||||||
|
- notifyConfigurationUpdateListeners();
|
||||||
|
- }
|
||||||
|
- };
|
||||||
|
-
|
||||||
|
- updateTask.execute();
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public void addConfigurationUpdateListener(ConfigurationUpdateListener listener) {
|
||||||
|
- try {
|
||||||
|
- configurationUpdateListeners.add(listener);
|
||||||
|
- } catch (Throwable t) {
|
||||||
|
-
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private void notifyUpdate(final Context context) {
|
||||||
|
- try {
|
||||||
|
- if (update.a == null) {
|
||||||
|
- update.a = UPDATE_ACTION_OTA; // make it the old behavior
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (update.a.equals(UPDATE_ACTION_OTA)) {
|
||||||
|
- if (!SystemUtils.getUpdateInstallerPath().exists()) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- String message = StringUtils.getLocaleString(update.updateMessages, context.getString(R.string.update_message));
|
||||||
|
-
|
||||||
|
- UIUtils.showYesNoDialog(context, R.drawable.app_icon, message, R.string.update_title, new OnClickListener() {
|
||||||
|
- public void onClick(DialogInterface dialog, int which) {
|
||||||
|
- Engine.instance().stopServices(false);
|
||||||
|
- UIUtils.openFile(context, SystemUtils.getUpdateInstallerPath().getAbsolutePath(), Constants.MIME_TYPE_ANDROID_PACKAGE_ARCHIVE);
|
||||||
|
- }
|
||||||
|
- });
|
||||||
|
- } else if (update.a.equals(UPDATE_ACTION_MARKET)) {
|
||||||
|
-
|
||||||
|
- String message = StringUtils.getLocaleString(update.marketMessages, context.getString(R.string.update_message));
|
||||||
|
-
|
||||||
|
- UIUtils.showYesNoDialog(context, R.drawable.app_icon, message, R.string.update_title, new OnClickListener() {
|
||||||
|
- public void onClick(DialogInterface dialog, int which) {
|
||||||
|
- Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
- intent.setData(Uri.parse(update.m));
|
||||||
|
- context.startActivity(intent);
|
||||||
|
- }
|
||||||
|
- });
|
||||||
|
- }
|
||||||
|
- } catch (Throwable e) {
|
||||||
|
- Log.e(TAG, "Failed to notify update", e);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /**
|
||||||
|
- *
|
||||||
|
- * @param md5
|
||||||
|
- * - Expected MD5 hash as a string.
|
||||||
|
- * @return
|
||||||
|
- */
|
||||||
|
- private boolean downloadedLatestFrostWire(String md5) {
|
||||||
|
- if (!SystemUtils.getUpdateInstallerPath().exists()) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
- return checkMD5(SystemUtils.getUpdateInstallerPath(), md5);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /**
|
||||||
|
- * mv = my version
|
||||||
|
- * lv = latest version
|
||||||
|
- *
|
||||||
|
- * returns true if mv is older.
|
||||||
|
- */
|
||||||
|
- private boolean isFrostWireOld(byte[] mv, byte[] lv) {
|
||||||
|
- if (mv[0] < lv[0]) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (mv[0] == lv[0] && mv[1] < lv[1]) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (mv[0] == lv[0] && mv[1] == lv[1] && mv[2] < lv[2]) {
|
||||||
|
- return true;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private static String getMD5(File f) {
|
||||||
|
- try {
|
||||||
|
- MessageDigest m = MessageDigest.getInstance("MD5");
|
||||||
|
-
|
||||||
|
- // We read the file in buffers so we don't
|
||||||
|
- // eat all the memory in case we have a huge plugin.
|
||||||
|
- byte[] buf = new byte[65536];
|
||||||
|
- int num_read;
|
||||||
|
-
|
||||||
|
- InputStream in = new BufferedInputStream(new FileInputStream(f));
|
||||||
|
-
|
||||||
|
- while ((num_read = in.read(buf)) != -1) {
|
||||||
|
- m.update(buf, 0, num_read);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- in.close();
|
||||||
|
-
|
||||||
|
- String result = new BigInteger(1, m.digest()).toString(16);
|
||||||
|
-
|
||||||
|
- // pad with zeros if until it's 32 chars long.
|
||||||
|
- if (result.length() < 32) {
|
||||||
|
- int paddingSize = 32 - result.length();
|
||||||
|
- for (int i = 0; i < paddingSize; i++) {
|
||||||
|
- result = "0" + result;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return result;
|
||||||
|
- } catch (Exception e) {
|
||||||
|
- return null;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private static boolean checkMD5(File f, String expectedMD5) {
|
||||||
|
- if (expectedMD5 == null) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (expectedMD5.length() != 32) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- String checkedMD5 = getMD5(f);
|
||||||
|
- if (checkedMD5 == null) {
|
||||||
|
- return false;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- return checkedMD5.trim().equalsIgnoreCase(expectedMD5.trim());
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private void updateConfiguration(Update update) {
|
||||||
|
- if (update.config == null) {
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ConfigurationManager.instance().setBoolean(Constants.PREF_KEY_GUI_SUPPORT_FROSTWIRE_THRESHOLD, ByteUtils.randomInt(0, 100) < update.config.supportThreshold);
|
||||||
|
-
|
||||||
|
- for (String name : update.config.activeSearchEngines.keySet()) {
|
||||||
|
- SearchEngine engine = SearchEngine.forName(name);
|
||||||
|
- if (engine != null) {
|
||||||
|
- engine.setActive(update.config.activeSearchEngines.get(name));
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ConfigurationManager.instance().setBoolean(Constants.PREF_KEY_GUI_SHOW_TV_MENU_ITEM,update.config.tv);
|
||||||
|
- ConfigurationManager.instance().setBoolean(Constants.PREF_KEY_GUI_INITIALIZE_OFFERCAST, update.config.offercast);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private void notifyConfigurationUpdateListeners() {
|
||||||
|
- for (ConfigurationUpdateListener listener : configurationUpdateListeners) {
|
||||||
|
- try {
|
||||||
|
- listener.onConfigurationUpdate();
|
||||||
|
- } catch (Throwable t) {
|
||||||
|
-
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private static class Update {
|
||||||
|
- public String v;
|
||||||
|
- public String u;
|
||||||
|
- public String md5;
|
||||||
|
-
|
||||||
|
- /**
|
||||||
|
- * Address from the market
|
||||||
|
- */
|
||||||
|
- public String m;
|
||||||
|
-
|
||||||
|
- /**
|
||||||
|
- * Action for the update message
|
||||||
|
- * - "ota" is download from 'u' (a regular http)
|
||||||
|
- * - "market" go to market page
|
||||||
|
- */
|
||||||
|
- public String a;
|
||||||
|
-
|
||||||
|
- public Map<String, String> updateMessages;
|
||||||
|
- public Map<String, String> marketMessages;
|
||||||
|
- public Config config;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- private static class Config {
|
||||||
|
- public int supportThreshold = 100;
|
||||||
|
- public Map<String, Boolean> activeSearchEngines;
|
||||||
|
- public boolean tv = true;
|
||||||
|
- public boolean offercast = true;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- public void removeConfigurationUpdateListener(Object slideMenuFragment) {
|
||||||
|
- if (configurationUpdateListeners.size() > 0) {
|
||||||
|
- configurationUpdateListeners.remove(slideMenuFragment);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/gui/com/frostwire/android/gui/activities/MainActivity.java b/src/gui/com/frostwire/android/gui/activities/MainActivity.java
|
||||||
|
index 433a447..fb76e43 100644
|
||||||
|
--- a/src/gui/com/frostwire/android/gui/activities/MainActivity.java
|
||||||
|
+++ b/src/gui/com/frostwire/android/gui/activities/MainActivity.java
|
||||||
|
@@ -47,7 +47,6 @@ import com.frostwire.android.core.DesktopUploadRequestStatus;
|
||||||
|
import com.frostwire.android.core.FileDescriptor;
|
||||||
|
import com.frostwire.android.gui.Librarian;
|
||||||
|
import com.frostwire.android.gui.PeerManager;
|
||||||
|
-import com.frostwire.android.gui.SoftwareUpdater;
|
||||||
|
import com.frostwire.android.gui.fragments.AboutFragment;
|
||||||
|
import com.frostwire.android.gui.fragments.BrowsePeerFragment;
|
||||||
|
import com.frostwire.android.gui.fragments.BrowsePeersFragment;
|
||||||
|
@@ -539,6 +538,5 @@ public class MainActivity extends AbstractSlidingActivity {
|
||||||
|
Engine.instance().startServices(); // it's necessary for the first time after wizard
|
||||||
|
}
|
||||||
|
|
||||||
|
- SoftwareUpdater.instance().checkForUpdate(this);
|
||||||
|
}
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
+}
|
||||||
|
diff --git a/src/gui/com/frostwire/android/gui/adapters/PeerListAdapter.java b/src/gui/com/frostwire/android/gui/adapters/PeerListAdapter.java
|
||||||
|
index acf1d6b..a5fc333 100644
|
||||||
|
--- a/src/gui/com/frostwire/android/gui/adapters/PeerListAdapter.java
|
||||||
|
+++ b/src/gui/com/frostwire/android/gui/adapters/PeerListAdapter.java
|
||||||
|
@@ -33,7 +33,6 @@ import android.widget.TextView;
|
||||||
|
import com.frostwire.android.R;
|
||||||
|
import com.frostwire.android.core.Constants;
|
||||||
|
import com.frostwire.android.gui.Peer;
|
||||||
|
-import com.frostwire.android.gui.SoftwareUpdater;
|
||||||
|
import com.frostwire.android.gui.activities.BrowsePeerActivity;
|
||||||
|
import com.frostwire.android.gui.activities.MainActivity;
|
||||||
|
import com.frostwire.android.gui.adapters.menu.BrowsePeerMenuAction;
|
||||||
|
@@ -85,12 +84,6 @@ public class PeerListAdapter extends AbstractListAdapter<Peer> {
|
||||||
|
} else {
|
||||||
|
title.setTextColor(0xff54afe4);
|
||||||
|
|
||||||
|
- // show my version in red If I'm old to encourage user to update.
|
||||||
|
- if (SoftwareUpdater.instance().isOldVersion()) {
|
||||||
|
- version.setTextColor(Color.RED);
|
||||||
|
- version.setText(getContext().getString(R.string.please_update_to_v, SoftwareUpdater.instance().getLatestVersion()));
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
howtoShareButton.setVisibility(View.VISIBLE);
|
||||||
|
howtoShareButton.setImageResource(R.drawable.share_howto);
|
||||||
|
}
|
||||||
|
@@ -166,4 +159,4 @@ public class PeerListAdapter extends AbstractListAdapter<Peer> {
|
||||||
|
|
||||||
|
return new MenuAdapter(context, peer.getNickname(), items);
|
||||||
|
}
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
+}
|
||||||
|
diff --git a/src/gui/com/frostwire/android/gui/fragments/SlideMenuFragment.java b/src/gui/com/frostwire/android/gui/fragments/SlideMenuFragment.java
|
||||||
|
index 345d2d9..1681c07 100644
|
||||||
|
--- a/src/gui/com/frostwire/android/gui/fragments/SlideMenuFragment.java
|
||||||
|
+++ b/src/gui/com/frostwire/android/gui/fragments/SlideMenuFragment.java
|
||||||
|
@@ -45,8 +45,6 @@ import android.widget.TextView;
|
||||||
|
import com.frostwire.android.R;
|
||||||
|
import com.frostwire.android.core.ConfigurationManager;
|
||||||
|
import com.frostwire.android.core.Constants;
|
||||||
|
-import com.frostwire.android.gui.SoftwareUpdater;
|
||||||
|
-import com.frostwire.android.gui.SoftwareUpdater.ConfigurationUpdateListener;
|
||||||
|
import com.frostwire.android.gui.activities.MainActivity;
|
||||||
|
import com.frostwire.android.gui.activities.MediaPlayerActivity;
|
||||||
|
import com.frostwire.android.gui.activities.PreferencesActivity;
|
||||||
|
@@ -58,7 +56,7 @@ import com.frostwire.android.gui.views.PlayerMenuItemView;
|
||||||
|
* @author aldenml
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
-public class SlideMenuFragment extends ListFragment implements ConfigurationUpdateListener {
|
||||||
|
+public class SlideMenuFragment extends ListFragment {
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(SlideMenuFragment.class);
|
||||||
|
|
||||||
|
@@ -82,7 +80,6 @@ public class SlideMenuFragment extends ListFragment implements ConfigurationUpda
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
- SoftwareUpdater.instance().addConfigurationUpdateListener(this);
|
||||||
|
initMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -296,11 +293,4 @@ public class SlideMenuFragment extends ListFragment implements ConfigurationUpda
|
||||||
|
initMenuItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
- @Override
|
||||||
|
- public void onDestroy() {
|
||||||
|
- super.onDestroy();
|
||||||
|
-
|
||||||
|
- //avoid memory leaks when the device is tilted and the menu gets recreated.
|
||||||
|
- SoftwareUpdater.instance().removeConfigurationUpdateListener(this);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
+}
|
Loading…
Reference in a new issue