Change loader + add about page

This commit is contained in:
Thomas 2020-10-04 09:43:59 +02:00
parent 7ffd54ac7f
commit 4705cb68c5
10 changed files with 177 additions and 11 deletions

View File

@ -6,7 +6,7 @@ android {
defaultConfig {
applicationId "app.fedilab.mobilizon"
minSdkVersion 21
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
@ -49,6 +49,7 @@ dependencies {
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

View File

@ -5,13 +5,19 @@ import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -21,6 +27,7 @@ import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -49,7 +56,7 @@ import es.dmoral.toasty.Toasty;
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
public static int PICK_INSTANCE = 5641;
//public static int PICK_INSTANCE = 5641;
public static boolean isAuthenticated = false;
final private int REQUEST_CODE_ASK_MULTIPLE_PERMISSIONS = 124;
private final LocationListener mLocationListener = new LocationListener() {
@ -166,6 +173,58 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
if (id == R.id.action_instance) {
showRadioButtonDialogFullInstances();
return true;
} else if (id == R.id.action_about) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.popup_about, new LinearLayout(MainActivity.this), false);
TextView about = dialogView.findViewById(R.id.about);
TextView terms = dialogView.findViewById(R.id.terms);
TextView license = dialogView.findViewById(R.id.license);
TextView about_the_app = dialogView.findViewById(R.id.about_the_app);
SpannableString contentAbout = new SpannableString(about.getText().toString());
contentAbout.setSpan(new UnderlineSpan(), 0, contentAbout.length(), 0);
about.setText(contentAbout);
about.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://" + Helper.getLiveInstance(MainActivity.this) + "/about"));
startActivity(browserIntent);
});
SpannableString contentTerms = new SpannableString(terms.getText().toString());
contentTerms.setSpan(new UnderlineSpan(), 0, contentTerms.length(), 0);
terms.setText(contentTerms);
terms.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://" + Helper.getLiveInstance(MainActivity.this) + "/terms"));
startActivity(browserIntent);
});
SpannableString contentLicense = new SpannableString(license.getText().toString());
contentLicense.setSpan(new UnderlineSpan(), 0, contentTerms.length(), 0);
license.setText(contentLicense);
license.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://framagit.org/framasoft/mobilizon/blob/master/LICENSE"));
startActivity(browserIntent);
});
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
String version = pInfo.versionName;
about_the_app.setText(getResources().getString(R.string.about_the_app, version));
} catch (PackageManager.NameNotFoundException ignored) {
}
SpannableString contentAboutApp = new SpannableString(about_the_app.getText().toString());
contentAboutApp.setSpan(new UnderlineSpan(), 0, contentAboutApp.length(), 0);
about_the_app.setText(contentAboutApp);
about_the_app.setOnClickListener(v -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://framagit.org/tom79/mobilizon-android-app"));
startActivity(browserIntent);
});
builder.setView(dialogView);
builder
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss())
.setIcon(R.drawable.ic_baseline_info_24)
.show();
}
return super.onOptionsItemSelected(item);

View File

@ -19,7 +19,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.List;
@SuppressWarnings("unused")
@SuppressWarnings({"unused", "RedundantSuppression"})
public class WellKnownNodeinfo {
@SerializedName("links")

View File

@ -26,8 +26,6 @@ import android.widget.FrameLayout;
import androidx.appcompat.app.AppCompatActivity;
import app.fedilab.mobilizon.MainActivity;
/**
* Created by Thomas

View File

@ -87,7 +87,6 @@ public class MobilizonWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
view.setVisibility(View.INVISIBLE);
super.onPageStarted(view, url, favicon);
if (activity instanceof MainActivity) {
((MainActivity) activity).showProgressDialog();

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
</vector>

View File

@ -30,17 +30,16 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
<com.github.ybq.android.spinkit.SpinKitView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_centerInParent="true"
android:id="@+id/progressBar"
style="?android:attr/indeterminate"
style="@style/SpinKitView.Large.FadingCircle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
android:layout_gravity="center"
app:SpinKit_Color="@color/colorPrimary" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/logo_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:background="@color/colorPrimaryDark"
android:paddingTop="30dp"
android:paddingBottom="30dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/logo_mobilizon"
android:src="@drawable/mobilizon_logo"
/>
</RelativeLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingTop="30dp"
android:paddingBottom="30dp"
android:background="@color/colorPrimary"
app:layout_constraintTop_toBottomOf="@+id/logo_container"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<TextView
android:id="@+id/about"
android:layout_margin="20dp"
android:textSize="24sp"
android:textColor="@android:color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@id/about_the_app"
app:layout_constraintEnd_toStartOf="@id/terms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about"
/>
<TextView
android:id="@+id/terms"
android:layout_margin="20dp"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="@+id/about"
app:layout_constraintTop_toTopOf="parent"
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="@id/about_the_app"
app:layout_constraintEnd_toStartOf="@id/license"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/terms"
/>
<TextView
android:id="@+id/license"
android:layout_margin="20dp"
android:textSize="24sp"
app:layout_constraintStart_toEndOf="@+id/terms"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textColor="@android:color/white"
app:layout_constraintBottom_toBottomOf="@id/about_the_app"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/license"
/>
<TextView
android:id="@+id/about_the_app"
android:layout_margin="40dp"
android:textSize="24sp"
android:textColor="@android:color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/about"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_the_app"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -13,4 +13,10 @@
android:orderInCategory="100"
android:title="@string/change_instance"
app:showAsAction="never" />
<item
android:id="@+id/action_about"
android:orderInCategory="100"
android:title="@string/about"
app:showAsAction="never" />
</menu>

View File

@ -31,4 +31,10 @@
<string name="my_account">My account</string>
<string name="register">Register</string>
<string name="account">Account</string>
<string name="about">About</string>
<string name="logo_mobilizon">Mobilizon logo</string>
<string name="close">Close</string>
<string name="terms">Terms</string>
<string name="license">License</string>
<string name="about_the_app">About the app (Release %1$s)</string>
</resources>