44import android .app .AlarmManager ;
55import android .app .PendingIntent ;
66import android .content .Context ;
7- import android .content .DialogInterface ;
87import android .content .Intent ;
98import android .content .SharedPreferences ;
109import android .content .res .Configuration ;
1110import android .os .Build ;
1211import android .os .Bundle ;
13- import android .text .Editable ;
14- import android .text .TextWatcher ;
1512import android .util .Log ;
1613import android .widget .AutoCompleteTextView ;
1714import android .widget .Button ;
18- import android .widget .EditText ;
1915import android .widget .Toast ;
2016
2117import androidx .annotation .NonNull ;
2218import androidx .annotation .StringRes ;
2319import androidx .appcompat .app .AlertDialog ;
24- import androidx .appcompat .widget .AppCompatEditText ;
2520import androidx .fragment .app .Fragment ;
2621import androidx .fragment .app .FragmentTransaction ;
2722import androidx .preference .ListPreference ;
3025import androidx .preference .TwoStatePreference ;
3126
3227import com .fox2code .foxcompat .FoxActivity ;
28+ import com .fox2code .foxcompat .FoxDisplay ;
29+ import com .fox2code .foxcompat .FoxViewCompat ;
3330import com .fox2code .mmm .AppUpdateManager ;
3431import com .fox2code .mmm .BuildConfig ;
3532import com .fox2code .mmm .Constants ;
@@ -256,7 +253,7 @@ public boolean onBackPressed(FoxActivity compatActivity) {
256253 }
257254
258255 public static class RepoFragment extends PreferenceFragmentCompat {
259- private static final int CUSTOM_REPO_ENTRIES = 3 ;
256+ private static final int CUSTOM_REPO_ENTRIES = 5 ;
260257
261258 @ Override
262259 public void onCreatePreferences (Bundle savedInstanceState , String rootKey ) {
@@ -293,7 +290,8 @@ public void updateCustomRepoList(boolean initial) {
293290 }
294291 Preference preference = findPreference ("pref_custom_add_repo" );
295292 if (preference == null ) return ;
296- preference .setVisible (customRepoManager .canAddRepo ());
293+ preference .setVisible (customRepoManager .canAddRepo () &&
294+ customRepoManager .getRepoCount () < CUSTOM_REPO_ENTRIES );
297295 if (initial ) { // Custom repo add button part.
298296 preference = findPreference ("pref_custom_add_repo_button" );
299297 if (preference == null ) return ;
@@ -303,6 +301,7 @@ public void updateCustomRepoList(boolean initial) {
303301 final MaterialAutoCompleteTextView input =
304302 new MaterialAutoCompleteTextView (context );
305303 input .setHint (R .string .custom_url );
304+ builder .setIcon (R .drawable .ic_baseline_add_box_24 );
306305 builder .setTitle (R .string .add_repo );
307306 builder .setView (input );
308307 builder .setPositiveButton ("OK" , (dialog , which ) -> {
@@ -346,10 +345,14 @@ public CharSequence fixText(CharSequence charSequence) {
346345 public void onTextChanged (
347346 @ NonNull CharSequence charSequence , int i , int i1 , int i2 ) {
348347 positiveButton .setEnabled (customRepoManager
349- .canAddRepo (charSequence .toString ()));
348+ .canAddRepo (charSequence .toString ()) &&
349+ customRepoManager .getRepoCount () < CUSTOM_REPO_ENTRIES );
350350 }
351351 });
352352 positiveButton .setEnabled (false );
353+ int dp10 = FoxDisplay .dpToPixel (10 ),
354+ dp20 = FoxDisplay .dpToPixel (20 );
355+ FoxViewCompat .setMargin (input , dp20 , dp10 , dp20 , dp10 );
353356 return true ;
354357 });
355358 }
0 commit comments