mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 04:12:08 +01:00
Load license, contributors, maintainers and 3party libs from ressources
This commit is contained in:
parent
89ee0450e9
commit
c93e28cdc7
10 changed files with 142 additions and 50 deletions
|
@ -3,9 +3,9 @@
|
|||
02l>> If you helped by translating the app, please send a message on crowdin
|
||||
03l>>
|
||||
04l>> Schemes:
|
||||
05l>> Firstname Lastname (Link)
|
||||
06l>> Firstname Lastname (E-Mail)
|
||||
07l>> Username (Link)
|
||||
08l>> Username (E-Mail)
|
||||
05l>> Firstname Lastname (Link): Text
|
||||
06l>> Firstname Lastname (E-Mail): Text
|
||||
07l>> Username (Link): Text
|
||||
08l>> Username (E-Mail): Text
|
||||
## 99l CONTRIBUTORS
|
||||
Abhijith Balan (abhijithb21@openmailbox.org): Malayalam translation
|
||||
|
|
|
@ -15,4 +15,5 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
|||
|
||||
|
||||
# Splashscreen-Images
|
||||
|
||||
The splashscreen images can be found on [flickr](https://www.flickr.com/photos/129581906@N06/sets/72157651933980136/with/16594947123/).
|
||||
|
|
|
@ -53,14 +53,25 @@ dependencies {
|
|||
|
||||
|
||||
task copyRepoFiles(type: Copy) {
|
||||
String[] copyFiles = ["README.md", "CONTRIBUTORS.md", "LICENSE.md", "CHANGELOG.md"]
|
||||
String[] copyFiles = ["README.md", "LICENSE.md", "CHANGELOG.md"]
|
||||
from rootProject.files(copyFiles)
|
||||
into 'src/main/res/raw'
|
||||
rename { String fileName ->
|
||||
fileName.replace(fileName, fileName.toLowerCase())
|
||||
}
|
||||
filter { line -> (line.toString().matches("..l>>.*") || line.toString().startsWith("## 99l CONTRIBUTORS")) \
|
||||
? null : line.toString().trim()
|
||||
|
||||
// Filter Contributors file
|
||||
from(rootProject.file("CONTRIBUTORS.md")) {
|
||||
into '.' // Target already changed to 'src/main/res/raw'
|
||||
rename { String fileName ->
|
||||
fileName.replace(fileName, fileName.toLowerCase())
|
||||
}
|
||||
filter { line ->
|
||||
(line.toString().matches("..l>>.*") || line.toString().startsWith("## 99l CONTRIBUTORS")) ? null : line.toString().trim().replaceAll(" \\(.*\\)", "")
|
||||
}
|
||||
}
|
||||
tasks.copyRepoFiles.execute()
|
||||
|
||||
}
|
||||
tasks
|
||||
.
|
||||
copyRepoFiles.execute()
|
|
@ -41,6 +41,11 @@ import android.widget.TextView;
|
|||
import com.github.dfa.diaspora_android.App;
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
import com.github.dfa.diaspora_android.data.AppSettings;
|
||||
import com.github.dfa.diaspora_android.ui.HtmlTextView;
|
||||
import com.github.dfa.diaspora_android.util.Helpers;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Activity that holds some fragments that show information about the app in a tab layout
|
||||
|
@ -79,7 +84,6 @@ public class AboutActivity extends AppCompatActivity {
|
|||
|
||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,16 +117,62 @@ public class AboutActivity extends AppCompatActivity {
|
|||
* Fragment that shows information about the license of the app and used 3rd party libraries
|
||||
*/
|
||||
public static class LicenseFragment extends Fragment {
|
||||
@BindView(R.id.fragment_license__licensetext)
|
||||
HtmlTextView textLicenseBox;
|
||||
|
||||
@BindView(R.id.fragment_license__3rdparty)
|
||||
HtmlTextView textLicense3partyBox;
|
||||
|
||||
|
||||
public LicenseFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_license, container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
final Context context = rootView.getContext();
|
||||
accentColor = Helpers.hexColorFromRessourceColor(context, R.color.colorAccent);
|
||||
|
||||
textLicenseBox.setTextFormatted(getString(R.string.fragment_license__license_content,
|
||||
getMaintainersHtml(context),
|
||||
getContributorsHtml(context),
|
||||
getLicenseHtml(context)
|
||||
));
|
||||
|
||||
textLicense3partyBox.setTextFormatted(
|
||||
getLicense3dPartyHtml(context)
|
||||
);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private String accentColor;
|
||||
|
||||
public String getContributorsHtml(Context context) {
|
||||
String text = Helpers.readTextfileFromRawRessource(context, R.raw.contributors,
|
||||
"<font color='" + accentColor + "'><b>*</b></font> ", "<br>");
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getMaintainersHtml(Context context) {
|
||||
String text = Helpers.readTextfileFromRawRessource(context, R.raw.maintainers, "", "<br>");
|
||||
text = text
|
||||
.replace("NEWENTRY", "<font color='" + accentColor + "'><b>*</b></font> ")
|
||||
.replace("SUBTABBY", " ");
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getLicenseHtml(Context context) {
|
||||
String text = Helpers.readTextfileFromRawRessource(context, R.raw.license,
|
||||
"", "").replace("\n\n", "<br><br>");
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getLicense3dPartyHtml(Context context) {
|
||||
String text = Helpers.readTextfileFromRawRessource(context, R.raw.license_third_party, "", "<br>");
|
||||
text = text.replace("NEWENTRY", "<font color='" + accentColor + "'><b>*</b></font> ");
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,6 +65,15 @@ public class HtmlTextView extends TextView {
|
|||
* Linkify, format markdown and escape the displayed text.
|
||||
*/
|
||||
private void init(){
|
||||
formatHtmlAndCustomTags();
|
||||
}
|
||||
|
||||
public void setTextFormatted(String text){
|
||||
setText(text);
|
||||
formatHtmlAndCustomTags();
|
||||
}
|
||||
|
||||
private void formatHtmlAndCustomTags(){
|
||||
setText(new SpannableString(Html.fromHtml(getText().toString())));
|
||||
Linkify.TransformFilter filter = new Linkify.TransformFilter() {
|
||||
public final String transformUrl(final Matcher match, String url) {
|
||||
|
|
|
@ -26,8 +26,10 @@ import android.os.Environment;
|
|||
|
||||
import com.github.dfa.diaspora_android.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
@ -64,4 +66,35 @@ public class Helpers {
|
|||
storageDir /* directory */
|
||||
);
|
||||
}
|
||||
|
||||
public static String readTextfileFromRawRessource(Context context, int rawRessourceId, String linePrefix, String linePostfix) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line = "";
|
||||
BufferedReader br = null;
|
||||
linePrefix = linePrefix == null ? "" : linePrefix;
|
||||
linePostfix = linePostfix == null ? "" : linePostfix;
|
||||
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(context.getResources().openRawResource(rawRessourceId)));
|
||||
while ((line = br.readLine()) != null) {
|
||||
sb.append(linePrefix);
|
||||
sb.append(line);
|
||||
sb.append(linePostfix);
|
||||
sb.append("\n");
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String hexColorFromRessourceColor(Context context, int idColor){
|
||||
return "#" + Integer.toHexString(context.getResources().getColor(idColor) & 0x00ffffff);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<com.github.dfa.diaspora_android.ui.HtmlTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/fragment_license__licensetext"
|
||||
android:text="@string/fragment_license__license_content"
|
||||
style="@android:style/TextAppearance.DeviceDefault.Small"
|
||||
android:linksClickable="true" />
|
||||
|
@ -39,7 +40,7 @@
|
|||
<com.github.dfa.diaspora_android.ui.HtmlTextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/fragment_license__3rd_party_libs_content"
|
||||
android:id="@+id/fragment_license__3rdparty"
|
||||
style="@android:style/TextAppearance.DeviceDefault.Small"
|
||||
android:linksClickable="true" />
|
||||
</LinearLayout>
|
||||
|
|
11
app/src/main/res/raw/license_third_party.tpl
Normal file
11
app/src/main/res/raw/license_third_party.tpl
Normal file
|
@ -0,0 +1,11 @@
|
|||
NEWENTRY NetCipher
|
||||
https://github.com/guardianproject/NetCipher
|
||||
|
||||
NEWENTRY ButterKnife
|
||||
https://jakewharton.github.io/butterknife
|
||||
|
||||
NEWENTRY Android Support Library
|
||||
https://developer.android.com/topic/libraries/support-library/index.html
|
||||
|
||||
NEWENTRY Android Design Library
|
||||
https://android-developers.blogspot.de/2015/05/android-design-support-library.html
|
5
app/src/main/res/raw/maintainers.tpl
Normal file
5
app/src/main/res/raw/maintainers.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
NEWENTRY Gregor Santner (gsantner)
|
||||
SUBTABBY https://gsantner.github.io
|
||||
|
||||
NEWENTRY Paul Schaub (vanitasvitae)
|
||||
SUBTABBY https://github.com/vanitasvitaes
|
|
@ -107,30 +107,11 @@
|
|||
|
||||
<!-- License & help (large amount of text) -->
|
||||
<string name="fragment_license__copyright_years" translatable="false">Copyright © 2015–2016</string>
|
||||
<string name="fragment_license__license_content" translatable="false"><b>Maintainers:</b><br>
|
||||
|
||||
• gsantner<br>
|
||||
https://gsantner.github.io<br>
|
||||
• Paul Schaub (vanitasvitae)<br>
|
||||
https://github.com/vanitasvitae<br> <br>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see<br>
|
||||
http://www.gnu.org/licenses.<br> <br>
|
||||
|
||||
<i>The splashscreen images can be found on flickr: <br>
|
||||
https://www.flickr.com/photos/129581906@N06/sets/72157651933980136/with/16594947123 <br>
|
||||
They were published by \"Lydia\" and are licensed under cc by-nc-sa.</i></string>
|
||||
<string name="fragment_license__license_content" translatable="false">
|
||||
<h2>Maintainers:</h2> %1$s
|
||||
<h2>Contributors:</h2> %2$s
|
||||
<h2>License:</h2> %3$s
|
||||
</string>
|
||||
<string name="about_activity__title_about_app">About</string>
|
||||
<string name="about_activity__title_about_license">License</string>
|
||||
<string name="about_activity__title_debug_info">Debugging</string>
|
||||
|
@ -157,15 +138,5 @@
|
|||
Also feel free to tell your friends about #DiasporaForAndroid!</string>
|
||||
<string name="lorem_ipsum" translatable="false">Auch gibt es niemanden, der den Schmerz an sich liebt, sucht oder wünscht, nur, weil er Schmerz ist, es sei denn, es kommt zu zufälligen Umständen, in denen Mühen und Schmerz ihm große Freude bereiten können. Um ein triviales Beispiel zu nehmen, wer von uns unterzieht sich je anstrengender körperlicher Betätigung, außer um Vorteile daraus zu ziehen? Aber wer hat irgend ein Recht, einen Menschen zu tadeln, der die Entscheidung trifft, eine Freude zu genießen, die keine unangenehmen Folgen hat, oder einen, der Schmerz vermeidet, welcher keine daraus resultierende Freude nach sich zieht? Auch gibt es niemanden, der den Schmerz an sich liebt, sucht oder wünscht, nur, weil er Schmerz ist, es sei denn, es kommt zu zufälligen Umständen, in denen Mühen und Schmerz ihm große Freude bereiten können. Um ein triviales Beispiel zu nehmen, wer von uns unterzieht sich je anstrengender körperlicher Betätigung, außer um Vorteile daraus zu ziehen? Aber wer hat irgend ein Recht, einen Menschen zu tadeln, der die Entscheidung trifft, eine Freude zu genießen, die keine unangenehmen Folgen hat, oder einen, der Schmerz vermeidet, welcher keine daraus resultierende Freude nach sich zieht?</string>
|
||||
<string name="fragment_license__3rd_party_libs_title">Used 3rd Party Libraries</string>
|
||||
<string name="fragment_license__3rd_party_libs_content" translatable="false">
|
||||
•Android Support Library:<br>
|
||||
https://developer.android.com/topic/libraries/support-library/index.html <br>
|
||||
•Anndroid Design Library:<br>
|
||||
https://android-developers.blogspot.de/2015/05/android-design-support-library.html <br>
|
||||
•NetCipher:<br>
|
||||
https://github.com/guardianproject/NetCipher <br>
|
||||
•ButterKnife:<br>
|
||||
https://jakewharton.github.io/butterknife/ <br>
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue