telegram-s / telegram

Telegram S Edition Android App
MIT License
229 stars 108 forks source link

Service not startable from Notifications.java #10

Open FlorentAnders opened 10 years ago

FlorentAnders commented 10 years ago

Hello!

I would like to build the App in Android Studio. I added the V4 Support Librarys in the Projects which Needed it but the main package requires ActionBarSherlock. How can I add ActionBarSherlock into the Project?

Thanks for your help

Florent1510

ex3ndr commented 10 years ago

I am using original IntelliJ IDEA, but it is very buggy (as Android Studio), but project is optimized for it. Try to use IDEA.

FlorentAnders commented 10 years ago

Ok, I will try it. Thanks!

FlorentAnders commented 10 years ago

I now tried IntelliJ IDEA and now it gets the same error that I got on Android Studio (I got ActionBarSherlock added).

"No resource found that matches given Name at" ...

For example "at background with value @drawable/st_bubble_service"

What's the Problem?

ex3ndr commented 10 years ago

You may try to reimport app. I building app from console with gradle assembleDevDebug, not by IDE. May be it helps.

FlorentAnders commented 10 years ago

Thank you. I finally got it built with gradle! :)

But there are two things:

  1. How do I Change the Version from "debug" to another?
  2. How do I Change the package Name from "org.telegram.dev" to "org.telegram"?
FlorentAnders commented 10 years ago

Ok , I got everything built and translated it fully to German.

To thank you, I am ready to send you this german Translation.

Do you want it?

ex3ndr commented 10 years ago

Yes, of course! Just made pull-request.

FlorentAnders commented 10 years ago

Hello!

I'm now working on Chat head notifications when a message arrives so in .Android.core.Notifications at onNewChatMessage I want to start the Service ChatHeadService. But how do I do that?

If I type application.startService(new Intent(application, ChatHeadService.class)); , the app Exits and nothing happens.

So the application.startService is an error I think. What do I have to write?

FlorentAnders commented 10 years ago

BTW get the values-de here:

https://drive.google.com/folderview?id=0B7PIyoRznmeuU25IdXBoNjhNR3M&usp=sharing

ex3ndr commented 10 years ago

For now this is not good to keep application running, because it keeps all connections during this, this will drain battery and produces a lot of traffic. Unfortunately, starting service in different process will produce other initialization problems :-(

BTW application.startService isn't a mistake. I think that your service was started, but you have bugs in it.

FlorentAnders commented 10 years ago

Ok, thanks.

FlorentAnders commented 10 years ago

Hi again :) Can you find the error here?

package org.telegram.android;

/**

import android.annotation.SuppressLint; import android.app.Service; import android.content.Intent; import android.graphics.PixelFormat; import android.graphics.Point; import android.graphics.Typeface; import android.os.IBinder; import android.view.Display; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.WindowManager; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast;

import com.fa.atom.R;

import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; import static android.view.WindowManager.LayoutParams.TYPE_PHONE;

public class ChatHeadDrawerService extends Service {

private WindowManager mWindowManager;
private View mChatHead;
private ImageView mChatHeadImageView;
private TextView mChatHeadTextView;
private LinearLayout mLayout;
private static int screenWidth;
private static int screenHeight;

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@SuppressLint("NewApi")
@Override
public void onCreate() {
    super.onCreate();

    Typeface tf = Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf");

    mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    Display display = mWindowManager.getDefaultDisplay();
    Point size= new Point();
    display.getSize(size);
    screenWidth = size.x;
    screenHeight = size.y;

    LayoutInflater inflater = LayoutInflater.from(this);
    mChatHead = inflater.inflate(R.layout.chathead, null);
    mChatHeadImageView = (ImageView) mChatHead.findViewById(R.id.chathead_imageview);
    mChatHeadTextView = (TextView) mChatHead.findViewById(R.id.chathead_textview);
    mLayout = (LinearLayout) mChatHead.findViewById(R.id.chathead_linearlayout);

    mChatHeadTextView.setTypeface(tf);

    final WindowManager.LayoutParams parameters = new WindowManager.LayoutParams(
            WRAP_CONTENT, // Width
            WRAP_CONTENT, // Height
            TYPE_PHONE, // Type
            FLAG_NOT_FOCUSABLE, // Flag
            PixelFormat.TRANSLUCENT // Format
    );

    parameters.x = 0;
    parameters.y = 50;
    parameters.gravity = Gravity.TOP | Gravity.LEFT;

    // Drag support!
    mChatHeadImageView.setOnTouchListener(new OnTouchListener() {

        int initialX, initialY;
        float initialTouchX, initialTouchY;

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            switch (event.getAction()) {
                case ACTION_DOWN:
                    initialX = parameters.x;
                    initialY = parameters.y;
                    initialTouchX = event.getRawX();
                    initialTouchY = event.getRawY();
                    Toast.makeText(getApplication(), "Zum Löschen hierhin ziehen!", Toast.LENGTH_SHORT).show();
                    return true;

                case ACTION_MOVE:
                    mChatHeadTextView.setVisibility(View.GONE);
                    parameters.x = initialX + (int) (event.getRawX() - initialTouchX);
                    parameters.y = initialY    + (int) (event.getRawY() - initialTouchY);
                    mWindowManager.updateViewLayout(mChatHead, parameters);
                    return true;

                case ACTION_UP:

                    if(parameters.y > screenHeight * 0.6) {
                        mChatHead.setVisibility(View.GONE);
                        Toast.makeText(getApplication(), "Gelöscht!", Toast.LENGTH_SHORT).show();
                        stopSelf();
                    }

                    if(parameters.x < screenWidth / 2) {
                        mLayout.removeAllViews();
                        mLayout.addView(mChatHeadImageView);
                        mLayout.addView(mChatHeadTextView);
                        mChatHeadTextView.setVisibility(View.VISIBLE);

                    } else { // Set textView to left of image
                        mLayout.removeAllViews();
                        mLayout.addView(mChatHeadTextView);
                        mLayout.addView(mChatHeadImageView);
                        mChatHeadTextView.setVisibility(View.VISIBLE);
                    }
                    return true;

                default:
                    return false;
            }
        }
    });

    mWindowManager.addView(mChatHead, parameters);
}

}

ex3ndr commented 10 years ago

What kind of problem do you have? BTW, for fonts there are FontController and everywhere fonts are replaced mostly automatically (you just need to init inflater).

FlorentAnders commented 10 years ago

When the message arrives, the app starts the Service and the Service Exits so but the app works so there must be a Problem within the Service code

ex3ndr commented 10 years ago

I'll recomend you to take window manager not from service context, but from ApplicationContext.

FlorentAnders commented 10 years ago

Hello, I'm working on the Chat heads.

My other question is: On the Google Play page of Telegram (Unofficial), which is Telegram S, the app hasn't got the same design. It has this iOS7-like White flat design.

How can I get to this design? I love it!

ex3ndr commented 10 years ago

This is old design of Telegram S, may be we will introduce something same, but for now this design is not available.

David292 commented 9 years ago

hello , I have problem during running then app . it says resource not found.please look detail. can you guys help me . Error:Execution failed for task ':TMessagesProj:processDebugResources'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/dilippatel/Downloads/adt-bundle-mac-x86_64-20140702/sdk/build-tools/21.0.2/aapt package -f --no-crunch -I /Users/dilippatel/Downloads/adt-bundle-mac-x8664-20140702/sdk/platforms/android-21/android.jar -M /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/res/debug -A /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/assets/debug -m -J /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/generated/source/r/debug -F /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/res/resources-debug.ap --debug-mode --custom-package org.iparivar.jobakaSMS -0 apk --output-text-symbols /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/symbols/debug Error Code: 1 Output: /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/manifests/full/debug/AndroidManifest.xml:91: error: Error: No resource found that matches the given name (at 'label' with value '@string/jobakaSMS'). /Users/dilippatel/Desktop/jobakaSMS/TMessagesProj/build/intermediates/manifests/full/debug/AndroidManifest.xml:102: error: Error: No resource found that matches the given name (at 'label' with value '@string/jobakaSMS').