show plugin name instead of file name
This commit is contained in:
parent
99a18444bf
commit
0f04acbc36
@ -2,7 +2,7 @@ package com.cradle.iitc_mobile;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
@ -25,22 +25,35 @@ public class IITC_Settings extends Activity {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> asset_list = new ArrayList<String>(Arrays.asList(asset_array));
|
ArrayList<String> asset_list = new ArrayList<String>();
|
||||||
ArrayList<String> asset_values = new ArrayList<String>();
|
ArrayList<String> asset_values = new ArrayList<String>();
|
||||||
|
|
||||||
for (int i = 0; i < asset_list.size();) {
|
for (int i = 0; i < asset_array.length ; i++) {
|
||||||
|
if (asset_array[i].endsWith("user.js")) {
|
||||||
|
// find user plugin name for user readable entries
|
||||||
|
Scanner s = null;
|
||||||
|
String src = "";
|
||||||
try {
|
try {
|
||||||
if (asset_list.get(i).endsWith("user.js")) {
|
s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A");
|
||||||
asset_values.add(am.open("plugins/" + asset_list.get(i)).toString());
|
} catch (IOException e2) {
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
asset_list.remove(i);
|
|
||||||
asset_values.add(am.open("plugins/" + asset_list.get(i)).toString());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e2.printStackTrace();
|
||||||
|
}
|
||||||
|
if (s != null) src = s.hasNext() ? s.next() : "";
|
||||||
|
String header = src.substring(src.indexOf("==UserScript=="), src.indexOf("==/UserScript=="));
|
||||||
|
// remove new line comments and replace with space
|
||||||
|
// this way we get double spaces instead of newline + double slash
|
||||||
|
header = header.replace("\n//", " ");
|
||||||
|
// get a list of key-value...split on multiple spaces
|
||||||
|
String[] attributes = header.split(" +");
|
||||||
|
String plugin_name = "not found";
|
||||||
|
for (int j = 0; j < attributes.length; j++) {
|
||||||
|
// search for name and use the value
|
||||||
|
if (attributes[j].equals("@name")) plugin_name = attributes[j+1];
|
||||||
|
}
|
||||||
|
asset_list.add(plugin_name);
|
||||||
|
// real value
|
||||||
|
asset_values.add(asset_array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
|||||||
//plugins
|
//plugins
|
||||||
MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins");
|
MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins");
|
||||||
pref_plugins.setEntries(getArguments().getStringArray("ASSETS"));
|
pref_plugins.setEntries(getArguments().getStringArray("ASSETS"));
|
||||||
pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS"));
|
pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS_VAL"));
|
||||||
|
|
||||||
// set build version
|
// set build version
|
||||||
ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version");
|
ListPreference pref_build_version = (ListPreference) findPreference("pref_build_version");
|
||||||
|
@ -46,7 +46,7 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
String[] attributes = header.split(" +");
|
String[] attributes = header.split(" +");
|
||||||
String iitc_version = "not found";
|
String iitc_version = "not found";
|
||||||
for (int i = 0; i < attributes.length; i++) {
|
for (int i = 0; i < attributes.length; i++) {
|
||||||
// search vor version and use the value
|
// search for version and use the value
|
||||||
if (attributes[i].equals("@version")) iitc_version = attributes[i+1];
|
if (attributes[i].equals("@version")) iitc_version = attributes[i+1];
|
||||||
}
|
}
|
||||||
return iitc_version;
|
return iitc_version;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user