Merge branch 'main' into notification-toast

This commit is contained in:
M M Arif
2022-05-04 21:10:27 +02:00
6 changed files with 49 additions and 236 deletions

View File

@@ -241,7 +241,6 @@ public class CreateLabelActivity extends BaseActivity {
else {
enableProcessButton();
tinyDB.putString("labelColor", "");
Toasty.error(ctx, getString(R.string.genericError));
}
}
@@ -296,8 +295,6 @@ public class CreateLabelActivity extends BaseActivity {
else {
enableProcessButton();
tinyDB.putString("labelColor", "");
tinyDB.putString("labelColorDefault", "");
Toasty.error(ctx, getString(R.string.genericError));
}
}

View File

@@ -80,7 +80,7 @@ public class SettingsAppearanceActivity extends BaseActivity {
activitySettingsAppearanceBinding.darkThemeSelectedTime.setText(ctx.getResources().getString(R.string.settingsThemeTimeSelectedHint, darkHour,
darkMinute));
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(timeList[timeSelectedChoice]);
activitySettingsAppearanceBinding.customFontSelected.setText(tinyDB.getString("customFontStr", "Manrope"));
activitySettingsAppearanceBinding.customFontSelected.setText(customFontList[customFontSelectedChoice]);
activitySettingsAppearanceBinding.themeSelected.setText(themeList[themeSelectedChoice]);
if(themeList[themeSelectedChoice].startsWith("Auto")) {
@@ -159,7 +159,6 @@ public class SettingsAppearanceActivity extends BaseActivity {
customFontSelectedChoice = i;
activitySettingsAppearanceBinding.customFontSelected.setText(customFontList[i]);
tinyDB.putString("customFontStr", customFontList[i]);
tinyDB.putInt("customFontId", i);
AppUtil.typeface = null; // reset typeface
FontsOverride.setDefaultFont(this);
@@ -187,7 +186,6 @@ public class SettingsAppearanceActivity extends BaseActivity {
timeSelectedChoice = i;
activitySettingsAppearanceBinding.tvDateTimeSelected.setText(timeList[i]);
tinyDB.putString("timeStr", timeList[i]);
tinyDB.putInt("timeId", i);
switch(i) {

View File

@@ -1,6 +1,7 @@
package org.mian.gitnex.fragments;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
@@ -229,6 +230,17 @@ public class RepoInfoFragment extends Fragment {
binding.repoIsArchived.setVisibility(View.GONE);
}
if(repoInfo.isFork()) {
binding.repoForkFrame.setVisibility(View.VISIBLE);
binding.repoForkFrame.setOnClickListener((v) -> {
Intent parent = new RepositoryContext(repoInfo.getParent(), requireContext()).getIntent(requireContext(), RepoDetailActivity.class);
startActivity(parent);
});
binding.repoFork.setText(getString(R.string.repoForkOf, repoInfo.getParent().getFullName()));
} else {
binding.repoForkFrame.setVisibility(View.GONE);
}
getFileContents(repository.getOwner(), repository.getName(), getResources().getString(R.string.defaultFilename), repoInfo.getDefaultBranch());
pageContent.setVisibility(View.VISIBLE);
@@ -242,12 +254,12 @@ public class RepoInfoFragment extends Fragment {
.getWebInterface(getContext())
.getFileContents(owner, repo, defBranch, filename);
call.enqueue(new Callback<ResponseBody>() {
call.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<ResponseBody> call, @NonNull retrofit2.Response<ResponseBody> response) {
if (isAdded()) {
if(isAdded()) {
switch(response.code()) {
@@ -288,6 +300,7 @@ public class RepoInfoFragment extends Fragment {
@Override
public void onFailure(@NonNull Call<ResponseBody> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
}

View File

@@ -69,7 +69,6 @@ public class TinyDB {
try {
fileCreated = imageFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
@@ -81,18 +80,14 @@ public class TinyDB {
} catch (Exception e) {
e.printStackTrace();
bitmapCompressed = false;
} finally {
if (out != null) {
try {
out.flush();
out.close();
streamClosed = true;
} catch (IOException e) {
e.printStackTrace();
streamClosed = false;
}
}
}
@@ -105,7 +100,6 @@ public class TinyDB {
/**
* Get int value from SharedPreferences at 'key'. If key not found, return 'defaultValue'
* @param key SharedPreferences key
* @param defaultValue int value returned if key was not found
* @return int value at 'key' or 'defaultValue' if key not found
*/
public int getInt(String key) {
@@ -116,22 +110,6 @@ public class TinyDB {
return preferences.getInt(key, defaultValue);
}
/**
* Get parsed ArrayList of Integers from SharedPreferences at 'key'
* @param key SharedPreferences key
* @return ArrayList of Integers
*/
public ArrayList<Integer> getListInt(String key) {
String[] myList = TextUtils.split(preferences.getString(key, ""), "‚‗‚");
ArrayList<String> arrayToList = new ArrayList<String>(Arrays.asList(myList));
ArrayList<Integer> newList = new ArrayList<Integer>();
for (String item : arrayToList)
newList.add(Integer.parseInt(item));
return newList;
}
/**
* Get long value from SharedPreferences at 'key'. If key not found, return 'defaultValue'
* @param key SharedPreferences key
@@ -145,7 +123,6 @@ public class TinyDB {
/**
* Get float value from SharedPreferences at 'key'. If key not found, return 'defaultValue'
* @param key SharedPreferences key
* @param defaultValue float value returned if key was not found
* @return float value at 'key' or 'defaultValue' if key not found
*/
public float getFloat(String key) {
@@ -156,55 +133,6 @@ public class TinyDB {
return preferences.getFloat(key, defaultValue);
}
/**
* Get double value from SharedPreferences at 'key'. If exception thrown, return 'defaultValue'
* @param key SharedPreferences key
* @param defaultValue double value returned if exception is thrown
* @return double value at 'key' or 'defaultValue' if exception is thrown
*/
public double getDouble(String key, double defaultValue) {
String number = getString(key);
try {
return Double.parseDouble(number);
} catch (NumberFormatException e) {
return defaultValue;
}
}
/**
* Get parsed ArrayList of Double from SharedPreferences at 'key'
* @param key SharedPreferences key
* @return ArrayList of Double
*/
public ArrayList<Double> getListDouble(String key) {
String[] myList = TextUtils.split(preferences.getString(key, ""), "‚‗‚");
ArrayList<String> arrayToList = new ArrayList<String>(Arrays.asList(myList));
ArrayList<Double> newList = new ArrayList<Double>();
for (String item : arrayToList)
newList.add(Double.parseDouble(item));
return newList;
}
/**
* Get parsed ArrayList of Integers from SharedPreferences at 'key'
* @param key SharedPreferences key
* @return ArrayList of Longs
*/
public ArrayList<Long> getListLong(String key) {
String[] myList = TextUtils.split(preferences.getString(key, ""), "‚‗‚");
ArrayList<String> arrayToList = new ArrayList<String>(Arrays.asList(myList));
ArrayList<Long> newList = new ArrayList<Long>();
for (String item : arrayToList)
newList.add(Long.parseLong(item));
return newList;
}
/**
* Get String value from SharedPreferences at 'key'. If key not found, return ""
* @param key SharedPreferences key
@@ -218,19 +146,9 @@ public class TinyDB {
return preferences.getString(key, defaultValue);
}
/**
* Get parsed ArrayList of String from SharedPreferences at 'key'
* @param key SharedPreferences key
* @return ArrayList of String
*/
public ArrayList<String> getListString(String key) {
return new ArrayList<String>(Arrays.asList(TextUtils.split(preferences.getString(key, ""), "‚‗‚")));
}
/**
* Get boolean value from SharedPreferences at 'key'. If key not found, return 'defaultValue'
* @param key SharedPreferences key
* @param defaultValue boolean value returned if key was not found
* @return boolean value at 'key' or 'defaultValue' if key not found
*/
public boolean getBoolean(String key) {
@@ -241,52 +159,6 @@ public class TinyDB {
return preferences.getBoolean(key, defaultValue);
}
/**
* Get parsed ArrayList of Boolean from SharedPreferences at 'key'
* @param key SharedPreferences key
* @return ArrayList of Boolean
*/
public ArrayList<Boolean> getListBoolean(String key) {
ArrayList<String> myList = getListString(key);
ArrayList<Boolean> newList = new ArrayList<Boolean>();
for (String item : myList) {
if (item.equals("true")) {
newList.add(true);
} else {
newList.add(false);
}
}
return newList;
}
// public ArrayList<Object> getListObject(String key, Class<?> mClass){
// Gson gson = new Gson();
//
// ArrayList<String> objStrings = getListString(key);
// ArrayList<Object> objects = new ArrayList<Object>();
//
// for(String jObjString : objStrings){
// Object value = gson.fromJson(jObjString, mClass);
// objects.add(value);
// }
// return objects;
// }
// public <T> T getObject(String key, Class<T> classOfT){
//
// String json = getString(key);
// Object value = new Gson().fromJson(json, classOfT);
// if (value == null)
// throw new NullPointerException();
// return (T)value;
// }
// Put methods
/**
@@ -299,17 +171,6 @@ public class TinyDB {
preferences.edit().putInt(key, value).apply();
}
/**
* Put ArrayList of Integer into SharedPreferences with 'key' and save
* @param key SharedPreferences key
* @param intList ArrayList of Integer to be added
*/
public void putListInt(String key, ArrayList<Integer> intList) {
checkForNullKey(key);
Integer[] myIntList = intList.toArray(new Integer[0]);
preferences.edit().putString(key, TextUtils.join("‚‗‚", myIntList)).apply();
}
/**
* Put long value into SharedPreferences with 'key' and save
* @param key SharedPreferences key
@@ -320,17 +181,6 @@ public class TinyDB {
preferences.edit().putLong(key, value).apply();
}
/**
* Put ArrayList of Long into SharedPreferences with 'key' and save
* @param key SharedPreferences key
* @param longList ArrayList of Long to be added
*/
public void putListLong(String key, ArrayList<Long> longList) {
checkForNullKey(key);
Long[] myLongList = longList.toArray(new Long[0]);
preferences.edit().putString(key, TextUtils.join("‚‗‚", myLongList)).apply();
}
/**
* Put float value into SharedPreferences with 'key' and save
* @param key SharedPreferences key
@@ -341,27 +191,6 @@ public class TinyDB {
preferences.edit().putFloat(key, value).apply();
}
/**
* Put double value into SharedPreferences with 'key' and save
* @param key SharedPreferences key
* @param value double value to be added
*/
public void putDouble(String key, double value) {
checkForNullKey(key);
putString(key, String.valueOf(value));
}
/**
* Put ArrayList of Double into SharedPreferences with 'key' and save
* @param key SharedPreferences key
* @param doubleList ArrayList of Double to be added
*/
public void putListDouble(String key, ArrayList<Double> doubleList) {
checkForNullKey(key);
Double[] myDoubleList = doubleList.toArray(new Double[doubleList.size()]);
preferences.edit().putString(key, TextUtils.join("‚‗‚", myDoubleList)).apply();
}
/**
* Put String value into SharedPreferences with 'key' and save
* @param key SharedPreferences key
@@ -372,17 +201,6 @@ public class TinyDB {
preferences.edit().putString(key, value).apply();
}
/**
* Put ArrayList of String into SharedPreferences with 'key' and save
* @param key SharedPreferences key
* @param stringList ArrayList of String to be added
*/
public void putListString(String key, ArrayList<String> stringList) {
checkForNullKey(key);
String[] myStringList = stringList.toArray(new String[stringList.size()]);
preferences.edit().putString(key, TextUtils.join("‚‗‚", myStringList)).apply();
}
/**
* Put boolean value into SharedPreferences with 'key' and save
* @param key SharedPreferences key
@@ -393,47 +211,6 @@ public class TinyDB {
preferences.edit().putBoolean(key, value).apply();
}
/**
* Put ArrayList of Boolean into SharedPreferences with 'key' and save
* @param key SharedPreferences key
* @param boolList ArrayList of Boolean to be added
*/
public void putListBoolean(String key, ArrayList<Boolean> boolList) {
checkForNullKey(key);
ArrayList<String> newList = new ArrayList<String>();
for (Boolean item : boolList) {
if (item) {
newList.add("true");
} else {
newList.add("false");
}
}
putListString(key, newList);
}
/**
* Put ObJect any type into SharedPrefrences with 'key' and save
* @param key SharedPreferences key
* @param obj is the Object you want to put
*/
// public void putObject(String key, Object obj){
// checkForNullKey(key);
// Gson gson = new Gson();
// putString(key, gson.toJson(obj));
// }
//
// public void putListObject(String key, ArrayList<Object> objArray){
// checkForNullKey(key);
// Gson gson = new Gson();
// ArrayList<String> objStrings = new ArrayList<String>();
// for(Object obj : objArray){
// objStrings.add(gson.toJson(obj));
// }
// putListString(key, objStrings);
// }
/**
* Remove SharedPreferences item with 'key'
* @param key SharedPreferences key
@@ -509,18 +286,18 @@ public class TinyDB {
}
/**
* null keys would corrupt the shared pref file and make them unreadable this is a preventive measure
* @param the pref key
* @param key the pref key
*/
public void checkForNullKey(String key){
public void checkForNullKey(String key) {
if (key == null){
throw new NullPointerException();
}
}
/**
* null keys would corrupt the shared pref file and make them unreadable this is a preventive measure
* @param the pref key
* @param value the pref key
*/
public void checkForNullValue(String value){
public void checkForNullValue(String value) {
if (value == null){
throw new NullPointerException();
}

View File

@@ -203,12 +203,39 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp"
android:layout_marginBottom="12dp"
android:background="?attr/dividerColor" />
<LinearLayout
android:id="@+id/repo_fork_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?android:attr/selectableItemBackground"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_fork" />
<TextView
android:id="@+id/repo_fork"
android:layout_marginStart="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:paddingLeft="15dp"

View File

@@ -758,4 +758,5 @@
<string name="notLoggedIn">%s \u25CF not logged in</string>
<string name="followSystem">Follow system (Light/Dark)</string>
<string name="followSystemBlack">Follow system (Light/Pitch Black)</string>
<string name="repoForkOf">Fork of: %s</string>
</resources>