Skip to content

Commit

Permalink
Rename SpinnerCompat to QuranSpinner
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Sep 1, 2016
1 parent 20ab43d commit d58b118
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.quran.labs.androidquran.ui.PagerActivity;
import com.quran.labs.androidquran.ui.helpers.HighlightType;
import com.quran.labs.androidquran.util.QuranUtils;
import com.quran.labs.androidquran.widgets.spinner.SpinnerCompat;
import com.quran.labs.androidquran.widgets.QuranSpinner;

public class AyahPlaybackFragment extends AyahActionFragment {
private static final int REPEAT_MAX = 3;
Expand All @@ -33,12 +33,12 @@ public class AyahPlaybackFragment extends AyahActionFragment {
private int mVerseRepeatCount;

private Button mApplyButton;
private SpinnerCompat mStartSuraSpinner;
private SpinnerCompat mStartAyahSpinner;
private SpinnerCompat mEndingSuraSpinner;
private SpinnerCompat mEndingAyahSpinner;
private SpinnerCompat mRepeatVerseSpinner;
private SpinnerCompat mRepeatRangeSpinner;
private QuranSpinner mStartSuraSpinner;
private QuranSpinner mStartAyahSpinner;
private QuranSpinner mEndingSuraSpinner;
private QuranSpinner mEndingAyahSpinner;
private QuranSpinner mRepeatVerseSpinner;
private QuranSpinner mRepeatRangeSpinner;
private CheckBox mRestrictToRange;
private ArrayAdapter<CharSequence> mStartAyahAdapter;
private ArrayAdapter<CharSequence> mEndingAyahAdapter;
Expand All @@ -50,13 +50,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
R.layout.audio_panel, container, false);
view.setOnClickListener(mOnClickListener);

mStartSuraSpinner = (SpinnerCompat) view.findViewById(R.id.start_sura_spinner);
mStartAyahSpinner = (SpinnerCompat) view.findViewById(R.id.start_ayah_spinner);
mEndingSuraSpinner = (SpinnerCompat) view.findViewById(R.id.end_sura_spinner);
mEndingAyahSpinner = (SpinnerCompat) view.findViewById(R.id.end_ayah_spinner);
mRepeatVerseSpinner = (SpinnerCompat) view
mStartSuraSpinner = (QuranSpinner) view.findViewById(R.id.start_sura_spinner);
mStartAyahSpinner = (QuranSpinner) view.findViewById(R.id.start_ayah_spinner);
mEndingSuraSpinner = (QuranSpinner) view.findViewById(R.id.end_sura_spinner);
mEndingAyahSpinner = (QuranSpinner) view.findViewById(R.id.end_ayah_spinner);
mRepeatVerseSpinner = (QuranSpinner) view
.findViewById(R.id.repeat_verse_spinner);
mRepeatRangeSpinner = (SpinnerCompat) view
mRepeatRangeSpinner = (QuranSpinner) view
.findViewById(R.id.repeat_range_spinner);
mRestrictToRange = (CheckBox) view.findViewById(R.id.restrict_to_range);
mApplyButton = (Button) view.findViewById(R.id.apply);
Expand Down Expand Up @@ -174,7 +174,7 @@ private void apply() {
}

private void initializeSuraSpinner(final Context context,
SpinnerCompat spinner, final ArrayAdapter<CharSequence> ayahAdapter) {
QuranSpinner spinner, final ArrayAdapter<CharSequence> ayahAdapter) {
String[] suras = context.getResources().
getStringArray(R.array.sura_names);
for (int i=0; i<suras.length; i++){
Expand Down Expand Up @@ -210,15 +210,15 @@ public void onNothingSelected(AdapterView<?> arg0) {
}

private ArrayAdapter<CharSequence> initializeAyahSpinner(
Context context, SpinnerCompat spinner) {
Context context, QuranSpinner spinner) {
final ArrayAdapter<CharSequence> ayahAdapter =
new ArrayAdapter<>(context, ITEM_LAYOUT);
ayahAdapter.setDropDownViewResource(ITEM_DROPDOWN_LAYOUT);
spinner.setAdapter(ayahAdapter);
return ayahAdapter;
}

private void updateAyahSpinner(SpinnerCompat spinner,
private void updateAyahSpinner(QuranSpinner spinner,
ArrayAdapter<CharSequence> adapter,
int maxAyah, int currentAyah) {
final Context context = getActivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.quran.labs.androidquran.ui.util.TranslationsSpinnerAdapter;
import com.quran.labs.androidquran.util.QuranSettings;
import com.quran.labs.androidquran.widgets.TranslationView;
import com.quran.labs.androidquran.widgets.spinner.SpinnerCompat;
import com.quran.labs.androidquran.widgets.QuranSpinner;

import java.util.List;

Expand All @@ -31,7 +31,7 @@ public class AyahTranslationFragment extends AyahActionFragment {
private AsyncTask mCurrentTask;
private LocalTranslation mTranslationItem;
private View mTranslationControls;
private SpinnerCompat mTranslator;
private QuranSpinner mTranslator;
private TranslationsSpinnerAdapter mTranslationAdapter;
private List<LocalTranslation> mTranslations;

Expand All @@ -41,7 +41,7 @@ public View onCreateView(LayoutInflater inflater,
final View view = inflater.inflate(
R.layout.translation_panel, container, false);

mTranslator = (SpinnerCompat) view.findViewById(R.id.translator);
mTranslator = (QuranSpinner) view.findViewById(R.id.translator);
mTranslationView =
(TranslationView) view.findViewById(R.id.translation_view);
mTranslationView.setIsInAyahActionMode(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.quran.labs.androidquran.ui.PagerActivity;
import com.quran.labs.androidquran.ui.QuranActivity;
import com.quran.labs.androidquran.util.QuranUtils;
import com.quran.labs.androidquran.widgets.spinner.SpinnerCompat;
import com.quran.labs.androidquran.widgets.QuranSpinner;

import timber.log.Timber;

Expand All @@ -48,7 +48,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
builder.setTitle(activity.getString(R.string.menu_jump));

// Sura Spinner
final SpinnerCompat suraSpinner = (SpinnerCompat) layout.findViewById(R.id.sura_spinner);
final QuranSpinner suraSpinner = (QuranSpinner) layout.findViewById(R.id.sura_spinner);
String[] suras = activity.getResources().getStringArray(R.array.sura_names);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < suras.length; i++) {
Expand All @@ -64,7 +64,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
suraSpinner.setAdapter(adapter);

// Ayah Spinner
final SpinnerCompat ayahSpinner = (SpinnerCompat) layout.findViewById(R.id.ayah_spinner);
final QuranSpinner ayahSpinner = (QuranSpinner) layout.findViewById(R.id.ayah_spinner);
final ArrayAdapter<CharSequence> ayahAdapter =
new ArrayAdapter<CharSequence>(activity, android.R.layout.simple_spinner_item) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.quran.labs.androidquran.util.QuranScreenInfo;
import com.quran.labs.androidquran.util.QuranSettings;
import com.quran.labs.androidquran.util.QuranUtils;
import com.quran.labs.androidquran.widgets.spinner.SpinnerCompat;

import java.util.List;

Expand Down Expand Up @@ -62,7 +61,7 @@ public class AudioStatusBar extends LinearLayout {
private boolean mHaveCriticalError = false;
private SharedPreferences mSharedPreferences;

private SpinnerCompat mSpinner;
private QuranSpinner mSpinner;
private TextView mProgressText;
private ProgressBar mProgressBar;
private RepeatButton mRepeatButton;
Expand Down Expand Up @@ -283,7 +282,7 @@ private View getViewInternal(int position, View convertView,

private void addSpinner() {
if (mSpinner == null) {
mSpinner = new SpinnerCompat(mContext, null,
mSpinner = new QuranSpinner(mContext, null,
R.attr.actionDropDownStyle);
mSpinner.setDropDownVerticalOffset(mSpinnerPadding);
mSpinner.setAdapter(mAdapter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.quran.labs.androidquran.widgets.spinner;
package com.quran.labs.androidquran.widgets;

import android.content.Context;
import android.support.v7.widget.AppCompatSpinner;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SpinnerAdapter;

public class SpinnerCompat extends AppCompatSpinner {
/**
* An {@link AppCompatSpinner} that uses the last items in an adapter and a multiplier to
* determine the width of the Spinner and its dropdown.
*
* AppCompatSpinner uses the measurement of the first 15 items to determine the width.
*/
public class QuranSpinner extends AppCompatSpinner {
private static final int MAX_ITEMS_MEASURED = 15;
private static final float WIDTH_MULTIPLIER = 1.1f;

private SpinnerAdapter adapter;

public SpinnerCompat(Context context) {
public QuranSpinner(Context context) {
super(context);
}

public SpinnerCompat(Context context, AttributeSet attrs) {
public QuranSpinner(Context context, AttributeSet attrs) {
super(context, attrs);
}

public SpinnerCompat(Context context, AttributeSet attrs, int defStyleAttr) {
public QuranSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

Expand Down Expand Up @@ -92,7 +83,7 @@ private int calculateWidth() {
itemView.measure(widthMeasureSpec, heightMeasureSpec);
width = Math.max(width, itemView.getMeasuredWidth());
}
width *= 1.1; // add some extra spacing
width *= WIDTH_MULTIPLIER; // add some extra spacing
return width;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 6 additions & 6 deletions app/src/main/res/layout-ar-land/audio_panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
android:layout_weight="1"
android:gravity="end"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/end_ayah_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="rtl" />
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/end_sura_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -65,12 +65,12 @@
android:layout_weight="1"
android:gravity="end"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/start_ayah_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="rtl" />
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/start_sura_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -84,7 +84,7 @@
android:layout_marginBottom="16dp"
android:orientation="horizontal"
android:layout_gravity="end">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/repeat_range_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -103,7 +103,7 @@
android:layout_marginBottom="16dp"
android:orientation="horizontal"
android:layout_gravity="end">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/repeat_verse_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout-ar/audio_panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
android:layout_marginBottom="12dp"
android:layout_gravity="end"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/start_ayah_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="rtl" />
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/start_sura_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -46,12 +46,12 @@
android:layout_marginBottom="12dp"
android:layout_gravity="end"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/end_ayah_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layoutDirection="rtl" />
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/end_sura_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -64,7 +64,7 @@
android:layout_marginBottom="12dp"
android:layout_gravity="end"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/repeat_range_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -83,7 +83,7 @@
android:layout_marginBottom="12dp"
android:layout_gravity="end"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/repeat_verse_spinner"
android:layoutDirection="rtl"
android:layout_width="wrap_content"
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout-land/audio_panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/start_sura_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/start_ayah_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Expand All @@ -59,11 +59,11 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/end_sura_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/end_ayah_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Expand All @@ -81,7 +81,7 @@
android:layout_gravity="center_vertical"
android:text="@string/play_verses_range"
android:textAppearance="@style/PanelLabel"/>
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/repeat_range_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Expand All @@ -98,7 +98,7 @@
android:layout_gravity="center_vertical"
android:text="@string/play_each_verse"
android:textAppearance="@style/PanelLabel"/>
<com.quran.labs.androidquran.widgets.spinner.SpinnerCompat
<com.quran.labs.androidquran.widgets.QuranSpinner
android:id="@+id/repeat_verse_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Expand Down
Loading

0 comments on commit d58b118

Please sign in to comment.