Extends classes

This commit is contained in:
stom79 2017-12-12 18:17:01 +01:00
parent 560617750a
commit 3a93e35551
24 changed files with 59 additions and 37 deletions

View File

@ -7,8 +7,8 @@ android {
applicationId "fr.gouv.etalab.mastodon"
minSdkVersion 15
targetSdkVersion 27
versionCode 87
versionName "1.6.6"
versionCode 88
versionName "1.6.7-beta-1"
}
flavorDimensions "default"
buildTypes {
@ -43,5 +43,5 @@ dependencies {
implementation 'com.github.stom79:country-picker-android:1.2.0'
implementation 'com.github.stom79:mytransl:1.2'
playstoreImplementation 'io.github.kobakei:ratethisapp:1.2.0'
implementation files('libs/conscrypt-openjdk-1.0.0.RC14.jar')
compile 'org.conscrypt:conscrypt-android:1.0.0.RC14'
}

View File

@ -51,7 +51,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
* About activity
*/
public class AboutActivity extends AppCompatActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface {
public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface {
private List<Account> developers = new ArrayList<>();
private List<Account> contributors = new ArrayList<>();

View File

@ -0,0 +1,15 @@
package fr.gouv.etalab.mastodon.activities;
import android.support.v7.app.AppCompatActivity;
import org.conscrypt.Conscrypt;
import java.security.Security;
/**
* Created by Thomas on 12/12/2017.
*/
public class BaseActivity extends AppCompatActivity {
static { Security.insertProviderAt(Conscrypt.newProvider("GmsCore_OpenSSL"), 1); }
}

View File

@ -113,7 +113,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.updateHeaderAccountInfo;
import android.support.v4.app.FragmentStatePagerAdapter;
public abstract class BaseMainActivity extends AppCompatActivity
public abstract class BaseMainActivity extends BaseActivity
implements NavigationView.OnNavigationItemSelectedListener, OnUpdateAccountInfoInterface, OnRetrieveMetaDataInterface, OnRetrieveInstanceInterface {
private FloatingActionButton toot, delete_all, add_new;

View File

@ -79,7 +79,7 @@ import fr.gouv.etalab.mastodon.sqlite.Sqlite;
* Edit profile activity
*/
public class EditProfileActivity extends AppCompatActivity implements OnRetrieveAccountInterface, OnUpdateCredentialInterface {
public class EditProfileActivity extends BaseActivity implements OnRetrieveAccountInterface, OnUpdateCredentialInterface {

View File

@ -48,7 +48,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
* Show hashtag stream
*/
public class HashTagActivity extends AppCompatActivity implements OnRetrieveFeedsInterface {
public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInterface {
public static int position;

View File

@ -47,7 +47,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
* Instance activity
*/
public class InstanceActivity extends AppCompatActivity implements OnRetrieveInstanceInterface {
public class InstanceActivity extends BaseActivity implements OnRetrieveInstanceInterface {
private LinearLayout instance_container;
private RelativeLayout loader;

View File

@ -65,7 +65,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.withSuffix;
* Instance health activity class
*/
public class InstanceHealthActivity extends AppCompatActivity {
public class InstanceHealthActivity extends BaseActivity {
private InstanceSocial instanceSocial;
private TextView name, values, checked_at, up, uptime;

View File

@ -34,6 +34,7 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.conscrypt.Conscrypt;
import org.conscrypt.OpenSSLProvider;
import org.json.JSONArray;
import org.json.JSONException;
@ -58,7 +59,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
* Login activity class which handles the connection
*/
public class LoginActivity extends AppCompatActivity {
public class LoginActivity extends BaseActivity {
private String client_id;
private String client_secret;
@ -70,11 +71,12 @@ public class LoginActivity extends AppCompatActivity {
private EditText login_passwd;
boolean isLoadingInstance = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Security.insertProviderAt(new OpenSSLProvider(), 1);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
@ -238,7 +240,7 @@ public class LoginActivity extends AppCompatActivity {
}
});
} catch (Exception ignored) {}
} catch (Exception ignored) {ignored.printStackTrace();}
}
}).start();

View File

@ -71,7 +71,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
* Media Activity
*/
public class MediaActivity extends AppCompatActivity implements OnDownloadInterface {
public class MediaActivity extends BaseActivity implements OnDownloadInterface {
private RelativeLayout loader;

View File

@ -30,7 +30,7 @@ import fr.gouv.etalab.mastodon.helper.Helper;
* Privacy activity
*/
public class PrivacyActivity extends AppCompatActivity {
public class PrivacyActivity extends BaseActivity {
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {

View File

@ -83,7 +83,7 @@ import fr.gouv.etalab.mastodon.sqlite.Sqlite;
* Remote follow activity class
*/
public class RemoteFollowActivity extends AppCompatActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface, OnPostActionInterface {
public class RemoteFollowActivity extends BaseActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface, OnPostActionInterface {
private ImageView pp_actionBar;

View File

@ -46,7 +46,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchStatusInterface;
* Show search results within two tabs: Toots and accounts
*/
public class SearchResultActivity extends AppCompatActivity implements OnRetrieveSearchInterface, OnRetrieveSearchStatusInterface {
public class SearchResultActivity extends BaseActivity implements OnRetrieveSearchInterface, OnRetrieveSearchStatusInterface {
private String search;

View File

@ -100,7 +100,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.withSuffix;
* Show account activity class
*/
public class ShowAccountActivity extends AppCompatActivity implements OnPostActionInterface, OnRetrieveAccountInterface, OnRetrieveFeedsAccountInterface, OnRetrieveRelationshipInterface, OnRetrieveFeedsInterface {
public class ShowAccountActivity extends BaseActivity implements OnPostActionInterface, OnRetrieveAccountInterface, OnRetrieveFeedsAccountInterface, OnRetrieveRelationshipInterface, OnRetrieveFeedsInterface {
private List<Status> statuses;

View File

@ -68,7 +68,7 @@ import fr.gouv.etalab.mastodon.sqlite.Sqlite;
* Show conversation activity class
*/
public class ShowConversationActivity extends AppCompatActivity implements OnRetrieveFeedsInterface, OnRetrieveContextInterface {
public class ShowConversationActivity extends BaseActivity implements OnRetrieveFeedsInterface, OnRetrieveContextInterface {
private String statusId;

View File

@ -152,7 +152,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
* Toot activity class
*/
public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface, OnRetrieveEmojiInterface, OnDownloadInterface {
public class TootActivity extends BaseActivity implements OnRetrieveSearcAccountshInterface, OnRetrieveAttachmentInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface, OnRetrieveEmojiInterface, OnDownloadInterface {
private String visibility;

View File

@ -48,7 +48,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.manageDownloads;
* Webview activity
*/
public class WebviewActivity extends AppCompatActivity {
public class WebviewActivity extends BaseActivity {
private String url;
private WebView webView;

View File

@ -48,7 +48,7 @@ import fr.gouv.etalab.mastodon.R;
* Created by Thomas on 24/04/2017.
* Webview to connect accounts
*/
public class WebviewConnectActivity extends AppCompatActivity {
public class WebviewConnectActivity extends BaseActivity {
private WebView webView;

View File

@ -100,8 +100,7 @@ public class HttpsConnection {
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
if( token != null)
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
httpsURLConnection.setRequestMethod("GET");
@ -136,8 +135,7 @@ public class HttpsConnection {
httpsURLConnection.setConnectTimeout(30 * 1000);
httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36");
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setRequestMethod("GET");
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
Reader in = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream(), "UTF-8"));
@ -203,8 +201,7 @@ public class HttpsConnection {
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setDoOutput(true);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setRequestMethod("POST");
if( token != null)
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
@ -358,8 +355,7 @@ public class HttpsConnection {
httpsURLConnection.setFixedLengthStreamingMode(lengthSent);
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setDoInput(true);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setUseCaches(false);
@ -484,8 +480,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
if( token != null)
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
httpsURLConnection.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
@ -532,8 +527,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setRequestMethod("PATCH");
if( token != null)
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
@ -578,8 +572,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP)
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
if( token != null)
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
httpsURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

View File

@ -87,7 +87,7 @@ public class TLSSocketFactory extends SSLSocketFactory {
private Socket enableTLSOnSocket(Socket socket) {
if(socket != null && (socket instanceof SSLSocket)) {
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2",});
}
return socket;
}

View File

@ -35,6 +35,9 @@ import com.evernote.android.job.Job;
import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest;
import org.conscrypt.Conscrypt;
import java.security.Security;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@ -74,7 +77,7 @@ public class HomeTimelineSyncJob extends Job implements OnRetrieveHomeTimelineSe
return Result.SUCCESS;
}
static { Security.insertProviderAt(Conscrypt.newProvider("GmsCore_OpenSSL"), 1); }
public static int schedule(boolean updateCurrent){
Set<JobRequest> jobRequests = JobManager.instance().getAllJobRequestsForTag(HOME_TIMELINE);

View File

@ -35,6 +35,9 @@ import com.evernote.android.job.Job;
import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest;
import org.conscrypt.Conscrypt;
import java.security.Security;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -65,6 +68,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.notify_user;
public class NotificationsSyncJob extends Job implements OnRetrieveNotificationsInterface{
static final String NOTIFICATION_REFRESH = "job_notification";
static { Security.insertProviderAt(Conscrypt.newProvider("GmsCore_OpenSSL"), 1); }
@NonNull
@Override

View File

@ -20,6 +20,10 @@ import android.support.annotation.NonNull;
import com.evernote.android.job.Job;
import com.evernote.android.job.JobRequest;
import org.conscrypt.Conscrypt;
import java.security.Security;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -40,6 +44,7 @@ import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
public class ScheduledTootsSyncJob extends Job {
public static final String SCHEDULED_TOOT = "job_scheduled_toot";
static { Security.insertProviderAt(Conscrypt.newProvider("GmsCore_OpenSSL"), 1); }
@NonNull
@Override