Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Made FAB settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SlideCI committed Nov 17, 2015
1 parent b59599d commit b5c136e
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 128 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "me.ccrama.redditslide"
minSdkVersion 17
targetSdkVersion 23
versionCode 86
versionName "4.3.25"
versionCode 88
versionName "4.3.4"
multiDexEnabled = true
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
android:name=".Activities.ModQueue"
android:configChanges="keyboardHidden|orientation|screenSize"

android:theme="@style/swipeable" />
<activity
android:name=".Activities.SettingsFab"
android:configChanges="keyboardHidden|orientation|screenSize"

android:theme="@style/swipeable" />
<activity
android:name=".Activities.CommentSearch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,16 +1049,18 @@ public void run() {
}

public void restartTheme() {
if (Reddit.single != currentSingle) {
((Reddit) getApplication()).startMain();


finish();
} else {
Intent intent = this.getIntent();
if(pager != null) {
intent.putExtra("pageTo", pager.getCurrentItem());
}
intent.putExtra("pageTo", pager.getCurrentItem());

startActivity(intent);
overridePendingTransition(R.anim.fade_in_real, R.anim.fading_out_real);
finish();

}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void onClick(View d) {
Reddit.notifications.cancel(getApplication());
Reddit.notifications.start(getApplication());
dialog.dismiss();
((TextView)findViewById(R.id.notifications_current)).setText(getString(R.string.settings_notification_short,
((TextView) findViewById(R.id.notifications_current)).setText(getString(R.string.settings_notification_short,
TimeUtils.getTimeInHoursAndMins(Reddit.notificationTime, getBaseContext())));
}
}
Expand Down Expand Up @@ -285,6 +285,13 @@ public void onClick(View v) {
Settings.this.startActivity(inte);
}
});
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent inte = new Intent(Settings.this, SettingsFab.class);
Settings.this.startActivity(inte);
}
});
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package me.ccrama.redditslide.Activities;

import android.app.ActivityManager;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.Window;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import me.ccrama.redditslide.ColorPreferences;
import me.ccrama.redditslide.R;
import me.ccrama.redditslide.Reddit;
import me.ccrama.redditslide.SettingValues;
import me.ccrama.redditslide.Visuals.FontPreferences;
import me.ccrama.redditslide.Visuals.Pallete;


/**
* Created by l3d00m on 11/13/2015.
*/
public class SettingsFab extends BaseActivityNoAnim {


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getTheme().applyStyle(new FontPreferences(this).getFontStyle().getResId(), true);
getTheme().applyStyle(new ColorPreferences(this).getFontStyle().getBaseId(), true);
setContentView(R.layout.activity_settings_fab);
final Toolbar b = (Toolbar) findViewById(R.id.toolbar);
b.setBackgroundColor(Pallete.getDefaultColor());
setSupportActionBar(b);
getSupportActionBar().setTitle(R.string.settings_fab);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.setStatusBarColor(Pallete.getDarkerColor(Pallete.getDefaultColor()));
SettingsFab.this.setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.settings_fab),
((BitmapDrawable) ContextCompat.getDrawable(getBaseContext(), R.drawable.ic_launcher)).getBitmap(), Pallete.getDefaultColor()));
}

CheckBox fab = (CheckBox) findViewById(R.id.fab_visible);
fab.setChecked(Reddit.fab);
fab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Reddit.fab = isChecked;
SettingValues.prefs.edit().putBoolean("Fab", isChecked).apply();
}
});

CheckBox fabType = (CheckBox) findViewById(R.id.fab_type);
fabType.setChecked(Reddit.fabType == R.integer.FAB_DISMISS);
fabType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
Reddit.fabType = R.integer.FAB_DISMISS;
SettingValues.prefs.edit().putInt("FabType", R.integer.FAB_DISMISS).apply();
}
else{
Reddit.fabType = R.integer.FAB_POST;
SettingValues.prefs.edit().putInt("FabType", R.integer.FAB_POST).apply();
}
}
});
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -186,31 +186,7 @@ public boolean onMenuItemClick(MenuItem item) {
popup.show();
}
});
CheckBox fab = (CheckBox) findViewById(R.id.fab_visible);
fab.setChecked(Reddit.fab);
fab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Reddit.fab = isChecked;
SettingValues.prefs.edit().putBoolean("Fab", isChecked).apply();
}
});

CheckBox fabType = (CheckBox) findViewById(R.id.fab_type);
fabType.setChecked(Reddit.fabType == R.integer.FAB_DISMISS);
fabType.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
Reddit.fabType = R.integer.FAB_DISMISS;
SettingValues.prefs.edit().putInt("FabType", R.integer.FAB_DISMISS).apply();
}
else{
Reddit.fabType = R.integer.FAB_POST;
SettingValues.prefs.edit().putInt("FabType", R.integer.FAB_POST).apply();
}
}
});

findViewById(R.id.theme).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.ccrama.redditslide.Fragments;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
Expand All @@ -18,6 +19,8 @@
import android.view.View;
import android.view.ViewGroup;

import com.afollestad.materialdialogs.AlertDialogWrapper;

import net.dean.jraw.models.Submission;

import java.util.ArrayList;
Expand Down Expand Up @@ -141,17 +144,46 @@ public void onClick(View v) {
}
});
} else {
fab.setImageResource(R.drawable.close);
fab.setImageResource(R.drawable.hide);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clearSeenPosts(false);
if(!Reddit.fabClear){
new AlertDialogWrapper.Builder(getActivity()).setTitle(R.string.fabclear_title)
.setMessage(R.string.fabclear_msg)
.setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Reddit.seen.edit().putBoolean("fabClear", true).apply();
Reddit.fabClear = true;
clearSeenPosts(false);

}
}).show();
} else {
clearSeenPosts(false);
}
}
});
fab.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
clearSeenPosts(true);
if(!Reddit.fabClear){
new AlertDialogWrapper.Builder(getActivity()).setTitle(R.string.fabclear_title)
.setMessage(R.string.fabclear_msg)
.setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Reddit.seen.edit().putBoolean("fabClear", true).apply();
Reddit.fabClear = true;
clearSeenPosts(true);

}
}).show();
} else {
clearSeenPosts(true);

}
/*
ToDo Make a sncakbar with an undo option of the clear all
View.OnClickListener undoAction = new View.OnClickListener() {
Expand Down Expand Up @@ -221,11 +253,13 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
private ArrayList<Submission> clearSeenPosts(boolean forever) {
ArrayList<Submission> originalDataSetPosts = adapter.dataSet.posts;
System.out.println("Posts number is " + adapter.dataSet.posts.size());

for (int i = adapter.dataSet.posts.size(); i > -1; i--) {
try {
if (HasSeen.getSeen(adapter.dataSet.posts.get(i).getFullName())) {
if (forever)
if (forever) {
Hidden.setHidden(adapter.dataSet.posts.get(i));
}
adapter.dataSet.posts.remove(i);
adapter.notifyItemRemoved(i);
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/me/ccrama/redditslide/Reddit.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class Reddit extends MultiDexApplication implements Application.ActivityL
private Runnable mBackgroundTransition;
public static long time = System.currentTimeMillis();
private boolean isRestarting;
public static boolean fabClear;

public static CustomTabsSession getSession() {
if (mClient == null) {
Expand Down Expand Up @@ -324,6 +325,7 @@ public void uncaughtException(Thread thread, Throwable t) {
video = SettingValues.prefs.getBoolean("video", true);
exit = SettingValues.prefs.getBoolean("Exit", true);
fastscroll = SettingValues.prefs.getBoolean("Fastscroll", false);
fabClear = seen.getBoolean("fabClear", false);
hideButton = SettingValues.prefs.getBoolean("Hidebutton", false);

int height = this.getResources().getConfiguration().screenWidthDp;
Expand Down
Binary file added app/src/main/res/drawable/fab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,35 @@
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="@+id/fab"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"

android:paddingLeft="16dp"
android:paddingRight="16dp">

<ImageView
android:layout_width="56dp"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:src="@drawable/fab"
android:tint="?attr/tint"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"

android:gravity="center_vertical"
android:text="@string/settings_fab"
android:textColor="?attr/font"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>

<LinearLayout
android:id="@+id/tablet"
Expand Down
Loading

0 comments on commit b5c136e

Please sign in to comment.