Problem on upgrading the code to suit the latest sdk

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Postby totw » Mon Apr 13, 2009 2:23 pm

OK..Thks..

I will try out whatever you have suggested and reply back..

:)
User avatar
totw
Developer
Developer
 
Posts: 27
Joined: Tue Mar 31, 2009 10:35 am

Top

Postby totw » Thu Apr 16, 2009 11:13 am

Hey,

I tried a lot but couldn't find a solution to the last part (the display one). So, I am posting the entire application. Please take a look..

I am using the latest sdk (android-sdk-windows-1.1_r1)..
(the application is a telnet client which is supposed to connect to a remote server on port 23.. the problem is in the final display only.. concerned with classes terminalactivity, terminalview and charpanel)

Thanx a ton :)
Last edited by totw on Fri Apr 17, 2009 7:32 am, edited 1 time in total.
User avatar
totw
Developer
Developer
 
Posts: 27
Joined: Tue Mar 31, 2009 10:35 am

Postby padde » Thu Apr 16, 2009 3:00 pm

I played a bit with the code.. but there are FAR more problems than just a display problem.
I never realy get that app far enough to test if its a display issue or not.
I would suggest u start from scratch .. and use the chance to write a cleaner version.
Anyway i have no time or spirit to make that thing work at this state.
Maybe u send me a wrong version? Even the layouts contains errors...


Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby totw » Fri Apr 17, 2009 9:47 am

Extremely sorry for that code.. I am posting the correct version of the code. Just a few precautions :

You will have to change the .classpath file.
there are 2 ways of doing it (you may know them already but I'm still writing it here.)

1) just open the .classpath file into wordpad and make the necessary changes (like entering the correct directory path). But this must be done before you open the project in eclipse

2) or create a new android project in eclipse with following names
Project name : Main
package name : tel.net.client
activity name : .Main
application name : Main

and then import the folder I sent you by rightclick->import->general->file system->browse
then select the folder
Then untick the .classpath and click finish

(additionally you will have to check the text file encoding in properties; it should be UTF-8 )
(If you want to test the display, just try connecting to your router by typing IP of your default gateway. That will be easier than connecting to any other PC)
Last edited by totw on Sun Apr 26, 2009 8:36 am, edited 1 time in total.
User avatar
totw
Developer
Developer
 
Posts: 27
Joined: Tue Mar 31, 2009 10:35 am

Postby padde » Fri Apr 17, 2009 11:42 am

K that code works :)
I installed a Telnet/SSH server on my PC called KpyM to test the app.
With the changes i suggested i see all i supposed to see i think :)
Just 2 lines of code..


1. line in TerminalActivity.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. class MyHandler extends Handler {
  3.  
  4.     TerminalView tv;
  5.  
  6.     TextView txt;
  7.  
  8.  
  9.  
  10.     MyHandler(TerminalView termView, TextView txt) {
  11.  
  12.         super();
  13.  
  14.         tv = termView;
  15.  
  16.         this.txt = txt;
  17.  
  18.     }
  19.  
  20.  
  21.  
  22.     public void handleMessage(android.os.Message msg) {
  23.  
  24.         Bundle hm = msg.getData();
  25.  
  26.  
  27.  
  28.         String msgText = (String) hm.get("message");
  29.  
  30.         if(msg.what == 0)
  31.  
  32.         {
  33.  
  34.             tv.draw(tv.getHolder().lockCanvas());       // call draw witch correct locked canvas
  35.  
  36.             tv.cp.AddBuffer(msgText.toCharArray());
  37.  
  38.             tv.invalidate(0,0,Integer.MAX_VALUE,Integer.MAX_VALUE);
  39.  
  40.             txt.setVisibility(View.INVISIBLE);
  41.  
  42.         }
  43.  
  44.         else if(msg.what == 1)
  45.  
  46.         {
  47.  
  48.             txt.setText(msgText);
  49.  
  50.             txt.setTextColor(0xFFFF0000);
  51.  
  52.             txt.setVisibility(View.VISIBLE);            
  53.  
  54.         }
  55.  
  56.         else if(msg.what == 2)
  57.  
  58.         {
  59.  
  60.             txt.setText(msgText);
  61.  
  62.             txt.setTextColor(0xFF00FF00);
  63.  
  64.             txt.setVisibility(View.VISIBLE);            
  65.  
  66.         }
  67.  
  68.     }
  69.  
  70. }
  71.  
  72.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


2.line in TerminalView.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public void draw(Canvas canvas)
  3.  
  4. {
  5.  
  6.     Paint paint = new Paint();
  7.  
  8.     paint.setTypeface(Typeface.MONOSPACE);
  9.  
  10.     paint.setAntiAlias(true);
  11.  
  12.     paint.setTextSize(fontSize);
  13.  
  14.    
  15.  
  16.     if(cp == null) return;
  17.  
  18.     canvas.drawColor(Color.BLACK);
  19.  
  20.     for(int j = 0; j < cp.iSizeY; j++)
  21.  
  22.     {
  23.  
  24.         if(cp.isDirty && cp.isDirtyLine[j])
  25.  
  26.         {
  27.  
  28.             for(int i = 0; i < cp.iSizeX; i++)
  29.  
  30.             {
  31.  
  32.                 canvas.save();
  33.  
  34.                 canvas.clipRect(i * fontWidth + offsetX, j * fontHeight + offsetY, (i + 1) *fontWidth + offsetX, (j + 1) * fontHeight + offsetY);
  35.  
  36.                 canvas.drawColor(cp.Matrix[i][j].clrBg);
  37.  
  38.                 canvas.restore();            
  39.  
  40.                 paint.setColor(cp.Matrix[i][j].clrFg);
  41.  
  42.                 canvas.drawText("" + cp.Matrix[i][j].chr , i*fontWidth + offsetX, j * fontHeight - fontAsc + offsetY, paint);
  43.  
  44.             }
  45.  
  46.         }
  47.  
  48.     }
  49.  
  50.     getHolder().unlockCanvasAndPost(canvas); // unlock canvas and post changes
  51.  
  52. }
  53.  
  54.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Greets
Padde
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Postby totw » Fri Apr 17, 2009 2:21 pm

Thanks a lot :)
The problem is almost solved..
I am getting the display right.. Whenever I type anything, it gets displayed properly, but there is always a lag of one character..

for example :

If the username of my server is say 'Randy'

When I press the connect button, first of all , I get a blank display.

Then when I press the first letter, 'R' in this case, the message prompt for username appears. (here, 'R' has actually been accepted but not been displayed yet)

When I press the next character 'a', it displays 'R' (i.e the previous character sent)

This goes on...

Thus, there is a problem in the proper updation of the display, resulting in lag of display for one character...

Thanks a lot..
User avatar
totw
Developer
Developer
 
Posts: 27
Joined: Tue Mar 31, 2009 10:35 am

Top

Postby totw » Wed Apr 22, 2009 12:38 pm

The Problem above has been solved :)
User avatar
totw
Developer
Developer
 
Posts: 27
Joined: Tue Mar 31, 2009 10:35 am

Top
Previous

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests