Skip to content

Commit

Permalink
added new example link form
Browse files Browse the repository at this point in the history
  • Loading branch information
Wladefant committed Nov 13, 2022
1 parent 03a2784 commit b795adf
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 156 deletions.
14 changes: 13 additions & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Bug Report
description: Create a report to help us improve existing features
labels: ['type: possible bug']

body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: checkboxes
id: checklist
attributes:
Expand All @@ -17,6 +19,7 @@ body:
required: true
- label: If the bug only occurs with a certain link, post, image..., I will include the URL.
required: true

- type: input
id: version
attributes:
Expand All @@ -25,6 +28,7 @@ body:
placeholder: x.y.z
validations:
required: true

- type: dropdown
id: source
attributes:
Expand All @@ -36,13 +40,15 @@ body:
- Other
validations:
required: true

- type: input
id: android_version
attributes:
label: Android version
description: Please mention if you are using a custom rom!
validations:
required: true

- type: input
id: device
attributes:
Expand All @@ -52,16 +58,22 @@ body:
attributes:
label: First occurred
placeholder: about x days/weeks ago

- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: Do not forget to always add example posts, links, markdown...
placeholder: |
1. This
2. Then that
3. Then this
4. Etc.
- type: textarea
id: links
attributes:
label: Example post, link, markdown...

- type: textarea
id: expected
attributes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,197 +1,173 @@
package ml.docilealligator.infinityforreddit.activities;

import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import javax.inject.Inject;
import javax.inject.Named;

import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.AdvancedPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment;
import ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment;
import ml.docilealligator.infinityforreddit.settings.FontPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.GesturesAndButtonsPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.InterfacePreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.MainPreferenceFragment;
import ml.docilealligator.infinityforreddit.settings.NsfwAndSpoilerFragment;
import ml.docilealligator.infinityforreddit.settings.PostHistoryFragment;
import ml.docilealligator.infinityforreddit.settings.PostPreferenceFragment;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;

public class SettingsActivity extends BaseActivity implements
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {

private static final String TITLE_STATE = "TS";

package ml.docilealligator.infinityforreddit.activities

import ml.docilealligator.infinityforreddit.activities.BaseActivity
import androidx.preference.PreferenceFragmentCompat
import butterknife.BindView
import ml.docilealligator.infinityforreddit.R
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import javax.inject.Inject
import android.content.SharedPreferences
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper
import android.os.Bundle
import ml.docilealligator.infinityforreddit.Infinity
import butterknife.ButterKnife
import android.os.Build
import android.view.MenuItem
import androidx.appcompat.widget.Toolbar
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils
import ml.docilealligator.infinityforreddit.settings.MainPreferenceFragment
import ml.docilealligator.infinityforreddit.activities.SettingsActivity
import ml.docilealligator.infinityforreddit.settings.AboutPreferenceFragment
import ml.docilealligator.infinityforreddit.settings.InterfacePreferenceFragment
import ml.docilealligator.infinityforreddit.settings.FontPreferenceFragment
import ml.docilealligator.infinityforreddit.settings.GesturesAndButtonsPreferenceFragment
import ml.docilealligator.infinityforreddit.settings.PostPreferenceFragment
import ml.docilealligator.infinityforreddit.settings.AdvancedPreferenceFragment
import ml.docilealligator.infinityforreddit.settings.CustomizeMainPageTabsFragment
import ml.docilealligator.infinityforreddit.settings.NsfwAndSpoilerFragment
import ml.docilealligator.infinityforreddit.settings.CustomizeBottomAppBarFragment
import ml.docilealligator.infinityforreddit.settings.PostHistoryFragment
import org.greenrobot.eventbus.ThreadMode
import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent
import androidx.core.app.ActivityCompat
import androidx.preference.Preference
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import javax.inject.Named

class SettingsActivity : BaseActivity(), PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
@BindView(R.id.appbar_layout_settings_activity)
AppBarLayout appBarLayout;
var appBarLayout: AppBarLayout? = null

@BindView(R.id.collapsing_toolbar_layout_settings_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
var collapsingToolbarLayout: CollapsingToolbarLayout? = null

@BindView(R.id.toolbar_settings_activity)
Toolbar toolbar;
private String mAccountName;
var toolbar: Toolbar? = null
private var mAccountName: String? = null

@Inject
@Named("default")
SharedPreferences mSharedPreferences;
var mSharedPreferences: SharedPreferences? = null

@Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;

@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);

setImmersiveModeNotApplicable();

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_settings);

ButterKnife.bind(this);

EventBus.getDefault().register(this);
var mCurrentAccountSharedPreferences: SharedPreferences? = null

applyCustomTheme();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(appBarLayout);
@Inject
var mCustomThemeWrapper: CustomThemeWrapper? = null
override fun onCreate(savedInstanceState: Bundle?) {
(application as Infinity).appComponent.inject(this)
setImmersiveModeNotApplicable()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings)
ButterKnife.bind(this)
EventBus.getDefault().register(this)
applyCustomTheme()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor) {
addOnOffsetChangedListener(appBarLayout)
}

setSupportActionBar(toolbar);

mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);

setSupportActionBar(toolbar)
mAccountName = mCurrentAccountSharedPreferences!!.getString(SharedPreferencesUtils.ACCOUNT_NAME, null)
if (savedInstanceState == null) {
getSupportFragmentManager()
supportFragmentManager
.beginTransaction()
.replace(R.id.frame_layout_settings_activity, new MainPreferenceFragment())
.commit();
.replace(R.id.frame_layout_settings_activity, MainPreferenceFragment())
.commit()
} else {
setTitle(savedInstanceState.getCharSequence(TITLE_STATE));
title = savedInstanceState.getCharSequence(TITLE_STATE)
}

getSupportFragmentManager().addOnBackStackChangedListener(() -> {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
setTitle(R.string.settings_activity_label);
return;
supportFragmentManager.addOnBackStackChangedListener {
if (supportFragmentManager.backStackEntryCount == 0) {
setTitle(R.string.settings_activity_label)
return@addOnBackStackChangedListener
}
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.frame_layout_settings_activity);
if (fragment instanceof AboutPreferenceFragment) {
setTitle(R.string.settings_about_master_title);
} else if (fragment instanceof InterfacePreferenceFragment) {
setTitle(R.string.settings_interface_title);
} else if (fragment instanceof FontPreferenceFragment) {
setTitle(R.string.settings_font_title);
} else if (fragment instanceof GesturesAndButtonsPreferenceFragment) {
setTitle(R.string.settings_gestures_and_buttons_title);
} else if (fragment instanceof PostPreferenceFragment) {
setTitle(R.string.settings_category_post_title);
} else if (fragment instanceof AdvancedPreferenceFragment) {
setTitle(R.string.settings_advanced_master_title);
val fragment = supportFragmentManager.findFragmentById(R.id.frame_layout_settings_activity)
if (fragment is AboutPreferenceFragment) {
setTitle(R.string.settings_about_master_title)
} else if (fragment is InterfacePreferenceFragment) {
setTitle(R.string.settings_interface_title)
} else if (fragment is FontPreferenceFragment) {
setTitle(R.string.settings_font_title)
} else if (fragment is GesturesAndButtonsPreferenceFragment) {
setTitle(R.string.settings_gestures_and_buttons_title)
} else if (fragment is PostPreferenceFragment) {
setTitle(R.string.settings_category_post_title)
} else if (fragment is AdvancedPreferenceFragment) {
setTitle(R.string.settings_advanced_master_title)
}
});
}
}

@Override
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
public override fun getDefaultSharedPreferences(): SharedPreferences {
return mSharedPreferences!!
}

@Override
protected CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
override fun getCustomThemeWrapper(): CustomThemeWrapper {
return mCustomThemeWrapper!!
}

@Override
protected void applyCustomTheme() {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
override fun applyCustomTheme() {
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar)
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) {
onBackPressed()
return true
}
return false;
return false
}

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putCharSequence(TITLE_STATE, getTitle());
public override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putCharSequence(TITLE_STATE, title)
}

@Override
public boolean onSupportNavigateUp() {
if (getSupportFragmentManager().popBackStackImmediate()) {
return true;
}
return super.onSupportNavigateUp();
override fun onSupportNavigateUp(): Boolean {
return if (supportFragmentManager.popBackStackImmediate()) {
true
} else super.onSupportNavigateUp()
}

@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
// Instantiate the new Fragment
final Bundle args = pref.getExtras();
final Fragment fragment = getSupportFragmentManager().getFragmentFactory().instantiate(
getClassLoader(),
pref.getFragment());
if (fragment instanceof CustomizeMainPageTabsFragment) {
args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} else if (fragment instanceof NsfwAndSpoilerFragment) {
args.putString(NsfwAndSpoilerFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} else if (fragment instanceof CustomizeBottomAppBarFragment) {
args.putString(CustomizeBottomAppBarFragment.EXTRA_ACCOUNT_NAME, mAccountName);
} else if (fragment instanceof PostHistoryFragment) {
args.putString(PostHistoryFragment.EXTRA_ACCOUNT_NAME, mAccountName);
val args = pref.extras
val fragment = supportFragmentManager.fragmentFactory.instantiate(
classLoader,
pref.fragment!!)
if (fragment is CustomizeMainPageTabsFragment) {
args.putString(CustomizeMainPageTabsFragment.EXTRA_ACCOUNT_NAME, mAccountName)
} else if (fragment is NsfwAndSpoilerFragment) {
args.putString(NsfwAndSpoilerFragment.EXTRA_ACCOUNT_NAME, mAccountName)
} else if (fragment is CustomizeBottomAppBarFragment) {
args.putString(CustomizeBottomAppBarFragment.EXTRA_ACCOUNT_NAME, mAccountName)
} else if (fragment is PostHistoryFragment) {
args.putString(PostHistoryFragment.EXTRA_ACCOUNT_NAME, mAccountName)
}
fragment.setArguments(args);
fragment.setTargetFragment(caller, 0);

getSupportFragmentManager().beginTransaction()
fragment.arguments = args
fragment.setTargetFragment(caller, 0)
supportFragmentManager.beginTransaction()
.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
.replace(R.id.frame_layout_settings_activity, fragment)
.addToBackStack(null)
.commit();
setTitle(pref.getTitle());
return true;
.commit()
title = pref.title
return true
}

@Override
protected void onDestroy() {
super.onDestroy();
EventBus.getDefault().unregister(this);
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onRecreateActivityEvent(RecreateActivityEvent recreateActivityEvent) {
ActivityCompat.recreate(this);
fun onRecreateActivityEvent(recreateActivityEvent: RecreateActivityEvent?) {
ActivityCompat.recreate(this)
}

companion object {
private const val TITLE_STATE = "TS"
}
}
}

0 comments on commit b795adf

Please sign in to comment.