├── .gitignore ├── settings.gradle └── app ├── libs └── dx.jar ├── src └── main │ ├── res │ ├── drawable-hdpi │ │ ├── file.png │ │ ├── folder.png │ │ ├── folder_in.png │ │ ├── ic_drawer.png │ │ ├── icon_jar.png │ │ ├── icon_java.png │ │ ├── icon_zip.png │ │ ├── red_mark.png │ │ ├── ic_launcher.png │ │ ├── ambilwarna_hue.png │ │ ├── ambilwarna_keker.png │ │ ├── ambilwarna_panah.png │ │ ├── app_default_icon.png │ │ ├── drawer_shadow.9.png │ │ ├── ambilwarna_menjadi.png │ │ ├── gradient_bg_2.xml │ │ ├── gradient_bg_1.xml │ │ └── list_selector.xml │ ├── drawable-mdpi │ │ ├── ic_drawer.png │ │ ├── ic_launcher.png │ │ └── drawer_shadow.9.png │ ├── drawable-xhdpi │ │ ├── ic_drawer.png │ │ ├── ic_launcher.png │ │ └── drawer_shadow.9.png │ ├── drawable-xxhdpi │ │ ├── ic_drawer.png │ │ └── drawer_shadow.9.png │ ├── values │ │ ├── config_str.xml │ │ ├── locales.xml │ │ ├── dimens.xml │ │ ├── styles.xml │ │ └── strings.xml │ ├── layout │ │ ├── default_displayable_layout.xml │ │ ├── fragment_navigation_drawer.xml │ │ ├── fragment_main.xml │ │ ├── file_browser_layout.xml │ │ ├── ambilwarna_pemilih.xml │ │ ├── list_row.xml │ │ ├── ambilwarna_dialog.xml │ │ ├── activity_main.xml │ │ └── list_row_jar.xml │ ├── menu │ │ ├── global.xml │ │ └── main.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-w820dp │ │ └── dimens.xml │ ├── values-v14 │ │ └── styles.xml │ └── values-ru │ │ └── strings.xml │ ├── java │ ├── ua │ │ └── naiksoftware │ │ │ ├── j2meloader │ │ │ ├── SortItem.java │ │ │ ├── converter │ │ │ │ ├── ConvertException.java │ │ │ │ └── JarConverter.java │ │ │ ├── AlphabeticComparator.java │ │ │ ├── AppItem.java │ │ │ ├── FSItem.java │ │ │ ├── AppsListAdapter.java │ │ │ ├── AppsListFragment.java │ │ │ ├── FileListAdapter.java │ │ │ └── MainActivity.java │ │ │ └── util │ │ │ ├── MathUtils.java │ │ │ ├── ProcessUtils.java │ │ │ └── FileUtils.java │ ├── javax │ │ ├── microedition │ │ │ ├── media │ │ │ │ ├── Control.java │ │ │ │ ├── Controllable.java │ │ │ │ ├── control │ │ │ │ │ ├── PanControl.java │ │ │ │ │ ├── VolumeControl.java │ │ │ │ │ ├── VideoControl.java │ │ │ │ │ └── MetaDataControl.java │ │ │ │ ├── MediaException.java │ │ │ │ ├── PlayerListener.java │ │ │ │ ├── Player.java │ │ │ │ └── DataSource.java │ │ │ ├── rms │ │ │ │ ├── RecordFilter.java │ │ │ │ ├── RecordComparator.java │ │ │ │ ├── RecordStoreNotOpenException.java │ │ │ │ ├── InvalidRecordIDException.java │ │ │ │ ├── RecordStoreNotFoundException.java │ │ │ │ ├── RecordStoreException.java │ │ │ │ └── RecordEnumeration.java │ │ │ ├── lcdui │ │ │ │ ├── EventFilter.java │ │ │ │ ├── ItemStateListener.java │ │ │ │ ├── list │ │ │ │ │ ├── ItemSelector.java │ │ │ │ │ ├── CompoundSpinnerAdapter.java │ │ │ │ │ ├── CompoundItem.java │ │ │ │ │ ├── CompoundListAdapter.java │ │ │ │ │ └── CompoundAdapter.java │ │ │ │ ├── CommandListener.java │ │ │ │ ├── ItemCommandListener.java │ │ │ │ ├── Ticker.java │ │ │ │ ├── event │ │ │ │ │ ├── SimpleEvent.java │ │ │ │ │ ├── RunnableEvent.java │ │ │ │ │ ├── LayoutEvent.java │ │ │ │ │ └── CommandActionEvent.java │ │ │ │ ├── AlertType.java │ │ │ │ ├── ViewHandler.java │ │ │ │ ├── XMLForm.java │ │ │ │ ├── Spacer.java │ │ │ │ ├── Choice.java │ │ │ │ ├── ImageItem.java │ │ │ │ ├── game │ │ │ │ │ ├── GameCanvas.java │ │ │ │ │ └── Layer.java │ │ │ │ ├── StringItem.java │ │ │ │ ├── Event.java │ │ │ │ ├── Gauge.java │ │ │ │ ├── pointer │ │ │ │ │ └── KeyRepeater.java │ │ │ │ ├── Command.java │ │ │ │ ├── Screen.java │ │ │ │ ├── Overlay.java │ │ │ │ ├── Displayable.java │ │ │ │ └── Image.java │ │ │ ├── midlet │ │ │ │ ├── MIDletStateChangeException.java │ │ │ │ └── MIDlet.java │ │ │ ├── io │ │ │ │ ├── Connection.java │ │ │ │ ├── ConnectionProvider.java │ │ │ │ ├── StreamConnection.java │ │ │ │ ├── ConnectionNotFoundException.java │ │ │ │ ├── HttpConnectionProvider.java │ │ │ │ ├── ImmediateOutputStream.java │ │ │ │ ├── ImmediateInputStream.java │ │ │ │ ├── HttpConnection.java │ │ │ │ ├── file │ │ │ │ │ └── FileSystemRegistry.java │ │ │ │ └── Connector.java │ │ │ ├── util │ │ │ │ ├── ActivityResultListener.java │ │ │ │ ├── ArrayStack.java │ │ │ │ ├── ContextHolder.java │ │ │ │ └── LinkedEntry.java │ │ │ ├── shell │ │ │ │ ├── ScreenFragment.java │ │ │ │ └── MyClassLoader.java │ │ │ ├── amms │ │ │ │ └── control │ │ │ │ │ ├── EffectControl.java │ │ │ │ │ └── audioeffect │ │ │ │ │ └── EqualizerControl.java │ │ │ └── param │ │ │ │ ├── DataEditor.java │ │ │ │ ├── DataContainer.java │ │ │ │ ├── BundleContainer.java │ │ │ │ └── SharedPreferencesContainer.java │ │ └── bluetooth │ │ │ ├── BluetoothStateException.java │ │ │ ├── DeviceClass.java │ │ │ ├── RemoteDevice.java │ │ │ ├── ServiceRecord.java │ │ │ ├── L2CAPConnectionNotifier.java │ │ │ ├── DiscoveryAgent.java │ │ │ ├── DiscoveryListener.java │ │ │ ├── BTUtils.java │ │ │ ├── BTL2CAPConnectionProvider.java │ │ │ └── L2CAPConnection.java │ ├── filelog │ │ └── Log.java │ └── yuku │ │ └── ambilwarna │ │ └── AmbilWarnaKotak.java │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /app/build 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/libs/dx.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/libs/dx.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/file.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/folder.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/folder_in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/folder_in.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_jar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/icon_jar.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_java.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/icon_java.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/icon_zip.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/red_mark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/red_mark.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-mdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-xhdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_drawer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-xxhdpi/ic_drawer.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ambilwarna_hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/ambilwarna_hue.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ambilwarna_keker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/ambilwarna_keker.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ambilwarna_panah.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/ambilwarna_panah.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/app_default_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/app_default_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-mdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-xhdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ambilwarna_menjadi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NaikSoftware/J2meLoader/HEAD/app/src/main/res/drawable-hdpi/ambilwarna_menjadi.png -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/SortItem.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | /** 4 | * 5 | * @author Naik 6 | */ 7 | public interface SortItem { 8 | 9 | public String getSortField(); 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/config_str.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | x 4 | - 5 | -1 6 | -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/converter/ConvertException.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader.converter; 2 | 3 | public class ConvertException extends Exception { 4 | 5 | public ConvertException(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/default_displayable_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/gradient_bg_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/gradient_bg_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/menu/global.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/locales.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | English 6 | Русский 7 | 8 | 9 | en 10 | ru 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/AlphabeticComparator.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | import java.util.*; 4 | 5 | /* 6 | * @author Naik 7 | */ 8 | public class AlphabeticComparator implements Comparator { 9 | 10 | public int compare(T p1, T p2) { 11 | return p1.getSortField().compareToIgnoreCase(p2.getSortField()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/util/MathUtils.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.util; 2 | 3 | /** 4 | * 5 | * @author Naik 6 | */ 7 | public class MathUtils { 8 | 9 | /** 10 | * 11 | * @param sourceNum 12 | * @return rounded to two decimal places 13 | */ 14 | public static float round(float sourceNum) { 15 | int temp = (int) (sourceNum / 0.01f); 16 | return temp / 100f; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_navigation_drawer.xml: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/list_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 11 | 240dp 12 | 13 | 1dp 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.0" 6 | 7 | defaultConfig { 8 | applicationId "ua.naiksoftware.j2meloader" 9 | minSdkVersion 14 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile 'com.android.support:appcompat-v7:+' 24 | compile 'com.android.support:support-v4:+' 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | 27 | compile 'io.reactivex:rxjava:1.1.5' 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/Control.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media; 18 | 19 | public interface Control 20 | { 21 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/RecordFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | public class RecordFilter 20 | { 21 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/RecordComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | public class RecordComparator 20 | { 21 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/EventFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public interface EventFilter 20 | { 21 | public boolean accept(Event event); 22 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/midlet/MIDletStateChangeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.midlet; 18 | 19 | public class MIDletStateChangeException extends Exception 20 | { 21 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/RecordStoreNotOpenException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | public class RecordStoreNotOpenException extends RecordStoreException 20 | { 21 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/ItemStateListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public interface ItemStateListener 20 | { 21 | public void itemStateChanged(Item item); 22 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/list/ItemSelector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.list; 18 | 19 | public interface ItemSelector 20 | { 21 | public boolean isSelected(int elementNum); 22 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/CommandListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public interface CommandListener 20 | { 21 | public void commandAction(Command c, Displayable d); 22 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/ItemCommandListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public interface ItemCommandListener 20 | { 21 | public void commandAction(Command c, Item item); 22 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/Connection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | 21 | public interface Connection 22 | { 23 | public void close() throws IOException; 24 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/util/ProcessUtils.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | 7 | /** 8 | * 9 | * @author Naik 10 | */ 11 | public class ProcessUtils { 12 | 13 | public static String readFromProcess(java.lang.Process process, boolean err) { 14 | StringBuilder result = new StringBuilder(); 15 | String line; 16 | BufferedReader br = new BufferedReader(new InputStreamReader(err ? process.getErrorStream() : process.getInputStream())); 17 | try { 18 | while ((line = br.readLine()) != null) { 19 | result.append(line).append("\n"); 20 | } 21 | } catch (IOException e) { 22 | //Log.e("Main", "read From Process", e); 23 | } 24 | return result.toString(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/file_browser_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 16 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/Controllable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media; 18 | 19 | public interface Controllable 20 | { 21 | public Control getControl(String controlType); 22 | public Control[] getControls(); 23 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/ConnectionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | 21 | public interface ConnectionProvider 22 | { 23 | public Connection open(String name, int mode) throws IOException; 24 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/BluetoothStateException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.io.IOException; 20 | 21 | public class BluetoothStateException extends IOException 22 | { 23 | public BluetoothStateException(String msg) 24 | { 25 | super(msg); 26 | } 27 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/control/PanControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media.control; 18 | 19 | import javax.microedition.media.Control; 20 | 21 | public interface PanControl extends Control 22 | { 23 | public int setPan(int pan); 24 | public int getPan(); 25 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/util/ActivityResultListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.util; 18 | 19 | import android.content.Intent; 20 | 21 | public interface ActivityResultListener 22 | { 23 | public void onActivityResult(int requestCode, int resultCode, Intent data); 24 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/MediaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media; 18 | 19 | public class MediaException extends Exception 20 | { 21 | public MediaException(Exception e) 22 | { 23 | super(e); 24 | } 25 | 26 | public MediaException(String message) 27 | { 28 | super(message); 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/InvalidRecordIDException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | public class InvalidRecordIDException extends RecordStoreException 20 | { 21 | public InvalidRecordIDException(Exception e) 22 | { 23 | super(e); 24 | } 25 | 26 | public InvalidRecordIDException() 27 | { 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/RecordStoreNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | public class RecordStoreNotFoundException extends RecordStoreException 20 | { 21 | public RecordStoreNotFoundException(Exception e) 22 | { 23 | super(e); 24 | } 25 | 26 | public RecordStoreNotFoundException() 27 | { 28 | } 29 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/shell/ScreenFragment.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.shell; 2 | 3 | import javax.microedition.lcdui.Displayable; 4 | 5 | import ua.naiksoftware.j2meloader.R; 6 | import android.os.Bundle; 7 | import android.support.v4.app.Fragment; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | 12 | public class ScreenFragment extends Fragment { 13 | 14 | private Displayable displayable; 15 | 16 | public ScreenFragment() { 17 | } 18 | 19 | public ScreenFragment(Displayable d) { 20 | displayable = d; 21 | } 22 | 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 25 | Bundle savedInstanceState) { 26 | return displayable.getDisplayableView(); 27 | } 28 | 29 | @Override 30 | public void onHiddenChanged(boolean hidden) { 31 | // TODO Auto-generated method stub 32 | super.onHiddenChanged(hidden); 33 | } 34 | 35 | public Displayable getDisplayable() { 36 | return displayable; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/control/VolumeControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media.control; 18 | 19 | import javax.microedition.media.Control; 20 | 21 | public interface VolumeControl extends Control 22 | { 23 | public void setMute(boolean mute); 24 | public boolean isMuted(); 25 | 26 | public int setLevel(int level); 27 | public int getLevel(); 28 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/StreamConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | 23 | public interface StreamConnection extends Connection 24 | { 25 | public InputStream openInputStream() throws IOException; 26 | public OutputStream openOutputStream() throws IOException; 27 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/DeviceClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import android.bluetooth.BluetoothClass; 20 | 21 | public class DeviceClass 22 | { 23 | protected BluetoothClass cls; 24 | 25 | public DeviceClass(BluetoothClass cls) 26 | { 27 | this.cls = cls; 28 | } 29 | 30 | public int getMajorDeviceClass() 31 | { 32 | return cls.getMajorDeviceClass(); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/RecordStoreException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | public class RecordStoreException extends Exception 20 | { 21 | public RecordStoreException(Exception e) 22 | { 23 | super(e); 24 | } 25 | 26 | public RecordStoreException() 27 | { 28 | } 29 | 30 | public RecordStoreException(String message) 31 | { 32 | super(message); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Ticker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public class Ticker 20 | { 21 | protected String text; 22 | 23 | public Ticker(String text) 24 | { 25 | setString(text); 26 | } 27 | 28 | public void setString(String text) 29 | { 30 | this.text = text; 31 | } 32 | 33 | public String getString() 34 | { 35 | return text; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/amms/control/EffectControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.amms.control; 18 | 19 | import javax.microedition.media.Control; 20 | 21 | public interface EffectControl extends Control 22 | { 23 | public String[] getPresetNames(); 24 | 25 | public void setPreset(String preset); 26 | public String getPreset(); 27 | 28 | public void setEnabled(boolean enable); 29 | public boolean isEnabled(); 30 | } -------------------------------------------------------------------------------- /app/src/main/java/filelog/Log.java: -------------------------------------------------------------------------------- 1 | package filelog; 2 | 3 | import android.os.Environment; 4 | import java.io.File; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Date; 8 | 9 | public class Log { 10 | 11 | private static final String token = " : "; 12 | private static final long MAX_LEN = 300 * 1024;//50 Kb 13 | 14 | public static void d(String tag, String message) { 15 | try { 16 | boolean noClear; 17 | File file = new File(Environment.getExternalStorageDirectory(), "log_j2meloader.txt"); 18 | if (file.length() > MAX_LEN) { 19 | noClear = false; 20 | } else { 21 | noClear = true; 22 | } 23 | FileWriter fw = new FileWriter(file, noClear); 24 | String msg = "\n" + new Date().toLocaleString() + token + tag + token + message; 25 | fw.write(msg); 26 | fw.flush(); 27 | fw.close(); 28 | //Log.d("L", msg); 29 | } catch (IOException e) { 30 | android.util.Log.e("L", "err in logging", e); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/event/SimpleEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.event; 18 | 19 | import javax.microedition.lcdui.Event; 20 | 21 | public abstract class SimpleEvent extends Event 22 | { 23 | public void recycle() 24 | { 25 | } 26 | 27 | public void enterQueue() 28 | { 29 | } 30 | 31 | public void leaveQueue() 32 | { 33 | } 34 | 35 | public boolean placeableAfter(Event event) 36 | { 37 | return true; 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/ConnectionNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | 21 | public class ConnectionNotFoundException extends IOException 22 | { 23 | public ConnectionNotFoundException(String message) 24 | { 25 | super(message); 26 | } 27 | 28 | public ConnectionNotFoundException(Exception e) 29 | { 30 | super(e); 31 | } 32 | 33 | public ConnectionNotFoundException() 34 | { 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/AppItem.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | /** 4 | * 5 | * @author Naik 6 | */ 7 | public class AppItem { 8 | 9 | private int imageId; 10 | private String title; 11 | private String author; 12 | private String version; 13 | private String path; 14 | 15 | public AppItem(int imageId_, String title_, String author_, String version_) { 16 | imageId = imageId_; 17 | title = title_; 18 | author = author_; 19 | version = version_; 20 | } 21 | 22 | public void setPath(String p) { 23 | path = p; 24 | } 25 | 26 | public String getPath() { 27 | return path; 28 | } 29 | 30 | public void setTitle(String title_) { 31 | title = title_; 32 | } 33 | 34 | public String getTitle() { 35 | return title; 36 | } 37 | 38 | public void setImageId(int imageId) { 39 | this.imageId = imageId; 40 | } 41 | 42 | public int getImageId() { 43 | return imageId; 44 | } 45 | 46 | public String getAuthor() { 47 | return author; 48 | } 49 | 50 | public String getVersion() { 51 | return version; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/AlertType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public class AlertType 20 | { 21 | public static final AlertType ALARM = new AlertType(); 22 | public static final AlertType CONFIRMATION = new AlertType(); 23 | public static final AlertType ERROR = new AlertType(); 24 | public static final AlertType INFO = new AlertType(); 25 | public static final AlertType WARNING = new AlertType(); 26 | 27 | public void playSound(Display display) 28 | { 29 | } 30 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/RemoteDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import android.bluetooth.BluetoothDevice; 20 | 21 | public class RemoteDevice 22 | { 23 | protected BluetoothDevice device; 24 | 25 | public RemoteDevice(BluetoothDevice device) 26 | { 27 | this.device = device; 28 | } 29 | 30 | public String getBluetoothAddress() 31 | { 32 | return BTUtils.formatBluetoothAddress(device.getAddress()); 33 | } 34 | 35 | public String getFriendlyName(boolean alwaysAsk) 36 | { 37 | return device.getName(); 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/shell/MyClassLoader.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.shell; 2 | 3 | import dalvik.system.DexClassLoader; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.InputStream; 7 | import java.io.FileNotFoundException; 8 | import filelog.Log; 9 | 10 | public class MyClassLoader extends DexClassLoader { 11 | 12 | private static final String tag = MyClassLoader.class.getName(); 13 | private File resFolder; 14 | 15 | public MyClassLoader(String paths, String tmpDir, String libs, ClassLoader parent, String resDir) { 16 | super(paths, tmpDir, libs, parent); 17 | this.resFolder = new File(resDir); 18 | } 19 | 20 | @Override 21 | public InputStream getResourceAsStream(String resName) { 22 | System.err.println("CUSTOM GET RES CALLED WITH PATH: " + resName); 23 | Log.d(tag, "CUSTOM GET RES CALLED WITH PATH: " + resName); 24 | try { 25 | return new FileInputStream(new File(resFolder, resName)); 26 | } catch (FileNotFoundException e) { 27 | System.err.println("Can't load res " + resName + " on path: " + resFolder.getPath() + resName); 28 | Log.d(tag, "Can't load res " + resName + " on path: " + resFolder.getPath() + resName); 29 | return null; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/amms/control/audioeffect/EqualizerControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.amms.control.audioeffect; 18 | 19 | import javax.microedition.amms.control.EffectControl; 20 | 21 | public interface EqualizerControl extends EffectControl 22 | { 23 | public int getNumberOfBands(); 24 | public int getBand(int frequency); 25 | public int getCenterFreq(int band); 26 | 27 | public int getMinBandLevel(); 28 | public int getMaxBandLevel(); 29 | 30 | public void setBandLevel(int level, int band); 31 | public int getBandLevel(int band); 32 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/ViewHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import android.os.Handler; 20 | import android.os.Looper; 21 | 22 | /** 23 | * Класс для централизованного создания и изменения View. 24 | * Необходим, потому что чертов Android не дает изменять View из разных потоков. 25 | */ 26 | public class ViewHandler 27 | { 28 | private static Handler handler; 29 | 30 | static 31 | { 32 | handler = new Handler(Looper.getMainLooper()); 33 | } 34 | 35 | public static void postEvent(Runnable event) 36 | { 37 | handler.post(event); 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/param/DataEditor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.param; 18 | 19 | public interface DataEditor 20 | { 21 | public DataEditor clear(); 22 | public DataEditor remove(String key); 23 | 24 | public DataEditor putBoolean(String key, boolean value); 25 | public DataEditor putFloat(String key, float value); 26 | public DataEditor putInt(String key, int value); 27 | public DataEditor putLong(String key, long value); 28 | public DataEditor putString(String key, String value); 29 | 30 | public void apply(); 31 | public boolean commit(); 32 | 33 | public void close(); 34 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/ServiceRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.util.UUID; 20 | 21 | public class ServiceRecord 22 | { 23 | protected RemoteDevice device; 24 | protected UUID uuid; 25 | 26 | public ServiceRecord(RemoteDevice device, UUID uuid) 27 | { 28 | this.device = device; 29 | this.uuid = uuid; 30 | } 31 | 32 | public RemoteDevice getHostDevice() 33 | { 34 | return device; 35 | } 36 | 37 | public String getConnectionURL(int requiredSecurity, boolean mustBeMaster) 38 | { 39 | return "btl2cap://" + device.getBluetoothAddress() + ":" + uuid.toString(); 40 | } 41 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/HttpConnectionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | import java.net.HttpURLConnection; 21 | import java.net.URL; 22 | 23 | public class HttpConnectionProvider implements ConnectionProvider 24 | { 25 | public Connection open(String name, int mode) throws IOException 26 | { 27 | HttpURLConnection conn = (HttpURLConnection)(new URL("http://" + name)).openConnection(); 28 | 29 | conn.setDoInput(true); 30 | conn.setDoOutput(true); 31 | conn.setChunkedStreamingMode(0); 32 | 33 | return new HttpConnection(conn); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/rms/RecordEnumeration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.rms; 18 | 19 | import java.util.ArrayList; 20 | 21 | public class RecordEnumeration 22 | { 23 | protected RecordStore store; 24 | 25 | protected ArrayList ids; 26 | protected int index; 27 | 28 | public RecordEnumeration(RecordStore store, ArrayList ids) 29 | { 30 | this.store = store; 31 | this.ids = ids; 32 | this.index = 0; 33 | } 34 | 35 | public boolean hasNextElement() 36 | { 37 | return index < ids.size(); 38 | } 39 | 40 | public int nextRecordId() 41 | { 42 | return ids.get(index++); 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/FSItem.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | /** 4 | * 5 | * @author Naik 6 | */ 7 | public class FSItem implements SortItem { 8 | 9 | private int imageId; 10 | Type type; 11 | private String name, descr; 12 | 13 | public FSItem(int imageId, String name, String descr, Type type) { 14 | this.imageId = imageId; 15 | this.name = name; 16 | this.descr = descr; 17 | this.type = type; 18 | } 19 | 20 | public void setType(Type t) { 21 | type = t; 22 | } 23 | 24 | public Type getType() { 25 | return type; 26 | } 27 | 28 | public void setName(String header) { 29 | this.name = header; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setDescription(String subheader) { 37 | this.descr = subheader; 38 | } 39 | 40 | public String getDescription() { 41 | return descr; 42 | } 43 | 44 | public void setImageId(int imageId) { 45 | this.imageId = imageId; 46 | } 47 | 48 | public int getImageId() { 49 | return imageId; 50 | } 51 | 52 | public String getSortField() { 53 | return name; 54 | } 55 | 56 | public enum Type { 57 | 58 | Folder, File, Back 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/ambilwarna_pemilih.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 23 | 24 | 32 | 33 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/XMLForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import android.view.LayoutInflater; 20 | import android.view.View; 21 | 22 | public class XMLForm extends Screen 23 | { 24 | protected View view; 25 | protected int resID; 26 | 27 | public XMLForm(String title, int resID) 28 | { 29 | setTitle(title); 30 | this.resID = resID; 31 | } 32 | 33 | public View getScreenView() 34 | { 35 | if(view == null) 36 | { 37 | view = LayoutInflater.from(getParentActivity()).inflate(resID, null); 38 | } 39 | 40 | return view; 41 | } 42 | 43 | public void clearScreenView() 44 | { 45 | view = null; 46 | } 47 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/L2CAPConnectionNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.io.IOException; 20 | 21 | import javax.microedition.io.Connection; 22 | 23 | import android.bluetooth.BluetoothServerSocket; 24 | 25 | public class L2CAPConnectionNotifier implements Connection 26 | { 27 | protected BluetoothServerSocket socket; 28 | 29 | public L2CAPConnectionNotifier(BluetoothServerSocket socket) 30 | { 31 | this.socket = socket; 32 | } 33 | 34 | public L2CAPConnection acceptAndOpen() throws IOException 35 | { 36 | return new L2CAPConnection(socket.accept()); 37 | } 38 | 39 | public void close() throws IOException 40 | { 41 | socket.close(); 42 | } 43 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/DiscoveryAgent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.util.UUID; 20 | 21 | public interface DiscoveryAgent 22 | { 23 | public static final int CACHED = 0; 24 | public static final int PREKNOWN = 1; 25 | 26 | public static final int NOT_DISCOVERABLE = 0; 27 | public static final int LIAC = 10390272; 28 | public static final int GIAC = 10390323; 29 | 30 | public boolean startInquiry(int accessCode, DiscoveryListener listener); 31 | public boolean cancelInquiry(DiscoveryListener listener); 32 | public int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, DiscoveryListener discListener); 33 | public boolean cancelServiceSearch(int transID); 34 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/param/DataContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.param; 18 | 19 | public interface DataContainer 20 | { 21 | public DataEditor edit(); 22 | 23 | public boolean contains(String key); 24 | 25 | public boolean getBoolean(String key, boolean defValue); 26 | public float getFloat(String key, float defValue); 27 | public int getInt(String key, int defValue); 28 | public long getLong(String key, long defValue); 29 | public String getString(String key, String defValue); 30 | 31 | public boolean getBoolean(String key); 32 | public float getFloat(String key); 33 | public int getInt(String key); 34 | public long getLong(String key); 35 | public String getString(String key); 36 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/PlayerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media; 18 | 19 | public interface PlayerListener 20 | { 21 | public static final String CLOSED = "closed"; 22 | public static final String DEVICE_AVAILABLE = "deviceAvailable"; 23 | public static final String DEVICE_UNAVAILABLE = "deviceUnavailable"; 24 | public static final String DURATION_UPDATED = "durationUpdated"; 25 | public static final String END_OF_MEDIA = "endOfMedia"; 26 | public static final String ERROR = "error"; 27 | public static final String STARTED = "started"; 28 | public static final String STOPPED = "stopped"; 29 | public static final String VOLUME_CHANGED = "volumeChanged"; 30 | 31 | public void playerUpdate(Player player, String event, Object eventData); 32 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/DiscoveryListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | public interface DiscoveryListener 20 | { 21 | public static final int INQUIRY_COMPLETED = 0; 22 | public static final int SERVICE_SEARCH_COMPLETED = 1; 23 | public static final int SERVICE_SEARCH_TERMINATED = 2; 24 | public static final int SERVICE_SEARCH_ERROR = 3; 25 | public static final int SERVICE_SEARCH_NO_RECORDS = 4; 26 | public static final int INQUIRY_TERMINATED = 5; 27 | public static final int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 6; 28 | public static final int INQUIRY_ERROR = 7; 29 | 30 | public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod); 31 | public void servicesDiscovered(int transID, ServiceRecord[] servRecord); 32 | public void serviceSearchCompleted(int transID, int respCode); 33 | public void inquiryCompleted(int discType); 34 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/list/CompoundSpinnerAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.list; 18 | 19 | import android.content.Context; 20 | import android.view.View; 21 | import android.view.ViewGroup; 22 | import android.widget.SpinnerAdapter; 23 | 24 | public class CompoundSpinnerAdapter extends CompoundAdapter implements SpinnerAdapter 25 | { 26 | public CompoundSpinnerAdapter(Context context) 27 | { 28 | super(context); 29 | } 30 | 31 | public View getView(int position, View convertView, ViewGroup parent) 32 | { 33 | return getView(position, convertView, parent, android.R.layout.simple_spinner_item, false); 34 | } 35 | 36 | public View getDropDownView(int position, View convertView, ViewGroup parent) 37 | { 38 | return getView(position, convertView, parent, android.R.layout.simple_spinner_dropdown_item, true); 39 | } 40 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/list_row.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 21 | 22 | 23 | 33 | 34 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/ambilwarna_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 22 | 23 | 27 | 28 | 36 | 37 | 44 | 45 | 46 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/control/VideoControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media.control; 18 | 19 | import javax.microedition.media.Control; 20 | import javax.microedition.media.MediaException; 21 | 22 | public interface VideoControl extends Control 23 | { 24 | public static final int USE_DIRECT_VIDEO = 1; 25 | 26 | public Object initDisplayMode(int mode, Object arg); 27 | 28 | public void setDisplayLocation(int x, int y); 29 | public void setDisplaySize(int width, int height) throws MediaException; 30 | public void setDisplayFullScreen(boolean fullScreenMode) throws MediaException; 31 | public void setVisible(boolean visible); 32 | 33 | public int getSourceWidth(); 34 | public int getSourceHeight(); 35 | 36 | public int getDisplayX(); 37 | public int getDisplayY(); 38 | 39 | public int getDisplayWidth(); 40 | public int getDisplayHeight(); 41 | 42 | public byte[] getSnapshot(java.lang.String imageType) throws MediaException; 43 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Spacer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import android.view.View; 20 | 21 | public class Spacer extends Item 22 | { 23 | private int width, height; 24 | private View view; 25 | 26 | public Spacer(int width, int height) 27 | { 28 | this.width = width; 29 | this.height = height; 30 | } 31 | 32 | public void setMinimumSize(int width, int height) 33 | { 34 | this.width = width; 35 | this.height = height; 36 | 37 | if(view != null) 38 | { 39 | view.setMinimumWidth(width); 40 | view.setMinimumHeight(height); 41 | } 42 | } 43 | 44 | public View getItemContentView() 45 | { 46 | if(view == null) 47 | { 48 | view = new View(getOwnerForm().getParentActivity()); 49 | 50 | view.setMinimumWidth(width); 51 | view.setMinimumHeight(height); 52 | } 53 | 54 | return view; 55 | } 56 | 57 | public void clearItemContentView() 58 | { 59 | view = null; 60 | } 61 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/ImmediateOutputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | import java.io.OutputStream; 21 | 22 | public class ImmediateOutputStream extends OutputStream 23 | { 24 | protected StreamConnection base; 25 | protected OutputStream out; 26 | 27 | public ImmediateOutputStream(StreamConnection conn) throws IOException 28 | { 29 | base = conn; 30 | out = conn.openOutputStream(); 31 | } 32 | 33 | public void close() throws IOException 34 | { 35 | out.close(); 36 | base.close(); 37 | } 38 | 39 | public void flush() throws IOException 40 | { 41 | out.flush(); 42 | } 43 | 44 | public void write(int b) throws IOException 45 | { 46 | out.write(b); 47 | } 48 | 49 | public void write(byte[] b) throws IOException 50 | { 51 | out.write(b, 0, b.length); 52 | } 53 | 54 | public void write(byte[] b, int off, int len) throws IOException 55 | { 56 | out.write(b, off, len); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/Player.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media; 18 | 19 | public interface Player extends Controllable 20 | { 21 | public static final int CLOSED = 0; 22 | public static final int UNREALIZED = 100; 23 | public static final int REALIZED = 200; 24 | public static final int PREFETCHED = 300; 25 | public static final int STARTED = 400; 26 | 27 | public static final long TIME_UNKNOWN = -1; 28 | 29 | public void realize() throws MediaException; 30 | public void prefetch() throws MediaException; 31 | public void start() throws MediaException; 32 | public void stop() throws MediaException; 33 | public void deallocate(); 34 | public void close(); 35 | 36 | public long setMediaTime(long now) throws MediaException; 37 | public long getMediaTime(); 38 | public long getDuration(); 39 | public void setLoopCount(int count); 40 | 41 | public int getState(); 42 | 43 | public void addPlayerListener(PlayerListener playerListener); 44 | public void removePlayerListener(PlayerListener playerListener); 45 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/list/CompoundItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.list; 18 | 19 | import javax.microedition.lcdui.Image; 20 | 21 | import android.graphics.drawable.BitmapDrawable; 22 | import android.graphics.drawable.Drawable; 23 | 24 | public class CompoundItem 25 | { 26 | protected String stringPart; 27 | 28 | protected Image imagePart; 29 | protected Drawable imageDrawable; 30 | 31 | public CompoundItem(String stringPart, Image imagePart) 32 | { 33 | this.stringPart = stringPart; 34 | this.imagePart = imagePart; 35 | } 36 | 37 | public void setString(String stringPart) 38 | { 39 | this.stringPart = stringPart; 40 | } 41 | 42 | public String getString() 43 | { 44 | return stringPart; 45 | } 46 | 47 | public void setImage(Image imagePart) 48 | { 49 | this.imagePart = imagePart; 50 | this.imageDrawable = new BitmapDrawable(imagePart.getBitmap()); 51 | } 52 | 53 | public Image getImage() 54 | { 55 | return imagePart; 56 | } 57 | 58 | public Drawable getDrawable() 59 | { 60 | return imageDrawable; 61 | } 62 | } -------------------------------------------------------------------------------- /app/src/main/java/yuku/ambilwarna/AmbilWarnaKotak.java: -------------------------------------------------------------------------------- 1 | package yuku.ambilwarna; 2 | 3 | import android.content.*; 4 | import android.graphics.*; 5 | import android.graphics.Shader.TileMode; 6 | import android.util.*; 7 | import android.view.*; 8 | /* change this import */ 9 | import ua.naiksoftware.j2meloader.R; 10 | 11 | public class AmbilWarnaKotak extends View { 12 | 13 | public AmbilWarnaKotak(Context context) { 14 | this(context, null); 15 | } 16 | 17 | public AmbilWarnaKotak(Context context, AttributeSet attrs) { 18 | this(context, attrs, 0); 19 | } 20 | 21 | public AmbilWarnaKotak(Context context, AttributeSet attrs, int defStyle) { 22 | super(context, attrs, defStyle); 23 | 24 | satudp = context.getResources().getDimension(R.dimen.ambilwarna_satudp); 25 | } 26 | Paint paint; 27 | Shader dalam; 28 | Shader luar; 29 | float hue; 30 | float satudp; 31 | float[] tmp00 = new float[3]; 32 | 33 | @Override 34 | protected void onDraw(Canvas canvas) { 35 | super.onDraw(canvas); 36 | 37 | if (paint == null) { 38 | paint = new Paint(); 39 | luar = new LinearGradient(0.f, 0.f, 0.f, 256.f, 0xffffffff, 0xff000000, TileMode.CLAMP); 40 | } 41 | 42 | tmp00[1] = tmp00[2] = 1.f; 43 | tmp00[0] = hue; 44 | int rgb = Color.HSVToColor(tmp00); 45 | 46 | dalam = new LinearGradient(0.f, 0.f, 256.f, 0.f, 0xffffffff, rgb, TileMode.CLAMP); 47 | ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY); 48 | 49 | paint.setShader(shader); 50 | 51 | canvas.drawRect(0.f, 0.f, 256.f, 256.f, paint); 52 | } 53 | 54 | void setHue(float hue) { 55 | this.hue = hue; 56 | invalidate(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 18 | 19 | 26 | 30 | 31 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/event/RunnableEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.event; 18 | 19 | import javax.microedition.lcdui.Event; 20 | import javax.microedition.util.ArrayStack; 21 | 22 | public class RunnableEvent extends Event 23 | { 24 | private static ArrayStack recycled = new ArrayStack(); 25 | 26 | private Runnable runnable; 27 | 28 | private RunnableEvent() 29 | { 30 | } 31 | 32 | public static Event getInstance(Runnable runnable) 33 | { 34 | RunnableEvent instance = recycled.pop(); 35 | 36 | if(instance == null) 37 | { 38 | instance = new RunnableEvent(); 39 | } 40 | 41 | instance.runnable = runnable; 42 | 43 | return instance; 44 | } 45 | 46 | public void process() 47 | { 48 | runnable.run(); 49 | } 50 | 51 | public void recycle() 52 | { 53 | runnable = null; 54 | recycled.push(this); 55 | } 56 | 57 | public void enterQueue() 58 | { 59 | } 60 | 61 | public void leaveQueue() 62 | { 63 | } 64 | 65 | public boolean placeableAfter(Event event) 66 | { 67 | return true; 68 | } 69 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Choice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public interface Choice 20 | { 21 | public static final int EXCLUSIVE = 1; 22 | public static final int MULTIPLE = 2; 23 | public static final int IMPLICIT = 3; 24 | public static final int POPUP = 4; 25 | 26 | public static final int TEXT_WRAP_DEFAULT = 0; 27 | public static final int TEXT_WRAP_ON = 1; 28 | public static final int TEXT_WRAP_OFF = 2; 29 | 30 | public int append(String stringPart, Image imagePart); 31 | public void delete(int elementNum); 32 | public void deleteAll(); 33 | public Image getImage(int elementNum); 34 | public int getSelectedFlags(boolean[] selectedArray_return); 35 | public int getSelectedIndex(); 36 | public String getString(int elementNum); 37 | public void insert(int elementNum, String stringPart, Image imagePart); 38 | public boolean isSelected(int elementNum); 39 | public void set(int elementNum, String stringPart, Image imagePart); 40 | public void setSelectedFlags(boolean[] selectedArray); 41 | public void setSelectedIndex(int elementNum, boolean selected); 42 | public int size(); 43 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/util/ArrayStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.util; 18 | 19 | public class ArrayStack 20 | { 21 | public static final int DELTA = 100; 22 | 23 | protected Object[] data; 24 | protected int index; 25 | 26 | public ArrayStack() 27 | { 28 | clear(); 29 | } 30 | 31 | public void push(E value) 32 | { 33 | if(index >= data.length - 1) 34 | { 35 | Object[] temp = new Object[data.length + DELTA]; 36 | System.arraycopy(data, 0, temp, 0, data.length); 37 | data = temp; 38 | } 39 | 40 | data[++index] = value; 41 | } 42 | 43 | public E pop() 44 | { 45 | if(index < 0) 46 | { 47 | return null; 48 | } 49 | 50 | // if(index + (DELTA << 1) <= data.length - 1) 51 | // { 52 | // Object[] temp = new Object[data.length - DELTA]; 53 | // System.arraycopy(data, 0, temp, 0, temp.length); 54 | // data = temp; 55 | // } 56 | 57 | return (E)data[index--]; 58 | } 59 | 60 | public void clear() 61 | { 62 | data = new Object[0]; 63 | index = -1; 64 | } 65 | 66 | public boolean empty() 67 | { 68 | return index < 0; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/ImageItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import android.view.View; 20 | import android.widget.ImageView; 21 | 22 | public class ImageItem extends Item 23 | { 24 | private Image image; 25 | private ImageView imgview; 26 | 27 | public ImageItem(String label, Image image, int layout, String altText) 28 | { 29 | this(label, image, layout, altText, PLAIN); 30 | } 31 | 32 | public ImageItem(String label, Image image, int layout, String altText, int appearanceMode) 33 | { 34 | setLabel(label); 35 | setImage(image); 36 | setLayout(layout); 37 | } 38 | 39 | public void setImage(Image img) 40 | { 41 | image = img; 42 | 43 | if(imgview != null) 44 | { 45 | imgview.setImageBitmap(image != null ? image.getBitmap() : null); 46 | } 47 | } 48 | 49 | public Image getImage() 50 | { 51 | return image; 52 | } 53 | 54 | public View getItemContentView() 55 | { 56 | if(imgview == null) 57 | { 58 | imgview = new ImageView(getOwnerForm().getParentActivity()); 59 | imgview.setImageBitmap(image != null ? image.getBitmap() : null); 60 | } 61 | 62 | return imgview; 63 | } 64 | 65 | public void clearItemContentView() 66 | { 67 | imgview = null; 68 | } 69 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/AppsListAdapter.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | import android.content.*; 4 | import android.view.*; 5 | import android.widget.*; 6 | import java.util.*; 7 | import ua.naiksoftware.j2meloader.R; 8 | 9 | /** 10 | * 11 | * @author Naik 12 | */ 13 | public class AppsListAdapter extends BaseAdapter { 14 | 15 | private List list; 16 | private final LayoutInflater li; 17 | 18 | public AppsListAdapter(Context context, List arr) { 19 | if (arr != null) { 20 | list = arr; 21 | } 22 | li = LayoutInflater.from(context); 23 | } 24 | 25 | public int getCount() { 26 | return list.size(); 27 | } 28 | 29 | public Object getItem(int position) { 30 | return list.get(position); 31 | } 32 | 33 | public long getItemId(int position) { 34 | return position; 35 | } 36 | 37 | public View getView(int position, View view, ViewGroup viewGroup) { 38 | ViewHolder holder; 39 | if (view == null) { 40 | view = li.inflate(R.layout.list_row_jar, null); 41 | holder = new ViewHolder(); 42 | holder.icon = (ImageView) view.findViewById(R.id.list_image); 43 | holder.name = (TextView) view.findViewById(R.id.list_title); 44 | holder.author = (TextView) view.findViewById(R.id.list_author); 45 | holder.version = (TextView) view.findViewById(R.id.list_version); 46 | view.setTag(holder); 47 | } else { 48 | holder = (ViewHolder) view.getTag(); 49 | } 50 | AppItem item = list.get(position); 51 | 52 | holder.icon.setImageResource(item.getImageId()); 53 | holder.name.setText(item.getTitle()); 54 | holder.author.setText(item.getAuthor()); 55 | holder.version.setText(item.getVersion()); 56 | 57 | return view; 58 | } 59 | 60 | private static class ViewHolder { 61 | ImageView icon; 62 | TextView name; 63 | TextView author; 64 | TextView version; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/control/MetaDataControl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media.control; 18 | 19 | import javax.microedition.media.Control; 20 | 21 | public interface MetaDataControl extends Control 22 | { 23 | public static final String TRACK_NUMBER_KEY = "tracknum"; 24 | public static final String ALBUM_KEY = "album"; 25 | public static final String ARTIST_KEY = "artist"; 26 | public static final String AUTHOR_KEY = "author"; 27 | public static final String COMPOSER_KEY = "composer"; 28 | public static final String DATE_KEY = "date"; 29 | public static final String GENRE_KEY = "genre"; 30 | public static final String TITLE_KEY = "title"; 31 | public static final String YEAR_KEY = "year"; 32 | public static final String DURATION_KEY = "duration"; 33 | public static final String NUM_TRACKS_KEY = "numtracks"; 34 | public static final String WRITER_KEY = "writer"; 35 | public static final String MIME_TYPE_KEY = "mimetype"; 36 | public static final String ALBUM_ARTIST_KEY = "albumartist"; 37 | public static final String DISC_NUMBER_KEY = "discnum"; 38 | public static final String COMPILATION_KEY = "compilation"; 39 | public static final String COPYRIGHT_KEY = "copyright"; 40 | 41 | public String[] getKeys(); 42 | public String getKeyValue(String key); 43 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/game/GameCanvas.java: -------------------------------------------------------------------------------- 1 | package javax.microedition.lcdui.game; 2 | 3 | import javax.microedition.lcdui.Canvas; 4 | import javax.microedition.lcdui.Graphics; 5 | import javax.microedition.lcdui.Image; 6 | 7 | public class GameCanvas extends Canvas { 8 | 9 | private Image image; 10 | private Graphics graphics; 11 | private int key; 12 | public static final int UP_PRESSED = 1 << Canvas.UP; 13 | public static final int DOWN_PRESSED = 1 << Canvas.DOWN; 14 | public static final int LEFT_PRESSED = 1 << Canvas.LEFT; 15 | public static final int RIGHT_PRESSED = 1 << Canvas.RIGHT; 16 | public static final int FIRE_PRESSED = 1 << Canvas.FIRE; 17 | public static final int GAME_A_PRESSED = 1 << Canvas.GAME_A; 18 | public static final int GAME_B_PRESSED = 1 << Canvas.GAME_B; 19 | public static final int GAME_C_PRESSED = 1 << Canvas.GAME_C; 20 | public static final int GAME_D_PRESSED = 1 << Canvas.GAME_D; 21 | 22 | public GameCanvas(boolean suppressCommands) { 23 | super(); 24 | image = Image.createImage(getWidth(), getHeight()); 25 | graphics = image.getGraphics(); 26 | } 27 | 28 | public void paint(Graphics g) { 29 | g.drawImage(image, 0, 0, Graphics.LEFT | Graphics.TOP); 30 | } 31 | 32 | public void keyPressed(int keyCode) { 33 | switch (keyCode) { 34 | case KEY_LEFT: 35 | case KEY_NUM4: 36 | key = LEFT_PRESSED; 37 | break; 38 | case KEY_UP: 39 | case KEY_NUM2: 40 | key = UP_PRESSED; 41 | break; 42 | case KEY_RIGHT: 43 | case KEY_NUM6: 44 | key = RIGHT_PRESSED; 45 | break; 46 | case KEY_DOWN: 47 | case KEY_NUM8: 48 | key = DOWN_PRESSED; 49 | break; 50 | } 51 | } 52 | 53 | public void keyReleased(int keyCode) { 54 | key = 0; 55 | } 56 | 57 | public int getKeyStates() { 58 | return key; 59 | } 60 | 61 | public Graphics getGraphics() { 62 | return graphics; 63 | } 64 | 65 | public void flushGraphics() { 66 | repaint(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/AppsListFragment.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.microedition.lcdui.Display; 7 | import javax.microedition.midlet.MIDlet; 8 | import javax.microedition.shell.ConfScreen; 9 | import javax.microedition.util.ContextHolder; 10 | 11 | import android.os.Bundle; 12 | import android.support.v4.app.ListFragment; 13 | import android.view.View; 14 | import android.widget.ListView; 15 | 16 | /** 17 | * 18 | * @author Naik 19 | */ 20 | public class AppsListFragment extends ListFragment { 21 | 22 | private static ArrayList confScreens = new ArrayList(); 23 | private static ConfScreen currConfScreen; 24 | 25 | public static ConfScreen getCurrConf() { 26 | return currConfScreen; 27 | } 28 | 29 | private List apps; 30 | 31 | public AppsListFragment() { 32 | } 33 | 34 | public AppsListFragment(List apps) { 35 | this.apps = apps; 36 | } 37 | 38 | @Override 39 | public void onActivityCreated(Bundle savedInstanceState) { 40 | super.onActivityCreated(savedInstanceState); 41 | 42 | } 43 | 44 | @Override 45 | public void onListItemClick(ListView l, View v, int position, long id) { 46 | ContextHolder.setContext((MainActivity) getActivity()); 47 | MIDlet confMidlet = new ConfMidlet(); 48 | confMidlet.start(apps.get(position)); 49 | } 50 | 51 | private static class ConfMidlet extends MIDlet { 52 | 53 | private ConfScreen confScreen; 54 | private boolean paused; 55 | 56 | @Override 57 | public void startApp() { 58 | Display d = Display.getDisplay(this); 59 | if (paused) { 60 | d.setCurrent(confScreen); 61 | } else { 62 | confScreen = new ConfScreen(this, getAppItem()); 63 | confScreens.add(confScreen); 64 | currConfScreen = confScreen; 65 | d.setCurrent(confScreen); 66 | } 67 | } 68 | 69 | @Override 70 | public void pauseApp() { 71 | paused = true; 72 | confScreen.saveParams(); 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/ImmediateInputStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | public class ImmediateInputStream extends InputStream 23 | { 24 | protected StreamConnection base; 25 | protected InputStream in; 26 | 27 | public ImmediateInputStream(StreamConnection conn) throws IOException 28 | { 29 | base = conn; 30 | in = conn.openInputStream(); 31 | } 32 | 33 | public int available() throws IOException 34 | { 35 | return in.available(); 36 | } 37 | 38 | public void close() throws IOException 39 | { 40 | in.close(); 41 | base.close(); 42 | } 43 | 44 | public void mark(int readLimit) 45 | { 46 | in.mark(readLimit); 47 | } 48 | 49 | public boolean markSupported() 50 | { 51 | return in.markSupported(); 52 | } 53 | 54 | public int read() throws IOException 55 | { 56 | return in.read(); 57 | } 58 | 59 | public int read(byte[] b) throws IOException 60 | { 61 | return in.read(b, 0, b.length); 62 | } 63 | 64 | public int read(byte[] b, int off, int len) throws IOException 65 | { 66 | return in.read(b, off, len); 67 | } 68 | 69 | public void reset() throws IOException 70 | { 71 | in.reset(); 72 | } 73 | 74 | public long skip(long n) throws IOException 75 | { 76 | return in.skip(n); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/BTUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.util.UUID; 20 | 21 | import android.bluetooth.BluetoothAdapter; 22 | 23 | public class BTUtils 24 | { 25 | public static UUID parseUUID(String uuidValue) 26 | { 27 | try 28 | { 29 | return UUID.fromString(uuidValue); 30 | } 31 | catch(IllegalArgumentException x) 32 | { 33 | StringBuilder buf = new StringBuilder(36); 34 | buf.append(uuidValue); 35 | 36 | while(buf.length() < 32) 37 | { 38 | buf.insert(0, '0'); 39 | } 40 | 41 | buf.insert(8, '-'); 42 | buf.insert(13, '-'); 43 | buf.insert(18, '-'); 44 | buf.insert(23, '-'); 45 | 46 | return UUID.fromString(buf.toString()); 47 | } 48 | } 49 | 50 | public static String validateBluetoothAddress(String address) 51 | { 52 | if(BluetoothAdapter.checkBluetoothAddress(address)) 53 | { 54 | return address; 55 | } 56 | else 57 | { 58 | StringBuilder buf = new StringBuilder(17); 59 | buf.append(address.toUpperCase()); 60 | 61 | buf.insert(2, ':'); 62 | buf.insert(5, ':'); 63 | buf.insert(8, ':'); 64 | buf.insert(11, ':'); 65 | buf.insert(14, ':'); 66 | 67 | return buf.toString(); 68 | } 69 | } 70 | 71 | public static String formatBluetoothAddress(String address) 72 | { 73 | return address.replace(":", ""); 74 | } 75 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/FileListAdapter.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | /** 4 | * 5 | * @author Naik 6 | */ 7 | import android.content.Context; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.BaseAdapter; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | import java.util.ArrayList; 15 | import ua.naiksoftware.j2meloader.FSItem; 16 | import ua.naiksoftware.j2meloader.R; 17 | 18 | public class FileListAdapter extends BaseAdapter { 19 | 20 | private ArrayList list = new ArrayList(); 21 | private final LayoutInflater li; 22 | 23 | public FileListAdapter(Context context, ArrayList arr) { 24 | if (arr != null) { 25 | list = arr; 26 | } 27 | li = LayoutInflater.from(context); 28 | } 29 | 30 | public int getCount() { 31 | return list.size(); 32 | } 33 | 34 | public Object getItem(int position) { 35 | return list.get(position); 36 | } 37 | 38 | public long getItemId(int position) { 39 | return position; 40 | } 41 | 42 | public View getView(int position, View view, ViewGroup viewGroup) { 43 | ViewHolder holder; 44 | if (view == null) { 45 | view = li.inflate(R.layout.list_row, null); 46 | holder = new ViewHolder(); 47 | holder.icon = (ImageView) view.findViewById(R.id.list_image); 48 | holder.label = (TextView) view.findViewById(R.id.list_header); 49 | holder.sublabel = (TextView) view.findViewById(R.id.list_subheader); 50 | view.setTag(holder); 51 | } else { 52 | holder = (ViewHolder) view.getTag(); 53 | } 54 | 55 | FSItem item = list.get(position); 56 | 57 | holder.icon.setImageResource(item.getImageId()); 58 | holder.label.setText(item.getName()); 59 | holder.sublabel.setText(item.getDescription()); 60 | 61 | return view; 62 | } 63 | 64 | private static class ViewHolder { 65 | ImageView icon; 66 | TextView label; 67 | TextView sublabel; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/event/LayoutEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.event; 18 | 19 | import javax.microedition.lcdui.Event; 20 | import javax.microedition.util.ArrayStack; 21 | 22 | import android.view.View; 23 | import android.view.ViewGroup; 24 | 25 | public class LayoutEvent extends Event 26 | { 27 | private static ArrayStack recycled = new ArrayStack(); 28 | 29 | private static final int ADD_VIEW = 0; 30 | 31 | private int eventType; 32 | private ViewGroup layout; 33 | private View view; 34 | 35 | public static Event addView(ViewGroup layout, View view) 36 | { 37 | LayoutEvent instance = recycled.pop(); 38 | 39 | if(instance == null) 40 | { 41 | instance = new LayoutEvent(); 42 | } 43 | 44 | instance.eventType = ADD_VIEW; 45 | 46 | instance.layout = layout; 47 | instance.view = view; 48 | 49 | return instance; 50 | } 51 | 52 | public void process() 53 | { 54 | switch(eventType) 55 | { 56 | case ADD_VIEW: 57 | layout.addView(view); 58 | return; 59 | } 60 | } 61 | 62 | public void recycle() 63 | { 64 | layout = null; 65 | view = null; 66 | 67 | recycled.push(this); 68 | } 69 | 70 | public void enterQueue() 71 | { 72 | } 73 | 74 | public void leaveQueue() 75 | { 76 | } 77 | 78 | public boolean placeableAfter(Event event) 79 | { 80 | return true; 81 | } 82 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/StringItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import javax.microedition.lcdui.event.SimpleEvent; 20 | 21 | import android.content.Context; 22 | import android.view.View; 23 | import android.widget.TextView; 24 | 25 | public class StringItem extends Item 26 | { 27 | private String text; 28 | private TextView textview; 29 | 30 | private SimpleEvent msgSetText = new SimpleEvent() 31 | { 32 | public void process() 33 | { 34 | textview.setText(text); 35 | } 36 | }; 37 | 38 | public StringItem(String label, String text) 39 | { 40 | this(label, text, PLAIN); 41 | } 42 | 43 | public StringItem(String label, String text, int appearanceMode) 44 | { 45 | setLabel(label); 46 | setText(text); 47 | } 48 | 49 | public void setText(String text) 50 | { 51 | this.text = text; 52 | 53 | if(textview != null) 54 | { 55 | ViewHandler.postEvent(msgSetText); 56 | } 57 | } 58 | 59 | public String getText() 60 | { 61 | return text; 62 | } 63 | 64 | public View getItemContentView() 65 | { 66 | if(textview == null) 67 | { 68 | Context context = getOwnerForm().getParentActivity(); 69 | 70 | textview = new TextView(context); 71 | textview.setTextAppearance(context, android.R.style.TextAppearance_Small); 72 | textview.setText(text); 73 | } 74 | 75 | return textview; 76 | } 77 | 78 | public void clearItemContentView() 79 | { 80 | textview = null; 81 | } 82 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/BTL2CAPConnectionProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.io.IOException; 20 | 21 | import javax.microedition.io.Connection; 22 | import javax.microedition.io.ConnectionProvider; 23 | 24 | import android.bluetooth.BluetoothAdapter; 25 | import android.bluetooth.BluetoothDevice; 26 | import android.bluetooth.BluetoothSocket; 27 | 28 | public class BTL2CAPConnectionProvider implements ConnectionProvider 29 | { 30 | public Connection open(String name, int mode) throws IOException 31 | { 32 | if(name.startsWith("localhost:")) 33 | { 34 | String[] params = name.substring(10).split(";"); 35 | name = null; 36 | 37 | for(int i = 1; i < params.length; i++) 38 | { 39 | if(params[i].startsWith("name=")) 40 | { 41 | name = params[i].substring(5); 42 | break; 43 | } 44 | } 45 | 46 | if(name == null) 47 | { 48 | name = "MicroBTL2CAP"; 49 | } 50 | 51 | return new L2CAPConnectionNotifier(BluetoothAdapter.getDefaultAdapter().listenUsingRfcommWithServiceRecord(name, BTUtils.parseUUID(params[0]))); 52 | } 53 | else 54 | { 55 | String[] params = name.split(";")[0].split(":"); 56 | 57 | BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(BTUtils.validateBluetoothAddress(params[0])); 58 | BluetoothSocket socket = device.createRfcommSocketToServiceRecord(BTUtils.parseUUID(params[1])); 59 | 60 | return new L2CAPConnection(socket); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/list_row_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 21 | 22 | 23 | 33 | 34 | 35 | 42 | 50 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Event.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | /** 20 | * Базовый класс для всех событий. 21 | */ 22 | public abstract class Event implements Runnable 23 | { 24 | // private static int count = 0; 25 | // private int id = count++; 26 | // 27 | // public int getID() 28 | // { 29 | // return id; 30 | // } 31 | 32 | /** 33 | * Обработка события. 34 | * Именно здесь нужно выполнять требуемые действия. 35 | */ 36 | public abstract void process(); 37 | 38 | /** 39 | * Сдача события в утиль. 40 | * 41 | * Если предусмотрен пул событий, то здесь 42 | * событие нужно обнулить и вернуть в пул. 43 | */ 44 | public abstract void recycle(); 45 | 46 | /** 47 | * Обработать событие и сдать в утиль за один прием. 48 | */ 49 | public void run() 50 | { 51 | process(); 52 | recycle(); 53 | } 54 | 55 | /** 56 | * Вызывается, когда событие вошло в очередь. 57 | * Здесь можно увеличить счетчик таких событий в очереди. 58 | */ 59 | public abstract void enterQueue(); 60 | 61 | /** 62 | * Вызывается, когда событие покинуло очередь. 63 | * Здесь можно уменьшить счетчик таких событий в очереди. 64 | */ 65 | public abstract void leaveQueue(); 66 | 67 | /** 68 | * Проверить, можно ли поместить это событие в очередь 69 | * сразу за некоторым другим событием. 70 | * 71 | * @param event событие, после которого нас могут поместить в очередь 72 | * @return true, если мы на это согласны 73 | */ 74 | public abstract boolean placeableAfter(Event event); 75 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/HttpConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.DataInputStream; 20 | import java.io.DataOutputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.io.OutputStream; 24 | import java.net.HttpURLConnection; 25 | import java.net.ProtocolException; 26 | 27 | public class HttpConnection implements StreamConnection 28 | { 29 | protected HttpURLConnection conn; 30 | 31 | protected HttpConnection(HttpURLConnection conn) 32 | { 33 | this.conn = conn; 34 | } 35 | 36 | public void close() 37 | { 38 | conn.disconnect(); 39 | } 40 | 41 | public InputStream openInputStream() throws IOException 42 | { 43 | return conn.getInputStream(); 44 | } 45 | 46 | public DataInputStream openDataInputStream() throws IOException 47 | { 48 | return new DataInputStream(openInputStream()); 49 | } 50 | 51 | public OutputStream openOutputStream() throws IOException 52 | { 53 | return conn.getOutputStream(); 54 | } 55 | 56 | public DataOutputStream openDataOutputStream() throws IOException 57 | { 58 | return new DataOutputStream(openOutputStream()); 59 | } 60 | 61 | public void setRequestMethod(String method) throws ProtocolException 62 | { 63 | conn.setRequestMethod(method); 64 | } 65 | 66 | public void setRequestProperty(String field, String newValue) 67 | { 68 | conn.setRequestProperty(field, newValue); 69 | } 70 | 71 | public int getResponseCode() throws IOException 72 | { 73 | return conn.getResponseCode(); 74 | } 75 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/bluetooth/L2CAPConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.bluetooth; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | 23 | import javax.microedition.io.StreamConnection; 24 | 25 | import android.bluetooth.BluetoothSocket; 26 | 27 | public class L2CAPConnection implements StreamConnection 28 | { 29 | public static final int DEFAULT_MTU = 672; 30 | public static final int MINIMUM_MTU = 48; 31 | 32 | protected BluetoothSocket socket; 33 | 34 | protected InputStream in; 35 | protected OutputStream out; 36 | 37 | // protected int receiveMTU; 38 | // protected int transmitMTU; 39 | 40 | public L2CAPConnection(BluetoothSocket socket) throws IOException 41 | { 42 | this.socket = socket; 43 | 44 | in = socket.getInputStream(); 45 | out = socket.getOutputStream(); 46 | } 47 | 48 | public void close() throws IOException 49 | { 50 | in.close(); 51 | out.close(); 52 | 53 | socket.close(); 54 | } 55 | 56 | public int getReceiveMTU() 57 | { 58 | return DEFAULT_MTU; // receiveMTU; 59 | } 60 | 61 | public int getTransmitMTU() 62 | { 63 | return DEFAULT_MTU; // transmitMTU; 64 | } 65 | 66 | public boolean ready() throws IOException 67 | { 68 | return in.available() > 0; 69 | } 70 | 71 | public int receive(byte[] inBuf) throws IOException 72 | { 73 | return in.read(inBuf, 0, Math.min(inBuf.length, in.available())); 74 | } 75 | 76 | public void send(byte[] data) throws IOException 77 | { 78 | out.write(data); 79 | } 80 | 81 | public InputStream openInputStream() throws IOException 82 | { 83 | return in; 84 | } 85 | 86 | public OutputStream openOutputStream() throws IOException 87 | { 88 | return out; 89 | } 90 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/game/Layer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MicroEmulator 3 | * Copyright (C) 2005 Andres Navarro 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | package javax.microedition.lcdui.game; 21 | 22 | import javax.microedition.lcdui.Graphics; 23 | 24 | /** 25 | * 26 | * @author Andres Navarro 27 | */ 28 | 29 | // i suppose this Class needs no comments 30 | public abstract class Layer { 31 | private int width; 32 | private int height; 33 | private int x; 34 | private int y; 35 | private boolean visible; 36 | 37 | Layer(int x, int y, int width, int height, boolean visible) { 38 | setSize(width, height); 39 | setPosition(x, y); 40 | setVisible(visible); 41 | } 42 | 43 | // package access to modify from Sprite 44 | void setSize(int width, int height) { 45 | if (width < 1 || height < 1) 46 | throw new IllegalArgumentException(); 47 | 48 | this.width = width; 49 | this.height = height; 50 | } 51 | 52 | public final int getWidth() { 53 | return width; 54 | } 55 | 56 | public final int getHeight() { 57 | return height; 58 | } 59 | 60 | public final int getX() { 61 | return x; 62 | } 63 | 64 | public final int getY() { 65 | return y; 66 | } 67 | 68 | public final boolean isVisible() { 69 | return visible; 70 | } 71 | 72 | public void move(int dx, int dy) { 73 | synchronized (this) { 74 | x += dx; 75 | y += dy; 76 | } 77 | } 78 | 79 | public abstract void paint(Graphics g); 80 | 81 | public void setPosition(int x, int y) { 82 | synchronized (this) { 83 | this.x = x; 84 | this.y = y; 85 | } 86 | } 87 | 88 | public void setVisible(boolean visible) { 89 | this.visible = visible; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/list/CompoundListAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.list; 18 | 19 | import javax.microedition.lcdui.Choice; 20 | 21 | import android.R.layout; 22 | import android.content.Context; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.widget.CompoundButton; 26 | import android.widget.ListAdapter; 27 | 28 | public class CompoundListAdapter extends CompoundAdapter implements ListAdapter 29 | { 30 | protected int listType; 31 | protected int viewResourceID; 32 | protected ItemSelector selector; 33 | 34 | public CompoundListAdapter(Context context, ItemSelector selector, int type) 35 | { 36 | super(context); 37 | 38 | this.listType = type; 39 | this.selector = selector; 40 | 41 | switch(type) 42 | { 43 | case Choice.IMPLICIT: 44 | viewResourceID = layout.simple_list_item_1; 45 | break; 46 | 47 | case Choice.EXCLUSIVE: 48 | viewResourceID = layout.simple_list_item_single_choice; 49 | break; 50 | 51 | case Choice.MULTIPLE: 52 | viewResourceID = layout.simple_list_item_multiple_choice; 53 | break; 54 | 55 | default: 56 | throw new IllegalArgumentException("list type " + type + " is not supported"); 57 | } 58 | 59 | if(type != Choice.IMPLICIT && selector == null) 60 | { 61 | throw new IllegalArgumentException("ItemSelector is requered for this list type"); 62 | } 63 | } 64 | 65 | public View getView(int position, View convertView, ViewGroup parent) 66 | { 67 | convertView = getView(position, convertView, parent, viewResourceID, true); 68 | 69 | if(listType != Choice.IMPLICIT && convertView instanceof CompoundButton) 70 | { 71 | ((CompoundButton)convertView).setChecked(selector.isSelected(position)); 72 | } 73 | 74 | return convertView; 75 | } 76 | 77 | public boolean areAllItemsEnabled() 78 | { 79 | return true; 80 | } 81 | 82 | public boolean isEnabled(int position) 83 | { 84 | return true; 85 | } 86 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/MainActivity.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.TreeMap; 7 | 8 | import javax.microedition.shell.ConfScreen; 9 | import javax.microedition.util.ContextHolder; 10 | 11 | import ua.naiksoftware.util.FileUtils; 12 | import android.support.v7.app.ActionBarActivity; 13 | import android.support.v7.app.ActionBar; 14 | import android.support.v4.app.FragmentManager; 15 | import android.os.Bundle; 16 | import android.view.Menu; 17 | import android.view.MenuItem; 18 | import android.support.v4.widget.DrawerLayout; 19 | import android.os.Environment; 20 | import ua.naiksoftware.j2meloader.converter.*; 21 | import android.support.v7.app.*; 22 | 23 | public class MainActivity extends AppCompatActivity { 24 | 25 | private String startPath; 26 | private static final String EXTS = ".jar.zip.java"; 27 | private AppsListFragment appsListFragment; 28 | private final List apps = new ArrayList(); 29 | 30 | /** Путь к папке со сконвертированными приложениями */ 31 | private String pathConverted; 32 | 33 | private JarConverter converter; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_main); 39 | 40 | startPath = Environment.getExternalStorageDirectory().getAbsolutePath(); 41 | 42 | pathConverted = getApplicationInfo().dataDir + "/converted/"; 43 | appsListFragment = new AppsListFragment(apps); 44 | // update the main content by replacing fragments 45 | FragmentManager fragmentManager = getSupportFragmentManager(); 46 | fragmentManager.beginTransaction() 47 | .replace(R.id.container, appsListFragment).commit(); 48 | updateApps(); 49 | } 50 | 51 | @Override 52 | public boolean onCreateOptionsMenu(Menu menu) { 53 | getMenuInflater().inflate(R.menu.main, menu); 54 | return super.onCreateOptionsMenu(menu); 55 | } 56 | 57 | @Override 58 | public boolean onOptionsItemSelected(MenuItem item) { 59 | int id = item.getItemId(); 60 | if (id == R.id.action_settings) { 61 | return true; 62 | } 63 | return super.onOptionsItemSelected(item); 64 | } 65 | 66 | public void updateApps() { 67 | apps.clear(); 68 | AppItem item; 69 | String author = getString(R.string.author); 70 | String version = getString(R.string.version); 71 | String[] appFolders = new File(pathConverted).list(); 72 | if (!(appFolders == null)) { 73 | for (String appFolder : appFolders) { 74 | TreeMap params = FileUtils 75 | .loadManifest(new File(pathConverted + appFolder 76 | + ConfScreen.MIDLET_CONF_FILE)); 77 | item = new AppItem(R.drawable.app_default_icon, 78 | params.get("MIDlet-Name"), author 79 | + params.get("MIDlet-Vendor"), version 80 | + params.get("MIDlet-Version")); 81 | item.setPath(pathConverted + appFolder); 82 | apps.add(item); 83 | } 84 | } 85 | AppsListAdapter adapter = new AppsListAdapter(this, apps); 86 | appsListFragment.setListAdapter(adapter); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/j2meloader/converter/JarConverter.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.j2meloader.converter; 2 | 3 | import java.io.*; 4 | 5 | import android.app.ProgressDialog; 6 | import android.content.Context; 7 | import android.os.AsyncTask; 8 | import android.widget.Toast; 9 | import com.android.dx.command.Main; 10 | import filelog.Log; 11 | import javax.microedition.shell.ConfScreen; 12 | import ua.naiksoftware.util.FileUtils; 13 | import rx.*; 14 | 15 | public class JarConverter { 16 | 17 | private static final String TAG = "JarConverter"; 18 | 19 | private final File dirTmp, dirForJAssist; 20 | 21 | private static final String classRepl = "java.lang.Class"; 22 | private static final String methodRepl = "getResourceAsStream"; 23 | 24 | public JarConverter(Context context) { 25 | dirTmp = new File(context.getApplicationInfo().dataDir + "/tmp"); 26 | dirForJAssist = new File(dirTmp, "/_converted_classes"); 27 | } 28 | 29 | public Observable convert(final String pathToJar, final String pathConverted) { 30 | Log.d(TAG, "doInBackground$ pathToJar=" + pathToJar + " pathConverted=" + pathConverted); 31 | return Observable.create(new Observable.OnSubscribe() { 32 | 33 | @Override 34 | public void call(Subscriber subscriber) { 35 | FileUtils.deleteDirectory(dirTmp); 36 | dirTmp.mkdir(); 37 | try { 38 | if (!FileUtils.unzip(new FileInputStream(new File(pathToJar)), dirTmp)) { 39 | subscriber.onError(new ConvertException("Brocken jar")); 40 | return; 41 | } 42 | } catch (FileNotFoundException e) { 43 | subscriber.onError(e); 44 | return; 45 | } 46 | 47 | String appDir = FileUtils.loadManifest( 48 | new File(dirTmp, "/META-INF/MANIFEST.MF")).get("MIDlet-Name"); 49 | File appConverted = new File(pathConverted + appDir); 50 | FileUtils.deleteDirectory(appConverted); 51 | appConverted.mkdirs(); 52 | // dirForJAssist.mkdir(); 53 | // workModifyClass(dirTmp.getPath()); // MODIFY 54 | // Log.d(tag, "-------\n\nreplace OK"); 55 | // Convert to dex 56 | Log.d(TAG, "appConverted=" + appConverted.getPath()); 57 | Main.main(new String[] { 58 | "--dex", 59 | "--output=" + appConverted.getPath() 60 | + ConfScreen.MIDLET_DEX_FILE, 61 | /* dirForJAssist.getPath() */pathToJar }); 62 | File conf = new File(dirTmp, "/META-INF/MANIFEST.MF"); 63 | if (!conf.exists()) { 64 | subscriber.onError(new ConvertException("Manifest not exists: " + conf.getPath())); 65 | return; 66 | } 67 | conf.renameTo(new File(appConverted, ConfScreen.MIDLET_CONF_FILE)); 68 | // Extract other resources from jar. 69 | FileUtils.moveFiles(dirTmp.getPath(), pathConverted + appDir 70 | + ConfScreen.MIDLET_RES_DIR, new FilenameFilter() { 71 | public boolean accept(File dir, String fname) { 72 | if (fname.equalsIgnoreCase("MANIFEST.MF") 73 | || fname.endsWith(".class")) { 74 | return false; 75 | } else { 76 | return true; 77 | } 78 | } 79 | }); 80 | FileUtils.deleteDirectory(dirTmp); 81 | subscriber.onCompleted(); 82 | } 83 | }); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Gauge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import android.view.View; 20 | import android.widget.ProgressBar; 21 | import android.widget.SeekBar; 22 | 23 | public class Gauge extends Item 24 | { 25 | public static final int CONTINUOUS_IDLE = 0; 26 | public static final int INCREMENTAL_IDLE = 1; 27 | public static final int CONTINUOUS_RUNNING = 2; 28 | public static final int INCREMENTAL_UPDATING = 3; 29 | 30 | public static final int INDEFINITE = -1; 31 | 32 | private ProgressBar pbar; 33 | 34 | private boolean interactive; 35 | private int value, maxValue; 36 | 37 | private class SeekBarListener implements SeekBar.OnSeekBarChangeListener 38 | { 39 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) 40 | { 41 | if(fromUser) 42 | { 43 | value = progress; 44 | notifyStateChanged(); 45 | } 46 | } 47 | 48 | public void onStartTrackingTouch(SeekBar seekBar) 49 | { 50 | } 51 | 52 | public void onStopTrackingTouch(SeekBar seekBar) 53 | { 54 | } 55 | } 56 | 57 | private SeekBarListener listener = new SeekBarListener(); 58 | 59 | public Gauge(String label, boolean interactive, int maxValue, int initialValue) 60 | { 61 | setLabel(label); 62 | 63 | this.interactive = interactive; 64 | this.maxValue = maxValue; 65 | this.value = initialValue; 66 | } 67 | 68 | public int getValue() 69 | { 70 | return value; 71 | } 72 | 73 | public void setValue(int value) 74 | { 75 | this.value = value; 76 | 77 | if(pbar != null) 78 | { 79 | pbar.setProgress(value); 80 | } 81 | } 82 | 83 | public int getMaxValue() 84 | { 85 | return maxValue; 86 | } 87 | 88 | public void setMaxValue(int maxValue) 89 | { 90 | this.maxValue = maxValue; 91 | 92 | if(pbar != null) 93 | { 94 | pbar.setMax(maxValue); 95 | } 96 | } 97 | 98 | protected View getItemContentView() 99 | { 100 | if(pbar == null) 101 | { 102 | if(interactive) 103 | { 104 | pbar = new SeekBar(getOwnerForm().getParentActivity()); 105 | ((SeekBar)pbar).setOnSeekBarChangeListener(listener); 106 | } 107 | else 108 | { 109 | pbar = new ProgressBar(getOwnerForm().getParentActivity(), null, android.R.attr.progressBarStyleHorizontal); 110 | } 111 | 112 | pbar.setMax(maxValue); 113 | pbar.setProgress(value); 114 | } 115 | 116 | return pbar; 117 | } 118 | 119 | protected void clearItemContentView() 120 | { 121 | pbar = null; 122 | } 123 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/pointer/KeyRepeater.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.pointer; 18 | 19 | import javax.microedition.lcdui.Canvas; 20 | import javax.microedition.lcdui.event.CanvasEvent; 21 | 22 | public class KeyRepeater implements Runnable 23 | { 24 | public static long[] INTERVALS = 25 | { 26 | 400, 27 | 200, 28 | 400, 29 | 128, 30 | 128, 31 | 128, 32 | 128, 33 | 128, 34 | 80 35 | }; 36 | 37 | protected Canvas target; 38 | 39 | protected Thread thread; 40 | protected Object waiter; 41 | protected boolean isrunning; 42 | 43 | protected boolean enabled; 44 | protected int position; 45 | 46 | protected int keyCode; 47 | protected int secondKeyCode; 48 | 49 | public KeyRepeater() 50 | { 51 | waiter = new Object(); 52 | 53 | thread = new Thread(this); 54 | thread.start(); 55 | } 56 | 57 | public void setTarget(Canvas canvas) 58 | { 59 | if(canvas == null) 60 | { 61 | stop(); 62 | } 63 | 64 | target = canvas; 65 | } 66 | 67 | public void start(int keyCode) 68 | { 69 | start(keyCode, 0); 70 | } 71 | 72 | public void start(int keyCode, int secondKeyCode) 73 | { 74 | if(target == null) 75 | { 76 | return; 77 | } 78 | 79 | synchronized(waiter) 80 | { 81 | if(isrunning) 82 | { 83 | return; 84 | } 85 | 86 | this.keyCode = keyCode; 87 | this.secondKeyCode = secondKeyCode; 88 | 89 | enabled = true; 90 | position = 0; 91 | 92 | waiter.notifyAll(); 93 | } 94 | } 95 | 96 | public void stop() 97 | { 98 | enabled = false; 99 | thread.interrupt(); 100 | } 101 | 102 | public boolean isRunning() 103 | { 104 | return isrunning; 105 | } 106 | 107 | public void run() 108 | { 109 | while(true) 110 | { 111 | try 112 | { 113 | synchronized(waiter) 114 | { 115 | isrunning = false; 116 | waiter.wait(); 117 | 118 | isrunning = true; 119 | } 120 | 121 | while(enabled) 122 | { 123 | Thread.sleep(INTERVALS[position]); 124 | 125 | target.postEvent(CanvasEvent.getInstance(target, CanvasEvent.KEY_REPEATED, keyCode)); 126 | 127 | if(secondKeyCode != 0) 128 | { 129 | target.postEvent(CanvasEvent.getInstance(target, CanvasEvent.KEY_REPEATED, secondKeyCode)); 130 | } 131 | 132 | if(position < INTERVALS.length - 1) 133 | { 134 | position++; 135 | } 136 | } 137 | } 138 | catch(InterruptedException ie) 139 | { 140 | } 141 | } 142 | } 143 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/file/FileSystemRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io.file; 18 | 19 | import java.io.File; 20 | import java.util.Enumeration; 21 | import java.util.Vector; 22 | 23 | import javax.microedition.io.Connection; 24 | import javax.microedition.io.ConnectionProvider; 25 | import javax.microedition.io.Connector; 26 | 27 | import android.os.Environment; 28 | 29 | public class FileSystemRegistry implements ConnectionProvider 30 | { 31 | public static final String INTERNAL_DISK = "c:/"; 32 | public static final String EXTERNAL_DISK = "e:/"; 33 | 34 | private static Vector roots = new Vector(); 35 | 36 | public static Enumeration listRoots() 37 | { 38 | synchronized(roots) 39 | { 40 | roots.removeAllElements(); 41 | roots.addElement(INTERNAL_DISK); 42 | 43 | String state = Environment.getExternalStorageState(); 44 | 45 | if(Environment.MEDIA_MOUNTED.equals(state) || 46 | Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) 47 | { 48 | roots.addElement(EXTERNAL_DISK); 49 | } 50 | 51 | return roots.elements(); 52 | } 53 | } 54 | 55 | public static String getExternalStoragePath() 56 | { 57 | String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath(); 58 | 59 | if(sdcard.startsWith("/")) 60 | { 61 | sdcard = sdcard.substring(1); 62 | } 63 | 64 | if(!sdcard.endsWith("/")) 65 | { 66 | sdcard += "/"; 67 | } 68 | 69 | return sdcard; 70 | } 71 | 72 | public static String midpFileToAndroid(String name) 73 | { 74 | if(name.startsWith("/")) 75 | { 76 | name = name.substring(1); 77 | } 78 | 79 | if(name.startsWith(INTERNAL_DISK)) 80 | { 81 | name = name.substring(INTERNAL_DISK.length()); 82 | } 83 | else if(name.startsWith(EXTERNAL_DISK)) 84 | { 85 | name = getExternalStoragePath() + name.substring(EXTERNAL_DISK.length()); 86 | } 87 | 88 | return "/" + name; 89 | } 90 | 91 | public static String androidFileToMIDP(String name) 92 | { 93 | if(name.startsWith("/")) 94 | { 95 | name = name.substring(1); 96 | } 97 | 98 | String sdcard = getExternalStoragePath(); 99 | 100 | if(name.startsWith(sdcard)) 101 | { 102 | name = EXTERNAL_DISK + name.substring(sdcard.length()); 103 | } 104 | else 105 | { 106 | name = INTERNAL_DISK + name; 107 | } 108 | 109 | return "/" + name; 110 | } 111 | 112 | public Connection open(String name, int mode) 113 | { 114 | return new FileConnection(new File(midpFileToAndroid(name)), (mode & Connector.WRITE) != 0 ? FileConnection.READ_WRITE : FileConnection.READ); 115 | } 116 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Command.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | public class Command implements Comparable 20 | { 21 | public static final int SCREEN = 1; 22 | public static final int BACK = 2; 23 | public static final int CANCEL = 3; 24 | public static final int OK = 4; 25 | public static final int HELP = 5; 26 | public static final int STOP = 6; 27 | public static final int EXIT = 7; 28 | public static final int ITEM = 8; 29 | 30 | private String shortLabel; 31 | private String longLabel; 32 | private int commandType; 33 | private int priority; 34 | 35 | public Command(String label, int commandType, int priority) 36 | { 37 | this(label, null, commandType, priority); 38 | } 39 | 40 | public Command(String shortLabel, String longLabel, int commandType, int priority) 41 | { 42 | this.shortLabel = shortLabel; 43 | this.longLabel = longLabel; 44 | this.commandType = commandType; 45 | this.priority = priority; 46 | } 47 | 48 | public String getLabel() 49 | { 50 | return shortLabel; 51 | } 52 | 53 | public String getLongLabel() 54 | { 55 | return longLabel; 56 | } 57 | 58 | public int getCommandType() 59 | { 60 | return commandType; 61 | } 62 | 63 | public int getPriority() 64 | { 65 | return priority; 66 | } 67 | 68 | public int hashCode() 69 | { 70 | int hash = 3; 71 | 72 | hash = 97 * hash + (shortLabel != null ? shortLabel.hashCode() : 0); 73 | hash = 97 * hash + (longLabel != null ? longLabel.hashCode() : 0); 74 | hash = 97 * hash + commandType; 75 | hash = 97 * hash + priority; 76 | 77 | return hash; 78 | } 79 | 80 | public boolean equals(Object obj) 81 | { 82 | if(obj == null) 83 | { 84 | return false; 85 | } 86 | 87 | if(getClass() != obj.getClass()) 88 | { 89 | return false; 90 | } 91 | 92 | final Command other = (Command) obj; 93 | 94 | if((shortLabel == null) ? (other.shortLabel != null) : !shortLabel.equals(other.shortLabel)) 95 | { 96 | return false; 97 | } 98 | 99 | if((longLabel == null) ? (other.longLabel != null) : !longLabel.equals(other.longLabel)) 100 | { 101 | return false; 102 | } 103 | 104 | if(commandType != other.commandType) 105 | { 106 | return false; 107 | } 108 | 109 | if(priority != other.priority) 110 | { 111 | return false; 112 | } 113 | 114 | return true; 115 | } 116 | 117 | public int compareTo(Command cmd) 118 | { 119 | return cmd.getPriority() - priority; 120 | } 121 | 122 | public String toString() 123 | { 124 | return "Command(\"" + shortLabel + "\", " + commandType + ", " + priority + ")"; 125 | } 126 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Screen.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import javax.microedition.lcdui.event.SimpleEvent; 20 | 21 | import android.content.Context; 22 | import android.text.TextUtils.TruncateAt; 23 | import android.view.View; 24 | import android.widget.LinearLayout; 25 | import android.widget.TextView; 26 | 27 | public abstract class Screen extends Displayable 28 | { 29 | private static final int TICKER_NO_ACTION = 0; 30 | private static final int TICKER_SHOW = 1; 31 | private static final int TICKER_HIDE = 2; 32 | 33 | private Ticker ticker; 34 | 35 | private LinearLayout layout; 36 | private TextView marquee; 37 | private int tickermode; 38 | 39 | private SimpleEvent msgSetTicker = new SimpleEvent() 40 | { 41 | public void process() 42 | { 43 | if(ticker != null) 44 | { 45 | marquee.setText(ticker.getString()); 46 | } 47 | 48 | switch(tickermode) 49 | { 50 | case TICKER_SHOW: 51 | layout.addView(marquee, 0); 52 | break; 53 | 54 | case TICKER_HIDE: 55 | layout.removeView(marquee); 56 | break; 57 | } 58 | 59 | tickermode = TICKER_NO_ACTION; 60 | } 61 | }; 62 | 63 | public void setTicker(Ticker newticker) 64 | { 65 | if(layout != null) 66 | { 67 | if(ticker == null && newticker != null) 68 | { 69 | tickermode = TICKER_SHOW; 70 | } 71 | else if(ticker != null && newticker == null) 72 | { 73 | tickermode = TICKER_HIDE; 74 | } 75 | 76 | ticker = newticker; 77 | 78 | ViewHandler.postEvent(msgSetTicker); 79 | } 80 | else 81 | { 82 | ticker = newticker; 83 | } 84 | } 85 | 86 | public Ticker getTicker() 87 | { 88 | return ticker; 89 | } 90 | 91 | public View getDisplayableView() 92 | { 93 | if(layout == null) 94 | { 95 | Context context = getParentActivity(); 96 | 97 | 98 | layout = new LinearLayout(context); 99 | layout.setOrientation(LinearLayout.VERTICAL); 100 | 101 | marquee = new TextView(context); 102 | marquee.setTextAppearance(context, android.R.style.TextAppearance_Medium); 103 | marquee.setEllipsize(TruncateAt.MARQUEE); 104 | marquee.setSelected(true); 105 | 106 | if(ticker != null) 107 | { 108 | marquee.setText(ticker.getString()); 109 | layout.addView(marquee); 110 | } 111 | 112 | layout.addView(getScreenView()); 113 | } 114 | 115 | return layout; 116 | } 117 | 118 | public void clearDisplayableView() 119 | { 120 | layout = null; 121 | marquee = null; 122 | 123 | clearScreenView(); 124 | } 125 | 126 | public abstract View getScreenView(); 127 | public abstract void clearScreenView(); 128 | } 129 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/event/CommandActionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.event; 18 | 19 | import javax.microedition.lcdui.Command; 20 | import javax.microedition.lcdui.CommandListener; 21 | import javax.microedition.lcdui.Displayable; 22 | import javax.microedition.lcdui.Event; 23 | import javax.microedition.lcdui.Item; 24 | import javax.microedition.lcdui.ItemCommandListener; 25 | import javax.microedition.util.ArrayStack; 26 | 27 | public class CommandActionEvent extends Event 28 | { 29 | private static ArrayStack recycled = new ArrayStack(); 30 | 31 | private CommandListener listener; 32 | private ItemCommandListener itemlistener; 33 | 34 | private Command command; 35 | private Displayable displayable; 36 | private Item item; 37 | 38 | private CommandActionEvent() 39 | { 40 | } 41 | 42 | public static Event getInstance(CommandListener listener, Command command, Displayable displayable) 43 | { 44 | CommandActionEvent instance = recycled.pop(); 45 | 46 | if(instance == null) 47 | { 48 | instance = new CommandActionEvent(); 49 | } 50 | 51 | instance.listener = listener; 52 | instance.command = command; 53 | instance.displayable = displayable; 54 | 55 | return instance; 56 | } 57 | 58 | public static Event getInstance(ItemCommandListener itemlistener, Command command, Item item) 59 | { 60 | CommandActionEvent instance = recycled.pop(); 61 | 62 | if(instance == null) 63 | { 64 | instance = new CommandActionEvent(); 65 | } 66 | 67 | instance.itemlistener = itemlistener; 68 | instance.command = command; 69 | instance.item = item; 70 | 71 | return instance; 72 | } 73 | 74 | public void process() 75 | { 76 | if(listener != null) 77 | { 78 | listener.commandAction(command, displayable); 79 | } 80 | else if(itemlistener != null) 81 | { 82 | itemlistener.commandAction(command, item); 83 | } 84 | } 85 | 86 | public void recycle() 87 | { 88 | listener = null; 89 | itemlistener = null; 90 | 91 | command = null; 92 | displayable = null; 93 | item = null; 94 | 95 | recycled.push(this); 96 | } 97 | 98 | public void enterQueue() 99 | { 100 | } 101 | 102 | public void leaveQueue() 103 | { 104 | } 105 | 106 | public boolean placeableAfter(Event event) 107 | { 108 | return true; 109 | } 110 | 111 | // public String toString() 112 | // { 113 | // if(listener != null) 114 | // { 115 | // return "сommandAction(" + command + ", " + displayable + ")"; 116 | // } 117 | // else if(itemlistener != null) 118 | // { 119 | // return "сommandAction(" + command + ", " + item + ")"; 120 | // } 121 | // else 122 | // { 123 | // return "сommandAction(" + command + ")"; 124 | // } 125 | // } 126 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/util/ContextHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy, Naik 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.util; 18 | 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.io.InputStream; 22 | import java.util.ArrayList; 23 | 24 | import ua.naiksoftware.j2meloader.MainActivity; 25 | import android.content.Context; 26 | import android.content.Intent; 27 | import android.os.Environment; 28 | import android.view.LayoutInflater; 29 | import filelog.Log; 30 | 31 | public class ContextHolder { 32 | 33 | private static final String tag = "ContextHolder"; 34 | 35 | private static MainActivity context; 36 | private static ArrayList resultListeners = new ArrayList(); 37 | private static LayoutInflater inflater; 38 | 39 | public static void setContext(MainActivity cx) { 40 | context = cx; 41 | inflater = LayoutInflater.from(cx); 42 | } 43 | 44 | public static Context getContext() { 45 | if (context == null) { 46 | throw new IllegalStateException( 47 | "call setContext() before calling getContext()"); 48 | } 49 | return context; 50 | } 51 | 52 | public static LayoutInflater getInflater() { 53 | return inflater; 54 | } 55 | 56 | public static InputStream getResourceAsStream(String filename) { 57 | if (filename.startsWith("/")) { 58 | filename = filename.substring(1); 59 | } 60 | 61 | try { 62 | return getContext().getAssets().open(filename); 63 | } catch (IOException e) { 64 | Log.d(tag, "getResourceAsStream err: " + e.getMessage()); 65 | return null; 66 | } 67 | } 68 | 69 | public static File getCacheDir() { 70 | if (Environment.MEDIA_MOUNTED.equals(Environment 71 | .getExternalStorageState())) { 72 | return getContext().getExternalCacheDir(); 73 | } else { 74 | return getContext().getCacheDir(); 75 | } 76 | } 77 | 78 | public static int getRequestCode(String requestString) { 79 | return requestString.hashCode() & 0x7FFFFFFF; 80 | } 81 | 82 | public static MainActivity getActivity() { 83 | if (context == null) { 84 | throw new IllegalStateException( 85 | "call setContext() before calling getActivity()"); 86 | } 87 | return context; 88 | } 89 | 90 | public static void addActivityResultListener(ActivityResultListener listener) { 91 | if (!resultListeners.contains(listener)) { 92 | resultListeners.add(listener); 93 | } 94 | } 95 | 96 | public static void removeActivityResultListener( 97 | ActivityResultListener listener) { 98 | resultListeners.remove(listener); 99 | } 100 | 101 | public static void notifyOnActivityResult(int requestCode, int resultCode, 102 | Intent data) { 103 | for (ActivityResultListener listener : resultListeners) { 104 | listener.onActivityResult(requestCode, resultCode, data); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/io/Connector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.io; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | import java.util.HashMap; 23 | 24 | import javax.bluetooth.BTL2CAPConnectionProvider; 25 | import javax.microedition.io.file.FileSystemRegistry; 26 | 27 | public class Connector 28 | { 29 | public static final int READ = 1; 30 | public static final int READ_WRITE = 3; 31 | public static final int WRITE = 2; 32 | 33 | private static HashMap providers; 34 | 35 | static 36 | { 37 | registerConnectionProvider("file", new FileSystemRegistry()); 38 | registerConnectionProvider("http", new HttpConnectionProvider()); 39 | registerConnectionProvider("btl2cap", new BTL2CAPConnectionProvider()); 40 | } 41 | 42 | public static void registerConnectionProvider(String protocol, ConnectionProvider provider) 43 | { 44 | if(providers == null) 45 | { 46 | providers = new HashMap(); 47 | } 48 | 49 | providers.put(protocol.toLowerCase(), provider); 50 | } 51 | 52 | public static Connection open(String name) throws IOException 53 | { 54 | return open(name, READ_WRITE); 55 | } 56 | 57 | public static Connection open(String name, int mode) throws IOException 58 | { 59 | if(providers == null || providers.isEmpty()) 60 | { 61 | throw new ConnectionNotFoundException("no registered connection providers"); 62 | } 63 | 64 | int index = name.indexOf("://"); 65 | 66 | if(index >= 0) 67 | { 68 | String protocol = name.substring(0, index).toLowerCase(); 69 | ConnectionProvider provider = providers.get(protocol); 70 | 71 | if(provider != null) 72 | { 73 | return provider.open(name.substring(index + 3), mode); 74 | } 75 | else 76 | { 77 | throw new ConnectionNotFoundException("'" + protocol + "' connections are not supported"); 78 | } 79 | } 80 | else 81 | { 82 | throw new IllegalArgumentException("malformed URL: " + name); 83 | } 84 | } 85 | 86 | public static InputStream openInputStream(String name) throws IOException 87 | { 88 | Connection conn = open(name, READ); 89 | 90 | if(conn instanceof StreamConnection) 91 | { 92 | return new ImmediateInputStream((StreamConnection)conn); 93 | } 94 | else 95 | { 96 | throw new IOException("cannot open stream on a non-stream connection"); 97 | } 98 | } 99 | 100 | public static OutputStream openOutputStream(String name) throws IOException 101 | { 102 | Connection conn = open(name, WRITE); 103 | 104 | if(conn instanceof StreamConnection) 105 | { 106 | return new ImmediateOutputStream((StreamConnection)conn); 107 | } 108 | else 109 | { 110 | throw new IOException("cannot open stream on a non-stream connection"); 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/media/DataSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.media; 18 | 19 | import java.io.File; 20 | import java.io.FileDescriptor; 21 | import java.io.FileInputStream; 22 | import java.io.IOException; 23 | 24 | import javax.microedition.util.ContextHolder; 25 | 26 | import android.content.res.AssetFileDescriptor; 27 | import android.media.MediaMetadataRetriever; 28 | import android.media.MediaPlayer; 29 | 30 | public class DataSource 31 | { 32 | protected String locator; 33 | protected File file; 34 | 35 | protected FileInputStream stream; 36 | protected AssetFileDescriptor asset; 37 | protected FileDescriptor descriptor; 38 | protected long offset; 39 | protected long length; 40 | 41 | public DataSource(String locator) 42 | { 43 | this.locator = locator; 44 | } 45 | 46 | public DataSource(File file) 47 | { 48 | this.file = file; 49 | } 50 | 51 | public void open() throws IOException 52 | { 53 | if(descriptor == null) 54 | { 55 | if(locator != null && !locator.contains("://")) 56 | { 57 | if(locator.startsWith("/")) 58 | { 59 | locator = locator.substring(1); 60 | } 61 | 62 | asset = ContextHolder.getContext().getAssets().openFd(locator); 63 | 64 | descriptor = asset.getFileDescriptor(); 65 | 66 | offset = asset.getStartOffset(); 67 | length = asset.getLength(); 68 | } 69 | else if(file != null) 70 | { 71 | stream = new FileInputStream(file); 72 | 73 | descriptor = stream.getFD(); 74 | 75 | offset = 0; 76 | length = file.length(); 77 | } 78 | } 79 | } 80 | 81 | public void close() 82 | { 83 | if(stream != null) 84 | { 85 | try 86 | { 87 | stream.close(); 88 | } 89 | catch(IOException e) 90 | { 91 | } 92 | 93 | stream = null; 94 | } 95 | 96 | if(asset != null) 97 | { 98 | try 99 | { 100 | asset.close(); 101 | } 102 | catch(IOException e) 103 | { 104 | } 105 | 106 | asset = null; 107 | } 108 | 109 | descriptor = null; 110 | } 111 | 112 | public String getURL() 113 | { 114 | if(locator != null) 115 | { 116 | return locator; 117 | } 118 | else 119 | { 120 | return "file://" + file.getAbsolutePath(); 121 | } 122 | } 123 | 124 | public void setFor(MediaPlayer player) throws IOException 125 | { 126 | open(); 127 | 128 | if(descriptor != null) 129 | { 130 | player.setDataSource(descriptor, offset, length); 131 | } 132 | else 133 | { 134 | player.setDataSource(locator); 135 | } 136 | } 137 | 138 | public void setFor(MediaMetadataRetriever retriever) throws IOException 139 | { 140 | open(); 141 | 142 | if(descriptor != null) 143 | { 144 | retriever.setDataSource(descriptor, 0, length); 145 | } 146 | else 147 | { 148 | retriever.setDataSource(locator); 149 | } 150 | } 151 | } -------------------------------------------------------------------------------- /app/src/main/res/values-ru/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Конвертация JAR... 4 | Завершено 5 | Автор: 6 | Версия: 7 | нет данных для отображения 8 | 9 | Настройки запуска 10 | Параметры экрана 11 | Масштабировать 12 | Сохранять пропорции 13 | Фильтрация 14 | Параметры шрифтов 15 | Ширина 16 | Высота 17 | Малый 18 | Средний 19 | Большой 20 | Значения в масш. пикселях 21 | Фон 22 | Виртуальная клавиатура 23 | Кнопки 24 | Надписи 25 | Обводка 26 | RGB 27 | Прозрачность: 28 | Скрывать через 29 | мс 30 | Настройка раскладки: 31 | Пуск 32 | Отмена 33 | Надписи (Н) 34 | Кнопки (Н) 35 | Размеры клавиш 36 | Джойстик: 37 | Софт-кл.: 38 | Цифры: 39 | Огонь: 40 | Разм. 41 | Сброс 42 | Предустановки 43 | Код кл. 44 | Язык: %A 45 | Прочие параметры 46 | Редакт. манифест 47 | Принудительное закрытие приложения может привести к потере данных или даже полной его неработоспособности!\nПродолжить? 48 | Требуется подтверждение 49 | Да 50 | Нет 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/param/BundleContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.param; 18 | 19 | import android.os.Bundle; 20 | 21 | public class BundleContainer implements DataContainer, DataEditor 22 | { 23 | protected Bundle bundle; 24 | protected Bundle editor; 25 | 26 | public BundleContainer() 27 | { 28 | bundle = new Bundle(); 29 | } 30 | 31 | public BundleContainer(Bundle bundle) 32 | { 33 | this.bundle = bundle; 34 | } 35 | 36 | public Bundle getBundle() 37 | { 38 | return bundle; 39 | } 40 | 41 | public DataEditor edit() 42 | { 43 | if(editor == null) 44 | { 45 | editor = new Bundle(bundle); 46 | } 47 | 48 | return this; 49 | } 50 | 51 | public boolean contains(String key) 52 | { 53 | return bundle.containsKey(key); 54 | } 55 | 56 | public boolean getBoolean(String key, boolean defValue) 57 | { 58 | return bundle.getBoolean(key, defValue); 59 | } 60 | 61 | public float getFloat(String key, float defValue) 62 | { 63 | return bundle.getFloat(key, defValue); 64 | } 65 | 66 | public int getInt(String key, int defValue) 67 | { 68 | return bundle.getInt(key, defValue); 69 | } 70 | 71 | public long getLong(String key, long defValue) 72 | { 73 | return bundle.getLong(key, defValue); 74 | } 75 | 76 | public String getString(String key, String defValue) 77 | { 78 | key = bundle.getString(key); 79 | return key != null ? key : defValue; 80 | } 81 | 82 | public boolean getBoolean(String key) 83 | { 84 | return bundle.getBoolean(key); 85 | } 86 | 87 | public float getFloat(String key) 88 | { 89 | return bundle.getFloat(key); 90 | } 91 | 92 | public int getInt(String key) 93 | { 94 | return bundle.getInt(key); 95 | } 96 | 97 | public long getLong(String key) 98 | { 99 | return bundle.getLong(key); 100 | } 101 | 102 | public String getString(String key) 103 | { 104 | return bundle.getString(key); 105 | } 106 | 107 | public DataEditor clear() 108 | { 109 | editor.clear(); 110 | return this; 111 | } 112 | 113 | public DataEditor remove(String key) 114 | { 115 | editor.remove(key); 116 | return this; 117 | } 118 | 119 | public DataEditor putBoolean(String key, boolean value) 120 | { 121 | editor.putBoolean(key, value); 122 | return this; 123 | } 124 | 125 | public DataEditor putFloat(String key, float value) 126 | { 127 | editor.putFloat(key, value); 128 | return this; 129 | } 130 | 131 | public DataEditor putInt(String key, int value) 132 | { 133 | editor.putInt(key, value); 134 | return this; 135 | } 136 | 137 | public DataEditor putLong(String key, long value) 138 | { 139 | editor.putLong(key, value); 140 | return this; 141 | } 142 | 143 | public DataEditor putString(String key, String value) 144 | { 145 | editor.putString(key, value); 146 | return this; 147 | } 148 | 149 | public void apply() 150 | { 151 | commit(); 152 | } 153 | 154 | public boolean commit() 155 | { 156 | bundle.clear(); 157 | bundle.putAll(editor); 158 | 159 | return true; 160 | } 161 | 162 | public void close() 163 | { 164 | editor = null; 165 | } 166 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/param/SharedPreferencesContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.param; 18 | 19 | import javax.microedition.util.ContextHolder; 20 | 21 | import android.content.SharedPreferences; 22 | import android.content.Context; 23 | 24 | public class SharedPreferencesContainer implements DataContainer, DataEditor 25 | { 26 | protected SharedPreferences prefs; 27 | protected SharedPreferences.Editor editor; 28 | 29 | public SharedPreferencesContainer(String name, int mode, Context context) 30 | { 31 | prefs = context.getSharedPreferences(name, mode); 32 | } 33 | 34 | public SharedPreferencesContainer(SharedPreferences prefs) 35 | { 36 | this.prefs = prefs; 37 | } 38 | 39 | public DataEditor edit() 40 | { 41 | if(editor == null) 42 | { 43 | editor = prefs.edit(); 44 | } 45 | 46 | return this; 47 | } 48 | 49 | public boolean contains(String key) 50 | { 51 | return prefs.contains(key); 52 | } 53 | 54 | public boolean getBoolean(String key, boolean defValue) 55 | { 56 | return prefs.getBoolean(key, defValue); 57 | } 58 | 59 | public float getFloat(String key, float defValue) 60 | { 61 | return prefs.getFloat(key, defValue); 62 | } 63 | 64 | public int getInt(String key, int defValue) 65 | { 66 | return prefs.getInt(key, defValue); 67 | } 68 | 69 | public long getLong(String key, long defValue) 70 | { 71 | return prefs.getLong(key, defValue); 72 | } 73 | 74 | public String getString(String key, String defValue) 75 | { 76 | return prefs.getString(key, defValue); 77 | } 78 | 79 | public boolean getBoolean(String key) 80 | { 81 | return prefs.getBoolean(key, false); 82 | } 83 | 84 | public float getFloat(String key) 85 | { 86 | return prefs.getFloat(key, 0); 87 | } 88 | 89 | public int getInt(String key) 90 | { 91 | return prefs.getInt(key, 0); 92 | } 93 | 94 | public long getLong(String key) 95 | { 96 | return prefs.getLong(key, 0); 97 | } 98 | 99 | public String getString(String key) 100 | { 101 | return prefs.getString(key, ""); 102 | } 103 | 104 | public DataEditor clear() 105 | { 106 | editor.clear(); 107 | return this; 108 | } 109 | 110 | public DataEditor remove(String key) 111 | { 112 | editor.remove(key); 113 | return this; 114 | } 115 | 116 | public DataEditor putBoolean(String key, boolean value) 117 | { 118 | editor.putBoolean(key, value); 119 | return this; 120 | } 121 | 122 | public DataEditor putFloat(String key, float value) 123 | { 124 | editor.putFloat(key, value); 125 | return this; 126 | } 127 | 128 | public DataEditor putInt(String key, int value) 129 | { 130 | editor.putInt(key, value); 131 | return this; 132 | } 133 | 134 | public DataEditor putLong(String key, long value) 135 | { 136 | editor.putLong(key, value); 137 | return this; 138 | } 139 | 140 | public DataEditor putString(String key, String value) 141 | { 142 | editor.putString(key, value); 143 | return this; 144 | } 145 | 146 | public void apply() 147 | { 148 | editor.apply(); 149 | } 150 | 151 | public boolean commit() 152 | { 153 | return editor.commit(); 154 | } 155 | 156 | public void close() 157 | { 158 | editor = null; 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | J2me Loader 5 | Section 1 6 | Section 2 7 | Section 3 8 | Open navigation drawer 9 | Close navigation drawer 10 | Exit 11 | Settings 12 | Open jar 13 | Author: 14 | Version: 15 | 16 | Converting JAR #8230; 17 | Complete 18 | No data for display 19 | 20 | Run configuration 21 | Screen options 22 | Scale to fit 23 | Keep aspect ratio 24 | Filter 25 | Font options 26 | Width 27 | Height 28 | Small 29 | Medium 30 | Large 31 | Values are in Scaled Pixels 32 | Background 33 | Virtual keyboard 34 | Buttons 35 | Labels 36 | Outline 37 | RGB 38 | Opacity: 39 | Hide delay: 40 | ms 41 | Layout customization: 42 | Start 43 | Cancel 44 | Labels (P) 45 | Buttons (P) 46 | Key sizes 47 | Joystick: 48 | Soft keys: 49 | Digits: 50 | Fire: 51 | Size 52 | Reset 53 | Presets 54 | Key code 55 | Language: %A 56 | Misc options 57 | Edit manifest 58 | Force-closing the application may result in data loss or even break it completely!\nProceed? 59 | Confirmation required 60 | Yes 61 | No 62 | 63 | 64 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Overlay.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import android.graphics.RectF; 20 | 21 | public interface Overlay 22 | { 23 | /** 24 | * Нацелить оверлей на указанный Canvas 25 | * @param canvas Canvas, которому при необходимости следует передавать 26 | * нажатия клавиш и движения указателя 27 | */ 28 | public void setTarget(Canvas canvas); 29 | 30 | /** 31 | * Вызывается при изменении размера реального (например, при повороте) 32 | * или виртуального экранов. 33 | * 34 | * @param screen размер реального экрана устройства 35 | * @param virtualScreen размер виртуального экрана, который доступен мидлету 36 | */ 37 | public void resize(RectF screen, RectF virtualScreen); 38 | 39 | /** 40 | * Вызывается при перерисовке экрана. 41 | * См. метод paint() в Canvas. 42 | * 43 | * @param g Graphics, через который следует вести рисование 44 | */ 45 | public void paint(Graphics g); 46 | 47 | /** 48 | * Вызывается при первом нажатии аппаратной клавиши. 49 | * 50 | * @param keyCode код нажатой клавиши 51 | * @return true, если нажатие обработано здесь и дальше его передавать не нужно 52 | */ 53 | public boolean keyPressed(int keyCode); 54 | 55 | /** 56 | * Вызывается при повторном (2, 3, и т.д.) нажатии аппаратной клавиши. 57 | * 58 | * @param keyCode код нажатой клавиши 59 | * @return true, если нажатие обработано здесь и дальше его передавать не нужно 60 | */ 61 | public boolean keyRepeated(int keyCode); 62 | 63 | /** 64 | * Вызывается при отпускании аппаратной клавиши. 65 | * 66 | * @param keyCode код нажатой клавиши 67 | * @return true, если нажатие обработано здесь и дальше его передавать не нужно 68 | */ 69 | public boolean keyReleased(int keyCode); 70 | 71 | /** 72 | * Вызывается при касании экрана указателем. 73 | * 74 | * @param pointer индекс указателя (всегда 0, если указатель один; 75 | * может быть больше 0, если устройство поддерживает мультитач) 76 | * @param x горизонтальная координата точки касания указателя на экране 77 | * @param y вертикальная координата точки касания указателя на экране 78 | * @return true, если касание обработано здесь и дальше его передавать не нужно 79 | */ 80 | public boolean pointerPressed(int pointer, float x, float y); 81 | 82 | /** 83 | * Вызывается при перемещении указателя по экрану. 84 | * 85 | * @param pointer индекс указателя (всегда 0, если указатель один; 86 | * может быть больше 0, если устройство поддерживает мультитач) 87 | * @param x горизонтальная координата точки касания указателя на экране 88 | * @param y вертикальная координата точки касания указателя на экране 89 | * @return true, если движение обработано здесь и дальше его передавать не нужно 90 | */ 91 | public boolean pointerDragged(int pointer, float x, float y); 92 | 93 | /** 94 | * Вызывается при отпускании указателя. 95 | * 96 | * @param pointer индекс указателя (всегда 0, если указатель один; 97 | * может быть больше 0, если устройство поддерживает мультитач) 98 | * @param x горизонтальная координата точки касания указателя на экране 99 | * @param y вертикальная координата точки касания указателя на экране 100 | * @return true, если касание обработано здесь и дальше его передавать не нужно 101 | */ 102 | public boolean pointerReleased(int pointer, float x, float y); 103 | 104 | /** 105 | * Показать оверлей. 106 | * Вызывается Canvas'ом при первом касании экрана указателем. 107 | */ 108 | public void show(); 109 | 110 | /** 111 | * Скрыть оверлей. 112 | * Вызывается Canvas'ом при отпускании с экрана последнего указателя. 113 | */ 114 | public void hide(); 115 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/list/CompoundAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui.list; 18 | 19 | import java.util.ArrayList; 20 | 21 | import javax.microedition.lcdui.Image; 22 | 23 | import android.content.Context; 24 | import android.database.DataSetObserver; 25 | import android.view.LayoutInflater; 26 | import android.view.View; 27 | import android.view.ViewGroup; 28 | import android.widget.Adapter; 29 | import android.widget.TextView; 30 | 31 | public abstract class CompoundAdapter implements Adapter 32 | { 33 | protected ArrayList items; 34 | protected ArrayList observers; 35 | protected Context context; 36 | 37 | public CompoundAdapter(Context context) 38 | { 39 | this.context = context; 40 | 41 | items = new ArrayList(); 42 | observers = new ArrayList(); 43 | } 44 | 45 | public void append(String stringPart, Image imagePart) 46 | { 47 | items.add(new CompoundItem(stringPart, imagePart)); 48 | notifyDataSetChanged(); 49 | } 50 | 51 | public void insert(int elementNum, String stringPart, Image imagePart) 52 | { 53 | items.add(elementNum, new CompoundItem(stringPart, imagePart)); 54 | notifyDataSetChanged(); 55 | } 56 | 57 | public void set(int elementNum, String stringPart, Image imagePart) 58 | { 59 | items.set(elementNum, new CompoundItem(stringPart, imagePart)); 60 | notifyDataSetChanged(); 61 | } 62 | 63 | public void delete(int elementNum) 64 | { 65 | items.remove(elementNum); 66 | notifyDataSetChanged(); 67 | } 68 | 69 | public void deleteAll() 70 | { 71 | items.clear(); 72 | notifyDataSetChanged(); 73 | } 74 | 75 | public int getCount() 76 | { 77 | return items.size(); 78 | } 79 | 80 | public boolean isEmpty() 81 | { 82 | return items.isEmpty(); 83 | } 84 | 85 | public CompoundItem getItem(int position) 86 | { 87 | return items.get(position); 88 | } 89 | 90 | public boolean hasStableIds() 91 | { 92 | return true; 93 | } 94 | 95 | public long getItemId(int position) 96 | { 97 | return position; 98 | } 99 | 100 | public int getViewTypeCount() 101 | { 102 | return 1; 103 | } 104 | 105 | public int getItemViewType(int position) 106 | { 107 | return 0; 108 | } 109 | 110 | protected View getView(int position, View convertView, ViewGroup parent, int viewResourceID, boolean useImagePart) 111 | { 112 | TextView textview; 113 | 114 | if(convertView != null && convertView instanceof TextView) 115 | { 116 | textview = (TextView)convertView; 117 | } 118 | else 119 | { 120 | textview = (TextView)LayoutInflater.from(context).inflate(viewResourceID, null); 121 | } 122 | 123 | CompoundItem item = items.get(position); 124 | textview.setText(item.getString()); 125 | 126 | if(useImagePart) 127 | { 128 | textview.setCompoundDrawablesWithIntrinsicBounds(item.getDrawable(), null, null, null); 129 | textview.setCompoundDrawablePadding(textview.getPaddingLeft()); 130 | } 131 | 132 | return textview; 133 | } 134 | 135 | public abstract View getView(int position, View convertView, ViewGroup parent); 136 | 137 | public void registerDataSetObserver(DataSetObserver observer) 138 | { 139 | if(!observers.contains(observer)) 140 | { 141 | observers.add(observer); 142 | } 143 | } 144 | 145 | public void unregisterDataSetObserver(DataSetObserver observer) 146 | { 147 | observers.remove(observer); 148 | } 149 | 150 | public void notifyDataSetChanged() 151 | { 152 | for(DataSetObserver observer : observers) 153 | { 154 | observer.onChanged(); 155 | } 156 | } 157 | 158 | public void notifyDataSetInvalidated() 159 | { 160 | for(DataSetObserver observer : observers) 161 | { 162 | observer.onInvalidated(); 163 | } 164 | } 165 | } -------------------------------------------------------------------------------- /app/src/main/java/ua/naiksoftware/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package ua.naiksoftware.util; 2 | 3 | import java.io.*; 4 | 5 | import java.util.TreeMap; 6 | import java.util.zip.ZipEntry; 7 | import java.util.zip.ZipInputStream; 8 | import filelog.Log; 9 | 10 | /** 11 | * 12 | * @author Naik 13 | */ 14 | public class FileUtils { 15 | 16 | private static final String tag = "FileUtils"; 17 | 18 | private static final long MIN_LOCAL_MEMORY = 1024 * 100;// 100 Kb 19 | 20 | public static void moveFiles(String src, String dest, FilenameFilter filter) { 21 | File fsrc = new File(src); 22 | File fdest = new File(dest); 23 | fdest.mkdirs(); 24 | String to; 25 | File[] list = fsrc.listFiles(filter); 26 | for(File entry: list) { 27 | to = entry.getPath().replace(src, dest); 28 | if (entry.isDirectory()) { 29 | moveFiles(entry.getPath(), to, filter); 30 | } else { 31 | entry.renameTo(new File(to)); 32 | } 33 | } 34 | } 35 | 36 | public static boolean unzip(InputStream is, File folderToUnzip) { 37 | //Log.d("Unzip", "method unzip started"); 38 | ZipInputStream zip = new ZipInputStream(new BufferedInputStream(is)); 39 | FileOutputStream fos = null; 40 | String fileName = null; 41 | ZipEntry zipEntry; 42 | try { 43 | while ((zipEntry = zip.getNextEntry()) != null) { 44 | //long free = folderToUnzip.getFreeSpace(); 45 | fileName = zipEntry.getName(); 46 | final File outputFile = new File(folderToUnzip, fileName); 47 | outputFile.getParentFile().mkdirs(); 48 | //Log.d("Unzip", "Zip entry: " + fileName + ", extract to: " + outputFile.getPath()); 49 | if (fileName.endsWith("/")) { 50 | //Log.d("Unzip", fileName+ " is directory"); 51 | outputFile.mkdirs(); 52 | continue; 53 | } else { 54 | outputFile.createNewFile(); 55 | //if (zipEntry.getSize() == outputFile.length()) { 56 | // continue; 57 | //} 58 | //free = free - zipEntry.getSize() + outputFile.length(); 59 | //if (free < MIN_LOCAL_MEMORY) { 60 | // error 61 | // return false; 62 | //} 63 | fos = new FileOutputStream(outputFile, false); 64 | byte[] bytes = new byte[2048]; 65 | int c; 66 | try { 67 | while ((c = zip.read(bytes)) != -1) { 68 | fos.write(bytes, 0, c); 69 | } 70 | fos.flush(); 71 | fos.close(); 72 | } catch (IOException e) { 73 | Log.d("Unzip", "IOErr in readFromStream (zip.read(bytes)): " + e.getMessage()); 74 | return false; 75 | } 76 | } 77 | zip.closeEntry(); 78 | } 79 | } catch (IOException ioe) { 80 | Log.d("Unzip err", ioe.getMessage()); 81 | return false; 82 | } finally { 83 | try { 84 | zip.close(); 85 | zip = null; 86 | } catch (Exception e) { 87 | } 88 | } 89 | return true; 90 | } 91 | 92 | public static void deleteDirectory(File dir) { 93 | if (dir.isDirectory()) { 94 | File[] listFiles = dir.listFiles(); 95 | for (File file : listFiles) { 96 | deleteDirectory(file); 97 | } 98 | dir.delete(); 99 | } else { 100 | dir.delete(); 101 | } 102 | } 103 | 104 | public static TreeMap loadManifest(File mf) { 105 | TreeMap params = new TreeMap(); 106 | try { 107 | BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(mf))); 108 | String line; 109 | int index; 110 | while ((line = br.readLine()) != null) { 111 | index = line.indexOf(':'); 112 | if (index > 0) { 113 | params.put(line.substring(0, index).trim(), line.substring(index + 1).trim()); 114 | } 115 | } 116 | br.close(); 117 | } catch (Throwable t) { 118 | System.out.println("getAppProperty() will not be available due to " + t.toString()); 119 | } 120 | return params; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/util/LinkedEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.util; 18 | 19 | /** 20 | * Элемент связного списка. 21 | * @param что он содержит 22 | */ 23 | public class LinkedEntry 24 | { 25 | private LinkedEntry prev; 26 | private LinkedEntry next; 27 | 28 | private E element; 29 | 30 | // private static int counter = 0; 31 | // private int id; 32 | // 33 | // public LinkedEntry() 34 | // { 35 | // id = ++counter; 36 | // } 37 | 38 | /** 39 | * Присвоить элементу значение. 40 | * @param element новое значение 41 | */ 42 | public void setElement(E element) 43 | { 44 | this.element = element; 45 | } 46 | 47 | /** 48 | * @return текущее значение элемента 49 | */ 50 | public E getElement() 51 | { 52 | return element; 53 | } 54 | 55 | /** 56 | * @return элемент, предшествующий данному; или null, если такого элемента нет 57 | */ 58 | public LinkedEntry prevEntry() 59 | { 60 | return prev; 61 | } 62 | 63 | /** 64 | * @return элемент, следующий за данным; null, если такого элемента нет 65 | */ 66 | public LinkedEntry nextEntry() 67 | { 68 | return next; 69 | } 70 | 71 | /** 72 | * Изъять этот элемент из списка. 73 | * Смежные элементы при этом соединяются между собой. 74 | */ 75 | public void remove() 76 | { 77 | if(prev != null) 78 | { 79 | prev.next = next; // следующий за предыдущим = следующий за этим 80 | } 81 | 82 | if(next != null) 83 | { 84 | next.prev = prev; // предшествующий следующему = предшествующий этому 85 | } 86 | 87 | prev = null; 88 | next = null; 89 | } 90 | 91 | /** 92 | * Восстановить двунаправленность связей для этого элемента. 93 | * 94 | * То есть, если перед нами кто-то есть, то мы стоим за ним; 95 | * если кто-то есть после нас, то мы стоим перед ним. 96 | */ 97 | private void updateLinks() 98 | { 99 | if(prev != null) 100 | { 101 | prev.next = this; 102 | } 103 | 104 | if(next != null) 105 | { 106 | next.prev = this; 107 | } 108 | } 109 | 110 | /** 111 | * Вставить этот элемент перед указанным. 112 | * Предполагается, что указанный элемент входит в состав некоторого списка. 113 | * 114 | * @param entry 115 | */ 116 | public void insertBefore(LinkedEntry entry) 117 | { 118 | remove(); // элемент не можеть быть одновременно в двух местах в списке 119 | 120 | prev = entry.prev; // предыдущий для указанного - теперь наш предыдущий 121 | next = entry; // сам указанный - теперь наш следующий 122 | 123 | updateLinks(); // доносим эти изменения до наших новых соседей 124 | } 125 | 126 | /** 127 | * Вставить этот элемент после указанного. 128 | * Предполагается, что указанный элемент входит в состав некоторого списка. 129 | * 130 | * @param entry 131 | */ 132 | public void insertAfter(LinkedEntry entry) 133 | { 134 | remove(); // элемент не можеть быть одновременно в двух местах в списке 135 | 136 | prev = entry; // сам указанный - теперь наш предыдущий 137 | next = entry.next; // следующий для указанного - теперь наш следующий 138 | 139 | updateLinks(); // доносим эти изменения до наших новых соседей 140 | } 141 | 142 | // public String toString() 143 | // { 144 | // StringBuilder buf = new StringBuilder(); 145 | // 146 | // buf.append("LinkedEntry("); 147 | // 148 | // if(prev != null) 149 | // { 150 | // buf.append(prev.id); 151 | // } 152 | // else 153 | // { 154 | // buf.append(-1); 155 | // } 156 | // 157 | // buf.append(", "); 158 | // 159 | // buf.append(id); 160 | // buf.append(", "); 161 | // 162 | // if(next != null) 163 | // { 164 | // buf.append(next.id); 165 | // } 166 | // else 167 | // { 168 | // buf.append(-1); 169 | // } 170 | // 171 | // buf.append(", "); 172 | // buf.append(element); 173 | // 174 | // buf.append(")"); 175 | // 176 | // return buf.toString(); 177 | // } 178 | } -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/midlet/MIDlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy, Naik 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package javax.microedition.midlet; 17 | 18 | import java.util.Locale; 19 | import java.util.TreeMap; 20 | 21 | import javax.microedition.io.ConnectionNotFoundException; 22 | import javax.microedition.lcdui.Display; 23 | import javax.microedition.lcdui.Displayable; 24 | import javax.microedition.util.ContextHolder; 25 | 26 | import ua.naiksoftware.j2meloader.AppItem; 27 | import android.content.ActivityNotFoundException; 28 | import android.content.Intent; 29 | import android.net.Uri; 30 | 31 | public class MIDlet { 32 | 33 | private static TreeMap tempProps; 34 | private TreeMap props; 35 | private AppItem app; 36 | 37 | /** 38 | * Для первоначальной инициализации мидлета, чтобы в конструкторе оболочка 39 | * уже была готова работать с этим мидлетом. 40 | */ 41 | { 42 | Display.addDisplay(this); 43 | Display.getDisplay(this).setCurrent(defaultDisplayable); 44 | } 45 | 46 | /** 47 | * Запуск мидлета 48 | * 49 | * @param app 50 | */ 51 | public void start(AppItem app) { 52 | this.app = app; 53 | ContextHolder.getActivity().setTitle( 54 | app.getTitle() + " " + app.getVersion()); 55 | startApp(); 56 | } 57 | 58 | /** 59 | * Установка временных параметров мидлета из его манифеста. Нужно для их 60 | * доступности в конструкторе по умолчанию, который вызывается через 61 | * рефлексию. После инициализации мидлета нужно установить эти же параметры 62 | * с помощью {@link #setProps(TreeMap)} 63 | * 64 | * @param p 65 | */ 66 | public static void initTempProps(TreeMap p) { 67 | tempProps = p; 68 | } 69 | 70 | /** 71 | * @see {@link #initTempProps(TreeMap)} 72 | * @param p 73 | */ 74 | public void setProps(TreeMap p) { 75 | this.props = p; 76 | } 77 | 78 | public String getAppProperty(String key) { 79 | if (props == null) { 80 | return tempProps.get(key); 81 | } else { 82 | return props.get(key); 83 | } 84 | } 85 | 86 | /** 87 | * Вызывается каждый раз, когда мидлет становится активным: при запуске, при 88 | * восстановлении из свернутого состояния, ... Не вызывайте напрямую этот 89 | * метод! Для запуска мидлета вызывайте {@link #start(AppItem)} 90 | */ 91 | public void startApp() { 92 | } 93 | 94 | /** 95 | * Сообщить оболочке, что мидлет готов перейти в состояние паузы. При этом 96 | * он будет свернут в фон. 97 | * 98 | * Вызовы этого метода из pauseApp() игнорируются. 99 | */ 100 | public final void notifyPaused() { 101 | // if (!pauseAppCalled) { 102 | // ContextHolder.notifyPaused(); 103 | // } 104 | } 105 | 106 | /** 107 | * Сообщить оболочке, что мидлет завершил работу. При этом экран мидлета 108 | * будет удален. 109 | */ 110 | public final void notifyDestroyed() { 111 | Display.removeDisplay(this); 112 | } 113 | 114 | /** 115 | * Вызывается каждый раз, когда мидлет становится на паузу: при сворачивании 116 | * в фоновый режим, ... 117 | */ 118 | public void pauseApp() { 119 | } 120 | 121 | /** 122 | * Вызывается при завершении работы приложения. 123 | * 124 | * @param unconditional 125 | * флаг безусловного завершения, для Android не имеет особого 126 | * смысла 127 | */ 128 | public static void destroyApp(boolean unconditional) { 129 | } 130 | 131 | public static String getDefaultLocale() { 132 | return Locale.getDefault().getCountry(); 133 | } 134 | 135 | public boolean platformRequest(String url) 136 | throws ConnectionNotFoundException { 137 | try { 138 | ContextHolder.getContext().startActivity( 139 | new Intent(Intent.ACTION_VIEW, Uri.parse(url))); 140 | } catch (ActivityNotFoundException e) { 141 | throw new ConnectionNotFoundException(); 142 | } 143 | 144 | return true; 145 | } 146 | 147 | public AppItem getAppItem() { 148 | return app; 149 | } 150 | 151 | private static Displayable defaultDisplayable = new Displayable() { 152 | // default implementation 153 | }; 154 | 155 | } 156 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Displayable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import java.util.ArrayList; 20 | 21 | import javax.microedition.lcdui.event.CommandActionEvent; 22 | import javax.microedition.util.ContextHolder; 23 | 24 | import ua.naiksoftware.j2meloader.R; 25 | import android.view.Menu; 26 | import android.view.MenuItem; 27 | import android.view.View; 28 | 29 | public abstract class Displayable { 30 | private MicroActivity parent; 31 | private String title; 32 | 33 | private ArrayList commands; 34 | private CommandListener listener; 35 | private View defaultView; 36 | 37 | private static EventQueue queue; 38 | 39 | static { 40 | queue = new EventQueue(); 41 | queue.startProcessing(); 42 | } 43 | 44 | public Displayable() { 45 | commands = new ArrayList(); 46 | listener = null; 47 | 48 | // queue = new EventQueue(); 49 | } 50 | 51 | @Deprecated 52 | public void setParentActivity(MicroActivity activity) { 53 | parent = activity; 54 | 55 | // if(activity != null) 56 | // { 57 | // queue.startProcessing(); 58 | // } 59 | // else 60 | // { 61 | // queue.stopProcessing(); 62 | // } 63 | 64 | clearDisplayableView(); 65 | } 66 | 67 | @Deprecated 68 | public MicroActivity getParentActivity() { 69 | if (parent == null) { 70 | throw new IllegalStateException( 71 | "call setParentActivity() before calling getParentActivity()"); 72 | } 73 | 74 | return parent; 75 | } 76 | 77 | @Deprecated 78 | public boolean hasParentActivity() { 79 | return parent != null; 80 | } 81 | 82 | public void setTitle(String title) { 83 | this.title = title; 84 | 85 | if (parent != null) { 86 | parent.setTitle(title); 87 | } 88 | } 89 | 90 | public String getTitle() { 91 | return title; 92 | } 93 | 94 | public boolean isShown() { 95 | if (parent != null) { 96 | return parent.isVisible() && parent.getCurrent() == this; 97 | } 98 | 99 | return false; 100 | } 101 | 102 | public View getDisplayableView() { 103 | if (defaultView == null) { 104 | defaultView = ContextHolder.getInflater().inflate( 105 | R.layout.default_displayable_layout, null); 106 | } 107 | return defaultView; 108 | } 109 | 110 | public void clearDisplayableView() { 111 | defaultView = null; 112 | } 113 | 114 | public void addCommand(Command cmd) { 115 | commands.add(cmd); 116 | } 117 | 118 | public void removeCommand(Command cmd) { 119 | commands.remove(cmd); 120 | } 121 | 122 | public void removeAllCommands() { 123 | commands.clear(); 124 | } 125 | 126 | public int countCommands() { 127 | return commands.size(); 128 | } 129 | 130 | public Command[] getCommands() { 131 | return commands.toArray(new Command[0]); 132 | } 133 | 134 | public void setCommandListener(CommandListener listener) { 135 | this.listener = listener; 136 | } 137 | 138 | public void fireCommandAction(Command c, Displayable d) { 139 | if (listener != null) { 140 | queue.postEvent(CommandActionEvent.getInstance(listener, c, d)); 141 | } 142 | } 143 | 144 | public void populateMenu(Menu menu) { 145 | menu.clear(); 146 | 147 | for (Command cmd : commands) { 148 | menu.add(Menu.NONE, cmd.hashCode(), cmd.getPriority(), 149 | cmd.getLabel()); 150 | } 151 | } 152 | 153 | public boolean menuItemSelected(MenuItem item) { 154 | if (listener == null) { 155 | return false; 156 | } 157 | 158 | int id = item.getItemId(); 159 | 160 | for (Command cmd : commands) { 161 | if (cmd.hashCode() == id) { 162 | queue.postEvent(CommandActionEvent.getInstance(listener, cmd, 163 | this)); 164 | return true; 165 | } 166 | } 167 | 168 | return false; 169 | } 170 | 171 | public EventQueue getEventQueue() { 172 | return queue; 173 | } 174 | 175 | public void postEvent(Event event) { 176 | queue.postEvent(event); 177 | } 178 | 179 | // Added by Naik 180 | public int getWidth() { 181 | return getDisplayableView().getWidth(); 182 | } 183 | 184 | // Added by Naik 185 | public int getHeight() { 186 | return getDisplayableView().getHeight(); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /app/src/main/java/javax/microedition/lcdui/Image.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 Kulikov Dmitriy 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package javax.microedition.lcdui; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | 22 | import javax.microedition.lcdui.game.Sprite; 23 | import javax.microedition.util.ContextHolder; 24 | 25 | import android.graphics.Bitmap; 26 | import android.graphics.BitmapFactory; 27 | import android.graphics.Canvas; 28 | 29 | import java.io.FileInputStream; 30 | 31 | import javax.microedition.shell.ConfScreen; 32 | 33 | import ua.naiksoftware.j2meloader.AppsListFragment; 34 | 35 | public class Image 36 | { 37 | private Bitmap bitmap; 38 | private Canvas canvas; 39 | 40 | public Image(Bitmap bitmap) 41 | { 42 | if(bitmap == null) 43 | { 44 | throw new NullPointerException(); 45 | } 46 | 47 | this.bitmap = bitmap; 48 | } 49 | 50 | public Bitmap getBitmap() 51 | { 52 | return bitmap; 53 | } 54 | 55 | public Canvas getCanvas() 56 | { 57 | if(canvas == null) 58 | { 59 | canvas = new Canvas(bitmap); 60 | } 61 | 62 | return canvas; 63 | } 64 | 65 | public static Image createImage(int width, int height) 66 | { 67 | return new Image(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)); 68 | } 69 | 70 | public static Image createImage(int id) 71 | { 72 | return new Image(BitmapFactory.decodeResource(ContextHolder.getContext().getResources(), id)); 73 | } 74 | 75 | public static Image createImage(String resname) throws IOException 76 | { 77 | if(resname.startsWith("/")) 78 | { 79 | resname = resname.substring(1); 80 | } 81 | 82 | InputStream is = new FileInputStream(AppsListFragment.getCurrConf().getAppDir() + ConfScreen.MIDLET_RES_DIR + resname); 83 | Bitmap bitmap = BitmapFactory.decodeStream(is); 84 | is.close(); 85 | 86 | return new Image(bitmap); 87 | } 88 | 89 | public static Image createImage(InputStream stream) 90 | { 91 | return new Image(BitmapFactory.decodeStream(stream)); 92 | } 93 | 94 | public static Image createImage(byte[] imageData, int imageOffset, int imageLength) 95 | { 96 | return new Image(BitmapFactory.decodeByteArray(imageData, imageOffset, imageLength)); 97 | } 98 | 99 | public static Image createImage(Image image, int x, int y, int width, int height, int transform) 100 | { 101 | return new Image(Bitmap.createBitmap(image.bitmap, x, y, width, height, Sprite.transformMatrix(null, transform, width / 2f, height / 2f), true)); 102 | } 103 | 104 | public static Image createRGBImage(int[] rgb, int width, int height, boolean processAlpha) 105 | { 106 | return new Image(Bitmap.createBitmap(rgb, width, height, Bitmap.Config.ARGB_8888)); 107 | } 108 | 109 | /** 110 | * Функция масштабирования изображений. 111 | * 112 | * Если один из конечных размеров меньше 0, 113 | * он вычисляется на основе другого с сохранением пропорций. 114 | * 115 | * Если оба конечных размера меньше 0, 116 | * или они равны размеру исходной картинки, 117 | * возвращается исходная картинка. 118 | * 119 | * @param destw конечная ширина 120 | * @param desth конечная высота 121 | * @param filter true, если нужно использовать интерполяцию 122 | * @return масштабированная картинка 123 | */ 124 | public Image scale(int destw, int desth, boolean filter) 125 | { 126 | int srcw = getWidth(); 127 | int srch = getHeight(); 128 | 129 | if(srcw == destw && srch == desth) 130 | { 131 | return this; 132 | } 133 | 134 | if(destw < 0) 135 | { 136 | if(desth < 0) 137 | { 138 | return this; 139 | } 140 | else 141 | { 142 | destw = srcw * desth / srch; 143 | } 144 | } 145 | else if(desth < 0) 146 | { 147 | desth = srch * destw / srcw; 148 | } 149 | 150 | return new Image(Bitmap.createScaledBitmap(bitmap, destw, desth, filter)); 151 | } 152 | 153 | public Graphics getGraphics() 154 | { 155 | return new Graphics(getCanvas()); 156 | } 157 | 158 | public boolean isMutable() 159 | { 160 | return bitmap.isMutable(); 161 | } 162 | 163 | public int getWidth() 164 | { 165 | return bitmap.getWidth(); 166 | } 167 | 168 | public int getHeight() 169 | { 170 | return bitmap.getHeight(); 171 | } 172 | 173 | public void getRGB(int[] rgbData, int offset, int scanlength, int x, int y, int width, int height) 174 | { 175 | bitmap.getPixels(rgbData, offset, scanlength, x, y, width, height); 176 | } 177 | } 178 | --------------------------------------------------------------------------------