Merge branch 'master' of https://github.com/jonatkins/ingress-intel-total-conversion
This commit is contained in:
commit
b73db4585f
@ -135,6 +135,8 @@
|
|||||||
<string name="pref_update_plugins_interval_sum">How often IITCm should search for new plugin versions</string>
|
<string name="pref_update_plugins_interval_sum">How often IITCm should search for new plugin versions</string>
|
||||||
<string name="pref_force_plugin_update">Force plugin update</string>
|
<string name="pref_force_plugin_update">Force plugin update</string>
|
||||||
<string name="pref_force_plugin_update_sum">Update all enabled user plugins</string>
|
<string name="pref_force_plugin_update_sum">Update all enabled user plugins</string>
|
||||||
|
<string name="pref_secure_updates">Require secure updates</string>
|
||||||
|
<string name="pref_secure_updates_sum">If enabled, only https updates are handled</string>
|
||||||
|
|
||||||
<string-array name="pref_hide_fullscreen">
|
<string-array name="pref_hide_fullscreen">
|
||||||
<item>System Bar</item>
|
<item>System Bar</item>
|
||||||
|
@ -106,6 +106,11 @@
|
|||||||
android:key="pref_force_plugin_update"
|
android:key="pref_force_plugin_update"
|
||||||
android:title="@string/pref_force_plugin_update"
|
android:title="@string/pref_force_plugin_update"
|
||||||
android:summary="@string/pref_force_plugin_update_sum"/>
|
android:summary="@string/pref_force_plugin_update_sum"/>
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="pref_secure_updates"
|
||||||
|
android:summary="@string/pref_secure_updates_sum"
|
||||||
|
android:title="@string/pref_secure_updates"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_advanced_tweaks_cat"
|
android:key="pref_advanced_tweaks_cat"
|
||||||
|
@ -205,6 +205,7 @@ public class IITC_Mobile extends Activity
|
|||||||
} else if (key.equals("pref_press_twice_to_exit")
|
} else if (key.equals("pref_press_twice_to_exit")
|
||||||
|| key.equals("pref_share_selected_tab")
|
|| key.equals("pref_share_selected_tab")
|
||||||
|| key.equals("pref_messages")
|
|| key.equals("pref_messages")
|
||||||
|
|| key.equals("pref_secure_updates")
|
||||||
|| key.equals("pref_external_storage")) {
|
|| key.equals("pref_external_storage")) {
|
||||||
// no reload needed
|
// no reload needed
|
||||||
return;
|
return;
|
||||||
|
@ -17,12 +17,14 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class UpdateScript extends AsyncTask<String, Void, Boolean> {
|
public class UpdateScript extends AsyncTask<String, Void, Boolean> {
|
||||||
|
|
||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
private String mFilePath;
|
private String mFilePath;
|
||||||
private String mScript;
|
private String mScript;
|
||||||
|
private HashMap<String, String> mScriptInfo;
|
||||||
|
|
||||||
public UpdateScript(final Activity activity) {
|
public UpdateScript(final Activity activity) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
@ -34,20 +36,28 @@ public class UpdateScript extends AsyncTask<String, Void, Boolean> {
|
|||||||
mFilePath = urls[0];
|
mFilePath = urls[0];
|
||||||
// get local script meta information
|
// get local script meta information
|
||||||
mScript = IITC_FileManager.readStream(new FileInputStream(new File(mFilePath)));
|
mScript = IITC_FileManager.readStream(new FileInputStream(new File(mFilePath)));
|
||||||
final String updateURL = IITC_FileManager.getScriptInfo(mScript).get("updateURL");
|
mScriptInfo = IITC_FileManager.getScriptInfo(mScript);
|
||||||
final String downloadURL = IITC_FileManager.getScriptInfo(mScript).get("downloadURL");
|
String updateURL = mScriptInfo.get("updateURL");
|
||||||
|
final String downloadURL = mScriptInfo.get("downloadURL");
|
||||||
|
if (updateURL == null) updateURL = downloadURL;
|
||||||
|
|
||||||
|
// check for https protocol
|
||||||
|
final URL url = new URL(updateURL);
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
|
||||||
|
Boolean secureUpdates = prefs.getBoolean("pref_secure_updates", true);
|
||||||
|
if (!url.getProtocol().equals("https") && secureUpdates) return false;
|
||||||
|
|
||||||
// get remote script meta information
|
// get remote script meta information
|
||||||
final File file_old = new File(mFilePath);
|
final InputStream is = url.openStream();
|
||||||
final InputStream is = new URL(updateURL).openStream();
|
final String remote_version = IITC_FileManager.getScriptInfo(IITC_FileManager.readStream(is)).get("version");
|
||||||
final String old_version = IITC_FileManager.getScriptInfo(mScript).get("version");
|
final File local_file = new File(mFilePath);
|
||||||
final String new_version = IITC_FileManager.getScriptInfo(IITC_FileManager.readStream(is)).get("version");
|
final String local_version = mScriptInfo.get("version");
|
||||||
|
|
||||||
// update script if neccessary
|
// update script if neccessary
|
||||||
if (old_version.compareTo(new_version) < 0) {
|
if (local_version.compareTo(remote_version) < 0) {
|
||||||
Log.d("plugin " + mFilePath + " outdated\n" + old_version + " vs " + new_version);
|
Log.d("plugin " + mFilePath + " outdated\n" + local_version + " vs " + remote_version);
|
||||||
Log.d("updating file....");
|
Log.d("updating file....");
|
||||||
IITC_FileManager.copyStream(new URL(downloadURL).openStream(), new FileOutputStream(file_old), true);
|
IITC_FileManager.copyStream(new URL(downloadURL).openStream(), new FileOutputStream(local_file), true);
|
||||||
Log.d("...done");
|
Log.d("...done");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,6 @@ import android.util.AttributeSet;
|
|||||||
|
|
||||||
import com.cradle.iitc_mobile.R;
|
import com.cradle.iitc_mobile.R;
|
||||||
|
|
||||||
/**
|
|
||||||
* The OptionDialogPreference will display a dialog, and will persist the
|
|
||||||
* <code>true</code> when pressing the positive button and <code>false</code>
|
|
||||||
* otherwise. It will persist to the android:key specified in xml-preference.
|
|
||||||
*/
|
|
||||||
public class ForceUpdatePreference extends Preference {
|
public class ForceUpdatePreference extends Preference {
|
||||||
|
|
||||||
public ForceUpdatePreference(Context context, AttributeSet attrs) {
|
public ForceUpdatePreference(Context context, AttributeSet attrs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user