Fix last issues

This commit is contained in:
tom79 2019-10-13 11:44:23 +02:00
parent f0ebcf7a90
commit ca16524e9e
5 changed files with 48 additions and 29 deletions

View File

@ -84,7 +84,7 @@ dependencies {
implementation "com.google.code.gson:gson:$gsonLibraryVersion" implementation "com.google.code.gson:gson:$gsonLibraryVersion"
implementation "com.google.guava:guava:$guavaLibraryVersion" implementation "com.google.guava:guava:$guavaLibraryVersion"
implementation "com.github.chrisbanes:PhotoView:$photoViewLibraryVersion" implementation "com.github.chrisbanes:PhotoView:$photoViewLibraryVersion"
implementation 'com.r0adkll:slidableactivity:2.1.0' implementation 'com.r0adkll:slidableactivity:2.0.6'
implementation 'com.github.stom79:country-picker-android:1.2.0' implementation 'com.github.stom79:country-picker-android:1.2.0'
implementation 'com.github.stom79:mytransl:1.5' implementation 'com.github.stom79:mytransl:1.5'
implementation 'com.github.stom79:SparkButton:1.0.12' implementation 'com.github.stom79:SparkButton:1.0.12'

View File

@ -310,6 +310,7 @@
<activity <activity
android:name="app.fedilab.android.activities.SlideMediaActivity" android:name="app.fedilab.android.activities.SlideMediaActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTask"
android:theme="@style/TransparentDark" android:theme="@style/TransparentDark"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:noHistory="true" /> android:noHistory="true" />

View File

@ -85,7 +85,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
int flags; int flags;
private TextView media_description; private TextView media_description;
private Handler handler; private Handler handler;
private boolean swipeEnabled;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
@ -105,7 +105,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
setTheme(R.style.TransparentDark); setTheme(R.style.TransparentDark);
} }
setContentView(R.layout.activity_media_pager); setContentView(R.layout.activity_media_pager);
RelativeLayout swipeBackLayout = findViewById(R.id.swipeBackLayout); CoordinatorLayout swipeBackLayout = findViewById(R.id.swipeBackLayout);
if (theme == Helper.THEME_LIGHT) { if (theme == Helper.THEME_LIGHT) {
swipeBackLayout.setBackgroundResource(R.color.white); swipeBackLayout.setBackgroundResource(R.color.white);
} else if (theme == Helper.THEME_BLACK) { } else if (theme == Helper.THEME_BLACK) {
@ -117,7 +117,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
media_description = findViewById(R.id.media_description); media_description = findViewById(R.id.media_description);
flags = getWindow().getDecorView().getSystemUiVisibility(); flags = getWindow().getDecorView().getSystemUiVisibility();
swipeEnabled = true;
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
@ -248,7 +248,7 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
.build(); .build();
slidrInterface = Slidr.attach(this, config); slidrInterface = Slidr.attach(SlideMediaActivity.this, config);
setFullscreen(true); setFullscreen(true);
} }
@ -387,10 +387,13 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
public void enableSliding(boolean enable){ public void enableSliding(boolean enable){
if (enable) if (enable && !swipeEnabled) {
slidrInterface.unlock(); slidrInterface.unlock();
else swipeEnabled = true;
}else if( !enable && swipeEnabled) {
slidrInterface.lock(); slidrInterface.lock();
swipeEnabled = false;
}
} }
public boolean getFullScreen(){ public boolean getFullScreen(){
@ -400,27 +403,39 @@ public class SlideMediaActivity extends BaseActivity implements OnDownloadInterf
public void setFullscreen(boolean fullscreen) public void setFullscreen(boolean fullscreen)
{ {
this.fullscreen = fullscreen; this.fullscreen = fullscreen;
View mDecorView = getWindow().getDecorView();
if (!fullscreen) { if (!fullscreen) {
mDecorView.setSystemUiVisibility(flags); showSystemUI();
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { hideSystemUI();
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}else{
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
);
}
} }
} }
private void hideSystemUI() {
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
}
// Shows the system bars by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
} }

View File

@ -25,6 +25,7 @@ import android.media.MediaPlayer;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -160,10 +161,12 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
@Override @Override
public void onMatrixChanged(RectF rect) { public void onMatrixChanged(RectF rect) {
canSwipe = (imageView.getScale() == 1); canSwipe = (imageView.getScale() == 1);
if( !canSwipe){ if( !canSwipe){
if( ! ((SlideMediaActivity)context).getFullScreen()) { if( ! ((SlideMediaActivity)context).getFullScreen()) {
((SlideMediaActivity) context).setFullscreen(true); ((SlideMediaActivity) context).setFullscreen(true);
} }
Log.v(Helper.TAG,"canSwipe! " + canSwipe);
((SlideMediaActivity) context).enableSliding(false); ((SlideMediaActivity) context).enableSliding(false);
}else{ }else{
((SlideMediaActivity) context).enableSliding(true); ((SlideMediaActivity) context).enableSliding(true);

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along with Fedilab; if not, You should have received a copy of the GNU General Public License along with Fedilab; if not,
see <http://www.gnu.org/licenses>. see <http://www.gnu.org/licenses>.
--> -->
<RelativeLayout <androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:id="@+id/swipeBackLayout" android:id="@+id/swipeBackLayout"
@ -32,9 +32,9 @@
android:id="@+id/media_description" android:id="@+id/media_description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="20dp" android:layout_marginBottom="70dp"
android:layout_gravity="center_horizontal|bottom" android:layout_gravity="center_horizontal|bottom"
android:padding="12dp" android:padding="12dp"
android:background="#AA000000" android:background="#AA000000"
android:textColor="#ffffffff" /> android:textColor="#ffffffff" />
</RelativeLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>