├── server ├── proxy.php ├── 401test.php ├── index.html ├── update.php ├── oauthproxy.php ├── tokenproxy.php └── kl.php ├── res ├── c.mp3 ├── ava.png ├── b1.mp3 ├── avas.png ├── avash.png ├── back.png ├── camera.png ├── docjar.png ├── docmus.png ├── docsis.png ├── doctxt.png ├── docvid.png ├── doczip.png ├── flash.png ├── icons.png ├── login.png ├── typing.gif ├── docfile.png ├── flashoff.png ├── vika256.png ├── vikahead.png ├── deactivated.png ├── emptyCover.png ├── ic_online.png ├── miniplayer.png ├── multichat.png ├── playerbtns.png ├── loginpressed.png ├── emoji │ └── D83DDE00.png └── vikaheadnight2.png ├── PerfMon.sis ├── .gitattributes ├── kemfm1.0.jar ├── vikaTouch.jar ├── src ├── org │ └── json │ │ └── me │ │ ├── JSONString.java │ │ ├── JSONException.java │ │ ├── StringWriter.java │ │ └── JSONStringer.java ├── vikatouch │ ├── screens │ │ ├── AgreementScreen.java │ │ ├── ReturnableListScreen.java │ │ ├── PhotosScreen.java │ │ ├── AboutScreen.java │ │ └── temp │ │ │ └── SplashScreen.java │ ├── json │ │ ├── INextLoadable.java │ │ └── JSONBase.java │ ├── NokiaUITextEditorListener.java │ ├── attachments │ │ ├── LinkAttachment.java │ │ ├── UnsupportedAttachment.java │ │ ├── WallReplyAttachment.java │ │ ├── ErrorAttachment.java │ │ ├── GiftAttachment.java │ │ ├── ImageAttachment.java │ │ ├── ISocialable.java │ │ ├── WallAttachment.java │ │ ├── StickerAttachment.java │ │ ├── AudioAttachment.java │ │ ├── Attachment.java │ │ ├── PhotoSize.java │ │ ├── DocumentAttachment.java │ │ ├── VideoAttachment.java │ │ └── VoiceAttachment.java │ ├── VikaNetworkError.java │ ├── locale │ │ └── LangObject.java │ ├── music │ │ ├── AsyncLoadListener.java │ │ └── AsyncLoadDataSource.java │ ├── NotificationListener.java │ ├── utils │ │ ├── DebugUtils.java │ │ ├── IntObject.java │ │ ├── captcha │ │ │ └── CaptchaObject.java │ │ ├── text │ │ │ ├── CountUtils.java │ │ │ └── TextEditor.java │ │ ├── ProfileObject.java │ │ ├── url │ │ │ ├── URLBuilder.java │ │ │ └── URLDecoder.java │ │ ├── error │ │ │ └── ErrorCodes.java │ │ ├── HttpMultipartRequest.java │ │ ├── ResizeUtils.java │ │ └── Camera.java │ ├── items │ │ ├── chat │ │ │ ├── ChatItem.java │ │ │ ├── IMessage.java │ │ │ └── DateItem.java │ │ ├── smile.java │ │ ├── PhotoItem.java │ │ ├── fm │ │ │ ├── FileItem.java │ │ │ ├── FolderLoadNextItem.java │ │ │ ├── FolderItem.java │ │ │ └── FileManagerItem.java │ │ ├── music │ │ │ ├── MusicMenuItem.java │ │ │ ├── PlaylistItem.java │ │ │ └── AudioTrackItem.java │ │ ├── JSONUIItem.java │ │ ├── LoadMoreButtonItem.java │ │ ├── menu │ │ │ ├── OnOffItem.java │ │ │ ├── GroupItem.java │ │ │ ├── FriendItem.java │ │ │ └── MemberItem.java │ │ └── JSONItem.java │ ├── NokiaUITextEditor.java │ ├── DirectUtilsInvoker.java │ ├── TestUtils.java │ ├── SoftNotificationInvoker.java │ ├── updates │ │ └── VikaUpdate.java │ ├── VikaFileManager.java │ └── settings │ │ └── SettingMenuItem.java ├── ru │ └── nnproject │ │ ├── vikaui │ │ ├── menu │ │ │ ├── IMenu.java │ │ │ ├── EmptyMenu.java │ │ │ └── items │ │ │ │ ├── UIItem.java │ │ │ │ ├── PressableUIItem.java │ │ │ │ └── OptionItem.java │ │ ├── popup │ │ │ ├── VikaNotice.java │ │ │ ├── AutoContextMenu.java │ │ │ ├── ConfirmBox.java │ │ │ ├── InfoPopup.java │ │ │ └── ContextMenu.java │ │ ├── utils │ │ │ ├── MathUtils.java │ │ │ ├── DisplayUtils.java │ │ │ └── images │ │ │ │ └── IconsManager.java │ │ ├── VikaCanvas.java │ │ ├── screen │ │ │ └── VikaScreen.java │ │ └── UIThread.java │ │ └── vikatouch │ │ └── VikaTouchApp.java └── tube42 │ └── lib │ └── imagelib │ ├── ImageAnalysisUtils.java │ └── ColorUtils.java ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.mtj.core.prefs └── fr.kazejiyu.discord.rpc.integration.prefs ├── LICENSE ├── langs ├── formats │ ├── tut.txt │ ├── regionlist │ ├── US.txt │ ├── KZ.txt │ ├── RU.txt │ ├── UA.txt │ ├── UK.txt │ ├── BY.txt │ └── ES.txt └── langs │ └── langlist ├── .classpath ├── .gitignore ├── vikaTouch.jad ├── MANIFEST.MF ├── .project ├── Application Descriptor └── README.md /server/proxy.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /res/c.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/c.mp3 -------------------------------------------------------------------------------- /PerfMon.sis: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/PerfMon.sis -------------------------------------------------------------------------------- /res/ava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/ava.png -------------------------------------------------------------------------------- /res/b1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/b1.mp3 -------------------------------------------------------------------------------- /server/401test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /kemfm1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/kemfm1.0.jar -------------------------------------------------------------------------------- /res/avas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/avas.png -------------------------------------------------------------------------------- /res/avash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/avash.png -------------------------------------------------------------------------------- /res/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/back.png -------------------------------------------------------------------------------- /res/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/camera.png -------------------------------------------------------------------------------- /res/docjar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/docjar.png -------------------------------------------------------------------------------- /res/docmus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/docmus.png -------------------------------------------------------------------------------- /res/docsis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/docsis.png -------------------------------------------------------------------------------- /res/doctxt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/doctxt.png -------------------------------------------------------------------------------- /res/docvid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/docvid.png -------------------------------------------------------------------------------- /res/doczip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/doczip.png -------------------------------------------------------------------------------- /res/flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/flash.png -------------------------------------------------------------------------------- /res/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/icons.png -------------------------------------------------------------------------------- /res/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/login.png -------------------------------------------------------------------------------- /res/typing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/typing.gif -------------------------------------------------------------------------------- /vikaTouch.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/vikaTouch.jar -------------------------------------------------------------------------------- /res/docfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/docfile.png -------------------------------------------------------------------------------- /res/flashoff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/flashoff.png -------------------------------------------------------------------------------- /res/vika256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/vika256.png -------------------------------------------------------------------------------- /res/vikahead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/vikahead.png -------------------------------------------------------------------------------- /res/deactivated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/deactivated.png -------------------------------------------------------------------------------- /res/emptyCover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/emptyCover.png -------------------------------------------------------------------------------- /res/ic_online.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/ic_online.png -------------------------------------------------------------------------------- /res/miniplayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/miniplayer.png -------------------------------------------------------------------------------- /res/multichat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/multichat.png -------------------------------------------------------------------------------- /res/playerbtns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/playerbtns.png -------------------------------------------------------------------------------- /res/loginpressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/loginpressed.png -------------------------------------------------------------------------------- /res/emoji/D83DDE00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/emoji/D83DDE00.png -------------------------------------------------------------------------------- /res/vikaheadnight2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Computershik73/ViKaTouch/HEAD/res/vikaheadnight2.png -------------------------------------------------------------------------------- /src/org/json/me/JSONString.java: -------------------------------------------------------------------------------- 1 | package org.json.me; 2 | 3 | public interface JSONString { 4 | String toJSONString(); 5 | } -------------------------------------------------------------------------------- /src/vikatouch/screens/AgreementScreen.java: -------------------------------------------------------------------------------- 1 | package vikatouch.screens; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class AgreementScreen { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/vikatouch/json/INextLoadable.java: -------------------------------------------------------------------------------- 1 | package vikatouch.json; 2 | 3 | /** 4 | * @author Feodor0090 5 | * 6 | */ 7 | public interface INextLoadable { 8 | public void loadNext(); 9 | } 10 | -------------------------------------------------------------------------------- /src/vikatouch/NokiaUITextEditorListener.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public interface NokiaUITextEditorListener { 8 | 9 | public void action(NokiaUITextEditor editor, int act); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/LinkAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | /** 4 | * @author Feodor0090 5 | * 6 | */ 7 | public class LinkAttachment extends Attachment { 8 | 9 | public void parseJSON() { 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/UnsupportedAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class UnsupportedAttachment extends Attachment { 8 | 9 | public void parseJSON() { 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/WallReplyAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class WallReplyAttachment extends Attachment { 8 | 9 | public void parseJSON() { 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/vikatouch/VikaNetworkError.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | /** 4 | * @author Feodor0090 5 | * 6 | */ 7 | public class VikaNetworkError extends RuntimeException { 8 | 9 | public VikaNetworkError(String string) { 10 | super(string); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/ru/nnproject/vikatouch/VikaTouchApp.java=UTF-8 3 | encoding//src/vikaMobile/base/URLDecoder.java=UTF-8 4 | encoding//src/vikatouch/utils/VikaUtils.java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /src/vikatouch/locale/LangObject.java: -------------------------------------------------------------------------------- 1 | package vikatouch.locale; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class LangObject 8 | { 9 | public String shortName; 10 | public int index; 11 | public String authors; 12 | public String name; 13 | } 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 2 | -------------------------------------------------------------------------------- /.settings/org.eclipse.mtj.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | obfuscate_use_project=true 3 | pkg_use_project=true 4 | preverify_config_value=CLDC-1.0 5 | proguard_options=-dontusemixedcaseclassnames -dontwarn -dontnote -dontoptimize -microedition 6 | proguard_use_specified=true 7 | -------------------------------------------------------------------------------- /src/vikatouch/screens/ReturnableListScreen.java: -------------------------------------------------------------------------------- 1 | package vikatouch.screens; 2 | 3 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public abstract class ReturnableListScreen extends ScrollableCanvas { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /.settings/fr.kazejiyu.discord.rpc.integration.prefs: -------------------------------------------------------------------------------- 1 | PROJECT_NAME=Vika Touch 2 | RESET_ELAPSED_TIME=RESET_ELAPSED_TIME_ON_STARTUP 3 | SHOW_ELAPSED_TIME=true 4 | SHOW_FILE_NAME=true 5 | SHOW_LANGUAGE_ICON=true 6 | SHOW_PROJECT_NAME=true 7 | USE_PROJECT_SETTINGS=true 8 | eclipse.preferences.version=1 9 | -------------------------------------------------------------------------------- /src/vikatouch/music/AsyncLoadListener.java: -------------------------------------------------------------------------------- 1 | package vikatouch.music; 2 | 3 | public interface AsyncLoadListener { 4 | 5 | public void bufferedPercent(float percent); 6 | 7 | public void bufferDone(int size); 8 | 9 | public void deallocated(); 10 | 11 | public void positionReset(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/vikatouch/NotificationListener.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | import com.nokia.mid.ui.SoftNotification; 4 | 5 | public interface NotificationListener { 6 | 7 | public void notificationSelected(SoftNotification notification); 8 | 9 | public void notificationDismissed(SoftNotification notification); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/vikatouch/utils/DebugUtils.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class DebugUtils { 8 | 9 | public static void printStackTrace() { 10 | try { 11 | throw new Exception(); 12 | } catch (Exception e) { 13 | e.printStackTrace(); 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/vikatouch/items/chat/ChatItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.chat; 2 | 3 | import org.json.me.JSONObject; 4 | 5 | import vikatouch.items.JSONItem; 6 | 7 | 8 | /** 9 | * @author Shinovon 10 | * 11 | */ 12 | public abstract class ChatItem extends JSONItem { 13 | public ChatItem(JSONObject json) { 14 | super(json); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/menu/IMenu.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.menu; 5 | 6 | /** 7 | * @author Feodor0090 8 | * 9 | */ 10 | public interface IMenu { 11 | public void onMenuItemPress(int i); 12 | 13 | public void onMenuItemOption(int i); 14 | } 15 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/popup/VikaNotice.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.popup; 5 | 6 | import ru.nnproject.vikaui.screen.VikaScreen; 7 | 8 | /** 9 | * @author Feodor0090 10 | * 11 | */ 12 | public abstract class VikaNotice extends VikaScreen { 13 | } 14 | -------------------------------------------------------------------------------- /server/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Vika Touch 4 | 5 | 6 | 7 |

Vika Touch

8 | Сайта нету! 9 |
10 |
11 | Скоро ЗБТ (закрытое бета тестирование)
12 |
13 | Что-бы принять участие нужно зайти в дискорд вики мобайл (тут будет ссылка)
14 | и написать в лс Арману или Федору в вк 15 | -------------------------------------------------------------------------------- /langs/formats/tut.txt: -------------------------------------------------------------------------------- 1 | #| - new line 2 | #datetime format: 3 | # DATE 4 | #DD - day 5 | #S - short month 6 | #N - month 7 | #O - month (number) 8 | #YEAR - year 9 | # TIME 10 | #tt - low case am / pm 11 | #TT - high case AM / PM 12 | #h - hour in 12 hours format 13 | #H - hour 14 | #HH - hour with zero if less than 10 15 | #M - minute 16 | #MM - minute with zero if less than 10 -------------------------------------------------------------------------------- /src/vikatouch/attachments/ErrorAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class ErrorAttachment extends Attachment { 8 | 9 | public String description; 10 | 11 | public ErrorAttachment(String desc) { 12 | this.description = desc; 13 | this.type = null; 14 | } 15 | 16 | public void parseJSON() { 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/vikatouch/items/chat/IMessage.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.chat; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public interface IMessage { 8 | 9 | public int getMessageId(); 10 | 11 | public int getFromId(); 12 | 13 | public String getText(); 14 | 15 | public void setName(String n); 16 | 17 | public void setRead(boolean i); 18 | 19 | public boolean isRead(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/menu/EmptyMenu.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.menu; 5 | 6 | /** 7 | * @author Feodor0090 8 | * 9 | */ 10 | public class EmptyMenu implements IMenu { 11 | 12 | public void onMenuItemPress(int i) { 13 | } 14 | 15 | public void onMenuItemOption(int i) { 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/menu/items/UIItem.java: -------------------------------------------------------------------------------- 1 | package ru.nnproject.vikaui.menu.items; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | 5 | /** 6 | * @author Feodor0090 7 | * 8 | */ 9 | public interface UIItem { 10 | public void paint(Graphics g, int y, int scrolled); 11 | 12 | public int getDrawHeight(); 13 | 14 | public void addDrawHeight(int i); 15 | 16 | public void setDrawHeight(int i); 17 | } 18 | -------------------------------------------------------------------------------- /src/org/json/me/JSONException.java: -------------------------------------------------------------------------------- 1 | package org.json.me; 2 | 3 | public class JSONException extends RuntimeException { 4 | private Throwable cause; 5 | 6 | public JSONException(String var1) { 7 | super(var1); 8 | } 9 | 10 | public JSONException(Throwable var1) { 11 | super(var1.getMessage()); 12 | this.cause = var1; 13 | } 14 | 15 | public Throwable getCause() { 16 | return this.cause; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | /bin 14 | 15 | /build 16 | 17 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 18 | hs_err_pid* 19 | .mtj 20 | .settings/org.eclipse.jdt.core.prefs 21 | src.rar 22 | deployed/ 23 | build.properties 24 | .idea/* 25 | vikatouch.iml 26 | serverdata/ 27 | .settings/org.eclipse.jdt.ui.prefs 28 | -------------------------------------------------------------------------------- /src/vikatouch/NokiaUITextEditor.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | /*public class NokiaUITextEditor extends com.nokia.mid.ui.TextEditor { 10 | 11 | public String getContent() { 12 | //textEditor.setCaretXY(0,8); 13 | ChatScreen.inputText=this.getContent(); 14 | VikaTouch.needstoRedraw=false; 15 | return this.getContent(); 16 | // 17 | } 18 | 19 | }*/ 20 | public interface NokiaUITextEditor { 21 | 22 | public String getContent(); 23 | 24 | } -------------------------------------------------------------------------------- /src/vikatouch/attachments/GiftAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Image; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public class GiftAttachment extends ImageAttachment { 10 | 11 | public void parseJSON() { 12 | 13 | } 14 | 15 | public Image getPreviewImage() { 16 | return null; 17 | } 18 | 19 | public Image getFullImage() { 20 | return null; 21 | } 22 | 23 | public Image getImage(int height) { 24 | return null; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/vikatouch/DirectUtilsInvoker.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | 4 | 5 | //import com.nokia.mid.ui.DirectUtils; 6 | 7 | 8 | /*class DirectUtilsInvoker { 9 | 10 | static Font getFont(int face, int style, int height) { 11 | try { 12 | return DirectUtils.getFont(face, style, height); 13 | } catch (Throwable e) { 14 | e.printStackTrace(); 15 | } 16 | return null; 17 | } 18 | 19 | static void init() { 20 | try { 21 | DirectUtils.getFont(0, 0, 12); 22 | } catch (Throwable ee) {} 23 | } 24 | 25 | }*/ -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/utils/MathUtils.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.utils; 5 | 6 | /** 7 | * @author Shinovon 8 | * 9 | */ 10 | public class MathUtils { 11 | 12 | public static int lerp(final int start, final int target, final int mul, final int div) { 13 | return start + ((target - start) * mul / div); 14 | } 15 | 16 | public static int clamp(final int val, final int min, final int max) { 17 | return Math.max(Math.min(val, max), min); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/vikatouch/items/smile.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items; 2 | 3 | import vikatouch.VikaTouch; 4 | 5 | public class smile { 6 | public int smilePos; 7 | public String smilePath; 8 | public int smileX = 0; 9 | public int smileY = 0; 10 | public smile(int smPos, String smPath) { 11 | smilePos=smPos; 12 | smilePath=smPath; 13 | } 14 | public smile (int smPos, String smPath, int smX, int smY) { 15 | smilePos=smPos; 16 | smilePath=smPath; 17 | smileX=smX; 18 | smileY=smY; 19 | VikaTouch.needstoRedraw=true; 20 | VikaTouch.canvas.serviceRepaints(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/ImageAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Image; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public abstract class ImageAttachment extends Attachment { 10 | public abstract Image getPreviewImage(); 11 | 12 | public abstract Image getFullImage(); 13 | 14 | // public abstract String getPreviewImageUrl(); 15 | // public abstract String getFullImageUrl(); 16 | 17 | public abstract Image getImage(int height); // Может таки не по индексу, а по требуемой высоте всё получать?)) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/vikatouch/items/PhotoItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | /*public class PhotoItem extends JSONItem { 10 | /* 11 | public int itemDrawWidth = 50; 12 | private String iconUrl; 13 | private Image iconImg; 14 | 15 | public PhotoItem(JSONObject json, boolean dontLoadImage) { 16 | super(json); 17 | 18 | if (!dontLoadImage) { 19 | 20 | } 21 | } 22 | */ 23 | /* public void paint(Graphics g, int y, int scrolled) { 24 | 25 | } 26 | 27 | public void tap(int x, int y) { 28 | 29 | } 30 | 31 | public void keyPress(int key) { 32 | 33 | } 34 | 35 | }*/ 36 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/menu/items/PressableUIItem.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.menu.items; 5 | 6 | /** 7 | * @author Feodor0090 8 | * 9 | */ 10 | public abstract interface PressableUIItem extends UIItem { 11 | public static final int KEY_OK = -5; 12 | public static final int KEY_FUNC = -6; 13 | public static final int KEY_DELETE = 8; 14 | public static final int KEY_BACK = 999; // TODO: obtain code 15 | public static final int KEY_RFUNC = -7; 16 | 17 | public void tap(int x, int y); 18 | 19 | public void keyPress(int key); 20 | 21 | public boolean isSelected(); 22 | 23 | public void setSelected(boolean selected); 24 | } 25 | -------------------------------------------------------------------------------- /langs/formats/regionlist: -------------------------------------------------------------------------------- 1 | # Список регионов 2 | # Region list 3 | # 4 | # Для моддеров! 5 | # For modders! 6 | # 7 | # Название файла не должно содержать пробелы и не латинские символы! 8 | # File name must not contain spaces or non-Latin characters! 9 | # 10 | # Format: ;;; 11 | # 12 | # Example: 13 | # AB;me, and you;en-US;My region 14 | # 15 | US;Shinovon;en-US;United States 16 | UK;Shinovon;en-UK;United Kingdom 17 | RU;Shinovon;ru-RU,ru-UA,ru-KZ,ru-BY;Россия 18 | ES;Jazminrocio, Shinovon;es-ES,es-AR;España 19 | UA;Phantom_Horror, Shinovon;uk-UA;Україна 20 | BY;Jazminrocio, Shinovon;be-BY;Беларусь 21 | KZ;Shinovon;kk-KZ;Қазақстан 22 | PL;Temmie Flakes;pl-PL;Polska 23 | -------------------------------------------------------------------------------- /src/vikatouch/json/JSONBase.java: -------------------------------------------------------------------------------- 1 | package vikatouch.json; 2 | 3 | import org.json.me.JSONObject; 4 | 5 | import vikatouch.utils.VikaUtils; 6 | 7 | /** 8 | * @author Shinovon 9 | * 10 | */ 11 | public abstract class JSONBase { 12 | public JSONObject json; 13 | 14 | public abstract void parseJSON(); 15 | 16 | public final static String fixJSONString(String jsonString) { 17 | if (jsonString == null || jsonString.equals("")) { 18 | return ""; 19 | } 20 | return VikaUtils.replace(VikaUtils.replace(VikaUtils.replace(jsonString, "\\/", "/"), "\\n", "\n"), "\\\"", 21 | "\""); 22 | } 23 | 24 | public void disposeJson() { 25 | if (json != null && !json.disposed) { 26 | json.dispose(); 27 | } 28 | json = null; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/vikatouch/utils/IntObject.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class IntObject { 8 | public IntObject(int value) { 9 | this.value = value; 10 | } 11 | 12 | public final int hashCode() { 13 | return value; 14 | } 15 | 16 | public final boolean equals(Object var1) { 17 | if (var1 instanceof IntObject) { 18 | if (this.value == ((IntObject) var1).value) { 19 | return true; 20 | } 21 | if (this == (IntObject) var1) { 22 | return true; 23 | } 24 | return false; 25 | } else if (var1 instanceof Integer) { 26 | if (this.value == ((Integer) var1).intValue()) { 27 | return true; 28 | } 29 | return false; 30 | } 31 | return false; 32 | } 33 | 34 | public int value; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /vikaTouch.jad: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | VikaTouch-Edition: openbeta 3 | Nokia-MIDlet-Background-Event: run 4 | MIDlet-Version: 2.9.3 5 | MIDlet-Info-URL: http://vikamobile.ru 6 | LGE-MIDlet-TargetLCD-Width: 480 7 | Nokia-MIDlet-UID-1: 0xA02033e9 8 | MicroEdition-Configuration: CLDC-1.1 9 | MIDlet-Name: Vika Touch 10 | FlipInsensitive: True 11 | Nokia-MIDlet-On-Screen-Keypad: no 12 | MIDlet-Vendor: nnproject 13 | Progressive_Download: enabled 14 | MIDlet-Icon: vika256.png 15 | LGE-MIDlet-TargetLCD-Height: 800 16 | MicroEdition-Profile: MIDP-2.0 17 | MIDlet-Permissions: javax.microedition.io.Connector.http 18 | Nokia-MIDlet-No-Exit: true 19 | MIDlet-1: Vika Touch,/vika256.png,ru.nnproject.vikatouch.VikaTouchApp 20 | MIDlet-Jar-Size: 532721 21 | MIDlet-Jar-URL: vikaTouch.jar 22 | Nokia-MIDlet-Category: Game 23 | -------------------------------------------------------------------------------- /src/vikatouch/items/fm/FileItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.fm; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.io.file.FileConnection; 6 | 7 | import vikatouch.screens.temp.FileManagerScreen; 8 | 9 | /** 10 | * @author Shinovon 11 | * 12 | */ 13 | public class FileItem extends FileManagerItem { 14 | 15 | public FileItem(FileManagerScreen fms, String path, String name, int size) { 16 | super(fms, path, name, size); 17 | } 18 | 19 | public FileItem(FileManagerScreen fms, String path, String name) { 20 | super(fms, path, name); 21 | } 22 | 23 | public FileItem(FileManagerScreen fms, String path) { 24 | super(fms, path); 25 | } 26 | 27 | public FileItem(FileManagerScreen fms, FileConnection fileConn) throws IOException { 28 | super(fms, fileConn); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /langs/langs/langlist: -------------------------------------------------------------------------------- 1 | # Список языков 2 | # Languages list 3 | # 4 | # Для моддеров! 5 | # For modders! 6 | # 7 | # Название файла не должно содержать пробелы и не латинские символы! 8 | # File name must not contain spaces or non-Latin characters! 9 | # 10 | # Format: ;;;; 11 | # 12 | # Example: 13 | # language.txt;Me, and you;en-US,en-UK;example;My locale 14 | # 15 | english.txt;Shinovon;en-US,en-UK;english;English 16 | russian.txt;Shinovon, Feodor0090;ru-RU,ru-KZ,kk-KZ,ru-KZ,ru-UA;russian;Русский 17 | spanish.txt;Илья Высоцкий, Jazminrocio, Shinovon;es-ES,es-AR;spanish,Español 18 | ukrainian.txt;Phantom_Horror;uk-UA;ukrainian;Українська 19 | belarussian.txt;Jazminrocio;be-BY;belarus;Беларуская 20 | vietnamese.txt;Jazminrocio;vi-VN;vietnamese;Tiếng Việt 21 | polish.txt;Temmie Flakes;pl-PL;polish;polszczyzna -------------------------------------------------------------------------------- /MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | VikaTouch-Edition: openbeta 3 | Nokia-MIDlet-Background-Event: run 4 | MIDlet-Version: 2.9.3 5 | MIDlet-Info-URL: http://vikamobile.ru 6 | LGE-MIDlet-TargetLCD-Width: 480 7 | Nokia-MIDlet-UID-1: 0xA02033e9 8 | MicroEdition-Configuration: CLDC-1.1 9 | MIDlet-Name: Vika Touch 10 | FlipInsensitive: True 11 | Nokia-MIDlet-On-Screen-Keypad: no 12 | MIDlet-Vendor: nnproject 13 | Progressive_Download: enabled 14 | MIDlet-Icon: vika256.png 15 | LGE-MIDlet-TargetLCD-Height: 800 16 | MIDlet-Touch-Support: True 17 | UseNativeCommands: false 18 | ReverseSoftkeys: true 19 | MIDlet-ScreenMode: ROTATE 20 | MIDlet-Landscape-Support: true 21 | MIDlet-Scaleup-Support: false 22 | MicroEdition-Profile: MIDP-2.0 23 | MIDlet-Permissions: javax.microedition.io.Connector.http 24 | Nokia-MIDlet-No-Exit: true 25 | MIDlet-1: Vika Touch,/vika256.png,ru.nnproject.vikatouch.VikaTouchApp 26 | 27 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | vikatouch 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.mtj.core.validator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.mtj.core.preverifier 20 | 21 | 22 | 23 | 24 | org.eclipse.mtj.core.packageBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jdt.core.javanature 31 | org.eclipse.mtj.core.nature 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/vikatouch/items/music/MusicMenuItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.music; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | 5 | import ru.nnproject.vikaui.menu.IMenu; 6 | import ru.nnproject.vikaui.menu.items.OptionItem; 7 | import ru.nnproject.vikaui.utils.images.IconsManager; 8 | import vikatouch.music.MusicPlayer; 9 | 10 | /** 11 | * @author Feodor0090 12 | * 13 | */ 14 | // а-ля по канонам ООП 15 | public class MusicMenuItem extends OptionItem { 16 | 17 | public String origStr; 18 | 19 | public MusicMenuItem(IMenu m, String t, int ic, int i, int h) { 20 | super(m, t, ic, i, h); 21 | origStr = t; 22 | } 23 | 24 | public void paint(Graphics g, int y, int scrolled) { 25 | icon = (MusicPlayer.inst == null) ? IconsManager.MUSIC : IconsManager.PLAY; 26 | text = (MusicPlayer.inst == null) ? origStr : (origStr + " (" + MusicPlayer.inst.title + ")"); 27 | super.paint(g, y, scrolled); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Application Descriptor: -------------------------------------------------------------------------------- 1 | VikaTouch-Edition: release 2 | Nokia-MIDlet-Background-Event: run 3 | MIDlet-Version: 2.9.12 4 | MIDlet-Info-URL: http://vikamobile.ru 5 | Nokia-UI-Enhancement: CanvasHasBackground,MusicKeysSupported,IgnoreProfilesBasedSoundMuting 6 | Manifest-Version: 1.0 7 | LGE-MIDlet-TargetLCD-Width: 480 8 | MicroEdition-Configuration: CLDC-1.0 9 | Nokia-MIDlet-UID-1: 0xE02033e8 10 | Nokia-MIDlet-Block-Uninstall: true 11 | MIDlet-Name: ViKa Mobile 12 | FlipInsensitive: True 13 | Nokia-MIDlet-On-Screen-Keypad: no 14 | MIDlet-Vendor: Ilya Vysotsky 15 | Progressive_Download: enabled 16 | MIDlet-Icon: vika256.png 17 | Nokia-MIDlet-Category: Application 18 | LGE-MIDlet-TargetLCD-Height: 800 19 | MIDlet-1: ViKa Mobile,/vika256.png,ru.nnproject.vikatouch.VikaTouchApp 20 | MicroEdition-Profile: MIDP-2.0 21 | MIDlet-Jar-URL: vikamobile.jar 22 | MIDlet-Permissions: javax.microedition.io.Connector.http 23 | Nokia-MIDlet-No-Exit: true 24 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/ISocialable.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | /** 4 | * @author Feodor0090 5 | * 6 | */ 7 | // Нужен для объединения разных объектов ВК, умеющих в социалку. Например, в ImagePreview. Пригодится короче. 8 | public interface ISocialable { 9 | public boolean canSave(); // возвращать false например для УЖЕ своиих фото. 10 | 11 | public void save(); // сохранить себе 12 | 13 | public boolean canLike(); // документы - 0 например 14 | 15 | public boolean getLikeStatus(); // лайкнул ли 16 | 17 | public void like(boolean val); // 1 - поставить лайк, 0 - убрать. 18 | 19 | public void send(); // отправить в лс 20 | 21 | public void repost(); // репост. Всё кроме постов - при вызове ничего не делать. 22 | 23 | public boolean commentsAliveable(); // можно ли комментировать 24 | 25 | public void openComments(); // открыть экран комментариев 26 | // public void sendComment(Comment comment); // отправить коммент 27 | } 28 | -------------------------------------------------------------------------------- /src/vikatouch/utils/captcha/CaptchaObject.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils.captcha; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.lcdui.Image; 6 | 7 | import org.json.me.JSONObject; 8 | 9 | import vikatouch.json.JSONBase; 10 | import vikatouch.utils.VikaUtils; 11 | 12 | /** 13 | * @author Shinovon 14 | * 15 | */ 16 | public class CaptchaObject extends JSONBase { 17 | 18 | public String captchasid; 19 | protected String captchaimg; 20 | 21 | public CaptchaObject(JSONObject json) { 22 | this.json = json; 23 | } 24 | 25 | public void parseJSON() { 26 | captchasid = json.optString("captcha_sid"); 27 | captchaimg = fixJSONString(json.optString("captcha_img")); 28 | } 29 | 30 | public Image getImage() { 31 | try { 32 | return VikaUtils.downloadImage(captchaimg); 33 | } catch (InterruptedException e) { 34 | return null; 35 | } catch (IOException e) { 36 | e.printStackTrace(); 37 | return null; 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/utils/DisplayUtils.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.utils; 5 | 6 | import ru.nnproject.vikaui.VikaCanvas; 7 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 8 | 9 | /** 10 | * @author Shinovon 11 | * 12 | */ 13 | public class DisplayUtils { 14 | public static short width; 15 | public static short height; 16 | public static VikaCanvas canvas; 17 | 18 | public static boolean compact; // дисплеи <300 в высоту (е72, альбом 19 | // 240х320, портреты 220 и 208. 20 | 21 | public static boolean verycompact; 22 | public static void checkdisplay() { 23 | if (canvas == null) 24 | return; 25 | width = (short) canvas.getWidth(); 26 | height = (short) canvas.getHeight(); 27 | compact = DisplayUtils.height <= 240; 28 | verycompact = DisplayUtils.height <= 176; 29 | if (compact) 30 | ScrollableCanvas.oneitemheight = 36; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/VikaCanvas.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui; 5 | 6 | import javax.microedition.lcdui.game.GameCanvas; 7 | 8 | import ru.nnproject.vikaui.popup.VikaNotice; 9 | import ru.nnproject.vikaui.screen.VikaScreen; 10 | import vikatouch.VikaTouch; 11 | 12 | /** 13 | * @author Shinovon 14 | * 15 | */ 16 | public abstract class VikaCanvas extends GameCanvas { 17 | 18 | public static VikaNotice currentAlert; 19 | public int fps; 20 | public int realFps; 21 | 22 | protected VikaCanvas() { 23 | super(false); 24 | } 25 | 26 | public abstract void callCommand(int i, VikaScreen scrollableCanvas); 27 | 28 | public abstract boolean isSensorModeOK(); 29 | 30 | public abstract boolean isSensorModeJ2MELoader(); 31 | 32 | public abstract boolean poorScrolling(); 33 | 34 | protected abstract int getFPSLimit(); 35 | 36 | protected abstract boolean drawMaxPriority(); 37 | 38 | public abstract boolean isNight(); 39 | } 40 | -------------------------------------------------------------------------------- /src/vikatouch/items/JSONUIItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items; 2 | 3 | import org.json.me.JSONObject; 4 | 5 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 6 | 7 | /** 8 | * @author Shinovon 9 | * 10 | */ 11 | public abstract class JSONUIItem extends JSONItem implements PressableUIItem { 12 | public JSONUIItem(JSONObject json) { 13 | super(json); 14 | // TODO Auto-generated constructor stub 15 | } 16 | public int itemDrawHeight; 17 | public boolean selected; 18 | 19 | /*public JSONUIItem() { 20 | super(); 21 | } 22 | 23 | public JSONUIItem(JSONObject json) { 24 | super(json); 25 | }*/ 26 | 27 | /*public int getDrawHeight() { 28 | return itemDrawHeight; 29 | } 30 | 31 | public boolean isSelected() { 32 | return super(); 33 | } 34 | 35 | public void setSelected(boolean selected) { 36 | this.selected = selected; 37 | } 38 | 39 | public void setDrawHeight(int i) { 40 | this.itemDrawHeight = i; 41 | } 42 | 43 | public void addDrawHeight(int i) { 44 | this.itemDrawHeight += i; 45 | }*/ 46 | } 47 | -------------------------------------------------------------------------------- /src/vikatouch/items/fm/FolderLoadNextItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.fm; 2 | 3 | import ru.nnproject.vikaui.utils.images.IconsManager; 4 | import vikatouch.locale.TextLocal; 5 | import vikatouch.screens.temp.FileManagerScreen; 6 | 7 | /** 8 | * @author Shinovon 9 | * 10 | */ 11 | public class FolderLoadNextItem extends FolderItem { 12 | 13 | public FolderLoadNextItem(FileManagerScreen fms, String path) { 14 | super(fms, path, TextLocal.inst.get("loadmore")); 15 | } 16 | 17 | 18 | public void tap(int x, int y) { 19 | fms.openFolder(this.path, FileManagerScreen.len - 1); 20 | } 21 | 22 | public void keyPress(int key) { 23 | if(key == -5 || key == -6) { 24 | fms.openFolder(this.path, FileManagerScreen.len - 1); 25 | } 26 | } 27 | 28 | public boolean isImage() { 29 | return false; 30 | } 31 | 32 | public boolean isDirectory() { 33 | return true; 34 | } 35 | 36 | protected int getIcon() { 37 | return IconsManager.REPOST; 38 | } 39 | 40 | protected String getSizeString() { 41 | return ""; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/vikatouch/utils/text/CountUtils.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils.text; 2 | 3 | import vikatouch.locale.TextLocal; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public class CountUtils { 10 | 11 | public static String countStrMessages(int length) { 12 | return countStr("message", length); 13 | } 14 | 15 | public static String countStrViews(int length) { 16 | return countStr("view", length); 17 | } 18 | 19 | public static String countStrMembers(int length) { 20 | return countStr("member", length); 21 | } 22 | 23 | public static String countStr(String x, int length) { 24 | return length + " " + getStr(x, length); 25 | } 26 | 27 | public static String getStr(String x, int a) { 28 | return TextLocal.inst.get("count." + x + getsomehuyna(x, a)); 29 | } 30 | 31 | public static String getsomehuyna(String x, int a) { 32 | a = a % 10; 33 | String x2; 34 | if (a == 1) { 35 | x2 = ""; 36 | } else if (a == 0) { 37 | x2 = "s"; 38 | } else if (a < 5) { 39 | x2 = "sfew"; 40 | } else { 41 | x2 = "s"; 42 | } 43 | return x2; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/vikatouch/items/fm/FolderItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.fm; 2 | 3 | import javax.microedition.io.file.FileConnection; 4 | 5 | import ru.nnproject.vikaui.utils.images.IconsManager; 6 | import vikatouch.screens.temp.FileManagerScreen; 7 | 8 | /** 9 | * @author Shinovon 10 | * 11 | */ 12 | public class FolderItem extends FileManagerItem { 13 | 14 | public FolderItem(FileManagerScreen fms, String path, String name) { 15 | super(fms, path, name, 0); 16 | } 17 | 18 | public FolderItem(FileManagerScreen fms, FileConnection fc) { 19 | super(fms, fc.getPath(), fc.getName(), 0); 20 | } 21 | 22 | public void tap(int x, int y) { 23 | fms.openFolder(this.path, 0); 24 | } 25 | 26 | public void keyPress(int key) { 27 | if(key == -5 || key == -6) { 28 | fms.openFolder(this.path, 0); 29 | } 30 | } 31 | 32 | public boolean isImage() { 33 | return false; 34 | } 35 | 36 | public boolean isDirectory() { 37 | return true; 38 | } 39 | 40 | protected int getIcon() { 41 | return IconsManager.REPOST; 42 | } 43 | 44 | protected String getSizeString() { 45 | return "DIR"; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /langs/formats/US.txt: -------------------------------------------------------------------------------- 1 | #United States 2 | #Authors: 3 | #YYYY.MM.DD 4 | format.version=2020.12.16 5 | 6 | format.time=h:MM TT 7 | format.chatdate=S DD 8 | format.chatdatewyear=O/DD/YEAR 9 | format.shortdatenoyear=N DD 10 | format.shortdate=O/DD/YEAR 11 | format.date=O/DD/YEAR 12 | format.fulldate=O/DD/YEAR h:MM TT 13 | 14 | date.today=today 15 | date.todayat=today at 16 | date.yesterday=yesterday 17 | date.shortmonth.jan=jan 18 | date.shortmonth.feb=feb 19 | date.shortmonth.mar=mar 20 | date.shortmonth.apr=apr 21 | date.shortmonth.may=may 22 | date.shortmonth.jun=jun 23 | date.shortmonth.jul=jul 24 | date.shortmonth.aug=aug 25 | date.shortmonth.sep=sep 26 | date.shortmonth.oct=oct 27 | date.shortmonth.nov=nov 28 | date.shortmonth.dec=deс 29 | date.month.jan=january 30 | date.month.feb=february 31 | date.month.mar=march 32 | date.month.apr=april 33 | date.month.may=may 34 | date.month.jun=june 35 | date.month.jul=july 36 | date.month.aug=august 37 | date.month.sep=september 38 | date.month.oct=october 39 | date.month.nov=november 40 | date.month.dec=december 41 | 42 | date.minutesago=minutes ago 43 | date.hoursago=hours ago 44 | date.justnow=just now 45 | -------------------------------------------------------------------------------- /langs/formats/KZ.txt: -------------------------------------------------------------------------------- 1 | #Russia 2 | #Authors: shinovon 3 | #YYYY.MM.DD 4 | format.version=2020.12.16 5 | 6 | format.time=HH:MM 7 | format.chatdate=DD S 8 | format.chatdatewyear=DD.O.YEAR 9 | format.shortdatenoyear=DD N 10 | format.shortdate=DD.O.YEAR 11 | format.date=YEAR ж. DD N 12 | format.fulldate=HH:MM, YEAR ж. DD N 13 | 14 | date.today=бүгін 15 | date.todayat=бүгін сағат 16 | date.yesterday=кеше 17 | date.shortmonth.jan=қаң 18 | date.shortmonth.feb=ақп 19 | date.shortmonth.mar=нау 20 | date.shortmonth.apr=сәу 21 | date.shortmonth.may=мам 22 | date.shortmonth.jun=мау 23 | date.shortmonth.jul=шіл 24 | date.shortmonth.aug=там 25 | date.shortmonth.sep=қыр 26 | date.shortmonth.oct=қаз 27 | date.shortmonth.nov=қар 28 | date.shortmonth.dec=жел 29 | date.month.jan=қаңтар 30 | date.month.feb=ақпан 31 | date.month.mar=наурыз 32 | date.month.apr=сәуір 33 | date.month.may=мамыр 34 | date.month.jun=маусым 35 | date.month.jul=шілде 36 | date.month.aug=тамыз 37 | date.month.sep=қыркүйек 38 | date.month.oct=қазан 39 | date.month.nov=қараша 40 | date.month.dec=желтоқсан 41 | 42 | date.minutesago=минут бұрын 43 | date.hoursago=сағат бұрын 44 | date.justnow=дәл қазір 45 | -------------------------------------------------------------------------------- /langs/formats/RU.txt: -------------------------------------------------------------------------------- 1 | #Russia 2 | #Authors: shinovon 3 | #YYYY.MM.DD 4 | format.version=2020.12.16 5 | 6 | format.time=H:MM 7 | format.chatdate=DD S 8 | format.chatdatewyear=DD S YEAR 9 | format.shortdatenoyear=DD N 10 | format.shortdate=DD.N.YEAR 11 | format.date=DD N YEAR г. 12 | format.fulldate=DD N YEAR г. в H:MM 13 | 14 | date.today=сегодня 15 | date.todayat=сегодня в 16 | date.yesterday=вчера 17 | date.shortmonth.jan=янв 18 | date.shortmonth.feb=фев 19 | date.shortmonth.mar=мар 20 | date.shortmonth.apr=апр 21 | date.shortmonth.may=мая 22 | date.shortmonth.jun=июн 23 | date.shortmonth.jul=июл 24 | date.shortmonth.aug=авг 25 | date.shortmonth.sep=сен 26 | date.shortmonth.oct=окт 27 | date.shortmonth.nov=ноя 28 | date.shortmonth.dec=дек 29 | date.month.jan=января 30 | date.month.feb=февраля 31 | date.month.mar=марта 32 | date.month.apr=апреля 33 | date.month.may=мая 34 | date.month.jun=июня 35 | date.month.jul=июля 36 | date.month.aug=августа 37 | date.month.sep=сентября 38 | date.month.oct=октября 39 | date.month.nov=ноября 40 | date.month.dec=декабря 41 | 42 | date.minutesago=минут назад 43 | date.hoursago=часов назад 44 | date.justnow=только что 45 | -------------------------------------------------------------------------------- /langs/formats/UA.txt: -------------------------------------------------------------------------------- 1 | #Ukraine 2 | #Authors: Phantom_Horror, shinovon 3 | #YYYY.MM.DD 4 | format.version=2020.12.16 5 | 6 | format.time=H:MM 7 | format.chatdate=DD S 8 | format.chatdatewyear=DD.O.YEAR 9 | format.shortdatenoyear=DD N 10 | format.shortdate=DD.O.YEAR 11 | format.date=DD N YEAR 12 | format.fulldate=DD N YEAR H:MM 13 | 14 | date.today=сьогодні 15 | date.todayat=о 16 | date.yesterday=вчора 17 | date.shortmonth.jan=січ 18 | date.shortmonth.feb=лют 19 | date.shortmonth.mar=бер 20 | date.shortmonth.apr=квіт 21 | date.shortmonth.may=трав 22 | date.shortmonth.jun=чер 23 | date.shortmonth.jul=лип 24 | date.shortmonth.aug=сер 25 | date.shortmonth.sep=вер 26 | date.shortmonth.oct=жов 27 | date.shortmonth.nov=лис 28 | date.shortmonth.dec=груд 29 | date.month.jan=січня 30 | date.month.aug=лютого 31 | date.month.mar=березня 32 | date.month.apr=квітня 33 | date.month.may=травня 34 | date.month.jun=червня 35 | date.month.jul=липня 36 | date.month.aug=серпня 37 | date.month.sep=вересня 38 | date.month.oct=жовтня 39 | date.month.nov=листопада 40 | date.month.dec=грудня 41 | 42 | date.minutesago=хвилин тому 43 | date.hoursago=годин тому 44 | date.justnow=щойно -------------------------------------------------------------------------------- /langs/formats/UK.txt: -------------------------------------------------------------------------------- 1 | #United Kingdom 2 | #Authors: shinovon 3 | #YYYY.MM.DD 4 | format.version=2020.12.16 5 | 6 | format.time=H:MM 7 | format.chatdate=DD S 8 | format.chatdatewyear=DD/O/YEAR 9 | format.shortdatenoyear=DD N 10 | format.shortdate=DD/O/YEAR 11 | format.date=DD N YEAR 12 | format.fulldate=DD/O/YEAR H:MM 13 | 14 | date.today=today 15 | date.todayat=today at 16 | date.yesterday=yesterday 17 | date.shortmonth.jan=jan 18 | date.shortmonth.feb=feb 19 | date.shortmonth.mar=mar 20 | date.shortmonth.apr=apr 21 | date.shortmonth.may=may 22 | date.shortmonth.jun=jun 23 | date.shortmonth.jul=jul 24 | date.shortmonth.aug=aug 25 | date.shortmonth.sep=sep 26 | date.shortmonth.oct=oct 27 | date.shortmonth.nov=nov 28 | date.shortmonth.dec=deс 29 | date.month.jan=january 30 | date.month.feb=february 31 | date.month.mar=march 32 | date.month.apr=april 33 | date.month.may=may 34 | date.month.jun=june 35 | date.month.jul=july 36 | date.month.aug=august 37 | date.month.sep=september 38 | date.month.oct=october 39 | date.month.nov=november 40 | date.month.dec=december 41 | 42 | date.minutesago=minutes ago 43 | date.hoursago=hours ago 44 | date.justnow=just now 45 | -------------------------------------------------------------------------------- /src/vikatouch/items/chat/DateItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.chat; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public final class DateItem extends ChatItem { 10 | // private int width; 11 | // private String stringDate; 12 | 13 | public DateItem(long date) { 14 | 15 | super(null); 16 | /* 17 | * this.date = date; this.itemDrawHeight = 26; this.stringDate = 18 | * VikaUtils.parseShortTime(date); 19 | */ 20 | } 21 | 22 | public void parseJSON() { 23 | 24 | } 25 | 26 | public void paint(Graphics g, int y, int scrolled) { 27 | /* 28 | * Font font = Font.getFont(0, 0, 8); g.setFont(font); 29 | * 30 | * this.width = font.stringWidth(this.stringDate); 31 | * 32 | * if (this.width < 74) { this.width = 74; } else { this.width += 32; } 33 | * if (scrolled < 0) { ColorUtils.setcolor(g, -1); 34 | * g.fillRoundRect((DisplayUtils.width - this.width) / 2, 56, 35 | * this.width, this.itemDrawHeight, 10, 10); } 36 | */ 37 | } 38 | 39 | public void tap(int x, int y) { 40 | 41 | } 42 | 43 | public void keyPress(int key) { 44 | 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /langs/formats/BY.txt: -------------------------------------------------------------------------------- 1 | #Belarus 2 | #Authors: Jazminrocio, shinovon 3 | #YYYY.MM.DD 4 | format.version=2020.12.16 5 | 6 | format.time=HH:MM 7 | format.chatdate=DD S 8 | format.chatdatewyear=DD.O.YEAR 9 | format.shortdatenoyear=DD N 10 | format.shortdate=DD.O.YEAR 11 | format.date=DD.O.YEAR 12 | format.fulldate=DD.O.YEAR HH:MM 13 | 14 | date.today=сёння 15 | date.todayat=у 16 | дата.учора=учора 17 | date.shortmonth.jan=сту 18 | date.shortmonth.feb=лют 19 | date.shortmonth.mar=сак 20 | date.shortmonth.apr=ска 21 | date.shortmonth.may=тра 22 | date.shortmonth.jun=чэр 23 | date.shortmonth.jul=ліп 24 | date.shortmonth.aug=жні 25 | date.shortmonth.sep=вер 26 | date.shortmonth.oct=кас 27 | date.shortmonth.nov=ліс 28 | date.shortmonth.dec=сне 29 | date.month.jan=студзень 30 | date.month.aug=люты 31 | date.month.mar=сакавік 32 | date.month.apr=красавік 33 | date.month.may=травень 34 | date.month.jun=чэрвень 35 | date.month.jul=ліпень 36 | date.month.aug=жнівень 37 | date.month.sep=верасень 38 | date.month.oct=кастрычнік 39 | date.month.nov=лістапад 40 | date.month.dec=снежань 41 | 42 | date.minutesago=Хвілін таму 43 | date.hoursago=Гадзіны таму 44 | date.justnow=Зараз 45 | -------------------------------------------------------------------------------- /langs/formats/ES.txt: -------------------------------------------------------------------------------- 1 | #Spain 2 | #Authors: Jazminrocio, shinovon 3 | #YYYY.MM.DD 4 | format.version=2020.12.19 5 | 6 | format.time=HH:MM 7 | format.chatdate=DD S 8 | format.chatdatewyear=DD/O/YEAR 9 | format.shortdatenoyear=DD N 10 | format.shortdate=DD/O/YEAR 11 | format.date=DD/O/YEAR 12 | format.fulldate=DD/O/YEAR HH:MM 13 | 14 | date.today=hoy 15 | date.todayat=a las 16 | date.yesterday=ayer 17 | date.shortmonth.jan=enero 18 | date.shortmonth.feb=feb 19 | date.shortmonth.mar=mar 20 | date.shortmonth.apr=abr 21 | date.shortmonth.may=may 22 | date.shortmonth.jun=jun 23 | date.shortmonth.jul=jul 24 | date.shortmonth.aug=agosto 25 | date.shortmonth.sep=sep 26 | date.shortmonth.oct=oct 27 | date.shortmonth.nov=nov 28 | date.shortmonth.dec=dic 29 | date.month.jan=enero 30 | date.month.aug=febrero 31 | date.month.mar=marzo 32 | date.month.apr=abril 33 | date.month.may=mayo 34 | date.month.jun=junio 35 | date.month.jul=julio 36 | date.month.aug=agosto 37 | date.month.sep=septiembre 38 | date.month.oct=octubre 39 | date.month.nov=noviembre 40 | date.month.dec=diciembre 41 | 42 | date.minutesago=Hace minutos 43 | date.hoursago=Hace horas 44 | date.justnow=Justo ahora 45 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/screen/VikaScreen.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.screen; 5 | 6 | import javax.microedition.lcdui.Graphics; 7 | import javax.microedition.media.Player; 8 | 9 | import ru.nnproject.vikaui.VikaCanvas; 10 | import ru.nnproject.vikaui.utils.DisplayUtils; 11 | import vikatouch.VikaTouch; 12 | import vikatouch.music.MusicPlayer; 13 | import vikatouch.screens.ChatScreen; 14 | import vikatouch.utils.VikaUtils; 15 | 16 | /** 17 | * @author Shinovon 18 | * 19 | */ 20 | public abstract class VikaScreen { 21 | public abstract void draw(Graphics g); 22 | 23 | public void tap(int x, int y, int time) { 24 | } 25 | 26 | public void drag(int x, int y) { 27 | } 28 | 29 | public void press(int i) { 30 | } 31 | 32 | public void release(int i) { 33 | } 34 | 35 | public void repeat(int i) { 36 | } 37 | 38 | public static void paint(Graphics g) { 39 | } 40 | 41 | public void repaint() { 42 | VikaTouch.needRepaint(); 43 | } 44 | 45 | public void serviceRepaints() { 46 | VikaTouch.needRepaint(); 47 | } 48 | 49 | public void onLeave() { 50 | VikaTouch.needRepaint(); 51 | } 52 | 53 | public boolean scroll(int i) { 54 | return false; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/WallAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.utils.ColorUtils; 7 | import ru.nnproject.vikaui.utils.images.IconsManager; 8 | import vikatouch.VikaTouch; 9 | import vikatouch.locale.TextLocal; 10 | import vikatouch.screens.NewsScreen; 11 | 12 | /** 13 | * @author Shinovon 14 | * 15 | */ 16 | public class WallAttachment extends Attachment { 17 | public void parseJSON() { 18 | this.type = "wall"; 19 | title = TextLocal.inst.get("msg.attach.wall"); 20 | } 21 | 22 | public static String title = ""; 23 | 24 | public int getDrawHeight() { 25 | return 30; 26 | } 27 | 28 | public void press() { 29 | NewsScreen ns = new NewsScreen(); 30 | ns.scrollWithKeys=true; 31 | //ns.newsSource = VikaTouch.integerUserId; 32 | ns.loadAtt(this); 33 | VikaTouch.setDisplay(ns, 1); 34 | } 35 | 36 | public void draw(Graphics g, int x1, int y1, int w) { 37 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 38 | g.fillRect(x1, y1, w, getDrawHeight()); 39 | g.drawImage(IconsManager.ico[IconsManager.NEWS], x1 + 4, y1 + 3, 0); 40 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 41 | Font f = Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_SMALL); 42 | g.setFont(f); 43 | g.drawString(title, x1 + 34, y1 + 15 - f.getHeight() / 2, 0); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/StickerAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.lcdui.Image; 6 | 7 | import vikatouch.utils.VikaUtils; 8 | 9 | /** 10 | * @author Shinovon 11 | * 12 | */ 13 | public class StickerAttachment extends ImageAttachment { 14 | 15 | public int productid; 16 | public int stickerid; 17 | public PhotoSize[] images = new PhotoSize[10]; 18 | 19 | public void parseJSON() { 20 | productid = json.optInt("product_id"); 21 | stickerid = json.optInt("sticker_id"); 22 | images = PhotoSize.parseSizes(json.optJSONArray("images_with_background")); 23 | } 24 | 25 | public Image getPreviewImage() { 26 | return getImg(0); 27 | } 28 | 29 | private Image getImg(int i) { 30 | try { 31 | return VikaUtils.downloadImage(images[i].url); 32 | } catch (Exception e) { 33 | try { 34 | return Image.createImage("/image.png"); 35 | } catch (IOException e1) { 36 | return null; 37 | } 38 | } 39 | } 40 | 41 | public Image getFullImage() { 42 | return getImg(3); 43 | } 44 | 45 | public Image getImage(int height) { 46 | switch (height) { 47 | case 64: { 48 | return getImg(0); 49 | } 50 | case 128: { 51 | return getImg(1); 52 | } 53 | case 256: { 54 | return getImg(2); 55 | } 56 | case 512: { 57 | return getImg(3); 58 | } 59 | default: { 60 | return getPreviewImage(); 61 | } 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/vikatouch/utils/ProfileObject.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils; 2 | 3 | import vikatouch.json.JSONBase; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public class ProfileObject { 10 | 11 | private int id; 12 | private String firstName; 13 | private String lastName; 14 | private String url; 15 | private String online; 16 | 17 | public ProfileObject(int id, String name, String url) { 18 | if(url == null || url.indexOf("camera_50.png") > -1) { 19 | url = null; 20 | } else if(url.indexOf("\\/") > -1) { 21 | url = JSONBase.fixJSONString(url); 22 | } 23 | this.id = id; 24 | this.firstName = name; 25 | this.url = url; 26 | this.online=null; 27 | } 28 | 29 | public ProfileObject(int id, String firstName, String lastName, String url, String online) { 30 | if(url.indexOf("camera_50.png") > -1) { 31 | url = null; 32 | } else if(url.indexOf("\\/") > -1) { 33 | url = JSONBase.fixJSONString(url); 34 | } 35 | this.id = id; 36 | this.firstName = firstName; 37 | this.lastName = lastName; 38 | this.url = url; 39 | this.online=online; 40 | } 41 | 42 | public int getId() { 43 | return id; 44 | } 45 | 46 | public String getName() { 47 | return lastName == null ? firstName : firstName + " " + lastName; 48 | } 49 | 50 | public String getUrl() { 51 | return url == null ? "camera_50" : url; 52 | } 53 | 54 | public String getFirstName() { 55 | return firstName; 56 | } 57 | 58 | public String getOnline() { 59 | return online; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/vikatouch/utils/url/URLBuilder.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils.url; 2 | 3 | import vikatouch.VikaTouch; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public class URLBuilder { 10 | 11 | private String urlString = ""; 12 | private boolean state = false; 13 | 14 | public URLBuilder(String host, String req) { 15 | append(host); 16 | append("/"); 17 | append(req); 18 | } 19 | 20 | public URLBuilder(String method) { 21 | this(method, true); 22 | } 23 | 24 | public URLBuilder(String method, boolean defaultParams) { 25 | this(VikaTouch.API, method, defaultParams); 26 | } 27 | 28 | public URLBuilder(String host, String method, boolean defaultParams) { 29 | append(host); 30 | append("/method/"); 31 | append(method); 32 | if (defaultParams) { 33 | addField("access_token", VikaTouch.accessToken); 34 | addField("v", VikaTouch.API_VERSION); 35 | } 36 | } 37 | 38 | public URLBuilder addField(String param, String value) { 39 | if (!state) 40 | append("?"); 41 | else 42 | append("&"); 43 | state = true; 44 | append(param); 45 | append("="); 46 | append(URLDecoder.encode(value)); 47 | return this; 48 | } 49 | 50 | public URLBuilder append(String string) { 51 | urlString += string; 52 | return this; 53 | } 54 | 55 | public String toString() { 56 | return urlString; 57 | } 58 | 59 | public static final String makeSimpleURL(String method) { 60 | return new URLBuilder(method).toString(); 61 | } 62 | 63 | public URLBuilder addField(String param, int value) { 64 | return addField(param, "" + value); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikatouch/VikaTouchApp.java: -------------------------------------------------------------------------------- 1 | package ru.nnproject.vikatouch; 2 | 3 | import java.util.Hashtable; 4 | 5 | import javax.microedition.midlet.*; 6 | 7 | import vikatouch.Dialogs; 8 | //import vikatouch.NokiaUIInvoker; 9 | import vikatouch.VikaTouch; 10 | import vikatouch.cache.CacheManager; 11 | import vikatouch.screens.ChatScreen; 12 | 13 | /** 14 | * @author Shinovon 15 | * 16 | */ 17 | public final class VikaTouchApp extends MIDlet implements Runnable { 18 | public boolean isPaused; 19 | public boolean started = false; 20 | 21 | public void destroyApp(boolean arg0) { 22 | CacheManager.removeTempImages(); 23 | ChatScreen.stopUpdater(); 24 | VikaTouch.inst.stop(); 25 | Dialogs.stopUpdater(); 26 | this.notifyDestroyed(); 27 | } 28 | 29 | protected void pauseApp() { 30 | isPaused = true; 31 | } 32 | 33 | protected void startApp() { 34 | VikaTouch.mobilePlatform = System.getProperty("microedition.platform"); 35 | isPaused = false; 36 | //if (VikaTouch.a!=0) { 37 | /*try { 38 | VikaTouch.sendLog("started " + String.valueOf(VikaTouch.a)); 39 | } catch (Throwable e) { 40 | 41 | }*/ 42 | //} 43 | if (!started) { 44 | VikaTouch.lastsuccessfullupdatetime=System.currentTimeMillis(); 45 | VikaTouch.a=0; 46 | VikaTouch.supportsTouch=false; 47 | VikaTouch.smilestable=new Hashtable(); 48 | try { 49 | started = true; 50 | VikaTouch.appInst = this; 51 | VikaTouch.inst = new VikaTouch(); 52 | 53 | VikaTouch.inst.start(); 54 | } catch (Throwable e) { 55 | 56 | } 57 | } 58 | 59 | } 60 | 61 | public void run() { 62 | try { 63 | VikaTouch.inst.threadRun(); 64 | } catch (Throwable e) { 65 | e.printStackTrace(); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /src/vikatouch/screens/PhotosScreen.java: -------------------------------------------------------------------------------- 1 | package vikatouch.screens; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | 5 | import ru.nnproject.vikaui.utils.DisplayUtils; 6 | import tube42.lib.imagelib.ImageUtils; 7 | import vikatouch.VikaTouch; 8 | import vikatouch.locale.TextLocal; 9 | import vikatouch.settings.Settings; 10 | 11 | /** 12 | * @author Shinovon 13 | * 14 | */ 15 | public class PhotosScreen extends MainScreen { 16 | private String title; 17 | 18 | public PhotosScreen(int owner, int album) { 19 | VikaTouch.needstoRedraw=true; 20 | title = TextLocal.inst.get("title.photos"); 21 | hasBackButton = true; 22 | } 23 | 24 | public void draw(Graphics g) { 25 | int size = adapt(DisplayUtils.width); 26 | int count = 17; 27 | update(g); 28 | int y = 0; 29 | int z = 0; 30 | int x = 0; 31 | boolean set = false; 32 | for (x = 0; x < count; x++) { 33 | if ((x + 1 - (z * y)) * size <= DisplayUtils.width) { 34 | g.drawImage(ImageUtils.resize(VikaTouch.cameraImg, size, size, !Settings.fastImageScaling, 35 | !Settings.fastImageScaling), (x - (z * y)) * size, topPanelH + y * size, 0); 36 | } else { 37 | if (!set) 38 | z = x; 39 | set = true; 40 | y++; 41 | g.drawImage(ImageUtils.resize(VikaTouch.cameraImg, size, size, !Settings.fastImageScaling, 42 | !Settings.fastImageScaling), (x - (z * y)) * size, topPanelH + y * size, 0); 43 | } 44 | } 45 | listHeight = topPanelH + y * size; 46 | g.translate(0, -g.getTranslateY()); 47 | } 48 | 49 | public static int adapt(int width) { 50 | if (width == 360) { 51 | return 72; 52 | } 53 | if (width == 640 || width == 320) { 54 | return 64; 55 | } 56 | if (width == 240 || width == 480) { 57 | return 48; 58 | } 59 | return 50; 60 | } 61 | 62 | public final void drawHUD(Graphics g) { 63 | drawHUD(g, title); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/vikatouch/items/LoadMoreButtonItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 7 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 8 | import ru.nnproject.vikaui.utils.ColorUtils; 9 | import ru.nnproject.vikaui.utils.DisplayUtils; 10 | import vikatouch.json.INextLoadable; 11 | import vikatouch.locale.TextLocal; 12 | 13 | /** 14 | * @author Feodor0090 15 | * 16 | */ 17 | public class LoadMoreButtonItem implements PressableUIItem { 18 | 19 | public LoadMoreButtonItem(INextLoadable list) { 20 | text = TextLocal.inst.get("loadmore"); 21 | l = list; 22 | // precalcs 23 | f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM); 24 | h = f.getHeight(); 25 | w = f.stringWidth(text); 26 | } 27 | 28 | private INextLoadable l; 29 | private int w; 30 | private int h; 31 | private Font f; 32 | 33 | public boolean selected; 34 | 35 | public static String text = "Загрузить ещё..."; 36 | 37 | public void paint(Graphics g, int y, int scrolled) { 38 | if (ScrollableCanvas.keysMode && selected) { 39 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 40 | g.fillRect(0, y, DisplayUtils.width, 40); 41 | } 42 | ColorUtils.setcolor(g, ColorUtils.TEXT); 43 | g.setFont(f); 44 | g.drawString(text, DisplayUtils.width / 2 - (w / 2), y + (20 - (h / 2)), 0); 45 | } 46 | 47 | public int getDrawHeight() { 48 | return 40; 49 | } 50 | 51 | public void tap(int x, int y) { 52 | l.loadNext(); 53 | } 54 | 55 | public void keyPress(int key) { 56 | if (key == KEY_OK) { 57 | l.loadNext(); 58 | } 59 | } 60 | 61 | public boolean isSelected() { 62 | return selected; 63 | } 64 | 65 | public void setSelected(boolean selected) { 66 | this.selected = selected; 67 | } 68 | 69 | public void addDrawHeight(int i) { 70 | 71 | } 72 | 73 | public void setDrawHeight(int i) { 74 | 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/vikatouch/music/AsyncLoadDataSource.java: -------------------------------------------------------------------------------- 1 | package vikatouch.music; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.media.Control; 6 | import javax.microedition.media.protocol.DataSource; 7 | import javax.microedition.media.protocol.SourceStream; 8 | 9 | import vikatouch.utils.VikaUtils; 10 | import vikatouch.utils.emulatordetect.EmulatorDetector; 11 | 12 | public class AsyncLoadDataSource extends DataSource { 13 | 14 | private SourceStream[] streams = new SourceStream[1]; 15 | private String locator; 16 | private AsyncLoadStream stream; 17 | 18 | public AsyncLoadDataSource(String aLocator) throws IOException { 19 | super(aLocator); 20 | this.locator = aLocator; 21 | stream = new AsyncLoadStream(locator); 22 | streams[0] = stream; 23 | } 24 | 25 | public Control getControl(String controlType) { 26 | return null; 27 | } 28 | 29 | public Control[] getControls() { 30 | return new Control[0]; 31 | } 32 | 33 | public void setListener(AsyncLoadListener l) { 34 | if(stream != null) stream.setListener(l); 35 | } 36 | 37 | public void connect() throws IOException { 38 | VikaUtils.logToFile("connect"); 39 | if(stream == null) { 40 | stream = new AsyncLoadStream(locator); 41 | streams[0] = stream; 42 | } 43 | } 44 | 45 | public void disconnect() { 46 | VikaUtils.logToFile("disconnect"); 47 | try { 48 | stream.deallocate(); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | } 52 | } 53 | 54 | public String getContentType() { 55 | VikaUtils.logToFile("getContentType"); 56 | //return EmulatorDetector.isEmulator && EmulatorDetector.emulatorType == EmulatorDetector.EM_J2L ? "audio/mpeg" : null; 57 | return "audio/mpeg"; 58 | } 59 | 60 | public SourceStream[] getStreams() { 61 | return streams; 62 | } 63 | 64 | public AsyncLoadStream getStream() { 65 | return stream; 66 | } 67 | 68 | public void start() throws IOException { 69 | } 70 | 71 | public void stop() throws IOException { 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/popup/AutoContextMenu.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.popup; 5 | 6 | import javax.microedition.lcdui.Graphics; 7 | 8 | import ru.nnproject.vikaui.VikaCanvas; 9 | import ru.nnproject.vikaui.menu.items.OptionItem; 10 | import ru.nnproject.vikaui.utils.ColorUtils; 11 | import ru.nnproject.vikaui.utils.DisplayUtils; 12 | import vikatouch.VikaTouch; 13 | 14 | /** 15 | * @author Feodor0090 16 | * 17 | */ 18 | public class AutoContextMenu extends ContextMenu { 19 | 20 | public AutoContextMenu(OptionItem[] list) { 21 | super(list); 22 | VikaCanvas.currentAlert = this; 23 | VikaTouch.needstoRedraw=true; 24 | } 25 | 26 | public void draw(Graphics g) { 27 | VikaTouch.needstoRedraw=true; 28 | int dh = DisplayUtils.height; 29 | int itemsH = 16; // margin = 8 30 | int width = Math.min(DisplayUtils.width - 8, 350); 31 | int x = DisplayUtils.width / 2 - width / 2; 32 | for (int i = 0; i < items.length; i++) { 33 | if (items[i] == null) 34 | continue; 35 | items[i].drawX = x + 8; 36 | items[i].fillW = width - 16; 37 | itemsH = itemsH + items[i].getDrawHeight(); 38 | } 39 | 40 | int th = itemsH; 41 | int y = dh / 2 - th / 2; 42 | 43 | if (th > dh - 20) { 44 | int ih = (dh - 20) / items.length; 45 | th = ih * items.length + 16; 46 | for (int i = 0; i < items.length; i++) { 47 | if (items[i] == null) 48 | continue; 49 | items[i].h = ih; 50 | } 51 | } 52 | 53 | // BG 54 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 55 | g.fillRoundRect(x, y, width, th, 16, 16); 56 | // border 57 | g.setStrokeStyle(Graphics.SOLID); 58 | ColorUtils.setcolor(g, ColorUtils.TEXT); 59 | g.drawRoundRect(x, y, width, th, 16, 16); 60 | 61 | int cy = 8 + y; 62 | for (int i = 0; i < items.length; i++) { 63 | if (items[i] == null) 64 | continue; 65 | items[i].paint(g, cy, 0); 66 | cy = cy + items[i].getDrawHeight(); 67 | } 68 | VikaTouch.needstoRedraw=true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /server/update.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/AudioAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.utils.ColorUtils; 7 | import ru.nnproject.vikaui.utils.images.IconsManager; 8 | import vikatouch.VikaTouch; 9 | import vikatouch.music.MusicPlayer; 10 | import vikatouch.screens.music.MusicScreen; 11 | import vikatouch.utils.error.ErrorCodes; 12 | 13 | /** 14 | * @author Feodor0090 15 | * 16 | */ 17 | public class AudioAttachment extends DocumentAttachment { 18 | public AudioAttachment() { 19 | this.type = "audio"; 20 | } 21 | 22 | public String name; 23 | public String url; 24 | public int size; 25 | public String musUrl; 26 | 27 | public void parseJSON() { 28 | try { 29 | name = json.optString("artist") + " " + json.optString("title"); 30 | url = fixJSONString(json.optString("url")); 31 | size = json.optInt("duration"); 32 | if (!json.isNull("url")) { 33 | musUrl = fixJSONString(json.optString("url")); 34 | } 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | VikaTouch.error(e, ErrorCodes.DOCPARSE); 38 | } 39 | 40 | System.gc(); 41 | } 42 | 43 | public int getDrawHeight() { 44 | return 40; 45 | } 46 | 47 | public void draw(Graphics g, int x1, int y1, int w) { 48 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 49 | g.fillRect(x1, y1, w, getDrawHeight()); 50 | g.drawImage(IconsManager.ico[IconsManager.MUSIC], x1 + 4, y1 + 8, 0); 51 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 52 | Font f = Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_SMALL); 53 | g.setFont(f); 54 | if (name != null) 55 | g.drawString(name, x1 + 34, y1 + 10 - f.getHeight() / 2, 0); 56 | ColorUtils.setcolor(g, ColorUtils.TEXT); 57 | f = Font.getFont(0, 0, Font.SIZE_SMALL); 58 | g.setFont(f); 59 | g.drawString(String.valueOf(size) + " sec", x1 + 34, y1 + 30 - f.getHeight() / 2, 0); 60 | } 61 | 62 | public void press() { 63 | // в плеере скачать можно. 64 | MusicScreen ms = new MusicScreen(); 65 | ms.loadAtt(this); 66 | MusicPlayer.launch(ms, 0); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/tube42/lib/imagelib/ImageAnalysisUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of the TUBE42 imagelib, released under the LGPL license. 3 | * 4 | * Development page: https://github.com/tube42/imagelib 5 | * License: http://www.gnu.org/copyleft/lesser.html 6 | */ 7 | 8 | package tube42.lib.imagelib; 9 | 10 | 11 | 12 | import javax.microedition.lcdui.*; 13 | 14 | 15 | /** 16 | * This class contains some functions 17 | * for image analysis 18 | */ 19 | 20 | public final class ImageAnalysisUtils 21 | { 22 | 23 | /** 24 | * Create a histogram over the ARGB component distribution. 25 | * 26 | * Note that this function returns pixel counters, so 27 | * the accumulative total for each component is w * h, not 1.0 28 | */ 29 | public static int [][] getARGBHistogram(Image image) 30 | { 31 | int w = image.getWidth(); 32 | int h = image.getHeight(); 33 | 34 | return getARGBHistogram(image, 0, 0, w, h); 35 | } 36 | 37 | /** 38 | * Create a histogram over the ARGB component distribution 39 | * of selected parts in an image. 40 | * 41 | * Note that this function returns pixel counters, so 42 | * the accumulative total for each component is w * h, not 1.0 43 | */ 44 | public static int [][] getARGBHistogram(Image image, int x, int y, int w, int h) 45 | { 46 | // 1. create initial empty histogram 47 | int [][]ret = new int[4][]; 48 | for(int i = 0; i < ret.length; i++) { 49 | ret[i] = new int[256]; 50 | for(int j = 0; j < 256; j++) ret[i][j] = 0; 51 | } 52 | 53 | // 2. build histogram 54 | int [] buffer = new int[w]; 55 | for(int i = 0; i < h; i++) { 56 | image.getRGB(buffer, 0, w, 0, i, w, 1); 57 | 58 | for(int j = 0; j < w; j++) { 59 | int c = buffer[j]; 60 | 61 | ret[0][(c >> 24) & 0xFF]++; 62 | ret[1][(c >> 16) & 0xFF]++; 63 | ret[2][(c >> 8) & 0xFF]++; 64 | ret[3][(c >> 0) & 0xFF]++; 65 | } 66 | } 67 | 68 | // 3. and we are done 69 | return ret; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/org/json/me/StringWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2002 JSON.org 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | The Software shall be used for Good, not Evil. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | package org.json.me; 26 | 27 | import java.io.IOException; 28 | import java.io.Writer; 29 | 30 | /** 31 | * A simple StringBuffer-based implementation of StringWriter 32 | */ 33 | public class StringWriter extends Writer { 34 | 35 | final private StringBuffer buf; 36 | 37 | public StringWriter() { 38 | super(); 39 | buf = new StringBuffer(); 40 | } 41 | 42 | public StringWriter(int initialSize) { 43 | super(); 44 | buf = new StringBuffer(initialSize); 45 | } 46 | 47 | public void write(char[] cbuf, int off, int len) throws IOException { 48 | buf.append(cbuf, off, len); 49 | } 50 | 51 | public void write(String str) throws IOException { 52 | buf.append(str); 53 | } 54 | 55 | public void write(String str, int off, int len) throws IOException { 56 | buf.append(str.substring(off, len)); 57 | } 58 | 59 | public void flush() throws IOException { 60 | } 61 | 62 | public void close() throws IOException { 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /server/oauthproxy.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vika Touch 2 | Vika Touch это клиент соц. сети "ВКонтакте" для смартфонов с сенсорным экраном и простых "звонилок" на Java ME платформе. 3 | 4 | # Список дел 5 | Глав. меню
6 | Новости
7 | Список диалогов
8 | Чат
9 | Анимация загрузки
10 | Профили
11 | Список документов
12 | Список друзей
13 | Список групп
14 | Страницы групп
15 | Настройки
16 | Возможность ответить на сообщение
17 | Круглые аватарки
18 | Анимации переходов
19 | Предпросмотр фото
20 | Список видео
21 | Нормальные значки
22 | Возможность проигрывать видео
23 | Ссылки в сообщениях
24 | Кинетическая прокрутка
25 | Вложения в посте
26 | Репосты в новостях
27 | Вложения в сообщениях
28 | Локализация
29 | Возможность начать диалог c группой или с человеком в профиле
30 | Стена пользователя
31 | Стена группы
32 | Несколько фотографий в посте
33 | Полная поддержка клавиш
34 | Пересылка сообщений
35 | Музыкальный плеер
36 | Удобная прокрутка на кнопках
37 | Форматы времени для других стран
38 | Подгрузка элементов по мере прокрутки
39 | Больше переводов на разные языки (как минимум 2)
40 | Возможность импортировать языки из памяти телефона
41 | Моя музыка
42 | Мои фото
43 | Уведомления с вибрацией
44 | Встроенный файл-менеджер и возможность загрузки фото и документов
45 | Оптимизация под S40/SE
46 | Редактирование сообщений
47 | Запись и отправка голосовых сообщений
48 | Поиск друзей
49 | Поиск музыки
50 | Поиск пабликов
51 | Подсвечивание упоминаний
52 | Репост в беседе
53 | Действия в беседе (баны, приглашения)
54 | Мгновенная отправка фотографии (Встроенная камера)
55 |
56 | # Исправить 57 | "Error 25. Token confirmation required" в музыке
58 | Багучий файл менеджер
59 |
60 | 61 | # Разработчики 62 | @Shinovon (vk.com/shinovon) Арман Джусупгалиев (Автор)
63 | @Feodor0090 (vk.com/feodor0090) Фёдор Рыжов
64 | @Azreale1997 (vk.com/yrii.belov1997) Юрий Белов
65 | @Computershik73 (vk.com/okabe2011) Илья Высоцкий
66 | -------------------------------------------------------------------------------- /server/tokenproxy.php: -------------------------------------------------------------------------------- 1 | 61 | -------------------------------------------------------------------------------- /src/vikatouch/items/menu/OnOffItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.menu; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.menu.IMenu; 7 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 8 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 9 | import ru.nnproject.vikaui.utils.ColorUtils; 10 | import ru.nnproject.vikaui.utils.DisplayUtils; 11 | import ru.nnproject.vikaui.utils.images.IconsManager; 12 | 13 | /** 14 | * @author Shinovon 15 | * 16 | */ 17 | public class OnOffItem implements PressableUIItem { 18 | 19 | public IMenu menu; 20 | public String text; 21 | public int icon; 22 | public int h; 23 | public int i; 24 | boolean s; 25 | static Font f; 26 | static Font sf; 27 | private boolean bool; 28 | 29 | public OnOffItem(IMenu m, String t, int ic, int i, int h, boolean on) { 30 | this.h = h; 31 | this.i = i; 32 | icon = ic; 33 | text = t; 34 | menu = m; 35 | bool = on; 36 | f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); 37 | sf = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL); 38 | } 39 | 40 | public void paint(Graphics g, int y, int scrolled) { 41 | ColorUtils.setcolor(g, (ScrollableCanvas.keysMode && s) ? ColorUtils.BUTTONCOLOR : ColorUtils.TEXT); 42 | g.setFont((ScrollableCanvas.keysMode && s) ? sf : f); 43 | int x = 48; 44 | if (icon == -1) 45 | x = x - 40; 46 | if (text != null) 47 | g.drawString(text, x, y + ((h / 2) - (((ScrollableCanvas.keysMode && s) ? sf : f).getHeight() / 2)), 0); 48 | String x2 = ""; 49 | if (bool) { 50 | x2 = "ON"; 51 | } else { 52 | x2 = "OFF"; 53 | } 54 | g.drawString(x2, DisplayUtils.width - 16 - g.getFont().stringWidth(x2), 55 | y + ((h / 2) - (((ScrollableCanvas.keysMode && s) ? sf : f).getHeight() / 2)), 0); 56 | if (icon != -1) 57 | g.drawImage(((ScrollableCanvas.keysMode && s) ? (IconsManager.selIco) : (IconsManager.ico))[icon], 12, 58 | y + (h / 2 - 12), 0); 59 | } 60 | 61 | public int getDrawHeight() { 62 | return h; 63 | } 64 | 65 | public void tap(int x, int y) { 66 | bool = !bool; 67 | menu.onMenuItemPress(i); 68 | } 69 | 70 | public void keyPress(int key) { 71 | if (key == KEY_OK) { 72 | bool = !bool; 73 | menu.onMenuItemPress(i); 74 | } 75 | } 76 | 77 | public boolean isSelected() { 78 | return s; 79 | } 80 | 81 | public void setSelected(boolean selected) { 82 | s = selected; 83 | } 84 | 85 | public void addDrawHeight(int i) { 86 | h += i; 87 | } 88 | 89 | public void setDrawHeight(int i) { 90 | h = i; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/menu/items/OptionItem.java: -------------------------------------------------------------------------------- 1 | package ru.nnproject.vikaui.menu.items; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.menu.IMenu; 7 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 8 | import ru.nnproject.vikaui.utils.ColorUtils; 9 | import ru.nnproject.vikaui.utils.images.IconsManager; 10 | import vikatouch.VikaTouch; 11 | 12 | /** 13 | * @author Feodor0090 14 | * 15 | */ 16 | public class OptionItem implements PressableUIItem { 17 | 18 | public IMenu menu; 19 | public String text; 20 | public int icon; 21 | public int h; 22 | public int i; 23 | boolean s; 24 | static Font f; 25 | static Font sf; 26 | 27 | public int drawX; 28 | public int fillW; // for context menu 29 | 30 | public OptionItem(IMenu m, String t, int ic, int i, int h) { 31 | VikaTouch.needstoRedraw=true; 32 | this.h = h; 33 | this.i = i; 34 | icon = ic; 35 | text = t; 36 | menu = m; 37 | // ворчали что слишком крупно. Согласен. Ты кстати тоже, это я медиум 38 | // пихнул, до 39 | // меня смалл был 40 | f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); 41 | sf = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL); 42 | } 43 | 44 | public void paint(Graphics g, int y, int scrolled) { 45 | /* 46 | * if(ScrollableCanvas.keysMode && s) { ColorUtils.setcolor(g, 47 | * ColorUtils.BUTTONCOLOR); g.fillRect(drawX, y, 48 | * fillW==0?DisplayUtils.width:fillW, h); } 49 | */ 50 | VikaTouch.needstoRedraw=true; 51 | ColorUtils.setcolor(g, (ScrollableCanvas.keysMode && s) ? ColorUtils.BUTTONCOLOR : ColorUtils.TEXT); 52 | g.setFont((ScrollableCanvas.keysMode && s) ? sf : f); 53 | int x = drawX + 48; 54 | if (icon == -1) 55 | x = x - 40; 56 | if (text != null) 57 | g.drawString(text, x, y + ((h / 2) - (((ScrollableCanvas.keysMode && s) ? sf : f).getHeight() / 2)), 0); 58 | if (icon != -1) 59 | g.drawImage(((ScrollableCanvas.keysMode && s) ? (IconsManager.selIco) : (IconsManager.ico))[icon], 60 | drawX + 12, y + (h / 2 - 12), 0); 61 | VikaTouch.needstoRedraw=true; 62 | } 63 | 64 | public int getDrawHeight() { 65 | return h; 66 | } 67 | 68 | public void tap(int x, int y) { 69 | menu.onMenuItemPress(i); 70 | } 71 | 72 | public void keyPress(int key) { 73 | if (key == KEY_OK) 74 | menu.onMenuItemPress(i); 75 | } 76 | 77 | public boolean isSelected() { 78 | return s; 79 | } 80 | 81 | public void setSelected(boolean selected) { 82 | VikaTouch.needstoRedraw=true; 83 | s = selected; 84 | } 85 | 86 | public void addDrawHeight(int i) { 87 | h += i; 88 | } 89 | 90 | public void setDrawHeight(int i) { 91 | h = i; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/Attachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import org.json.me.JSONObject; 4 | 5 | import vikatouch.json.JSONBase; 6 | 7 | /** 8 | * @author Shinovon 9 | * 10 | */ 11 | public abstract class Attachment extends JSONBase { 12 | public String type; 13 | public int drawHeight = 0; 14 | 15 | public int getDrawHeight() { 16 | return drawHeight; 17 | } 18 | 19 | public int attNumber; 20 | 21 | // да, для всего. Т.к. кнопка одна, а координаты городить слишком мелко. 22 | public void press() { 23 | } 24 | 25 | public static Attachment parse(JSONObject json) { 26 | 27 | String type = json.optString("type"); 28 | Attachment result = null; 29 | 30 | if (type == null) { 31 | return null; 32 | } 33 | try { 34 | if (type.equals("photo")) { 35 | result = new PhotoAttachment(); 36 | result.json = json.getJSONObject("photo"); 37 | 38 | } else if (type.equals("video")) { 39 | result = new VideoAttachment(); 40 | result.json = json.getJSONObject("video"); 41 | } else if (type.equals("audio")) { 42 | result = new AudioAttachment(); 43 | result.json = json.getJSONObject("audio"); 44 | } else if (type.equals("audio_message")) { 45 | result = new VoiceAttachment(); 46 | result.json = json.getJSONObject("audio_message"); 47 | } else if (type.equals("doc")) { 48 | result = new DocumentAttachment(); 49 | result.json = json.getJSONObject("doc"); 50 | } else if (type.equals("link")) { 51 | result = new LinkAttachment(); 52 | result.json = json.getJSONObject("link"); 53 | } else if (type.equals("market")) { 54 | result = new UnsupportedAttachment(); 55 | } else if (type.equals("market_album")) { 56 | result = new UnsupportedAttachment(); 57 | } else if (type.equals("wall")) { 58 | result = new WallAttachment(); 59 | result.json = json.getJSONObject("wall"); 60 | } else if (type.equals("wall_reply")) { 61 | result = new WallReplyAttachment(); 62 | result.json = json.getJSONObject("wall_reply"); 63 | } else if (type.equals("sticker")) { 64 | result = new StickerAttachment(); 65 | result.json = json.getJSONObject("sticker"); 66 | } else if (type.equals("gift")) { 67 | result = new UnsupportedAttachment(); 68 | // result = new GiftAttachment(); 69 | // result.json = json.getJSONObject("gift"); 70 | } else if (type.equals("widget")) { 71 | result = new WidgetAttachment(); 72 | result.json = json.getJSONObject("widget"); 73 | } 74 | } catch (Exception e) { 75 | if (result == null) { 76 | result = new ErrorAttachment(e.toString()); 77 | } 78 | } 79 | if (result != null) { 80 | result.parseJSON(); 81 | } 82 | return result; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/vikatouch/utils/error/ErrorCodes.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils.error; 2 | 3 | /** 4 | * @author Shinovon 5 | * 6 | */ 7 | public class ErrorCodes 8 | { 9 | //коды ошибок 10 | public static final int MENUIMAGE = 1; 11 | public static final int VIKACANVASPAINT = 2; 12 | public static final int NEWSPARSE = 3; 13 | public static final int NEWSDRAW = 4; 14 | public static final int NEWSPOSTSDRAW = 5; 15 | public static final int MENUAVATAR = 6; 16 | public static final int MENUPROFILEINFO1 = 7; 17 | public static final int MENUPROFILEINFO2 = 8; 18 | public static final int MENUPROFILEINFO3 = 9; 19 | public static final int GROUPSPARSE = 10; 20 | public static final int GROUPSLOAD = 11; 21 | public static final int DOCUMENTSPARSE = 12; 22 | public static final int DOCUMENTSLOAD = 13; 23 | public static final int DOCUMENTSDRAW = 14; 24 | public static final int DOCUMENTSITEMDRAW = 15; 25 | public static final int DOCPREVIEWDRAW = 16; 26 | public static final int GROUPPAGELOAD = 17; 27 | public static final int GROUPPAGEPARSE = 18; 28 | public static final int FRIENDSLOAD = 19; 29 | public static final int FRIENDSPARSE = 20; 30 | public static final int FRIENDSITEMDRAW = 21; 31 | public static final int FRIENDSDRAW = 22; 32 | public static final int DIALOGSITEMDRAW = 23; 33 | public static final int DIALOGSDRAW = 24; 34 | public static final int TOKENLOAD = 25; 35 | public static final int TOKENSAVE = 26; 36 | public static final int GROUPPARSE = 27; 37 | public static final int CONVERPARSE = 28; 38 | public static final int FRIENDPARSE = 29; 39 | public static final int DOCPREVIEWLOAD = 30; 40 | public static final int DOCPARSE = 31; 41 | public static final int POSTTEXT = 32; 42 | public static final int POSTAVAGROUPS = 33; 43 | public static final int POSTAVAPROFILES = 34; 44 | public static final int POSTIMAGE = 35; 45 | public static final int GROUPSITEMDRAW = 36; 46 | public static final int GROUPSDRAW = 37; 47 | public static final int VIDEOSPARSE = 38; 48 | public static final int VIDEOSLOAD = 39; 49 | public static final int VIDEOSDRAW = 40; 50 | public static final int LANGLOAD = 41; 51 | public static final int ICONSLOAD = 42; 52 | public static final int LANGGET = 43; 53 | public static final int SETSSAVE = 44; 54 | public static final int VIDEOPLAY = 45; 55 | public static final int MUSICDRAW = 46; 56 | public static final int MUSICITEMDRAW = 47; 57 | public static final int MUSICLISTPARSE = 48; 58 | public static final int MUSICLISTLOAD = 49; 59 | public static final int LOCALELOAD = 50; 60 | public static final int MENUNOUSERID = 51; 61 | public static final int PLAYLISTSLOAD = 52; 62 | public static final int PLAYLISTSPARSE = 53; 63 | public static final int POINTERRELEASED = 54; 64 | public static final int POINTERPRESSED = 55; 65 | public static final int POINTERDRAGGED = 56; 66 | } 67 | -------------------------------------------------------------------------------- /src/vikatouch/items/JSONItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | 5 | import org.json.me.JSONArray; 6 | import org.json.me.JSONObject; 7 | 8 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 9 | import vikatouch.VikaTouch; 10 | import vikatouch.attachments.Attachment; 11 | import vikatouch.json.JSONBase; 12 | import vikatouch.utils.VikaUtils; 13 | 14 | /** 15 | * @author Shinovon 16 | * 17 | */ 18 | public abstract class JSONItem extends JSONBase implements PressableUIItem { 19 | public int itemDrawHeight; 20 | public boolean selected; 21 | 22 | public JSONItem() { 23 | } 24 | 25 | /*public JSONItem(JSONObject json) { 26 | super(json); 27 | }*/ 28 | 29 | public int getDrawHeight() { 30 | return itemDrawHeight; 31 | } 32 | 33 | public boolean isSelected() { 34 | return selected; 35 | } 36 | 37 | public void setSelected(boolean selected) { 38 | this.selected = selected; 39 | } 40 | 41 | public void setDrawHeight(int i) { 42 | this.itemDrawHeight = i; 43 | } 44 | 45 | public void addDrawHeight(int i) { 46 | this.itemDrawHeight += i; 47 | } 48 | 49 | 50 | public JSONItem(JSONObject json) { 51 | this.json = json; 52 | } 53 | 54 | 55 | 56 | public Attachment[] attachments = new Attachment[15]; 57 | 58 | public int fromid; 59 | public String text; 60 | public long date; 61 | 62 | public void parseJSON() { 63 | if (json == null) { 64 | text = "Ошибка"; 65 | fromid = 0; 66 | date = 0; 67 | VikaTouch.needstoRedraw=true; 68 | VikaTouch.canvas.serviceRepaints(); 69 | return; 70 | } 71 | text = fixJSONString(json.optString("text")); 72 | fromid = json.optInt("from_id"); 73 | date = json.optLong("date"); 74 | VikaTouch.needstoRedraw=true; 75 | VikaTouch.canvas.serviceRepaints(); 76 | } 77 | 78 | protected void parseAttachments() { 79 | try { 80 | if (!json.isNull("attachments")) { 81 | JSONArray attachments = json.optJSONArray("attachments"); 82 | if (this.attachments.length > attachments.length()) { 83 | this.attachments = new Attachment[attachments.length()]; 84 | //setDrawHeight(1); 85 | } 86 | for (int i = 0; i < attachments.length(); i++) { 87 | if (i >= this.attachments.length) { 88 | break; 89 | } 90 | this.attachments[i] = Attachment.parse(attachments.optJSONObject(i)); 91 | addDrawHeight(this.attachments[i].getDrawHeight()); 92 | } 93 | } 94 | } catch (Exception e) { 95 | e.printStackTrace(); 96 | } catch (Throwable e) { 97 | e.printStackTrace(); 98 | } 99 | VikaTouch.needstoRedraw=true; 100 | VikaTouch.canvas.serviceRepaints(); 101 | } 102 | 103 | public String getTime() { 104 | return VikaUtils.parseTime(date); 105 | } 106 | 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/PhotoSize.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import org.json.me.JSONArray; 4 | import org.json.me.JSONObject; 5 | 6 | import vikatouch.json.JSONBase; 7 | 8 | /** 9 | * @author Shinovon 10 | * 11 | */ 12 | public class PhotoSize { 13 | public int height; 14 | public String url; 15 | public String type; 16 | public int width; 17 | 18 | public static PhotoSize[] parseSizes(JSONArray jsonArray) { 19 | PhotoSize[] sizes = new PhotoSize[10]; 20 | if (jsonArray == null) 21 | return sizes; 22 | try { 23 | int len = jsonArray.length(); 24 | for (int i = 0; i < len; i++) { 25 | if (i >= 10) { 26 | break; 27 | } 28 | sizes[i] = parseSize(jsonArray.getJSONObject(i)); 29 | } 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } 33 | return sizes; 34 | } 35 | 36 | public static PhotoSize parseSize(JSONObject jsonObject) { 37 | PhotoSize ps = new PhotoSize(); 38 | ps.height = jsonObject.optInt("height"); 39 | if (!jsonObject.isNull("url")) { 40 | ps.url = JSONBase.fixJSONString(jsonObject.optString("url")); 41 | } else { 42 | ps.url = JSONBase.fixJSONString(jsonObject.optString("src")); 43 | } 44 | ps.type = jsonObject.optString("type"); 45 | ps.width = jsonObject.optInt("width"); 46 | return ps; 47 | } 48 | 49 | public static PhotoSize getSize(PhotoSize[] sizes, String type) { 50 | for (int i = 0; i < sizes.length; i++) { 51 | if (sizes[i] != null && sizes[i].type.equalsIgnoreCase(type)) { 52 | return sizes[i]; 53 | } 54 | } 55 | return null; 56 | } 57 | 58 | public static PhotoSize searchNearestSize(PhotoSize[] sizes, int tW) { 59 | PhotoSize curr = null; 60 | int currD = 0xFFFF; 61 | for (int i = 0; i < sizes.length; i++) { 62 | if (sizes[i] != null) { 63 | int d = Math.abs(tW - sizes[i].width); 64 | if (d < currD) { 65 | currD = d; 66 | curr = sizes[i]; 67 | } 68 | } 69 | } 70 | return curr; 71 | } 72 | 73 | public static PhotoSize searchSmallerSize(PhotoSize[] sizes, int tW) { 74 | PhotoSize curr = null; 75 | int currD = 0xFFFF; 76 | for (int i = 0; i < sizes.length; i++) { 77 | if (sizes[i] != null) { 78 | int d = tW - sizes[i].width; 79 | if (d < 0) 80 | continue; 81 | if (d < currD) { 82 | currD = d; 83 | curr = sizes[i]; 84 | } 85 | } 86 | } 87 | return curr; 88 | } 89 | 90 | public static PhotoSize searchSmallerSizeH(PhotoSize[] sizes, int tH) { 91 | PhotoSize curr = null; 92 | int currD = 0xFFFF; 93 | for (int i = 0; i < sizes.length; i++) { 94 | if (sizes[i] != null) { 95 | int d = tH - sizes[i].height; 96 | if (d < 0) 97 | continue; 98 | if (d < currD) { 99 | currD = d; 100 | curr = sizes[i]; 101 | } 102 | } 103 | } 104 | return curr; 105 | } 106 | } -------------------------------------------------------------------------------- /src/vikatouch/TestUtils.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | import java.io.*; 4 | 5 | public class TestUtils { 6 | public static byte[] read(InputStream is) throws IOException { 7 | int l = is.available(); 8 | byte[] buffer = new byte[l+1]; 9 | int length = 0; 10 | 11 | while ((l = is.read(buffer, length, buffer.length - length)) != -1) { 12 | length += l; 13 | if (length == buffer.length) { 14 | byte[] b = new byte[buffer.length + 4096]; 15 | System.arraycopy(buffer, 0, b, 0, length); 16 | buffer = b; 17 | } 18 | } 19 | 20 | if (length < buffer.length) { 21 | byte[] b = new byte[length]; 22 | System.arraycopy(buffer, 0, b, 0, length); 23 | buffer = b; 24 | } 25 | 26 | return buffer; 27 | } 28 | 29 | static String checkCodeFormat(String code) { 30 | if (code == null) { 31 | return code; 32 | } 33 | if (code.length() == 10) { 34 | String c1 = code.substring(0, 5); 35 | String c2 = code.substring(5); 36 | return c1 + " " + c2; 37 | } else if (code.length() == 6) { 38 | String c1 = code.substring(0, 2); 39 | String c2 = code.substring(2); 40 | return c1 + " " + c2; 41 | } else { 42 | return code; 43 | } 44 | } 45 | 46 | final static int LEAD_OFFSET = 0xD800 - (0x10000 >> 10); 47 | 48 | static String getSurrogatePairs(String inputString) { 49 | int character; 50 | char low, high; 51 | int start = 0, end = 0; 52 | if (inputString == null) { 53 | return inputString; 54 | } 55 | 56 | StringBuffer sb = new StringBuffer(1000); 57 | 58 | // Go through all characters in the input. 59 | // Space (0x20) is used as separator 60 | do { 61 | end = inputString.indexOf(" ", start); 62 | 63 | // Space not found -> last sub-string 64 | if (end == -1) { 65 | end = inputString.length(); 66 | } 67 | 68 | try { 69 | character = Integer.parseInt(inputString.substring(start, end), 16); 70 | } catch (Exception e) { 71 | e.printStackTrace(); 72 | return null; 73 | } 74 | 75 | // Anything below 0xffff is not surrogate pair 76 | if (character < 0xffff) { 77 | sb.append((char) character); 78 | } else { 79 | // From http://www.unicode.org/faq/utf_bom.html 80 | high = (char) (LEAD_OFFSET + (character >> 10)); 81 | low = (char) (0xDC00 + (character & 0x3FF)); 82 | 83 | sb.append(high); 84 | sb.append(low); 85 | } 86 | 87 | // skip the space 88 | start = (end + 1); 89 | } while (end != inputString.length()); 90 | 91 | return sb.toString(); 92 | } 93 | 94 | public static String getEmojiString(String code) { 95 | return getSurrogatePairs(checkCodeFormat(code)); 96 | } 97 | } -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/utils/images/IconsManager.java: -------------------------------------------------------------------------------- 1 | package ru.nnproject.vikaui.utils.images; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.lcdui.*; 6 | 7 | /** 8 | * @author Feodor0090 9 | * 10 | */ 11 | public class IconsManager { 12 | 13 | public static Image[] ico; 14 | public static Image[] selIco; 15 | 16 | public static void Load() throws IOException { 17 | String string = "init"; 18 | try { 19 | string = "icons.png"; 20 | Image sheet = Image.createImage("/icons.png"); 21 | int c /* count */ = sheet.getWidth() / 24; 22 | ico = new Image[c]; 23 | selIco = new Image[c]; 24 | // sheet = Image.createImage(sheet); 25 | string = "crop"; 26 | for (int i = 0; i < c; i++) { 27 | ico[i] = Image.createImage(sheet, i * 24, 0, 24, 24, 0); 28 | // ico[i] = ImageUtils.crop(sheet, i*24, 0, i*24+24, 24); 29 | selIco[i] = Image.createImage(sheet, i * 24, 24, 24, 24, 0); 30 | } 31 | string = "ava.png"; 32 | ac = Image.createImage("/ava.png"); 33 | string = "avas.png"; 34 | acs = Image.createImage("/avas.png"); 35 | string = "avash.png"; 36 | acsh = Image.createImage("/avash.png"); 37 | string = "vikahead.png"; 38 | logoImg = Image.createImage("/vikahead.png"); 39 | string = "back.png"; 40 | backImg = Image.createImage("/back.png"); 41 | //xdImg= Image.createImage("/D83DDE06.png"); 42 | } catch (IOException e) { 43 | e.printStackTrace(); 44 | throw new IOException(string); 45 | } 46 | } 47 | 48 | public static Image ac; 49 | public static Image acs; 50 | public static Image acsh; 51 | public static Image logoImg; 52 | public static Image backImg; 53 | public static Image onlineimg; 54 | // public static Image xdImg; 55 | 56 | public static final int FRIENDS = 0; 57 | public static final int GROUPS = 1; 58 | public static final int PHOTOS = 2; 59 | public static final int VIDEOS = 3; 60 | public static final int MUSIC = 4; 61 | public static final int DOCS = 5; 62 | public static final int CLOSE = 6; 63 | public static final int NEWS = 7; 64 | public static final int MSGS = 8; 65 | public static final int MENU = 9; 66 | public static final int SETTINGS = 10; 67 | public static final int BACK = 11; 68 | public static final int SEARCH = 12; 69 | public static final int OPTIONS = 13; 70 | public static final int APPLY = 14; 71 | public static final int ADD = 15; 72 | public static final int VOICE = 16; 73 | public static final int ATTACHMENT = 17; 74 | public static final int SEND = 18; 75 | public static final int EDIT = 19; 76 | public static final int INFO = 20; 77 | public static final int STICKERS = 21; 78 | public static final int LIKE = 22; 79 | public static final int LIKE_F = 23; 80 | public static final int COMMENTS = 24; 81 | public static final int VIEWS = 25; 82 | public static final int REPOST = 26; 83 | public static final int PIN = 27; 84 | public static final int ANSWER = 28; 85 | public static final int FAV = 29; 86 | public static final int LINK = 30; 87 | public static final int DOWNLOAD = 31; 88 | public static final int REFRESH = 32; 89 | public static final int ANIMATION = 33; 90 | public static final int DEVICE = 34; 91 | public static final int CAMERA = 35; 92 | public static final int PLAY = 36; 93 | public static final int TOPBAR = 37; 94 | } 95 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/DocumentAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.menu.IMenu; 7 | import ru.nnproject.vikaui.menu.items.OptionItem; 8 | import ru.nnproject.vikaui.popup.ContextMenu; 9 | import ru.nnproject.vikaui.utils.ColorUtils; 10 | import ru.nnproject.vikaui.utils.images.IconsManager; 11 | import vikatouch.VikaTouch; 12 | import vikatouch.popup.ImagePreview; 13 | import vikatouch.utils.error.ErrorCodes; 14 | 15 | /** 16 | * @author Shinovon 17 | * 18 | */ 19 | public class DocumentAttachment extends Attachment implements IMenu { 20 | public DocumentAttachment() { 21 | this.type = "doc"; 22 | } 23 | 24 | public String name; 25 | public String url; 26 | public int size; 27 | public String prevImgUrl; 28 | 29 | public void parseJSON() { 30 | try { 31 | name = json.optString("title"); 32 | url = fixJSONString(json.optString("url")); 33 | size = json.optInt("size"); 34 | //ext = json.optString("ext"); 35 | //docType = json.optInt("type"); 36 | 37 | if (!json.isNull("preview")) { 38 | PhotoSize[] prevSizes = PhotoSize 39 | .parseSizes(json.getJSONObject("preview").getJSONObject("photo").getJSONArray("sizes")); 40 | 41 | PhotoSize prevPs = null; 42 | try { 43 | prevPs = PhotoSize.getSize(prevSizes, "x"); 44 | if (prevPs == null) 45 | throw new Exception(); 46 | } catch (Exception e1) { 47 | try { 48 | prevPs = PhotoSize.getSize(prevSizes, "o"); 49 | } catch (Exception e2) { 50 | } 51 | } 52 | if (prevPs != null) 53 | prevImgUrl = fixJSONString(prevPs.url); 54 | } 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | VikaTouch.error(e, ErrorCodes.DOCPARSE); 58 | } 59 | 60 | System.gc(); 61 | } 62 | 63 | public int getDrawHeight() { 64 | return 40; 65 | } 66 | 67 | public void draw(Graphics g, int x1, int y1, int w) { 68 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 69 | g.fillRect(x1, y1, w, getDrawHeight()); 70 | g.drawImage(IconsManager.ico[IconsManager.DOCS], x1 + 4, y1 + 8, 0); 71 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 72 | Font f = Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_SMALL); 73 | g.setFont(f); 74 | if (name != null) 75 | g.drawString(name, x1 + 34, y1 + 10 - f.getHeight() / 2, 0); 76 | ColorUtils.setcolor(g, ColorUtils.TEXT); 77 | f = Font.getFont(0, 0, Font.SIZE_SMALL); 78 | g.setFont(f); 79 | g.drawString(size / 1000 + "kb", x1 + 34, y1 + 30 - f.getHeight() / 2, 0); 80 | } 81 | 82 | public void press() { 83 | OptionItem[] i = new OptionItem[prevImgUrl == null ? 1 : 2]; 84 | i[0] = new OptionItem(this, "Скачать", IconsManager.DOCS, 0, 50); 85 | if (prevImgUrl != null) { 86 | i[1] = new OptionItem(this, "Открыть", IconsManager.PHOTOS, 1, 50); 87 | } 88 | VikaTouch.popup(new ContextMenu(i)); 89 | } 90 | 91 | public void onMenuItemPress(int i) { 92 | if (i == 0) { 93 | try { 94 | VikaTouch.appInst.platformRequest(url); 95 | } catch (Exception e) { 96 | } 97 | } else if (i == 1 && prevImgUrl != null) { 98 | VikaTouch.popup(new ImagePreview(this)); 99 | } 100 | } 101 | 102 | public void onMenuItemOption(int i) { 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/vikatouch/utils/HttpMultipartRequest.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | import java.util.Enumeration; 7 | import java.util.Hashtable; 8 | 9 | import javax.microedition.io.Connector; 10 | import javax.microedition.io.HttpConnection; 11 | 12 | public class HttpMultipartRequest { 13 | 14 | private byte[] aByteArray15 = null; 15 | private String aString16 = null; 16 | 17 | public HttpMultipartRequest(String var1, Hashtable var2, String var3, String var4, String var5, byte[] var6) { 18 | this.aString16 = var1; 19 | var1 = "----------V2ymHFg03ehbqgZCaKO6jy"; 20 | String var7 = getBoundaryMessage("----------V2ymHFg03ehbqgZCaKO6jy", var2, var3, var4, var5); 21 | var1 = "\r\n--" + var1 + "--\r\n"; 22 | ByteArrayOutputStream var8; 23 | try 24 | { 25 | (var8 = new ByteArrayOutputStream()).write(var7.getBytes()); 26 | var8.write(var6); 27 | var8.write(var1.getBytes()); 28 | this.aByteArray15 = var8.toByteArray(); 29 | var8.close(); 30 | }catch(Exception e) 31 | { 32 | 33 | } 34 | } 35 | 36 | private static String getBoundaryMessage(String var0, Hashtable var1, String var2, String var3, String var4) { 37 | StringBuffer var5 = (new StringBuffer("--")).append(var0).append("\r\n"); 38 | Enumeration var6 = var1.keys(); 39 | 40 | while (var6.hasMoreElements()) { 41 | String var7 = (String) var6.nextElement(); 42 | String var8 = (String) var1.get(var7); 43 | var5.append("Content-Disposition: form-data; name=\"").append(var7).append("\"\r\n\r\n").append(var8) 44 | .append("\r\n--").append(var0).append("\r\n"); 45 | } 46 | 47 | var5.append("Content-Disposition: form-data; name=\"").append(var2).append("\"; filename=\"").append(var3) 48 | .append("\"\r\nContent-Type: ").append(var4).append("\r\n\r\n"); 49 | return var5.toString(); 50 | } 51 | 52 | public final byte[] send() { 53 | HttpConnection var1 = null; 54 | InputStream var2 = null; 55 | ByteArrayOutputStream var3 = new ByteArrayOutputStream(); 56 | byte[] var4 = null; 57 | String s = this.aString16; 58 | try { 59 | /* if(vikaMobile.mobilePlatform.indexOf("BlackBerry") == 0) 60 | { 61 | if(vikaMobile.bbIsWifi) 62 | { 63 | s += ";deviceside=true;interface=wifi"; 64 | } 65 | else 66 | { 67 | s += ";deviceside=true"; 68 | } 69 | }*/ 70 | (var1 = (HttpConnection) Connector.open(s)).setRequestProperty("Content-Type", 71 | "multipart/form-data; boundary=----------V2ymHFg03ehbqgZCaKO6jy"); 72 | var1.setRequestMethod("POST"); 73 | OutputStream var5; 74 | (var5 = var1.openOutputStream()).write(this.aByteArray15); 75 | var5.close(); 76 | var2 = var1.openInputStream(); 77 | 78 | int var13; 79 | while ((var13 = var2.read()) != -1) { 80 | var3.write(var13); 81 | } 82 | 83 | var4 = var3.toByteArray(); 84 | } catch (Exception var11) { 85 | var11.printStackTrace(); 86 | } finally { 87 | try { 88 | var3.close(); 89 | if (var2 != null) { 90 | var2.close(); 91 | } 92 | 93 | if (var1 != null) { 94 | var1.close(); 95 | } 96 | } catch (Exception var10) { 97 | var10.printStackTrace(); 98 | } 99 | 100 | } 101 | 102 | return var4; 103 | } 104 | 105 | } -------------------------------------------------------------------------------- /src/vikatouch/items/music/PlaylistItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.music; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | import javax.microedition.lcdui.Image; 6 | 7 | import org.json.me.JSONObject; 8 | 9 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 10 | import ru.nnproject.vikaui.utils.ColorUtils; 11 | import vikatouch.VikaTouch; 12 | import vikatouch.items.JSONItem; 13 | import vikatouch.items.JSONUIItem; 14 | import vikatouch.screens.music.MusicScreen; 15 | import vikatouch.settings.Settings; 16 | import vikatouch.utils.VikaUtils; 17 | 18 | /** 19 | * @author Feodor0090 20 | * 21 | */ 22 | public class PlaylistItem extends JSONItem { 23 | public int id; 24 | public int owner_id; 25 | public String name; 26 | private String iconUrl; 27 | private Image iconImg; 28 | private int size; 29 | private String bigCoverUrl; 30 | 31 | public PlaylistItem(JSONObject json) { 32 | super(json); 33 | setDrawHeight(); 34 | } 35 | 36 | public PlaylistItem(String namee, int sizee, int ownerid, int idd, String iconUrll, String bigCoverUrll) { 37 | name = namee; 38 | size = sizee; 39 | owner_id = ownerid; 40 | id = idd; 41 | iconUrl = iconUrll; 42 | bigCoverUrl = bigCoverUrll; 43 | setDrawHeight(); 44 | } 45 | 46 | public void parseJSON() { 47 | System.out.println(json.toString()); 48 | 49 | try { 50 | name = json.optString("title"); 51 | size = json.optInt("count"); 52 | owner_id = json.optInt("owner_id"); 53 | id = json.optInt("id"); 54 | iconUrl = fixJSONString(json.getJSONObject("photo").optString("photo_135")); 55 | bigCoverUrl = fixJSONString(json.getJSONObject("photo").optString("photo_600")); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | } 59 | 60 | setDrawHeight(); 61 | System.gc(); 62 | } 63 | 64 | private void setDrawHeight() { 65 | itemDrawHeight = 102; 66 | } 67 | 68 | public void paint(Graphics g, int y, int scrolled) { 69 | if (iconImg == null) { 70 | ColorUtils.setcolor(g, 6); 71 | g.fillRect(1, y + 1, 100, 100); 72 | } else { 73 | g.drawImage(iconImg, 1, y + 1, 0); 74 | } 75 | 76 | ColorUtils.setcolor(g, (ScrollableCanvas.keysMode && selected) ? ColorUtils.BUTTONCOLOR : ColorUtils.TEXT); 77 | g.setFont(Font.getFont(0, 0, Font.SIZE_MEDIUM)); 78 | if (name != null) 79 | g.drawString(name, 102, y + 12, 0); 80 | ColorUtils.setcolor(g, ColorUtils.OUTLINE); 81 | g.setFont(Font.getFont(0, 0, Font.SIZE_SMALL)); 82 | g.drawString(size + " аудиозаписей", 102, y + 46, 0); 83 | VikaTouch.needstoRedraw=true; 84 | } 85 | 86 | private Image getIcon() { 87 | Image img = null; 88 | try { 89 | if ((!Settings.dontLoadAvas) && (iconUrl!=null)) 90 | img = VikaUtils.resize(VikaUtils.downloadImage(iconUrl), 100, 100); 91 | } catch (Exception e) { 92 | 93 | } 94 | return img; 95 | } 96 | 97 | public void loadIcon() { 98 | iconImg = getIcon(); 99 | } 100 | 101 | public void open() { 102 | //VikaTouch.sendLog(String.valueOf(id)); 103 | MusicScreen pls = new MusicScreen(); 104 | pls.load(owner_id, id, name); 105 | pls.coverUrl = bigCoverUrl; 106 | VikaTouch.setDisplay(pls, 1); 107 | } 108 | 109 | public void tap(int x, int y) { 110 | open(); 111 | } 112 | 113 | public void keyPress(int key) { 114 | if (key == KEY_OK) { 115 | open(); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/org/json/me/JSONStringer.java: -------------------------------------------------------------------------------- 1 | package org.json.me; 2 | 3 | /* 4 | Copyright (c) 2006 JSON.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | The Software shall be used for Good, not Evil. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | /** 28 | * JSONStringer provides a quick and convenient way of producing JSON text. 29 | * The texts produced strictly conform to JSON syntax rules. No whitespace is 30 | * added, so the results are ready for transmission or storage. Each instance of 31 | * JSONStringer can produce one JSON text. 32 | *

33 | * A JSONStringer instance provides a value method for appending 34 | * values to the 35 | * text, and a key 36 | * method for adding keys before values in objects. There are array 37 | * and endArray methods that make and bound array values, and 38 | * object and endObject methods which make and bound 39 | * object values. All of these methods return the JSONWriter instance, 40 | * permitting cascade style. For example,

41 |  * myString = new JSONStringer()
42 |  *     .object()
43 |  *         .key("JSON")
44 |  *         .value("Hello, World!")
45 |  *     .endObject()
46 |  *     .toString();
which produces the string
47 |  * {"JSON":"Hello, World!"}
48 | *

49 | * The first method called must be array or object. 50 | * There are no methods for adding commas or colons. JSONStringer adds them for 51 | * you. Objects and arrays can be nested up to 20 levels deep. 52 | *

53 | * This can sometimes be easier than using a JSONObject to build a string. 54 | * @author JSON.org 55 | * @version 2 56 | */ 57 | public class JSONStringer extends JSONWriter { 58 | /** 59 | * Make a fresh JSONStringer. It can be used to build one JSON text. 60 | */ 61 | public JSONStringer() { 62 | super(new StringWriter()); 63 | } 64 | 65 | /** 66 | * Return the JSON text. This method is used to obtain the product of the 67 | * JSONStringer instance. It will return null if there was a 68 | * problem in the construction of the JSON text (such as the calls to 69 | * array were not properly balanced with calls to 70 | * endArray). 71 | * @return The JSON text. 72 | */ 73 | public String toString() { 74 | return this.mode == 'd' ? this.writer.toString() : null; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/UIThread.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui; 5 | 6 | import java.io.IOException; 7 | 8 | import javax.microedition.lcdui.Display; 9 | import javax.microedition.media.Manager; 10 | import javax.microedition.media.MediaException; 11 | import javax.microedition.media.Player; 12 | 13 | import vikatouch.VikaTouch; 14 | import vikatouch.settings.Settings; 15 | import vikatouch.utils.VikaUtils; 16 | 17 | /** 18 | * @author Shinovon 19 | * 20 | */ 21 | 22 | // UNUSED 23 | public class UIThread extends Thread { 24 | 25 | private VikaCanvas canvas; 26 | private int frames; 27 | 28 | public UIThread(VikaCanvas canvas) { 29 | super(); 30 | this.canvas = canvas; 31 | if (canvas.drawMaxPriority()) { 32 | // Ставим девятку, что-бы в случае крайней необходимости, интерфейс был в меньшем приоритете. 33 | this.setPriority(9); 34 | } else { 35 | this.setPriority(Thread.NORM_PRIORITY); 36 | } 37 | } 38 | 39 | public void run() { 40 | /*Thread fpsThread = new Thread("FPS-Counter") { 41 | public void run() { 42 | while(true) { 43 | try { 44 | canvas.realFps = frames; 45 | frames = 0; 46 | Thread.yield(); 47 | Thread.sleep(1000); 48 | } catch (Exception e) { 49 | return; 50 | } 51 | } 52 | } 53 | };*/ 54 | //fpsThread.setPriority(Thread.NORM_PRIORITY); 55 | //fpsThread.start(); 56 | while (true) { 57 | 58 | if (System.currentTimeMillis() - VikaTouch.lastsuccessfullupdatetime>(Settings.refreshtimeout * 1000)) { 59 | //VikaTouch.needstoRedraw=true; 60 | VikaTouch.istimeout=true; 61 | //VikaTouch.silenterror("Сети нет более 16 секунд!", false); 62 | //Display d = Display.getDisplay(VikaTouch.appInst); 63 | VikaTouch.needstoRedraw=true; 64 | //d.vibrate(500); 65 | 66 | 67 | /* try { 68 | Thread.sleep(100); 69 | } catch (InterruptedException e) { 70 | // TODO Auto-generated catch block 71 | e.printStackTrace(); 72 | } 73 | d.vibrate(1000); 74 | try { 75 | Thread.sleep(100); 76 | } catch (InterruptedException e) { 77 | // TODO Auto-generated catch block 78 | e.printStackTrace(); 79 | } 80 | d.vibrate(1000);*/ 81 | 82 | /*Player notifplayer; 83 | try { 84 | notifplayer = Manager.createPlayer("device://tone"); 85 | notifplayer.realize(); 86 | notifplayer.start(); 87 | } catch (IOException e) { 88 | // TODO Auto-generated catch block 89 | e.printStackTrace(); 90 | } catch (MediaException e) { 91 | // TODO Auto-generated catch block 92 | e.printStackTrace(); 93 | }*/ 94 | 95 | 96 | } else { 97 | VikaTouch.istimeout=false; 98 | } 99 | long wastedTime = 0; 100 | try { 101 | long i = System.currentTimeMillis(); 102 | //canvas.tick(); 103 | wastedTime = System.currentTimeMillis() - i; 104 | frames++; 105 | canvas.fps = (int) ((1000d - wastedTime) / wastedTime); 106 | //canvas.frametime = (int) wastedTime; 107 | } catch (Throwable e) { 108 | 109 | } 110 | Thread.yield(); 111 | try { 112 | double i = (1000d / (double)canvas.getFPSLimit()); 113 | i -= wastedTime; 114 | if (i < 1) 115 | i = 1; 116 | Thread.sleep((long)i); 117 | } catch (Exception e) { 118 | //fpsThread.interrupt(); 119 | return; 120 | } 121 | } 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/popup/ConfirmBox.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.popup; 5 | 6 | import javax.microedition.lcdui.Font; 7 | import javax.microedition.lcdui.Graphics; 8 | 9 | import ru.nnproject.vikaui.VikaCanvas; 10 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 11 | import ru.nnproject.vikaui.utils.ColorUtils; 12 | import ru.nnproject.vikaui.utils.DisplayUtils; 13 | 14 | /** 15 | * @author Feodor0090 16 | * 17 | */ 18 | public class ConfirmBox extends VikaNotice { 19 | 20 | private String line1; 21 | private String line2; 22 | private Runnable ok; 23 | private Runnable cancel; 24 | private String customYes; 25 | private String customNo; 26 | private String okT; 27 | private String cancT; 28 | 29 | public ConfirmBox(String text, String subtext, Runnable onOk, Runnable onCancel, String customYes, 30 | String customNo) { 31 | line1 = text; 32 | line2 = subtext; 33 | ok = onOk; 34 | cancel = onCancel; 35 | this.customYes = customYes; 36 | this.customNo = customNo; 37 | } 38 | 39 | public void draw(Graphics g) { 40 | int width = Math.min(DisplayUtils.width - 20, 300); 41 | Font f = Font.getFont(0, 0, Font.SIZE_SMALL); 42 | int h1 = f.getHeight(); 43 | int th = h1 * 6; 44 | int y = DisplayUtils.height / 2 - th / 2; 45 | int x = DisplayUtils.width / 2 - width / 2; 46 | 47 | if (customYes != null) 48 | okT = customYes; 49 | if (customNo != null) 50 | cancT = customNo; 51 | 52 | // drawing 53 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 54 | g.fillRoundRect(x, y, width, th, 16, 16); 55 | 56 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 57 | g.fillRoundRect(x + 20, y + h1 * 3, width / 2 - 40, h1 * 2, 30, 30); 58 | g.fillRoundRect(DisplayUtils.width / 2 + 20, y + h1 * 3, width / 2 - 40, h1 * 2, 30, 30); 59 | 60 | g.setFont(f); 61 | g.setStrokeStyle(Graphics.SOLID); 62 | ColorUtils.setcolor(g, ColorUtils.TEXT); 63 | g.drawRoundRect(x, y, width, th, 16, 16); 64 | if (line1 != null) 65 | g.drawString(line1, DisplayUtils.width / 2 - f.stringWidth(line1) / 2, y + h1 / 2, 0); 66 | if (line2 != null) 67 | g.drawString(line2, DisplayUtils.width / 2 - f.stringWidth(line2) / 2, y + h1 + h1 / 2, 0); 68 | ColorUtils.setcolor(g, ColorUtils.BUTTONTEXT); 69 | g.drawString(okT, ((x + 20) + (DisplayUtils.width / 2 - 20)) / 2 - f.stringWidth(okT) / 2, y + h1 * 3 + h1 / 2, 70 | 0); 71 | g.drawString(cancT, ((DisplayUtils.width / 2 + 20) + (DisplayUtils.width / 2 + 20 + (width / 2 - 40))) / 2 72 | - f.stringWidth(cancT) / 2, y + h1 * 3 + h1 / 2, 0); 73 | } 74 | 75 | public void press(int key) { 76 | if (key == PressableUIItem.KEY_OK || key == PressableUIItem.KEY_FUNC) { 77 | VikaCanvas.currentAlert = null; 78 | if (ok != null) 79 | new Thread(ok).start(); 80 | } else if (key == PressableUIItem.KEY_RFUNC || key == PressableUIItem.KEY_BACK) { 81 | VikaCanvas.currentAlert = null; 82 | if (cancel != null) 83 | new Thread(cancel).start(); 84 | } 85 | } 86 | 87 | public void tap(int x, int y, int time) { 88 | int width = Math.min(DisplayUtils.width - 20, 300); 89 | Font f = Font.getFont(0, 0, Font.SIZE_MEDIUM); 90 | int h1 = f.getHeight(); 91 | int th = h1 * 6; 92 | int ry = DisplayUtils.height / 2 - th / 2; 93 | int rx = DisplayUtils.width / 2 - width / 2; // углы диалога 94 | 95 | if (y > ry + h1 * 3 && y < ry + h1 * 5) { 96 | if (x > rx + 20 && x < DisplayUtils.width / 2 - 20) { 97 | press(PressableUIItem.KEY_OK); 98 | } else if (x > DisplayUtils.width / 2 + 20 && x < DisplayUtils.width / 2 + 20 + (width / 2 - 40)) { 99 | press(PressableUIItem.KEY_RFUNC); 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/vikatouch/items/fm/FileManagerItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.fm; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.io.ConnectionNotFoundException; 6 | import javax.microedition.io.file.FileConnection; 7 | import javax.microedition.lcdui.Font; 8 | import javax.microedition.lcdui.Graphics; 9 | 10 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 11 | import ru.nnproject.vikaui.utils.ColorUtils; 12 | import ru.nnproject.vikaui.utils.DisplayUtils; 13 | import ru.nnproject.vikaui.utils.images.IconsManager; 14 | import vikatouch.VikaTouch; 15 | import vikatouch.popup.ImagePreview; 16 | import vikatouch.screens.temp.FileManagerScreen; 17 | 18 | /** 19 | * @author Shinovon 20 | * 21 | */ 22 | public abstract class FileManagerItem implements PressableUIItem { 23 | 24 | protected FileManagerScreen fms; 25 | private boolean selected; 26 | private int drawHeight; 27 | protected String path; 28 | private String displayString; 29 | private int size; 30 | 31 | public FileManagerItem(FileManagerScreen fms, String path, String name, int size) { 32 | this.fms = fms; 33 | this.path = path; 34 | this.displayString = name; 35 | this.size = size; 36 | this.drawHeight = DisplayUtils.compact ? 24 : 50; 37 | } 38 | 39 | public FileManagerItem(FileManagerScreen fms, String path, String name) { 40 | this(fms, path, name, 0); 41 | } 42 | 43 | public FileManagerItem(FileManagerScreen fms, String path) { 44 | this(fms, path, null); 45 | } 46 | 47 | public FileManagerItem(FileManagerScreen fms, FileConnection fc) throws IOException { 48 | this(fms, fc.getPath(), fc.getName(), (int) fc.fileSize()); 49 | } 50 | 51 | public void paint(Graphics g, int y, int scrolled) { 52 | g.setFont(Font.getFont(0, 0, 8)); 53 | ColorUtils.setcolor(g, ColorUtils.TEXT); 54 | g.drawString(displayString, 36, y + 1, 0); 55 | g.drawString(getSizeString() ,DisplayUtils.width - 2 - g.getFont().stringWidth(getSizeString()), y+2, 0); 56 | g.drawImage(IconsManager.ico[getIcon()], 2, y + (drawHeight / 2 - 12), 0); 57 | if(selected) { 58 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 59 | g.drawRect(0, y, DisplayUtils.width-1, drawHeight); 60 | g.drawRect(1, y+1, DisplayUtils.width-3, drawHeight-2); 61 | } 62 | } 63 | 64 | protected int getIcon() { 65 | if(isImage()) { 66 | return IconsManager.PHOTOS; 67 | } else { 68 | return IconsManager.DOCS; 69 | } 70 | } 71 | 72 | public boolean isImage() { 73 | return path.endsWith(".png") || path.endsWith(".jpg") || path.endsWith(".jpeg") || path.endsWith(".gif"); 74 | } 75 | 76 | public int getDrawHeight() { 77 | return this.drawHeight; 78 | } 79 | 80 | public void addDrawHeight(int i) { 81 | this.drawHeight += i; 82 | } 83 | 84 | public void setDrawHeight(int i) { 85 | this.drawHeight = i; 86 | } 87 | 88 | public void tap(int x, int y) { 89 | fms.selected(this); 90 | } 91 | 92 | protected String getSizeString() { 93 | if(size == 0) 94 | return ""; 95 | return size / 1024 + "K"; 96 | } 97 | 98 | public void keyPress(int key) { 99 | if(key == -5) { 100 | if(isImage()) 101 | fms.send(this); 102 | } else if(key == -6) { 103 | if(isImage()) 104 | preview(); 105 | } 106 | } 107 | 108 | protected void preview() { 109 | 110 | VikaTouch.popup(new ImagePreview(this.path, "Фото: ")); 111 | VikaTouch.needstoRedraw=true; 112 | VikaTouch.canvas.repaint(); 113 | 114 | //VikaTouch.appInst.platformRequest(this.path); 115 | } 116 | 117 | public boolean isSelected() { 118 | return selected; 119 | } 120 | 121 | public void setSelected(boolean selected) { 122 | this.selected = selected; 123 | } 124 | 125 | public String getPath() { 126 | return path; 127 | } 128 | 129 | public boolean isDirectory() { 130 | return false; 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/popup/InfoPopup.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.popup; 5 | 6 | import javax.microedition.lcdui.Font; 7 | import javax.microedition.lcdui.Graphics; 8 | 9 | import ru.nnproject.vikaui.VikaCanvas; 10 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 11 | import ru.nnproject.vikaui.utils.ColorUtils; 12 | import ru.nnproject.vikaui.utils.DisplayUtils; 13 | import ru.nnproject.vikaui.utils.text.TextBreaker; 14 | import vikatouch.VikaTouch; 15 | 16 | /** 17 | * @author Feodor0090 18 | * 19 | */ 20 | public class InfoPopup extends VikaNotice { 21 | private String[] lines; 22 | private Runnable ok; 23 | private int linesCount; 24 | private String button; 25 | private String header; 26 | 27 | public InfoPopup(String text, Runnable onOk, String title, String btnText) { 28 | lines = TextBreaker.breakText(text, Font.getFont(0, 0, Font.SIZE_SMALL), 29 | Math.min(DisplayUtils.width - 20, 340) - 60); 30 | ok = onOk; 31 | linesCount = lines.length; 32 | header = title; 33 | button = btnText == null ? "OK" : btnText; 34 | } 35 | 36 | public InfoPopup(String text, Runnable onOk) { 37 | lines = TextBreaker.breakText(text, Font.getFont(0, 0, Font.SIZE_SMALL), 38 | Math.min(DisplayUtils.width - 20, 340) - 60); 39 | ok = onOk; 40 | linesCount = lines.length; 41 | header = null; 42 | button = "OK"; 43 | } 44 | 45 | public void draw(Graphics g) { 46 | int width = Math.min(DisplayUtils.width - 8, 350); 47 | Font f = Font.getFont(0, 0, Font.SIZE_SMALL); 48 | Font hf = Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_MEDIUM); // Header 49 | // Font 50 | int hh = hf.getHeight(); // Header Height 51 | int h1 = f.getHeight(); 52 | int hp = header == null ? 0 : hh + (h1 / 2); // Header Place (сколько он 53 | // занимает) 54 | int th = h1 * 4 + h1 * linesCount + hp; 55 | int y = DisplayUtils.height / 2 - th / 2; 56 | int x = DisplayUtils.width / 2 - width / 2; 57 | int btnW = Math.max(f.stringWidth(button) + 20, 60); 58 | 59 | // drawing 60 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 61 | g.fillRoundRect(x, y, width, th, 16, 16); 62 | 63 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 64 | g.fillRoundRect(DisplayUtils.width / 2 - btnW / 2, y + h1 * (linesCount + 1) + hp, btnW, h1 * 2, 14, 14); // кнопка 65 | if (header != null) { 66 | g.setFont(hf); 67 | g.drawString(header, DisplayUtils.width / 2 - hf.stringWidth(header) / 2, y + h1 / 2, 0); 68 | } 69 | 70 | g.setFont(f); 71 | g.setStrokeStyle(Graphics.SOLID); 72 | ColorUtils.setcolor(g, ColorUtils.TEXT); 73 | g.drawRoundRect(x, y, width, th, 16, 16); // бордер 74 | for (int i = 0; i < linesCount; i++) { 75 | if (lines[i] != null) 76 | g.drawString(lines[i], DisplayUtils.width / 2 - f.stringWidth(lines[i]) / 2, y + hp + h1 / 2 + h1 * i, 77 | 0); 78 | } 79 | ColorUtils.setcolor(g, ColorUtils.BUTTONTEXT); 80 | g.drawString(button, DisplayUtils.width / 2 - f.stringWidth(button) / 2, 81 | y + hp + h1 * (linesCount + 1) + h1 / 2, 0); // кнопка 82 | } 83 | 84 | public void press(int key) { 85 | if (!(key == PressableUIItem.KEY_OK || key == PressableUIItem.KEY_FUNC)) 86 | return; 87 | VikaCanvas.currentAlert = null; 88 | if (ok != null) 89 | new Thread(ok).start(); 90 | VikaTouch.needstoRedraw=true; 91 | } 92 | 93 | public void tap(int x, int y, int time) { 94 | Font f = Font.getFont(0, 0, Font.SIZE_MEDIUM); 95 | int h1 = f.getHeight(); 96 | int th = h1 * 4 + h1 * linesCount; 97 | int ry = DisplayUtils.height / 2 - th / 2; 98 | 99 | if (y > ry + h1 * (linesCount + 1) && y < ry + th - h1) { 100 | if (x > DisplayUtils.width / 2 - 25 && x < DisplayUtils.width / 2 + 25) { 101 | press(PressableUIItem.KEY_OK); 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/vikatouch/screens/AboutScreen.java: -------------------------------------------------------------------------------- 1 | package vikatouch.screens; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 7 | import ru.nnproject.vikaui.utils.ColorUtils; 8 | import ru.nnproject.vikaui.utils.DisplayUtils; 9 | import vikatouch.VikaTouch; 10 | import vikatouch.locale.TextLocal; 11 | 12 | /** 13 | * @author Shinovon 14 | * 15 | */ 16 | public class AboutScreen extends ScrollableCanvas { 17 | 18 | // private static final String[] strings; 19 | /* 20 | * static { strings = new String[]{ "Издатель:", "Ilya Visotsky", "", 21 | * "Разработчики:", "shinovon", "Feodor0090", "", "Бета-тестеры:", 22 | * "nikitashustol", "bodyz", "mishivanov", "alias_omnia", "niceday", "avilolo", 23 | * "linuxoid85", "", }; } 24 | */ 25 | 26 | private static String backStr; 27 | private static String publisherStr; 28 | private static String devsStr; 29 | // private static String teamStr; 30 | private String testersStr; 31 | 32 | public AboutScreen() { 33 | super(); 34 | listHeight = 48 + (16 * 24) + 25; 35 | 36 | backStr = TextLocal.inst.get("back"); 37 | 38 | devsStr = TextLocal.inst.get("about.devs"); 39 | 40 | publisherStr = TextLocal.inst.get("about.vendor"); 41 | 42 | testersStr = TextLocal.inst.get("about.testers"); 43 | VikaTouch.needstoRedraw=true; 44 | VikaTouch.canvas.serviceRepaints(); 45 | // teamStr = TextLocal.inst.get("about.team"); 46 | } 47 | 48 | public void draw(Graphics g) { 49 | update(g); 50 | ColorUtils.setcolor(g, ColorUtils.TEXT); 51 | 52 | g.setFont(Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_LARGE)); 53 | 54 | g.drawString("Vika Mobile", 8, 8, 0); 55 | 56 | g.setFont(Font.getFont(0, 0, Font.SIZE_SMALL)); 57 | 58 | g.drawString("Версия: " + VikaTouch.getVersion(), 59 | Font.getFont(0, 0, Font.SIZE_LARGE).stringWidth("Vika Mobile") + 12, 20, 0); 60 | 61 | g.setFont(Font.getFont(0, 0, Font.SIZE_MEDIUM)); 62 | 63 | /* 64 | * g.drawString("Издатель:", 32, 48, 0); g.drawString("Ilya Visotsky", 32, 72, 65 | * 0); 66 | * 67 | * g.drawString("Разработчик:", 32, 120, 0); g.drawString("shinovon", 32, 144, 68 | * 0); 69 | * 70 | * g.drawString("Разработчик/Бета-тестер:", 32, 192, 0); 71 | * g.drawString("Feodor0090", 32, 216, 0); 72 | */ 73 | // for(int i = 0; i < strings.length; i++) 74 | { 75 | g.drawString("Copyright:", 32, 48, 0); 76 | g.drawString("(c) 2023", 32, 48 + 24, 0); 77 | g.drawString(devsStr, 32, 48 + (3 * 24), 0); 78 | g.drawString("shinovon", 32, 48 + (4 * 24), 0); 79 | g.drawString("Feodor0090", 32, 48 + (5 * 24), 0); 80 | //g.drawString(publisherStr, 32, 48 + (7 * 24), 0); 81 | g.drawString("Ilya Vysotsky", 32, 48 + (6 * 24), 0); 82 | } 83 | 84 | g.translate(0, -g.getTranslateY()); 85 | 86 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 87 | g.fillRect(0, DisplayUtils.height - 25, 640, 25); 88 | 89 | ColorUtils.setcolor(g, ColorUtils.TEXT); 90 | g.drawString(backStr, 0, DisplayUtils.height - 24, 0); 91 | 92 | } 93 | 94 | public void tap(int x, int y, int time) { 95 | if (x < 50 && y > DisplayUtils.height - 30) { 96 | VikaTouch.setDisplay(VikaTouch.setsScr, -1); 97 | VikaTouch.needstoRedraw=true; 98 | VikaTouch.canvas.serviceRepaints(); 99 | } else 100 | super.tap(x, y, time); 101 | } 102 | 103 | public void press(int key) { 104 | if (key == 8 || key == -6) { 105 | VikaTouch.setDisplay(VikaTouch.setsScr, -1); 106 | VikaTouch.needstoRedraw=true; 107 | VikaTouch.canvas.serviceRepaints(); 108 | } else 109 | super.press(key); 110 | } 111 | 112 | protected void scrollHorizontally(int deltaX) { 113 | 114 | } 115 | 116 | public void scrollToSelected() { 117 | 118 | } 119 | 120 | public void selectCentered() { 121 | 122 | } 123 | 124 | protected void keysScroll(int dir) { 125 | 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/vikatouch/SoftNotificationInvoker.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | import com.nokia.mid.ui.SoftNotification; 4 | import com.nokia.mid.ui.SoftNotificationException; 5 | import com.nokia.mid.ui.SoftNotificationListener; 6 | 7 | 8 | /** 9 | * @author Shinovon 10 | * 11 | */ 12 | class SoftNotificationInvoker { 13 | 14 | //private static 15 | 16 | static int softNotification(String groupText, final String text) { 17 | try { 18 | SoftNotification o = SoftNotification.newInstance(); 19 | o.setText(text, groupText); 20 | SoftNotificationListener listener = new SoftNotificationListener() { 21 | 22 | 23 | public void notificationSelected(SoftNotification notification) { 24 | // TODO Auto-generated method stub 25 | 26 | VikaTouch.sendLog("openDialognotificationSelected"); 27 | try { 28 | Integer did = (Integer)VikaTouch.hash.get(new Integer (notification.getId())); 29 | Dialogs.openDialog(did.intValue()); 30 | } catch (Throwable ee) { 31 | VikaTouch.sendLog("didget " + ee.getMessage()); 32 | } 33 | //return; 34 | } 35 | public void notificationDismissed(SoftNotification notification) { 36 | // TODO Auto-generated method stub 37 | //VikaTouch.sendLog("openDialognotificationDismissed"); 38 | //return; 39 | } 40 | 41 | 42 | }; 43 | // if(listener != null) { 44 | o.setListener(listener); 45 | /*(new SoftNotificationListener() { 46 | public void notificationDismissed(SoftNotification notification) { 47 | //listener.closed(notification.getId()); 48 | } 49 | public void notificationSelected(SoftNotification notification) { 50 | //listener.selected(notification.getId()); 51 | } 52 | });*/ 53 | //} 54 | o.post(); 55 | return o.getId(); 56 | } catch (Throwable e) { 57 | e.printStackTrace(); 58 | } 59 | return -1000; 60 | } 61 | 62 | public static int softNotification(int id, String text, final String groupText, SoftNotificationListener listener) { 63 | //try { 64 | 65 | SoftNotification o = SoftNotification.newInstance(VikaTouch.a); 66 | /*try { 67 | o.remove(); 68 | } catch (SoftNotificationException e3) { 69 | // TODO Auto-generated catch block 70 | e3.printStackTrace(); 71 | }*/ 72 | try { 73 | o.setText(text, groupText); 74 | } catch (SoftNotificationException e1) { 75 | // TODO Auto-generated catch block 76 | VikaTouch.sendLog("SetTextSoftNotificationInvokersoftNotification" + e1.getMessage()); 77 | e1.printStackTrace(); 78 | } 79 | //if(listener != null) 80 | o.setListener(listener); 81 | /*(new SoftNotificationListener() { 82 | //int a = 0; 83 | public void notificationDismissed(SoftNotification notification) { 84 | //listener.notificationDismissed(notification); 85 | VikaTouch.sendLog("notification was dismissed"); 86 | } 87 | public void notificationSelected(SoftNotification notification) { 88 | VikaTouch.sendLog("notification was selected"); 89 | Dialogs.openDialog(notification.getId()); 90 | //listener.notificationSelected(notification); 91 | } 92 | });*/ 93 | 94 | try { 95 | o.post(); 96 | } catch (SoftNotificationException e) { 97 | // TODO Auto-generated catch block 98 | VikaTouch.sendLog("PostSoftNotificationInvokersoftNotification" + e.getMessage()); 99 | e.printStackTrace(); 100 | } 101 | try { 102 | VikaTouch.hash.put(new Integer(o.getId()), new Integer(id)); 103 | } catch (Throwable e2) { 104 | VikaTouch.sendLog("hashput" + e2.getMessage()); 105 | return 1; 106 | } 107 | return o.getId(); 108 | /*} catch (Throwable e) { 109 | VikaTouch.sendLog("SoftNotificationInvokersoftNotification" + e.getMessage()); 110 | e.printStackTrace(); 111 | return -1000; 112 | }*/ 113 | 114 | } 115 | 116 | static void init() { 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/vikatouch/utils/ResizeUtils.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | import javax.microedition.lcdui.Image; 5 | 6 | import tube42.lib.imagelib.ImageUtils; 7 | import vikatouch.settings.Settings; 8 | 9 | /** 10 | * @author Shinovon 11 | * 12 | */ 13 | public class ResizeUtils { 14 | 15 | 16 | 17 | public static Image resizeava(Image img) { 18 | short h = (short) img.getHeight(); 19 | short need = h; 20 | /* 21 | * switch(DisplayUtils.idispi) { case DisplayUtils.DISPLAY_E6: case 22 | * DisplayUtils.DISPLAY_PORTRAIT: case DisplayUtils.DISPLAY_ALBUM: { need = 50; 23 | * break; } 24 | * 25 | * case DisplayUtils.DISPLAY_S40: case DisplayUtils.DISPLAY_ASHA311: case 26 | * DisplayUtils.DISPLAY_EQWERTY: { need = 25; break; } 27 | * 28 | * default: { need = 50; break; } } 29 | */ 30 | need = 50; 31 | if (h != need) { 32 | return ImageUtils.resize(img, need, need, !Settings.fastImageScaling, !Settings.fastImageScaling); 33 | // return VikaUtils.resize(img, need, -1); 34 | } 35 | return img; 36 | } 37 | 38 | public static Image resizeChatAva(Image img) { 39 | 40 | short h = (short) img.getHeight(); 41 | short need = h; 42 | /* 43 | * switch(DisplayUtils.idispi) { case DisplayUtils.DISPLAY_E6: case 44 | * DisplayUtils.DISPLAY_PORTRAIT: case DisplayUtils.DISPLAY_ALBUM: { need = 50; 45 | * break; } 46 | * 47 | * case DisplayUtils.DISPLAY_S40: case DisplayUtils.DISPLAY_ASHA311: case 48 | * DisplayUtils.DISPLAY_EQWERTY: { need = 50; break; } 49 | * 50 | * default: { need = 50; break; } } 51 | */ 52 | need = 50; 53 | if (h != need) { 54 | return ImageUtils.resize(img, need, need, !Settings.fastImageScaling, !Settings.fastImageScaling); 55 | // return VikaUtils.resize(img, need, -1); 56 | } 57 | return img; 58 | } 59 | 60 | public static Image prepareForCaching(Image img) { 61 | short w = (short) img.getWidth(); 62 | short h = (short) img.getHeight(); 63 | short need = h; 64 | /* 65 | * if(h == 50) need = 48; 66 | */ 67 | if (h != need) { 68 | short needh = getHeight(w, h, need); 69 | return ImageUtils.resize(img, need, needh, !Settings.fastImageScaling, !Settings.fastImageScaling); 70 | // return VikaUtils.resize(img, need, -1); 71 | } 72 | return img; 73 | } 74 | 75 | private static short getHeight(short w, short h, short need) { 76 | return (short) (need * h / w); 77 | } 78 | 79 | public static Image resizeItemPreview(Image img) { 80 | short w = (short) img.getWidth(); 81 | short h = (short) img.getHeight(); 82 | short need = h; 83 | /* 84 | * switch(DisplayUtils.idispi) { case DisplayUtils.DISPLAY_E6: case 85 | * DisplayUtils.DISPLAY_PORTRAIT: case DisplayUtils.DISPLAY_ALBUM: { need = 48; 86 | * break; } 87 | * 88 | * case DisplayUtils.DISPLAY_S40: case DisplayUtils.DISPLAY_ASHA311: case 89 | * DisplayUtils.DISPLAY_EQWERTY: { need = 48; break; } 90 | * 91 | * case DisplayUtils.DISPLAY_UNDEFINED: default: { need = 48; break; } } 92 | */ 93 | need = 50; 94 | if (h != need) { 95 | short needh = getHeight(w, h, need); 96 | return ImageUtils.resize(img, need, needh, !Settings.fastImageScaling, !Settings.fastImageScaling); 97 | // return VikaUtils.resize(img, need, -1); 98 | } 99 | return img; 100 | } 101 | 102 | public static void drawRectWithEmptyCircleInside(Graphics g, int r, int gg, int b, int x, int y, int radius) { 103 | 104 | //if (Settings.nightTheme) { 105 | // g.setColor(0, 0, 0); 106 | //} else { 107 | g.setColor(r, gg, b); 108 | //} 109 | int xx = x; 110 | int yy = y; 111 | //int i=0; 112 | while (yy<2*radius+y) { 113 | while (xx<2*radius+x) { 114 | 115 | if (((xx-(x+radius))*(xx-(x+radius))+(yy-(y+radius))*(yy-(y+radius)))>radius*radius) { 116 | g.drawLine(xx, yy, xx, yy); 117 | 118 | } 119 | xx++; 120 | } 121 | xx=x; 122 | yy++; 123 | } 124 | xx=x; 125 | yy=y; 126 | } 127 | 128 | 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/vikatouch/utils/text/TextEditor.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils.text; 2 | 3 | import javax.microedition.lcdui.Canvas; 4 | import javax.microedition.lcdui.Command; 5 | import javax.microedition.lcdui.CommandListener; 6 | import javax.microedition.lcdui.Display; 7 | import javax.microedition.lcdui.Displayable; 8 | import javax.microedition.lcdui.Form; 9 | import javax.microedition.lcdui.Image; 10 | import javax.microedition.lcdui.ImageItem; 11 | import javax.microedition.lcdui.TextBox; 12 | import javax.microedition.lcdui.TextField; 13 | 14 | import vikatouch.VikaTouch; 15 | 16 | /** 17 | * @author Shinovon 18 | * 19 | */ 20 | public class TextEditor implements CommandListener { 21 | public String str; 22 | private static TextBox textBox; 23 | private static TextField textField; 24 | private static boolean inputFinished; 25 | private static Displayable screen; 26 | private static final Command ok; 27 | private static final Command cancel; 28 | 29 | TextEditor(final String str) { 30 | this.str = str; 31 | } 32 | 33 | public static String inputString(final String s, final String s2, final int n, final Image image) { 34 | TextEditor.inputFinished = false; 35 | final TextEditor commandListener = new TextEditor(null); 36 | screen = Display.getDisplay(VikaTouch.appInst).getCurrent(); 37 | final Form current = new Form(s); 38 | current.append(new ImageItem((String) null, image, 771, (String) null)); 39 | current.append(TextEditor.textField = new TextField((String) null, s2, (n > 0) ? n : 1024, 0)); 40 | current.addCommand(TextEditor.ok); 41 | current.addCommand(TextEditor.cancel); 42 | current.setCommandListener((CommandListener) commandListener); 43 | VikaTouch.setDisplay((Displayable) current); 44 | VikaTouch.needstoRedraw=true; 45 | VikaTouch.canvas.serviceRepaints(); 46 | while (!TextEditor.inputFinished) { 47 | try { 48 | Thread.yield(); 49 | } catch (Throwable ex) { 50 | } 51 | try { 52 | Thread.sleep(20L); 53 | } catch (Exception ex) { 54 | } 55 | } 56 | return commandListener.str; 57 | } 58 | 59 | public static String inputString(final String s, final String s2, final int n) { 60 | return inputString(s, s2, n, false); 61 | } 62 | 63 | 64 | public static String inputString(final String header, final String preset, final int max, final boolean password) { 65 | TextEditor.inputFinished = false; 66 | final TextEditor commandListener = new TextEditor(preset); 67 | screen = Display.getDisplay(VikaTouch.appInst).getCurrent(); 68 | TextEditor.textBox = new TextBox("", "", (max > 0) ? max : 1024, password ? 65536 : 0); 69 | textBox.setTitle(header); 70 | textBox.setString(preset); 71 | textBox.addCommand(TextEditor.ok); 72 | TextEditor.textBox.setCommandListener((CommandListener) commandListener); 73 | VikaTouch.setDisplay((Displayable) TextEditor.textBox); 74 | while (!TextEditor.inputFinished) { 75 | try { 76 | Thread.yield(); 77 | } catch (Throwable e) { 78 | //e.printStackTrace(); 79 | } 80 | try { 81 | Thread.sleep(20l); 82 | } catch (InterruptedException e) { 83 | //e.printStackTrace(); 84 | } 85 | } 86 | VikaTouch.needstoRedraw=true; 87 | VikaTouch.canvas.serviceRepaints(); 88 | return commandListener.str; 89 | } 90 | 91 | public void commandAction(final Command command, final Displayable displayable) { 92 | if (command == TextEditor.ok) { 93 | if (displayable == TextEditor.textBox) { 94 | this.str = TextEditor.textBox.getString(); 95 | } else { 96 | this.str = TextEditor.textField.getString(); 97 | } 98 | } 99 | VikaTouch.setDisplay(TextEditor.screen); 100 | VikaTouch.appInst.isPaused = false; 101 | if (TextEditor.screen instanceof Canvas) 102 | ((Canvas) TextEditor.screen).setFullScreenMode(true); 103 | TextEditor.textField = null; 104 | TextEditor.textBox = null; 105 | TextEditor.inputFinished = true; 106 | VikaTouch.needstoRedraw=true; 107 | VikaTouch.canvas.serviceRepaints(); 108 | } 109 | 110 | static { 111 | ok = new Command("ОК", 4, 0); 112 | cancel = new Command("Отмена", 1, 1); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/vikatouch/updates/VikaUpdate.java: -------------------------------------------------------------------------------- 1 | package vikatouch.updates; 2 | 3 | import javax.microedition.io.ConnectionNotFoundException; 4 | 5 | import ru.nnproject.vikaui.popup.ConfirmBox; 6 | import ru.nnproject.vikaui.popup.InfoPopup; 7 | import vikatouch.VikaTouch; 8 | import vikatouch.locale.TextLocal; 9 | import vikatouch.utils.VikaUtils; 10 | 11 | /** 12 | * @author Feodor0090 13 | * 14 | */ 15 | public class VikaUpdate { 16 | 17 | public String currVer; 18 | public String newVer; 19 | public String changeLog; 20 | public String url; 21 | 22 | public static VikaUpdate check() 23 | { 24 | VikaTouch.needstoRedraw=true; 25 | int step = 0; 26 | try 27 | { 28 | step = 1; 29 | String ver = VikaUtils.replace(VikaUtils.replace(VikaUtils.download("http://vikamobile.ru:80/vkt/ver.txt"), "\r", ""), "\n", ""); 30 | step = 2; 31 | String[] vers = VEUtils.split(ver, 3, '.'); 32 | step = 3; 33 | String[] cvers = VEUtils.split(VikaTouch.getVersion(), 3, '.'); 34 | step = 4; 35 | //VikaTouch.sendLog("vers: " + vers[0]+ " "+ vers[1]+" "+vers[2]); 36 | //VikaTouch.sendLog("cvers: " + cvers[0]+ " "+ cvers[1]+" "+cvers[2]); 37 | //VikaTouch.sendLog(String.valueOf(vers[0].equals(cvers[0])) + String.valueOf(vers[1].equals(cvers[1])) + vers[2]+"=="+cvers[2]+"="+String.valueOf(vers[2].equals(cvers[2]))); 38 | if(!vers[0].equals(cvers[0]) || Integer.parseInt(vers[1]) > Integer.parseInt(cvers[1]) || Integer.parseInt(vers[2]) > Integer.parseInt(cvers[2])) 39 | { 40 | VikaUpdate vu = new VikaUpdate(); 41 | vu.currVer = VikaTouch.getVersion(); 42 | vu.newVer = ver; 43 | vu.url = "http://vikamobile.ru/vkt/"+ver+".jar"; 44 | vu.changeLog = "http://vikamobile.ru/vkt/"+ver+".jar " + VikaUtils.download("http://vikamobile.ru:80/vkt/cl.txt"); 45 | 46 | return vu; 47 | } 48 | 49 | return null; 50 | } 51 | catch (Throwable t) 52 | { 53 | t.printStackTrace(); 54 | //VikaTouch.sendLog("Updates check: "+t.toString()+" step"+step); 55 | return null; 56 | } 57 | } 58 | 59 | public void ask() 60 | { 61 | VikaTouch.needstoRedraw=true; 62 | VikaTouch.popup(new InfoPopup(TextLocal.inst.get("update.available") + " - "+newVer+"\n"+changeLog, new Runnable() { 63 | public void run () { 64 | VikaTouch.popup(new ConfirmBox(TextLocal.inst.get("update.dl"), "", new Runnable() { 65 | public void run () { 66 | try { 67 | VikaTouch.appInst.platformRequest(url); 68 | } catch (ConnectionNotFoundException e) { 69 | } 70 | } 71 | }, null, TextLocal.inst.get("ok"), TextLocal.inst.get("cancel"))); 72 | } 73 | })); 74 | } 75 | 76 | // кусок виэновских утилит 77 | public static class VEUtils { 78 | 79 | public static String getStr(char[] a, int from, int to) 80 | { 81 | String s = ""; 82 | for(int i = from; (i < to && i < a.length); i++) 83 | { 84 | s += String.valueOf(a[i]); 85 | } 86 | return s; 87 | } 88 | public static String getStr(char[] a, int from, char to) 89 | { 90 | System.out.println("getStr with char ending"); 91 | String s = ""; 92 | for(int i = from; i < a.length; i++) 93 | { 94 | if(to == a[i]) 95 | { 96 | return s; 97 | } 98 | s += String.valueOf(a[i]); 99 | } 100 | return s; 101 | } 102 | public static int findLF(char[] a, int from) 103 | { 104 | for(int i = from; i < a.length; i++) 105 | { 106 | if('\n' == a[i]) return i; 107 | } 108 | return -1; 109 | } 110 | public static String[] singleSplit(String s, char t) 111 | { 112 | String[] a = new String[2]; 113 | int i = s.indexOf(t); 114 | a[0] = s.substring(0, i); 115 | a[1] = s.substring(i+1); 116 | return a; 117 | } 118 | 119 | public static String[] split(String in, int l, char t) 120 | { 121 | String[] res = new String[l]; 122 | String[] c = singleSplit(in, t); 123 | res[0] = c[0]; 124 | for(int i = 1; i < l-1; i++) 125 | { 126 | c = singleSplit(c[1], t); 127 | res[i] = c[0]; 128 | } 129 | res[l-1] = c[1]; 130 | return res; 131 | } 132 | } 133 | 134 | } 135 | -------------------------------------------------------------------------------- /src/vikatouch/utils/url/URLDecoder.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils.url; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | /** 6 | * @author Shinovon 7 | * 8 | */ 9 | public final class URLDecoder { 10 | 11 | public static String encode(String s) { 12 | StringBuffer sbuf = new StringBuffer(); 13 | int len = s.length(); 14 | for (int i = 0; i < len; i++) { 15 | int ch = s.charAt(i); 16 | if ((65 <= ch) && (ch <= 90)) { 17 | sbuf.append((char) ch); 18 | } else if ((97 <= ch) && (ch <= 122)) { 19 | sbuf.append((char) ch); 20 | } else if ((48 <= ch) && (ch <= 57)) { 21 | sbuf.append((char) ch); 22 | } else if (ch == 32) { 23 | // sbuf.append("%20"); 24 | sbuf.append("%20"); 25 | } else if ((ch == 45) || (ch == 95) || (ch == 46) || (ch == 33) || (ch == 126) || (ch == 42) || (ch == 39) 26 | || (ch == 40) || (ch == 41) || (ch == 58) || (ch == 47)) { 27 | sbuf.append((char) ch); 28 | } else if (ch <= 127) { 29 | sbuf.append(hex(ch)); 30 | } else if (ch <= 2047) { 31 | sbuf.append(hex(0xC0 | ch >> 6)); 32 | sbuf.append(hex(0x80 | ch & 0x3F)); 33 | } else { 34 | sbuf.append(hex(0xE0 | ch >> 12)); 35 | sbuf.append(hex(0x80 | ch >> 6 & 0x3F)); 36 | sbuf.append(hex(0x80 | ch & 0x3F)); 37 | } 38 | } 39 | return sbuf.toString(); 40 | } 41 | 42 | public static String encodeFull(String s) { 43 | StringBuffer sbuf = new StringBuffer(); 44 | int len = s.length(); 45 | for (int i = 0; i < len; i++) { 46 | int ch = s.charAt(i); 47 | if ((65 <= ch) && (ch <= 90)) { 48 | sbuf.append((char) ch); 49 | } else if ((97 <= ch) && (ch <= 122)) { 50 | sbuf.append((char) ch); 51 | } else if ((48 <= ch) && (ch <= 57)) { 52 | sbuf.append((char) ch); 53 | } else if (ch == 32) { 54 | // sbuf.append("%20"); 55 | sbuf.append("%20"); 56 | } else if ((ch == 45) || (ch == 95) || (ch == 46) || (ch == 33) || (ch == 126) || (ch == 42) || (ch == 39) 57 | || (ch == 40) || (ch == 41) || (ch == 58) || (ch == 47)) { 58 | sbuf.append(hex(ch)); 59 | //sbuf.append((char) ch); 60 | } else if (ch <= 127) { 61 | sbuf.append(hex(ch)); 62 | } else if (ch <= 2047) { 63 | sbuf.append(hex(0xC0 | ch >> 6)); 64 | sbuf.append(hex(0x80 | ch & 0x3F)); 65 | } else { 66 | sbuf.append(hex(0xE0 | ch >> 12)); 67 | sbuf.append(hex(0x80 | ch >> 6 & 0x3F)); 68 | sbuf.append(hex(0x80 | ch & 0x3F)); 69 | } 70 | } 71 | return sbuf.toString(); 72 | } 73 | 74 | private static String hex(int ch) { 75 | String x = Integer.toHexString(ch); 76 | return "%" + (x.length() == 1 ? "0" : "") + x; 77 | } 78 | 79 | public static String decode(String s) throws UnsupportedEncodingException { 80 | String enc = "UTF-8"; 81 | int i = 0; 82 | int j = s.length(); 83 | StringBuffer sb = new StringBuffer(j > 500 ? j / 2 : j); 84 | int k = 0; 85 | if (enc.length() == 0) { 86 | throw new UnsupportedEncodingException("URLDecoder: empty string enc parameter"); 87 | } 88 | byte[] arrayOfByte = null; 89 | while (k < j) { 90 | char c = s.charAt(k); 91 | switch (c) { 92 | case '+': 93 | sb.append(' '); 94 | k++; 95 | i = 1; 96 | break; 97 | case '%': 98 | try { 99 | if (arrayOfByte == null) { 100 | arrayOfByte = new byte[(j - k) / 3]; 101 | } 102 | int m = 0; 103 | while ((k + 2 < j) && (c == '%')) { 104 | arrayOfByte[(m++)] = ((byte) Integer.parseInt(s.substring(k + 1, k + 3), 16)); 105 | k += 3; 106 | if (k < j) { 107 | c = s.charAt(k); 108 | } 109 | } 110 | if ((k < j) && (c == '%')) { 111 | throw new IllegalArgumentException("URLDecoder: Incomplete trailing escape (%) pattern"); 112 | } 113 | sb.append(new String(arrayOfByte, 0, m, enc)); 114 | } catch (NumberFormatException localNumberFormatException) { 115 | throw new IllegalArgumentException("URLDecoder: Illegal hex characters in escape (%) pattern - " 116 | + localNumberFormatException.getMessage()); 117 | } 118 | i = 1; 119 | break; 120 | default: 121 | sb.append(c); 122 | k++; 123 | } 124 | } 125 | return i != 0 ? sb.toString() : s; 126 | } 127 | } -------------------------------------------------------------------------------- /src/vikatouch/items/menu/GroupItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.menu; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.lcdui.Graphics; 6 | import javax.microedition.lcdui.Image; 7 | 8 | import org.json.me.JSONObject; 9 | 10 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 11 | import ru.nnproject.vikaui.utils.ColorUtils; 12 | import ru.nnproject.vikaui.utils.DisplayUtils; 13 | import ru.nnproject.vikaui.utils.images.IconsManager; 14 | import vikatouch.VikaTouch; 15 | import vikatouch.items.JSONItem; 16 | import vikatouch.items.JSONUIItem; 17 | import vikatouch.screens.menu.GroupsScreen; 18 | import vikatouch.screens.page.GroupPageScreen; 19 | import vikatouch.settings.Settings; 20 | import vikatouch.utils.ResizeUtils; 21 | import vikatouch.utils.VikaUtils; 22 | import vikatouch.utils.error.ErrorCodes; 23 | 24 | /** 25 | * @author Shinovon 26 | * 27 | */ 28 | public class GroupItem extends JSONItem { 29 | 30 | private String name; 31 | // private String link; 32 | private int id; 33 | private Image ava = null; 34 | private int members; 35 | private boolean isAdmin; 36 | 37 | public static final int BORDER = 1; 38 | 39 | public GroupItem(JSONObject json) { 40 | super(json); 41 | itemDrawHeight = 50; 42 | ava = VikaTouch.cameraImg; 43 | VikaTouch.needstoRedraw=true; 44 | VikaTouch.canvas.serviceRepaints(); 45 | name = ""; 46 | id = 0; 47 | isAdmin = false; 48 | members = 0; 49 | } 50 | 51 | public void parseJSON() { 52 | try { 53 | name = json.optString("name"); 54 | // link = json.optString("screen_name"); 55 | id = json.optInt("id"); 56 | isAdmin = json.optInt("is_admin") == 1; 57 | members = json.optInt("members_count"); 58 | } catch (Throwable e) { 59 | e.printStackTrace(); 60 | VikaTouch.error(e, ErrorCodes.GROUPPARSE); 61 | } 62 | 63 | setDrawHeight(); 64 | 65 | System.gc(); 66 | } 67 | 68 | private void setDrawHeight() { 69 | /* 70 | * switch(DisplayUtils.idispi) { case DisplayUtils.DISPLAY_S40: case 71 | * DisplayUtils.DISPLAY_ASHA311: case DisplayUtils.DISPLAY_EQWERTY: { 72 | * itemDrawHeight = 25; break; } case DisplayUtils.DISPLAY_PORTRAIT: 73 | * case DisplayUtils.DISPLAY_ALBUM: case DisplayUtils.DISPLAY_E6: 74 | * default: { itemDrawHeight = 48; break; } } 75 | */ 76 | itemDrawHeight = 50; 77 | itemDrawHeight += BORDER * 2; 78 | } 79 | 80 | public void getAva() { 81 | try { 82 | if (!Settings.dontLoadAvas) 83 | ava = ResizeUtils.resizeItemPreview(VikaUtils.downloadImage(fixJSONString(json.optString("photo_50")), true)); 84 | VikaTouch.needstoRedraw=true; 85 | VikaTouch.canvas.serviceRepaints(); 86 | } catch (InterruptedException e) { 87 | return; 88 | } catch (IOException e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | 93 | public void paint(Graphics g, int y, int scrolled) { 94 | try { 95 | int tx = 4; 96 | if (ava != null) { 97 | g.drawImage(ava, 14, y + BORDER, 0); 98 | if (!Settings.nightTheme) { 99 | ResizeUtils.drawRectWithEmptyCircleInside(g, 255, 255, 255, 14, y + BORDER, 25); 100 | } else { 101 | ResizeUtils.drawRectWithEmptyCircleInside(g, 0, 0, 0, 14, y + BORDER, 25); 102 | } 103 | //g.drawImage(IconsManager.ac, 14, y + BORDER, 0); 104 | tx = 73; 105 | } 106 | 107 | ColorUtils.setcolor(g, ColorUtils.TEXT); 108 | if (ScrollableCanvas.keysMode && selected) { 109 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 110 | g.drawRect(0, y, DisplayUtils.width - 1, itemDrawHeight); 111 | g.drawRect(1, y + 1, DisplayUtils.width - 3, itemDrawHeight - 2); 112 | } 113 | if (name != null) 114 | g.drawString(name, tx, y, 0); 115 | ColorUtils.setcolor(g, ColorUtils.OUTLINE); 116 | String descrS = (isAdmin ? "Администрирование, " : "") 117 | + (members > 9999 ? ((members / 1000) + "K участников") : (members + " участников")); 118 | g.drawString(descrS, tx, y + 24, 0); 119 | } catch (Throwable e) { 120 | 121 | } 122 | 123 | } 124 | 125 | public void tap(int x, int y) { 126 | try { 127 | GroupsScreen.abortLoading(); 128 | VikaTouch.setDisplay(new GroupPageScreen(id), 1); 129 | } catch (Exception e) { 130 | 131 | } 132 | } 133 | 134 | public void keyPress(int key) { 135 | if (key == KEY_OK) 136 | tap(20, 20); 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/vikatouch/screens/temp/SplashScreen.java: -------------------------------------------------------------------------------- 1 | package vikatouch.screens.temp; 2 | 3 | import java.util.Random; 4 | 5 | import javax.microedition.lcdui.Font; 6 | import javax.microedition.lcdui.Graphics; 7 | import javax.microedition.lcdui.Image; 8 | 9 | import ru.nnproject.vikaui.utils.ColorUtils; 10 | import ru.nnproject.vikaui.utils.DisplayUtils; 11 | import ru.nnproject.vikaui.utils.text.TextBreaker; 12 | import vikatouch.VikaTouch; 13 | import vikatouch.locale.TextLocal; 14 | import vikatouch.screens.MainScreen; 15 | 16 | /** 17 | * @author Feodor0090 18 | * 19 | */ 20 | public class SplashScreen extends MainScreen { 21 | private Image logo; 22 | private String header; 23 | 24 | public static int currState = 0; // до 7 25 | 26 | private final int[] statesProgress = new int[] { 0, 5, 10, 20, 40, 60, 80, 100 }; 27 | private String[] statesNames = new String[] { "Starting application", "Loading settings", "Loading text tables", 28 | "Preparing assets", "Autorization", "Loading profile data", "Pre-loading conversations", "Ready." }; 29 | private String tipStr = "Tip"; 30 | private String[] tip; 31 | private int tipL; 32 | 33 | public SplashScreen() { 34 | super(); 35 | VikaTouch.needstoRedraw=true; 36 | try { 37 | logo = Image.createImage("/vika256.png"); 38 | } catch (Exception e) { 39 | logo = Image.createImage(1, 1); 40 | } 41 | 42 | header = "ViKa Mobile v" + VikaTouch.getVersion(); 43 | } 44 | 45 | public void draw(Graphics g) { 46 | int dw = DisplayUtils.width; 47 | int dh = DisplayUtils.height; 48 | int hdw = dw / 2; 49 | Font f = Font.getFont(0, 0, Font.SIZE_MEDIUM); 50 | g.setFont(f); 51 | int sy = (dh - (260 + 20 + 4 + f.getHeight() * 2)) / 2; 52 | if (dh >= 360) { 53 | try { 54 | g.drawImage(logo, hdw - 128, sy, 0); 55 | ColorUtils.setcolor(g, ColorUtils.TEXT); 56 | g.drawString(header, hdw - f.stringWidth(header) / 2, sy + 260, 0); 57 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 58 | g.fillRect(40, sy + 260 + f.getHeight() + 4, dw - 80, 16); 59 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 60 | g.fillRect(42, sy + 260 + f.getHeight() + 4 + 2, dw - 84, 12); 61 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 62 | g.fillRect(43, sy + 260 + f.getHeight() + 4 + 3, (dw - 86) * statesProgress[currState] / 100, 10); 63 | ColorUtils.setcolor(g, ColorUtils.TEXT); 64 | g.drawString(statesNames[currState], hdw, sy + 260 + f.getHeight() + 4 + 20, 65 | Graphics.TOP | Graphics.HCENTER); 66 | 67 | // Подсказка 68 | if (tip != null && dh > 450) // толку то, всё равно не влазит. 69 | { 70 | g.drawString(tipStr, hdw - f.stringWidth(tipStr) / 2, sy + 260 + f.getHeight() * 3 + 20 + 4, 0); 71 | f = Font.getFont(0, 0, Font.SIZE_SMALL); 72 | g.setFont(f); 73 | for (int i = 0; i < tipL; i++) { 74 | g.drawString(tip[i], hdw, sy + 260 + 24 + f.getHeight() * (i + 5), 75 | Graphics.TOP | Graphics.HCENTER); 76 | } 77 | } 78 | } catch (Throwable e) { 79 | e.printStackTrace(); 80 | } 81 | } else { 82 | try { 83 | if (logo != null) 84 | g.drawImage(logo, hdw - 128, dh / 2 - 128, 0); 85 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 86 | g.fillRect(40, dh - 18, dw - 80, 16); 87 | g.setGrayScale(255); 88 | g.fillRect(42, dh - 16, dw - 84, 12); 89 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 90 | g.fillRect(43, dh - 15, (dw - 86) * statesProgress[currState] / 100, 10); 91 | } catch (Throwable ee) {} 92 | } 93 | } 94 | 95 | public void setText() { 96 | try { 97 | for (int i = 3; i <= 7; i++) { 98 | statesNames[i] = TextLocal.inst.get("splash.title." + i); 99 | } 100 | tipStr = TextLocal.inst.get("splash.tip"); 101 | int tipsC = Integer.parseInt(TextLocal.inst.get("langinfo.hints")); 102 | Random r = new Random(); 103 | int i = r.nextInt(tipsC); 104 | tip = TextBreaker.breakText(TextLocal.inst.get("splash.tip." + i), Font.getFont(0, 0, Font.SIZE_SMALL), 105 | DisplayUtils.width - 40); 106 | tipL = tip.length; 107 | } catch (Throwable e) { 108 | e.printStackTrace(); 109 | } 110 | } 111 | 112 | public void drawHUD(Graphics g) { 113 | } 114 | 115 | public final void release(int x, int y) { 116 | 117 | } 118 | 119 | public void disp() { 120 | logo = null; 121 | statesNames = null; 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /server/kl.php: -------------------------------------------------------------------------------- 1 | 99 | -------------------------------------------------------------------------------- /src/vikatouch/items/menu/FriendItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.menu; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.lcdui.Graphics; 6 | import javax.microedition.lcdui.Image; 7 | 8 | import org.json.me.JSONException; 9 | import org.json.me.JSONObject; 10 | 11 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 12 | import ru.nnproject.vikaui.utils.ColorUtils; 13 | import ru.nnproject.vikaui.utils.DisplayUtils; 14 | import ru.nnproject.vikaui.utils.images.IconsManager; 15 | import vikatouch.VikaTouch; 16 | import vikatouch.items.JSONItem; 17 | import vikatouch.items.JSONUIItem; 18 | import vikatouch.screens.page.ProfilePageScreen; 19 | import vikatouch.settings.Settings; 20 | import vikatouch.utils.ResizeUtils; 21 | import vikatouch.utils.VikaUtils; 22 | import vikatouch.utils.error.ErrorCodes; 23 | 24 | /** 25 | * @author Shinovon 26 | * 27 | */ 28 | public class FriendItem extends JSONItem { 29 | private String name; 30 | // private String link; 31 | private int id; 32 | private Image ava = null; 33 | // private int lastSeen; 34 | private boolean online; 35 | private String city; 36 | private int yrsOld; 37 | 38 | public static final int BORDER = 1; 39 | 40 | public FriendItem(JSONObject json) { 41 | super(json); 42 | itemDrawHeight = 52; 43 | ava = VikaTouch.cameraImg; 44 | } 45 | 46 | public void parseJSON() { 47 | try { 48 | name = json.optString("first_name") + " " + json.optString("last_name"); 49 | // link = json.optString("domain"); 50 | id = json.optInt("id"); 51 | /* 52 | * try { lastSeen = json.getJSONObject("last_seen").optInt("time"); 53 | * } catch (Exception e) { 54 | * 55 | * } 56 | */ 57 | try { 58 | city = json.getJSONObject("city").optString("title"); 59 | } catch (Throwable e) { 60 | 61 | } 62 | online = json.optInt("online") == 1; 63 | /* 64 | * try { ava = 65 | * VikaUtils.downloadImage(fixJSONString(json.optString("photo_50")) 66 | * ); switch(DisplayUtils.idispi) { case DisplayUtils.DISPLAY_S40: 67 | * case DisplayUtils.DISPLAY_ASHA311: case 68 | * DisplayUtils.DISPLAY_EQWERTY: { ava = ResizeUtils.resizeava(ava); 69 | * break; } default: break; } } catch (Exception e) { 70 | * System.out.println("Юзер "+link+": ошибка аватарки"); 71 | * //System.out.println(json.toString()); } 72 | */ 73 | } catch (Throwable e) { 74 | e.printStackTrace(); 75 | VikaTouch.error(e, ErrorCodes.FRIENDPARSE); 76 | } 77 | 78 | setDrawHeight(); 79 | 80 | System.gc(); 81 | } 82 | 83 | private void setDrawHeight() { 84 | itemDrawHeight = 52; 85 | } 86 | 87 | public int getDrawHeight() { 88 | return itemDrawHeight; 89 | } 90 | 91 | public void getAva() { 92 | try { 93 | if (!Settings.dontLoadAvas) 94 | ava = ResizeUtils.resizeItemPreview(VikaUtils.downloadImage(fixJSONString(json.optString("photo_50")), true)); 95 | } catch (InterruptedException e) { 96 | 97 | } catch (IOException e) { 98 | e.printStackTrace(); 99 | } 100 | } 101 | 102 | public void paint(Graphics g, int y, int scrolled) { 103 | int tx = 4; 104 | if (ava != null) { 105 | g.drawImage(ava, 14, y + BORDER, 0); 106 | if (!Settings.nightTheme) { 107 | ResizeUtils.drawRectWithEmptyCircleInside(g, 255, 255, 255, 14, y + BORDER, 25); 108 | } else { 109 | ResizeUtils.drawRectWithEmptyCircleInside(g, 0, 0, 0, 14, y + BORDER, 25); 110 | } 111 | //g.drawImage(IconsManager.ac, 14, y + BORDER, 0); 112 | if (online) { 113 | ColorUtils.setcolor(g, ColorUtils.ONLINE); 114 | g.fillArc(52, y + itemDrawHeight - 16, 11, 11, 0, 360); 115 | } 116 | tx = 73; 117 | } 118 | ColorUtils.setcolor(g, ColorUtils.TEXT); 119 | 120 | if (ScrollableCanvas.keysMode && selected) { 121 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 122 | g.drawRect(0, y, DisplayUtils.width - 1, itemDrawHeight); 123 | g.drawRect(1, y + 1, DisplayUtils.width - 3, itemDrawHeight - 2); 124 | } 125 | if (name != null) 126 | g.drawString(name, tx, y, 0); 127 | String descrS = city != null ? city : yrsOld != 0 ? yrsOld + " лет" : ""; 128 | if (descrS != "" && descrS != null) { 129 | g.drawString(descrS, tx, y + 24, 0); 130 | } 131 | } 132 | 133 | public void tap(int x, int y) { 134 | try { 135 | VikaTouch.setDisplay(new ProfilePageScreen(id), 1); 136 | } catch (Exception e) { 137 | e.printStackTrace(); 138 | } 139 | } 140 | 141 | public void keyPress(int key) { 142 | if (key == KEY_OK) 143 | tap(20, 20); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/vikatouch/items/menu/MemberItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.menu; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.lcdui.Graphics; 6 | import javax.microedition.lcdui.Image; 7 | 8 | import org.json.me.JSONArray; 9 | import org.json.me.JSONObject; 10 | 11 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 12 | import ru.nnproject.vikaui.utils.ColorUtils; 13 | import ru.nnproject.vikaui.utils.DisplayUtils; 14 | import ru.nnproject.vikaui.utils.images.IconsManager; 15 | import vikatouch.VikaTouch; 16 | import vikatouch.items.JSONItem; 17 | import vikatouch.items.JSONUIItem; 18 | import vikatouch.screens.page.GroupPageScreen; 19 | import vikatouch.screens.page.ProfilePageScreen; 20 | import vikatouch.settings.Settings; 21 | import vikatouch.utils.ResizeUtils; 22 | import vikatouch.utils.VikaUtils; 23 | 24 | /** 25 | * @author Shinovon 26 | * 27 | */ 28 | public class MemberItem extends JSONItem { 29 | private String name; 30 | // private String link; 31 | private int id; 32 | private Image ava = null; 33 | // private int lastSeen; 34 | private boolean online; 35 | private JSONArray profiles; 36 | private String avaurl; 37 | private JSONArray groups; 38 | 39 | public static final int BORDER = 1; 40 | 41 | public MemberItem(int id, JSONArray profiles, JSONArray groups) { 42 | super(null); 43 | this.profiles = profiles; 44 | itemDrawHeight = 52; 45 | ava = VikaTouch.cameraImg; 46 | this.id = id; 47 | name = "id" + id; 48 | this.groups = groups; 49 | } 50 | 51 | public void parseJSON() { 52 | if (id < 0 && groups != null) { 53 | for (int i = 0; i < groups.length(); i++) { 54 | try { 55 | if (groups.getJSONObject(i).getInt("id") == -id) { 56 | JSONObject json = groups.getJSONObject(i); 57 | name = json.optString("name"); 58 | if (!Settings.dontLoadAvas) 59 | avaurl = fixJSONString(json.optString("photo_50")); 60 | break; 61 | } 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | } 66 | } else { 67 | for (int i = 0; i < profiles.length(); i++) { 68 | try { 69 | if (profiles.getJSONObject(i).getInt("id") == id) { 70 | JSONObject json = profiles.getJSONObject(i); 71 | name = json.optString("first_name") + " " + json.optString("last_name"); 72 | online = json.optInt("online") == 1; 73 | if (!Settings.dontLoadAvas) 74 | avaurl = fixJSONString(json.optString("photo_50")); 75 | break; 76 | } 77 | } catch (Exception e) { 78 | e.printStackTrace(); 79 | } 80 | } 81 | } 82 | setDrawHeight(); 83 | } 84 | 85 | private void setDrawHeight() { 86 | itemDrawHeight = 52; 87 | } 88 | 89 | public int getDrawHeight() { 90 | return itemDrawHeight; 91 | } 92 | 93 | public void getAva() { 94 | try { 95 | if (!Settings.dontLoadAvas) 96 | ava = ResizeUtils.resizeItemPreview(VikaUtils.downloadImage(avaurl, true)); 97 | } catch (InterruptedException e) { 98 | } catch (IOException e) { 99 | e.printStackTrace(); 100 | } 101 | } 102 | 103 | public void paint(Graphics g, int y, int scrolled) { 104 | ColorUtils.setcolor(g, ColorUtils.TEXT); 105 | int tx = 4; 106 | if (ava != null) { 107 | g.drawImage(ava, 14, y + BORDER, 0); 108 | if (!Settings.nightTheme) { 109 | ResizeUtils.drawRectWithEmptyCircleInside(g, 255, 255, 255, 14, y + BORDER, 25); 110 | } else { 111 | ResizeUtils.drawRectWithEmptyCircleInside(g, 0, 0, 0, 14, y + BORDER, 25); 112 | } 113 | //g.drawImage(IconsManager.ac, 14, y + BORDER, 0); 114 | if (online) { 115 | ColorUtils.setcolor(g, ColorUtils.ONLINE); 116 | g.fillArc(52, y + itemDrawHeight - 16, 11, 11, 0, 360); 117 | } 118 | tx = 73; 119 | } 120 | if (ScrollableCanvas.keysMode && selected) { 121 | ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 122 | g.drawRect(0, y, DisplayUtils.width - 1, itemDrawHeight); 123 | g.drawRect(1, y + 1, DisplayUtils.width - 3, itemDrawHeight - 2); 124 | } 125 | if (name != null) 126 | g.drawString(name, tx, y, 0); 127 | } 128 | 129 | public void tap(int x, int y) { 130 | if (id < 0) { 131 | try { 132 | VikaTouch.setDisplay(new GroupPageScreen(-id), 1); 133 | } catch (Exception e) { 134 | e.printStackTrace(); 135 | } 136 | } else { 137 | try { 138 | VikaTouch.setDisplay(new ProfilePageScreen(id), 1); 139 | } catch (Exception e) { 140 | e.printStackTrace(); 141 | } 142 | } 143 | } 144 | 145 | public void keyPress(int key) { 146 | if (key == KEY_OK) 147 | tap(20, 20); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/VideoAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Image; 5 | 6 | import org.json.me.JSONObject; 7 | 8 | import ru.nnproject.vikaui.utils.DisplayUtils; 9 | import vikatouch.VikaTouch; 10 | import vikatouch.items.chat.CommentItem; 11 | import vikatouch.items.chat.MsgItem; 12 | import vikatouch.items.menu.VideoItem; 13 | import vikatouch.utils.VikaUtils; 14 | import vikatouch.utils.url.URLBuilder; 15 | 16 | /** 17 | * @author Feodor0090 18 | * 19 | */ 20 | public class VideoAttachment extends ImageAttachment { 21 | public VideoAttachment() { 22 | this.type = "video"; 23 | } 24 | 25 | public int albumid; 26 | public long ownerid; 27 | public int userid = 100; 28 | public int id; 29 | public String key; 30 | public int origwidth; 31 | public int origheight; 32 | public PhotoSize[] sizes = new PhotoSize[10]; 33 | public String title; 34 | 35 | // for msg 36 | public int renderH; 37 | public int renderW; 38 | public Image renderImg = null; 39 | public String previewurl; 40 | 41 | public void parseJSON() { 42 | // VikaUtils.logToFile(json.toString()); 43 | //sizes = PhotoSize.parseSizes(json.optJSONArray("image")); 44 | origwidth = json.optInt("width"); 45 | origheight = json.optInt("height"); 46 | id = json.optInt("id"); 47 | key = json.optString("access_key"); 48 | ownerid = json.optInt("owner_id"); 49 | albumid = json.optInt("album_id"); 50 | userid = json.optInt("user_id"); 51 | title = json.optString("title"); 52 | } 53 | 54 | public PhotoSize getMessageImage() { 55 | //return PhotoSize.searchSmallerSize(sizes, 56 | // Math.min((int) (DisplayUtils.width * 0.6), MsgItem.msgWidth - MsgItem.attMargin * 2)); 57 | return PhotoSize.searchNearestSize(sizes, 58 | Math.min((int) (DisplayUtils.width), MsgItem.msgWidth - MsgItem.attMargin * 2)); 59 | } 60 | 61 | public void loadForMessage() { 62 | try { 63 | //PhotoSize ps = getMessageImage(); 64 | previewurl = fixJSONString(json.optString("photo_320")); 65 | Image i = VikaUtils.downloadImage(previewurl); 66 | 67 | 68 | int w = Math.min((int) (DisplayUtils.width * 0.6), MsgItem.msgWidth - MsgItem.attMargin * 2); 69 | if (i.getWidth() > w) { 70 | i = VikaUtils.resize(i, w, -1); 71 | } 72 | 73 | renderH = i.getHeight(); 74 | renderW = i.getWidth(); 75 | renderImg = i; 76 | } catch (Exception e) { 77 | e.printStackTrace(); 78 | } 79 | } 80 | 81 | public PhotoSize getCommentImage() { 82 | return PhotoSize.searchSmallerSize(sizes, 83 | Math.min((int) (DisplayUtils.width * 0.6), CommentItem.msgWidth - CommentItem.attMargin * 2)); 84 | } 85 | 86 | public void loadForComment() { 87 | try { 88 | //PhotoSize ps = getMessageImage(); 89 | previewurl = fixJSONString(json.optString("photo_320")); 90 | Image i = VikaUtils.downloadImage(previewurl); 91 | int w = Math.min((int) (DisplayUtils.width * 0.6), CommentItem.msgWidth - CommentItem.attMargin * 2); 92 | if (i.getWidth() > w) { 93 | i = VikaUtils.resize(i, w, -1); 94 | } 95 | 96 | renderH = i.getHeight(); 97 | renderW = i.getWidth(); 98 | renderImg = i; 99 | } catch (Exception e) { 100 | e.printStackTrace(); 101 | } 102 | } 103 | 104 | public void loadForNews() { 105 | try { 106 | previewurl = fixJSONString(json.optString("photo_320")); 107 | //PhotoSize ps = PhotoSize.searchSmallerSize(sizes, DisplayUtils.width); 108 | Image i = VikaUtils.downloadImage(previewurl); 109 | renderH = i.getHeight(); 110 | renderW = i.getWidth(); 111 | renderImg = i; 112 | } catch (Exception e) { 113 | e.printStackTrace(); 114 | } 115 | } 116 | 117 | public int getDrawHeight() { 118 | return renderH + Font.getFont(0, 0, 8).getHeight(); 119 | } 120 | 121 | public void press() { 122 | try { 123 | String x = VikaUtils.download(new URLBuilder("video.get").addField("videos", 124 | String.valueOf(ownerid) + "_" + id + (key == null ? "" : ("_" + key)))); 125 | JSONObject r = new JSONObject(x).getJSONObject("response").getJSONArray("items").getJSONObject(0); 126 | VideoItem i = new VideoItem(r); 127 | i.parseJSON(); 128 | i.keyPress(-5); 129 | } catch (Exception e) { 130 | VikaTouch.sendLog("Video att press: " + e.toString()); 131 | } 132 | } 133 | 134 | public Image getPreviewImage() { 135 | return null; 136 | } 137 | 138 | public Image getFullImage() { 139 | return null; 140 | } 141 | 142 | public Image getImage(int height) { 143 | return null; 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /src/vikatouch/items/music/AudioTrackItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.items.music; 2 | 3 | import javax.microedition.lcdui.Graphics; 4 | import javax.microedition.media.Manager; 5 | 6 | import org.json.me.JSONObject; 7 | 8 | import ru.nnproject.vikaui.menu.items.UIItem; 9 | import ru.nnproject.vikaui.popup.InfoPopup; 10 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 11 | import ru.nnproject.vikaui.utils.ColorUtils; 12 | import ru.nnproject.vikaui.utils.DisplayUtils; 13 | import ru.nnproject.vikaui.utils.images.IconsManager; 14 | import vikatouch.VikaTouch; 15 | import vikatouch.items.JSONItem; 16 | import vikatouch.items.JSONUIItem; 17 | import vikatouch.music.MusicPlayer; 18 | import vikatouch.screens.music.MusicScreen; 19 | 20 | /** 21 | * @author Feodor0090 22 | * 23 | */ 24 | public class AudioTrackItem extends JSONItem implements UIItem { 25 | public int id; 26 | public int owner_id; 27 | public String name; 28 | public String artist; // исполнтель, ну, вторая строка 29 | public int length; 30 | public String lengthS; 31 | public MusicScreen playlist; 32 | public int indexInPL; 33 | public String mp3; 34 | 35 | public AudioTrackItem() { 36 | id = 0; 37 | owner_id = 0; 38 | name = ""; 39 | artist = ""; 40 | length = 5; 41 | lengthS = "null"; 42 | playlist = null; 43 | mp3 = ""; 44 | } 45 | 46 | public AudioTrackItem(JSONObject json, MusicScreen s, int i) { 47 | super(json); 48 | setDrawHeight(); 49 | playlist = s; 50 | indexInPL = i; 51 | } 52 | 53 | public void parseJSON() { 54 | setDrawHeight(); 55 | if (json == null) 56 | return; 57 | 58 | try { 59 | name = json.optString("title").intern(); 60 | artist = json.optString("artist").intern(); 61 | id = json.optInt("id"); 62 | owner_id = json.optInt("owner_id"); 63 | length = json.optInt("duration"); 64 | lengthS = (length / 60) + ":" + (length % 60 < 10 ? "0" : "") + (length % 60); 65 | mp3 = json.optString("url", ""); 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | } 69 | 70 | disposeJson(); 71 | 72 | System.gc(); 73 | } 74 | 75 | private void setDrawHeight() { 76 | itemDrawHeight = 50; 77 | } 78 | 79 | public void paint(Graphics g, int y, int scrolled) { 80 | if (y + scrolled + itemDrawHeight < -50) 81 | return; 82 | // g.setFont(Font.getFont(0, 0, Font.SIZE_SMALL)); 83 | ColorUtils.setcolor(g, (ScrollableCanvas.keysMode && selected) ? ColorUtils.BUTTONCOLOR : ColorUtils.TEXT); 84 | if (name != null) 85 | g.drawString(name, 48, y, 0); 86 | ColorUtils.setcolor(g, ColorUtils.OUTLINE); 87 | if (lengthS != null) 88 | g.drawString(lengthS, DisplayUtils.width - 10 - g.getFont().stringWidth(lengthS), y, 0); 89 | int icon = IconsManager.MUSIC; 90 | if (MusicPlayer.inst != null && playlist == MusicPlayer.inst.playlist 91 | && indexInPL == MusicPlayer.inst.current) { 92 | icon = IconsManager.PLAY; 93 | // ColorUtils.setcolor(g, ColorUtils.BUTTONCOLOR); 94 | } 95 | if (artist != null) 96 | g.drawString(artist, 48, y + 24, 0); 97 | 98 | g.drawImage(((ScrollableCanvas.keysMode && selected) ? (IconsManager.selIco) : (IconsManager.ico))[icon], 12, 99 | y + 13, 0); 100 | } 101 | 102 | public void tap(int x, int y) { 103 | keyPress(-5); 104 | } 105 | 106 | public void keyPress(int key) { 107 | if (key == KEY_OK) { 108 | String[] x = Manager.getSupportedContentTypes((String)null); 109 | String x2 = ""; 110 | for(int i = 0; i < x.length; i++) { 111 | x2 += x[i] +(i == x.length - 1 ? "" : " "); 112 | } 113 | if(x2.indexOf("audio/mpeg") == -1) { 114 | VikaTouch.popup(new InfoPopup("Внимание!\nВаше устройство не поддерживает mp3", new Runnable() { 115 | 116 | public void run() { 117 | ok(); 118 | }})); 119 | return; 120 | } 121 | ok(); 122 | } 123 | } 124 | 125 | private void ok() { 126 | 127 | if (MusicPlayer.inst == null) { 128 | // System.out.println("Calling player"); 129 | MusicPlayer.launch(playlist, indexInPL); 130 | } else if (MusicPlayer.inst.playlist == playlist) { 131 | if (MusicPlayer.inst.current == indexInPL) { 132 | restorePlayerScreen(); 133 | } else { 134 | MusicPlayer.inst.current = indexInPL; 135 | restorePlayerScreen(); 136 | MusicPlayer.inst.loadTrack(); 137 | } 138 | } else { 139 | MusicPlayer.inst.destroy(); 140 | MusicPlayer.launch(playlist, indexInPL); 141 | } 142 | 143 | } 144 | 145 | public void restorePlayerScreen() { 146 | if (MusicPlayer.inst.backScreenIsPlaylist()) { 147 | VikaTouch.setDisplay(MusicPlayer.inst, 1); 148 | } else 149 | VikaTouch.setDisplay(playlist.backScreen, -1); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/ru/nnproject/vikaui/popup/ContextMenu.java: -------------------------------------------------------------------------------- 1 | // This file is part of VikaUI 2 | // Copyright (C) 2020 Arman Jussuplaliyev (Shinovon) 3 | 4 | package ru.nnproject.vikaui.popup; 5 | 6 | import javax.microedition.lcdui.Graphics; 7 | 8 | import ru.nnproject.vikaui.VikaCanvas; 9 | import ru.nnproject.vikaui.menu.items.OptionItem; 10 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 11 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 12 | import ru.nnproject.vikaui.utils.ColorUtils; 13 | import ru.nnproject.vikaui.utils.DisplayUtils; 14 | import vikatouch.VikaTouch; 15 | 16 | /** 17 | * @author Feodor0090 18 | * 19 | */ 20 | public class ContextMenu extends VikaNotice { 21 | 22 | public OptionItem[] items; 23 | public int selected = 0; 24 | public boolean dragging; 25 | private boolean opened; 26 | 27 | public ContextMenu(OptionItem[] list) { 28 | VikaCanvas.currentAlert = this; 29 | VikaTouch.needstoRedraw=true; 30 | 31 | items = list; 32 | if (ScrollableCanvas.keysMode) 33 | items[selected].setSelected(true); 34 | 35 | VikaTouch.needstoRedraw=true; 36 | } 37 | 38 | public void draw(Graphics g) { 39 | //if (VikaTouch.needstoRedraw==true) { 40 | int itemsH = 16; // margin = 8 41 | int width = Math.min(DisplayUtils.width - 8, 350); 42 | int x = DisplayUtils.width / 2 - width / 2; 43 | for (int i = 0; i < items.length; i++) { 44 | items[i].drawX = x + 8; 45 | items[i].fillW = width - 16; 46 | itemsH = itemsH + items[i].getDrawHeight(); 47 | } 48 | 49 | int th = itemsH; 50 | int y = DisplayUtils.height / 2 - th / 2; 51 | 52 | // BG 53 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 54 | g.fillRoundRect(x, y, width, th, 16, 16); 55 | // border 56 | g.setStrokeStyle(Graphics.SOLID); 57 | ColorUtils.setcolor(g, ColorUtils.TEXT); 58 | g.drawRoundRect(x, y, width, th, 16, 16); 59 | 60 | int cy = 8 + y; 61 | for (int i = 0; i < items.length; i++) { 62 | items[i].paint(g, cy, 0); 63 | cy = cy + items[i].getDrawHeight(); 64 | } 65 | //VikaTouch.needstoRedraw=false; 66 | //} 67 | } 68 | 69 | public void press(int key) { 70 | VikaTouch.needstoRedraw=true; 71 | ScrollableCanvas.keysMode = true; 72 | try { 73 | if (key == PressableUIItem.KEY_OK) { 74 | VikaCanvas.currentAlert = null; 75 | items[selected].keyPress(PressableUIItem.KEY_OK); 76 | } else if (key == -1) { 77 | items[selected].setSelected(false); 78 | selected--; 79 | if (selected < 0) 80 | selected = items.length - 1; 81 | items[selected].setSelected(true); 82 | } else if (key == -2) { 83 | items[selected].setSelected(false); 84 | selected++; 85 | if (selected >= items.length) 86 | selected = 0; 87 | items[selected].setSelected(true); 88 | } else if (key == PressableUIItem.KEY_RFUNC) { 89 | VikaCanvas.currentAlert = null; 90 | VikaTouch.needstoRedraw=true; 91 | repaint(); 92 | serviceRepaints(); 93 | VikaTouch.needstoRedraw=true; 94 | } 95 | } catch (Exception e) { 96 | e.printStackTrace(); 97 | } 98 | VikaTouch.needstoRedraw=true; 99 | this.repaint(); 100 | this.serviceRepaints(); 101 | VikaTouch.needstoRedraw=true; 102 | } 103 | 104 | int lastx = 0, lasty = 0; 105 | 106 | public void tap(int x, int y, int time) { 107 | 108 | VikaCanvas.currentAlert = this; 109 | VikaTouch.needstoRedraw=true; 110 | int margin = 8; 111 | int itemsH = margin * 2; // margin = 8 112 | int width = Math.min(DisplayUtils.width - 8, 350); 113 | int rx = DisplayUtils.width / 2 - width / 2; 114 | for (int i = 0; i < items.length; i++) { 115 | items[i].drawX = x + margin; 116 | items[i].fillW = width - margin * 2; 117 | itemsH = itemsH + items[i].getDrawHeight(); 118 | /*VikaTouch.needstoRedraw=true; 119 | repaint(); 120 | serviceRepaints(); 121 | VikaTouch.needstoRedraw=true;*/ 122 | 123 | } 124 | 125 | int th = itemsH; 126 | int ry = DisplayUtils.height / 2 - th / 2; 127 | 128 | if (x < rx || x > rx + width || y < ry || y > ry + th) { 129 | VikaCanvas.currentAlert = null; 130 | VikaTouch.needstoRedraw=true; 131 | repaint(); 132 | serviceRepaints(); 133 | VikaTouch.needstoRedraw=true; 134 | return; 135 | } 136 | 137 | int tapY = y - ry; 138 | int currY = margin; 139 | for (int i = 0; i < items.length; i++) { 140 | int h = items[i].getDrawHeight(); 141 | if (tapY > currY && tapY < currY + h) { 142 | VikaCanvas.currentAlert = null; 143 | VikaTouch.needstoRedraw=true; 144 | items[i].tap(x - rx, tapY - currY); 145 | repaint(); 146 | serviceRepaints(); 147 | VikaTouch.needstoRedraw=true; 148 | return; 149 | } 150 | currY = currY + h; 151 | } 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /src/tube42/lib/imagelib/ColorUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of the TUBE42 imagelib, released under the LGPL license. 3 | * 4 | * Development page: https://github.com/tube42/imagelib 5 | * License: http://www.gnu.org/copyleft/lesser.html 6 | */ 7 | 8 | package tube42.lib.imagelib; 9 | 10 | /** 11 | * This class contains some functions 12 | * that are common during color manipulation 13 | */ 14 | public final class ColorUtils 15 | { 16 | public static final int blend(final int c1, final int c2, final int value256) 17 | { 18 | 19 | final int v1 = value256 & 0xFF; 20 | final int c1_RB = c1 & 0x00FF00FF; 21 | final int c2_RB = c2 & 0x00FF00FF; 22 | 23 | final int c1_AG = (c1 >>> 8) & 0x00FF00FF; 24 | 25 | final int c2_AG_org = c2 & 0xFF00FF00; 26 | final int c2_AG = (c2_AG_org) >>> 8; 27 | 28 | // the world-famous tube42 blend with one mult per two components: 29 | final int rb = (c2_RB + (((c1_RB - c2_RB) * v1) >> 8)) & 0x00FF00FF; 30 | final int ag = (c2_AG_org + ((c1_AG - c2_AG) * v1)) & 0xFF00FF00; 31 | return ag | rb; 32 | 33 | } 34 | 35 | 36 | public static int darker(int c) 37 | { 38 | int a = (c >> 24) & 0xFF; 39 | int r = (c >> 16) & 0xFF; 40 | int g = (c >> 8) & 0xFF; 41 | int b = (c >> 0) & 0xFF; 42 | 43 | r = (r * 15) >> 4; 44 | g = (g * 15) >> 4; 45 | b = (b * 15) >> 4; 46 | 47 | return (a << 24) | (r << 16) | (g << 8) | b; 48 | } 49 | 50 | public static int lighter(int c) 51 | { 52 | int a = (c >> 24) & 0xFF; 53 | int r = (c >> 16) & 0xFF; 54 | int g = (c >> 8) & 0xFF; 55 | int b = (c >> 0) & 0xFF; 56 | 57 | r = Math.max(1, Math.min(255, (r * 17) >> 4)); 58 | g = Math.max(1, Math.min(255, (g * 17) >> 4)); 59 | b = Math.max(1, Math.min(255, (b * 17) >> 4)); 60 | 61 | 62 | return (a << 24) | (r << 16) | (g << 8) | b; 63 | } 64 | 65 | // ---------------------------------------------- 66 | public static int mix(int c1, int c2) 67 | { 68 | // return blend(c1, c2, 0x7f); 69 | 70 | int c_RB = (((c1 & 0x00FF00FF) + (c2 & 0x00FF00FF)) >> 1) & 0x00FF00FF; 71 | int c_AG = (((c1 & 0xFF00FF00) >>> 1) + ((c2 & 0xFF00FF00) >>> 1)) & 0xFF00FF00; 72 | return c_RB | c_AG; 73 | } 74 | 75 | public static int mix(int c1, int c2, int c3, int c4) 76 | { 77 | // return blend(c1, c2, 0x7f); 78 | 79 | int c_RB = ( 80 | ((c1 & 0x00FF00FF) + (c2 & 0x00FF00FF) + (c3 & 0x00FF00FF) + (c4 & 0x00FF00FF)) >> 2 81 | ) & 0x00FF00FF; 82 | 83 | int c_AG = ( 84 | ((c1 & 0xFF00FF00) >>> 2) + ((c2 & 0xFF00FF00) >>> 2) + 85 | ((c3 & 0xFF00FF00) >>> 2) + ((c4 & 0xFF00FF00) >>> 2) 86 | ) & 0xFF00FF00; 87 | return c_RB | c_AG; 88 | } 89 | 90 | // -------------------------------------- 91 | // colorspace conversion functions 92 | 93 | /* 94 | * ARGB_8 to A_8 + YCbCr_8 95 | * 96 | * (CCIR Recommendation 601, normalized to 0-255) 97 | */ 98 | public final static void ARGB2AYCbCr(int argb, int [] result) 99 | { 100 | int a = argb >>> 24; 101 | int r = (argb >> 16) & 0xFF; 102 | int g = (argb >> 8) & 0xFF; 103 | int b = argb & 0xFF; 104 | 105 | result[0] = a; 106 | result[1] = ( r * 77 + g * 150 + b * 29) >> 8; 107 | result[2] = (0x8000 - r * 43 - g * 85 + b * 128) >> 8; 108 | result[3] = (0x8000 + r * 128 - g * 107 - b * 21) >> 8; 109 | } 110 | 111 | /* 112 | * A_8 + YCbCr_8 to ARGB_8 113 | * 114 | * (CCIR Recommendation 601, normalized to 0-255) 115 | * 116 | * NOTE: the current implmentation is very inefficient! 117 | */ 118 | public final static int AYCbCr2ARGB(int [] components) 119 | { 120 | int Y8 = components[1] << 8; 121 | 122 | // XXX: I can't figure out why these number don't map to 0-255, hence the min/max for now :( 123 | int r = Math.max(0, Math.min(255, (Y8 + (components[3]-128) * 359) >> 8)); 124 | int g = Math.max(0, Math.min(255, (Y8 - (components[3]-128) * 183 - (components[2]-128) * 88) >> 8)); 125 | int b = Math.max(0, Math.min(255, (Y8 + (components[2]-128) * 454) >> 8)); 126 | 127 | return (components[0] << 24) | (r << 16) | (g << 8) | b; 128 | } 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/vikatouch/attachments/VoiceAttachment.java: -------------------------------------------------------------------------------- 1 | package vikatouch.attachments; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import org.json.me.JSONException; 7 | import org.json.me.JSONObject; 8 | 9 | import ru.nnproject.vikaui.menu.items.OptionItem; 10 | import ru.nnproject.vikaui.popup.ContextMenu; 11 | import ru.nnproject.vikaui.popup.InfoPopup; 12 | import ru.nnproject.vikaui.utils.ColorUtils; 13 | import ru.nnproject.vikaui.utils.images.IconsManager; 14 | import ru.nnproject.vikaui.utils.text.TextBreaker; 15 | import vikatouch.VikaTouch; 16 | import vikatouch.items.chat.MsgItem; 17 | import vikatouch.locale.TextLocal; 18 | import vikatouch.music.MusicPlayer; 19 | import vikatouch.utils.VikaUtils; 20 | import vikatouch.utils.error.ErrorCodes; 21 | import vikatouch.utils.url.URLBuilder; 22 | 23 | /** 24 | * @author Feodor0090 25 | * 26 | */ 27 | public class VoiceAttachment extends DocumentAttachment { 28 | 29 | public VoiceAttachment() { 30 | this.type = "audio_message"; 31 | } 32 | 33 | public static String name; 34 | public String url; 35 | public int size; 36 | public String length; 37 | public String musUrl; 38 | public String text; 39 | public String[] textB; 40 | public int lastW = 0; 41 | public long mid; 42 | 43 | public void parseJSON() { 44 | try { 45 | name = TextLocal.inst.get("msg.attach.voice"); 46 | size = json.optInt("duration"); 47 | length = MusicPlayer.time(size); 48 | musUrl = fixJSONString(json.optString("link_mp3")); 49 | if (VikaTouch.integerUserId==3225000) { 50 | text = null; 51 | } else { 52 | text = json.optString("transcript"); 53 | } 54 | if (text != null && text.length() > 2) { 55 | textB = TextBreaker.breakText(text, Font.getFont(0, 0, 8), MsgItem.msgWidth - 30); 56 | } 57 | } catch (Exception e) { 58 | e.printStackTrace(); 59 | VikaTouch.error(e, ErrorCodes.DOCPARSE); 60 | } 61 | 62 | System.gc(); 63 | } 64 | 65 | public int getDrawHeight() { 66 | int th = 0; 67 | if (textB != null) 68 | th = (textB.length * Font.getFont(0, 0, 8).getHeight()) + 5; 69 | return 40 + th; 70 | } 71 | 72 | public void draw(Graphics g, int x1, int y1, int w) { 73 | if (lastW != w) { 74 | if (text != null && text.length() > 2) { 75 | textB = TextBreaker.breakText(text, Font.getFont(0, 0, 8), w); 76 | } 77 | } 78 | ColorUtils.setcolor(g, ColorUtils.BACKGROUND); 79 | g.fillRect(x1, y1, w, 40); 80 | g.drawImage(IconsManager.ico[IconsManager.VOICE], x1 + 4, y1 + 8, 0); 81 | ColorUtils.setcolor(g, ColorUtils.COLOR1); 82 | Font f = Font.getFont(0, Font.STYLE_BOLD, Font.SIZE_SMALL); 83 | g.setFont(f); 84 | if (name != null) 85 | g.drawString(name, x1 + 34, y1 + 10 - f.getHeight() / 2, 0); 86 | ColorUtils.setcolor(g, ColorUtils.TEXT); 87 | f = Font.getFont(0, 0, Font.SIZE_SMALL); 88 | g.setFont(f); 89 | g.drawString(length, x1 + 34, y1 + 30 - f.getHeight() / 2, 0); 90 | try { 91 | if (textB != null) { 92 | for (int i = 0; i < textB.length; i++) { 93 | g.drawString(textB[i], x1, y1 + 45 + f.getHeight() * i, 0); 94 | } 95 | } 96 | } catch (Exception e) { 97 | } 98 | } 99 | 100 | public void press() { 101 | OptionItem[] i = new OptionItem[2]; 102 | i[0] = new OptionItem(this, "Прослушать", IconsManager.PLAY, 0, 50); 103 | i[1] = new OptionItem(this, "Транскрипт", IconsManager.EDIT, 1, 50); 104 | VikaTouch.popup(new ContextMenu(i)); 105 | // в плеере скачать можно. 106 | // MusicScreen ms = new MusicScreen(); 107 | // ms.loadAtt(this); 108 | // MusicPlayer.launch(ms, 0); 109 | } 110 | 111 | public void onMenuItemPress(int i) { 112 | if (i == 0) { 113 | try { 114 | MusicPlayer mp = new MusicPlayer(); 115 | mp.voice = this; 116 | mp.firstLoad(); 117 | VikaTouch.setDisplay(mp, 1); 118 | } catch (Exception e) { 119 | } 120 | } else if (i == 1) { 121 | String x = "0"; 122 | try { 123 | x = VikaUtils.download(new URLBuilder("messages.getById").addField("message_ids", String.valueOf(mid)) 124 | .addField("extended", 1)); 125 | JSONObject r = new JSONObject(x).getJSONObject("response").getJSONArray("items").getJSONObject(0); 126 | MsgItem m = new MsgItem(r); 127 | m.parseJSON(); 128 | 129 | m.loadAtts(); 130 | 131 | VoiceAttachment v = m.findVoice(); 132 | if (v != null) { 133 | VikaTouch.popup(new InfoPopup(v.text, null)); 134 | } 135 | } catch (JSONException e) { 136 | VikaTouch.popup(new InfoPopup("Transcript parse error", null)); 137 | VikaTouch.sendLog(x); 138 | } catch (Exception e) { 139 | VikaTouch.popup(new InfoPopup("Transcript loading error", null)); 140 | VikaTouch.sendLog("Voice transcript: " + e.toString()); 141 | } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/vikatouch/VikaFileManager.java: -------------------------------------------------------------------------------- 1 | package vikatouch; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.DataInputStream; 5 | 6 | import javax.microedition.io.Connector; 7 | import javax.microedition.io.file.FileConnection; 8 | import javax.microedition.lcdui.Command; 9 | import javax.microedition.lcdui.CommandListener; 10 | import javax.microedition.lcdui.Displayable; 11 | import javax.microedition.lcdui.Image; 12 | import javax.microedition.lcdui.List; 13 | 14 | import ru.nnproject.kemulator.filemanagerapi.AbstractFileManager; 15 | import ru.nnproject.kemulator.filemanagerapi.FileManagerAPI; 16 | import ru.nnproject.vikaui.popup.InfoPopup; 17 | import vikatouch.screens.ChatScreen; 18 | import vikatouch.screens.temp.FileManagerScreen; 19 | import vikatouch.settings.Settings; 20 | import vikatouch.utils.VikaUtils; 21 | 22 | /** 23 | * @author Shinovon 24 | * 25 | */ 26 | public class VikaFileManager { 27 | 28 | private static List list; 29 | 30 | public static void chatPhoto(final ChatScreen chat) { 31 | try { 32 | if (System.getProperty("kemulator.filemanagerapi.version") != null) { 33 | AbstractFileManager fm = FileManagerAPI.getInstance("Открыть файл", FileManagerAPI.NATIVE); 34 | fm.setFilterExtensions(new String[] { ".jpg", ".jpeg", ".png" }, "Любое изображение"); 35 | if (fm.openFile()) { 36 | FileConnection fc = fm.getFileConnection(); 37 | DataInputStream in = fc.openDataInputStream(); 38 | int len = (int) fc.fileSize(); 39 | byte[] var5 = new byte[len]; 40 | in.readFully(var5, 0, len); 41 | VikaUtils.sendPhoto(chat.peerId, var5, chat.inputText); 42 | chat.inputText = ""; 43 | return; 44 | } else { 45 | return; 46 | } 47 | } 48 | } catch (Throwable e) { 49 | e.printStackTrace(); 50 | } 51 | if (Settings.oldlcduiFm) { 52 | list = VikaUtils.selectPhoto("main"); 53 | VikaTouch.setDisplay(list); 54 | final Command back = new Command("Назад", 2, 0); 55 | final Command dirBack = new Command("Назад", 2, 0); 56 | final Command preview = new Command("Предпросмотр", 8, 1); 57 | list.addCommand(back); 58 | list.addCommand(List.SELECT_COMMAND); 59 | list.addCommand(preview); 60 | list.setCommandListener(new CommandListener() { 61 | 62 | public void commandAction(Command arg0, Displayable arg1) { 63 | if (arg0 == List.SELECT_COMMAND) { 64 | int var194 = list.getSelectedIndex(); 65 | int var196; 66 | byte[] var5 = null; 67 | ByteArrayOutputStream var201 = new ByteArrayOutputStream(); 68 | 69 | try { 70 | FileConnection var197 = (FileConnection) Connector 71 | .open(String.valueOf(VikaUtils.filesVector.elementAt(var194)), 1); 72 | // заходить в папку 73 | if (var197.isDirectory()) { 74 | list = VikaUtils.selectPhoto(var197.getURL()); 75 | VikaTouch.setDisplay(list); 76 | list.addCommand(dirBack); 77 | list.addCommand(List.SELECT_COMMAND); 78 | list.addCommand(preview); 79 | list.setCommandListener(this); 80 | return; 81 | } 82 | DataInputStream var220 = null; 83 | if (!var197.exists()) { 84 | list.append("File " + var197.getName() + " doesn't exist!", (Image) null); 85 | } else { 86 | var196 = (int) var197.fileSize(); 87 | if (var196 > 600 * 1024) { 88 | // файл весит больше 600 кб 89 | VikaTouch.popup( 90 | new InfoPopup("Фото весит более 600кб, и не может быть отправлено.", null)); 91 | return; 92 | } 93 | var220 = var197.openDataInputStream(); 94 | var5 = new byte[var196]; 95 | var220.readFully(var5, 0, var196); 96 | } 97 | var220.close(); 98 | var201.close(); 99 | VikaUtils.sendPhoto(chat.peerId, var5, chat.inputText); 100 | chat.inputText = ""; 101 | list = null; 102 | VikaTouch.setDisplay(VikaTouch.canvas); 103 | } catch (Exception e) { 104 | } 105 | } else if (arg0 == back) { 106 | VikaTouch.setDisplay(VikaTouch.canvas); 107 | } else if (arg0 == preview) { 108 | int var194 = list.getSelectedIndex(); 109 | try { 110 | VikaTouch.appInst.platformRequest((String) VikaUtils.filesVector.elementAt(var194)); 111 | } catch (Exception e) { 112 | } 113 | return; 114 | } else if (arg0 == dirBack) { 115 | list = VikaUtils.selectPhoto("main"); 116 | 117 | VikaTouch.setDisplay(list); 118 | list.addCommand(back); 119 | list.addCommand(List.SELECT_COMMAND); 120 | list.addCommand(preview); 121 | list.setCommandListener(this); 122 | return; 123 | } 124 | } 125 | 126 | }); 127 | } else { 128 | VikaTouch.setDisplay(new FileManagerScreen(chat), 1); 129 | } 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/vikatouch/utils/Camera.java: -------------------------------------------------------------------------------- 1 | package vikatouch.utils; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.microedition.amms.control.camera.FlashControl; 6 | import javax.microedition.amms.control.camera.FocusControl; 7 | import javax.microedition.lcdui.Canvas; 8 | import javax.microedition.media.Manager; 9 | import javax.microedition.media.MediaException; 10 | import javax.microedition.media.Player; 11 | import javax.microedition.media.control.VideoControl; 12 | 13 | import vikatouch.VikaTouch; 14 | 15 | /** 16 | * @author Shinovon 17 | * 18 | */ 19 | public final class Camera { 20 | private static Player player; 21 | public static VideoControl videoControl; 22 | private static Object focusControl; 23 | private static Object flashControl; 24 | 25 | public static void init(Canvas paramCanvas, boolean selfieOn) throws IOException, MediaException { 26 | if (player == null) { 27 | if (selfieOn) { 28 | player = Manager.createPlayer("capture://devcam1"); 29 | } else { 30 | try { 31 | try { 32 | if (VikaTouch.mobilePlatform.indexOf("S60") > -1) { 33 | player = Manager.createPlayer("capture://video"); 34 | } else { 35 | player = Manager.createPlayer("capture://image"); 36 | } 37 | } catch (Exception e) { 38 | player = Manager.createPlayer("capture://image"); 39 | } 40 | } catch (Exception e) { 41 | player = Manager.createPlayer("capture://video"); 42 | } 43 | } 44 | player.realize(); 45 | } 46 | if (videoControl == null) { 47 | videoControl = (VideoControl) player.getControl("VideoControl"); 48 | videoControl.initDisplayMode(1, paramCanvas); 49 | } 50 | try { 51 | focusControl = (FocusControl) player.getControl("javax.microedition.amms.control.camera.FocusControl"); 52 | /* 53 | * if(((FocusControl)focusControl).isMacroSupported()) { 54 | * ((FocusControl)focusControl).setMacro(true); } 55 | */ 56 | if (((FocusControl) focusControl).isAutoFocusSupported()) { 57 | ((FocusControl) focusControl).setFocus(FocusControl.AUTO); 58 | } 59 | } catch (Throwable e) { 60 | VikaTouch.sendLog("focuscontrol " + e.toString()+" " +focusControl); 61 | } 62 | 63 | try { 64 | flashControl = (FlashControl) player.getControl("javax.microedition.amms.control.camera.FlashControl"); 65 | ((FlashControl) flashControl).setMode(FlashControl.AUTO); 66 | } catch (Throwable e) { 67 | VikaTouch.sendLog("flashcontrol " + e.toString()+" " +flashControl); 68 | } 69 | } 70 | 71 | public static void macrooff() throws MediaException { 72 | if (focusControl != null && ((FocusControl) focusControl).isMacroSupported()) { 73 | ((FocusControl) focusControl).setMacro(false); 74 | } 75 | } 76 | 77 | public static void macroon() throws MediaException { 78 | if (focusControl != null && ((FocusControl) focusControl).isMacroSupported()) { 79 | ((FocusControl) focusControl).setMacro(true); 80 | } 81 | } 82 | 83 | public static void autofocus() throws MediaException { 84 | if (focusControl != null && ((FocusControl) focusControl).isAutoFocusSupported()) { 85 | ((FocusControl) focusControl).setFocus(FocusControl.AUTO); 86 | } 87 | } 88 | 89 | public static void show(int width, int height, int i) throws MediaException { 90 | videoControl.setDisplaySize(width, height - i); 91 | videoControl.setDisplayLocation((width - videoControl.getDisplayWidth()) / 2, 0); 92 | videoControl.setVisible(true); 93 | player.prefetch(); 94 | player.start(); 95 | } 96 | 97 | public static void stop() throws MediaException { 98 | if (videoControl != null) { 99 | videoControl.setVisible(false); 100 | videoControl = null; 101 | } 102 | if (player != null) { 103 | try { 104 | player.stop(); 105 | } catch (Exception localException1) { 106 | } 107 | try { 108 | player.deallocate(); 109 | } catch (Exception localException2) { 110 | } 111 | try { 112 | player.close(); 113 | } catch (Exception localException3) { 114 | } 115 | player = null; 116 | } 117 | } 118 | 119 | public static byte[] takeSnapshot(int width, int height) throws MediaException { 120 | byte[] arrayOfByte = null; 121 | try { 122 | arrayOfByte = videoControl.getSnapshot(/* "width=" + width + "&height=" + height */null); 123 | } catch (SecurityException localSecurityException) { 124 | arrayOfByte = null; 125 | } catch (Throwable localThrowable) { 126 | localThrowable.printStackTrace(); 127 | arrayOfByte = videoControl.getSnapshot(null); 128 | } 129 | return arrayOfByte; 130 | } 131 | 132 | public static boolean setFlash(boolean flashOn) throws Exception { 133 | if (flashControl == null) { 134 | return false; 135 | } 136 | if (flashOn) { 137 | ((FlashControl) flashControl).setMode(FlashControl.FORCE); 138 | return true; 139 | } else { 140 | ((FlashControl) flashControl).setMode(FlashControl.OFF); 141 | return false; 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /src/vikatouch/settings/SettingMenuItem.java: -------------------------------------------------------------------------------- 1 | package vikatouch.settings; 2 | 3 | import javax.microedition.lcdui.Font; 4 | import javax.microedition.lcdui.Graphics; 5 | 6 | import ru.nnproject.vikaui.menu.IMenu; 7 | import ru.nnproject.vikaui.menu.items.OptionItem; 8 | import ru.nnproject.vikaui.menu.items.PressableUIItem; 9 | import ru.nnproject.vikaui.popup.AutoContextMenu; 10 | import ru.nnproject.vikaui.popup.InfoPopup; 11 | import ru.nnproject.vikaui.screen.ScrollableCanvas; 12 | import ru.nnproject.vikaui.utils.ColorUtils; 13 | import ru.nnproject.vikaui.utils.images.IconsManager; 14 | import vikatouch.VikaTouch; 15 | import vikatouch.locale.TextLocal; 16 | 17 | /** 18 | * @author Feodor0090 19 | * 20 | */ 21 | public class SettingMenuItem implements PressableUIItem, IMenu { 22 | 23 | public SettingsScreen ss; 24 | public String text; 25 | public int icon; 26 | public int h; 27 | public int optN; 28 | boolean s; 29 | static Font f; 30 | static Font sf; 31 | public String[] opts; 32 | public int currentOption; 33 | String help; 34 | public boolean noyes; 35 | 36 | public int drawX; 37 | public int fillW; // for context menu 38 | 39 | public SettingMenuItem(SettingsScreen s, String title, int ic, int optN, int h, int[] list, int curr, String info) { 40 | this.h = h; 41 | this.optN = optN; 42 | icon = ic; 43 | text = title; 44 | ss = s; 45 | opts = new String[list.length]; 46 | for (int i = 0; i < list.length; i++) { 47 | opts[i] = String.valueOf(list[i]); 48 | } 49 | currentOption = curr; 50 | help = info; 51 | f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); 52 | sf = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL); 53 | } 54 | 55 | public SettingMenuItem(SettingsScreen s, String title, int ic, int optN, int h, String[] list, int curr, 56 | String info) { 57 | this.h = h; 58 | this.optN = optN; 59 | icon = ic; 60 | text = title; 61 | ss = s; 62 | opts = list; 63 | currentOption = curr; 64 | help = info; 65 | f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); 66 | sf = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL); 67 | } 68 | 69 | public SettingMenuItem(SettingsScreen s, String title, int ic, int optN, int h, String[] list, int curr, 70 | String info, boolean noyesset) { 71 | this.h = h; 72 | this.optN = optN; 73 | icon = ic; 74 | text = title; 75 | ss = s; 76 | opts = list; 77 | currentOption = curr; 78 | help = info; 79 | f = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); 80 | sf = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL); 81 | noyes = noyesset; 82 | } 83 | 84 | public void paint(Graphics g, int y, int scrolled) { 85 | ColorUtils.setcolor(g, (ScrollableCanvas.keysMode && s) ? ColorUtils.BUTTONCOLOR : ColorUtils.TEXT); 86 | g.setFont((ScrollableCanvas.keysMode && s) ? sf : f); 87 | int x = drawX + 48; 88 | if (icon == -1) 89 | x = x - 40; 90 | if (icon != -1) 91 | g.drawImage(((ScrollableCanvas.keysMode && s) ? (IconsManager.selIco) : (IconsManager.ico))[icon], 92 | drawX + 12, y + (h / 2 - 12), 0); 93 | try { 94 | g.drawString(text, x, y + ((h / 4) - (((ScrollableCanvas.keysMode && s) ? sf : f).getHeight() / 2)), 0); 95 | ColorUtils.setcolor(g, ColorUtils.TEXT2); 96 | g.setFont(f); 97 | g.drawString(opts[currentOption], x, y + ((h * 3 / 4) - (f.getHeight() / 2)), 0); 98 | } catch (Exception e) { 99 | e.printStackTrace(); 100 | } 101 | } 102 | 103 | public int getDrawHeight() { 104 | return h; 105 | } 106 | 107 | public void tap(int x, int y) { 108 | keyPress(-5); 109 | } 110 | 111 | public void keyPress(int key) { 112 | if (key == KEY_OK) { 113 | if(noyes) { 114 | currentOption = currentOption == 0 ? 1 : 0; 115 | ss.settingSet(optN, currentOption); 116 | } else { 117 | OptionItem[] po = new OptionItem[opts.length]; 118 | for (int i = 0; i < opts.length; i++) { 119 | if (noyes) { 120 | po[i] = new OptionItem(this, opts[i], (i == 0) ? IconsManager.CLOSE : IconsManager.APPLY, i, 40); 121 | } else { 122 | po[i] = new OptionItem(this, opts[i], 123 | (currentOption == i) ? IconsManager.APPLY : IconsManager.SETTINGS, i, 40); 124 | } 125 | } 126 | VikaTouch.popup(new AutoContextMenu(po)); 127 | } 128 | } else if (help != null && key == KEY_FUNC) { 129 | VikaTouch.popup(new InfoPopup(help, null, TextLocal.inst.get("settings.help"), null)); 130 | } 131 | } 132 | 133 | public boolean isSelected() { 134 | return s; 135 | } 136 | 137 | public void setSelected(boolean selected) { 138 | s = selected; 139 | } 140 | 141 | public void addDrawHeight(int i) { 142 | h += i; 143 | } 144 | 145 | public void setDrawHeight(int i) { 146 | h = i; 147 | } 148 | 149 | public void onMenuItemPress(int i) { 150 | ss.settingSet(optN, i); 151 | currentOption = i; 152 | } 153 | 154 | public void onMenuItemOption(int i) { 155 | if (help != null) { 156 | VikaTouch.popup(new InfoPopup(help, null, TextLocal.inst.get("settings.help"), null)); 157 | } 158 | } 159 | } 160 | --------------------------------------------------------------------------------