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.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.AssetManager;
|
||||
@ -25,22 +25,35 @@ public class IITC_Settings extends Activity {
|
||||
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>();
|
||||
|
||||
for (int i = 0; i < asset_list.size();) {
|
||||
try {
|
||||
if (asset_list.get(i).endsWith("user.js")) {
|
||||
asset_values.add(am.open("plugins/" + asset_list.get(i)).toString());
|
||||
i++;
|
||||
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 {
|
||||
s = new Scanner(am.open("plugins/" + asset_array[i])).useDelimiter("\\A");
|
||||
} catch (IOException e2) {
|
||||
// TODO Auto-generated catch block
|
||||
e2.printStackTrace();
|
||||
}
|
||||
else {
|
||||
asset_list.remove(i);
|
||||
asset_values.add(am.open("plugins/" + asset_list.get(i)).toString());
|
||||
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];
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
asset_list.add(plugin_name);
|
||||
// real value
|
||||
asset_values.add(asset_array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class IITC_SettingsFragment extends PreferenceFragment {
|
||||
//plugins
|
||||
MultiSelectListPreference pref_plugins = (MultiSelectListPreference) findPreference("pref_plugins");
|
||||
pref_plugins.setEntries(getArguments().getStringArray("ASSETS"));
|
||||
pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS"));
|
||||
pref_plugins.setEntryValues(getArguments().getStringArray("ASSETS_VAL"));
|
||||
|
||||
// set 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 iitc_version = "not found";
|
||||
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];
|
||||
}
|
||||
return iitc_version;
|
||||
|
Loading…
x
Reference in New Issue
Block a user