Skip to content

Commit

Permalink
Added default prayers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Saifullah Khan committed Oct 24, 2017
1 parent 592dab6 commit e730e75
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 29 deletions.
23 changes: 21 additions & 2 deletions app/src/main/java/pk/aspirasoft/tasbih/data/CounterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public class CounterManager extends ArrayList<Counter> {
private static CounterManager ourInstance;
private final Database database;

private boolean isInitialized = false;

private CounterManager(Activity activity) {
database = Database.getInstance(activity);
isInitialized = database.isInitialized();
diskIn();
}

Expand All @@ -22,6 +25,18 @@ public static CounterManager getInstance(Activity activity) throws NullPointerEx
return ourInstance;
}

public void addDefaultCounters(ArrayList<Counter> counters) {
for (Counter counter : counters) {
this.add(counter);
}
diskOut();
database.initialize();
}

public boolean isInitialized() {
return isInitialized;
}

public void diskOut() {
database.put(toString());
}
Expand All @@ -39,8 +54,12 @@ public void fromString(String counters) {

for (String s : counters.split("\n")) {
if (!s.replace("\t", "").replace(" ", "").equals("")) {
Counter counter = new Counter(s);
add(counter);
try {
Counter counter = new Counter(s);
add(counter);
} catch (ArrayIndexOutOfBoundsException ignored) {

}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/pk/aspirasoft/tasbih/data/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ static Database getInstance(Activity activity) throws NullPointerException {
return ourInstance;
}

void initialize() {
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("isInitialized", true);
editor.apply();
}

boolean isInitialized() {
return preferences.getBoolean("isInitialized", false);
}

void put(String value) {
SharedPreferences.Editor editor = preferences.edit();
editor.putString("counters", value);
Expand Down
44 changes: 44 additions & 0 deletions app/src/main/java/pk/aspirasoft/tasbih/scenes/LaunchScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;

import java.util.ArrayList;

import pk.aspirasoft.tasbih.R;
import pk.aspirasoft.tasbih.data.Counter;
import pk.aspirasoft.tasbih.data.CounterManager;

public class LaunchScreen extends AppCompatActivity {

Expand All @@ -16,6 +20,46 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.launch_screen);

CounterManager manager = CounterManager.getInstance(this);
if (!manager.isInitialized()) {
ArrayList<Counter> counters = new ArrayList<>();

Counter counter1 = new Counter(getString(R.string.counter_1), getString(R.string.counter_1_desc));
counter1.setMax(getResources().getInteger(R.integer.counter_1_max));

Counter counter2 = new Counter(getString(R.string.counter_2), getString(R.string.counter_2_desc));
counter2.setMax(getResources().getInteger(R.integer.counter_2_max));

Counter counter3 = new Counter(getString(R.string.counter_3), getString(R.string.counter_3_desc));
counter3.setMax(getResources().getInteger(R.integer.counter_3_max));

Counter counter4 = new Counter(getString(R.string.counter_4), getString(R.string.counter_4_desc));
counter4.setMax(getResources().getInteger(R.integer.counter_4_max));

Counter counter5 = new Counter(getString(R.string.counter_5), getString(R.string.counter_5_desc));
counter5.setMax(getResources().getInteger(R.integer.counter_5_max));

Counter counter6 = new Counter(getString(R.string.counter_6), getString(R.string.counter_6_desc));
counter6.setMax(getResources().getInteger(R.integer.counter_6_max));

Counter counter7 = new Counter(getString(R.string.counter_7), getString(R.string.counter_7_desc));
counter7.setMax(getResources().getInteger(R.integer.counter_7_max));

Counter counter8 = new Counter(getString(R.string.counter_8), getString(R.string.counter_8_desc));
counter8.setMax(getResources().getInteger(R.integer.counter_8_max));

counters.add(counter1);
counters.add(counter2);
counters.add(counter3);
counters.add(counter4);
counters.add(counter5);
counters.add(counter6);
counters.add(counter7);
counters.add(counter8);

manager.addDefaultCounters(counters);
}

countDownTimer = new CountDownTimer(1500, 1500) {
public void onTick(long millisUntilFinished) {
}
Expand Down
Binary file added app/src/main/res/drawable/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/list_row.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="100dp" />
<solid android:color="@color/colorAccent" />
<solid android:color="@color/colorPrimary" />
</shape>
56 changes: 37 additions & 19 deletions app/src/main/res/layout/counter_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,56 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/actionBar"
android:background="#fff"
android:background="@drawable/bg"
android:orientation="vertical"
android:weightSum="4">

<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:layout_marginBottom="5dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="vertical">
android:background="#CFFF">

<TextView
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_memo"
android:textColor="#000"
android:textStyle="bold" />
android:orientation="vertical"
android:padding="10dp">

<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="@string/placeholder_memo"
android:textColor="#000"
android:textStyle="normal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="@string/label_memo"
android:textColor="#000"
android:textStyle="bold" />

<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="@string/placeholder_memo"
android:textColor="#000"
android:textStyle="normal" />

</LinearLayout>

</LinearLayout>
</ScrollView>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_weight="3">

<com.google.android.gms.ads.AdView
Expand All @@ -64,6 +81,7 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:layout_marginTop="10dp"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ur/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources>
<string name="app_name">تسبیح</string>
<string name="app_version">تسبیح ١.١</string>
<string name="app_version">تسبیح 2.0</string>

<string name="title_counters">تسبیح ہوم</string>

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values/integers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="counter_1_max">33</integer>
<integer name="counter_2_max">33</integer>
<integer name="counter_3_max">34</integer>
<integer name="counter_4_max">100</integer>
<integer name="counter_5_max">100</integer>
<integer name="counter_6_max">100</integer>
<integer name="counter_7_max">100</integer>
<integer name="counter_8_max">3</integer>
</resources>
42 changes: 36 additions & 6 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
<string name="app_id" translatable="false">5243770836</string>
<string name="ad_unit_id" translatable="false">ca-app-pub-6293532072634065/4510334430</string>

<string name="title_counters">Prayers</string>
<string name="title_counters">Tasbih</string>

<string name="placeholder_memo">No translation added.</string>
<string name="placeholder_memo">No description added.</string>

<string name="label_add">Add</string>x
<string name="label_add_description">Add a new prayer.</string>
<string name="label_add_description">Create Tasbih</string>
<string name="label_decrement">Minus</string>
<string name="label_increment">Plus</string>

<string name="label_name">Name</string>
<string name="label_name">Title</string>
<string name="label_name_description">Name of the prayer.</string>

<string name="label_memo">Translation</string>
<string name="label_memo_description">(Optional) Notes about the counter e.g. recite 1000 times daily, read 100 times on Fridays, etc.</string>
<string name="label_memo">Description</string>
<string name="label_memo_description">Prayer\'s details.</string>

<string name="label_yes">Okay</string>
<string name="label_no">Cancel</string>
Expand All @@ -31,4 +31,34 @@
<string name="delete_confirmation">Do you really want to delete the counter? Proceed with caution. This action is permanent.</string>
<string name="reset_confirmation">This action would reset the counter value. Proceed with caution.</string>
<string name="label_finished">Finished: %1$d</string>

<string name="counter_1">الحمد لله</string>
<string name="counter_1_desc">All the praises and thanks be to Allah</string>

<string name="counter_2">سبحان الله</string>
<string name="counter_2_desc">(37: 159–160) Exalted is Allah above what they describe, except the chosen servants of Allah [who do not share in that sin].</string>

<string name="counter_3">الله أكبر</string>
<string name="counter_3_desc">Allah is the Greatest</string>

<string name="counter_4">بسم الله</string>
<string name="counter_4_desc">بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ</string>

<string name="counter_5">درود إبراهيمي</string>
<string name="counter_5_desc">اللَّهُمَّ صَلِّ عَلَى مُحَمَّدٍ وَعَلَى آلِ مُحَمَّدٍ.
كَمَا صَلَّيْتَ عَلَى إِبْرَاهِيمَ وَعَلَى آلِ إِبْرَاهِيمَ.
.إِنَّكَ حَمِيدٌ مَجِيدٌ.
اللَّهُمَّ بَارِكْ عَلَى مُحَمَّدٍ، وَعَلَى آلِ مُحَمَّدٍ.
كَمَا بَارَكْتَ عَلَى إِبْرَاهِيمَ وَعَلَى آلِ إِبْرَاهِيمَ.
.إِنَّكَ حَمِيدٌ مَجِيدٌ.</string>

<string name="counter_6">آية الكرسي</string>
<string name="counter_6_desc">اللّهُ لاَ إِلَـهَ إِلاَّ هُوَ الْحَيُّ الْقَيُّومُ لاَ تَأْخُذُهُ سِنَةٌ وَلاَ نَوْمٌ لَّهُ مَا فِي السَّمَوَاتِ وَمَا فِي الأَرْضِ مَن ذَا الَّذِي يَشْفَعُ عِنْدَهُ إِلاَّ بِإِذْنِهِ يَعْلَمُ مَا بَيْنَ أَيْدِيهِمْ وَمَا خَلْفَهم وَلاَ يُحِيطُونَ بِشَيْءٍ مِّنْ عِلْمِهِ إِلاَّ بِمَا شَاء وَسِعَ كُرْسِيُّهُ السَّمَوَاتِ وَالأَرْضَ وَلاَ يَؤُودُهُ حِفْظُهُمَا وَهُوَ الْعَلِيُّ الْعَظِيمُ</string>

<string name="counter_7">سُّورَةُ الْفَاتِحَة‎</string>
<string name="counter_7_desc">ٱلْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ. ٱلرَّحْمَٰنِ ٱلرَّحِيمِ. مٰالِكِ يَوْمِ ٱلدِّينِ. إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ. ٱهْدِنَا الصِّرَاطَ ٱلْمُسْتَقِيمَ. صِرَاطَ ٱلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِٱلْمَغْضُوبِ عَلَيْهِمْ وَلَا ٱلضَّآلِّين</string>

<string name="counter_8">سورة الإخلاص</string>
<string name="counter_8_desc">قُلْ هُوَ ٱللَّهُ أَحَدٌ. ٱللَّهُ ٱلصَّمَدُ. لَمْ يَلِدْ وَلَمْ يُولَدْ. وَلَمْ يَكُن لَّهُۥ كُفُوًا أَحَدٌۢ</string>

</resources>

0 comments on commit e730e75

Please sign in to comment.