Commit 51797317 authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin

tablet: use standard layout, cleanup

Change-Id: Ie189731923b185d1c6571cc901f5ed4335b2c416
parent d46a267e
......@@ -19,52 +19,52 @@
*/
package cx.ring.dependencyinjection;
import net.jami.facades.ConversationFacade;
import net.jami.services.AccountService;
import net.jami.services.CallService;
import net.jami.services.DaemonService;
import net.jami.services.HardwareService;
import javax.inject.Singleton;
import cx.ring.account.AccountEditionFragment;
import cx.ring.account.JamiAccountPasswordFragment;
import cx.ring.account.JamiAccountUsernameFragment;
import cx.ring.account.JamiLinkAccountPasswordFragment;
import cx.ring.contactrequests.BlockListFragment;
import cx.ring.fragments.GeneralAccountFragment;
import cx.ring.fragments.LinkDeviceFragment;
import cx.ring.fragments.ContactPickerFragment;
import cx.ring.fragments.LocationSharingFragment;
import cx.ring.account.AccountWizardActivity;
import cx.ring.account.HomeAccountCreationFragment;
import cx.ring.account.JamiAccountConnectFragment;
import cx.ring.account.JamiAccountPasswordFragment;
import cx.ring.account.JamiAccountSummaryFragment;
import cx.ring.account.JamiAccountUsernameFragment;
import cx.ring.account.JamiLinkAccountPasswordFragment;
import cx.ring.account.ProfileCreationFragment;
import cx.ring.account.RegisterNameDialog;
import cx.ring.account.JamiAccountSummaryFragment;
import cx.ring.application.JamiApplication;
import cx.ring.client.ContactDetailsActivity;
import cx.ring.client.ConversationSelectionActivity;
import cx.ring.client.HomeActivity;
import cx.ring.client.RingtoneActivity;
import cx.ring.contactrequests.BlockListFragment;
import cx.ring.contactrequests.ContactRequestsFragment;
import net.jami.facades.ConversationFacade;
import cx.ring.fragments.AccountMigrationFragment;
import cx.ring.fragments.AdvancedAccountFragment;
import cx.ring.fragments.CallFragment;
import cx.ring.fragments.ContactPickerFragment;
import cx.ring.fragments.ConversationFragment;
import cx.ring.client.ConversationSelectionActivity;
import cx.ring.fragments.GeneralAccountFragment;
import cx.ring.fragments.LinkDeviceFragment;
import cx.ring.fragments.LocationSharingFragment;
import cx.ring.fragments.MediaPreferenceFragment;
import cx.ring.fragments.SIPAccountCreationFragment;
import cx.ring.fragments.SecurityAccountFragment;
import cx.ring.fragments.ShareWithFragment;
import cx.ring.fragments.SmartListFragment;
import cx.ring.history.DatabaseHelper;
import cx.ring.launch.LaunchActivity;
import cx.ring.service.BootReceiver;
import cx.ring.service.CallNotificationService;
import cx.ring.service.DRingService;
import cx.ring.service.JamiJobService;
import net.jami.services.AccountService;
import net.jami.services.CallService;
import cx.ring.services.ContactServiceImpl;
import net.jami.services.DaemonService;
import cx.ring.services.DataTransferService;
import cx.ring.services.DeviceRuntimeServiceImpl;
import net.jami.services.HardwareService;
import cx.ring.services.HistoryServiceImpl;
import cx.ring.services.LocationSharingService;
import cx.ring.services.NotificationServiceImpl;
......@@ -76,17 +76,17 @@ import cx.ring.share.ShareFragment;
import cx.ring.tv.account.TVAccountExport;
import cx.ring.tv.account.TVAccountWizard;
import cx.ring.tv.account.TVHomeAccountCreationFragment;
import cx.ring.tv.account.TVProfileCreationFragment;
import cx.ring.tv.account.TVProfileEditingFragment;
import cx.ring.tv.account.TVJamiAccountCreationFragment;
import cx.ring.tv.account.TVJamiLinkAccountFragment;
import cx.ring.tv.account.TVProfileCreationFragment;
import cx.ring.tv.account.TVProfileEditingFragment;
import cx.ring.tv.account.TVSettingsFragment;
import cx.ring.tv.account.TVShareFragment;
import cx.ring.tv.call.TVCallActivity;
import cx.ring.tv.call.TVCallFragment;
import cx.ring.tv.cards.iconcards.IconCardPresenter;
import cx.ring.tv.conversation.TvConversationFragment;
import cx.ring.tv.contact.TVContactFragment;
import cx.ring.tv.conversation.TvConversationFragment;
import cx.ring.tv.main.MainFragment;
import cx.ring.tv.search.ContactSearchFragment;
import dagger.Component;
......@@ -180,8 +180,6 @@ public interface JamiInjectionComponent {
void inject(JamiAccountConnectFragment fragment);
void inject(LaunchActivity activity);
// AndroidTV section
void inject(TVCallFragment fragment);
......
/*
* Copyright (C) 2004-2021 Savoir-faire Linux Inc.
*
* Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.launch;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import cx.ring.R;
import cx.ring.account.AccountWizardActivity;
import cx.ring.application.JamiApplication;
import cx.ring.client.HomeActivity;
import cx.ring.mvp.BaseActivity;
import cx.ring.tv.account.TVAccountWizard;
import cx.ring.utils.DeviceUtils;
public class LaunchActivity extends BaseActivity<LaunchPresenter> implements LaunchView {
@Override
public void onCreate(Bundle savedInstanceState) {
// dependency injection
JamiApplication.getInstance().getInjectionComponent().inject(this);
super.onCreate(savedInstanceState);
JamiApplication.getInstance().startDaemon();
setContentView(R.layout.activity_launch);
presenter.init();
}
@Override
public void askPermissions(String[] permissionsWeCanAsk) {
ActivityCompat.requestPermissions(this, permissionsWeCanAsk, JamiApplication.PERMISSIONS_REQUEST);
}
@Override
public void goToHome() {
startActivity(new Intent(LaunchActivity.this, DeviceUtils.isTv(this) ? cx.ring.tv.main.HomeActivity.class : HomeActivity.class));
finish();
}
@Override
public void goToAccountCreation() {
startActivity(new Intent(LaunchActivity.this, DeviceUtils.isTv(this) ? TVAccountWizard.class : AccountWizardActivity.class));
finish();
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case JamiApplication.PERMISSIONS_REQUEST: {
if (grantResults.length == 0) {
return;
}
for (int i = 0, n = permissions.length; i < n; i++) {
String permission = permissions[i];
JamiApplication.getInstance().permissionHasBeenAsked(permission);
switch (permission) {
case Manifest.permission.READ_CONTACTS:
presenter.contactPermissionChanged(grantResults[i] == PackageManager.PERMISSION_GRANTED);
break;
}
}
break;
}
}
}
}
\ No newline at end of file
/*
* Copyright (C) 2004-2021 Savoir-faire Linux Inc.
*
* Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>s
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.launch;
import android.Manifest;
import java.util.ArrayList;
import javax.inject.Inject;
import net.jami.model.Settings;
import net.jami.mvp.RootPresenter;
import net.jami.services.AccountService;
import net.jami.services.DeviceRuntimeService;
import net.jami.services.HardwareService;
import net.jami.services.PreferencesService;
import io.reactivex.android.schedulers.AndroidSchedulers;
public class LaunchPresenter extends RootPresenter<LaunchView> {
protected static final String TAG = LaunchPresenter.class.getSimpleName();
protected AccountService mAccountService;
protected DeviceRuntimeService mDeviceRuntimeService;
protected PreferencesService mPreferencesService;
protected HardwareService mHardwareService;
@Inject
public LaunchPresenter(AccountService accountService, DeviceRuntimeService deviceRuntimeService,
PreferencesService preferencesService, HardwareService hardwareService) {
this.mAccountService = accountService;
this.mDeviceRuntimeService = deviceRuntimeService;
this.mPreferencesService = preferencesService;
this.mHardwareService = hardwareService;
}
public void init() {
String[] toRequest = buildPermissionsToAsk();
if (toRequest.length == 0) {
checkAccounts();
} else {
getView().askPermissions(toRequest);
}
}
public void contactPermissionChanged(boolean isGranted) {
}
public void checkAccounts() {
mCompositeDisposable.add(mAccountService.getObservableAccountList()
.observeOn(AndroidSchedulers.mainThread())
.subscribe(accounts -> {
if (accounts.isEmpty()) {
getView().goToAccountCreation();
} else {
getView().goToHome();
}
mCompositeDisposable.clear();
}));
}
private String[] buildPermissionsToAsk() {
ArrayList<String> perms = new ArrayList<>();
Settings settings = mPreferencesService.getSettings();
if (settings.isAllowSystemContacts() && !mDeviceRuntimeService.hasContactPermission()) {
perms.add(Manifest.permission.READ_CONTACTS);
}
if (settings.isAllowPlaceSystemCalls() && !mDeviceRuntimeService.hasCallLogPermission()) {
perms.add(Manifest.permission.WRITE_CALL_LOG);
}
return perms.toArray(new String[perms.size()]);
}
}
\ No newline at end of file
/*
* Copyright (C) 2004-2021 Savoir-faire Linux Inc.
*
* Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.launch;
public interface LaunchView {
void askPermissions(String[] permissionsWeCanAsk);
void goToHome();
void goToAccountCreation();
}
......@@ -24,34 +24,27 @@ import android.app.UiModeManager;
import android.content.Context;
import android.content.res.Configuration;
import androidx.annotation.NonNull;
import net.jami.utils.Log;
import cx.ring.R;
import static android.content.Context.UI_MODE_SERVICE;
public class DeviceUtils {
private static final String TAG = DeviceUtils.class.getSimpleName();
private static final int MIN_SIZE_TABLET = 720;
private DeviceUtils() {
}
public static boolean isTv(Context context) {
if (context == null) {
net.jami.utils.Log.e(TAG, "null context");
return false;
}
public static boolean isTv(@NonNull Context context) {
UiModeManager uiModeManager = (UiModeManager) context.getSystemService(UI_MODE_SERVICE);
return (uiModeManager != null && uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION);
}
public static boolean isTablet(Context context) {
if (context == null) {
Log.e(TAG, "null context");
return false;
}
return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
&& context.getResources().getConfiguration().screenWidthDp >= MIN_SIZE_TABLET;
public static boolean isTablet(@NonNull Context context) {
return context.getResources().getBoolean(R.bool.isTablet);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical"
android:padding="88dp">
<ImageView
android:id="@+id/logo_ring"
android:layout_width="128dp"
android:layout_height="128dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="16dp"
android:contentDescription="@string/app_name"
android:src="@drawable/ic_jami" />
<ProgressBar
android:id="@+id/loading_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/logo_ring"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="16dp" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2004-2016 Savoir-faire Linux Inc.
Author: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-->
<resources>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2004-2016 Savoir-faire Linux Inc.
Author: Alexandre Lision <alexandre.lision@gmail.com>
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-->
<!--
Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw600dp devices (e.g. 7" tablets) here.
-->
<resources>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="drawer_content_padding">320dp</dimen>
<bool name="isTablet">true</bool>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2004-2016 Savoir-faire Linux Inc.
Author: Adrien Beraud <adrien.beraud@savoirfairelinux.com>
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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-->
<resources>
</resources>
\ No newline at end of file
......@@ -10,4 +10,6 @@
<attr name="status" format="string"/>
</declare-styleable>
<bool name="isTablet">false</bool>
</resources>
\ No newline at end of file
......@@ -51,9 +51,6 @@ along with this program; if not, write to the Free Software
<dimen name="toolbar_content_inset">72dp</dimen>
<dimen name="toolbar_elevation">4dp</dimen>
<dimen name="drawer_content_padding">0dp</dimen>
<dimen name="drawer_size">320dp</dimen>
<dimen name="default_image_card_width">110dp</dimen>
<dimen name="default_image_card_height">100dp</dimen>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment