Reorganized code a bit more
This commit is contained in:
parent
8f9aeecf82
commit
2217070995
40 changed files with 73 additions and 272 deletions
|
@ -81,7 +81,7 @@
|
|||
<!-- Main activities -->
|
||||
|
||||
<activity
|
||||
android:name=".activities.DialerActivity"
|
||||
android:name=".dialer.DialerActivity"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.DIAL" />
|
||||
|
@ -211,7 +211,7 @@
|
|||
<!-- Services -->
|
||||
|
||||
<service
|
||||
android:name=".LinphoneService"
|
||||
android:name=".service.LinphoneService"
|
||||
android:label="@string/service_name" />
|
||||
|
||||
<service
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.linphone.core.LoggingServiceListener;
|
|||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.notifications.NotificationsManager;
|
||||
import org.linphone.service.LinphoneService;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.DeviceUtils;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.Date;
|
|||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import org.linphone.assistant.PhoneAccountLinkingAssistantActivity;
|
||||
import org.linphone.call.AndroidAudioManager;
|
||||
import org.linphone.call.CallManager;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.core.AccountCreator;
|
||||
|
@ -67,7 +68,6 @@ import org.linphone.core.VersionUpdateCheckResult;
|
|||
import org.linphone.core.tools.H264Helper;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.AndroidAudioManager;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.utils.MediaScanner;
|
||||
import org.linphone.utils.PushNotificationUtils;
|
||||
|
|
|
@ -24,9 +24,9 @@ import android.os.Bundle;
|
|||
import android.view.Surface;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.service.LinphoneService;
|
||||
|
||||
public abstract class LinphoneGenericActivity extends ThemeableActivity {
|
||||
@Override
|
||||
|
|
|
@ -24,15 +24,16 @@ import android.content.Intent;
|
|||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Bundle;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.assistant.MenuAssistantActivity;
|
||||
import org.linphone.chat.ChatActivity;
|
||||
import org.linphone.contacts.ContactsActivity;
|
||||
import org.linphone.dialer.DialerActivity;
|
||||
import org.linphone.history.HistoryActivity;
|
||||
import org.linphone.service.LinphoneService;
|
||||
import org.linphone.service.ServiceWaitThread;
|
||||
import org.linphone.service.ServiceWaitThreadListener;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.ServiceWaitThread;
|
||||
import org.linphone.utils.ServiceWaitThreadListener;
|
||||
|
||||
/** Creates LinphoneService and wait until Core is ready to start main Activity */
|
||||
public class LinphoneLauncherActivity extends Activity implements ServiceWaitThreadListener {
|
||||
|
|
|
@ -45,7 +45,6 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.call.CallActivity;
|
||||
import org.linphone.call.CallIncomingActivity;
|
||||
|
@ -65,10 +64,12 @@ import org.linphone.core.CoreListenerStub;
|
|||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.core.RegistrationState;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.dialer.DialerActivity;
|
||||
import org.linphone.fragments.EmptyFragment;
|
||||
import org.linphone.fragments.StatusBarFragment;
|
||||
import org.linphone.history.HistoryActivity;
|
||||
import org.linphone.menu.SideMenuFragment;
|
||||
import org.linphone.service.LinphoneService;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.settings.SettingsActivity;
|
||||
import org.linphone.utils.DeviceUtils;
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.Locale;
|
|||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.DialerActivity;
|
||||
import org.linphone.activities.LinphoneGenericActivity;
|
||||
import org.linphone.core.AccountCreator;
|
||||
import org.linphone.core.Core;
|
||||
|
@ -38,6 +37,7 @@ import org.linphone.core.DialPlan;
|
|||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.dialer.DialerActivity;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
|
||||
public abstract class AssistantActivity extends LinphoneGenericActivity
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.utils;
|
||||
package org.linphone.call;
|
||||
|
||||
import static android.media.AudioManager.MODE_RINGTONE;
|
||||
import static android.media.AudioManager.STREAM_RING;
|
|
@ -49,9 +49,7 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import java.lang.ref.WeakReference;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.DialerActivity;
|
||||
import org.linphone.activities.LinphoneGenericActivity;
|
||||
import org.linphone.chat.ChatActivity;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
|
@ -67,8 +65,9 @@ import org.linphone.core.Core;
|
|||
import org.linphone.core.CoreListener;
|
||||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.dialer.DialerActivity;
|
||||
import org.linphone.service.LinphoneService;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.AndroidAudioManager;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
||||
public class CallActivity extends LinphoneGenericActivity
|
||||
|
|
|
@ -35,11 +35,11 @@ import org.linphone.core.Core;
|
|||
import org.linphone.core.MediaEncryption;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.dialer.views.AddressType;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.FileUtils;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.views.AddressType;
|
||||
|
||||
/** Handle call updating, reinvites. */
|
||||
public class CallManager {
|
||||
|
|
|
@ -30,9 +30,9 @@ import org.linphone.core.Call;
|
|||
import org.linphone.core.CallLog;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.dialer.views.AddressAware;
|
||||
import org.linphone.dialer.views.AddressText;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.views.AddressAware;
|
||||
import org.linphone.views.AddressText;
|
||||
|
||||
@SuppressLint("AppCompatCustomView")
|
||||
public class CallButton extends ImageView implements OnClickListener, AddressAware {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.call.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.call.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.call.views;
|
||||
|
||||
import android.view.WindowManager;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.call.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
|
@ -43,6 +43,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.call.views.LinphoneLinearLayoutManager;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
|
@ -62,7 +63,6 @@ import org.linphone.core.ProxyConfig;
|
|||
import org.linphone.core.SearchResult;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||
|
||||
public class ChatRoomCreationFragment extends Fragment
|
||||
implements View.OnClickListener,
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.List;
|
|||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.MainActivity;
|
||||
import org.linphone.call.views.LinphoneLinearLayoutManager;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.core.ChatMessage;
|
||||
|
@ -44,7 +45,6 @@ import org.linphone.core.Core;
|
|||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.utils.SelectableHelper;
|
||||
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||
|
||||
public class ChatRoomsFragment extends Fragment
|
||||
implements ContactsUpdatedListener,
|
||||
|
|
|
@ -42,6 +42,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.call.views.LinphoneLinearLayoutManager;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
|
@ -56,7 +57,6 @@ import org.linphone.core.Factory;
|
|||
import org.linphone.core.Participant;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||
|
||||
public class GroupInfoFragment extends Fragment {
|
||||
private ImageView mConfirmButton;
|
||||
|
|
|
@ -39,8 +39,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.call.views.LinphoneLinearLayoutManager;
|
||||
import org.linphone.utils.SelectableHelper;
|
||||
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||
|
||||
public class ContactsFragment extends Fragment
|
||||
implements OnItemClickListener,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.activities;
|
||||
package org.linphone.dialer;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
|
@ -37,6 +37,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.MainActivity;
|
||||
import org.linphone.call.views.CallButton;
|
||||
import org.linphone.contacts.ContactsActivity;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
|
@ -44,10 +45,10 @@ import org.linphone.core.Call;
|
|||
import org.linphone.core.Core;
|
||||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.dialer.views.AddressText;
|
||||
import org.linphone.dialer.views.Digit;
|
||||
import org.linphone.dialer.views.EraseButton;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.views.AddressText;
|
||||
import org.linphone.views.Digit;
|
||||
import org.linphone.views.EraseButton;
|
||||
|
||||
public class DialerActivity extends MainActivity implements AddressText.AddressChangedListener {
|
||||
private static final String ACTION_CALL_LINPHONE = "org.linphone.intent.action.CallLaunched";
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.dialer.views;
|
||||
|
||||
public interface AddressAware {
|
||||
void setAddressWidget(AddressText address);
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.dialer.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.dialer.views;
|
||||
|
||||
public interface AddressType {
|
||||
CharSequence getText();
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.dialer.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
package org.linphone.dialer.views;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
|
@ -38,6 +38,7 @@ import java.util.List;
|
|||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.call.views.LinphoneLinearLayoutManager;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.core.Address;
|
||||
|
@ -45,7 +46,6 @@ import org.linphone.core.Call;
|
|||
import org.linphone.core.CallLog;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.utils.SelectableHelper;
|
||||
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||
|
||||
public class HistoryFragment extends Fragment
|
||||
implements OnClickListener,
|
||||
|
|
|
@ -33,9 +33,7 @@ import android.service.notification.StatusBarNotification;
|
|||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.DialerActivity;
|
||||
import org.linphone.call.CallActivity;
|
||||
import org.linphone.call.CallIncomingActivity;
|
||||
import org.linphone.call.CallOutgoingActivity;
|
||||
|
@ -54,7 +52,9 @@ import org.linphone.core.Core;
|
|||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.core.Reason;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.dialer.DialerActivity;
|
||||
import org.linphone.history.HistoryActivity;
|
||||
import org.linphone.service.LinphoneService;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.DeviceUtils;
|
||||
import org.linphone.utils.FileUtils;
|
||||
|
|
|
@ -22,8 +22,8 @@ package org.linphone.receivers;
|
|||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.compatibility.Compatibility;
|
||||
import org.linphone.service.LinphoneService;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
|
|
@ -37,9 +37,9 @@ import java.util.List;
|
|||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.MainActivity;
|
||||
import org.linphone.call.views.LinphoneLinearLayoutManager;
|
||||
import org.linphone.utils.FileUtils;
|
||||
import org.linphone.utils.SelectableHelper;
|
||||
import org.linphone.views.LinphoneLinearLayoutManager;
|
||||
|
||||
public class RecordingsActivity extends MainActivity
|
||||
implements SelectableHelper.DeleteListener, RecordingViewHolder.ClickListener {
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.utils;
|
||||
package org.linphone.service;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
import java.util.ArrayList;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
||||
/**
|
||||
* Believe me or not, but knowing the application visibility state on Android is a nightmare. After
|
|
@ -17,22 +17,24 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone;
|
||||
package org.linphone.service;
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.view.WindowManager;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.call.views.LinphoneGL2JNIViewOverlay;
|
||||
import org.linphone.call.views.LinphoneOverlay;
|
||||
import org.linphone.call.views.LinphoneTextureViewOverlay;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
import org.linphone.settings.LinphonePreferences;
|
||||
import org.linphone.utils.ActivityMonitor;
|
||||
import org.linphone.views.LinphoneGL2JNIViewOverlay;
|
||||
import org.linphone.views.LinphoneOverlay;
|
||||
import org.linphone.views.LinphoneTextureViewOverlay;
|
||||
|
||||
public final class LinphoneService extends Service {
|
||||
private static LinphoneService sInstance;
|
|
@ -17,9 +17,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.utils;
|
||||
package org.linphone.service;
|
||||
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
||||
public class ServiceWaitThread extends Thread {
|
||||
private ServiceWaitThreadListener mListener;
|
|
@ -17,7 +17,7 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.utils;
|
||||
package org.linphone.service;
|
||||
|
||||
public interface ServiceWaitThreadListener {
|
||||
void onServiceReady();
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2019 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
class AsyncBitmap extends BitmapDrawable {
|
||||
private final WeakReference<BitmapWorkerTask> mBitmapWorkerTaskReference;
|
||||
|
||||
public AsyncBitmap(Resources res, Bitmap bitmap, BitmapWorkerTask bitmapWorkerTask) {
|
||||
super(res, bitmap);
|
||||
mBitmapWorkerTaskReference = new WeakReference<>(bitmapWorkerTask);
|
||||
}
|
||||
|
||||
public BitmapWorkerTask getBitmapWorkerTask() {
|
||||
return mBitmapWorkerTaskReference.get();
|
||||
}
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2019 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-android
|
||||
* (see https://www.linphone.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.linphone.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import org.linphone.LinphoneContext;
|
||||
import org.linphone.core.tools.Log;
|
||||
import org.linphone.utils.FileUtils;
|
||||
import org.linphone.utils.ImageUtils;
|
||||
|
||||
public class BitmapWorkerTask extends AsyncTask<String, Void, Bitmap> {
|
||||
private String path;
|
||||
|
||||
private final WeakReference<ImageView> mImageViewReference;
|
||||
private final Bitmap mDefaultBitmap;
|
||||
private final int mImageViewHeight;
|
||||
|
||||
public BitmapWorkerTask(ImageView imageView, Bitmap defaultBitmap) {
|
||||
mDefaultBitmap = defaultBitmap;
|
||||
path = null;
|
||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||
mImageViewReference = new WeakReference<>(imageView);
|
||||
mImageViewHeight = imageView.getMeasuredHeight();
|
||||
}
|
||||
|
||||
private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) {
|
||||
if (imageView != null) {
|
||||
final Drawable drawable = imageView.getDrawable();
|
||||
if (drawable instanceof AsyncBitmap) {
|
||||
final AsyncBitmap asyncDrawable = (AsyncBitmap) drawable;
|
||||
return asyncDrawable.getBitmapWorkerTask();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Bitmap scaleToFitHeight(Bitmap b, int height) {
|
||||
float factor = height / (float) b.getHeight();
|
||||
int dstWidth = (int) (b.getWidth() * factor);
|
||||
if (dstWidth > 0 && height > 0) {
|
||||
return Bitmap.createScaledBitmap(b, dstWidth, height, true);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
// Decode image in background.
|
||||
@Override
|
||||
protected Bitmap doInBackground(String... params) {
|
||||
Context context = LinphoneContext.instance().getApplicationContext();
|
||||
path = params[0];
|
||||
Bitmap bm = null;
|
||||
Bitmap thumbnail = null;
|
||||
if (FileUtils.isExtensionImage(path)) {
|
||||
if (path.startsWith("content")) {
|
||||
try {
|
||||
bm =
|
||||
MediaStore.Images.Media.getBitmap(
|
||||
context.getContentResolver(), Uri.parse(path));
|
||||
} catch (IOException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
} else {
|
||||
bm = BitmapFactory.decodeFile(path);
|
||||
}
|
||||
|
||||
ImageView imageView = mImageViewReference.get();
|
||||
|
||||
try {
|
||||
// Rotate the bitmap if possible/needed, using EXIF data
|
||||
Matrix matrix = new Matrix();
|
||||
ExifInterface exif = new ExifInterface(path);
|
||||
int width = bm.getWidth();
|
||||
int height = bm.getHeight();
|
||||
|
||||
int pictureOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
|
||||
if (pictureOrientation == 6 || pictureOrientation == 3 || pictureOrientation == 8) {
|
||||
if (imageView != null) {
|
||||
float factor = (float) mImageViewHeight / height;
|
||||
matrix.postScale(factor, factor);
|
||||
}
|
||||
if (pictureOrientation == 6) {
|
||||
matrix.preRotate(90);
|
||||
} else if (pictureOrientation == 3) {
|
||||
matrix.preRotate(180);
|
||||
} else {
|
||||
matrix.preRotate(270);
|
||||
}
|
||||
thumbnail = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);
|
||||
if (thumbnail != bm) {
|
||||
bm.recycle();
|
||||
bm = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
||||
if (thumbnail == null && bm != null) {
|
||||
if (imageView == null) return bm;
|
||||
thumbnail = scaleToFitHeight(bm, mImageViewHeight);
|
||||
if (thumbnail != bm) {
|
||||
bm.recycle();
|
||||
}
|
||||
}
|
||||
return thumbnail;
|
||||
} else {
|
||||
return mDefaultBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
// Once complete, see if ImageView is still around and set bitmap.
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
if (isCancelled()) {
|
||||
bitmap.recycle();
|
||||
bitmap = null;
|
||||
}
|
||||
if (mImageViewReference != null && bitmap != null) {
|
||||
Context context = LinphoneContext.instance().getApplicationContext();
|
||||
final ImageView imageView = mImageViewReference.get();
|
||||
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView);
|
||||
if (this == bitmapWorkerTask && imageView != null) {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
if (bitmap.getWidth() > ImageUtils.dpToPixels(context, 300)) {
|
||||
RelativeLayout.LayoutParams params =
|
||||
new RelativeLayout.LayoutParams(
|
||||
bitmap.getWidth(), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
int margin = (int) ImageUtils.dpToPixels(context, 5);
|
||||
params.setMargins(margin, margin, margin, margin);
|
||||
imageView.setLayoutParams(params);
|
||||
imageView.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
android:layout_marginBottom="10dp"
|
||||
android:background="?attr/lighToolbarBackgroundColor">
|
||||
|
||||
<org.linphone.views.EraseButton
|
||||
<org.linphone.dialer.views.EraseButton
|
||||
android:id="@+id/erase"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -23,7 +23,7 @@
|
|||
android:contentDescription="@string/content_description_backspace"
|
||||
android:src="@drawable/backspace" />
|
||||
|
||||
<org.linphone.views.AddressText
|
||||
<org.linphone.dialer.views.AddressText
|
||||
android:id="@+id/address"
|
||||
style="@style/numpad_composed_number_font"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
android:layout_marginBottom="10dp"
|
||||
android:background="?attr/lighToolbarBackgroundColor">
|
||||
|
||||
<org.linphone.views.EraseButton
|
||||
<org.linphone.dialer.views.EraseButton
|
||||
android:id="@+id/erase"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -54,7 +54,7 @@
|
|||
android:contentDescription="@string/content_description_backspace"
|
||||
android:src="@drawable/backspace" />
|
||||
|
||||
<org.linphone.views.AddressText
|
||||
<org.linphone.dialer.views.AddressText
|
||||
android:id="@+id/address"
|
||||
style="@style/numpad_composed_number_font"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
android:layout_marginBottom="10dp"
|
||||
android:background="?attr/lighToolbarBackgroundColor">
|
||||
|
||||
<org.linphone.views.EraseButton
|
||||
<org.linphone.dialer.views.EraseButton
|
||||
android:id="@+id/erase"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -54,7 +54,7 @@
|
|||
android:contentDescription="@string/content_description_backspace"
|
||||
android:src="@drawable/backspace" />
|
||||
|
||||
<org.linphone.views.AddressText
|
||||
<org.linphone.dialer.views.AddressText
|
||||
android:id="@+id/address"
|
||||
style="@style/numpad_composed_number_font"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
android:layout_alignParentTop="true"
|
||||
android:background="?attr/lighToolbarBackgroundColor">
|
||||
|
||||
<org.linphone.views.EraseButton
|
||||
<org.linphone.dialer.views.EraseButton
|
||||
android:id="@+id/erase"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -22,7 +22,7 @@
|
|||
android:contentDescription="@string/content_description_backspace"
|
||||
android:src="@drawable/backspace" />
|
||||
|
||||
<org.linphone.views.AddressText
|
||||
<org.linphone.dialer.views.AddressText
|
||||
android:id="@+id/address"
|
||||
style="@style/numpad_composed_number_font"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit1"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_one"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="1" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit2"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_two"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="2" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit3"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_three"
|
||||
|
@ -35,21 +35,21 @@
|
|||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit4"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_four"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="4" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit5"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_five"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="5" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit6"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_six"
|
||||
|
@ -62,21 +62,21 @@
|
|||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit7"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_seven"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="7" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit8"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_eight"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="8" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit9"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_nine"
|
||||
|
@ -89,21 +89,21 @@
|
|||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/DigitStar"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_star_digit"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="*" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/Digit00"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_zero"
|
||||
android:soundEffectsEnabled="true"
|
||||
android:text="0+" />
|
||||
|
||||
<org.linphone.views.Digit
|
||||
<org.linphone.dialer.views.Digit
|
||||
android:id="@+id/DigitHash"
|
||||
style="@style/DialerDigit"
|
||||
android:background="@drawable/numpad_sharp"
|
||||
|
|
Loading…
Reference in a new issue