Partnership masto.host
|
@ -175,6 +175,11 @@
|
|||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
/>
|
||||
<activity android:name=".activities.PartnerShipActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
/>
|
||||
<activity android:name=".activities.InstanceActivity"
|
||||
android:windowSoftInputMode="stateAlwaysHidden"
|
||||
android:configChanges="orientation|screenSize"
|
||||
|
|
|
@ -686,12 +686,8 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
startActivity(myIntent);
|
||||
finish();
|
||||
return true;
|
||||
case R.id.action_about:
|
||||
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_privacy:
|
||||
intent = new Intent(getApplicationContext(), PrivacyActivity.class);
|
||||
Intent intent = new Intent(getApplicationContext(), PrivacyActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
case R.id.action_about_instance:
|
||||
|
@ -1386,15 +1382,18 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
// Handle navigation view item clicks here.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.nav_remote_follow) {
|
||||
Intent remoteFollow = new Intent(getApplicationContext(), RemoteFollowActivity.class);
|
||||
startActivity(remoteFollow);
|
||||
return false;
|
||||
}
|
||||
if( id == R.id.nav_archive) {
|
||||
Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class);
|
||||
startActivity(myIntent);
|
||||
return false;
|
||||
} else if( id == R.id.nav_about) {
|
||||
Intent intent = new Intent(getApplicationContext(), AboutActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
} else if( id == R.id.nav_partnership) {
|
||||
Intent intent = new Intent(getApplicationContext(), PartnerShipActivity.class);
|
||||
startActivity(intent);
|
||||
return false;
|
||||
}
|
||||
final NavigationView navigationView = findViewById(R.id.nav_view);
|
||||
unCheckAllMenuItems(navigationView);
|
||||
|
@ -1420,7 +1419,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
}else{
|
||||
delete_all.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if( id != R.id.nav_search && id != R.id.nav_list){
|
||||
if( id != R.id.nav_list){
|
||||
add_new.setVisibility(View.GONE);
|
||||
}else{
|
||||
add_new.setVisibility(View.VISIBLE);
|
||||
|
@ -1432,7 +1431,7 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, tabLayoutSettingsFragment, fragmentTag).commit();
|
||||
|
||||
} else if (id == R.id.nav_favorites) {
|
||||
}else if (id == R.id.nav_favorites) {
|
||||
toot.setVisibility(View.GONE);
|
||||
statusFragment = new DisplayStatusFragment();
|
||||
bundle.putSerializable("type", RetrieveFeedsAsyncTask.Type.FAVOURITES);
|
||||
|
@ -1474,12 +1473,6 @@ public abstract class BaseMainActivity extends BaseActivity
|
|||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, displayBookmarksFragment, fragmentTag).commit();
|
||||
toot.setVisibility(View.GONE);
|
||||
}else if (id == R.id.nav_search) {
|
||||
DisplaySearchFragment displaySearchFragment = new DisplaySearchFragment();
|
||||
fragmentTag = "SEARCH";
|
||||
fragmentManager.beginTransaction()
|
||||
.replace(R.id.main_app_container, displaySearchFragment, fragmentTag).commit();
|
||||
toot.setVisibility(View.GONE);
|
||||
}else if( id == R.id.nav_follow_request){
|
||||
toot.setVisibility(View.GONE);
|
||||
DisplayFollowRequestSentFragment followRequestSentFragment = new DisplayFollowRequestSentFragment();
|
||||
|
|
|
@ -0,0 +1,173 @@
|
|||
/* Copyright 2018 Thomas Schneider
|
||||
*
|
||||
* This file is a part of Mastalab
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Mastalab 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 Mastalab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
package fr.gouv.etalab.mastodon.activities;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.gouv.etalab.mastodon.R;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRelationshipAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.asynctasks.RetrieveRemoteDataAsyncTask;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Account;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Error;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Relationship;
|
||||
import fr.gouv.etalab.mastodon.client.Entities.Results;
|
||||
import fr.gouv.etalab.mastodon.drawers.AccountSearchDevAdapter;
|
||||
import fr.gouv.etalab.mastodon.helper.ExpandableHeightListView;
|
||||
import fr.gouv.etalab.mastodon.helper.Helper;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRelationshipInterface;
|
||||
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveRemoteAccountInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Thomas on 31/08/2018.
|
||||
* About activity
|
||||
*/
|
||||
|
||||
public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface {
|
||||
|
||||
private List<Account> mastohostAcct = new ArrayList<>();
|
||||
|
||||
private AccountSearchDevAdapter mastohostAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
|
||||
switch (theme){
|
||||
case Helper.THEME_LIGHT:
|
||||
setTheme(R.style.AppTheme);
|
||||
break;
|
||||
case Helper.THEME_DARK:
|
||||
setTheme(R.style.AppThemeDark);
|
||||
break;
|
||||
case Helper.THEME_BLACK:
|
||||
setTheme(R.style.AppThemeBlack);
|
||||
break;
|
||||
default:
|
||||
setTheme(R.style.AppThemeDark);
|
||||
}
|
||||
|
||||
if( getSupportActionBar() != null)
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.activity_partnership);
|
||||
|
||||
|
||||
|
||||
TextView about_partnership = findViewById(R.id.about_partnership);
|
||||
about_partnership.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
ExpandableHeightListView lv_mastohost = findViewById(R.id.lv_mastohost);
|
||||
|
||||
ImageView mastohost = findViewById(R.id.mastohost_logo);
|
||||
|
||||
mastohost.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://masto.host"));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
TextView about_mastohost = findViewById(R.id.about_mastohost);
|
||||
about_mastohost.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
setTitle(R.string.action_partnership);
|
||||
lv_mastohost.setExpanded(true);
|
||||
|
||||
|
||||
mastohostAdapter = new AccountSearchDevAdapter(PartnerShipActivity.this, mastohostAcct);
|
||||
lv_mastohost.setAdapter(mastohostAdapter);
|
||||
|
||||
|
||||
new RetrieveRemoteDataAsyncTask(getApplicationContext(), "mastohost", "mastodon.social", PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRetrieveRemoteAccount(Results results) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
if( results == null){
|
||||
boolean show_error_messages = sharedpreferences.getBoolean(Helper.SET_SHOW_ERROR_MESSAGES, true);
|
||||
if( show_error_messages)
|
||||
Toast.makeText(getApplicationContext(), R.string.toast_error,Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
List<Account> accounts = results.getAccounts();
|
||||
Account account;
|
||||
if( accounts != null && accounts.size() > 0){
|
||||
account = accounts.get(0);
|
||||
account.setFollowing(true);
|
||||
switch (account.getUsername()) {
|
||||
case "mastohost":
|
||||
mastohostAcct.add(account);
|
||||
mastohostAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume(){
|
||||
super.onResume();
|
||||
if( mastohostAcct != null){
|
||||
for(Account account: mastohostAcct){
|
||||
new RetrieveRelationshipAsyncTask(getApplicationContext(), account.getId(),PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetrieveRelationship(Relationship relationship, Error error) {
|
||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
|
||||
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, "");
|
||||
if( error != null){
|
||||
return;
|
||||
}
|
||||
for( int i = 0 ; i < mastohostAcct.size() ; i++){
|
||||
if( mastohostAcct.get(i).getId() != null && mastohostAcct.get(i).getId().equals(relationship.getId())){
|
||||
mastohostAcct.get(i).setFollowing(relationship.isFollowing() || userId.trim().equals(relationship.getId()));
|
||||
mastohostAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 307 B |
After Width: | Height: | Size: 251 B |
After Width: | Height: | Size: 258 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 222 B |
After Width: | Height: | Size: 359 B |
After Width: | Height: | Size: 355 B |
After Width: | Height: | Size: 528 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 640 B |
After Width: | Height: | Size: 649 B |
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2018 Thomas Schneider
|
||||
|
||||
This file is a part of Mastalab
|
||||
|
||||
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.
|
||||
|
||||
Mastalab 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 Mastalab; if not,
|
||||
see <http://www.gnu.org/licenses>.
|
||||
-->
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="@dimen/fab_margin"
|
||||
android:layout_marginEnd="@dimen/fab_margin"
|
||||
android:layout_marginLeft="@dimen/fab_margin"
|
||||
android:layout_marginStart="@dimen/fab_margin"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<!-- About masto.host -->
|
||||
<ImageView
|
||||
android:id="@+id/mastohost_logo"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/mastohost"
|
||||
/>
|
||||
|
||||
|
||||
<!-- About partnership -->
|
||||
<TextView
|
||||
android:layout_marginTop="10dp"
|
||||
android:textSize="14sp"
|
||||
android:id="@+id/about_partnership"
|
||||
android:text="@string/about_partnership"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
|
||||
<fr.gouv.etalab.mastodon.helper.ExpandableHeightListView
|
||||
android:layout_marginTop="20dp"
|
||||
android:id="@+id/lv_mastohost"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none"
|
||||
android:divider="@null"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/about_mastohost"
|
||||
android:padding="5dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_mastohost"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
|
@ -31,14 +31,6 @@
|
|||
android:id="@+id/nav_bookmarks"
|
||||
android:icon="@drawable/ic_bookmark"
|
||||
android:title="@string/bookmarks" />
|
||||
<item
|
||||
android:id="@+id/nav_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/search" />
|
||||
<item
|
||||
android:id="@+id/nav_remote_follow"
|
||||
android:icon="@drawable/ic_person_add"
|
||||
android:title="@string/remote_follow_menu" />
|
||||
<item
|
||||
android:id="@+id/nav_follow_request"
|
||||
android:icon="@drawable/ic_group_add"
|
||||
|
@ -70,5 +62,21 @@
|
|||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:title="@string/neutral_menu_information"
|
||||
android:id="@+id/nav_main_info">
|
||||
<menu>
|
||||
<group android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/nav_about"
|
||||
android:icon="@drawable/ic_info"
|
||||
android:title="@string/action_about" />
|
||||
<item
|
||||
android:id="@+id/nav_partnership"
|
||||
android:icon="@drawable/ic_add_circle"
|
||||
android:title="@string/action_partnership" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
</group>
|
||||
</menu>
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_about"
|
||||
android:title="@string/action_about"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_privacy"
|
||||
android:title="@string/action_privacy"
|
||||
|
|
|
@ -551,6 +551,14 @@
|
|||
<string name="crash_title">Mastalab has stopped :(</string>
|
||||
<string name="crash_message">You can send me by email the crash report. It will help to fix it :)\n\nYou can add additional content. Thank you!</string>
|
||||
<string name="send_crash_report">Ask for sending crash reports by email?</string>
|
||||
<string name="mastohost_name" translatable="false">masto.host</string>
|
||||
<string name="about_partnership" translatable="false">
|
||||
Mastalab has a partnership with Masto.host\nMasto.host offers hosting for <a href="https://ins.mastalab.app">Mastalab\'s instance</a> for free.\nThis helps me to better understand how to manage an instance. If one day the API is open to moderators,
|
||||
I would be glad to be able to test new features.
|
||||
</string>
|
||||
<string name="about_mastohost" translatable="false"><a href="https://masto.host">Masto.host</a> is a fully managed Mastodon hosting service, meaning that you can create your own instance without having to touch a single line of code or maintain your own server.</string>
|
||||
<string name="action_partnership" >Partnerships</string>
|
||||
<string name="neutral_menu_information">Information</string>
|
||||
<string-array translatable="false" name="proxy_type_choice">
|
||||
<item>HTTP</item>
|
||||
<item>SOCKS</item>
|
||||
|
|