Skip to content

Commit

Permalink
Merge pull request #73 from shinovon/253
Browse files Browse the repository at this point in the history
2.5.3
  • Loading branch information
shinovon authored Sep 16, 2023
2 parents faab328 + d28ead8 commit 3448b09
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Application Descriptor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Nokia-MIDlet-Background-Event: pause
MIDlet-Version: 2.5.2
MIDlet-Version: 2.5.3
MIDlet-Info-URL: http://nnp.nnchan.ru/jtube
Nokia-MIDlet-S60-Selection-Key-Compatibility: true
MicroEdition-Configuration: CLDC-1.0
Expand Down
54 changes: 31 additions & 23 deletions src/jtube/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,34 @@ public void commandAction(Command c, Displayable arg1) {
return;
}
String url = getVideoLink(id, Settings.videoRes, true);
boolean bada = PlatformUtils.isBada;
String file = bada ? "file:///Media/Videos/" : ("file:///" + Settings.downloadDir);

if(PlatformUtils.isBada) {
String file = "file:///Media/Videos/watch.ram";
FileConnection fc = null;
OutputStream o = null;
try {
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
fc.create();
o = fc.openDataOutputStream();
o.write(url.getBytes("UTF-8"));
o.flush();
Util.platReq(file);
return;
} catch (Exception e) {
} finally {
try {
if (o != null)
o.close();
if (fc != null)
fc.close();
} catch (Exception e) {
}
}
}

String file = "file:///" + Settings.downloadDir;
if (!file.endsWith("/") && !file.endsWith("\\"))
file += "/";
if (PlatformUtils.isSymbian3Based() || PlatformUtils.isBada) {
Expand All @@ -440,20 +466,9 @@ public void commandAction(Command c, Displayable arg1) {
FileConnection fc = null;
OutputStream o = null;
try {
try {
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
} catch (IOException e) {
if(!bada) throw e;
file = System.getProperty("fileconn.dir.videos");
if (!file.endsWith("/") && !file.endsWith("\\"))
file += "/";
file += "watch.ram";
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
}
fc = (FileConnection) Connector.open(file, 3);
if (fc.exists())
fc.delete();
fc.create();
o = fc.openDataOutputStream();
o.write(url.getBytes("UTF-8"));
Expand All @@ -467,13 +482,6 @@ public void commandAction(Command c, Displayable arg1) {
} catch (Exception e) {
}
}
if(bada) {
try {
Util.platReq("file:///Media/Videos/watch.ram");
return;
} catch (Exception e) {
}
}
Util.platReq(file);
break;
}
Expand Down
26 changes: 18 additions & 8 deletions src/jtube/ui/AbstractListScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ protected boolean keyPress(int i) {
if(cItem == null) selectItem();
if(i == -1) {
if(cItem == null) return false;
if(cItem.getY() < -scroll) {
smoothlyScrollTo((int)scroll+(screenHeight/3));
int ss = (int) scroll;
if(scrollTarget < 0) ss = scrollTarget;
if(cItem.getY() < -ss) {
smoothlyScrollTo((int)ss+(screenHeight/3));
} else {
if(cItem.getListPosition() == 0) {
if(-scroll < screenHeight/4) {
Expand All @@ -239,24 +241,32 @@ protected boolean keyPress(int i) {
}
focusItem(item);
}
if(!isItemSeenOnScreen(cItem, 24)) {
smoothlyScrollTo(-cItem.getY());
if(!isItemSeenOnScreen(cItem, screenHeight/5)) {
int s = (int)scroll+(screenHeight/4);
if(s > -cItem.getY()) s = -cItem.getY();
smoothlyScrollTo(s);
//smoothlyScrollTo(-cItem.getY()+screenHeight/2);
}
return true;
}
} else if(i == -2) {
if(cItem == null) return false;
if(cItem.getY()+cItem.getHeight() > -(scroll-screenHeight)) {
smoothlyScrollTo((int)scroll-(screenHeight/3));
int ss = (int) scroll;
if(scrollTarget < 0) ss = scrollTarget;
if(cItem.getY()+cItem.getHeight() > -(ss-screenHeight)) {
smoothlyScrollTo((int)ss-(screenHeight/3));
} else {
if(cItem.getListPosition() == items.size()-1) return false;
UIItem item = (UIItem) items.elementAt(cItem.getListPosition()+1);
while(!item.canBeFocused() && item.getListPosition() != items.size()-1) {
item = (UIItem) items.elementAt(item.getListPosition()+1);
}
focusItem(item);
if(!isItemSeenOnScreen(cItem, 24)) {
smoothlyScrollTo(-cItem.getY());
if(!isItemSeenOnScreen(cItem, screenHeight/5)) {
int s = (int)scroll-(screenHeight/4);
if(s < -cItem.getY()-cItem.getHeight()) s = -cItem.getY()-cItem.getHeight();
smoothlyScrollTo(s);
//smoothlyScrollTo(-cItem.getY()+screenHeight/2);
}
}
if(scroll < -height + screenHeight) {
Expand Down
4 changes: 0 additions & 4 deletions src/jtube/ui/screens/ChannelScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,6 @@ public void dispose() {
continuation = null;
}

protected void menuAction(int action) {
super.menuAction(action);
}

protected void back() {
super.back();
}
Expand Down
60 changes: 36 additions & 24 deletions src/jtube/ui/screens/NavigationScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ protected void paint(Graphics g, int w, int h) {
g.drawLine(0, sy, w, sy);
}
}
} else {
g.setColor(AppUI.getColor(COLOR_SOFTBAR_BG));
g.fillRect(0, h-softBarHeight, w, softBarHeight);
g.setColor(AppUI.getColor(COLOR_TOPBAR_BORDER));
g.drawLine(0, h-softBarHeight, w, h-softBarHeight);
g.setColor(AppUI.getColor(COLOR_SOFTBAR_FG));
g.setFont(softFont);
String s1 = Locale.s(CMD_FullEdit);
String s2 = Locale.s(searchText.length() > 0 ? CMD_Clean : CMD_Cancel);
g.drawString(s1, 2, h-2, Graphics.BOTTOM | Graphics.LEFT);
g.drawString(s2, w-2, h-2, Graphics.BOTTOM | Graphics.RIGHT);
g.drawString(Locale.s(CMD_Search), w >> 1, h-2, Graphics.BOTTOM | Graphics.HCENTER);
}
if(editor == null || editorHidden) {
if(keyboard != null && keyboard.isVisible()) {
Expand All @@ -324,30 +336,16 @@ protected void paint(Graphics g, int w, int h) {
}
}
} else {
if(!topBar) {
g.setColor(AppUI.getColor(COLOR_SOFTBAR_BG));
g.fillRect(0, h-softBarHeight, w, softBarHeight);
if(!(this instanceof VideoScreen)) {
g.setColor(AppUI.getColor(COLOR_TOPBAR_BG));
g.fillRect(0, h-topBarHeight, w, topBarHeight);
g.setColor(AppUI.getColor(COLOR_TOPBAR_BORDER));
g.drawLine(0, h-softBarHeight, w, h-softBarHeight);
g.setColor(AppUI.getColor(COLOR_SOFTBAR_FG));
g.setFont(softFont);
String s1 = Locale.s(CMD_FullEdit);
String s2 = Locale.s(searchText.length() > 0 ? CMD_Clean : CMD_Cancel);
g.drawString(s1, 2, h-2, Graphics.BOTTOM | Graphics.LEFT);
g.drawString(s2, w-2, h-2, Graphics.BOTTOM | Graphics.RIGHT);
g.drawString(Locale.s(CMD_Search), w >> 1, h-2, Graphics.BOTTOM | Graphics.HCENTER);
} else {
if(!(this instanceof VideoScreen)) {
g.setColor(AppUI.getColor(COLOR_TOPBAR_BG));
g.fillRect(0, h-topBarHeight, w, topBarHeight);
g.setColor(AppUI.getColor(COLOR_TOPBAR_BORDER));
g.drawLine(0, h-topBarHeight, w, h-topBarHeight);

int f = w / 2;
g.drawImage(ui.currentTab == 0 ? homeSelImg : homeImg, (f-24) >> 1, h-36, 0);
g.drawImage(ui.currentTab == 1 ? subsSelImg : subsImg, ((f-24) >> 1) + f, h-36, 0);
// g.drawImage(ui.currentTab == 2 ? libSelImg : libImg, ((f-24) >> 1) + f + f, h-36, 0);
}
g.drawLine(0, h-topBarHeight, w, h-topBarHeight);

int f = w / 2;
g.drawImage(ui.currentTab == 0 ? homeSelImg : homeImg, (f-24) >> 1, h-36, 0);
g.drawImage(ui.currentTab == 1 ? subsSelImg : subsImg, ((f-24) >> 1) + f, h-36, 0);
// g.drawImage(ui.currentTab == 2 ? libSelImg : libImg, ((f-24) >> 1) + f + f, h-36, 0);
}
if(Settings.fullScreen) {
int xx = 4;
Expand Down Expand Up @@ -461,7 +459,7 @@ protected void paint(Graphics g, int w, int h) {
yy += ih;
}
g.setColor(AppUI.getColor(COLOR_MAINBORDER));
g.drawRect(xx, y2, menuW, itemMenuH);
g.drawRect(xx, y2, menuW, menuH); // XXX
}
g.setColor(AppUI.getColor(COLOR_SOFTBAR_BG));
g.fillRect(0, h-softBarHeight, w, softBarHeight);
Expand Down Expand Up @@ -633,6 +631,20 @@ protected boolean keyPress(int i) {
search(searchText);
return true;
}
if(i == -7) {
if(searchText.length() == 0) {
editorHidden = true;
if(editor != null && editor.isVisible()) {
editor.setFocus(false);
editor.setVisible(false);
editor.setParent(null);
} else if(keyboard != null && keyboard.isVisible()) {
keyboard.hide();
}
search = false;
return true;
}
}
}
if(keyboard != null && keyboard.isVisible() && keyboard.keyPressed(i)) {
return true;
Expand Down

0 comments on commit 3448b09

Please sign in to comment.