Advertisement
Guest User

Untitled

a guest
Jul 16th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 62.37 KB | None | 0 0
  1. package com.iran.sunni.time;
  2.  
  3. import java.io.IOException;
  4. import java.text.DateFormat;
  5. import java.text.ParseException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Calendar;
  9. import java.util.Date;
  10. import java.util.Locale;
  11. import java.util.Timer;
  12. import java.util.TimerTask;
  13.  
  14. import android.app.Activity;
  15. import android.app.AlarmManager;
  16. import android.app.Dialog;
  17. import android.app.Notification;
  18. import android.app.NotificationManager;
  19. import android.app.PendingIntent;
  20. import android.content.Context;
  21. import android.content.Intent;
  22. import android.graphics.Typeface;
  23. import android.graphics.drawable.ColorDrawable;
  24. import android.os.Bundle;
  25. import android.view.KeyEvent;
  26. import android.view.View;
  27. import android.view.View.OnClickListener;
  28. import android.view.Window;
  29. import android.view.WindowManager;
  30. import android.widget.ImageView;
  31. import android.widget.LinearLayout;
  32. import android.widget.RadioButton;
  33. import android.widget.ScrollView;
  34. import android.widget.Spinner;
  35. import android.widget.TextView;
  36.  
  37. import com.google.android.gms.ads.AdListener;
  38. import com.google.android.gms.ads.AdRequest;
  39. import com.google.android.gms.ads.AdView;
  40.  
  41. public class PrayerTimeActivity extends Activity {
  42.  
  43. TextView fajarTime, ishraTime, zuharTime, asarTime, margibTime, ishaTime,
  44. dateText, timeText,
  45. countryText, // qiblaDirection,//cityText,
  46. diffText, fajarText, zuharText, asarText, magribText, ishaText,
  47. sunRiseText, islmaicTimeText;
  48. private ScrollView scrollView;
  49. Spinner citySpinner;
  50. String hijriMonthName[];
  51. int notificationId = 1;
  52. NotificationManager notificationManager;
  53. public MyDailoag customDialog = new MyDailoag(this);
  54. LinearLayout fajarLayout, sunRiseLayout, zuharLayout, asarLayout,
  55. magribLayout, ishaLayout, prayerLayout, qiblaLayout, settingLayout;
  56. ImageView imgPrayer, imgQibla, imgSettings;// imgCalendar,imgMore;
  57. private final String DEV_HASH = "5725V9X2K1PEBJZK4HMN3YRUYS5WB";
  58. public static final long INTERVAL_FIFTEEN_MINUTES = 15 * 60 * 1000;
  59. public static final long INTERVAL_HALF_HOUR = 2 * INTERVAL_FIFTEEN_MINUTES;
  60. public static final long INTERVAL_HOUR = 2 * INTERVAL_HALF_HOUR;
  61. public static final long INTERVAL_HALF_DAY = 12 * INTERVAL_HOUR;
  62. public static final long INTERVAL_DAY = 2 * INTERVAL_HALF_DAY;
  63.  
  64. private static int adNo = 0;
  65. public Country countryData = new Country(this);
  66.  
  67. public static ArrayList<String> paryerData = null;
  68. public ArrayList<String> paryerData1 = null;
  69. public String fajaralarm = "true", zuharAlarm = "true",
  70. asarAlarm = "true", magribAlarm = "true", ishaAlarm = "true";
  71. ImageView fajarAudio, sunRiseAudio, zuharAudio, asarAudio, magribAudio,
  72. ishaAudio;
  73. int i = 3;
  74. boolean fajarCheck = true, sunRiseCheck = true, zuharCheck = true,
  75. asarCheck = true, magribCheck = true, ishaCheck = true,
  76. showDialog = true;
  77. Timer timer = new Timer();
  78. TimerTask timer1;
  79. // LinearLayout ltcountry;
  80. public String calMethod = "3";
  81. String[] calMethods;
  82. public static Context context;
  83. public static ArrayList<String> getData = new ArrayList<String>();
  84. public static ArrayList<String> country = new ArrayList<String>();
  85. public static ArrayList<String> cites = new ArrayList<String>();
  86. public static ArrayList<String> latitude = new ArrayList<String>();
  87. public static ArrayList<String> timeZone = new ArrayList<String>();
  88. public static ArrayList<String> longitude = new ArrayList<String>();
  89.  
  90. RadioButton hanfi, shafi;
  91. public static String lati, longi, qibla, currentCounty, currentCity,
  92. timezone;
  93. String firka = "Shafi";
  94.  
  95. // ListView menu_dialog;
  96.  
  97. public PrayerTimeActivity() {
  98. context = this;
  99.  
  100. }
  101.  
  102. public void setAlarmImage() {
  103. if (Settings.storeData.getTextData("audio").equals("")) {
  104.  
  105. //////////// On all prayer times
  106. fajaralarm = "true";
  107. fajarCheck = false;
  108. setAlarm(paryerData.get(0), 0);
  109. fajarAudio.setImageResource(R.drawable.sound_on);
  110.  
  111. zuharAlarm = "true";
  112. zuharCheck = false;
  113. setAlarm(paryerData.get(2), 2);
  114. zuharAudio.setImageResource(R.drawable.sound_on);
  115.  
  116. asarAlarm = "true";
  117. asarCheck = false;
  118. setAlarm(paryerData.get(3), 3);
  119. asarAudio.setImageResource(R.drawable.sound_on);
  120.  
  121. magribAlarm = "true";
  122. magribCheck = false;
  123. setAlarm(paryerData.get(4), 4);
  124. magribAudio.setImageResource(R.drawable.sound_on);
  125.  
  126. ishaAlarm = "true";
  127. ishaCheck = false;
  128. setAlarm(paryerData.get(5), 5);
  129. ishaAudio.setImageResource(R.drawable.sound_on);
  130.  
  131. } else {
  132.  
  133. String[] highlight = Settings.storeData.getTextData("audio").split(
  134. ",");
  135. if (highlight[0].equals("true")) {
  136. fajaralarm = "true";
  137. fajarCheck = false;
  138. setAlarm(paryerData.get(0), 0);
  139. fajarAudio.setImageResource(R.drawable.sound_on);
  140.  
  141. } else {
  142. fajaralarm = "false";
  143. fajarCheck = true;
  144. removeAlarm(paryerData.get(0), 0);
  145. fajarAudio.setImageResource(R.drawable.sound_off);
  146.  
  147. }
  148. if (highlight[1].equals("true")) {
  149. zuharAlarm = "true";
  150. zuharCheck = false;
  151. setAlarm(paryerData.get(2), 2);
  152. zuharAudio.setImageResource(R.drawable.sound_on);
  153.  
  154. } else {
  155. zuharAlarm = "false";
  156. zuharCheck = true;
  157. removeAlarm(paryerData.get(2), 2);
  158. zuharAudio.setImageResource(R.drawable.sound_off);
  159.  
  160. }
  161. if (highlight[2].equals("true")) {
  162. asarAlarm = "true";
  163. asarCheck = false;
  164. setAlarm(paryerData.get(3), 3);
  165. asarAudio.setImageResource(R.drawable.sound_on);
  166.  
  167. } else {
  168. asarAlarm = "false";
  169. asarCheck = true;
  170. removeAlarm(paryerData.get(3), 3);
  171. asarAudio.setImageResource(R.drawable.sound_off);
  172.  
  173. }
  174. if (highlight[3].equals("true")) {
  175. magribAlarm = "true";
  176. magribCheck = false;
  177. setAlarm(paryerData.get(4), 4);
  178. magribAudio.setImageResource(R.drawable.sound_on);
  179.  
  180. } else {
  181. magribAlarm = "false";
  182. magribCheck = true;
  183. removeAlarm(paryerData.get(4), 4);
  184. magribAudio.setImageResource(R.drawable.sound_off);
  185.  
  186. }
  187. if (highlight[4].equals("true")) {
  188. ishaAlarm = "true";
  189. ishaCheck = false;
  190. setAlarm(paryerData.get(5), 5);
  191. ishaAudio.setImageResource(R.drawable.sound_on);
  192.  
  193. } else {
  194. ishaAlarm = "false";
  195. ishaCheck = true;
  196. removeAlarm(paryerData.get(5), 5);
  197. ishaAudio.setImageResource(R.drawable.sound_off);
  198.  
  199. }
  200.  
  201. }
  202. }
  203.  
  204. public void readFile()
  205. {
  206. getData.clear();
  207. country.clear();
  208. cites.clear();
  209. latitude.clear();
  210. longitude.clear();
  211. timeZone.clear();
  212.  
  213. try
  214. {
  215. countryData.getAllCountires();
  216.  
  217. int index = 0;
  218.  
  219. if (Settings.storeData.getTextData("text").equals("")) {
  220. ArrayList<ArrayList<String>> value = countryData
  221. .getAllDataCities("Iran");
  222. country = countryData.myCountries;
  223. cites = value.get(0);
  224. latitude = value.get(1);
  225. longitude = value.get(2);
  226. timeZone = value.get(4);
  227. calMethod = "3";
  228. } else {
  229. String value = Settings.storeData.getTextData("text");
  230. String[] str = Settings.storeData.getTextData("text").split(",");
  231. int countyCode = countryData.myCountries.indexOf("Iran");
  232. ArrayList<ArrayList<String>> list = countryData
  233. .getAllDataCities(str[0]);
  234. cites = list.get(0);
  235. latitude = list.get(1);
  236. longitude = list.get(2);
  237. timeZone = list.get(4);
  238. calMethod = "" + Integer.parseInt((str[7]));
  239.  
  240. }
  241. }
  242. catch(Exception e)
  243. {
  244.  
  245. e.printStackTrace();
  246. }
  247.  
  248. }
  249.  
  250. public void onWindowFocusChanged(boolean hasFocus) {
  251. super.onWindowFocusChanged(hasFocus);
  252. if (!hasFocus) {
  253.  
  254. String saveString = fajaralarm + "," + zuharAlarm + "," + asarAlarm
  255. + "," + magribAlarm + "," + ishaAlarm;
  256. Settings.storeData.saveTextData("audio", saveString);
  257.  
  258. /*
  259. * if(imgPrayer!=null) {
  260. * imgPrayer.setImageResource(R.drawable.prayertab_on);
  261. * imgQibla.setImageResource(R.drawable.qiblahtab_off);
  262. * imgSettings.setImageResource(R.drawable.settingtab_off);
  263. * //imgMore.setImageResource(R.drawable.moretab_off);
  264. * //imgCalendar.setImageResource(R.drawable.calendertab_off); }
  265. */} else if (!showDialog) {
  266.  
  267. showDialog = false;
  268. showMenu();
  269. }
  270.  
  271. }
  272.  
  273. public void setNotification(String time) {
  274. String serName = Context.NOTIFICATION_SERVICE;
  275. notificationManager = (NotificationManager) getSystemService(serName);
  276. // define notification using: icon, text, and timing.
  277. int icon = R.drawable.ic_launcher;
  278. String tickerText = "1. My Notification TickerText";
  279. long when = System.currentTimeMillis();
  280. Notification notification = new Notification(icon, tickerText, when);
  281. // configure appearance of the notification
  282. String extendedTitle = getString(R.string.app_name);
  283. String extendedText = "It's " + time + " Prayer Time";
  284. // set a Pending Activity to take care of the potential request the user
  285. // may have by clicking on the notification asking for more explanations
  286. Intent intent = new Intent(getApplicationContext(),
  287. PrayerTimeActivity.class);
  288. intent.putExtra("extendedText", extendedText);
  289. intent.putExtra("extendedTitle", extendedTitle);
  290. PendingIntent launchIntent = PendingIntent.getActivity(
  291. getApplicationContext(), 0, intent, 0);
  292.  
  293. notification.setLatestEventInfo(getApplicationContext(), extendedTitle,
  294. extendedText, launchIntent);
  295. // trigger notification
  296. notificationId = 1;
  297. notificationManager.notify(notificationId, notification);
  298. }
  299.  
  300. public void onCreate(Bundle savedInstanceState) {
  301. super.onCreate(savedInstanceState);
  302. this.requestWindowFeature(Window.FEATURE_NO_TITLE);
  303. this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  304. WindowManager.LayoutParams.FLAG_FULLSCREEN);
  305. setContentView(R.layout.main);
  306. initGui();
  307.  
  308. calMethods = new String[] { getResources().getString(R.string.ummal_qura_makkah),
  309. getResources().getString(R.string.university_of_islamic_science_karachi), getResources().getString(R.string.muslim_world_league),
  310. getResources().getString(R.string.muslim_world_league_iran),getResources().getString(R.string.egypton_general_authority_of_survey),
  311. getResources().getString(R.string.islamic_society_of_north_america) };
  312.  
  313. hijriMonthName = new String[] { getString(R.string.muharram), getString(R.string.Safar), getString(R.string.rabiulawal),
  314. getString(R.string.rabiulsani), getString(R.string.jamadiulawal), getString(R.string.jamadiulakhir), getString(R.string.Rajab),
  315. getString(R.string.shaban), getString(R.string.ramadan), getString(R.string.shawal), getString(R.string.zeqad),
  316. getString(R.string.zilhajj) };
  317.  
  318. setListener();
  319.  
  320. readFile();
  321.  
  322. selectCountryAndValues();
  323. calculateParyerTime();
  324. setIslamicDate();
  325. setAlarmImage();
  326. startTimer();
  327. }
  328.  
  329. public void setIslamicDate() {
  330. Date date = new Date();
  331. islmaicTimeText.setText(""
  332. + getIslamicTime(date.getYear() + 1900, date.getMonth() + 1,
  333. date.getDate()));
  334. }
  335.  
  336. public void selectCountryAndValues() {
  337.  
  338. if (Settings.storeData.getTextData("text").equals("")) {
  339.  
  340. countryText.setText(cites.get(cites.indexOf("Tehran")) + ", "
  341. + country.get(country.indexOf("Iran")));
  342. currentCounty = country.get(country.indexOf("Iran"));
  343. // cityText.setText(cites.get(0));
  344. currentCity = cites.get(cites.indexOf("Tehran"));
  345. timezone = timeZone.get(cites.indexOf("Tehran"));
  346. lati = latitude.get(cites.indexOf("Tehran"));
  347. longi = longitude.get(cites.indexOf("Tehran"));
  348. firka = getString(R.string.shafi);
  349. } else {
  350. String[] values = Settings.storeData.getTextData("text").split(",");
  351. countryText.setText(values[1] + ", " + values[0]);
  352. currentCounty = values[0];
  353. // cityText.setText(values[1]);
  354. currentCity = values[1];
  355. lati = values[2];
  356. longi = values[3];
  357. qibla = values[4];
  358.  
  359. firka = values[5];
  360. timezone = values[6];
  361. }
  362.  
  363. }
  364.  
  365. public String getDayFromDate(int year, int month, int day)
  366. throws ParseException {
  367.  
  368. String dateString = String.format("%d-%d-%d", year, month, day);
  369. Date date = new SimpleDateFormat("yyyy-M-d").parse(dateString);
  370.  
  371. // Then get the day of week from the Date based on specific locale.
  372. String dayOfWeek = new SimpleDateFormat("EEEE", Locale.ENGLISH)
  373. .format(date);
  374. String monthName = new SimpleDateFormat("MMM").format(date);
  375. return dayOfWeek;
  376. }
  377.  
  378. public String getMonthFromDate(int year, int month, int day)
  379. throws ParseException {
  380.  
  381. String dateString = String.format("%d-%d-%d", year, month, day);
  382. Date date = new SimpleDateFormat("yyyy-M-d").parse(dateString);
  383.  
  384. // Then get the day of week from the Date based on specific locale.
  385. ;
  386. String monthName = new SimpleDateFormat("MMM").format(date);
  387. return monthName;
  388. }
  389.  
  390. public void calculateParyerTime() {
  391. // calcuate current System time
  392. PrayTime pt = new PrayTime(this);
  393. Calendar cal = Calendar.getInstance();
  394.  
  395. DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd/hh/mm/a");
  396. Date date = new Date();
  397. int hour = date.getHours();
  398. int min = date.getMinutes();
  399.  
  400. String yourDate = dateFormat.format(cal.getTime());
  401.  
  402. // calculate paryer Times
  403. String[] time = yourDate.split("/");
  404. int currenthourTime = 0;
  405. int currentminTime = 0;
  406. try {
  407. String dayName = getDayFromDate(Integer.parseInt(time[0]),
  408. Integer.parseInt(time[1]), Integer.parseInt(time[2]));
  409. String monthName = getMonthFromDate(Integer.parseInt(time[0]),
  410. Integer.parseInt(time[1]), Integer.parseInt(time[2]));
  411. dateText.setText(dayName.substring(0, 3) + ", " + time[2] + " "
  412. + monthName);
  413. String text = time[3] + ":" + time[4] + " " + time[5];
  414. //Typeface type = Typeface.createFromAsset(getAssets(),
  415. // "fonts/DS-DIGIT.TTF");
  416. //timeText.setTypeface(type);
  417. String ampm="";
  418. if (time[5].equals("pm")) {
  419. ampm = ""+ getString(R.string.pm);
  420. } else {
  421. ampm = ""+ getString(R.string.am);
  422. }
  423. timeText.setText(time[3] + ":" + time[4] + " " + ampm);
  424. currenthourTime = Integer.parseInt(time[3]);
  425. currentminTime = Integer.parseInt(time[4]);
  426.  
  427. } catch (NumberFormatException e) {
  428.  
  429. e.printStackTrace();
  430. } catch (ParseException e) {
  431. // TODO Auto-generated catch block
  432. e.printStackTrace();
  433. }
  434. if (firka.equals(getString(R.string.hanfi))) {
  435. pt.setAsrJuristic(pt.Hanafi);
  436. pt.getHanafi();
  437. } else {
  438. pt.setAsrJuristic(pt.Shafii);
  439. pt.getShafii();
  440. }
  441. calculasMethod(pt);
  442. pt.setAdjustHighLats(pt.AngleBased);
  443. int[] offsets = { 0, 0, 0, 0, 0, 0, 0 }; // {Fajr,Sunrise,Dhuhr,Asr,Sunset,Maghrib,Isha}
  444. pt.tune(offsets);
  445.  
  446. double valuee = adjustLatitude(lati);
  447. double value1 = adjustLongitude(longi);
  448. // getQiblaDriectionFromLatiLongi(valuee+"", value1+"");
  449. paryerData = pt.getDatePrayerTimes(Integer.parseInt(time[0]),
  450. Integer.parseInt(time[1]), Integer.parseInt(time[2]),
  451. adjustLatitude(lati), adjustLongitude(longi),
  452. Double.parseDouble(timezone));
  453. paryerData.remove(paryerData.size() - 2);
  454. ArrayList<String> am_pmList;
  455. applyDayNightSetting();
  456. ajustTime();
  457.  
  458. /////////Add hour in prayer times//////
  459. paryerData1 = paryerData;
  460. adjustOneHourTime();
  461. String setDuration = getTimeDiff(paryerData, Integer.parseInt(time[3]),
  462. Integer.parseInt(time[4]), time[5]);
  463. String[] value = setDuration.split(":");
  464. hightlistParyerTime(Integer.parseInt(value[2]));
  465. if (Integer.parseInt(value[0]) == 0) {
  466. if (Integer.parseInt(value[1]) != 0) {
  467. diffText.setText(pt.timeNames.get(Integer.parseInt(value[2]))
  468. + " "+getString(R.string.after)+" " + value[1] + " "+getString(R.string.mins));
  469. } else {
  470. diffText.setText(getString(R.string.time) +" "+getString(R.string.namaz) +" "+
  471. pt.timeNames.get(Integer.parseInt(value[2])));
  472. }
  473. } else {
  474. diffText.setText(pt.timeNames.get(Integer.parseInt(value[2]))
  475. + " "+getString(R.string.after)+" " + value[0] + " "+getString(R.string.hour)+" "+getString(R.string.and)
  476. +" " + value[1] + " "+getString(R.string.mins));
  477. }
  478. // pt.setTimeFormat(pt.Time12);
  479. am_pmList = setFormate(paryerData);
  480. fajarTime.setText(setTimeFormat(paryerData.get(0)) + " "
  481. + am_pmList.get(0));
  482. ishraTime.setText(setTimeFormat(paryerData.get(1)) + " "
  483. + am_pmList.get(1));
  484. zuharTime.setText(setTimeFormat(paryerData.get(2)) + " "
  485. + am_pmList.get(2));
  486. asarTime.setText(setTimeFormat(paryerData.get(3)) + " "
  487. + am_pmList.get(3));
  488. margibTime.setText(setTimeFormat(paryerData.get(4)) + " "
  489. + am_pmList.get(4));
  490. ishaTime.setText(setTimeFormat(paryerData.get(5)) + " "
  491. + am_pmList.get(5));
  492.  
  493. }
  494.  
  495. public void getQiblaDriectionFromLatiLongi(String lati, String longi) {
  496. double direction = QiblaDirectionCalculator.getQiblaDirectionFromNorth(
  497. Double.parseDouble(lati), Double.parseDouble(longi)) + 10;
  498. // qiblaDirection.setText("Qiblah: "+new
  499. // DecimalFormat("###.####").format(direction) + " clockwise");
  500. }
  501.  
  502. public Double adjustLatitude(String lati) {
  503. Double laty = Double.parseDouble(lati);
  504. if (!lati.contains(".")) {
  505. laty = laty / 10000;
  506. } else {
  507. laty = Double.parseDouble(lati);
  508. }
  509.  
  510. return laty;
  511. }
  512.  
  513. public Double adjustLongitude(String longi) {
  514. Double longy = Double.parseDouble(longi);
  515. if (!longi.contains(".")) {
  516. longy = longy / 10000;
  517. } else {
  518. longy = Double.parseDouble(longi);
  519. }
  520.  
  521. return longy;
  522. }
  523.  
  524. public void ajustTime() {
  525. {
  526. String dtFajarSetting = Settings.storeData.getTextData("At0");
  527. if (!dtFajarSetting.equals("")) {
  528. String[] dnValue = dtFajarSetting.split(",");
  529. int index = Integer.parseInt(dnValue[0]);
  530. int totalMin = Integer.parseInt(dnValue[1]);
  531. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  532. paryerData.remove(index + 1);
  533. }
  534. }
  535.  
  536. // ----------------------------------
  537.  
  538. {
  539. String dtSunRiseSetting = Settings.storeData.getTextData("At1");
  540. if (!dtSunRiseSetting.equals("")) {
  541. String[] dnValue = dtSunRiseSetting.split(",");
  542. int index = Integer.parseInt(dnValue[0]);
  543. int totalMin = Integer.parseInt(dnValue[1]);
  544. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  545. paryerData.remove(index + 1);
  546. }
  547. }
  548.  
  549. // ---------------------------
  550.  
  551. {
  552. String dtZuharSetting = Settings.storeData.getTextData("At2");
  553. if (!dtZuharSetting.equals("")) {
  554. String[] dnValue = dtZuharSetting.split(",");
  555. int index = Integer.parseInt(dnValue[0]);
  556. int totalMin = Integer.parseInt(dnValue[1]);
  557. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  558. paryerData.remove(index + 1);
  559. }
  560. }
  561.  
  562. // ---------------------------------------
  563.  
  564. {
  565. String dtAsarSetting = Settings.storeData.getTextData("At3");
  566. if (!dtAsarSetting.equals("")) {
  567. String[] dnValue = dtAsarSetting.split(",");
  568. int index = Integer.parseInt(dnValue[0]);
  569. int totalMin = Integer.parseInt(dnValue[1]);
  570. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  571. paryerData.remove(index + 1);
  572. }
  573. }
  574.  
  575. {
  576. String dtMagribSetting = Settings.storeData.getTextData("At4");
  577. if (!dtMagribSetting.equals("")) {
  578. String[] dnValue = dtMagribSetting.split(",");
  579. int index = Integer.parseInt(dnValue[0]);
  580. int totalMin = Integer.parseInt(dnValue[1]);
  581. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  582. paryerData.remove(index + 1);
  583. }
  584.  
  585. }
  586. {
  587. String dtIshaSetting = Settings.storeData.getTextData("At5");
  588. if (!dtIshaSetting.equals("")) {
  589. String[] dnValue = dtIshaSetting.split(",");
  590. int index = Integer.parseInt(dnValue[0]);
  591. int totalMin = Integer.parseInt(dnValue[1]);
  592. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  593. paryerData.remove(index + 1);
  594. }
  595. }
  596. }
  597.  
  598. public void adjustOneHourTime() {
  599. int index = 0;
  600. int totalMin;
  601. {
  602. String dtFajarSetting = Settings.storeData.getTextData("At0");
  603. //if (!dtFajarSetting.equals("")) {
  604. String[] dnValue = dtFajarSetting.split(",");
  605.  
  606. totalMin = 60;
  607. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  608. paryerData.remove(index + 1);
  609. //}
  610. }
  611.  
  612. // ----------------------------------
  613. index++;
  614. {
  615. String dtSunRiseSetting = Settings.storeData.getTextData("At1");
  616. //if (!dtSunRiseSetting.equals("")) {
  617. // String[] dnValue = dtSunRiseSetting.split(",");
  618. //int index = Integer.parseInt(dnValue[0]);
  619. totalMin = 60;
  620. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  621. paryerData.remove(index + 1);
  622. //}
  623. }
  624.  
  625. // ---------------------------
  626. index++;
  627. {
  628. String dtZuharSetting = Settings.storeData.getTextData("At2");
  629. //if (!dtZuharSetting.equals("")) {
  630. //String[] dnValue = dtZuharSetting.split(",");
  631. //int index = Integer.parseInt(dnValue[0]);
  632. totalMin = 60;
  633. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  634. paryerData.remove(index + 1);
  635. //}
  636. }
  637.  
  638. // ---------------------------------------
  639. index++;
  640. {
  641. /*if (firka.equals(getString(R.string.shafi))) {
  642. totalMin = -19;
  643. } else {
  644. totalMin = 57;
  645. }*/
  646. totalMin = 60;
  647.  
  648. String dtAsarSetting = Settings.storeData.getTextData("At3");
  649. //if (!dtAsarSetting.equals("")) {
  650. //String[] dnValue = dtAsarSetting.split(",");
  651. //int index = Integer.parseInt(dnValue[0]);
  652.  
  653. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  654. paryerData.remove(index + 1);
  655. //}
  656.  
  657. }
  658. index++;
  659. {
  660. String dtMagribSetting = Settings.storeData.getTextData("At4");
  661. //if (!dtMagribSetting.equals("")) {
  662. //String[] dnValue = dtMagribSetting.split(",");
  663. //int index = Integer.parseInt(dnValue[0]);
  664. totalMin = 60;
  665. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  666. paryerData.remove(index + 1);
  667. //}
  668.  
  669. }
  670. index++;
  671. {
  672. String dtIshaSetting = Settings.storeData.getTextData("At5");
  673. // if (!dtIshaSetting.equals("")) {
  674. // String[] dnValue = dtIshaSetting.split(",");
  675. //int index = Integer.parseInt(dnValue[0]);
  676. totalMin = 60;
  677. paryerData.add(index, addMin(totalMin, paryerData.get(index)));
  678. paryerData.remove(index + 1);
  679. //}
  680. }
  681. }
  682.  
  683. public void applyDayNightSetting() {
  684. String dnSetting = Settings.storeData.getTextData("dn");
  685. if (dnSetting.equals(""))
  686. return;
  687. String[] dnValue = dnSetting.split(",");
  688. int totalMin = Integer.parseInt(dnValue[1]);
  689. if (dnValue[0].equals("true")) {
  690. for (int i = 0; i < paryerData.size(); i++) {
  691. paryerData
  692. .add(i,
  693. set24HourFormate(
  694. addMin(totalMin, paryerData.get(i)), i));
  695. paryerData.remove(i + 1);
  696. }
  697. }
  698. }
  699.  
  700. public void SetAlarm(Context context) {
  701. // AlarmManager
  702. // am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
  703. // Intent intent = new Intent(context, AlarmActivity.class);
  704. // PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0);
  705. // After after 30 seconds
  706. // am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),
  707. // 1000 , pi);
  708. }
  709.  
  710. public void calculasMethod(PrayTime pt) {
  711. if (calMethod.equals("0")) {
  712. pt.setCalcMethod(pt.Makkah);
  713. }
  714. if (calMethod.equals("1")) {
  715. pt.setCalcMethod(pt.Karachi);
  716. }
  717. if (calMethod.equals("2")) {
  718. pt.setCalcMethod(pt.MWL);
  719. }
  720. if (calMethod.equals("3")) {
  721. pt.setCalcMethod(pt.MWL);
  722. }
  723. if (calMethod.equals("4")) {
  724. pt.setCalcMethod(pt.Egypt);
  725. }
  726. if (calMethod.equals("5")) {
  727. pt.setCalcMethod(pt.ISNA);
  728. }
  729.  
  730. }
  731.  
  732. public String set24HourFormate(String prayerMin, int index) {
  733. String[] str = prayerMin.split(":");
  734. int hour = Integer.parseInt(str[0]);
  735. int min = Integer.parseInt(str[1]);
  736. if (index > 1) {
  737.  
  738. hour = hour + 12;
  739.  
  740. }
  741. return hour + ":" + min + "";
  742. }
  743.  
  744. public static String applyAlermelay(String time, int index) {
  745.  
  746. int totalMin = Integer.parseInt(time);
  747. String value = addMin(totalMin, paryerData.get(index));
  748. return addDelayMin(totalMin, paryerData.get(index));
  749.  
  750. }
  751.  
  752. public static String addMin(int mins, String prayerMin) {
  753. String[] str = prayerMin.split(":");
  754. int hour = Integer.parseInt(str[0]);
  755. int min = Integer.parseInt(str[1]);
  756. min = min + mins;
  757. if (min >= 60) {
  758. int h = (int) min / 60;
  759. hour += h;
  760. int m = (int) min % 60;
  761. min = m;
  762. }
  763. if (min < 0) {
  764. int h = (int) min / 60;
  765. hour = hour + (h - 1);
  766. int m = 60 + (int) min % 60;
  767. min = m;
  768. }
  769. return hour + ":" + min + "";
  770. }
  771.  
  772. public static String addDelayMin(int mins, String prayerMin) {
  773. String[] str = prayerMin.split(":");
  774. int hour = Integer.parseInt(str[0]);
  775. int min = Integer.parseInt(str[1]);
  776. min = min + mins;
  777. if (min >= 60) {
  778. hour = (hour + (int) min / 60);
  779. if (hour == 0)
  780. hour = 1;
  781. min = min % 60;
  782. } else {
  783. hour = hour % 12;
  784. if (hour == 0)
  785. hour = 12;
  786. min = min % 60;
  787. }
  788. return hour + ":" + min + "";
  789. }
  790.  
  791. public static String getTimeDiff(ArrayList<String> paryer,
  792. int currenthourTime, int currentminTime, String formate) {
  793. String[] getMin = paryer.get(1).split(" ");
  794. String diff = "";
  795. ArrayList<String> resultTime = new ArrayList<String>();
  796. String time1 = "", time2 = "", resultHour = "", resultMin = "0";
  797. Date date = null;
  798. // if(formate.equals(getMin[1].toUpperCase()))
  799. date = new Date("12/12/11 " + currenthourTime + ":" + currentminTime
  800. + ":" + "00 " + formate);
  801. time1 = new SimpleDateFormat("HH").format(date);
  802. time2 = new SimpleDateFormat("mm").format(date);
  803. int paryerH = 0, currentH = 0;
  804. String[] times = null;
  805. for (int i = 0; i < paryer.size(); i++) {
  806. // if (i == 4)
  807. // continue;
  808. times = paryer.get(i).split(":");
  809. paryerH = Integer.parseInt(times[0]);
  810. currentH = Integer.parseInt(time1);
  811. if (paryerH >= currentH) {
  812. resultHour = ""
  813. + (Integer.parseInt(times[0]) - Integer.parseInt(time1));
  814.  
  815. if ((Integer.parseInt(times[1]) < Integer.parseInt(time2))) {
  816.  
  817. int remainMin = 60 - Integer.parseInt(time2);
  818. int remainHour = (Integer.parseInt(resultHour));
  819. if (remainHour <= 0) {
  820. resultMin = Integer.parseInt(time2)
  821. - Integer.parseInt(times[1]) + "";
  822. continue;
  823. }
  824. remainHour--;
  825. remainMin = remainMin + (Integer.parseInt(times[1]));
  826. resultHour = "" + remainHour;
  827. resultMin = "" + remainMin;
  828.  
  829. } else {
  830. resultMin = ""
  831. + (Integer.parseInt(times[1]) - Integer
  832. .parseInt(time2));
  833. }
  834.  
  835. resultTime.add(resultHour + ":" + resultMin + ":" + i);
  836. }
  837.  
  838. }
  839.  
  840. if (resultTime.size() < 1) {
  841. if (currentH > 18) {
  842.  
  843. times = paryer.get(0).split(":");
  844. paryerH = Integer.parseInt(times[0]);
  845. currentH = Integer.parseInt(time1);
  846.  
  847. int time = 24 - currentH;
  848. int totalHour = time + paryerH;
  849. resultHour = "" + totalHour;
  850.  
  851. if ((Integer.parseInt(times[1]) < Integer.parseInt(time2))) {
  852. int remainMin = 60 - Integer.parseInt(time2);
  853. int remainHour = (Integer.parseInt(resultHour));
  854. remainHour--;
  855. remainMin = remainMin + (Integer.parseInt(times[1]));
  856. resultHour = "" + remainHour;
  857. resultMin = "" + remainMin;
  858.  
  859. } else {
  860. resultMin = ""
  861. + (Integer.parseInt(times[1]) - Integer
  862. .parseInt(time2));
  863. }
  864. resultTime.add(resultHour + ":" + resultMin + ":" + 0);
  865.  
  866. } else {
  867. resultHour = "" + (currentH - paryerH);
  868. if ((Integer.parseInt(times[1]) < Integer.parseInt(time2))) {
  869. int remainMin = 60 - Integer.parseInt(time2);
  870. int remainHour = (Integer.parseInt(resultHour));
  871. remainHour--;
  872. remainMin = remainMin + (Integer.parseInt(times[1]));
  873. resultHour = "" + remainHour;
  874. resultMin = "" + remainMin;
  875.  
  876. } else {
  877. resultMin = ""
  878. + (Integer.parseInt(times[1]) - Integer
  879. .parseInt(time2));
  880. }
  881. resultTime.add(resultHour + ":" + resultMin + ":" + 0);
  882.  
  883. }
  884.  
  885. }
  886.  
  887. String mytime = resultTime.get(0);
  888. return mytime;
  889. }
  890.  
  891. public void hightlistParyerTime(int index) {
  892. if (index == 0) {
  893.  
  894. fajarLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
  895. fajarText.setTextColor(getResources().getColor(R.color.pressed));
  896. fajarTime.setTextColor(getResources().getColor(R.color.pressed));
  897. sunRiseText.setTextColor(getResources().getColor(R.color.norm));
  898. ishraTime.setTextColor(getResources().getColor(R.color.norm));
  899. zuharText.setTextColor(getResources().getColor(R.color.norm));
  900. zuharTime.setTextColor(getResources().getColor(R.color.norm));
  901. asarText.setTextColor(getResources().getColor(R.color.norm));
  902. asarTime.setTextColor(getResources().getColor(R.color.norm));
  903. magribText.setTextColor(getResources().getColor(R.color.norm));
  904. margibTime.setTextColor(getResources().getColor(R.color.norm));
  905. ishaText.setTextColor(getResources().getColor(R.color.norm));
  906. ishaTime.setTextColor(getResources().getColor(R.color.norm));
  907. sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  908. zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  909. asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  910. magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  911. ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  912.  
  913. }
  914. if (index == 1) {
  915. fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  916. sunRiseLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
  917. sunRiseText.setTextColor(getResources().getColor(R.color.pressed));
  918. ishraTime.setTextColor(getResources().getColor(R.color.pressed));
  919. fajarText.setTextColor(getResources().getColor(R.color.norm));
  920. fajarTime.setTextColor(getResources().getColor(R.color.norm));
  921. zuharText.setTextColor(getResources().getColor(R.color.norm));
  922. zuharTime.setTextColor(getResources().getColor(R.color.norm));
  923. asarText.setTextColor(getResources().getColor(R.color.norm));
  924. asarTime.setTextColor(getResources().getColor(R.color.norm));
  925. magribText.setTextColor(getResources().getColor(R.color.norm));
  926. margibTime.setTextColor(getResources().getColor(R.color.norm));
  927. ishaText.setTextColor(getResources().getColor(R.color.norm));
  928. ishaTime.setTextColor(getResources().getColor(R.color.norm));
  929. zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  930. asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  931. magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  932. ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  933.  
  934. }
  935. if (index == 2) {
  936. fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  937. sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  938. zuharLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
  939. zuharText.setTextColor(getResources().getColor(R.color.pressed));
  940. zuharTime.setTextColor(getResources().getColor(R.color.pressed));
  941. fajarText.setTextColor(getResources().getColor(R.color.norm));
  942. fajarTime.setTextColor(getResources().getColor(R.color.norm));
  943. sunRiseText.setTextColor(getResources().getColor(R.color.norm));
  944. ishraTime.setTextColor(getResources().getColor(R.color.norm));
  945. asarText.setTextColor(getResources().getColor(R.color.norm));
  946. asarTime.setTextColor(getResources().getColor(R.color.norm));
  947. magribText.setTextColor(getResources().getColor(R.color.norm));
  948. margibTime.setTextColor(getResources().getColor(R.color.norm));
  949. ishaText.setTextColor(getResources().getColor(R.color.norm));
  950. ishaTime.setTextColor(getResources().getColor(R.color.norm));
  951. asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  952. magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  953. ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  954.  
  955. }
  956. if (index == 3) {
  957. fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  958. sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  959. zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  960. asarLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
  961. asarText.setTextColor(getResources().getColor(R.color.pressed));
  962. asarTime.setTextColor(getResources().getColor(R.color.pressed));
  963. fajarText.setTextColor(getResources().getColor(R.color.norm));
  964. fajarTime.setTextColor(getResources().getColor(R.color.norm));
  965. sunRiseText.setTextColor(getResources().getColor(R.color.norm));
  966. ishraTime.setTextColor(getResources().getColor(R.color.norm));
  967. zuharText.setTextColor(getResources().getColor(R.color.norm));
  968. zuharTime.setTextColor(getResources().getColor(R.color.norm));
  969. magribText.setTextColor(getResources().getColor(R.color.norm));
  970. margibTime.setTextColor(getResources().getColor(R.color.norm));
  971. ishaText.setTextColor(getResources().getColor(R.color.norm));
  972. ishaTime.setTextColor(getResources().getColor(R.color.norm));
  973. magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  974. ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  975.  
  976. }
  977. if (index == 4) {
  978. fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  979. sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  980. zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  981. asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  982. magribLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
  983. magribText.setTextColor(getResources().getColor(R.color.pressed));
  984. margibTime.setTextColor(getResources().getColor(R.color.pressed));
  985. fajarText.setTextColor(getResources().getColor(R.color.norm));
  986. fajarTime.setTextColor(getResources().getColor(R.color.norm));
  987. sunRiseText.setTextColor(getResources().getColor(R.color.norm));
  988. ishraTime.setTextColor(getResources().getColor(R.color.norm));
  989. zuharText.setTextColor(getResources().getColor(R.color.norm));
  990. zuharTime.setTextColor(getResources().getColor(R.color.norm));
  991. asarText.setTextColor(getResources().getColor(R.color.norm));
  992. asarTime.setTextColor(getResources().getColor(R.color.norm));
  993. ishaText.setTextColor(getResources().getColor(R.color.norm));
  994. ishaTime.setTextColor(getResources().getColor(R.color.norm));
  995. ishaLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  996.  
  997. }
  998.  
  999. if (index == 5) {
  1000. fajarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  1001. sunRiseLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  1002. zuharLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  1003. asarLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  1004. magribLayout.setBackgroundResource(R.drawable.list_bar_n_slice);
  1005. ishaLayout.setBackgroundResource(R.drawable.list_bar_p_slice);
  1006. ishaText.setTextColor(getResources().getColor(R.color.pressed));
  1007. ishaTime.setTextColor(getResources().getColor(R.color.pressed));
  1008. fajarText.setTextColor(getResources().getColor(R.color.norm));
  1009. fajarTime.setTextColor(getResources().getColor(R.color.norm));
  1010. sunRiseText.setTextColor(getResources().getColor(R.color.norm));
  1011. ishraTime.setTextColor(getResources().getColor(R.color.norm));
  1012. zuharText.setTextColor(getResources().getColor(R.color.norm));
  1013. zuharTime.setTextColor(getResources().getColor(R.color.norm));
  1014. asarText.setTextColor(getResources().getColor(R.color.norm));
  1015. asarTime.setTextColor(getResources().getColor(R.color.norm));
  1016. magribText.setTextColor(getResources().getColor(R.color.norm));
  1017. margibTime.setTextColor(getResources().getColor(R.color.norm));
  1018. }
  1019.  
  1020. }
  1021.  
  1022. public static String setTimeFormat(String time) {
  1023. String newTime = "";
  1024. String formate = "";
  1025. String[] mytime = time.split(":");
  1026. int hour = Integer.parseInt(mytime[0]);
  1027.  
  1028. int hourTime = (hour % 12);
  1029. if (hourTime == 0)
  1030. hourTime = 12;
  1031. newTime = setformate(hourTime + "") + ":" + setformate(mytime[1]);
  1032. return newTime;
  1033. }
  1034.  
  1035. public ArrayList<String> setFormate(ArrayList<String> times) {
  1036. String formate;
  1037. ArrayList<String> str = new ArrayList<String>();
  1038. try {
  1039. for (int i = 0; i < times.size(); i++) {
  1040. String time = times.get(i);
  1041. String[] mytime = time.split(":");
  1042. int hour = Integer.parseInt(mytime[0]);
  1043. if (hour >= 12) {
  1044. formate = ""+ getString(R.string.pm);
  1045. } else {
  1046. formate = ""+ getString(R.string.am);
  1047. }
  1048. str.add(formate);
  1049. }
  1050. } catch (Exception e) {
  1051.  
  1052. }
  1053. return str;
  1054. }
  1055.  
  1056. public static String setformate(String str) {
  1057.  
  1058. if (Integer.parseInt(str) < 10) {
  1059. if (str.length() == 1)
  1060. str = "0" + str;
  1061. }
  1062. return str;
  1063. }
  1064.  
  1065. public void startTimer() {
  1066.  
  1067. timer.scheduleAtFixedRate(new TimerTask() {
  1068.  
  1069. public void run() {
  1070. runOnUiThread(new Runnable() {
  1071. public void run() {
  1072. calculateParyerTime();
  1073. }
  1074.  
  1075. });
  1076. }
  1077.  
  1078. }, 0, 500);
  1079. }
  1080.  
  1081. public void setAlarm(String alarmTime, int alarmId) {
  1082. SetAlarm(this);
  1083. //
  1084. Date date = new Date();
  1085.  
  1086. String[] alram = alarmTime.split(":");
  1087. int hour = Integer.parseInt(alram[0]);
  1088. int min = Integer.parseInt(alram[1]);
  1089.  
  1090. //
  1091. AlarmManager objAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  1092. //
  1093. Calendar now = Calendar.getInstance();
  1094. Calendar objCalendar = Calendar.getInstance();
  1095. int a = objCalendar.get(Calendar.YEAR);
  1096. int b = objCalendar.get(Calendar.MONTH);
  1097. int c = objCalendar.get(Calendar.DAY_OF_MONTH);
  1098. objCalendar.set(a, b, c, hour, min);
  1099. now.setTime(date);
  1100.  
  1101. if (objCalendar.before(now)) {
  1102.  
  1103. objCalendar.set(Calendar.DATE, c + 1);
  1104. // objCalendar.add(Calendar.DATE, 1); //Add 1 day if time selected
  1105. // before now
  1106. }
  1107.  
  1108. Intent alamShowIntent = new Intent(this, AlarmActivity.class);
  1109. alamShowIntent.putExtra("AlramId", "" + alarmId);
  1110. alamShowIntent.putExtra("name", PrayTime.timeNames.get(alarmId));
  1111. alamShowIntent.putExtra("lati", lati);
  1112. alamShowIntent.putExtra("longi", longi);
  1113. alamShowIntent.putExtra("timeZone", timezone);
  1114. alamShowIntent.putExtra("firka", firka);
  1115. PendingIntent alarmPendingIntent = PendingIntent.getActivity(this,
  1116. alarmId, alamShowIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  1117.  
  1118. objAlarmManager.set(AlarmManager.RTC_WAKEUP,
  1119. objCalendar.getTimeInMillis(),
  1120. // objCalendar.getTimeInMillis(),
  1121. alarmPendingIntent);
  1122.  
  1123. }
  1124.  
  1125. public void removeAlarm(String alarmTime, int alarmId) {
  1126.  
  1127. AlarmManager objAlarmManager = (AlarmManager) this
  1128. .getSystemService(Context.ALARM_SERVICE);
  1129.  
  1130. Intent alamShowIntent = new Intent(this, AlarmActivity.class);
  1131. PendingIntent alarmPendingIntent = PendingIntent.getActivity(this,
  1132. alarmId, alamShowIntent, 0);
  1133.  
  1134. objAlarmManager.cancel(alarmPendingIntent);
  1135. }
  1136.  
  1137. public void setListener() {
  1138.  
  1139. /*
  1140. * qiblaLayout.setOnClickListener(new OnClickListener() {
  1141. *
  1142. * public void onClick(View v) { startActivity(new
  1143. * Intent(PrayerTimeActivity.this,QiblaCompass.class)); } });
  1144. *
  1145. *
  1146. * ltcountry.setOnClickListener(new OnClickListener() {
  1147. *
  1148. * public void onClick(View v) { if(!showDialog) { showDialog=true; //
  1149. * menu_dialog.setVisibility(View.GONE); //
  1150. * menu_dialog.setAnimation(upAnimation()); return; } } });
  1151. */
  1152.  
  1153. fajarAudio.setOnClickListener(new OnClickListener() {
  1154.  
  1155. public void onClick(View v) {
  1156. if (!showDialog) {
  1157. showDialog = true;
  1158. // menu_dialog.setVisibility(View.GONE);
  1159. // menu_dialog.setAnimation(upAnimation());
  1160. return;
  1161. }
  1162.  
  1163. int alaramId = 0;
  1164. if (fajarCheck || fajaralarm == "false") {
  1165. fajaralarm = "true";
  1166. String alarmtime = paryerData.get(0);
  1167. setAlarm(alarmtime, 0);
  1168. fajarAudio.setImageResource(R.drawable.sound_on);
  1169. fajarCheck = false;
  1170. } else {
  1171. fajaralarm = "false";
  1172. removeAlarm(paryerData.get(0), 0);
  1173. fajarAudio.setImageResource(R.drawable.sound_off);
  1174. fajarCheck = true;
  1175. }
  1176.  
  1177. }
  1178. });
  1179.  
  1180. sunRiseAudio.setOnClickListener(new OnClickListener() {
  1181.  
  1182. public void onClick(View v) {
  1183. if (!showDialog) {
  1184. showDialog = true;
  1185. // menu_dialog.setVisibility(View.GONE);
  1186. // menu_dialog.setAnimation(upAnimation());
  1187. return;
  1188. }
  1189. }
  1190. });
  1191. zuharAudio.setOnClickListener(new OnClickListener() {
  1192.  
  1193. public void onClick(View v) {
  1194. if (!showDialog) {
  1195. showDialog = true;
  1196. // menu_dialog.setVisibility(View.GONE);
  1197. // menu_dialog.setAnimation(upAnimation());
  1198. return;
  1199. }
  1200.  
  1201. if (zuharCheck || zuharAlarm == "false") {
  1202. zuharAlarm = "true";
  1203. String alarmtime = paryerData.get(2);
  1204. setAlarm(alarmtime, 2);
  1205. zuharAudio.setImageResource(R.drawable.sound_on);
  1206. zuharCheck = false;
  1207. } else {
  1208. zuharAlarm = "false";
  1209. removeAlarm(paryerData.get(2), 2);
  1210. zuharAudio.setImageResource(R.drawable.sound_off);
  1211. zuharCheck = true;
  1212. }
  1213.  
  1214. }
  1215. });
  1216. asarAudio.setOnClickListener(new OnClickListener() {
  1217.  
  1218. public void onClick(View v) {
  1219. if (!showDialog) {
  1220. showDialog = true;
  1221. // menu_dialog.setVisibility(View.GONE);
  1222. // menu_dialog.setAnimation(upAnimation());
  1223. return;
  1224. }
  1225.  
  1226. if (asarCheck || asarAlarm == "false") {
  1227. asarAlarm = "true";
  1228. String alarmtime = paryerData.get(3);
  1229. setAlarm(alarmtime, 3);
  1230. asarAudio.setImageResource(R.drawable.sound_on);
  1231. asarCheck = false;
  1232. } else {
  1233. asarAlarm = "false";
  1234. removeAlarm(paryerData.get(3), 3);
  1235. asarAudio.setImageResource(R.drawable.sound_off);
  1236. asarCheck = true;
  1237. }
  1238.  
  1239. }
  1240. });
  1241. magribAudio.setOnClickListener(new OnClickListener() {
  1242.  
  1243. public void onClick(View v) {
  1244. if (!showDialog) {
  1245. showDialog = true;
  1246. // menu_dialog.setVisibility(View.GONE);
  1247. // menu_dialog.setAnimation(upAnimation());
  1248. return;
  1249. }
  1250.  
  1251. if (magribCheck || magribAlarm == "false") {
  1252. magribAlarm = "true";
  1253. String alarmtime = paryerData.get(4);
  1254. setAlarm(alarmtime, 4);
  1255. magribAudio.setImageResource(R.drawable.sound_on);
  1256. magribCheck = false;
  1257. } else {
  1258. magribAlarm = "false";
  1259. removeAlarm(paryerData.get(4), 4);
  1260. magribAudio.setImageResource(R.drawable.sound_off);
  1261. magribCheck = true;
  1262. }
  1263.  
  1264. }
  1265.  
  1266. });
  1267.  
  1268. ishaAudio.setOnClickListener(new OnClickListener() {
  1269.  
  1270. public void onClick(View v) {
  1271. if (!showDialog) {
  1272. showDialog = true;
  1273. // menu_dialog.setVisibility(View.GONE);
  1274. // menu_dialog.setAnimation(upAnimation());
  1275. return;
  1276. }
  1277.  
  1278. if (ishaCheck || ishaAlarm == "false") {
  1279. ishaAlarm = "true";
  1280. String alarmtime = paryerData.get(5);
  1281. setAlarm(alarmtime, 5);
  1282. ishaAudio.setImageResource(R.drawable.sound_on);
  1283. ishaCheck = false;
  1284. } else {
  1285. ishaAlarm = "false";
  1286. removeAlarm(paryerData.get(5), 5);
  1287. ishaAudio.setImageResource(R.drawable.sound_off);
  1288. ishaCheck = true;
  1289. }
  1290.  
  1291. }
  1292. });
  1293.  
  1294. fajarLayout.setOnClickListener(new OnClickListener() {
  1295.  
  1296. public void onClick(View v) {
  1297. if (!showDialog) {
  1298. showDialog = true;
  1299. // menu_dialog.setVisibility(View.GONE);
  1300. // menu_dialog.setAnimation(upAnimation());
  1301. return;
  1302. }
  1303.  
  1304. ;
  1305. customDialog.showDialog(getString(R.string.fajar));
  1306. // startActivity(new
  1307. // Intent(PrayerTimeActivity.this,AlarmActivity.class));
  1308.  
  1309. }
  1310. });
  1311.  
  1312. sunRiseLayout.setOnClickListener(new OnClickListener() {
  1313.  
  1314. public void onClick(View v) {
  1315. if (!showDialog) {
  1316. showDialog = true;
  1317. // menu_dialog.setVisibility(View.GONE);
  1318. // menu_dialog.setAnimation(upAnimation());
  1319. return;
  1320. }
  1321. ;
  1322. customDialog.showDialog(getString(R.string.sunrise));
  1323.  
  1324. }
  1325. });
  1326.  
  1327. zuharLayout.setOnClickListener(new OnClickListener() {
  1328.  
  1329. public void onClick(View v) {
  1330. if (!showDialog) {
  1331. showDialog = true;
  1332. // menu_dialog.setVisibility(View.GONE);
  1333. // menu_dialog.setAnimation(upAnimation());
  1334. return;
  1335. }
  1336. ;
  1337. customDialog.showDialog(getString(R.string.zuhar));
  1338.  
  1339. }
  1340. });
  1341. asarLayout.setOnClickListener(new OnClickListener() {
  1342.  
  1343. public void onClick(View v) {
  1344. if (!showDialog) {
  1345. showDialog = true;
  1346. // menu_dialog.setVisibility(View.GONE);
  1347. // menu_dialog.setAnimation(upAnimation());
  1348. return;
  1349. }
  1350. ;
  1351. customDialog.showDialog(getString(R.string.asar));
  1352.  
  1353. }
  1354. });
  1355.  
  1356. magribLayout.setOnClickListener(new OnClickListener() {
  1357.  
  1358. public void onClick(View v) {
  1359. if (!showDialog) {
  1360. showDialog = true;
  1361. // /menu_dialog.setVisibility(View.GONE);
  1362. // menu_dialog.setAnimation(upAnimation());
  1363. return;
  1364. }
  1365. ;
  1366. customDialog.showDialog(getString(R.string.maghrib));
  1367.  
  1368. }
  1369. });
  1370.  
  1371. ishaLayout.setOnClickListener(new OnClickListener() {
  1372.  
  1373. public void onClick(View v) {
  1374. if (!showDialog) {
  1375. showDialog = true;
  1376. return;
  1377. }
  1378. ;
  1379. customDialog.showDialog(getString(R.string.isha));
  1380.  
  1381. }
  1382. });
  1383.  
  1384. imgPrayer.setOnClickListener(new OnClickListener() {
  1385.  
  1386. public void onClick(View v) {
  1387. if (!showDialog) {
  1388. showDialog = true;
  1389. return;
  1390. }
  1391. prayerLayout
  1392. .setBackgroundResource(R.drawable.footer_tab_select_line);
  1393. qiblaLayout
  1394. .setBackgroundResource(R.drawable.footer_tab_unselect_line);
  1395. settingLayout
  1396. .setBackgroundResource(R.drawable.footer_tab_unselect_line);
  1397.  
  1398. }
  1399. });
  1400. imgQibla.setOnClickListener(new OnClickListener() {
  1401.  
  1402. public void onClick(View v) {
  1403. if (!showDialog) {
  1404. showDialog = true;
  1405. return;
  1406. }
  1407. prayerLayout
  1408. .setBackgroundResource(R.drawable.footer_tab_unselect_line);
  1409. qiblaLayout
  1410. .setBackgroundResource(R.drawable.footer_tab_select_line);
  1411. settingLayout
  1412. .setBackgroundResource(R.drawable.footer_tab_unselect_line);
  1413. PrayerTimeActivity.this.finish();
  1414. startActivity(new Intent(PrayerTimeActivity.this,
  1415. QiblaCompass.class));
  1416. }
  1417. });
  1418. imgSettings.setOnClickListener(new OnClickListener() {
  1419.  
  1420. public void onClick(View v) {
  1421. if (!showDialog) {
  1422. showDialog = true;
  1423. // menu_dialog.setVisibility(View.GONE);
  1424. // menu_dialog.setAnimation(upAnimation());
  1425. return;
  1426. }
  1427. prayerLayout
  1428. .setBackgroundResource(R.drawable.footer_tab_unselect_line);
  1429. qiblaLayout
  1430. .setBackgroundResource(R.drawable.footer_tab_unselect_line);
  1431. settingLayout
  1432. .setBackgroundResource(R.drawable.footer_tab_select_line);
  1433.  
  1434. PrayerTimeActivity.this.finish();
  1435. startActivity(new Intent(getApplicationContext(),
  1436. Settings.class));
  1437. }
  1438. });
  1439.  
  1440. }
  1441.  
  1442. public boolean onKeyDown(int keyCode, KeyEvent event) {
  1443. if (keyCode == KeyEvent.KEYCODE_BACK) {
  1444. // ShowRateDialog();
  1445. // Widget.pushWidgetUpdate(getApplicationContext());
  1446. exitDialog();
  1447.  
  1448. return false;
  1449. }
  1450. if (keyCode == KeyEvent.KEYCODE_MENU) {
  1451. showMenu();
  1452. }
  1453.  
  1454. return super.onKeyDown(keyCode, event);
  1455. }
  1456.  
  1457. public void showMenu() {
  1458. if (showDialog) {
  1459. showDialog = false;
  1460. // menu_dialog.setVisibility(View.VISIBLE);
  1461. // menu_dialog.setAnimation(downAnimation());
  1462. } else {
  1463. showDialog = true;
  1464. // menu_dialog.setVisibility(View.GONE);
  1465. // menu_dialog.setAnimation(upAnimation());
  1466. }
  1467.  
  1468. }
  1469.  
  1470. private void exitDialog() {
  1471. final Dialog exitDialog = new Dialog(this);
  1472. exitDialog.setCancelable(false);
  1473. exitDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  1474. exitDialog.setContentView(R.layout.exitdialog);
  1475. exitDialog.getWindow().setBackgroundDrawable(
  1476. new ColorDrawable(android.graphics.Color.TRANSPARENT));
  1477.  
  1478. TextView laterbtn = (TextView) exitDialog.findViewById(R.id.ok);
  1479. TextView likebtn = (TextView) exitDialog.findViewById(R.id.Cancel);
  1480. laterbtn.setOnClickListener(new OnClickListener() {
  1481.  
  1482. public void onClick(View arg0) {
  1483.  
  1484. PrayerTimeActivity.this.finish();
  1485. exitDialog.cancel();
  1486. exitDialog.dismiss();
  1487. }
  1488. });
  1489. likebtn.setOnClickListener(new OnClickListener() {
  1490.  
  1491. public void onClick(View v) {
  1492.  
  1493. exitDialog.cancel();
  1494. exitDialog.dismiss();
  1495. }
  1496. });
  1497.  
  1498. exitDialog.show();
  1499. }
  1500.  
  1501. public String getIslamicTime(int g_y, int g_m, int g_d) {
  1502. int year, month, day;
  1503.  
  1504. int zyr;
  1505. int zd;
  1506. int zm;
  1507. int zy;
  1508.  
  1509. float zjd;
  1510. int zl;
  1511. int zn;
  1512. int zj;
  1513.  
  1514. year = g_y;
  1515. month = g_m;
  1516. day = g_d;
  1517.  
  1518. zyr = year;
  1519. zd = day;
  1520. zm = month;
  1521. zy = zyr;
  1522.  
  1523. if ((zy > 1582) || ((zy == 1582) && (zm > 10))
  1524. || ((zy == 1582) && (zm == 10) && (zd > 14))) {
  1525. zjd = ((1461 * (zy + 4800 + ((zm - 14) / 12))) / 4)
  1526. + ((367 * (zm - 2 - 12 * (((zm - 14) / 12)))) / 12)
  1527. - ((3 * (((zy + 4900 + ((zm - 14) / 12)) / 100))) / 4) + zd
  1528. - 32075;
  1529. } else {
  1530. zjd = 367 * zy - ((7 * (zy + 5001 + ((zm - 9) / 7))) / 4)
  1531. + ((275 * zm) / 9) + zd + 1729777;
  1532. }
  1533.  
  1534. zl = (int) (zjd - 1948440 + 10632);
  1535. zn = ((zl - 1) / 10631);
  1536. zl = zl - 10631 * zn + 354;
  1537. zj = (((10985 - zl) / 5316)) * ((int) ((50 * zl) / 17719))
  1538. + ((zl / 5670)) * ((int) ((43 * zl) / 15238));
  1539.  
  1540. zl = zl - (((30 - zj) / 15)) * (((17719 * zj) / 50)) - ((zj / 16))
  1541. * (((15238 * zj) / 43)) + 29;
  1542.  
  1543. zm = ((24 * zl) / 709);
  1544. zd = zl - ((709 * zm) / 24);
  1545. zy = 30 * zn + zj - 30;
  1546.  
  1547. return "" + zd + " " + hijriMonthName[zm - 1] + " " + zy;
  1548. }
  1549.  
  1550. public void initGui() {
  1551.  
  1552. // qiblaLayout=(LinearLayout) findViewById(R.id.qiblaLayout);
  1553.  
  1554. // qiblaDirection = (TextView) findViewById(R.id.qiblaDireation);
  1555. // qiblaDirection.setSelected(true);
  1556. fajarTime = (TextView) findViewById(R.id.fajarTime);
  1557. ishraTime = (TextView) findViewById(R.id.IshraTime);
  1558. zuharTime = (TextView) findViewById(R.id.zuharTime);
  1559. asarTime = (TextView) findViewById(R.id.asarTime);
  1560. islmaicTimeText = (TextView) findViewById(R.id.islmaicTime);
  1561. margibTime = (TextView) findViewById(R.id.magribTime);
  1562. ishaTime = (TextView) findViewById(R.id.IshaTime);
  1563. countryText = (TextView) findViewById(R.id.conturyText);
  1564. countryText.setSelected(true);
  1565. // cityText = (TextView) findViewById(R.id.cityText);
  1566. // cityText.setSelected(true);
  1567. dateText = (TextView) findViewById(R.id.dateText);// citySpinner=(Spinner)findViewById(R.id.citySpinner);
  1568. timeText = (TextView) findViewById(R.id.timeText);//
  1569. // ltcountry = (LinearLayout) findViewById(R.id.ltcountry);
  1570. diffText = (TextView) findViewById(R.id.diffText);
  1571. fajarText = (TextView) findViewById(R.id.fajarText);
  1572. sunRiseText = (TextView) findViewById(R.id.IshraText);
  1573. zuharText = (TextView) findViewById(R.id.zuharText);
  1574. asarText = (TextView) findViewById(R.id.asarText);
  1575. magribText = (TextView) findViewById(R.id.magribText);
  1576. ishaText = (TextView) findViewById(R.id.IshaText);
  1577.  
  1578. fajarAudio = (ImageView) findViewById(R.id.audiofajar);
  1579. sunRiseAudio = (ImageView) findViewById(R.id.audiosunRise);
  1580. zuharAudio = (ImageView) findViewById(R.id.audioZuhar);
  1581. asarAudio = (ImageView) findViewById(R.id.audioAsar);
  1582. magribAudio = (ImageView) findViewById(R.id.audioMagrib);
  1583. ishaAudio = (ImageView) findViewById(R.id.audioIsha);
  1584.  
  1585. fajarLayout = (LinearLayout) findViewById(R.id.fajarLayout);
  1586. sunRiseLayout = (LinearLayout) findViewById(R.id.sunRiseLayout);
  1587. zuharLayout = (LinearLayout) findViewById(R.id.zuharLayout);
  1588. asarLayout = (LinearLayout) findViewById(R.id.asarLayout);
  1589. magribLayout = (LinearLayout) findViewById(R.id.magribLayout);
  1590. ishaLayout = (LinearLayout) findViewById(R.id.ishaLayout);
  1591. prayerLayout = (LinearLayout) findViewById(R.id.LayoutImagePrayer);
  1592. qiblaLayout = (LinearLayout) findViewById(R.id.LayoutImageQibla);
  1593. settingLayout = (LinearLayout) findViewById(R.id.LayoutImageSettings);
  1594.  
  1595. imgPrayer = (ImageView) findViewById(R.id.imgPrayer);
  1596. imgQibla = (ImageView) findViewById(R.id.imgQibla);
  1597. imgSettings = (ImageView) findViewById(R.id.imgSettings);
  1598. scrollView = (ScrollView) findViewById(R.id.scrollView);
  1599. // imgCalendar = (ImageView)findViewById(R.id.imgCalendar);
  1600. // imgMore = (ImageView)findViewById(R.id.imgMore);
  1601. }
  1602.  
  1603. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement