Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
r3.1 & UI Changes and optimizations (pre r3.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinovon committed Dec 26, 2021
1 parent 3730699 commit 00f9b38
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 105 deletions.
2 changes: 1 addition & 1 deletion Application Descriptor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIDlet-Version: 1.4.0
MIDlet-Version: 1.4.2
MicroEdition-Configuration: CLDC-1.0
Nokia-MIDlet-UID-1: 0xAFCE0816
MIDlet-Name: JTube
Expand Down
Binary file added res/jtlng.cn
Binary file not shown.
96 changes: 73 additions & 23 deletions src/App.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.Vector;

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;

import ui.AppUI;
import ui.TestCanvas;
Expand All @@ -21,11 +18,10 @@
import cc.nnproject.json.JSONObject;
import cc.nnproject.json.AbstractJSON;
import cc.nnproject.json.JSONException;
import cc.nnproject.utils.PlatformUtils;

public class App implements Constants {

public static final String ver = "r3";
public static final String ver = "r3 patch2";

// Settings
public static String videoRes;
Expand All @@ -44,12 +40,13 @@ public class App implements Constants {
public static boolean rmsPreviews;
public static boolean searchPlaylists;
public static String customLocale;
public static boolean debugMemory;

public static App inst;
public static App2 midlet;
private AppUI ui;

private static PlayerCanvas playerCanv;
//private static PlayerCanvas playerCanv;

public static boolean asyncLoading;

Expand All @@ -72,12 +69,22 @@ public void run() {
tasksLock.wait();
}
while(queuedTasks.size() > 0) {
Object o = queuedTasks.elementAt(0);
queuedTasks.removeElementAt(0);
try {
((Runnable)queuedTasks.elementAt(0)).run();
if(o instanceof Runnable) ((Runnable)o).run();
else if(o instanceof Object[]) {
Object[] oo = (Object[]) o;
IScheduledShowHide i = (IScheduledShowHide) oo[0];
boolean b = ((Boolean) oo[1]).booleanValue();
if(b) {
i.show();
} else {
i.hide();
}
}
} catch (Exception e) {
e.printStackTrace();
}
queuedTasks.removeElementAt(0);
Thread.yield();
}
} catch (InterruptedException e) {
Expand All @@ -87,9 +94,11 @@ public void run() {
}
};

public void scheduleRunnable(Runnable r) {
if(queuedTasks.contains(r)) return;
queuedTasks.addElement(r);
private int startSys;

public void schedule(Object o) {
if(queuedTasks.contains(o)) return;
queuedTasks.addElement(o);
synchronized(tasksLock) {
tasksLock.notify();
}
Expand All @@ -99,6 +108,10 @@ public void scheduleRunnable(Runnable r) {
public static int height;

public void startApp() {
String p = System.getProperty("com.nokia.memoryramfree");
if(p != null) {
startSys = Integer.parseInt(p)/1024;
}
region = System.getProperty("user.country");
if(region == null) {
region = System.getProperty("microedition.locale");
Expand Down Expand Up @@ -137,6 +150,41 @@ public void startApp() {
t0.start();
}
ui.loadForm();
if(debugMemory) {
Thread t = new Thread() {
public void run() {
try {
while(true) {
Displayable d = AppUI.display.getCurrent();
if(d != null && d instanceof Form) {
Runtime r = Runtime.getRuntime();
int t = (int) (r.totalMemory() / 1024);
int f = (int) (r.freeMemory() / 1024);
int m = t - f;
String p = System.getProperty("com.nokia.memoryramfree");
String sys = "";
if(p != null) {
int sy = Integer.parseInt(p)/1024;
String sysfree = "" + (int)((sy/1024D)*10)/10D;
String syst = "" + (startSys/1024);
String sysalloc = "" + (startSys - sy)/1024;
sys = sysalloc + "/" + syst+ "-" + sysfree;
}
//long gt = System.currentTimeMillis();
App.gc();
//gt = System.currentTimeMillis() - gt;
String s = ((int)((m/1024D)*10)/10D) + "/" + ((int)((t/1024D)*10)/10D) + "-" + ((int)((f/1024D)*10)/10D) + " s:" + sys/* + " gc:" + gt*/;
((Form)d).setTitle(s);
}
Thread.sleep(1000);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();
}
}

private void initUI() {
Expand Down Expand Up @@ -304,16 +352,17 @@ public static void download(final String id) {
}

public static void watch(final String id) {
ILoader r = new ILoader() {
System.out.println("watch");
/*ILoader r = new ILoader() {
public void load() {
// TODO other variants
// TODO other variants*/
try {
String url = getVideoLink(id, videoRes);
switch(watchMethod) {
case 0: {
//switch(watchMethod) {
//case 0: {
platReq(url);
break;
}
//break;
/*}
case 1: {
Player p = Manager.createPlayer(url);
playerCanv = new PlayerCanvas(p);
Expand Down Expand Up @@ -352,16 +401,17 @@ public void load() {
platReq(file);
break;
}
}
}*/
} catch (Exception e) {
e.printStackTrace();
error(null, Errors.App_watch, e);
}
}
/*}
};
inst.stopDoingAsyncTasks();
inst.addAsyncLoad(r);
inst.notifyAsyncTasks();
*/
inst.stopDoingAsyncTasks();
}

public static void gc() {
Expand Down
7 changes: 7 additions & 0 deletions src/IScheduledShowHide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

public interface IScheduledShowHide {

public void show();
public void hide();

}
16 changes: 11 additions & 5 deletions src/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public static void init() {
try {
int i;
while( (i = d.readShort()) != -1) {
table.put(new Integer(i), d.readUTF());
Integer n = new Integer(i);
String sl = d.readUTF();
if(table.containsKey(n)) continue;
table.put(n, sl);
}
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -81,11 +84,12 @@ public static void init() {
}

public static String s(int c) {
if(loaded) {
return (String) table.get(new Integer(c));
Integer i = new Integer(c);
if(loaded && table.containsKey(i)) {
return (String) table.get(i);
}
// Автор
if(c == 0) {
if(c == 0 && !loaded) {
return "Shinovon";
}
switch(localei) {
Expand Down Expand Up @@ -221,6 +225,8 @@ public static String s(int c) {
return "(Used only if http streaming is on)";
case SET_Tip2:
return "(Leave images proxy empty if HTTPS is supported)";
case BTN_Playlists:
return "Playlists";
}
}
case 1: {
Expand Down Expand Up @@ -254,7 +260,7 @@ public static String s(int c) {
case CMD_Videos:
return "Видео";
case CMD_ViewChannel:
return "View channel";
return "Открыть канал";
case CMD_SwitchToPopular:
return "Сменить на популярные";
case CMD_SwitchToTrends:
Expand Down
1 change: 1 addition & 0 deletions src/LocaleConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ public interface LocaleConstants {
public static final int SET_VQ_NoAudio = 68;
public static final int SET_Tip1 = 69;
public static final int SET_Tip2 = 70;
public static final int BTN_Playlists = 71;

}
9 changes: 6 additions & 3 deletions src/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ else if(downloadDir.startsWith("file:///"))
} else {
App.asyncLoading = true;
}
if(PlatformUtils.isSymbianTouch() || PlatformUtils.isBada()) {
if(PlatformUtils.isSymbian3Based() || PlatformUtils.isBada()) {
App.customItems = true;
}
App.rememberSearch = true;
Expand All @@ -117,10 +117,10 @@ else if(downloadDir.startsWith("file:///"))
if(PlatformUtils.isAsha()) {
App.videoPreviews = true;
App.customItems = true;
} else if(s40 || (PlatformUtils.isNotS60() && !PlatformUtils.isS603rd() && PlatformUtils.startMemory > 512 * 1024 && PlatformUtils.startMemory < 2024 * 1024)) {
} else if(s40 /*|| (PlatformUtils.isNotS60() && !PlatformUtils.isS603rd() && PlatformUtils.startMemory > 512 * 1024 && PlatformUtils.startMemory < 2024 * 1024)*/) {
App.videoPreviews = true;
App.customItems = true;
if(s40) App.rmsPreviews = true;
App.rmsPreviews = true;
}
int min = Math.min(App.width, App.height);
// Symbian 9.4 can't handle H.264/AVC
Expand Down Expand Up @@ -164,6 +164,8 @@ else if(downloadDir.startsWith("file:///"))
App.customLocale = j.getString("customLocale");
if(j.has("searchPlaylists"))
App.searchPlaylists = j.getBoolean("searchPlaylists");
if(j.has("debugMemory"))
App.debugMemory = j.getBoolean("debugMemory");
return;
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -195,6 +197,7 @@ public static void saveConfig() {
j.put("rmsPreviews", new Boolean(App.rmsPreviews));
j.put("customLocale", "\"" + App.customLocale + "\"");
j.put("searchPlaylists", new Boolean(App.searchPlaylists));
j.put("debugMemory", new Boolean(App.debugMemory));
byte[] b = j.build().getBytes("UTF-8");

r.addRecord(b, 0, b.length);
Expand Down
14 changes: 11 additions & 3 deletions src/cc/nnproject/utils/PlatformUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,24 @@ public static boolean isNotS60() {
}

public static boolean isSymbianTouch() {
return !isNotS60() && (isS60PlatformVersion("5"));
return !isNotS60() && isS60PlatformVersion("5");
}

public static boolean isSymbian3() {
return !isNotS60() && (isS60PlatformVersion("5.1") || isS60PlatformVersion("5.2") || isS60PlatformVersion("5.3") || isS60PlatformVersion("5.4") || isS60PlatformVersion("5.5"));
public static boolean isSymbian3Based() {
return isSymbianTouch() && !isS60PlatformVersion("5.0");
}

public static boolean isSymbian94() {
return !isNotS60() && isS60PlatformVersion("5.0");
}

public static boolean isSymbianAnna() {
return !isNotS60() && isS60PlatformVersion("5.2");
}

public static boolean isSymbian93() {
return isS60PlatformVersion("3.2");
}

public static boolean isS603rd() {
if(isS603rd != -1) return isS603rd == 1;
Expand Down
2 changes: 1 addition & 1 deletion src/models/ChannelModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private Item makeItem() {
if(App.customItems) {
return customItem = new ChannelItem(this);
}
if(!App.videoPreviews || App.rmsPreviews) {
if(!App.videoPreviews) {
return new StringItem(null, author);
}
return item = new ImageItem(author, img, Item.LAYOUT_CENTER, null);
Expand Down
Loading

0 comments on commit 00f9b38

Please sign in to comment.